LanguagelistAction.class.php (2890B)
1 <?php 2 3 namespace cms\action; 4 5 use cms\model\Language; 6 7 8 use cms\model\Project; 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 f?r die Bearbeitung einer Sprache 32 * @version $Id$ 33 * @author $Author$ 34 * @package openrat.actions 35 */ 36 class LanguagelistAction extends BaseAction 37 { 38 public $security = Action::SECURITY_USER; 39 40 /** 41 * @var Project 42 */ 43 private $project; 44 45 46 /** 47 * Konstruktor 48 */ 49 function __construct() 50 { 51 parent::__construct(); 52 53 } 54 55 56 public function init() 57 { 58 59 $this->project = new Project( $this->request->getRequestId()); 60 } 61 62 63 64 public function showView() 65 { 66 global $conf; 67 $countryList = $conf['countries']; 68 69 $list = array(); 70 71 $this->setTemplateVar('act_languageid',0 ); 72 73 74 75 foreach( $this->project->getLanguageIds() as $id ) 76 { 77 $l = new Language( $id ); 78 $l->load(); 79 80 unset( $countryList[strtoupper($l->isoCode)] ); 81 82 $list[$id] = array(); 83 $list[$id]['name' ] = $l->name; 84 $list[$id]['isocode'] = $l->isoCode; 85 $list[$id]['id' ] = $id; 86 87 $list[$id]['is_default'] = $l->isDefault; 88 89 $list[$id]['select_url'] = Html::url( 'index','language',$id ); 90 } 91 92 $this->setTemplateVar('el',$list); 93 } 94 95 96 97 function editView() 98 { 99 $this->nextSubAction('show'); 100 } 101 102 103 104 105 /** 106 * Sprache hinzufuegen 107 */ 108 function addView() 109 { 110 global $conf; 111 $countryList = $conf['countries']; 112 113 foreach( $this->project->getLanguageIds() as $id ) 114 { 115 116 $l = new Language( $id ); 117 $l->load(); 118 119 unset( $countryList[$l->isoCode] ); 120 } 121 122 asort( $countryList ); 123 $this->setTemplateVar('isocodes' ,$countryList ); 124 $this->setTemplateVar('isocode' ,'' ); 125 } 126 127 128 function addPost() 129 { 130 global $conf; 131 $countryList = $conf['countries']; 132 133 // Hinzufuegen einer Sprache 134 $iso = $this->getRequestVar('isocode'); 135 $language = new Language(); 136 $language->projectid = $this->project->projectid; 137 $language->isoCode = $iso; 138 $language->name = $countryList[$iso]; 139 $language->add(); 140 141 $this->addNotice('language',$language->name,'ADDED','ok'); 142 } 143 144 145 }