Fixed bug #16059: Use ExtJS Tooltips for CSH labels
authorSteffen Kamper <info@sk-typo3.de>
Tue, 19 Oct 2010 22:56:01 +0000 (22:56 +0000)
committerSteffen Kamper <info@sk-typo3.de>
Tue, 19 Oct 2010 22:56:01 +0000 (22:56 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@9172 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
t3lib/class.t3lib_befunc.php
t3lib/config_default.php
t3lib/extjs/dataprovider/class.extdirect_dataprovider_contexthelp.php [new file with mode: 0644]
t3lib/js/extjs/contexthelp.js [new file with mode: 0644]
typo3/index.php
typo3/sysext/t3skin/stylesheets/visual/element_csh.css
typo3/template.php

index 7fdad7a..eda605d 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -8,7 +8,8 @@
 
 2010-10-19  Steffen Kamper  <steffen@typo3.org>
 
-       * Fixed bug #16071: PHP Fatal error in t3lib_contextmenu_renderer_Abstract (Thanks to Stefan Kowalke)
+       * Fixed bug #16059: Use ExtJS Tooltips for CSH labels
+       * Fixed bug #16071: PHP Fatal error in t3lib_contextmenu_renderer_Abstract (Thanks to Stefano Kowalke)
        * Removal of unused and illegal files inside of codemirror library
        * Fixed bug #16055: BE debug mode should also enable debug mode for libraries
 
index 9b247ca..73e9aed 100644 (file)
@@ -2571,7 +2571,7 @@ final class t3lib_BEfunc {
                        $helpText = '<div class="t3-help-inline">' . $helpText . '</div>';
                        $text = '<abbr class="t3-help-teaser">' . $text . '</abbr>';
 
-                       $text = '<a class="t3-help-link" href="#" rel="' . $table . '|' . $field . '">' . $text . $helpText . '</a>';
+                       $text = '<a class="t3-help-link" href="#" data-table="' . $table . '" data-field="' . $field . '">' . $text . '</a>';
                }
                return $text;
        }
index a7cbd8b..d096206 100644 (file)
@@ -388,7 +388,9 @@ $TYPO3_CONF_VARS = array(
                                'default' => 't3lib/class.t3lib_frontendedit.php:t3lib_frontendedit'
                        )
                ),
-               'ExtDirect' => array(),                                 // array of key value pairs (provider -> location:className) that holds the classes for the ExtDirect functionality
+               'ExtDirect' => array(   // array of key value pairs (provider -> location:className) that holds the classes for the ExtDirect functionality
+                       'TYPO3.CSH.ExtDirect' => 't3lib/extjs/dataprovider/class.extdirect_dataprovider_contexthelp.php:extDirect_DataProvider_ContextHelp'
+               ),
        ),
        'EXTCONF' => array(             // Here you may add manually set configuration options for your extensions. Eg. $TYPO3_CONF_VARS['EXTCONF']['my_extension_key']['my_option'] = 'my_value';
 //             '--key--' => array()
diff --git a/t3lib/extjs/dataprovider/class.extdirect_dataprovider_contexthelp.php b/t3lib/extjs/dataprovider/class.extdirect_dataprovider_contexthelp.php
new file mode 100644 (file)
index 0000000..a2a5e99
--- /dev/null
@@ -0,0 +1,61 @@
+<?php\r
+/***************************************************************\r
+ *  Copyright notice\r
+ *\r
+ *  (c) 2010 Steffen Kamper <steffen@typo3.org>\r
+ *  All rights reserved\r
+ *\r
+ *  This script is part of the TYPO3 project. The TYPO3 project is\r
+ *  free software; you can redistribute it and/or modify\r
+ *  it under the terms of the GNU General Public License as published by\r
+ *  the Free Software Foundation; either version 2 of the License, or\r
+ *  (at your option) any later version.\r
+ *\r
+ *  The GNU General Public License can be found at\r
+ *  http://www.gnu.org/copyleft/gpl.html.\r
+ *  A copy is found in the textfile GPL.txt and important notices to the license\r
+ *  from the author is found in LICENSE.txt distributed with these scripts.\r
+ *\r
+ *\r
+ *  This script is distributed in the hope that it will be useful,\r
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ *  GNU General Public License for more details.\r
+ *\r
+ *  This copyright notice MUST APPEAR in all copies of the script!\r
+ ***************************************************************/\r
+\r
+/**\r
+ * ExtDirect DataProvider for ContextHelp\r
+ */\r
+class extDirect_DataProvider_ContextHelp {\r
+\r
+       /**\r
+        * Fetch the context help for the given table/field parameters\r
+        *\r
+        * @param  string $table table identifier\r
+        * @param  string $field field identifier\r
+        * @return array complete help information\r
+        */\r
+       public function getContextHelp($table, $field) {\r
+\r
+               if (!isset($GLOBALS['TCA_DESCR'][$table]['columns'])) {\r
+                       $GLOBALS['LANG']->loadSingleTableDescription($table);\r
+               }\r
+               $data = $GLOBALS['TCA_DESCR'][$table]['columns'][$field];\r
+\r
+\r
+                       // add description text\r
+               if ($data['description']) {\r
+                       $description = '<p class="t3-help-short">' . nl2br(strip_tags($data['description'])) . '</p>';\r
+               }\r
+\r
+               $title = $data['alttitle'] ? $data['alttitle'] : $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_view_help.xml:title');\r
+\r
+               return array(\r
+                       'title' => $title,\r
+                       'description' => $description,\r
+                       'id' => $table . '.' . $field,\r
+               );\r
+       }\r
+}\r
diff --git a/t3lib/js/extjs/contexthelp.js b/t3lib/js/extjs/contexthelp.js
new file mode 100644 (file)
index 0000000..909d573
--- /dev/null
@@ -0,0 +1,122 @@
+/***************************************************************\r
+ *  Copyright notice\r
+ *\r
+ *  (c) 2010 Steffen Kamper <steffen@typo3.org>\r
+ *  All rights reserved\r
+ *\r
+ *  This script is part of the TYPO3 project. The TYPO3 project is\r
+ *  free software; you can redistribute it and/or modify\r
+ *  it under the terms of the GNU General Public License as published by\r
+ *  the Free Software Foundation; either version 2 of the License, or\r
+ *  (at your option) any later version.\r
+ *\r
+ *  The GNU General Public License can be found at\r
+ *  http://www.gnu.org/copyleft/gpl.html.\r
+ *  A copy is found in the textfile GPL.txt and important notices to the license\r
+ *  from the author is found in LICENSE.txt distributed with these scripts.\r
+ *\r
+ *\r
+ *  This script is distributed in the hope that it will be useful,\r
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+ *  GNU General Public License for more details.\r
+ *\r
+ *  This copyright notice MUST APPEAR in all copies of the script!\r
+ ***************************************************************/\r
+\r
+Ext.ns('TYPO3', 'TYPO3.CSH.ExtDirect');\r
+\r
+/**\r
+ * Class to show tooltips for links that have the css t3-help-link\r
+ * need the tags data-table and data-field (HTML5)\r
+ */\r
+TYPO3.ContextHelp = function() {\r
+       /**\r
+        * Tooltip\r
+        * @type {Ext.ToolTip}\r
+        */\r
+       var tip;\r
+       /**\r
+        * Cache for CSH\r
+        * @type {Ext.util.MixedCollection}\r
+        */\r
+       var cshHelp = new Ext.util.MixedCollection(true);\r
+\r
+       return {\r
+               /**\r
+                * Constructor\r
+                */\r
+               init: function() {\r
+                       tip = new Ext.ToolTip({\r
+                               title: 'TYPO3 CSH',\r
+                               html: '',\r
+                               anchorToTarget: true,\r
+                               width: 160,\r
+                               renderTo: Ext.getBody(),\r
+                               cls: 'typo3-csh-tooltip',\r
+                               dismissDelay: 3000, // auto hide after 3 seconds\r
+                               showsDelay: 2000, // show after 2 seconds\r
+                               listeners: {\r
+                                       'render': function(){\r
+                                               this.body.on('click', function(e){\r
+                                                       e.stopEvent();\r
+                                                       top.TYPO3.ContextHelpWindow.open(this.cshLink);\r
+                                               }, this);\r
+                                       }\r
+                               }\r
+\r
+                       });\r
+                       Ext.select('div').on('mouseover', TYPO3.ContextHelp.showToolTipHelp, TYPO3.ContextHelp, {delegate: 'a.t3-help-link'});\r
+                       Ext.select('div').on('click', TYPO3.ContextHelp.openHelpWindow, TYPO3.ContextHelp, {delegate: 'a.t3-help-link'});\r
+               },\r
+\r
+               /**\r
+                * Shows the tooltip, triggered from mouseover event handler\r
+                *\r
+                * @param {Event} event\r
+                * @param {Node} link\r
+                */\r
+               showToolTipHelp: function(event, link) {\r
+                       event.stopEvent();\r
+                       var table = link.getAttribute('data-table');\r
+                       var field = link.getAttribute('data-field');\r
+                       var key = table + '.' + field;\r
+                       var element = Ext.fly(link);\r
+                       var response;\r
+\r
+                       tip.target = element;\r
+\r
+                       if (response = cshHelp.key(key)) {\r
+                               tip.body.dom.innerHTML = response.description;\r
+                               tip.cshLink = response.id;\r
+                               tip.setTitle(response.title);\r
+                               tip.showBy(element, 'tl-tr');\r
+                       } else {\r
+                               TYPO3.CSH.ExtDirect.getContextHelp(table, field, function(response, options) {\r
+                                       cshHelp[table + '.' + field] = response;\r
+                                       tip.body.dom.innerHTML = response.description;\r
+                                       tip.cshLink = response.id;\r
+                                       tip.setTitle(response.title);\r
+                                       cshHelp.add(response);\r
+                                       tip.showAt(event.getXY());\r
+                               }, this);\r
+                       }\r
+               },\r
+               /**\r
+                * Opens the help window, triggered from click event handler\r
+                *\r
+                * @param {Event} event\r
+                * @param {Node} link\r
+                */\r
+               openHelpWindow: function(event, link) {\r
+                       var id = link.getAttribute('data-table') + '.' + link.getAttribute('data-field');\r
+                       event.stopEvent();\r
+                       top.TYPO3.ContextHelpWindow.open(id);\r
+               }\r
+       }\r
+\r
+}();\r
+/**\r
+ * Calls the init on Ext.onReady\r
+ */\r
+Ext.onReady(TYPO3.ContextHelp.init, TYPO3.ContextHelp);
\ No newline at end of file
index 26beda1..b14e250 100644 (file)
@@ -211,7 +211,7 @@ class SC_index {
                }
 
                        // Starting page:
-               $this->content .= $TBE_TEMPLATE->startPage('TYPO3 Login: ' . htmlspecialchars($TYPO3_CONF_VARS['SYS']['sitename']));
+               $this->content .= $TBE_TEMPLATE->startPage('TYPO3 Login: ' . htmlspecialchars($TYPO3_CONF_VARS['SYS']['sitename']), FALSE);
 
                        // Add login form:
                $this->content.=$this->wrapLoginForm($loginForm);
index 1c9b6d2..97d6e2a 100644 (file)
@@ -59,6 +59,10 @@ div.t3-help-inline p.t3-help-short {
        border-top: none;
 }
 
+p.t3-help-short {
+       cursor: pointer;
+}
+
 img.t3-help-icon {
        cursor: help;
 }
index d02a1c6..75cf7a6 100644 (file)
@@ -677,10 +677,11 @@ class template {
         * This includes the proper header with charset, title, meta tag and beginning body-tag.
         *
         * @param       string          HTML Page title for the header
+        * @param       boolean         flag for including CSH
         * @return      string          Returns the whole header section of a HTML-document based on settings in internal variables (like styles, javascript code, charset, generator and docType)
         * @see endPage()
         */
-       function startPage($title)      {
+       function startPage($title, $includeCsh = TRUE) {
                        // hook pre start page
                if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/template.php']['preStartPageHook'])) {
                        $preStartPageHook =& $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/template.php']['preStartPageHook'];
@@ -753,7 +754,9 @@ class template {
                }
 
                        // include the JS for the Context Sensitive Help
-               $this->loadCshJavascript();
+               if ($includeCsh) {
+                       $this->loadCshJavascript();
+               }
 
                        // Get the browser info
                $browserInfo = t3lib_utility_Client::getBrowserInfo(t3lib_div::getIndpEnv('HTTP_USER_AGENT'));
@@ -1579,21 +1582,9 @@ $str.=$this->docBodyTagBegin().
         */
        protected function loadCshJavascript() {
                $this->pageRenderer->loadExtJS();
-               $this->pageRenderer->addExtOnReadyCode('
-                       Ext.getBody().on({
-                               click: {
-                                       delegate: "a",
-                                       scope:this,
-                                       fn:function(event, link) {
-                                               var element = Ext.fly(link);
-                                               if (element.hasClass("typo3-csh-link") || element.hasClass("t3-help-link")) {
-                                                       event.stopEvent();
-                                                       top.TYPO3.ContextHelpWindow.open(link.rel);
-                                               }
-                                       }
-                               }
-                       });
-               ');
+               $this->pageRenderer->addJsFile($this->backPath .'../t3lib/js/extjs/contexthelp.js');
+               $this->pageRenderer->addJsFile($this->backPath . 'ajax.php?ajaxID=ExtDirect::getAPI&namespace=TYPO3.CSH', NULL, FALSE);
+               $this->pageRenderer->addExtDirectCode();
        }
 
        /**