openrat-cms

# OpenRat Content Management System
git clone http://git.code.weiherhei.de/openrat-cms.git
Log | Files | Refs

LanguageAction.class.php (3892B)


      1 <?php
      2 
      3 namespace cms\action;
      4 
      5 use cms\model\Language;
      6 use cms\model\Project;
      7 use Session;
      8 use \Html;
      9 // OpenRat Content Management System
     10 // Copyright (C) 2002-2012 Jan Dankert, cms@jandankert.de
     11 //
     12 // This program is free software; you can redistribute it and/or
     13 // modify it under the terms of the GNU General Public License
     14 // as published by the Free Software Foundation; either version 2
     15 // of the License, or (at your option) any later version.
     16 //
     17 // This program is distributed in the hope that it will be useful,
     18 // but WITHOUT ANY WARRANTY; without even the implied warranty of
     19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     20 // GNU General Public License for more details.
     21 //
     22 // You should have received a copy of the GNU General Public License
     23 // along with this program; if not, write to the Free Software
     24 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
     25 
     26 
     27 /**
     28  * Action-Klasse f?r die Bearbeitung einer Sprache
     29  * @version $Id$
     30  * @author  $Author$
     31  * @package openrat.actions
     32  */
     33 class LanguageAction extends BaseAction
     34 {
     35 	public $security = Action::SECURITY_USER;
     36 	
     37 	/**
     38 	 * Zu bearbeitende Sprache, wird im Kontruktor instanziiert
     39 	 * @type Language
     40 	 */
     41 	private $language;
     42 
     43 
     44 	/**
     45 	 * Konstruktor
     46 	 */
     47 	public function __construct()
     48 	{
     49         parent::__construct();
     50 
     51     }
     52 
     53 
     54     public function init()
     55     {
     56 		$this->language = new Language( $this->getRequestId() );
     57 		$this->language->load();
     58 	}
     59 
     60 
     61 	/**
     62 	 * Setzen der Sprache als Standardsprache.
     63 	 * Diese Sprache wird benutzt beim Ausw?hlen des Projektes sowie
     64 	 * als Default-Sprache bei mehrsprachigen Webseiten ("content-negotiation") 
     65 	 */
     66 	public function setdefaultPost()
     67 	{
     68 		$this->language->setDefault();
     69 
     70         $this->addNotice('language',$this->language->name,'DONE',OR_NOTICE_OK);
     71     }
     72 
     73 
     74 
     75 	/**
     76 	 * Anzeigen der L�schbest�tigungs-Maske.
     77 	 */
     78 	public function removeView()
     79 	{
     80 		$this->setTemplateVar('name'   ,$this->language->name   );
     81 	}
     82 	
     83 	
     84 	/**
     85 	 * L�schen der Sprache.
     86 	 */
     87 	public function removePost()
     88 	{
     89 		if   ( $this->getRequestVar('confirm') == '1' )
     90 			$this->language->delete();
     91 	}
     92 	
     93 	
     94 	/**
     95 	 * Speichern der Sprache
     96 	 */
     97 	function propPost()
     98 	{
     99 		if	( $this->hasRequestVar('name') )
    100 		{
    101 			$this->language->name    = $this->getRequestVar('name'   );
    102 			$this->language->isoCode = $this->getRequestVar('isocode');
    103 		}
    104 		else
    105 		{
    106 			$countryList = config()['countries'];
    107 			$iso = $this->getRequestVar('isocode');
    108 			$this->language->name    = $countryList[$iso];
    109 			$this->language->isoCode = strtolower( $iso );
    110 		}
    111 
    112 		if  ( $this->hasRequestVar('is_default') )
    113 		    $this->language->setDefault();
    114 		
    115 		$this->language->save();
    116 
    117         $this->addNotice('language',$this->language->name,'DONE',OR_NOTICE_OK);
    118 	}
    119 
    120 
    121 
    122 	public function infoView()
    123 	{
    124 		$this->setTemplateVars( $this->language->getProperties() );
    125 	}
    126 
    127 
    128 	function propView()
    129 	{
    130 		$this->setTemplateVar('isocode'   ,$this->language->isoCode   );
    131 		$this->setTemplateVar('name'      ,$this->language->name      );
    132 		$this->setTemplateVar('is_default',$this->language->isDefault );
    133 	}
    134 	
    135 	
    136 	
    137 	
    138 	/**
    139 	 * Liefert die Struktur zu diesem Ordner:
    140 	 * - Mit den übergeordneten Ordnern und
    141 	 * - den in diesem Ordner enthaltenen Objekten
    142 	 * 
    143 	 * Beispiel:
    144 	 * <pre>
    145 	 * - A
    146 	 *   - B
    147 	 *     - C (dieser Ordner)
    148 	 *       - Unterordner
    149 	 *       - Seite
    150 	 *       - Seite
    151 	 *       - Datei
    152 	 * </pre> 
    153 	 */
    154 	public function structureView()
    155 	{
    156 		$structure = array();
    157 		$languagelistChildren = array();
    158 		
    159 		$structure[0] = array('id'=>'0','name'=>lang('LANGUAGES'),'type'=>'languagelist','level'=>1,'children'=>&$languagelistChildren);
    160 			
    161 		$languagelistChildren[ $this->language->languageid ] = array('id'=>$this->language->languageid,'name'=>$this->language->name,'type'=>'language','self'=>true);
    162 		
    163 		
    164 		//Html::debug($structure);
    165 		
    166 		$this->setTemplateVar('outline',$structure);
    167 	}
    168 }