Added feature #15990: Introduce a new CSH API function and make use of it in TCEforms
authorBenni Mack <benni.mack@typo3.org>
Fri, 15 Oct 2010 20:56:49 +0000 (20:56 +0000)
committerBenni Mack <benni.mack@typo3.org>
Fri, 15 Oct 2010 20:56:49 +0000 (20:56 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@9081 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
t3lib/class.t3lib_befunc.php
t3lib/class.t3lib_tceforms.php
typo3/stylesheets/structure/element_csh.css
typo3/sysext/setup/ext_tables.php
typo3/sysext/t3skin/stylesheets/structure/element_csh.css
typo3/sysext/t3skin/stylesheets/visual/element_csh.css
typo3/template.php

index 9437412..23ec43c 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -8,6 +8,7 @@
 
 2010-10-15  Benjamin Mack  <benni@typo3.org>
 
+       * Added feature #15990: Introduce a new CSH API function and make use of it in TCEforms
        * Added feature #15989: Create a new abstract class t3lib_message_abstractmessage
 
 2010-10-15 Steffen Kamper  <steffen@typo3.org>
index 4157c8a..a7934ad 100644 (file)
@@ -2482,8 +2482,14 @@ final class t3lib_BEfunc {
 
        /**
         * Returns help-text icon if configured for.
-        * TCA_DESCR must be loaded prior to this function and $BE_USER must have 'edit_showFieldHelp' set to 'icon', otherwise nothing is returned
+        * TCA_DESCR must be loaded prior to this function and $BE_USER must 
+        * have 'edit_showFieldHelp' set to 'icon', otherwise nothing is returned
         * Usage: 6
+        * 
+        * Please note: since TYPO3 4.5 the UX team decided to not use CSH in its former way,
+        * but to wrap the given text (where before the help icon was, and you could hover over it)
+        * Please also note that since TYPO3 4.5 the option to enable help (none, icon only, full text) 
+        * was completely removed.
         *
         * @param       string          Table name
         * @param       string          Field name
@@ -2496,7 +2502,7 @@ final class t3lib_BEfunc {
 
                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 = self::helpText($table, $field);
                                $text = '<span class="typo3-csh-inline">' . $GLOBALS['LANG']->hscAndCharConv($text, FALSE) . '</span>';
                        }
                        return '<a class="typo3-csh-link" href="#" rel="' . $table . '.' . $field . '">' . t3lib_iconWorks::getSpriteIcon('actions-system-help-open', array('class' => 'typo3-csh-icon')) . $text.'</a>';
@@ -2513,11 +2519,11 @@ final class t3lib_BEfunc {
         *
         * @param       string          Table name
         * @param       string          Field name
-        * @param       string          Back path
+        * @param       string          Back path, deprecated since TYPO3 4.5, will be removed in TYPO3 4.7, because not used at all
         * @param       string          DEPRECATED: Additional style-attribute content for wrapping table (now: only in function cshItem needed)
         * @return      string          HTML content for help text
         */
-       public static function helpText($table, $field, $BACK_PATH, $styleAttrib = '') {
+       public static function helpText($table, $field, $BACK_PATH = '', $styleAttrib = '') {
                global $TCA_DESCR, $BE_USER;
                $output = '';
 
@@ -2529,7 +2535,7 @@ final class t3lib_BEfunc {
                        }
                                // add description text
                        if ($data['description'] || $arrow) {
-                               $output = '<p class="t3-csh-short">' . nl2br(htmlspecialchars($data['description'])) . $arrow . '</p>';
+                               $output = '<p class="t3-help-short">' . nl2br(htmlspecialchars($data['description'])) . $arrow . '</p>';
                        }
 
                                // put header before the rest of the text
@@ -2540,6 +2546,36 @@ final class t3lib_BEfunc {
                return $output;
        }
 
+       /**
+        * API function that wraps the text / html in help text, so if a user hovers over it
+        * the help text will show up
+        * This is the new help API function since TYPO3 4.5, and uses the new behaviour
+        * (hover over text, no icon, no fulltext option, no option to disable the help)
+        * 
+        * @param       string  $table  The table name for which the help should be shown
+        * @param       string  $field  The field name for which the help should be shown
+        * @param       string  $text   the text which should be wrapped with the help text
+        * @return      string  the HTML code ready to render
+        * @api public
+        */
+       public static function wrapInHelp($table, $field, $text = '') {
+                       // get the help text that should be shown on hover
+               $GLOBALS['LANG']->loadSingleTableDescription($table);
+               $helpText = self::helpText($table, $field);
+               if ($helpText) {
+                               // if no text was given, just use the regular help icon 
+                       if ($text == '') {
+                               $text = t3lib_iconWorks::getSpriteIcon('actions-system-help-open');
+                       }
+
+                       $helpText = '<span class="t3-help-inline">' . $GLOBALS['LANG']->hscAndCharConv($helpText, FALSE) . '</span>';
+                       $text = '<abbr class="t3-help-teaser">' . $text . '</abbr>';
+
+                       $text = '<a class="t3-help-link" href="#" rel="' . $table . '|' . $field . '">' . $text . $helpText . '</a>';
+               }
+               return $text;
+       } 
+
 
        /**
         * API for getting CSH icons/text for use in backend modules.
index 137dc91..7f3e3b5 100644 (file)
@@ -921,11 +921,14 @@ class t3lib_TCEforms      {
                                        }
 
                                                // If the record has been saved and the "linkTitleToSelf" is set, we make the field name into a link, which will load ONLY this field in alt_doc.php
-                                       $PA['label'] = t3lib_div::deHSCentities(htmlspecialchars($PA['label']));
+                                       $label = t3lib_div::deHSCentities(htmlspecialchars($PA['label']));
                                        if (t3lib_div::testInt($row['uid']) && $PA['fieldTSConfig']['linkTitleToSelf'] && !t3lib_div::_GP('columnsOnly'))       {
                                                $lTTS_url = $this->backPath.'alt_doc.php?edit['.$table.']['.$row['uid'].']=edit&columnsOnly='.$field.'&returnUrl='.rawurlencode($this->thisReturnUrl());
-                                               $PA['label'] = '<a href="'.htmlspecialchars($lTTS_url).'">'.$PA['label'].'</a>';
+                                               $label = '<a href="' . htmlspecialchars($lTTS_url) . '">' . $label . '</a>';
                                        }
+                                       
+                                               // wrap the label with help text
+                                       $PA['label'] = $label = t3lib_BEfunc::wrapInHelp($table, $field, $label);
 
                                                // Create output value:
                                        if ($PA['fieldConf']['config']['form_type']=='user' && $PA['fieldConf']['config']['noTableWrapping'])   {
@@ -933,23 +936,20 @@ class t3lib_TCEforms      {
                                        } elseif ($PA['palette'])       {
                                                        // Array:
                                                $out=array(
-                                                       'NAME'=>$PA['label'],
+                                                       'NAME' => $label,
                                                        'ID'=>$row['uid'],
                                                        'FIELD'=>$field,
                                                        'TABLE'=>$table,
-                                                       'ITEM'=>$item,
-                                                       'HELP_ICON' => $this->helpTextIcon($table,$field,1)
+                                                       'ITEM'=>$item
                                                );
                                                $out = $this->addUserTemplateMarkers($out,$table,$field,$row,$PA);
                                        } else {
                                                        // String:
                                                $out=array(
-                                                       'NAME'=>$PA['label'],
+                                                       'NAME'=>$label,
                                                        'ITEM'=>$item,
                                                        'TABLE'=>$table,
                                                        'ID'=>$row['uid'],
-                                                       'HELP_ICON'=>$this->helpTextIcon($table,$field),
-                                                       'HELP_TEXT'=>$this->helpText($table,$field),
                                                        'PAL_LINK_ICON'=>$thePalIcon,
                                                        'FIELD'=>$field
                                                );
@@ -4820,8 +4820,8 @@ class t3lib_TCEforms      {
                        // Wrapping a single field:
                $this->fieldTemplate='
                        <tr ###BGCOLOR_HEAD######CLASSATTR_2###>
-                               <td>###FIELD_HELP_ICON###</td>
-                               <td width="99%"><span style="color:###FONTCOLOR_HEAD###;"###CLASSATTR_4###><strong>###FIELD_NAME###</strong></span>###FIELD_HELP_TEXT###</td>
+                               <td>&nbsp;</td>
+                               <td width="99%"><span style="color:###FONTCOLOR_HEAD###;"###CLASSATTR_4###><strong>###FIELD_NAME###</strong></span></td>
                        </tr>
                        <tr ###BGCOLOR######CLASSATTR_1###>
                                <td nowrap="nowrap"><img name="req_###FIELD_TABLE###_###FIELD_ID###_###FIELD_FIELD###" src="clear.gif" class="t3-TCEforms-reqImg" alt="" /><img name="cm_###FIELD_TABLE###_###FIELD_ID###_###FIELD_FIELD###" src="clear.gif" class="t3-TCEforms-contentchangedImg" alt="" /></td>
@@ -5096,7 +5096,6 @@ class t3lib_TCEforms      {
                                                '</label>' .
                                                '<span' . $fieldAttributes . '>' .
                                                        $content['ITEM'] .
-                                                       $content['HELP_ICON'] .
                                                '</span>' .
                                        '</span>';
                        }
index f5bd7b6..c9197e5 100644 (file)
@@ -10,4 +10,12 @@ a.typo3-csh-link span.typo3-csh-inline {
 
 a.typo3-csh-link:hover span.typo3-csh-inline {
        display: block;
+}
+
+.t3-help-link span.t3-help-inline {
+       display: none;
+}
+
+a.t3-help-link:hover span.t3-help-inline {
+       display: block;
 }
\ No newline at end of file
index 0735a1a..b6ba10b 100755 (executable)
@@ -74,22 +74,11 @@ $GLOBALS['TYPO3_USER_SETTINGS'] = array(
                        'label' => 'LLL:EXT:setup/mod/locallang.xml:edit_wideDocument',
                        'csh' => 'edit_wideDocument',
                ),
-               'edit_showFieldHelp' => array(
-                       'type' => 'select',
-                       'items' => array (
-                               '0' => 'LLL:EXT:setup/mod/locallang.xml:edit_showFieldHelp_none',
-                               'icon' => 'LLL:EXT:setup/mod/locallang.xml:edit_showFieldHelp_icon',
-                               'text' => 'LLL:EXT:setup/mod/locallang.xml:edit_showFieldHelp_message',
-                       ),
-                       'label' => 'LLL:EXT:setup/mod/locallang.xml:edit_showFieldHelp',
-                       'csh' => 'edit_showFieldHelp',
-               ),
                'titleLen' => array(
                        'type' => 'text',
                        'label' => 'LLL:EXT:setup/mod/locallang.xml:maxTitleLen',
                        'csh' => 'maxTitleLen',
                ),
-
                'edit_RTE' => array(
                        'type' => 'check',
                        'label' => 'LLL:EXT:setup/mod/locallang.xml:edit_RTE',
index e930547..e2a3902 100644 (file)
@@ -119,4 +119,126 @@ div.typo3-view-help .introduction {
 
 div.typo3-view-help img.c-inlineimg  {
        margin-left: 10px;
+}
+
+
+/*** new help code ***/
+.t3-help-teaser {
+       border-bottom: 1px dotted #434343;
+}
+table.t3-help-inline {
+       margin: 3px 4px 20px 0px;
+       padding: 0;
+}
+
+table.t3-help-inline a.t3-help-link {
+       float: none;
+       margin-right: 0;
+}
+
+a.t3-help-link .t3-help-inline {
+       display: none;
+       padding: 0px;
+       position: absolute;
+       width: 200px;
+       z-index: 100;
+}
+
+a.t3-help-link .t3-help-inline.show-right {
+       right: 10px;
+}
+
+table.t3-help-inline a.t3-help-link,
+table.t3-help-inline span.t3-row-header,
+span.t3-help-inline span.t3-row-header,
+a.t3-help-link span.t3-help-inline span.t3-row-header {
+       display: block;
+}
+
+a.t3-help-link:hover .t3-help-inline {
+       display: block;
+}
+
+.t3-help-inline h2.t3-row-header {
+       margin: 0;
+       height: auto;
+}
+
+.t3-help-inline p.t3-help-short {
+       padding: 3px;
+}
+
+table.t3-help-inline a.t3-help-link {
+       height: 16px;
+}
+
+table.t3-help-inline tr td h4 {
+       margin-top: 0px;
+       margin-bottom: 0px;
+}
+
+table.t3-help-inline span.paragraph,
+a.t3-help-link span.t3-help-inline span.paragraph {
+       display: block;
+       padding: 3px;
+}
+
+img.t3-help-icon {
+       vertical-align: middle;
+}
+
+div.t3-view-help h1 {
+       margin-bottom: 0px;
+       padding: 10px;
+}
+
+div.t3-view-help h2 {
+       margin-top: 0;
+       padding: 4px 2px 4px 10px;
+}
+
+div.t3-view-help h3 {
+       padding: 5px 10px;
+}
+
+div.t3-view-help h4 {
+       padding: 2px 10px;
+}
+
+div.t3-view-help {
+       margin: 0;
+       width: 100%;
+}
+
+div.t3-view-help p {
+       margin: 4px 4px 12px 10px;
+}
+
+div.t3-view-help div.c-toc {
+       padding-left: 6px;
+}
+
+div.t3-view-help div.c-toc p {
+       margin: 0;
+}
+
+div.t3-view-help div.c-toc ul {
+       padding: 2px 5px;
+}
+
+div.t3-view-help div.c-toc ul li ul {
+       margin-left: 10px;
+}
+
+div.t3-view-help div.c-toc ul li {
+       padding: 2px;
+}
+
+div.t3-view-help .manual-title,
+div.t3-view-help .introduction {
+       padding: 0 12px 6px;
+}
+
+div.t3-view-help img.c-inlineimg  {
+       margin-left: 10px;
 }
\ No newline at end of file
index 4baf839..1c9b6d2 100644 (file)
@@ -35,6 +35,39 @@ a.typo3-csh-link {
        white-space: normal;
 }
 
+/** new CSH code **/
+table.t3-help-inline {
+       background-color: #ffffff;
+       border: 1px solid #a2aab8;
+}
+
+.t3-help-inline {
+       box-shadow: 0px 1px 3px rgba(0, 0, 0, 0.3);
+       -moz-box-shadow: 0px 1px 3px rgba(0, 0, 0, 0.3);
+       -webkit-box-shadow: 0px 1px 3px rgba(0, 0, 0, 0.3);
+       line-height: 16px;
+}
+
+a.t3-help-link .t3-help-inline {
+       background: #ffffff;
+       color: #000000;
+       font-weight: normal;
+}
+
+div.t3-help-inline p.t3-help-short {
+       border: #b6b6b6 1px solid;
+       border-top: none;
+}
+
+img.t3-help-icon {
+       cursor: help;
+}
+
+a.t3-help-link {
+       white-space: normal;
+}
+
+
 /*  view_help.php */
 #typo3-view-help-php {
 }
index 9d98bb5..33ed1c5 100644 (file)
@@ -1578,11 +1578,14 @@ $str.=$this->docBodyTagBegin().
                $this->pageRenderer->addExtOnReadyCode('
                        Ext.getBody().on({
                                click: {
-                                       delegate: "a.typo3-csh-link",
+                                       delegate: "a",
                                        scope:this,
                                        fn:function(event, link) {
-                                               event.stopEvent();
-                                               top.TYPO3.ContextHelpWindow.open(link.rel);
+                                               var element = Ext.fly(link);
+                                               if (element.hasClass("typo3-csh-link") || element.hasClass("t3-help-link")) {
+                                                       event.stopEvent();
+                                                       top.TYPO3.ContextHelpWindow.open(link.rel);
+                                               }
                                        }
                                }
                        });