Fixed bug #16074: Add new API t3lib_befunc::helpTextArray and use it in the ExtDirect...
authorErnesto Baschny <ernst@cron-it.de>
Wed, 20 Oct 2010 09:31:10 +0000 (09:31 +0000)
committerErnesto Baschny <ernst@cron-it.de>
Wed, 20 Oct 2010 09:31:10 +0000 (09:31 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@9183 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
t3lib/class.t3lib_befunc.php
t3lib/extjs/dataprovider/class.extdirect_dataprovider_contexthelp.php

index c33e00e..489d709 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -6,6 +6,8 @@
 2010-10-20  Ernesto Baschny  <ernst@cron-it.de>
 
        * Fixed bug #16075: Add IfModule mod_rewrite.c to misc/advanced.htaccess
+       * Fixed bug #16077: Palette titles have no margin to the left in the new page / tt_content form layouts
+       * Fixed bug #16074: Add new API t3lib_befunc::helpTextArray and use it in the ExtDirect tooltips
 
 2010-10-20  Steffen Gebert  <steffen@steffen-gebert.de>
 
index 73e9aed..06379f4 100644 (file)
@@ -2509,6 +2509,43 @@ final class t3lib_BEfunc {
                }
        }
 
+       /**
+        * Returns CSH help text (description), if configured for, as an array (title, description)
+        * Will automatically call t3lib_BEfunc::helpTextIcon() to get the icon for the text.
+        *
+        * @param       string  Table name
+        * @param       string  Field name
+        * @return      array   With keys 'description' (raw, as available in locallang), 'title' (optional), 'moreInfo'
+        */
+       public static function helpTextArray($table, $field) {
+               if (!isset($GLOBALS['TCA_DESCR'][$table]['columns'])) {
+                       $GLOBALS['LANG']->loadSingleTableDescription($table);
+               }
+               $output = array(
+                       'description' => NULL,
+                       'title' => NULL,
+                       'moreInfo' => FALSE,
+               );
+               if (is_array($GLOBALS['TCA_DESCR'][$table]) && is_array($GLOBALS['TCA_DESCR'][$table]['columns'][$field])) {
+                       $data = $GLOBALS['TCA_DESCR'][$table]['columns'][$field];
+
+                               // add alternative title, if defined
+                       if ($data['alttitle']) {
+                               $output['title'] = $data['alttitle'];
+                       }
+
+                               // if we have more information to show
+                       if ($data['image_descr'] || $data['seeAlso'] || $data['details'] || $data['syntax']) {
+                               $output['moreInfo'] = TRUE;
+                       }
+
+                               // add description
+                       if ($data['description']) {
+                               $output['description'] = $data['description'];
+                       }
+               }
+               return $output;
+       }
 
        /**
         * Returns CSH help text (description), if configured for.
@@ -2524,25 +2561,27 @@ final class t3lib_BEfunc {
         * @return      string          HTML content for help text
         */
        public static function helpText($table, $field, $BACK_PATH = '', $styleAttrib = '') {
-               global $TCA_DESCR, $BE_USER;
-               $output = '';
+               $helpTextArray = self::helpTextArray($table, $field);
 
-               if (is_array($TCA_DESCR[$table]) && is_array($TCA_DESCR[$table]['columns'][$field])) {
-                       $data = $TCA_DESCR[$table]['columns'][$field];
-                               // add see also arrow
-                       if ($data['image_descr'] || $data['seeAlso'] || $data['details'] || $data['syntax']) {
-                               $arrow = t3lib_iconWorks::getSpriteIcon('actions-view-go-forward');
-                       }
-                               // add description text
-                       if ($data['description'] || $arrow) {
-                               $output = '<p class="t3-help-short">' . nl2br(htmlspecialchars($data['description'])) . $arrow . '</p>';
-                       }
+               $output = '';
 
-                               // put header before the rest of the text
-                       if ($data['alttitle']) {
-                               $output = '<h2 class="t3-row-header">' . $data['alttitle'] . '</h2>' . $output;
-                       }
+                       // put header before the rest of the text
+               if ($helpTextArray['title'] !== NULL) {
+                       $output .= '<h2 class="t3-row-header">' . $helpTextArray['title'] . '</h2>';
+               }
+                       // add the content
+               if ($helpTextArray['description'] !== NULL) {
+                       $output .= $helpTextArray['description'];
+               }
+                       // add see also arrow if we have more info
+               if ($data['moreInfo']) {
+                       $arrow = t3lib_iconWorks::getSpriteIcon('actions-view-go-forward');
+               }
+                       // add description text
+               if ($data['description'] || $arrow) {
+                       $output['description'] = '<p class="t3-help-short">' . nl2br(htmlspecialchars($data['description'])) . $arrow . '</p>';
                }
+
                return $output;
        }
 
@@ -2567,10 +2606,7 @@ final class t3lib_BEfunc {
                        if ($text == '') {
                                $text = t3lib_iconWorks::getSpriteIcon('actions-system-help-open');
                        }
-
-                       $helpText = '<div class="t3-help-inline">' . $helpText . '</div>';
                        $text = '<abbr class="t3-help-teaser">' . $text . '</abbr>';
-
                        $text = '<a class="t3-help-link" href="#" data-table="' . $table . '" data-field="' . $field . '">' . $text . '</a>';
                }
                return $text;
index 86d9d37..b16bb88 100644 (file)
@@ -38,23 +38,10 @@ class extDirect_DataProvider_ContextHelp {
         * @return array complete help information
         */
        public function getContextHelp($table, $field) {
-
-               if (!isset($GLOBALS['TCA_DESCR'][$table]['columns'])) {
-                       $GLOBALS['LANG']->loadSingleTableDescription($table);
-               }
-               $data = $GLOBALS['TCA_DESCR'][$table]['columns'][$field];
-
-
-                       // add description text
-               if ($data['description']) {
-                       $description = '<p class="t3-help-short">' . nl2br(strip_tags($data['description'])) . '</p>';
-               }
-
-               $title = $data['alttitle'] ? $data['alttitle'] : $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_view_help.xml:title');
-
+               $helpTextArray = t3lib_befunc::helpTextArray($table, $field);
                return array(
-                       'title' => $title,
-                       'description' => $description,
+                       'title' => $helpTextArray['title'],
+                       'description' => '<p class="t3-help-short">' . nl2br(strip_tags($helpTextArray['description'])) . '</p>',
                        'id' => $table . '.' . $field,
                );
        }