Cleanup: Updated copyright notices
[Packages/TYPO3.CMS.git] / typo3 / view_help.php
index b8834f0..6476ee5 100755 (executable)
@@ -2,7 +2,7 @@
 /***************************************************************
 *  Copyright notice
 *
-*  (c) 1999-2005 Kasper Skaarhoj (kasperYYYY@typo3.com)
+*  (c) 1999-2009 Kasper Skaarhoj (kasperYYYY@typo3.com)
 *  All rights reserved
 *
 *  This script is part of the TYPO3 project. The TYPO3 project is
  *
  *
  *
- *   82: class local_t3lib_parsehtml extends t3lib_parsehtml
- *   93:     function processContent($value,$dir,$conf)
+ *   91: class local_t3lib_parsehtml extends t3lib_parsehtml
+ *  102:     function processContent($value,$dir,$conf)
  *
  *
- *  114: class SC_view_help
- *  138:     function init()
- *  159:     function main()
- *  190:     function printContent()
+ *  122: class SC_view_help
+ *  146:     function init()
+ *  167:     function main()
+ *  198:     function printContent()
  *
  *              SECTION: Rendering main modes
- *  213:     function render_TOC()
- *  330:     function render_TOC_el($table, $tocCat, &$outputSections, &$tocArray, &$CSHkeys)
- *  362:     function render_TOC_makeTocList($tocArray)
- *  401:     function render_Table($table)
- *  461:     function render_Single($table,$field)
+ *  221:     function render_TOC()
+ *  338:     function render_TOC_el($table, $tocCat, &$outputSections, &$tocArray, &$CSHkeys)
+ *  370:     function render_TOC_makeTocList($tocArray)
+ *  409:     function render_Table($table)
+ *  469:     function render_Single($table,$field)
  *
  *              SECTION: Rendering CSH items
- *  507:     function make_seeAlso($value,$anchorTable='')
- *  556:     function printImage($images,$descr)
- *  591:     function headerLine($str,$type=0)
- *  612:     function prepareContent($str)
- *  627:     function printItem($table,$field,$anchors=0)
- *  660:     function getTableFieldNames($table,$field)
- *  683:     function getTableFieldLabel($table,$field='',$mergeToken=': ')
- *  702:     function createGlossaryIndex()
- *  738:     function substituteGlossaryWords($code)
- *  776:     function substituteGlossaryWords($code)
+ *  515:     function make_seeAlso($value,$anchorTable='')
+ *  564:     function printImage($images,$descr)
+ *  599:     function headerLine($str,$type=0)
+ *  620:     function prepareContent($str)
+ *  635:     function printItem($table,$field,$anchors=0)
+ *  668:     function getTableFieldNames($table,$field)
+ *  691:     function getTableFieldLabel($table,$field='',$mergeToken=': ')
+ *
+ *              SECTION: Glossary related
+ *  726:     function createGlossaryIndex()
+ *  785:     function substituteGlossaryWords($code)
+ *  801:     function substituteGlossaryWords_htmlcleaner_callback($code)
  *
  * TOTAL FUNCTIONS: 19
  * (This index is automatically created/updated by the extension "extdeveval")
@@ -127,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!
 
@@ -146,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');
 
@@ -166,7 +174,6 @@ class SC_view_help {
                global $BE_USER,$LANG,$TCA_DESCR,$TCA,$TBE_TEMPLATE;
 
                        // Start HTML output accumulation:
-               $TBE_TEMPLATE->docType = 'xhtml_trans';
                $TBE_TEMPLATE->divClass = 'typo3-view-help';
                $this->content.= $TBE_TEMPLATE->startPage($LANG->getLL('title'));
 
@@ -176,6 +183,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();
                }
@@ -290,21 +300,20 @@ class SC_view_help {
                $output = '';
                $output.= '
 
-                       <h1>'.$LANG->getLL('manual_title',1).'</h1>
-                       <p>'.t3lib_BEfunc::TYPO3_copyRightNotice().'</p>';
+                       <h1>'.$LANG->getLL('manual_title',1).'</h1>';
 
                $output.= '
 
-                       <h1>'.$LANG->getLL('introduction',1).'</h1>
+                       <h2>'.$LANG->getLL('introduction',1).'</h2>
                        <p>'.$LANG->getLL('description',1).'</p>';
 
                $output.= '
 
-                       <h1>'.$LANG->getLL('TOC',1).'</h1>'.
+                       <h2>'.$LANG->getLL('TOC',1).'</h2>'.
                        $this->render_TOC_makeTocList($tocArray);
 
                if (!$this->renderALL)  {
-               $output.= '
+                       $output.= '
                                <br/>
                                <p class="c-nav"><a href="view_help.php?renderALL=1">'.$LANG->getLL('full_manual',1).'</a></p>';
                }
@@ -312,7 +321,7 @@ class SC_view_help {
                if ($this->renderALL)   {
                        $output.= '
 
-                               <h1>'.$LANG->getLL('full_manual_chapters',1).'</h1>'.
+                               <h2>'.$LANG->getLL('full_manual_chapters',1).'</h2>'.
                                implode('
 
 
@@ -320,6 +329,8 @@ class SC_view_help {
                                ',$outputSections);
                }
 
+               $output .= '<hr /><p class="manual-title">'.t3lib_BEfunc::TYPO3_copyRightNotice().'</p>';
+
                return $output;
        }
 
@@ -488,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);
+       }
 
 
        /************************************
@@ -514,7 +534,7 @@ class SC_view_help {
                global $TCA,$BE_USER,$TCA_DESCR;
 
                        // Split references by comma, vert.line or linebreak
-               $items = split(',|'.chr(10),$value);
+               $items = preg_split('/[,|' . chr(10) . ']/', $value);
                $lines = array();
 
                foreach($items as $val) {
@@ -565,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];
 
@@ -656,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)
         *
@@ -717,7 +766,7 @@ class SC_view_help {
 
        /**
         * Creates glossary index in $this->glossaryWords
-        * Glossary is cached in cache_hash table and so will be updated only when cache is cleared.
+        * Glossary is cached in cache_hash cache and so will be updated only when cache is cleared.
         *
         * @return      void
         */
@@ -822,19 +871,17 @@ class SC_view_help {
 }
 
 
-// Include extension?
+
 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/view_help.php'])    {
        include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/view_help.php']);
 }
 
 
 
-
-
-
 // Make instance:
 $SOBE = t3lib_div::makeInstance('SC_view_help');
 $SOBE->init();
 $SOBE->main();
 $SOBE->printContent();
+
 ?>
\ No newline at end of file