* Various enhancements to the TS object browser and TS analyzer:
authorMichael Stucki <michael.stucki@typo3.org>
Fri, 27 Apr 2007 22:09:44 +0000 (22:09 +0000)
committerMichael Stucki <michael.stucki@typo3.org>
Fri, 27 Apr 2007 22:09:44 +0000 (22:09 +0000)
 - Add spaces left and right of the "=" mark in the object browser overview
 - Set new default values: Check several fields, e.g. "block mode", "syntax highlighting", etc. by default
 - Define default values properly in each class instead of setting them globally
 - Use the TSparser and display comments nicely in the object browser

git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@2278 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
t3lib/class.t3lib_befunc.php
t3lib/class.t3lib_scbase.php
t3lib/class.t3lib_tsparser_ext.php
t3lib/class.t3lib_tstemplate.php
typo3/sysext/cms/tslib/class.tslib_fe.php
typo3/sysext/tstemplate/ts/index.php
typo3/sysext/tstemplate_analyzer/class.tx_tstemplateanalyzer.php
typo3/sysext/tstemplate_objbrowser/class.tx_tstemplateobjbrowser.php

index 695a043..cba4801 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,6 +4,11 @@
        * Add new function t3lib_div::rmdir() to remove directories recursively
        * Modify filelist module to make use of the t3lib_div::rmdir()
        * Modify internal_clearPageCache() in t3lib_tcemain and make use of t3lib_div::rmdir() as well
+       * Various enhancements to the TS object browser and TS analyzer:
+               - Add spaces left and right of the "=" mark in the object browser overview
+               - Set new default values: Check several fields, e.g. "block mode", "syntax highlighting", etc. by default
+               - Define default values properly in each class instead of setting them globally
+               - Use the TSparser and display comments nicely in the object browser
 
 2007-04-27  Ingo Renner  <typo3@ingo-renner.com>
 
index 8a57a2d..f329bdc 100755 (executable)
@@ -2618,13 +2618,13 @@ class t3lib_BEfunc      {
                                        if (is_array($var) && (!$dontValidateList || !t3lib_div::inList($dontValidateList,$key)))       {
                                                        // If the setting is an array or not present in the menu-array, MOD_MENU, then the default value is inserted.
                                                if (is_array($settings[$key]) || !isset($MOD_MENU[$key][$settings[$key]]))      {
-                                                       $settings[$key]=(string)key($var);
+                                                       $settings[$key] = (string)key($var);
                                                        $changed=1;
                                                }
                                        }
                                        if ($setDefaultList && !is_array($var)) {       // Sets default values (only strings/checkboxes, not menus)
                                                if (t3lib_div::inList($setDefaultList,$key) && !isset($settings[$key])) {
-                                                       $settings[$key]=$var;
+                                                       $settings[$key] = (string)$var;
                                                }
                                        }
                                }
index 7de582c..6200704 100644 (file)
@@ -275,7 +275,6 @@ class t3lib_SCbase {
                #debug($this->MOD_MENU['function'],$this->MCONF['name']);
                #debug($this->modTSconfig['properties']);
 
-                       // CLEANSE 'function' SETTINGS
                $this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, t3lib_div::_GP('SET'), $this->MCONF['name'], $this->modMenu_type, $this->modMenu_dontValidateList, $this->modMenu_setDefaultList);
        }
 
@@ -351,7 +350,7 @@ class t3lib_SCbase {
                        $this->extObj = t3lib_div::makeInstance($this->extClassConf['name']);
                        $this->extObj->init($this,$this->extClassConf);
                                // Re-write:
-                       $this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, t3lib_div::_GP('SET'), $this->MCONF['name']);
+                       $this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, t3lib_div::_GP('SET'), $this->MCONF['name'], $this->modMenu_type, $this->modMenu_dontValidateList, $this->modMenu_setDefaultList);
                }
        }
 
index 6704554..7c99503 100755 (executable)
@@ -279,16 +279,15 @@ class t3lib_tsparser_ext extends t3lib_TStemplate {
        }
 
        /**
-        * [Describe function...]
+        * Parses the constants in $this->const with respect to the constant-editor in this module.
+        * In particular comments in the code are registered and the edit_divider is taken into account.
         *
         * @return      [type]          ...
         */
        function generateConfig_constants()     {
-                       // Parses the constants in $this->const with respect to the constant-editor in this module.
-                       // In particular comments in the code are registered and the edit_divider is taken into account.
                        // These vars are also set lateron...
-               $this->setup["resources"]= $this->resources;
-               $this->setup["sitetitle"]= $this->sitetitle;
+               $this->setup['resources'] = $this->resources;
+               $this->setup['sitetitle'] = $this->sitetitle;
 
                        // parse constants
                $constants = t3lib_div::makeInstance("t3lib_TSparser");
@@ -443,9 +442,16 @@ class t3lib_tsparser_ext extends t3lib_TStemplate  {
                                                $theValue = $this->ext_fixed_lgd($theValue,$lgdChars);
                                        }
                                        if ($this->tsbrowser_searchKeys[$depth] & 2)    {       // The value has matched the search string
-                                               $HTML.='=<b><font color="red">'.$this->makeHtmlspecialchars($theValue).'</font></b>';
+                                               $HTML.='&nbsp;=&nbsp;<b><font color="red">'.$this->makeHtmlspecialchars($theValue).'</font></b>';
                                        } else {
-                                               $HTML.="=<b>".$this->makeHtmlspecialchars($theValue)."</b>";
+                                               $HTML.="&nbsp;=&nbsp;<b>".$this->makeHtmlspecialchars($theValue)."</b>";
+                                       }
+                                       if ($this->ext_regComments && isset($arr[$key.'..']))   {
+                                               $comment = $arr[$key.'..'];
+                                               $comment = preg_replace('/[\r\n]/', ' ', $comment);     // Remove linebreaks, replace with " "
+                                               $comment = preg_replace('/[#\*]{2,}/', '', $comment);   // Remove # and * if more than twice in a row
+                                               $comment = preg_replace('/^[#\*\s]+/', '# ', $comment); // Replace leading # (just if it exists) and add it again. Result: Every comment should be prefixed by a "#".
+                                               $HTML.= ' <span class="comment">'.trim($comment).'</span>';
                                        }
                                }
                                $HTML.="<br />";
index bd47ea6..48780a1 100755 (executable)
@@ -123,7 +123,8 @@ class t3lib_TStemplate      {
        var $ext_constants_BRP=0;
        var $ext_config_BRP=0;
        var $ext_editorcfg_BRP=0;
-       var $ext_regLinenumbers=FALSE;
+       var $ext_regLinenumbers=false;
+       var $ext_regComments=false;
 
                // Constants:
        var $uplPath = 'uploads/tf/';
@@ -773,6 +774,7 @@ class t3lib_TStemplate      {
                $config = t3lib_div::makeInstance('t3lib_TSparser');
                $config->breakPointLN = intval($this->ext_config_BRP);
                $config->regLinenumbers = $this->ext_regLinenumbers;
+               $config->regComments = $this->ext_regComments;
                $config->setup = $this->setup;
 
                        // Transfer information about conditions found in "Constants" and which of them returned true.
index 67cb695..230a747 100755 (executable)
                                        $c--;
                                        $this->id = $this->rootLine[$c]['uid'];
                                        $this->page = $this->sys_page->getPage($this->id);
-                                       if (count($this->page)){ break; }
+                                       if (count($this->page)) { break; }
                                }
                        }
                                // If still no page...
index 5714ad4..1d46995 100644 (file)
@@ -31,7 +31,7 @@
  *     $TYPO3_CONF_VARS["MODS"]["web_ts"]["onlineResourceDir"]  = Directory of default resources. Eg. "fileadmin/res/" or so.
  *
  *
- * @author     Kasper Skårhøj <kasperYYYY@typo3.com>
+ * @author     Kasper Skaarhoj <kasperYYYY@typo3.com>
  */
 
 
@@ -59,9 +59,9 @@ class SC_mod_web_ts_index extends t3lib_SCbase {
        var $edit;
        var $textExtensions = 'html,htm,txt,css,tmpl,inc,js';
 
-       var $modMenu_type = "";
-       var $modMenu_dontValidateList = "ts_browser_toplevel_setup,ts_browser_toplevel_const,ts_browser_TLKeys_setup,ts_browser_TLKeys_const";
-       var $modMenu_setDefaultList = "ts_browser_linkObjects,ts_browser_fixedLgd";
+       var $modMenu_type = '';
+       var $modMenu_dontValidateList = '';
+       var $modMenu_setDefaultList = '';
 
        function init() {
                global $BE_USER,$LANG,$BACK_PATH,$TCA_DESCR,$TCA,$CLIENT,$TYPO3_CONF_VARS;
@@ -126,6 +126,7 @@ class SC_mod_web_ts_index extends t3lib_SCbase {
 
                        $this->doc->inDocStylesArray[] = '
                                TABLE#typo3-objectBrowser A { text-decoration: none; }
+                               TABLE#typo3-objectBrowser .comment { color: maroon; font-weight: bold; }
                        ';
 
 
@@ -313,7 +314,7 @@ class SC_mod_web_ts_index extends t3lib_SCbase {
                        }
                }
 
-               $this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, t3lib_div::_GP('SET'), $this->MCONF['name']);
+               $this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, t3lib_div::_GP('SET'), $this->MCONF['name'], $this->modMenu_type, $this->modMenu_dontValidateList, $this->modMenu_setDefaultList);
                $menu = t3lib_BEfunc::getFuncMenu($this->id,'SET[templatesOnPage]',$this->MOD_SETTINGS['templatesOnPage'],$this->MOD_MENU['templatesOnPage']);
 
                return $menu;
index cf09a0a..a1f569a 100644 (file)
 *  This copyright notice MUST APPEAR in all copies of the script!
 ***************************************************************/
 /**
- * @author     Kasper Skårhøj <kasperYYYY@typo3.com>
+ * @author     Kasper Skaarhoj <kasperYYYY@typo3.com>
  */
 
 require_once(PATH_t3lib."class.t3lib_extobjbase.php");
 
 class tx_tstemplateanalyzer extends t3lib_extobjbase {
+       function init(&$pObj,$conf)     {
+               parent::init($pObj,$conf);
+
+               $this->pObj->modMenu_setDefaultList.= ',ts_analyzer_checkLinenum,ts_analyzer_checkSyntax,ts_analyzer_checkSyntaxBlockmode';
+       }
+
        function modMenu()      {
                global $LANG;
 
-               return Array (
-                       "ts_analyzer_checkSetup" => "",
-                       "ts_analyzer_checkConst" => "",
-                       "ts_analyzer_checkLinenum" => "",
-                       "ts_analyzer_checkComments" => "",
-                       "ts_analyzer_checkCrop" => "",
-                       "ts_analyzer_checkSyntax" => "",
-                       "ts_analyzer_checkSyntaxBlockmode" => "",
+               return array (
+                       'ts_analyzer_checkSetup' => '1',
+                       'ts_analyzer_checkConst' => '1',
+                       'ts_analyzer_checkLinenum' => '1',
+                       'ts_analyzer_checkComments' => '1',
+                       'ts_analyzer_checkCrop' => '1',
+                       'ts_analyzer_checkSyntax' => '1',
+                       'ts_analyzer_checkSyntaxBlockmode' => '1',
                );
        }
 
index b79d567..37a79f0 100644 (file)
 require_once(PATH_t3lib."class.t3lib_extobjbase.php");
 
 class tx_tstemplateobjbrowser extends t3lib_extobjbase {
+       function init(&$pObj,$conf)     {
+               parent::init($pObj,$conf);
+
+               $this->pObj->modMenu_dontValidateList.= ',ts_browser_toplevel_setup,ts_browser_toplevel_const,ts_browser_TLKeys_setup,ts_browser_TLKeys_const';
+               $this->pObj->modMenu_setDefaultList.= ',ts_browser_fixedLgd,ts_browser_showComments';
+       }
+
        function modMenu()      {
                global $LANG;
 
@@ -50,9 +57,9 @@ class tx_tstemplateobjbrowser extends t3lib_extobjbase {
                                "subst" => "Substituted constants in green",
                                "const" => "UN-substituted constants in green"
                        ),
-                       "ts_browser_regexsearch" => "",
-                       "ts_browser_fixedLgd" => "1",
-                       "ts_browser_linkObjects" => "1",
+                       'ts_browser_regexsearch' => '1',
+                       'ts_browser_fixedLgd' => '1',
+                       'ts_browser_showComments' => '1',
                        'ts_browser_alphaSort' => '1',
                );
 
@@ -291,9 +298,9 @@ class tx_tstemplateobjbrowser extends t3lib_extobjbase {
 
                $tmpl->regexMode = $this->pObj->MOD_SETTINGS["ts_browser_regexsearch"];
                $tmpl->fixedLgd=$this->pObj->MOD_SETTINGS["ts_browser_fixedLgd"];
-#              $tmpl->linkObjects=$this->pObj->MOD_SETTINGS["ts_browser_linkObjects"];
                $tmpl->linkObjects = TRUE;
                $tmpl->ext_regLinenumbers = TRUE;
+               $tmpl->ext_regComments = $this->pObj->MOD_SETTINGS['ts_browser_showComments'];;
                $tmpl->bType=$bType;
                $tmpl->resourceCheck=1;
                $tmpl->uplPath = PATH_site.$tmpl->uplPath;
@@ -508,7 +515,7 @@ class tx_tstemplateobjbrowser extends t3lib_extobjbase {
 
                                // Menu in the bottom:
                        $menu = '<label for="checkTs_browser_fixedLgd">Crop lines:</label> '.t3lib_BEfunc::getFuncCheck($this->pObj->id,"SET[ts_browser_fixedLgd]",$this->pObj->MOD_SETTINGS["ts_browser_fixedLgd"],'','','id="checkTs_browser_fixedLgd"');
-                       #$menu.= "&nbsp;&nbsp;Enable object links".t3lib_BEfunc::getFuncCheck($this->pObj->id,"SET[ts_browser_linkObjects]",$this->pObj->MOD_SETTINGS["ts_browser_linkObjects"]);
+                       $menu .= '<br /><label for="checkTs_browser_showComments">Display comments:</label> '.t3lib_BEfunc::getFuncCheck($this->pObj->id,'SET[ts_browser_showComments]',$this->pObj->MOD_SETTINGS['ts_browser_showComments']);
                        $menu .= '<br /><label for="checkTs_browser_alphaSort">Sort alphabetically:</label> '.t3lib_BEfunc::getFuncCheck($this->pObj->id,'SET[ts_browser_alphaSort]',$this->pObj->MOD_SETTINGS['ts_browser_alphaSort'],'','','id="checkTs_browser_alphaSort"');
                        if ($bType=="setup" && !$this->pObj->MOD_SETTINGS["ts_browser_fixedLgd"])       {
                                $menu.= "<br />Constants display: ".t3lib_BEfunc::getFuncMenu($this->pObj->id,"SET[ts_browser_const]",$this->pObj->MOD_SETTINGS["ts_browser_const"],$this->pObj->MOD_MENU["ts_browser_const"]);