Fixed bug #15800: Cleanup CSH code (Thanks to Benjamin Mack and Steffen Kamper)
authorJeff Segars <jsegars@alumni.rice.edu>
Thu, 14 Oct 2010 14:43:05 +0000 (14:43 +0000)
committerJeff Segars <jsegars@alumni.rice.edu>
Thu, 14 Oct 2010 14:43:05 +0000 (14:43 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@9062 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
t3lib/class.t3lib_befunc.php
t3lib/js/extjs/notifications.js
typo3/backend.php
typo3/template.php

index bb19f36..594d32c 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2010-10-14  Jeff Segars  <jeff@webempoweredchurch.org>
+
+       * Fixed bug #15800: Cleanup CSH code (Thanks to Benjamin Mack and Steffen Kamper)
+
 2010-10-14  Benjamin Mack  <benni@typo3.org>
 
        * Followup to #15740: Move versioning code from TCEmain into "version" extension - delete action deleted entries twice (once in deleteAction and once in version extension)
index 41a16c0..641d87f 100644 (file)
@@ -2489,13 +2489,12 @@ final class t3lib_BEfunc {
        public static function helpTextIcon($table, $field, $BACK_PATH, $force = 0) {
                global $TCA_DESCR, $BE_USER;
 
-               $onClick = 'vHWin=window.open(\''.$BACK_PATH.'view_help.php?tfID='.($table.'.'.$field).'\',\'viewFieldHelp\',\'height=400,width=600,status=0,menubar=0,scrollbars=1\');vHWin.focus();return false;';
                if (is_array($TCA_DESCR[$table]) && is_array($TCA_DESCR[$table]['columns'][$field]) && (isset($BE_USER->uc['edit_showFieldHelp']) || $force)) {
                        if ($BE_USER->uc['edit_showFieldHelp'] == 'icon') {
                                $text = self::helpText($table, $field, $BACK_PATH, '');
                                $text = '<span class="typo3-csh-inline">' . $GLOBALS['LANG']->hscAndCharConv($text, FALSE) . '</span>';
                        }
-                       return '<a class="typo3-csh-link" href="#" onclick="'.htmlspecialchars($onClick).'">' . t3lib_iconWorks::getSpriteIcon('actions-system-help-open', array('class' => 'typo3-csh-icon')) . $text.'</a>';
+                       return '<a class="typo3-csh-link" href="#" rel="' . $table . '.' . $field . '">' . t3lib_iconWorks::getSpriteIcon('actions-system-help-open', array('class' => 'typo3-csh-icon')) . $text.'</a>';
                }
        }
 
index 7b01f09..4e56d61 100644 (file)
@@ -262,3 +262,78 @@ TYPO3.Dialog = function() {
                }
        }
 }();
+
+/**
+ * Helper class for dialog windows
+ *
+ * Example usage:
+ *
+ * TYPO3.ContextHelpWindow.open(identifier);
+ */
+TYPO3.ContextHelpWindow = function() {
+       /**
+       * Path to typo3 directory
+       *
+       * @type {String}
+       * @private
+       */
+       var typo3Path = '';
+
+       /**
+       * Context for open a window
+       * "window" - open a new window
+       * "inline" - open a TYPO3.Window (not currently implementy)
+       *
+       * @type {String}
+       * @private
+       */
+       var openContext;
+
+       /**
+       * Width for the window
+       *
+       * @type {Number}
+       * @private
+       */
+       var width;
+       /**
+       * Height of the window
+       *
+       * @type {Number}
+       * @private
+       */
+       var height;
+
+
+       return {
+               /**
+                * init class vars
+                *
+                * @return void
+                */
+               init: function() {
+                       this.typo3Path = top.TYPO3.configuration.PATH_typo3;
+                       this.openContext = 'window';
+                       this.width = top.TYPO3.configuration.ContextHelpWindows.width;
+                       this.height = top.TYPO3.configuration.ContextHelpWindows.height;
+               },
+
+               /**
+                * Open window for TYPO3 inline help
+                *
+                * @param {String} help identifier
+                * @return {Object} window
+                */
+               open: function(helpIdentifier) {
+                       if (this.openContext === 'window') {
+                               var cshWindow = window.open(
+                                       this.typo3Path + 'view_help.php?tfID=' + helpIdentifier,
+                                       'ContextHelpWindow',
+                                       'height=' + this.height + ',width=' + this.width + ',status=0,menubar=0,scrollbars=1'
+                               );
+                               cshWindow.focus();
+                               return cshWindow;
+                       }
+               }
+       }
+}();
\ No newline at end of file
index 4c64393..d731a42 100644 (file)
@@ -104,7 +104,8 @@ class TYPO3backend {
                        'TYPO3.Backend = new TYPO3.Viewport(TYPO3.Viewport.configuration);
                        if (typeof console === "undefined") {
                                console = TYPO3.Backend.DebugConsole;
-                       }',
+                       }
+                       TYPO3.ContextHelpWindow.init();',
                        TRUE
                );
                $this->pageRenderer->addJsInlineCode(
@@ -374,6 +375,10 @@ class TYPO3backend {
                        'showRefreshLoginPopup' => isset($GLOBALS['TYPO3_CONF_VARS']['BE']['showRefreshLoginPopup']) ? intval($GLOBALS['TYPO3_CONF_VARS']['BE']['showRefreshLoginPopup']) : FALSE,
                        'listModulePath' => t3lib_extMgm::isLoaded('list') ? t3lib_extMgm::extRelPath('list') . 'mod1/' : '',
                        'debugInWindow' => $GLOBALS['BE_USER']->uc['debugInWindow'] ? 1 : 0,
+                       'ContextHelpWindows' => array(
+                               'width' => 600,
+                               'height' => 400
+                       )
                );
                $t3LLLcore = array(
                        'waitTitle' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:mess.refresh_login_logging_in') ,
index 0447405..9d98bb5 100644 (file)
@@ -748,6 +748,9 @@ class template {
                        $this->loadJavascriptLib('tab.js');
                }
 
+                       // include the JS for the Context Sensitive Help
+               $this->loadCshJavascript();
+
                        // Get the browser info
                $browserInfo = t3lib_utility_Client::getBrowserInfo(t3lib_div::getIndpEnv('HTTP_USER_AGENT'));
 
@@ -1565,6 +1568,26 @@ $str.=$this->docBodyTagBegin().
               return array('','','');
        }
 
+        /**
+        * This loads everything needed for the Context Sensitive Help (CSH)
+        *
+        * @return void
+        */
+       protected function loadCshJavascript() {
+               $this->pageRenderer->loadExtJS();
+               $this->pageRenderer->addExtOnReadyCode('
+                       Ext.getBody().on({
+                               click: {
+                                       delegate: "a.typo3-csh-link",
+                                       scope:this,
+                                       fn:function(event, link) {
+                                               event.stopEvent();
+                                               top.TYPO3.ContextHelpWindow.open(link.rel);
+                                       }
+                               }
+                       });
+               ');
+       }
 
        /**
         * Creates a tab menu from an array definition