[TASK] Remove unsupported functionality related to workspaces
[Packages/TYPO3.CMS.git] / typo3 / wizard_tsconfig.php
old mode 100755 (executable)
new mode 100644 (file)
index ef64d43..3efd3b8
@@ -2,7 +2,7 @@
 /***************************************************************
 *  Copyright notice
 *
-*  (c) 1999-2005 Kasper Skaarhoj (kasperYYYY@typo3.com)
+*  (c) 1999-2011 Kasper Skårhøj (kasperYYYY@typo3.com)
 *  All rights reserved
 *
 *  This script is part of the TYPO3 project. The TYPO3 project is
 /**
  * Wizard for inserting TSconfig in form fields. (page,user or TS)
  *
- * $Id$
- * Revised for TYPO3 3.6 November/2003 by Kasper Skaarhoj
+ * Revised for TYPO3 3.6 November/2003 by Kasper Skårhøj
  * XHTML compliant
  *
- * @author     Kasper Skaarhoj <kasperYYYY@typo3.com>
- */
-/**
- * [CLASS/FUNCTION INDEX of SCRIPT]
- *
- *
- *
- *   94: class ext_TSparser extends t3lib_tsparser_ext
- *  102:     function makeHtmlspecialchars($P)
- *
- *
- *  123: class SC_wizard_tsconfig
- *  145:     function init()
- *  252:     function main()
- *  279:     function printContent()
- *  290:     function browseTSprop($mode,$show)
- *
- *              SECTION: Module functions
- *  376:     function getObjTree()
- *  406:     function setObj(&$objTree,$strArr,$params)
- *  426:     function revertFromSpecialChars($str)
- *  439:     function doLink($params)
- *  452:     function removePointerObjects($objArray)
- *  471:     function linkToObj($str,$uid,$objString='')
- *  484:     function printTable($table,$objString,$objTree)
- *  565:     function linkProperty($str,$propertyName,$prefix,$datatype)
- *
- * TOTAL FUNCTIONS: 13
- * (This index is automatically created/updated by the extension "extdeveval")
- *
+ * @author     Kasper Skårhøj <kasperYYYY@typo3.com>
  */
 
 
 
-$BACK_PATH='';
+$GLOBALS['BACK_PATH']='';
 require ('init.php');
 require ('template.php');
-$LANG->includeLLFile('EXT:lang/locallang_wizards.xml');
-require_once (PATH_t3lib.'class.t3lib_parsehtml.php');
-require_once (PATH_t3lib.'class.t3lib_tstemplate.php');
-require_once (PATH_t3lib.'class.t3lib_tsparser_ext.php');
-
-
-
-
-
+$GLOBALS['LANG']->includeLLFile('EXT:lang/locallang_wizards.xml');
 
 
 
@@ -87,7 +49,7 @@ require_once (PATH_t3lib.'class.t3lib_tsparser_ext.php');
 /**
  * TypoScript parser extension class.
  *
- * @author     Kasper Skaarhoj <kasperYYYY@typo3.com>
+ * @author     Kasper Skårhøj <kasperYYYY@typo3.com>
  * @package TYPO3
  * @subpackage core
  */
@@ -116,14 +78,19 @@ class ext_TSparser extends t3lib_tsparser_ext {
 /**
  * Script Class for rendering the TSconfig/TypoScript property browser.
  *
- * @author     Kasper Skaarhoj <kasperYYYY@typo3.com>
+ * @author     Kasper Skårhøj <kasperYYYY@typo3.com>
  * @package TYPO3
  * @subpackage core
  */
 class SC_wizard_tsconfig {
 
                // Internal, dynamic:
-       var $doc;                                       // Document template object
+       /**
+        * document template object
+        *
+        * @var mediumDoc
+        */
+       var $doc;
        var $content;                           // Content accumulation for the module.
 
                // Internal, static: GPvars
@@ -143,8 +110,6 @@ class SC_wizard_tsconfig {
         * @return      void
         */
        function init() {
-               global $LANG,$BACK_PATH;
-
                        // Check if the tsconfig_help extension is loaded - which is mandatory for this wizard to work.
                t3lib_extMgm::isLoaded('tsconfig_help',1);
 
@@ -155,7 +120,9 @@ class SC_wizard_tsconfig {
                $this->objString = t3lib_div::_GP('objString');
                $this->onlyProperty = t3lib_div::_GP('onlyProperty');
                        // Preparing some JavaScript code:
-               if (!is_array($this->P['fieldChangeFunc']))     $this->P['fieldChangeFunc']=array();
+               if (!$this->areFieldChangeFunctionsValid()) {
+                       $this->P['fieldChangeFunc']=array();
+               }
                unset($this->P['fieldChangeFunc']['alert']);
                $update='';
                foreach($this->P['fieldChangeFunc'] as $k=>$v)  {
@@ -164,9 +131,8 @@ class SC_wizard_tsconfig {
                }
 
                        // Init the document table object:
-               $this->doc = t3lib_div::makeInstance('mediumDoc');
-               $this->doc->docType = 'xhtml_trans';
-               $this->doc->backPath = $BACK_PATH;
+               $this->doc = t3lib_div::makeInstance('template');
+               $this->doc->backPath = $GLOBALS['BACK_PATH'];
                $this->doc->form='<form action="" name="editform">';
 
                        // Adding Styles (should go into stylesheet?)
@@ -188,6 +154,13 @@ class SC_wizard_tsconfig {
                                        return window.opener.document.'.$this->P['formName'].'["'.$this->P['itemValue'].'"];
                                }
                        }
+
+       /**
+        * [Describe function...]
+        *
+        * @param       [type]          $field,value: ...
+        * @return      [type]          ...
+        */
                        function setValue(field,value)  {
                                var nameField = checkReference_name();
                                var valueField = checkReference_value();
@@ -195,8 +168,12 @@ class SC_wizard_tsconfig {
                                        if (valueField) {       // This applies to the TS Object Browser module
                                                nameField.value=field;
                                                valueField.value=value;
-                                       } else {                // This applies to the Info/Modify module
-                                               nameField.value=field+"="+value+"\n"+nameField.value;
+                                       } else {                // This applies to the Info/Modify module and the Page TSconfig field
+                                               if (value) {
+                                                       nameField.value=field+"="+value+"\n"+nameField.value;
+                                               } else {
+                                                       nameField.value=field+"\n"+nameField.value;
+                                               }
                                        }
                                        '.$update.'
                                        window.opener.focus();
@@ -211,6 +188,13 @@ class SC_wizard_tsconfig {
                                        close();
                                }
                        }
+
+       /**
+        * [Describe function...]
+        *
+        * @param       [type]          $cmd,objString: ...
+        * @return      [type]          ...
+        */
                        function mixerField(cmd,objString)      {
                                var temp;
                                switch(cmd)     {
@@ -230,6 +214,13 @@ class SC_wizard_tsconfig {
                                        break;
                                }
                        }
+
+       /**
+        * [Describe function...]
+        *
+        * @param       [type]          $match,replace,string: ...
+        * @return      [type]          ...
+        */
                        function str_replace(match,replace,string)      {
                                var input = ""+string;
                                var matchStr = ""+match;
@@ -245,14 +236,21 @@ class SC_wizard_tsconfig {
                                output+=""+input.substr(pointer);
                                return output;
                        }
+
+       /**
+        * [Describe function...]
+        *
+        * @param       [type]          $show,objString: ...
+        * @return      [type]          ...
+        */
                        function jump(show,objString)   {
-                               document.location = "'.t3lib_div::linkThisScript(array('show'=>'','objString'=>'')).'&show="+show+"&objString="+objString;
+                               window.location.href = "'.t3lib_div::linkThisScript(array('show'=>'','objString'=>'')).'&show="+show+"&objString="+objString;
                        }
                ');
 
 
                        // Start the page:
-               $this->content.=$this->doc->startPage($LANG->getLL('tsprop'));
+               $this->content.=$this->doc->startPage($GLOBALS['LANG']->getLL('tsprop'));
        }
 
        /**
@@ -261,25 +259,21 @@ class SC_wizard_tsconfig {
         * @return      void
         */
        function main() {
-               global $LANG;
-
                        // Adding module content:
-               $this->content.=$this->doc->section($LANG->getLL('tsprop'),$this->browseTSprop($this->mode,$this->show),0,1);
+               $this->content.=$this->doc->section($GLOBALS['LANG']->getLL('tsprop'),$this->browseTSprop($this->mode,$this->show),0,1);
 
                        // Adding link to TSref:
                if ($this->mode=='tsref')       {
-                       $this->content.=$this->doc->section($LANG->getLL('tsprop_TSref'),'
-                       <a href="'.htmlspecialchars('http://typo3.org/documentation/document-library/doc_core_tsref/').'" target="_blank">'.$LANG->getLL('tsprop_TSref',1).'</a>
+                       $this->content.=$this->doc->section($GLOBALS['LANG']->getLL('tsprop_TSref'),'
+                       <a href="'. TYPO3_URL_DOCUMENTATION_TSREF.'" target="_blank">'.$GLOBALS['LANG']->getLL('tsprop_TSref',1).'</a>
                        ',0,1);
                }
                        // Adding link to admin guides etc:
                if ($this->mode=='page' || $this->mode=='beuser')       {
-                       $this->content.=$this->doc->section($LANG->getLL('tsprop_tsconfig'),'
-                       <a href="'.htmlspecialchars('http://typo3.org/documentation/document-library/doc_core_tsconfig/').'" target="_blank">'.$LANG->getLL('tsprop_tsconfig',1).'</a>
+                       $this->content.=$this->doc->section($GLOBALS['LANG']->getLL('tsprop_tsconfig'),'
+                       <a href="' . TYPO3_URL_DOCUMENTATION_TSCONFIG . '" target="_blank">' . $GLOBALS['LANG']->getLL('tsprop_tsconfig',1) . '</a>
                        ',0,1);
                }
-                       // Ending page:
-               $this->content.=$this->doc->endPage();
        }
 
        /**
@@ -288,6 +282,8 @@ class SC_wizard_tsconfig {
         * @return      void
         */
        function printContent() {
+               $this->content.= $this->doc->endPage();
+               $this->content = $this->doc->insertStylesAndJS($this->content);
                echo $this->content;
        }
 
@@ -299,8 +295,6 @@ class SC_wizard_tsconfig {
         * @return      string          HTML
         */
        function browseTSprop($mode,$show)      {
-               global $LANG;
-
                        // Get object tree:
                $objTree = $this->getObjTree();
 
@@ -315,7 +309,7 @@ class SC_wizard_tsconfig {
 
                                // Title and description:
                        $out.='<a href="'.htmlspecialchars(t3lib_div::linkThisScript(array('show'=>''))).'" class="typo3-goBack">'.
-                                       '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/goback.gif','width="14" height="14"').' alt="" />'.
+                                       t3lib_iconWorks::getSpriteIcon('actions-view-go-back') .
                                        htmlspecialchars($obj_string).
                                        '</a><br />';
                        if ($rec['title'])      $out.= '<strong>'.htmlspecialchars($rec['title']).': </strong>';
@@ -328,10 +322,10 @@ class SC_wizard_tsconfig {
                                // Printing the "mixer-field":
                        if (!$this->onlyProperty)       {
                                $links=array();
-                               $links[]='<a href="#" onclick="mixerField(\'Indent\');return false;">'.$LANG->getLL('tsprop_mixer_indent',1).'</a>';
-                               $links[]='<a href="#" onclick="mixerField(\'Outdent\');return false;">'.$LANG->getLL('tsprop_mixer_outdent',1).'</a>';
-                               $links[]='<a href="#" onclick="mixerField(\'Wrap\',unescape(\''.rawurlencode($obj_string).'\'));return false;">'.$LANG->getLL('tsprop_mixer_wrap',1).'</a>';
-                               $links[]='<a href="#" onclick="mixerField(\'Transfer\');return false;">'.$LANG->getLL('tsprop_mixer_transfer',1).'</a>';
+                               $links[]='<a href="#" onclick="mixerField(\'Indent\');return false;">'.$GLOBALS['LANG']->getLL('tsprop_mixer_indent',1).'</a>';
+                               $links[]='<a href="#" onclick="mixerField(\'Outdent\');return false;">'.$GLOBALS['LANG']->getLL('tsprop_mixer_outdent',1).'</a>';
+                               $links[]='<a href="#" onclick="mixerField(\'Wrap\',unescape(\''.rawurlencode($obj_string).'\'));return false;">'.$GLOBALS['LANG']->getLL('tsprop_mixer_wrap',1).'</a>';
+                               $links[]='<a href="#" onclick="mixerField(\'Transfer\');return false;">'.$GLOBALS['LANG']->getLL('tsprop_mixer_transfer',1).'</a>';
                                $out.='<textarea rows="5" name="mixer" wrap="off"'.$this->doc->formWidthText(48,'','off').' class="fixed-font enable-tab"></textarea>';
                                $out.='<br /><strong>'.implode('&nbsp; | &nbsp;',$links).'</strong>';
                                $out.='<hr />';
@@ -356,9 +350,10 @@ class SC_wizard_tsconfig {
                        <!--
                                TSconfig, object tree:
                        -->
-                               <table border="0" cellpadding="0" cellspacing="0" id="typo3-objtree">
+                               <table border="0" cellpadding="0" cellspacing="0" class="t3-tree t3-tree-config" id="typo3-objtree">
+                                       <tr class="t3-row-header"><td>TSref</td></tr>
                                        <tr>
-                                               <td nowrap="nowrap">'.$tmpl->ext_getObjTree($this->removePointerObjects($objTree[$mode.'.']),'','').'</td>
+                                               <td nowrap="nowrap">'.$tmpl->ext_getObjTree($this->removePointerObjects($objTree[$mode.'.']),'','','','','1').'</td>
                                        </tr>
                                </table>';
                }
@@ -385,17 +380,16 @@ class SC_wizard_tsconfig {
         * @access private
         */
        function getObjTree()   {
-               $hash = md5('WIZARD_TSCONFIG-objTree');
                $objTree=array();
 
                $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid,obj_string,title', 'static_tsconfig_help', '');
                while($rec = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))       {
                        $rec['obj_string'] = $this->revertFromSpecialChars($rec['obj_string']);
                        $p = explode(';',$rec['obj_string']);
-                       while(list(,$v)=each($p))       {
+                       foreach ($p as $v) {
                                $p2 = t3lib_div::trimExplode(':',$v,1);
                                $subp=t3lib_div::trimExplode('/',$p2[1],1);
-                               while(list(,$v2)=each($subp))   {
+                               foreach ($subp as $v2) {
                                        $this->setObj($objTree,explode('.',$p2[0].'.'.$v2),array($rec,$v2));
                                }
                        }
@@ -461,8 +455,7 @@ class SC_wizard_tsconfig {
         * @access private
         */
        function removePointerObjects($objArray)        {
-               reset($objArray);
-               while(list($k)=each($objArray)) {
+               foreach ($objArray as $k => $value) {
                        if (substr(trim($k),0,2)=="->" && trim($k)!='->.')      {
                                $objArray['->.'][substr(trim($k),2)]=$objArray[$k];
                                unset($objArray[$k]);
@@ -500,27 +493,20 @@ class SC_wizard_tsconfig {
 
                                // Adding header:
                        $lines[]='
-                               <tr>
-                                       <td><img src="clear.gif" width="175" height="1" alt="" /></td>
-                                       <td><img src="clear.gif" width="100" height="1" alt="" /></td>
-                                       <td><img src="clear.gif" width="400" height="1" alt="" /></td>
-                                       <td><img src="clear.gif" width="70" height="1" alt="" /></td>
-                               </tr>';
-                       $lines[]='
-                               <tr class="bgColor5">
-                                       <td><strong>Property:</strong></td>
-                                       <td><strong>Data type:</strong></td>
-                                       <td><strong>Description:</strong></td>
-                                       <td><strong>Default:</strong></td>
+                               <tr class="t3-row-header">
+                                       <td>Property:</td>
+                                       <td>Data type:</td>
+                                       <td>Description:</td>
+                                       <td>Default:</td>
                                </tr>';
 
                                // Traverse the content of "rows":
-                       foreach($table['rows'] as $row) {
+                       foreach($table['rows'] as $i => $row)   {
 
                                        // Linking:
-                               $lP=t3lib_div::trimExplode(chr(10),$row['property'],1);
+                               $lP=t3lib_div::trimExplode(LF,$row['property'],1);
                                $lP2=array();
-                               while(list($k,$lStr)=each($lP)) {
+                               foreach ($lP as $k => $lStr) {
                                        $lP2[$k] = $this->linkProperty($lStr,$lStr,$objString,$row['datatype']);
                                }
                                $linkedProperties=implode('<hr />',$lP2);
@@ -530,7 +516,7 @@ class SC_wizard_tsconfig {
 
                                        // Generally "->[something]"
                                $reg=array();
-                               ereg('->[[:alnum:]_]*',$dataType,$reg);
+                               preg_match('/->[[:alnum:]_]*/',$dataType,$reg);
                                if ($reg[0] && is_array($objTree[$reg[0]]))     {
                                        $dataType = str_replace($reg[0],'<a href="'.htmlspecialchars(t3lib_div::linkThisScript(array('show'=>$objTree[$reg[0]][0]['uid'],'objString'=>$objString.'.'.$lP[0]))).'">'.htmlspecialchars($reg[0]).'</a>',$dataType);
                                }
@@ -543,8 +529,8 @@ class SC_wizard_tsconfig {
 
 
                                $lines[]='
-                                       <tr class="bgColor4">
-                                               <td valign="top" class="bgColor4-20"><strong>'.$linkedProperties.'</strong></td>
+                                       <tr class="t3-row ' . ($i % 2 ? 't3-row-even' : 't3-row-odd') . '">
+                                               <td valign="top" class="bgColor4-20" nowrap="nowrap"><strong>'.$linkedProperties.'</strong></td>
                                                <td valign="top">'.nl2br($dataType.'&nbsp;').'</td>
                                                <td valign="top">'.nl2br($row['description']).'</td>
                                                <td valign="top">'.nl2br($row['default']).'</td>
@@ -558,7 +544,7 @@ class SC_wizard_tsconfig {
                        <!--
                                TSconfig, attribute selector:
                        -->
-                               <table border="0" cellpadding="0" cellspacing="1" width="500" id="typo3-attributes">
+                               <table border="0" cellpadding="0" cellspacing="1" width="98%" class="t3-table" id="typo3-attributes">
                                        '.implode('',$lines).'
                                </table>';
                }
@@ -585,8 +571,8 @@ class SC_wizard_tsconfig {
                if(!$this->onlyProperty)        {
                        $aOnClick = 'document.editform.mixer.value=unescape(\'  '.rawurlencode($propertyName.'='.$propertyVal).'\')+\'\n\'+document.editform.mixer.value; return false;';
                        $out.= '<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.
-                                       '<img'.t3lib_iconWorks::skinImg($this->doc->backPath,'gfx/plusbullet2.gif','width="18" height="16"').' title="'.$GLOBALS['LANG']->getLL('tsprop_addToList',1).'" align="top" alt="" />'.
-                                       '</a>';
+                                       t3lib_iconWorks::getSpriteIcon('actions-edit-add', array('title' => $GLOBALS['LANG']->getLL('tsprop_addToList', TRUE))) .
+                       '</a>';
                        $propertyName = $prefix.'.'.$propertyName;
                }
 
@@ -597,21 +583,25 @@ class SC_wizard_tsconfig {
                        // Return link:
                return $out;
        }
-}
 
-// Include extension?
-if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/wizard_tsconfig.php'])      {
-       include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/wizard_tsconfig.php']);
+       /**
+        * Determines whether submitted field change functions are valid
+        * and are coming from the system and not from an external abuse.
+        *
+        * @return boolean Whether the submitted field change functions are valid
+        */
+       protected function areFieldChangeFunctionsValid() {
+               return (
+                       isset($this->P['fieldChangeFunc']) && is_array($this->P['fieldChangeFunc']) && isset($this->P['fieldChangeFuncHash'])
+                       && $this->P['fieldChangeFuncHash'] === t3lib_div::hmac(serialize($this->P['fieldChangeFunc']))
+               );
+       }
 }
 
 
-
-
-
-
-
-
-
+if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/wizard_tsconfig.php'])) {
+       include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/wizard_tsconfig.php']);
+}
 
 
 
@@ -620,4 +610,5 @@ $SOBE = t3lib_div::makeInstance('SC_wizard_tsconfig');
 $SOBE->init();
 $SOBE->main();
 $SOBE->printContent();
+
 ?>
\ No newline at end of file