openrat-cms

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

TitleAction.class.php (3195B)


      1 <?php
      2 
      3 namespace cms\action;
      4 
      5 use cms\model\Project;
      6 use cms\model\BaseObject;
      7 use cms\model\Language;
      8 use cms\model\Model;
      9 
     10 use Session;
     11 use \Html;
     12 // OpenRat Content Management System
     13 // Copyright (C) 2002-2009 Jan Dankert, jandankert@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  * Actionklasse zum Anzeigen der Titelleiste.
     32  * 
     33  * @author Jan Dankert
     34  * @package openrat.actions
     35  */
     36 class TitleAction extends Action
     37 {
     38 	public $security = Action::SECURITY_GUEST;
     39 		
     40 	/**
     41 	 * Fuellen der Variablen und Anzeigen der Titelleiste
     42 	 */
     43 	public function showView()
     44 	{
     45 		$this->setTemplateVar('buildinfo',OR_TITLE.' '.OR_VERSION.' - build '.config('build','build') );
     46 
     47 		$user = Session::getUser();
     48 
     49 		if	( !is_object($user) )
     50 		{
     51             $this->setTemplateVar('isLoggedIn'  ,false );
     52             $this->setTemplateVar('userfullname',lang('NOT_LOGGED_IN') );
     53             return; // Kein Benutzer angemeldet.
     54         }
     55 
     56         $this->setTemplateVar('isLoggedIn',true );
     57 
     58         $db = db();
     59         $this->setTemplateVar('dbname',$db->conf['name'].(readonly()?' ('.lang('readonly').')':''));
     60         $this->setTemplateVar('dbid'  ,$db->id);
     61 
     62         $this->setTemplateVar('username'    ,$user->name    );
     63         $this->setTemplateVar('userfullname',$user->fullname);
     64 
     65 		// Urls zum Benutzerprofil und zum Abmelden
     66 		//$this->setTemplateVar('profile_url',Html::url( 'profile'         ));
     67 		//$this->setTemplateVar('logout_url' ,Html::url( 'index','logout'  ));
     68 		$this->setTemplateVar('isAdmin',$this->userIsAdmin() );
     69 
     70 		if	( config('interface','session','auto_extend') )
     71 		{
     72 			$this->setTemplateVar('ping_url'    ,Html::url('title','ping')            );			
     73 			$this->setTemplateVar('ping_timeout',ini_get('session.gc_maxlifetime')-60 );
     74 		}
     75 	}
     76 	
     77 	
     78 	public function historyView()
     79 	{
     80 		$resultList = array();
     81 
     82 		$history = Session::get('history');
     83 		
     84 		if	( is_array($history) )
     85 		{
     86 			foreach( array_reverse($history) as $objectid )
     87 			{
     88 				$o = new BaseObject( $objectid );
     89 				$o->load();
     90 				$resultList[$objectid] = array();
     91 				$resultList[$objectid]['url']  = Html::url($o->getType(),'',$objectid);
     92 				$resultList[$objectid]['type'] = $o->getType();
     93 				$resultList[$objectid]['name'] = $o->name;
     94 				$resultList[$objectid]['lastchange_date'] = $o->lastchangeDate;
     95 	
     96 				if	( $o->desc != '' )
     97 					$resultList[$objectid]['desc'] = $o->desc;
     98 				else
     99 					$resultList[$objectid]['desc'] = lang('NO_DESCRIPTION_AVAILABLE');
    100 			}
    101 		}
    102 
    103 		$this->setTemplateVar( 'history',$resultList );		
    104 	}
    105 }
    106 
    107 ?>