openrat-cms

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

FolderContentAction.class.php (2016B)


      1 <?php
      2 namespace cms\action\folder;
      3 use cms\action\FolderAction;
      4 use cms\action\Method;
      5 use cms\model\Permission;
      6 use cms\model\BaseObject;
      7 use cms\model\File;
      8 use util\Html;
      9 
     10 
     11 class FolderContentAction extends FolderAction implements Method {
     12     public function view() {
     13 		if   ( ! $this->folder->isRoot )
     14 			$this->setTemplateVar('up_url',Html::url('folder','show',$this->folder->parentid));
     15 
     16 		$this->setTemplateVar('writable',$this->folder->hasRight(Permission::ACL_WRITE) );
     17 
     18 		$list = array();
     19 
     20 		// Schleife ueber alle Objekte in diesem Ordner
     21 		foreach( $this->folder->getObjects() as $o )
     22 		{
     23             /* @var $o BaseObject */
     24             $id = $o->objectid;
     25 
     26 			if   ( $o->hasRight(Permission::ACL_READ) )
     27 			{
     28 				$list[$id]['name']     = \util\Text::maxLength($o->name, 30);
     29 				$list[$id]['filename'] = \util\Text::maxLength($o->filename, 20);
     30 				$list[$id]['desc']     = \util\Text::maxLength($o->desc, 30);
     31 				if	( $list[$id]['desc'] == '' )
     32 					$list[$id]['desc'] = \cms\base\Language::lang('NO_DESCRIPTION_AVAILABLE');
     33 				$list[$id]['desc'] = $list[$id]['desc'].' - '.\cms\base\Language::lang('IMAGE').' '.$id;
     34 
     35 				$list[$id]['type'] = $o->getType();
     36 				$list[$id]['id'  ] = $id;
     37 
     38 				$list[$id]['icon' ] = $o->getType();
     39 				$list[$id]['class'] = $o->getType();
     40 				$list[$id]['url' ] = Html::url($o->getType(),'',$id);
     41 
     42 				if	( $o->getType() == 'file' )
     43 				{
     44 					$file = new File( $id );
     45 					$file->load();
     46 					$list[$id]['desc'] .= ' - '.intval($file->size/1000).'kB';
     47 
     48 					if	( $file->isImage() )
     49 					{
     50 						$list[$id]['icon' ] = 'image';
     51 						$list[$id]['class'] = 'image';
     52 						//$list[$id]['url' ] = Html::url('file','show',$id) nur sinnvoll bei Lightbox-Anzeige
     53 					}
     54 //					if	( substr($file->mimeType(),0,5) == 'text/' )
     55 //						$list[$id]['icon'] = 'text';
     56 				}
     57 
     58 				$list[$id]['date'] = $o->lastchangeDate;
     59 				$list[$id]['user'] = $o->lastchangeUser;
     60 			}
     61 		}
     62 
     63 		$this->setTemplateVar('object'      ,$list            );
     64     }
     65 
     66 
     67     public function post() {
     68     }
     69 }