芝麻web文件管理V1.00
编辑当前文件:/home/p/r/i/prismawe/www/resuamer/site/application/classes/controller/admin/theme.php
template->admin = $admin; $this->template->menuActif = Controller_Admin_Accueil::menuThemes(); $this->template->content = null; if ($this->request->is_initial()) $this->tpl = & $this->template->content; else $this->tpl = & $this->template; } public function action_index() { $this->tpl = View::factory('admin/theme/index'); $this->tpl->themes = ORM::factory('theme')->find_all(); } public function action_modifier(){ $id = $this->request->param('id'); if($id != ''){ $theme = ORM::factory('theme', $id); if(!$theme->loaded()){ //le theme sélectionné n'existe pas $_SESSION['erreur'][] = 'theme existe pas'; $this->request->redirect(Route::get('admin')->uri(array('controller'=>'theme','action' => 'index'))); } }else{ //c'est une création $theme = ORM::factory('theme'); } if(count($_POST)>0){ //on tarite le formulaire //on traite les donnée non traduite $theme->save(); //$_SESSION['info'][] = $theme->getId(); $langues = ORM::factory('lang')->find_all(); foreach($langues as $langue){ //on traite les donnée traduite $themelang = ORM::factory('themelang') ->where('theme_id', '=', $theme->getId()) ->and_where('lang_id', '=', $langue->getId()) ->find(); if(!$themelang->loaded()){ $themelang->setTheme_id($theme->getId()); $themelang->setLang_id($langue->getId()); } $libelle = $this->request->post('libelle_'.$langue->getId()); $description = $this->request->post('description_'.$langue->getId()); if($libelle != '' && $description != ''){ $themelang->setLibelle($libelle); $themelang->setDescription($description); $themelang->save(); } } $_SESSION['info'][] = 'saved'; $this->request->redirect(Route::get('admin')->uri(array('controller'=>'theme','action' => 'index'))); } $this->tpl = View::factory('admin/theme/modifier'); $this->tpl->theme = $theme; $this->tpl->langues = ORM::factory('lang')->find_all(); $this->tpl->id = $theme->getId(); } public function action_supprimer(){ $id = $this->request->param('id'); $theme = ORM::factory('theme', $id); if(!$theme->loaded()){ //le theme sélectionné n'existe pas $_SESSION['erreur'][] = 'theme existe pas'; $this->request->redirect(Route::get('admin')->uri(array('controller'=>'theme','action' => 'index'))); }else{ //on supprime le theme $theme->delete(); $_SESSION['info'][] = 'Theme suprimée'; $this->request->redirect(Route::get('admin')->uri(array('controller'=>'theme','action' => 'index'))); } } }