TYPO3 API  SVNRelease
class.t3lib_contextmenu_action.php
Go to the documentation of this file.
00001 <?php
00002 /***************************************************************
00003  *  Copyright notice
00004  *
00005  *  (c) 2010-2011 TYPO3 Tree Team <http://forge.typo3.org/projects/typo3v4-extjstrees>
00006  *  All rights reserved
00007  *
00008  *  This script is part of the TYPO3 project. The TYPO3 project is
00009  *  free software; you can redistribute it and/or modify
00010  *  it under the terms of the GNU General Public License as published by
00011  *  the Free Software Foundation; either version 2 of the License, or
00012  *  (at your option) any later version.
00013  *
00014  *  The GNU General Public License can be found at
00015  *  http://www.gnu.org/copyleft/gpl.html.
00016  *  A copy is found in the textfile GPL.txt and important notices to the license
00017  *  from the author is found in LICENSE.txt distributed with these scripts.
00018  *
00019  *
00020  *  This script is distributed in the hope that it will be useful,
00021  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00022  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023  *  GNU General Public License for more details.
00024  *
00025  *  This copyright notice MUST APPEAR in all copies of the script!
00026  ***************************************************************/
00027 
00028 /**
00029  * Context Menu Action
00030  *
00031  * @author Stefan Galinski <stefan.galinski@gmail.com>
00032  * @package TYPO3
00033  * @subpackage t3lib
00034  */
00035 class t3lib_contextmenu_Action {
00036     /**
00037      * Label
00038      *
00039      * @var string
00040      */
00041     protected $label = '';
00042 
00043     /**
00044      * Identifier
00045      *
00046      * @var string
00047      */
00048     protected $id = '';
00049 
00050     /**
00051      * Icon
00052      *
00053      * @var string
00054      */
00055     protected $icon = '';
00056 
00057     /**
00058      * Class
00059      *
00060      * @var string
00061      */
00062     protected $class = '';
00063 
00064     /**
00065      * Callback Action
00066      *
00067      * @var string
00068      */
00069     protected $callbackAction = '';
00070 
00071     /**
00072      * Type
00073      *
00074      * @var string
00075      */
00076     protected $type = '';
00077 
00078     /**
00079      * Child Action Collection
00080      *
00081      * @var t3lib_contextmenu_ActionCollection
00082      */
00083     protected $childActions = NULL;
00084 
00085     /**
00086      * Custom Action Attributes
00087      *
00088      * @var array
00089      */
00090     protected $customAttributes = array();
00091 
00092     /**
00093      * Returns the label
00094      *
00095      * @return string
00096      */
00097     public function getLabel() {
00098         return $this->label;
00099     }
00100 
00101     /**
00102      * Sets the label
00103      *
00104      * @param string $label
00105      */
00106     public function setLabel($label) {
00107         $this->label = $label;
00108     }
00109 
00110     /**
00111      * Returns the identifier
00112      *
00113      * @return string
00114      */
00115     public function getId() {
00116         return $this->id;
00117     }
00118 
00119     /**
00120      * Sets the identifier
00121      *
00122      * @param string $id
00123      */
00124     public function setId($id) {
00125         $this->id = $id;
00126     }
00127 
00128     /**
00129      * Returns the icon
00130      *
00131      * @return string
00132      */
00133     public function getIcon() {
00134         return $this->icon;
00135     }
00136 
00137     /**
00138      * Sets the icon
00139      *
00140      * @param string $icon
00141      * @return void
00142      */
00143     public function setIcon($icon) {
00144         $this->icon = $icon;
00145     }
00146 
00147     /**
00148      * Returns the class
00149      *
00150      * @return string
00151      */
00152     public function getClass() {
00153         return $this->class;
00154     }
00155 
00156     /**
00157      * Sets the class
00158      *
00159      * @param string $class
00160      */
00161     public function setClass($class) {
00162         $this->class = $class;
00163     }
00164 
00165     /**
00166      * Returns the callback action
00167      *
00168      * @return string
00169      */
00170     public function getCallbackAction() {
00171         return $this->callbackAction;
00172     }
00173 
00174     /**
00175      * Sets the callback action
00176      *
00177      * @param string $callbackAction
00178      */
00179     public function setCallbackAction($callbackAction) {
00180         $this->callbackAction = $callbackAction;
00181     }
00182 
00183     /**
00184      * Returns the type
00185      *
00186      * @return string
00187      */
00188     public function getType() {
00189         return $this->type;
00190     }
00191 
00192     /**
00193      * Sets the type
00194      *
00195      * @param string $type
00196      * @return void
00197      */
00198     public function setType($type) {
00199         $this->type = $type;
00200     }
00201 
00202     /**
00203      * Returns the child actions
00204      *
00205      * @return t3lib_contextmenu_ActionCollection
00206      */
00207     public function getChildActions() {
00208         return $this->childActions;
00209     }
00210 
00211     /**
00212      * Sets the child actions
00213      *
00214      * @param t3lib_contextmenu_ActionCollection $actions
00215      * @return void
00216      */
00217     public function setChildActions(t3lib_contextmenu_ActionCollection $actions) {
00218         $this->childActions = $actions;
00219     }
00220 
00221     /**
00222      * Returns true if the action has child actions
00223      *
00224      * @return boolean
00225      */
00226     public function hasChildActions() {
00227         if ($this->childActions !== NULL) {
00228             return TRUE;
00229         }
00230 
00231         return FALSE;
00232     }
00233 
00234     /**
00235      * Sets the custom attributes
00236      *
00237      * @param array $customAttributes
00238      * @return void
00239      */
00240     public function setCustomAttributes(array $customAttributes) {
00241         $this->customAttributes = $customAttributes;
00242     }
00243 
00244     /**
00245      * Returns the custom attributes
00246      * 
00247      * @return array
00248      */
00249     public function getCustomAttributes() {
00250         return $this->customAttributes;
00251     }
00252 
00253     /**
00254      * Returns the action as an array
00255      *
00256      * @return array
00257      */
00258     public function toArray() {
00259         $arrayRepresentation = array(
00260             'label' => $this->getLabel(),
00261             'id' => $this->getId(),
00262             'icon' => $this->getIcon(),
00263             'class' => $this->getClass(),
00264             'callbackAction' => $this->getCallbackAction(),
00265             'type' => $this->getType(),
00266             'customAttributes' => $this->getCustomAttributes()
00267         );
00268 
00269         $arrayRepresentation['childActions'] = '';
00270         if ($this->hasChildActions()) {
00271             $arrayRepresentation['childActions'] = $this->childActions->toArray();
00272         }
00273 
00274         return $arrayRepresentation;
00275     }
00276 }
00277 
00278 ?>