Fixed bug #16706: Use ExtJS for collapseable sections like in reports module
authorSteffen Kamper <info@sk-typo3.de>
Fri, 17 Dec 2010 17:55:08 +0000 (17:55 +0000)
committerSteffen Kamper <info@sk-typo3.de>
Fri, 17 Dec 2010 17:55:08 +0000 (17:55 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@9830 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
t3lib/core_autoload.php
typo3/sysext/reports/ext_tables.php
typo3/sysext/reports/mod/index.php
typo3/sysext/reports/reports/class.tx_reports_reports_status.php
typo3/template.php

index dab8feb..051635e 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -14,6 +14,7 @@
 
 2010-12-17  Steffen Kamper  <steffen@typo3.org>
 
+       * Fixed bug #16706: Use ExtJS for collapseable sections like in reports module
        * Fixed bug #15686: Call the list module through the dispatcher instead directly (Thanks to Helmut Hummel)
        * Fixed bug #16735: Inclusion of js/css for loadResourcesForRegisteredNavigationComponents lacks loading order
        * Fixed bug #16084: Clicking a label should set the focus on the input field
index a6fa21c..331fcaa 100644 (file)
@@ -135,7 +135,7 @@ $t3libClasses = array(
        't3lib_tceformsinlinehook' => PATH_t3lib . 'interfaces/interface.t3lib_tceformsinlinehook.php',
        't3lib_tcemain_checkmodifyaccesslisthook' => PATH_t3lib . 'interfaces/interface.t3lib_tcemain_checkmodifyaccesslisthook.php',
        't3lib_tcemain_processuploadhook' => PATH_t3lib . 'interfaces/interface.t3lib_tcemain_processuploadhook.php',
-       't3lib_mail_mboxtransport' => PATH_t3lib . 'mail/class.t3lib_mail_mboxtransport.php', 
+       't3lib_mail_mboxtransport' => PATH_t3lib . 'mail/class.t3lib_mail_mboxtransport.php',
        't3lib_mail_message' => PATH_t3lib . 'mail/class.t3lib_mail_message.php',
        't3lib_mail_mailer' => PATH_t3lib . 'mail/class.t3lib_mail_mailer.php',
        'tx_t3lib_mail_hooks' => PATH_t3lib . 'mail/class.tx_t3lib_mail_hooks.php',
@@ -189,6 +189,7 @@ $t3libClasses = array(
        't3lib_tree_tca_databasetreedataprovider' => PATH_t3lib . 'tree/tca/class.t3lib_tree_tca_databasetreedataprovider.php',
        't3lib_tree_tca_dataproviderfactory' => PATH_t3lib . 'tree/tca/class.t3lib_tree_tca_dataproviderfactory.php',
        't3lib_tree_tca_tcatree' => PATH_t3lib . 'tree/tca/class.t3lib_tree_tca_tcatree.php',
+       'extdirect_dataprovider_backendusersettings' => PATH_t3lib . 'extjs/dataprovider/class.extdirect_dataprovider_beusersettings.php',
 );
 
 $tslibClasses = require(PATH_typo3 . 'sysext/cms/ext_autoload.php');
index 9172dfd..757f61d 100644 (file)
@@ -27,7 +27,6 @@ if (TYPO3_MODE == 'BE') {
        $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['reports']['tx_reports']['status']['providers']['security'][] = 'tx_reports_reports_status_SecurityStatus';
        $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['reports']['tx_reports']['status']['providers']['configuration'][] = 'tx_reports_reports_status_ConfigurationStatus';
 
-       $GLOBALS['TYPO3_CONF_VARS']['BE']['AJAX']['Reports::saveCollapseState'] = 'EXT:reports/reports/class.tx_reports_reports_status.php:tx_reports_reports_Status->saveCollapseState';
 }
 
 ?>
\ No newline at end of file
index d603721..8de86c7 100644 (file)
@@ -55,7 +55,6 @@ class tx_reports_Module extends t3lib_SCbase {
                        t3lib_extMgm::extPath('reports') . 'mod/mod_template.html'
                );
                $this->doc->backPath = $GLOBALS['BACK_PATH'];
-               $this->doc->getPageRenderer()->loadScriptaculous('effects');
                $this->doc->addStyleSheet(
                        'tx_reports',
                        '../' . t3lib_extMgm::siteRelPath('reports') . 'mod/mod_styles.css'
@@ -111,29 +110,6 @@ class tx_reports_Module extends t3lib_SCbase {
                                function jumpToUrl(URL) {
                                        document.location = URL;
                                }
-                               var state;
-                               Event.observe(document, "dom:loaded", function(){
-                                       $$("h2.section-header").invoke("observe", "click", function(event){
-                                               var item = Event.element(event);
-                                                       // possible icon inside h2
-                                               if (item.hasClassName("t3-icon")) {
-                                                       item = item.up("h2");
-                                               }
-                                               if (item.hasClassName("expanded")) {
-                                                       item.removeClassName("expanded").addClassName("collapsed");
-                                                       Effect.BlindUp(item.next("div"), {duration : 0.5});
-                                                       state = 1;
-                                               } else {
-                                                       item.removeClassName("collapsed").addClassName("expanded");
-                                                       Effect.BlindDown(item.next("div"), {duration : 0.5});
-                                                       state = 0;
-                                               }
-                                               event.stop();
-                                               new Ajax.Request("ajax.php", {
-                                                       parameters : "ajaxID=Reports::saveCollapseState&item=" + item.id + "&state=" + state
-                                               });
-                                       });
-                               });
                        ';
                        $this->doc->postCode='
                                <script language="javascript" type="text/javascript">
index 38566a4..31f6619 100644 (file)
@@ -164,14 +164,6 @@ class tx_reports_reports_Status implements tx_reports_Report {
                        $providerState = $this->sortStatuses($providerStatus);
 
                        $id = str_replace(' ', '-', $provider);
-                       if (isset($GLOBALS['BE_USER']->uc['reports']['states'][$id]) && $GLOBALS['BE_USER']->uc['reports']['states'][$id]) {
-                               $collapsedStyle = 'style="display: none"';
-                               $collapsedClass = 'collapsed';
-                       } else {
-                               $collapsedStyle = '';
-                               $collapsedClass = 'expanded';
-                       }
-
                        $classes = array(
                                tx_reports_reports_status_Status::NOTICE  => 'notice',
                                tx_reports_reports_status_Status::INFO    => 'information',
@@ -199,8 +191,7 @@ class tx_reports_reports_Status implements tx_reports_Report {
                        if ($sectionSeverity > 0) {
                                $headerIcon = $icon[$sectionSeverity];
                        }
-                       $content .= '<h2 id="' . $id . '" class="section-header ' . $collapsedClass . '">' . $headerIcon . $provider . '</h2>
-                               <div ' . $collapsedStyle . '>' . $messages . '</div>';
+                       $content .= $GLOBALS['TBE_TEMPLATE']->collapseableSection($headerIcon . $provider, $messages, $id, 'reports.states');
                }
 
                return $content;
@@ -282,19 +273,6 @@ class tx_reports_reports_Status implements tx_reports_Report {
                return $statuses;
        }
 
-       /**
-        * Saves the section toggle state in the backend user's uc.
-        *
-        * @param       array   Array of parameters from the AJAX interface, currently unused
-        * @param       TYPO3AJAX       Object of type TYPO3AJAX
-        */
-       public function saveCollapseState(array $params, TYPO3AJAX $ajaxObj) {
-               $item = t3lib_div::_POST('item');
-               $state = (bool)t3lib_div::_POST('state');
-
-               $GLOBALS['BE_USER']->uc['reports']['states'][$item] = $state;
-               $GLOBALS['BE_USER']->writeUC();
-       }
 }
 
 
index 2f15932..230e9dc 100644 (file)
@@ -2131,11 +2131,73 @@ $str.=$this->docBodyTagBegin().
                return $pageInfo;
        }
 
+       /**
+        * Makes a collapseable section. See reports module for an example
+        *
+        * @param  string  $title
+        * @param  string  $html
+        * @param  string  $id
+        * @param  string $saveStatePointer
+        * @return string
+        */
+       public function collapseableSection($title, $html, $id, $saveStatePointer = '') {
+               $hasSave = $saveStatePointer ? TRUE : FALSE;
+               $collapsedStyle =  $collapsedClass = '';
+
+               if ($hasSave) {
+                       /** @var $settings extDirect_DataProvider_BackendUserSettings */
+                       $settings = t3lib_div::makeInstance('extDirect_DataProvider_BackendUserSettings');
+                       $value = $settings->get($saveStatePointer . '.' . $id);
+                       if ($value) {
+                               $collapsedStyle = ' style="display: none"';
+                               $collapsedClass = ' collapsed';
+                       } else {
+                               $collapsedStyle = '';
+                               $collapsedClass = ' expanded';
+                       }
+               }
 
+               $this->pageRenderer->loadExtJS();
+               $this->pageRenderer->addExtOnReadyCode('
+                       Ext.select("h2.section-header").each(function(element){
+                               element.on("click", function(event, tag) {
+                                       var state = 0,
+                                               el = Ext.fly(tag),
+                                               div = el.next("div"),
+                                               saveKey = el.getAttribute("rel");
+                                       if (el.hasClass("collapsed")) {
+                                               el.removeClass("collapsed").addClass("expanded");
+                                               div.slideIn("t", {
+                                                       easing: "easeIn",
+                                                       duration: .5
+                                               });
+                                       } else {
+                                               el.removeClass("expanded").addClass("collapsed");
+                                               div.slideOut("t", {
+                                                       easing: "easeOut",
+                                                       duration: .5,
+                                                       remove: false,
+                                                       useDisplay: true
+                                               });
+                                               state = 1;
+                                       }
+                                       if (saveKey) {
+                                               try {
+                                                       top.TYPO3.BackendUserSettings.ExtDirect.set(saveKey + "." + tag.id, state, function(response) {});
+                                               } catch(e) {}
+                                       }
+                               });
+                       });
+               ');
+               return '
+                 <h2 id="' . $id . '" class="section-header' . $collapsedClass . '" rel="' . $saveStatePointer . '"> ' . $title . '</h2>
+                 <div' . $collapsedStyle  . '>' . $html . '</div>
+               ';
 
+       }
 
 
-               }
+}
 
 
 // ******************************