Revert "[RELEASE] Release of TYPO3 4.6.0alpha1"
[Packages/TYPO3.CMS.git] / t3lib / contextmenu / class.t3lib_contextmenu_action.php
index a8f01b6..b2b2006 100644 (file)
@@ -1,29 +1,29 @@
 <?php
 /***************************************************************
-*  Copyright notice
-*
-*  (c) 2010 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
-*  free software; you can redistribute it and/or modify
-*  it under the terms of the GNU General Public License as published by
-*  the Free Software Foundation; either version 2 of the License, or
-*  (at your option) any later version.
-*
-*  The GNU General Public License can be found at
-*  http://www.gnu.org/copyleft/gpl.html.
-*  A copy is found in the textfile GPL.txt and important notices to the license
-*  from the author is found in LICENSE.txt distributed with these scripts.
-*
-*
-*  This script is distributed in the hope that it will be useful,
-*  but WITHOUT ANY WARRANTY; without even the implied warranty of
-*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-*  GNU General Public License for more details.
-*
-*  This copyright notice MUST APPEAR in all copies of the script!
-***************************************************************/
+ *  Copyright notice
+ *
+ *  (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
+ *  free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  The GNU General Public License can be found at
+ *  http://www.gnu.org/copyleft/gpl.html.
+ *  A copy is found in the textfile GPL.txt and important notices to the license
+ *  from the author is found in LICENSE.txt distributed with these scripts.
+ *
+ *
+ *  This script is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
 
 /**
  * Context Menu Action
@@ -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