LinkValueAction.class.php (1116B)
1 <?php 2 namespace cms\action\link; 3 use cms\action\Action; 4 use cms\action\LinkAction; 5 use cms\action\Method; 6 use cms\model\BaseObject; 7 use cms\model\Permission; 8 use language\Messages; 9 10 11 class LinkValueAction extends LinkAction implements Method { 12 13 public function getRequiredPermission() { 14 return Permission::ACL_WRITE; 15 } 16 17 18 public function view() { 19 $this->setTemplateVars( $this->link->getProperties() ); 20 21 // Typ der Verknuepfung 22 $this->setTemplateVar('type' ,$this->link->getType() ); 23 24 if ( $this->link->linkedObjectId ) { 25 26 $target = new BaseObject( $this->link->linkedObjectId ); 27 $target->load(); 28 29 $this->setTemplateVar('target' ,$target->getProperties() ); 30 $this->setTemplateVar('targetobjectid' ,$target->objectid ); 31 $this->setTemplateVar('targetobjectname',$target->getName() ); 32 $this->setTemplateVar('targetobjecttype',$target->getType() ); 33 } 34 } 35 36 37 public function post() { 38 39 $this->link->linkedObjectId = $this->request->getText('targetobjectid'); 40 $this->link->save(); 41 42 $this->addNoticeFor( $this->link, Messages::SAVED); 43 } 44 }