Fixed bug #7028: Implement CSH for flexforms
authorDmitry Dulepov <dmitry.dulepov@gmail.com>
Thu, 27 Dec 2007 17:53:32 +0000 (17:53 +0000)
committerDmitry Dulepov <dmitry.dulepov@gmail.com>
Thu, 27 Dec 2007 17:53:32 +0000 (17:53 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@2860 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
t3lib/class.t3lib_tceforms.php
typo3/view_help.php

index 110fda2..88e1a38 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2007-12-27     Dmitry Dulepov  <dmitry@typo3.org>
+
+       * Fixed bug #7028: Implement CSH for flexforms
+
 2007-12-26  Oliver Hader  <oh@inpublica.de>
 
        * (minor) Fixed bug #6651: IRRE - Button for creating new records disappeared on nested child records if a parent record reached the maxitems value
index 8669108..7362f93 100755 (executable)
@@ -2264,6 +2264,7 @@ class t3lib_TCEforms      {
                                                $lang = 'l'.$lKey;      // Default language, other options are "lUK" or whatever country code (independant of system!!!)
                                                $PA['_valLang'] = $langChildren && !$langDisabled ? $editData['meta']['currentLangId'] : 'DEF'; // Default language, other options are "lUK" or whatever country code (independant of system!!!)
                                                $PA['_lang'] = $lang;
+                                               $PA['_cshFile'] = ((isset($dataStruct['ROOT']['TCEforms']) && isset($dataStruct['ROOT']['TCEforms']['cshFile'])) ? $dataStruct['ROOT']['TCEforms']['cshFile'] : '');
 
                                                        // Render flexform:
                                                $tRows = $this->getSingleField_typeFlex_draw(
@@ -2598,8 +2599,15 @@ class t3lib_TCEforms     {
 
                                                                        // Put row together
                                                                        // possible linebreaks in the label through xml: \n => <br/>, usage of nl2br() not possible, so it's done through str_replace
-                                                               $tRows[]='<div>
-                                                                       <div class="bgColor5">'.($vDEFkey=='vDEF' ? '' : $this->getLanguageIcon($table,$row,$vDEFkey)).str_replace('\n', '<br />', $theTitle).'</div>
+                                                               $processedTitle = str_replace('\n', '<br />', $theTitle);
+                                                               $helpText = $this->helpText_typeFlex($key, $processedTitle, $PA['_cshFile']);
+                                                               $tRows[]='<div>' .
+                                                                       '<div class="bgColor5">' .
+                                                                       ($helpText ?
+                                                                               ($vDEFkey=='vDEF' ? '' : $this->getLanguageIcon($table, $row, $vDEFkey)) . '<strong>' . $processedTitle . '</strong>' . $helpText :
+                                                                               $this->helpTextIcon_typeFlex($key, $processedTitle, $PA['_cshFile']) . ($vDEFkey == 'vDEF' ? '' : $this->getLanguageIcon($table, $row, $vDEFkey)) . $processedTitle
+                                                                       ) .
+                                                                       '</div>
                                                                        <div class="bgColor4">'.$theFormEl.$defInfo.$this->renderVDEFDiff($editData[$key],$vDEFkey).'</div>
                                                                </div>';
                                                        }
@@ -4696,6 +4704,61 @@ class t3lib_TCEforms     {
        }
 
        /**
+        * Returns help-text ICON if configured for.
+        *
+        * @param       string          Field name
+        * @param       string          Field title
+        * @param       string          File name with CSH labels
+        * @return      string          HTML, <a>-tag with
+        */
+       function helpTextIcon_typeFlex($field, $fieldTitle, $cshFile) {
+               if ($this->globalShowHelp && $cshFile) {
+                       $value = $GLOBALS['LANG']->sL($cshFile . ':' . $field . '.description');
+                       if (trim($value)) {
+                               if (substr($fieldTitle, -1, 1) == ':') {
+                                       $fieldTitle = substr($fieldTitle, 0, strlen($fieldTitle) - 1);
+                               }
+                               // CSH exists
+                               $params = base64_encode(serialize(array(
+                                       'cshFile' => $cshFile,
+                                       'field' => $field,
+                                       'title' => $fieldTitle
+                               )));
+                               $aOnClick = 'vHWin=window.open(\''.$this->backPath.'view_help.php?ffID=' . $params . '\',\'viewFieldHelp\',\'height=400,width=600,status=0,menubar=0,scrollbars=1\');vHWin.focus();return false;';
+                               return '<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.
+                                               '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/helpbubble.gif','width="14" height="14"').' hspace="2" border="0" class="absmiddle"'.($GLOBALS['CLIENT']['FORMSTYLE']?' style="cursor:help;"':'').' alt="" />'.
+                                               '</a>';
+                       }
+               }
+               return '';
+       }
+
+       /**
+        * Returns help text DESCRIPTION, if configured for.
+        *
+        * @param       string          Field name
+        * @param       string          CSH file name
+        * @return      string          Description for the field with cion or empty string
+        */
+       function helpText_typeFlex($field, $fieldTitle, $cshFile) {
+               if ($this->globalShowHelp && $cshFile && $this->edit_showFieldHelp == 'text') {
+                       $value = $GLOBALS['LANG']->sL($cshFile . ':' . $field . '.description');
+                       if (trim($value)) {
+                               return '<table border="0" cellpadding="2" cellspacing="0" width="90%"><tr><td valign="top" width="14">' .
+                                       $this->helpTextIcon_typeFlex(
+                                               $field,
+                                               $fieldTitle,
+                                               $cshFile
+                                       ).
+                                       '</td><td valign="top"><span class="typo3-TCEforms-helpText-flexform">' .
+                                       $GLOBALS['LANG']->hscAndCharConv(strip_tags($value), 1) .
+                                       '</span></td></tr></table>';
+                       }
+               }
+               return '';
+       }
+
+       /**
         * Setting the current color scheme ($this->colorScheme) based on $this->defColorScheme plus input string.
         *
         * @param       string          A color scheme string.
index 4c367a8..2a0137f 100755 (executable)
@@ -129,6 +129,7 @@ class SC_view_help {
 
                // Internal, static: GPvar:
        var $tfID;                      // Table/FIeld id.
+       var $ffID;                      // Flexform file/field information
        var $back;                      // Back (previous tfID)
        var $renderALL;         // If set, then in TOC mode the FULL manual will be printed as well!
 
@@ -148,6 +149,11 @@ class SC_view_help {
 
                        // Setting GPvars:
                $this->tfID = t3lib_div::_GP('tfID');
+               if (!$this->tfID) {
+                       if (($this->ffID = t3lib_div::_GP('ffID'))) {
+                               $this->ffID = unserialize(base64_decode($this->ffID));
+                       }
+               }
                $this->back = t3lib_div::_GP('back');
                $this->renderALL = t3lib_div::_GP('renderALL');
 
@@ -178,6 +184,9 @@ class SC_view_help {
                } elseif ($this->tfID) { // ... otherwise show only single field:
                        $this->createGlossaryIndex();
                        $this->content.= $this->render_Single($this->table,$this->field);
+               }
+               elseif (is_array($this->ffID)) {
+                       $this->content.= $this->render_SingleFlex();
                } else {        // Render Table Of Contents if nothing else:
                        $this->content.= $this->render_TOC();
                }
@@ -490,13 +499,22 @@ class SC_view_help {
        }
 
 
+       /**
+        * Renders CSH for a single field.
+        *
+        * @param       string          CSH key / table name
+        * @param       string          Sub key / field name
+        * @return      string          HTML output
+        */
+       function render_SingleFlex() {
+               $output = '';
 
+                       // Render
+               $output.= $this->printItemFlex();
 
-
-
-
-
-
+                       // Substitute glossary words:
+               return $this->substituteGlossaryWords($output);
+       }
 
 
        /************************************
@@ -567,7 +585,7 @@ class SC_view_help {
                $imgArray = t3lib_div::trimExplode(',', $images, 1);
                if (count($imgArray))   {
                        $descrArray = explode(chr(10),$descr,count($imgArray));
-#debug($descrArray);
+
                        foreach($imgArray as $k => $image)      {
                                $descr = $descrArray[$k];
 
@@ -658,6 +676,35 @@ class SC_view_help {
        }
 
        /**
+        * Prints a single $table/$field information piece
+        * If $anchors is set, then seeAlso references to the same table will be page-anchors, not links.
+        *
+        * @param       string          Table name
+        * @param       string          Field name
+        * @param       boolean         If anchors is to be shown.
+        * @return      string          HTML content
+        */
+       function printItemFlex() {
+               // Get all texts
+               foreach (explode(',', 'description,details,syntax,image,image_descr,seeAlso') as $var) {
+                       // Double $ below is not a error!
+                       $$var = $GLOBALS['LANG']->sL($this->ffID['cshFile'] . ':' . $this->ffID['field'] . '.' . $var);
+               }
+               // Make seeAlso references.
+               $seeAlsoRes = $this->make_seeAlso($seeAlso);
+
+                       // Making item:
+               $out= $this->headerLine($this->ffID['title'], 1) .
+                               $this->prepareContent($description) .
+                               ($details ? $this->headerLine($GLOBALS['LANG']->getLL('details').':') . $this->prepareContent($details) : '') .
+                               ($syntax ? $this->headerLine($GLOBALS['LANG']->getLL('syntax').':') . $this->prepareContent($syntax) : '') .
+                               ($image ? $this->printImage($image, $image_descr) : '') .
+                               ($seeAlso && $seeAlsoRes ? $this->headerLine($GLOBALS['LANG']->getLL('seeAlso').':').'<p>'.$seeAlsoRes.'</p>' : '') .
+               '<br />';
+               return $out;
+       }
+
+       /**
         * Returns labels for $table and $field.
         * If $table is "_MOD_" prefixed, the part after "_MOD_" is returned (non-tables, fx. modules)
         *