[FEATURE] Allow to order tabs of "Insert/modify image" in Page TSConfig
authorStanislas Rolland <typo3@sjbr.ca>
Mon, 20 Feb 2012 16:42:43 +0000 (11:42 -0500)
committerStanislas Rolland <typo3@sjbr.ca>
Mon, 27 Feb 2012 13:12:05 +0000 (14:12 +0100)
Allow configuring the order of tabs of the "Insert/modify image" dialogue
window via Page TSConfig property: buttons.image.options.orderItems.

Thanks go to Bernd Wilke for the idea.

Change-Id: If1532537d01ca6f51931f6b0bfb0101407dedbf7
Resolves: #34027
Releases: 4.7
Reviewed-on: http://review.typo3.org/9069
Reviewed-by: Stefan Neufeind
Tested-by: Stefan Neufeind
Reviewed-by: Stanislas Rolland
Tested-by: Stanislas Rolland
typo3/sysext/rtehtmlarea/doc/manual.sxw
typo3/sysext/rtehtmlarea/mod4/class.tx_rtehtmlarea_select_image.php

index 66cf2bb..880407e 100644 (file)
Binary files a/typo3/sysext/rtehtmlarea/doc/manual.sxw and b/typo3/sysext/rtehtmlarea/doc/manual.sxw differ
index a415767..bbab3ea 100644 (file)
@@ -824,6 +824,9 @@ class tx_rtehtmlarea_select_image extends browse_links {
                        $menuDef = $hookObject->modifyMenuDefinition($menuDef);
                }
 
+                       // Order the menu items as specified in Page TSconfig
+               $menuDef = $this->orderMenuDefinition($menuDef);
+
                $this->content .= $this->doc->getTabMenuRaw($menuDef);
 
                switch($this->act)      {
@@ -1183,6 +1186,26 @@ class tx_rtehtmlarea_select_image extends browse_links {
        }
 
        /**
+        * Order the definition of menu items according to configured order
+        *
+        * @param array $menuDefinition: definition of menu items
+        * @return array ordered menu definition
+        */
+       public function orderMenuDefinition($menuDefinition) {
+               $orderedMenuDefinition = array();
+               if (is_array($this->buttonConfig['options.']) && $this->buttonConfig['options.']['orderItems']) {
+                       $orderItems = t3lib_div::trimExplode(',', $this->buttonConfig['options.']['orderItems'], TRUE);
+                       $orderItems = array_intersect($orderItems, $this->allowedItems);
+                       foreach ($orderItems as $item) {
+                               $orderedMenuDefinition[$item] = $menuDefinition[$item];
+                       }
+               } else {
+                       $orderedMenuDefinition = $menuDefinition;
+               }
+               return $orderedMenuDefinition;
+       }
+
+       /**
         * Get the default image class
         *
         * @return      string          the default class, if any