ModelAction.class.php (2839B)
1 <?php 2 3 namespace cms\action; 4 5 use cms\model\Model; 6 7 8 9 use Session; 10 use \Html; 11 12 // OpenRat Content Management System 13 // Copyright (C) 2002-2012 Jan Dankert, cms@jandankert.de 14 // 15 // This program is free software; you can redistribute it and/or 16 // modify it under the terms of the GNU General Public License 17 // as published by the Free Software Foundation; either version 2 18 // of the License, or (at your option) any later version. 19 // 20 // This program is distributed in the hope that it will be useful, 21 // but WITHOUT ANY WARRANTY; without even the implied warranty of 22 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 23 // GNU General Public License for more details. 24 // 25 // You should have received a copy of the GNU General Public License 26 // along with this program; if not, write to the Free Software 27 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 28 29 30 /** 31 * Action-Klasse zum Bearbeiten eines Projetmodells 32 * @author $Author$ 33 * @version $Revision$ 34 * @package openrat.actions 35 */ 36 class ModelAction extends BaseAction 37 { 38 public $security = Action::SECURITY_USER; 39 40 /** 41 * @var Model 42 */ 43 private $model; 44 45 46 function __construct() 47 { 48 parent::__construct(); 49 50 } 51 52 53 public function init() 54 { 55 $this->model = new Model( $this->getRequestId() ); 56 $this->model->load(); 57 } 58 59 60 61 public function propView() 62 { 63 $this->setTemplateVar('name' ,$this->model->name ); 64 $this->setTemplateVar('is_default',$this->model->isDefault ); 65 } 66 67 68 69 /** 70 * Speichern der Sprache 71 */ 72 public function propPost() 73 { 74 if ( $this->hasRequestVar('name') ) { 75 $this->model->name = $this->getRequestVar('name'); 76 $this->model->save(); 77 } 78 79 if ( $this->hasRequestVar('is_default') ) 80 $this->model->setDefault(); 81 82 $this->addNotice('model',$this->model->name,'DONE',OR_NOTICE_OK); 83 } 84 85 86 /** 87 * Entfernen der Variante.<br> 88 * Es wird ein Best�tigungsdialog angezeigt. 89 */ 90 function removeView() 91 { 92 $this->model->load(); 93 94 $this->setTemplateVar( 'name',$this->model->name ); 95 } 96 97 98 /** 99 * Löschen des Models. 100 */ 101 function removePost() 102 { 103 if ( $this->hasRequestVar('confirm') ) 104 { 105 $this->model->delete(); 106 $this->addNotice('model',$this->model->name,'DONE',OR_NOTICE_OK); 107 } 108 else 109 { 110 $this->addNotice('model',$this->model->name,'NOTHING_DONE',OR_NOTICE_WARN); 111 } 112 } 113 114 115 116 function setdefaultPost() 117 { 118 if ( !$this->userIsAdmin() ) exit(); 119 120 $this->model->setDefault(); 121 122 $this->addNotice('model',$this->model->name,'DONE',OR_NOTICE_OK); 123 } 124 125 126 /** 127 * Bearbeiten der Variante. 128 * Ermitteln aller Eigenschaften der Variante. 129 */ 130 public function infoView() 131 { 132 $this->model->load(); 133 134 $this->setTemplateVars( $this->model->getProperties() ); 135 } 136 }