ModellistAction.class.php (2402B)
1 <?php 2 3 namespace cms\action; 4 5 use cms\model\Model; 6 use cms\model\Project; 7 use Html; 8 use Session; 9 10 // OpenRat Content Management System 11 // Copyright (C) 2002-2012 Jan Dankert, cms@jandankert.de 12 // 13 // This program is free software; you can redistribute it and/or 14 // modify it under the terms of the GNU General Public License 15 // as published by the Free Software Foundation; either version 2 16 // of the License, or (at your option) any later version. 17 // 18 // This program is distributed in the hope that it will be useful, 19 // but WITHOUT ANY WARRANTY; without even the implied warranty of 20 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 // GNU General Public License for more details. 22 // 23 // You should have received a copy of the GNU General Public License 24 // along with this program; if not, write to the Free Software 25 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 26 27 28 /** 29 * Action-Klasse zum Bearbeiten eines Projetmodells 30 * 31 * @author Jan Dankert 32 * @package openrat.actions 33 */ 34 class ModellistAction extends BaseAction 35 { 36 /** 37 * @var Project 38 */ 39 public $project; 40 41 public $security = Action::SECURITY_USER; 42 43 44 function __construct() 45 { 46 parent::__construct(); 47 } 48 49 50 public function init() 51 { 52 53 $this->project = new Project( $this->request->getRequestId()); 54 } 55 56 57 function showView() 58 { 59 $project = new Project( $this->project->projectid ); 60 61 $list = array(); 62 foreach( $project->getModelIds() as $id ) 63 { 64 $m = new Model( $id ); 65 $m->load(); 66 67 $list[$id]['id' ] = $id; 68 $list[$id]['name'] = $m->name; 69 70 $list[$id]['is_default'] = $m->isDefault; 71 $list[$id]['select_url'] = Html::url('index','model',$id); 72 } 73 $this->setTemplateVar( 'el',$list ); 74 $this->setTemplateVar( 'add',$this->userIsAdmin() ); 75 } 76 77 78 /** 79 * Bearbeiten der Variante. 80 * Ermitteln aller Eigenschaften der Variante. 81 */ 82 function editView() 83 { 84 $this->nextSubAction('show'); 85 } 86 87 88 89 90 function addView() 91 { 92 } 93 94 95 function addPost() 96 { 97 $model = new Model(); 98 $model->projectid = $this->getRequestVar('projectid'); 99 $model->name = $this->getRequestVar('name'); 100 $model->add(); 101 102 // Wenn kein Namen eingegeben, dann einen setzen. 103 if ( empty($model->name) ) 104 { 105 // Name ist "Variante <id>" 106 $model->name = lang('MODEL').' '.$model->modelid; 107 $model->save(); 108 } 109 } 110 111 }