Revert "[RELEASE] Release of TYPO3 4.6.0alpha1"
[Packages/TYPO3.CMS.git] / t3lib / contextmenu / class.t3lib_contextmenu_action.php
index 381336d..b2b2006 100644 (file)
@@ -2,7 +2,7 @@
 /***************************************************************
  *  Copyright notice
  *
- *  (c) 2010 TYPO3 Tree Team <http://forge.typo3.org/projects/typo3v4-extjstrees>
+ *  (c) 2010-2011 TYPO3 Tree Team <http://forge.typo3.org/projects/typo3v4-extjstrees>
  *  All rights reserved
  *
  *  This script is part of the TYPO3 project. The TYPO3 project is
@@ -69,6 +69,27 @@ class t3lib_contextmenu_Action {
        protected $callbackAction = '';
 
        /**
+        * Type
+        *
+        * @var string
+        */
+       protected $type = '';
+
+       /**
+        * Child Action Collection
+        *
+        * @var t3lib_contextmenu_ActionCollection
+        */
+       protected $childActions = NULL;
+
+       /**
+        * Custom Action Attributes
+        *
+        * @var array
+        */
+       protected $customAttributes = array();
+
+       /**
         * Returns the label
         *
         * @return string
@@ -105,6 +126,25 @@ class t3lib_contextmenu_Action {
        }
 
        /**
+        * Returns the icon
+        *
+        * @return string
+        */
+       public function getIcon() {
+               return $this->icon;
+       }
+
+       /**
+        * Sets the icon
+        *
+        * @param string $icon
+        * @return void
+        */
+       public function setIcon($icon) {
+               $this->icon = $icon;
+       }
+
+       /**
         * Returns the class
         *
         * @return string
@@ -139,4 +179,100 @@ class t3lib_contextmenu_Action {
        public function setCallbackAction($callbackAction) {
                $this->callbackAction = $callbackAction;
        }
+
+       /**
+        * Returns the type
+        *
+        * @return string
+        */
+       public function getType() {
+               return $this->type;
+       }
+
+       /**
+        * Sets the type
+        *
+        * @param string $type
+        * @return void
+        */
+       public function setType($type) {
+               $this->type = $type;
+       }
+
+       /**
+        * Returns the child actions
+        *
+        * @return t3lib_contextmenu_ActionCollection
+        */
+       public function getChildActions() {
+               return $this->childActions;
+       }
+
+       /**
+        * Sets the child actions
+        *
+        * @param t3lib_contextmenu_ActionCollection $actions
+        * @return void
+        */
+       public function setChildActions(t3lib_contextmenu_ActionCollection $actions) {
+               $this->childActions = $actions;
+       }
+
+       /**
+        * Returns TRUE if the action has child actions
+        *
+        * @return boolean
+        */
+       public function hasChildActions() {
+               if ($this->childActions !== NULL) {
+                       return TRUE;
+               }
+
+               return FALSE;
+       }
+
+       /**
+        * Sets the custom attributes
+        *
+        * @param array $customAttributes
+        * @return void
+        */
+       public function setCustomAttributes(array $customAttributes) {
+               $this->customAttributes = $customAttributes;
+       }
+
+       /**
+        * Returns the custom attributes
+        * 
+        * @return array
+        */
+       public function getCustomAttributes() {
+               return $this->customAttributes;
+       }
+
+       /**
+        * Returns the action as an array
+        *
+        * @return array
+        */
+       public function toArray() {
+               $arrayRepresentation = array(
+                       'label' => $this->getLabel(),
+                       'id' => $this->getId(),
+                       'icon' => $this->getIcon(),
+                       'class' => $this->getClass(),
+                       'callbackAction' => $this->getCallbackAction(),
+                       'type' => $this->getType(),
+                       'customAttributes' => $this->getCustomAttributes()
+               );
+
+               $arrayRepresentation['childActions'] = '';
+               if ($this->hasChildActions()) {
+                       $arrayRepresentation['childActions'] = $this->childActions->toArray();
+               }
+
+               return $arrayRepresentation;
+       }
 }
+
+?>
\ No newline at end of file