added clear cache actions menu to backend.php as part of the cleaner backend project
authorIngo Renner <ingo.renner@typo3.org>
Wed, 28 Nov 2007 10:07:52 +0000 (10:07 +0000)
committerIngo Renner <ingo.renner@typo3.org>
Wed, 28 Nov 2007 10:07:52 +0000 (10:07 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@2777 709f56b5-9817-0410-a4d7-c38de5d9e867

16 files changed:
ChangeLog
typo3/backend.php
typo3/classes/class.clearcachemenu.php [new file with mode: 0644]
typo3/classes/class.modulemenu.php
typo3/classes/class.workspaceselector.php
typo3/css/backend-scaffolding.css
typo3/css/backend-style.css
typo3/gfx/lightning.png [new file with mode: 0644]
typo3/gfx/lightning_green.png [new file with mode: 0644]
typo3/gfx/lightning_red.png [new file with mode: 0644]
typo3/gfx/toolbar_item_active_bg.png [new file with mode: 0644]
typo3/gfx/toolbar_separator.png [new file with mode: 0644]
typo3/interfaces/interface.backend_toolbaritem.php
typo3/js/clearcachemenu.js [new file with mode: 0644]
typo3/js/sizemanager.js
typo3/sysext/lang/locallang_core.xml

index f079445..1489cfc 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2007-11-27  Ingo Renner        <ingo@typo3.org>
+
+       * added clear cache actions menu to backend.php as part of the cleaner backend project
+
 2007-11-27  Stanislas Rolland  <stanislas.rolland@fructifor.ca>
 
        * Bugfix #6836: htmlArea RTE cannot enter line break in Safari (Windows)
index c89afcb..e4bbc56 100644 (file)
@@ -32,6 +32,7 @@ require_once ('interfaces/interface.backend_toolbaritem.php');
 require ('classes/class.typo3logo.php');
 require ('classes/class.modulemenu.php');
 require ('classes/class.workspaceselector.php');
+require ('classes/class.clearcachemenu.php');
 
 require_once (PATH_t3lib.'class.t3lib_loadmodules.php');
 require_once (PATH_t3lib.'class.t3lib_basicfilefunc.php');
@@ -99,6 +100,7 @@ class TYPO3backend {
                $this->js = '';
                $this->jsFiles = array(
                        'contrib/prototype/prototype.js',
+                       'contrib/scriptaculous/scriptaculous.js?load=builder,effects,controls,dragdrop',
                        'md5.js',
                        'js/sizemanager.js',
                        '../t3lib/jsfunc.evalfield.js'
@@ -124,8 +126,8 @@ class TYPO3backend {
 
                $coreToolbarItems = array(
                        'workspaceSelector' => 'WorkspaceSelector',
+                       'clearCacheActions' => 'ClearCacheMenu'
                        /* TODO
-                       'clearCacheActions' => '',
                        'backendSearch'     => '',
                        'shortcutMenu'      => ''
                        */
@@ -139,7 +141,7 @@ class TYPO3backend {
                        }
 
                        $toolbarItem->setBackend($this);
-                       $this->toolbarItems[] = $toolbarItem;
+                       $this->toolbarItems[$toolbarItemName] = $toolbarItem;
                }
        }
 
@@ -155,7 +157,6 @@ class TYPO3backend {
                $logo->setLogo('gfx/typo3logo_mini.png');
 
                $menu         = $this->moduleMenu->render();
-               $cacheActions = $this->moduleMenu->renderCacheActions();
                $logout       = $this->moduleMenu->renderLogoutButton();
                $loginInfo    = $this->getLoggedInUserLabel();
 
@@ -171,7 +172,6 @@ class TYPO3backend {
                <div id="typo3-main-container">
                        <div id="typo3-side-menu">'
                                .$menu
-                               .$cacheActions
                                .$logout
                                .$loginInfo
                                .'
@@ -229,13 +229,17 @@ class TYPO3backend {
         * @return      string  top toolbar elements as HTML
         */
        private function renderToolbar() {
-               $toolbar = '';
+               $toolbar = '<ul id="typo3-toolbar">';
 
-               foreach($this->toolbarItems as $toolbarItem) {
-                       $toolbar .= $toolbarItem->render();
+               $toolbarItems = array_reverse($this->toolbarItems);
+
+               foreach($toolbarItems as $toolbarItem) {
+                       $additionalAttributes = $toolbarItem->getAdditionalAttributes();
+
+                       $toolbar .= '<li'.$additionalAttributes.'>'.$toolbarItem->render().'</li>';
                }
 
-               return $toolbar;
+               return $toolbar.'</ul>';
        }
 
        /**
diff --git a/typo3/classes/class.clearcachemenu.php b/typo3/classes/class.clearcachemenu.php
new file mode 100644 (file)
index 0000000..931b2ae
--- /dev/null
@@ -0,0 +1,144 @@
+<?php
+/***************************************************************
+*  Copyright notice
+*
+*  (c) 2007 Ingo Renner <ingo@typo3.org>
+*  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!
+***************************************************************/
+
+
+/**
+ * class to render the menu for the cache clearing actions
+ *
+ * $Id$
+ *
+ * @author     Ingo Renner <ingo@typo3.org>
+ * @package TYPO3
+ * @subpackage core
+ */
+class ClearCacheMenu implements backend_toolbarItem {
+
+       private $cacheActions;
+
+       /**
+        * reference back to the backend object
+        *
+        * @var TYPO3backend
+        */
+       private $backendReference;
+
+       /**
+        * constructor
+        *
+        * @return      void
+        */
+       public function __construct() {
+               $this->cacheActions = array();
+
+                       // Clear cache for ALL tables!
+               $title = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:rm.clearCache_all');
+               $this->cacheActions[] = array(
+                       'id'    => 'all',
+                       'title' => $title,
+                       'href'  => $this->backPath.'tce_db.php?vC='.$GLOBALS['BE_USER']->veriCode().'&cacheCmd=all',
+                       'icon'  => '<img'.t3lib_iconWorks::skinImg($this->backPath, 'gfx/lightning_red.png', 'width="16" height="16"').' title="'.htmlspecialchars($title).'" alt="" />'
+               );
+
+                       // Clear cache for either ALL pages
+               $title = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:rm.clearCache_pages');
+               $this->cacheActions[] = array(
+                       'id'    => 'pages',
+                       'title' => $title,
+                       'href'  => $this->backPath.'tce_db.php?vC='.$GLOBALS['BE_USER']->veriCode().'&cacheCmd=pages',
+                       'icon'  => '<img'.t3lib_iconWorks::skinImg($this->backPath, 'gfx/lightning.png', 'width="16" height="16"').' title="'.htmlspecialchars($title).'" alt="" />'
+               );
+
+                       // Clearing of cache-files in typo3conf/ + menu
+               if ($GLOBALS['TYPO3_CONF_VARS']['EXT']['extCache'])     {
+                       $title = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:rm.clearCache_allTypo3Conf');
+                       $this->cacheActions[] = array(
+                               'id'    => 'temp_CACHED',
+                               'title' => $title,
+                               'href'  => $this->backPath.'tce_db.php?vC='.$GLOBALS['BE_USER']->veriCode().'&cacheCmd=temp_CACHED',
+                               'icon'  => '<img'.t3lib_iconWorks::skinImg($this->backPath, 'gfx/lightning_green.png', 'width="16" height="16"').' title="'.htmlspecialchars($title).'" alt="" />'
+                       );
+               }
+
+
+       }
+
+       /**
+        * sets the backend reference
+        *
+        * @param TYPO3backend backend object reference
+        */
+       public function setBackend(&$backendReference) {
+               $this->backendReference = $backendReference;
+       }
+
+       /**
+        * Creates the selector for workspaces
+        *
+        * @return      string          workspace selector as HTML select
+        */
+       public function render() {
+               $this->addJavascriptToBackend();
+               $cacheMenu = array();
+
+               $cacheMenu[] = '<a href="#" class="toolbar-item"><img'.t3lib_iconWorks::skinImg($this->backPath, 'gfx/lightning.png', 'width="16" height="16"').' title="Clear Cache" alt="" /></a>';
+
+               $cacheMenu[] = '<ul style="display: none;">';
+
+               foreach($this->cacheActions as $actionKey => $cacheAction) {
+                       $cacheMenu[] = '<li>'.$cacheAction['icon'].' <a href="'.htmlspecialchars($cacheAction['href']).'">'.$cacheAction['title'].'</a></li>';
+               }
+
+               $cacheMenu[] = '</ul>';
+
+               return implode("\n", $cacheMenu);
+       }
+
+       /**
+        * adds the neccessary javascript ot the backend
+        *
+        * @return      void
+        */
+       private function addJavascriptToBackend() {
+               $this->backendReference->addJavascriptFile('typo3/js/clearcachemenu.js');
+       }
+
+       /**
+        * returns additional attributes for the list item in the toolbar
+        *
+        * @return      string          list item HTML attibutes
+        */
+       public function getAdditionalAttributes() {
+               return ' id="clear-cache-actions-menu"';
+       }
+
+}
+
+if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/classes/class.workspaceselector.php']) {
+       include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/classes/class.workspaceselector.php']);
+}
+
+?>
\ No newline at end of file
index 0a8cf1b..7a938de 100644 (file)
@@ -43,7 +43,6 @@ class ModuleMenu {
        protected $moduleLoader;
 
        private $backPath;
-       private $cacheActions;
        private $linkModules;
        private $loadedModules;
        private $fsMod; //TODO find a more descriptive name, left over from alt_menu_functions
@@ -65,9 +64,6 @@ class ModuleMenu {
                $this->moduleLoader->load($GLOBALS['TBE_MODULES']);
                $this->loadedModules = $this->moduleLoader->modules;
 
-                       // init cache actions
-               $this->cacheActions = array();
-               $this->initCacheActions();
        }
 
        /**
@@ -482,60 +478,6 @@ class ModuleMenu {
                return $buttonForm;
        }
 
-       /**
-        * renders the actions to clear several caches
-        *
-        * @return      string  cache actions html code snippet
-        */
-       public function renderCacheActions() {
-               $renderedCacheActions = array('<ul id="cache-actions">');
-
-               foreach($this->cacheActions as $actionKey => $cacheAction) {
-                       $js = 
-                               'top.origIcon = $$(\'#action-'.$actionKey.' img\')[0].src;'.
-                               '$$(\'#action-'.$actionKey.' img\')[0].src = \'gfx/spinner.gif\';'.
-                               'new Ajax.Request(\''.htmlspecialchars($cacheAction['href']).'\', { '.
-                                       'method: \'get\', '.
-                                       'onComplete: function() {$$(\'#action-'.$actionKey.' img\')[0].src = top.origIcon;}'.
-                               '}); '.
-                               'return false;';
-
-                       $renderedCacheActions[] = '<li id="action-'.$actionKey.'"><a onclick="'.$js.'" href="#'.htmlspecialchars($cacheAction['href']).'">'.$cacheAction['icon'].' '.$cacheAction['title'].'</a></li>';
-               }
-
-               $renderedCacheActions[] = '</ul>';
-
-               return implode("\n", $renderedCacheActions);
-       }
-
-       /**
-        * initializes cache actions
-        *
-        * @return      void
-        */
-       private function initCacheActions() {
-
-                       // Clearing of cache-files in typo3conf/ + menu
-               if ($GLOBALS['TYPO3_CONF_VARS']['EXT']['extCache'])     {
-                       $title = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.clearCache_allTypo3Conf');
-                       $this->cacheActions[] = array(
-                               'id'    => 'temp_CACHED',
-                               'title' => $title,
-                               'href'  => $this->backPath.'tce_db.php?vC='.$GLOBALS['BE_USER']->veriCode().'&cacheCmd=temp_CACHED',
-                               'icon'  => '<img'.t3lib_iconWorks::skinImg($this->backPath, 'gfx/clear_cache_files_in_typo3c.gif', 'width="21" height="18"').' title="'.htmlspecialchars($title).'" alt="" />'
-                       );
-               }
-
-                       // Clear all page cache
-               $title = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.clearCache_all');
-               $this->cacheActions[] = array(
-                       'id'    => 'all',
-                       'title' => $title,
-                       'href'  => $this->backPath.'tce_db.php?vC='.$GLOBALS['BE_USER']->veriCode().'&cacheCmd=all',
-                       'icon'  => '<img'.t3lib_iconWorks::skinImg($this->backPath, 'gfx/clear_all_cache.gif', 'width="21" height="18"').' title="'.htmlspecialchars($title).'" alt="" />'
-               );
-       }
-
        /**
         * turns linking of modules on or off
         *
index dc7d855..2b844ae 100644 (file)
@@ -186,6 +186,15 @@ class WorkspaceSelector implements backend_toolbarItem {
        private function addJavascriptToBackend() {
                $this->backendReference->addJavascriptFile('typo3/js/workspaces.js');
        }
+
+       /**
+        * returns additional attributes for the list item in the toolbar
+        *
+        * @return      string          list item HTML attibutes
+        */
+       public function getAdditionalAttributes() {
+               return ' id="workspace-selector"';
+       }
 }
 
 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/classes/class.workspaceselector.php']) {
index 53957ee..2843b99 100644 (file)
@@ -6,8 +6,7 @@ URL    : http://typo3.org
 
 Description : styles the TYPO3 backend
 
-Created  : 2007/10/14
-Modified : 2007/10/17
+       $Id$
 
 - - - - - - - - - - - - - - - - - - - - - */
 
@@ -59,6 +58,7 @@ iframe {
 #typo3-main-container,
 #typo3-main-container * iframe {
        height: 660px;
+       z-index: 1;
 }
 
 
@@ -66,4 +66,3 @@ iframe {
 
 
 
-
index 9bad955..3742e36 100644 (file)
@@ -6,8 +6,7 @@ URL    : http://typo3.org
 
 Description : styles the TYPO3 backend
 
-Created  : 2007/11/01
-Modified : 2007/11/01
+       $Id$
 
 - - - - - - - - - - - - - - - - - - - - - */
 
@@ -27,25 +26,6 @@ Modified : 2007/11/01
 }
 
 
-/* ----- Caching ----- */
-
-#cache-actions {
-       list-style: none;
-       padding: 0px;
-       margin: 15px 0px;
-}
-
-#cache-actions li {
-       padding-left: 2px;
-}
-
-#cache-actions a {
-       display: block;
-       text-decoration: none;
-       vertical-align: center;
-}
-
-
 /* ----- Logout ----- */
 
 #typo3-side-menu form,
@@ -59,26 +39,80 @@ Modified : 2007/11/01
 }
 
 
+/* ----- Toolbar ----- */
 
+.typo3-top-toolbar {
+       padding-right: 15px;
+       text-align: right;
+}
 
+#typo3-toolbar {
+       display: inline;
+       list-style: none;
+       margin: 0px;
+       padding: 0px;
+}
 
+#typo3-toolbar li {
+       float: right;
+}
 
+.toolbar-item {
+       width: 30px;
+       height: 23px;
+       padding-top: 2px;
+       display: block;
+       text-align: center;
+       background-image: url(../gfx/toolbar_separator.png);
+       background-repeat: no-repeat;
+}
 
+.toolbar-item-active {
+       background-image: url(../gfx/toolbar_item_active_bg.png);
+}
 
+/* ----- Workspace Selector ----- */
 
+#workspace-selector {
+       padding-top: 2px;
+       margin-right: 5px;
+}
 
+/* ----- Caching ----- */
 
+#clear-cache-actions-menu ul {
+       position: absolute;
+       list-style: none;
+       padding: 2px 0px 0px;
+       margin: 0px;
+       background-color: #f9f9f9;
+       border: 1px solid #abb2bc;
+       border-top: none;
+       width: 180px;
+       right: 15px;
+}
 
+#clear-cache-actions-menu li {
+       padding-left: 3px;
+       padding-top: 2px;
+       clear: both;
+       text-align: left;
+       float: none;
+       vertical-align: middle;
+       height: 19px;
+}
 
+#clear-cache-actions-menu li img {
+       float: left;
+}
 
-
-
-
-
-
-
-
-
-
+#clear-cache-actions-menu li a {
+       text-decoration: none;
+       display: block;
+       padding-bottom: 2px;
+       padding-left: 5px;
+       float: left;
+       font-size: 11px;
+}
 
 
diff --git a/typo3/gfx/lightning.png b/typo3/gfx/lightning.png
new file mode 100644 (file)
index 0000000..9680afd
Binary files /dev/null and b/typo3/gfx/lightning.png differ
diff --git a/typo3/gfx/lightning_green.png b/typo3/gfx/lightning_green.png
new file mode 100644 (file)
index 0000000..12aed63
Binary files /dev/null and b/typo3/gfx/lightning_green.png differ
diff --git a/typo3/gfx/lightning_red.png b/typo3/gfx/lightning_red.png
new file mode 100644 (file)
index 0000000..3b9ca0f
Binary files /dev/null and b/typo3/gfx/lightning_red.png differ
diff --git a/typo3/gfx/toolbar_item_active_bg.png b/typo3/gfx/toolbar_item_active_bg.png
new file mode 100644 (file)
index 0000000..349bed6
Binary files /dev/null and b/typo3/gfx/toolbar_item_active_bg.png differ
diff --git a/typo3/gfx/toolbar_separator.png b/typo3/gfx/toolbar_separator.png
new file mode 100644 (file)
index 0000000..4e155fc
Binary files /dev/null and b/typo3/gfx/toolbar_separator.png differ
index c9bca1a..0b7ae1c 100644 (file)
@@ -49,6 +49,13 @@ interface backend_toolbarItem {
         * @return      string  the toolbar item rendered as HTML string
         */
        public function render();
+
+       /**
+        * returns additional attributes for the list item in the toolbar
+        *
+        * @return      string          list item HTML attibutes
+        */
+       public function getAdditionalAttributes();
 }
 
 ?>
\ No newline at end of file
diff --git a/typo3/js/clearcachemenu.js b/typo3/js/clearcachemenu.js
new file mode 100644 (file)
index 0000000..1b7dcdf
--- /dev/null
@@ -0,0 +1,90 @@
+/***************************************************************
+*  Copyright notice
+*
+*  (c) 2007 Ingo Renner <ingo@typo3.org>
+*  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!
+***************************************************************/
+
+/**
+ * class to handle the clear cache menu
+ *
+ * $Id$
+ */
+var ClearCacheMenu = Class.create({
+
+       /**
+        * registers for resize event listener and executes on DOM ready
+        */
+       initialize: function() {
+               Event.observe(window, 'resize', this.positionMenu);
+
+               Event.observe(document, 'dom:loaded', function(){
+                       this.toolbarItemIcon = $$('#clear-cache-actions-menu .toolbar-item img')[0].src;
+
+                       Event.observe('clear-cache-actions-menu', 'click', this.toggleMenu)
+
+                               // observe all clicks on clear cache actions in the menu
+                       $$('#clear-cache-actions-menu li a').each(function(element) {
+                               Event.observe(element, 'click', this.clearCache.bind(this));
+                       }.bindAsEventListener(this));
+               }.bindAsEventListener(this));
+       },
+
+       /**
+        * toggles the visibility of the menu and places it under the toolbar icon
+        */
+       toggleMenu: function() {
+               var toolbarItem = $$('#clear-cache-actions-menu > a')[0];
+               var menu        = $$('#clear-cache-actions-menu ul')[0];
+               toolbarItem.blur();
+
+               if(!toolbarItem.hasClassName('toolbar-item-active')) {
+                       toolbarItem.addClassName('toolbar-item-active');
+                       Effect.Appear(menu, {duration: 0.2});
+               } else {
+                       toolbarItem.removeClassName('toolbar-item-active');
+                       Effect.Fade(menu, {duration: 0.1});
+               }
+       },
+
+       /**
+        * calls the actual clear cache URL using an asynchronious HTTP request
+        *
+        * @param       Event   prototype event object
+        */
+       clearCache: function(event) {
+               $$('#clear-cache-actions-menu .toolbar-item img')[0].src = 'gfx/spinner.gif';
+
+               new Ajax.Request(Event.element(event).href, {
+                       'method': 'get',
+                       'onComplete': function() {
+                               $$('#clear-cache-actions-menu .toolbar-item img')[0].src = this.toolbarItemIcon;
+                       }.bind(this)
+               });
+
+               Event.stop(event);
+               this.toggleMenu();
+       }
+
+});
+
+var TYPO3BackendClearCacheMenu = new ClearCacheMenu();
index ca23c03..119cf31 100644 (file)
@@ -29,7 +29,7 @@
 var SizeManager = Class.create({
 
        /**
-        * registers for resize event listener and execute on DOM read
+        * registers for resize event listener and executes on DOM ready
         */
        initialize: function() {
                Event.observe(window, 'resize', this.resizeBackend);
index 7fd85ec..3ef885a 100755 (executable)
@@ -145,9 +145,9 @@ Would you like to save now in order to refresh the display?</label>
                        <label index="rm.closeAllDocs">Close all documents</label>
                        <label index="rm.clearCache_clearCache">Clear cache</label>
                        <label index="rm.clearCache_thisPage">This page</label>
-                       <label index="rm.clearCache_pages">Clear Page Cache</label>
-                       <label index="rm.clearCache_all">Clear FE cache</label>
-                       <label index="rm.clearCache_allTypo3Conf">Clear cache in typo3conf/</label>
+                       <label index="rm.clearCache_pages">clear page content cache</label>
+                       <label index="rm.clearCache_all">clear all caches</label>
+                       <label index="rm.clearCache_allTypo3Conf">clear configuration cache</label>
                        <label index="rm.adminFunctions">Admin functions</label>
                        <label index="rm.edit">Edit</label>
                        <label index="rm.export">Export</label>