FolderOrderAction.class.php (1746B)
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 language\Messages; 8 9 10 class FolderOrderAction extends FolderAction implements Method { 11 12 public function getRequiredPermission() { 13 return Permission::ACL_WRITE; 14 } 15 16 public function view() { 17 $list = array(); 18 19 // Schleife ueber alle Objekte in diesem Ordner 20 foreach( $this->folder->getObjects() as $o ) 21 { 22 /* @var $o BaseObject */ 23 $id = $o->objectid; 24 $name = $o->getDefaultName(); 25 26 if ( $o->hasRight(Permission::ACL_READ) ) 27 { 28 $list[$id]['id' ] = $id; 29 $list[$id]['name'] = $name->name; 30 $list[$id]['filename'] = $o->filename; 31 $list[$id]['desc'] = 'ID '.$id.' - '.$name->description; 32 33 $list[$id]['type'] = $o->getType(); 34 $list[$id]['icon'] = $o->getType(); 35 36 $list[$id]['date'] = $o->lastchangeDate; 37 $list[$id]['user'] = $o->lastchangeUser; 38 39 $last_objectid = $id; 40 } 41 } 42 43 $this->setTemplateVar('object' ,$list ); 44 $this->setTemplateVar('act_objectid',$this->folder->objectid); 45 } 46 47 48 public function post() { 49 $ids = $this->folder->getObjectIds(); 50 $seq = 0; 51 52 $order = explode(',',$this->request->getText('order') ); 53 54 foreach( $order as $objectid ) 55 { 56 if ( ! is_numeric($objectid) || ! in_array($objectid,$ids) ) 57 { 58 throw new \LogicException('Object-Id '.$objectid.' is not in this folder any more'); 59 } 60 $seq++; // Sequenz um 1 erhoehen 61 62 $o = new BaseObject( $objectid ); 63 $o->setOrderId( $seq ); 64 65 unset( $o ); // Selfmade Garbage Collection :-) 66 } 67 68 $this->addNoticeFor($this->folder, Messages::SEQUENCE_CHANGED); 69 $this->folder->setTimestamp(); 70 } 71 }