- Fixed t3lib_cli that negative numbers (like "-2") is not seen as a parameter
authorKasper Skårhøj <kasper@typo3.org>
Sat, 22 Sep 2007 19:52:18 +0000 (19:52 +0000)
committerKasper Skårhøj <kasper@typo3.org>
Sat, 22 Sep 2007 19:52:18 +0000 (19:52 +0000)
- New option, $GLOBALS['TYPO3_CONF_VARS']['BE']['flexFormXMLincludeDiffBase'], means that flexforms will allow a new index extending all "vXX" fields to "vXX.vDEFbase" with a value holding the "vDEF" value when the "vXX" value was changed. Effectively this is a memory of the value you translated from. Used for diff'ing.
- Introduced a new global hook, $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['recStatInfoHooks'], with which you can insert HTML before a records icon in the page tree, web>List and Web>Page modules (and possibly more places where makes sense). Used in l10nmgr for adding a small localization icon.
- Added "limit to languages" to "Admin" accounts (although it will not limit languages but merely decide what statuses you see in the page tree)
- List sys_log table entries in cleaner output!

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

13 files changed:
ChangeLog
t3lib/class.t3lib_cli.php
t3lib/class.t3lib_flexformtools.php
t3lib/class.t3lib_tceforms.php
t3lib/class.t3lib_tcemain.php
t3lib/class.t3lib_transl8tools.php
t3lib/config_default.php
t3lib/stddb/tbl_be.php
typo3/class.db_list_extra.inc
typo3/class.webpagetree.php
typo3/sysext/cms/layout/class.tx_cms_layout.php
typo3/sysext/lowlevel/clmods/class.syslog.php [new file with mode: 0644]
typo3/sysext/lowlevel/ext_localconf.php

index d247afa..e18ec4a 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2007-09-18  Kasper Sk\8crh¿j  <kasperYYYY@typo3.com>
+
+       * Fixed t3lib_cli that negative numbers (like "-2") is not seen as a parameter
+       * New option, $GLOBALS['TYPO3_CONF_VARS']['BE']['flexFormXMLincludeDiffBase'], means that flexforms will allow a new index extending all "vXX" fields to "vXX.vDEFbase" with a value holding the "vDEF" value when the "vXX" value was changed. Effectively this is a memory of the value you translated from. Used for diff'ing.
+       * Introduced a new global hook, $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['recStatInfoHooks'], with which you can insert HTML before a records icon in the page tree, web>List and Web>Page modules (and possibly more places where makes sense). Used in l10nmgr for adding a small localization icon.
+       * Added "limit to languages" to "Admin" accounts (although it will not limit languages but merely decide what statuses you see in the page tree)
+       * List sys_log table entries in cleaner output!
+
 2007-09-18  Oliver Hader  <oh@inpublica.de>
 
        * (minor) Fixed bug #65: Thumbnails in Element Browser are only displayed if fileSuffix is lowercase
index 8fce610..464cb51 100644 (file)
@@ -139,7 +139,7 @@ class t3lib_cli {
                $cli_options = array();
                $index = '_DEFAULT';
                foreach($_SERVER['argv'] as $token)     {
-                       if ($token{0}==='-')    {
+                       if ($token{0}==='-' && !t3lib_div::testInt($token{1}))  {       // Options starting with a number is invalid - they could be negative values... !
                                list($index,$opt) = explode('=',$token,2);
                                if (isset($cli_options[$index]))        {
                                        echo 'ERROR: Option '.$index.' was used twice!'.chr(10);
index 0b6d952..d93cb3c 100644 (file)
@@ -364,6 +364,14 @@ class t3lib_flexformtools {
                #debug(array($dsArr, $data, $PA),$path);
                        // Just setting value in our own result array, basically replicating the structure:
                $pObj->setArrayValueByPath($path,$this->cleanFlexFormXML,$data);
+
+                       // Looking if an "extension" called ".vDEFbase" is found and if so, accept that too:
+               if ($GLOBALS['TYPO3_CONF_VARS']['BE']['flexFormXMLincludeDiffBase'])    {
+                       $vDEFbase = $pObj->getArrayValueByPath($path.'.vDEFbase',$pObj->traverseFlexFormXMLData_Data);
+                       if (isset($vDEFbase))   {
+                               $pObj->setArrayValueByPath($path.'.vDEFbase',$this->cleanFlexFormXML,$vDEFbase);
+                       }
+               }
        }
 
 
index bd1e31a..08f2e62 100755 (executable)
@@ -2538,7 +2538,7 @@ class t3lib_TCEforms      {
                                                                        // Put row together
                                                                $tRows[]='<tr>
                                                                        <td nowrap="nowrap" valign="top" class="bgColor5">'.($vDEFkey=='vDEF' ? '' : $this->getLanguageIcon($table,$row,$vDEFkey)).$rowCells['title'].'</td>
-                                                                       <td class="bgColor4">'.$rowCells['formEl'].$defInfo.'</td>
+                                                                       <td class="bgColor4">'.$rowCells['formEl'].$defInfo.$this->renderVDEFDiff($editData[$key],$vDEFkey).'</td>
                                                                </tr>';
                                                        }
                                                }
@@ -3089,6 +3089,31 @@ class t3lib_TCEforms     {
                return $item;
        }
 
+       /**
+        * Renders the diff-view of vDEF fields in flexforms
+        *
+        * @param       string          Table name of the record being edited
+        * @param       string          Field name represented by $item
+        * @param       array           Record array of the record being edited
+        * @param       string          HTML of the form field. This is what we add the content to.
+        * @return      string          Item string returned again, possibly with the original value added to.
+        * @see getSingleField(), registerDefaultLanguageData()
+        */
+       function renderVDEFDiff($vArray,$vDEFkey)       {
+               if ($GLOBALS['TYPO3_CONF_VARS']['BE']['flexFormXMLincludeDiffBase'] && isset($vArray[$vDEFkey.'.vDEFbase']) && strcmp($vArray[$vDEFkey.'.vDEFbase'],$vArray['vDEF']))   {
+
+                               // Create diff-result:
+                       $t3lib_diff_Obj = t3lib_div::makeInstance('t3lib_diff');
+                       $diffres = $t3lib_diff_Obj->makeDiffDisplay($vArray[$vDEFkey.'.vDEFbase'],$vArray['vDEF']);
+
+                       $item.='<div class="typo3-TCEforms-diffBox">'.
+                               '<div class="typo3-TCEforms-diffBox-header">'.htmlspecialchars($this->getLL('l_changeInOrig')).':</div>'.
+                               $diffres.
+                       '</div>';
+               }
+
+               return $item;
+       }
 
 
 
index 93a74ea..d53bcee 100755 (executable)
@@ -2298,6 +2298,19 @@ class t3lib_TCEmain      {
                                                        if (isset($res['value']))       {
                                                                $dataValues[$key][$vKey] = $res['value'];
                                                        }
+
+                                                               // Finally, check if new and old values are different (or no .vDEFbase value is found) and if so, we record the vDEF value for diff'ing. 
+                                                               // We do this after $dataValues has been updated since I expect that $dataValues_current holds evaluated values from database (so this must be the right value to compare with).
+                                                       if ($GLOBALS['TYPO3_CONF_VARS']['BE']['flexFormXMLincludeDiffBase'] && $vKey!=='vDEF' && (strcmp($dataValues[$key][$vKey],$dataValues_current[$key][$vKey]) || !isset($dataValues_current[$key][$vKey.'.vDEFbase'])))   {
+                                                                       // Now, check if a vDEF value is submitted in the input data, if so we expect this has been processed prior to this operation (normally the case since those fields are higher in the form) and we can use that:
+                                                               if (isset($dataValues[$key]['vDEF']))   {
+                                                                       $diffValue = $dataValues[$key]['vDEF'];
+                                                               } else {        // If not found (for translators with no access to the default language) we use the one from the current-value data set:
+                                                                       $diffValue = $dataValues_current[$key]['vDEF'];
+                                                               }
+                                                                       // Setting the reference value for vDEF for this translation. This will be used for translation tools to make a diff between the vDEF and vDEFbase to see if an update would be fitting.
+                                                               $dataValues[$key][$vKey.'.vDEFbase'] = $diffValue;
+                                                       }
                                                }
                                        }
                                }
index 27ab49f..ff5ed4d 100755 (executable)
 /**
  * [CLASS/FUNCTION INDEX of SCRIPT]
  *
+ *
+ *
+ *   67: class t3lib_transl8tools
+ *   74:     function getSystemLanguages($page_id=0,$backPath='')
+ *  132:     function translationInfo($table,$uid,$sys_language_uid=0)
+ *  187:     function getTranslationTable($table)
+ *  197:     function isTranslationInOwnTable($table)
+ *  209:     function foreignTranslationTable($table)
+ *
+ * TOTAL FUNCTIONS: 5
+ * (This index is automatically created/updated by the extension "extdeveval")
+ *
  */
 
 
  * @subpackage t3lib
  */
 class t3lib_transl8tools       {
-       
+
        /**
-        *
+        * Returns array of system languages
+        * @param       integer         page id (only used to get TSconfig configuration setting flag and label for default language)
+        * @param       string          Backpath for flags
+        * @return      array           
         */
        function getSystemLanguages($page_id=0,$backPath='')    {
                global $TCA,$LANG;
@@ -102,17 +117,23 @@ class t3lib_transl8tools  {
                        if (strlen ($row['flag'])) {
                                $languageIconTitles[$row['uid']]['flagIcon'] = @is_file($flagAbsPath.$row['flag']) ? $flagIconPath.$row['flag'] : '';
                        }
-               }               
-               
+               }
+
                return $languageIconTitles;
        }
 
        /**
-        * Initialization of the class.
+        * Information about translation for an element
+        * Will overlay workspace version of record too!
+        *
+        * @param       string          Table name
+        * @param       integer         Record uid
+        * @param       integer         Language uid. If zero, then all languages are selected.
+        * @return      array           Array with information. Errors will return string with message.
         */
        function translationInfo($table,$uid,$sys_language_uid=0)       {
                global $TCA;
-               
+
                if ($TCA[$table] && $uid)       {
                        t3lib_div::loadTCA($table);
 
@@ -133,7 +154,7 @@ class t3lib_transl8tools    {
                                                                        t3lib_BEfunc::deleteClause($trTable).
                                                                        t3lib_BEfunc::versioningPlaceholderClause($trTable)
                                                        );
-                                                       
+
                                                        $translations = array();
                                                        $translations_errors = array();
                                                        foreach($translationsTemp as $r)        {
@@ -158,29 +179,38 @@ class t3lib_transl8tools  {
                        } else return 'Record "'.$table.'_'.$uid.'" was not found';
                } else return 'No table "'.$table.'" or no UID value';
        }
-               
+
        /**
-        *  Returns the table in which translations for input table is found.
+        * Returns the table in which translations for input table is found.
+        *
+        * @param       [type]          $table: ...
+        * @return      [type]          ...
         */
        function getTranslationTable($table) {
                return $this->isTranslationInOwnTable($table) ? $table : $this->foreignTranslationTable($table);
        }
-       
+
        /**
-        *  Returns true, if the input table has localization enabled and done so with records from the same table
+        * Returns true, if the input table has localization enabled and done so with records from the same table
+        *
+        * @param       [type]          $table: ...
+        * @return      [type]          ...
         */
        function isTranslationInOwnTable($table) {
                global $TCA;
 
                return $TCA[$table]['ctrl']['languageField'] && $TCA[$table]['ctrl']['transOrigPointerField'] && !$TCA[$table]['ctrl']['transOrigPointerTable'];
        }
-       
+
        /**
-        *  Returns foreign translation table, if any
+        * Returns foreign translation table, if any
+        *
+        * @param       [type]          $table: ...
+        * @return      [type]          ...
         */
        function foreignTranslationTable($table) {
                global $TCA;
-               
+
                $trTable = $TCA[$table]['ctrl']['transForeignTable'];
 
                if ($trTable && $TCA[$trTable] && $TCA[$trTable]['ctrl']['languageField'] && $TCA[$trTable]['ctrl']['transOrigPointerField'] && $TCA[$trTable]['ctrl']['transOrigPointerTable']===$table)       {
index 17e4db0..54b68a8 100755 (executable)
@@ -168,6 +168,7 @@ $TYPO3_CONF_VARS = Array(
                'explicitADmode' => 'explicitDeny',     // Sets the general allow/deny mode for selector box values. Value can be either "explicitAllow" or "explicitDeny", nothing else!
                'XCLASS' => Array(),                                    // See 'Inside TYPO3' document for more information.
                'niceFlexFormXMLtags' => TRUE,                  // If set, the flexform XML will be stored with meaningful tags which can be validated with DTD/schema. If you rely on custom reading of the XML from pre-4.0 versions you should set this to false if you don't like to change your reader code (internally it is insignificant since t3lib_div::xml2array() doesn't care for the tags if the index-attribute value is set)
+               'flexFormXMLincludeDiffBase' => TRUE,   // If set, an additional tag with index "vXX.vDEFbase" is created for translations in flexforms holding the value of the default language when translation was changed. Used to show diff of value. This setting will change whether the system thinks flexform XML looks clean. For example when FALSE XX.vDEFbase fields will be removed in cleaning while accepted if TRUE (of course)
                'compactFlexFormXML' => 0,                              // If set, the flexform XML will not contain indentation spaces making XML more compact
                'elementVersioningOnly' => FALSE,               // If true, only element versioning is allowed in the backend. This is recommended for new installations of TYPO3 4.2+ since "page" and "branch" versioning types are known for the drawbacks of loosing ids and "element" type versions supports moving now.
        ),
index 1c594df..b8f1093 100755 (executable)
@@ -382,7 +382,7 @@ $TCA['be_users'] = Array (
        ),
        'types' => Array (
                '0' => Array('showitem' => 'username;;;;2-2-2, password, usergroup, lockToDomain, disableIPlock, admin;;;;5-5-5, realName;;;;3-3-3, email, lang, userMods;;;;4-4-4, allowed_languages, workspace_perms, options, db_mountpoints, file_mountpoints, fileoper_perms, --div--, TSconfig;;;;5-5-5'),
-               '1' => Array('showitem' => 'username;;;;2-2-2, password, usergroup, disableIPlock, admin;;;;5-5-5, realName;;;;3-3-3, email, lang, options;;;;4-4-4, db_mountpoints, file_mountpoints, fileoper_perms, --div--, TSconfig;;;;5-5-5')
+               '1' => Array('showitem' => 'username;;;;2-2-2, password, usergroup, disableIPlock, admin;;;;5-5-5, realName;;;;3-3-3, email, lang, options;;;;4-4-4, allowed_languages;Preview languages:, db_mountpoints, file_mountpoints, fileoper_perms, --div--, TSconfig;;;;5-5-5')
        ),
        'palettes' => Array (
                '1' => Array('showitem' => 'disable, starttime, endtime')
index 686e7e6..4500686 100755 (executable)
@@ -978,11 +978,20 @@ class localRecordList extends recordList {
 
                        // If the record is edit-locked by another user, we will show a little warning sign:
                if ($lockInfo=t3lib_BEfunc::isRecordLocked($table,$row['uid'])) {
-                       $cells[]='<a href="#" onclick="'.htmlspecialchars('alert('.$LANG->JScharCode($lockInfo['msg']).');return false;').'">'.
+                       $cells[] = '<a href="#" onclick="'.htmlspecialchars('alert('.$LANG->JScharCode($lockInfo['msg']).');return false;').'">'.
                                        '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/recordlock_warning3.gif','width="17" height="12"').' title="'.htmlspecialchars($lockInfo['msg']).'" alt="" />'.
                                        '</a>';
                }
 
+                       // Call stats information hook
+               if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['recStatInfoHooks']))  {
+                       $stat='';
+                       $_params = array($table,$row['uid']);
+                       foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['recStatInfoHooks'] as $_funcRef)  {
+                               $stat.=t3lib_div::callUserFunction($_funcRef,$_params,$this);
+                       }
+                       $cells[] = $stat;
+               }               
 
                        // Compile items into a DIV-element:
                return '
index 1ddb4b4..084ecee 100755 (executable)
@@ -120,7 +120,16 @@ class webPageTree extends t3lib_browseTree {
                $pageIdStr = '';
                if ($this->ext_showPageId) { $pageIdStr = '['.$row['uid'].']&nbsp;'; }
 
-               return $dragDropIcon.$lockIcon.$pageIdStr;
+                       // Call stats information hook
+               $stat = '';
+               if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['recStatInfoHooks']))  {
+                       $_params = array('pages',$row['uid']);
+                       foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['recStatInfoHooks'] as $_funcRef)  {
+                               $stat.=t3lib_div::callUserFunction($_funcRef,$_params,$this);
+                       }
+               }
+
+               return $dragDropIcon.$lockIcon.$pageIdStr.$stat;
        }
 
        /**
index 0f66c9a..7e75805 100755 (executable)
@@ -1533,10 +1533,20 @@ class tx_cms_layout extends recordList {
                                                '<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/recordlock_warning3.gif','width="17" height="12"').' title="'.htmlspecialchars($lockInfo['msg']).'" alt="" />'.
                                                '</a>';
                } else $lockIcon='';
+               
+                       // Call stats information hook
+               $stat = '';
+               if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['recStatInfoHooks']))  {
+                       $_params = array('tt_content',$row['uid']);
+                       foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['recStatInfoHooks'] as $_funcRef)  {
+                               $stat.=t3lib_div::callUserFunction($_funcRef,$_params,$this);
+                       }
+               }
 
                        // Create header with icon/lock-icon/title:
                $header = $this->getIcon('tt_content',$row).
                                $lockIcon.
+                               $stat.
                                ($langMode ? $this->languageFlag($row['sys_language_uid']) : '').
                                '&nbsp;<b>'.htmlspecialchars($this->CType_labels[$row['CType']]).'</b>';
                $out = '
diff --git a/typo3/sysext/lowlevel/clmods/class.syslog.php b/typo3/sysext/lowlevel/clmods/class.syslog.php
new file mode 100644 (file)
index 0000000..7c0f4aa
--- /dev/null
@@ -0,0 +1,120 @@
+<?php
+/***************************************************************
+*  Copyright notice
+*
+*  (c) 2007 Kasper Skaarhoj (kasperYYYY@typo3.com)
+*  All rights reserved
+*
+*  This script is part of the TYPO3 project. The TYPO3 project is
+*  free software; you can redistribute it and/or modify
+*  it under the terms of the GNU General Public License as published by
+*  the Free Software Foundation; either version 2 of the License, or
+*  (at your option) any later version.
+*
+*  The GNU General Public License can be found at
+*  http://www.gnu.org/copyleft/gpl.html.
+*  A copy is found in the textfile GPL.txt and important notices to the license
+*  from the author is found in LICENSE.txt distributed with these scripts.
+*
+*
+*  This script is distributed in the hope that it will be useful,
+*  but WITHOUT ANY WARRANTY; without even the implied warranty of
+*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+*  GNU General Public License for more details.
+*
+*  This copyright notice MUST APPEAR in all copies of the script!
+***************************************************************/
+/**
+ * Cleaner module: syslog
+ * User function called from tx_lowlevel_cleaner_core configured in ext_localconf.php
+ *
+ * @author     Kasper Skårhøj <kasperYYYY@typo3.com>
+ */
+/**
+ * [CLASS/FUNCTION INDEX of SCRIPT]
+ *
+ *
+ *
+ *   57: class tx_lowlevel_cleanflexform extends tx_lowlevel_cleaner_core
+ *   64:     function tx_lowlevel_cleanflexform()
+ *   89:     function main()
+ *  122:     function main_parseTreeCallBack($tableName,$uid,$echoLevel,$versionSwapmode,$rootIsVersion)
+ *  154:     function main_autoFix($resultArray)
+ *
+ * TOTAL FUNCTIONS: 4
+ * (This index is automatically created/updated by the extension "extdeveval")
+ *
+ */
+
+
+/**
+ * syslog
+ *
+ * @author     Kasper Skårhøj <kasperYYYY@typo3.com>
+ * @package TYPO3
+ * @subpackage tx_lowlevel
+ */
+class tx_lowlevel_syslog extends tx_lowlevel_cleaner_core {
+
+       /**
+        * Constructor
+        *
+        * @return      void
+        */
+       function tx_lowlevel_cleanflexform()    {
+               parent::tx_lowlevel_cleaner_core();
+
+               $this->cli_help['name'] = 'syslog -- Show entries from syslog';
+               $this->cli_help['description'] = trim('
+Showing last 25 hour entries from the syslog. More features pending. This is the most basic and can be useful for nightly check test reports.
+');
+
+               $this->cli_help['examples'] = '';
+       }
+
+       /**
+        * Find syslog
+        *
+        * @return      array
+        */
+       function main() {
+               global $TYPO3_DB;
+
+                       // Initialize result array:
+               $resultArray = array(
+                       'message' => $this->cli_help['name'].chr(10).chr(10).$this->cli_help['description'],
+                       'headers' => array(
+                               'listing' => array('','',1),
+                               'allDetails' => array('','',0),
+                       ),
+                       'listing' => array(),
+                       'allDetails' => array()
+               );
+               
+               $rows = $TYPO3_DB->exec_SELECTgetRows(
+                               '*',
+                               'sys_log',
+                               'tstamp>'.(time()-25*3600)
+                       );
+               foreach($rows as $r)    {
+                       $l = unserialize($r['log_data']);
+                       $explained = '#'.$r['uid'].' '.t3lib_BEfunc::datetime($r['tstamp']).' USER['.$r['userid'].']: '.sprintf($r['details'],$l[0],$l[1],$l[2],$l[3],$l[4],$l[5]);
+                       $resultArray['listing'][] = $explained;
+                       $resultArray['allDetails'][] = array($explained,t3lib_div::arrayToLogString($r,'uid,userid,action,recuid,tablename,recpid,error,tstamp,type,details_nr,IP,event_pid,NEWid,workspace'));
+               }
+
+               return $resultArray;
+       }
+
+       /**
+        * Mandatory autofix function
+        * Will run auto-fix on the result array. Echos status during processing.
+        *
+        * @param       array           Result array from main() function
+        * @return      void
+        */
+       function main_autoFix($resultArray)     {
+       }
+}
+
+?>
\ No newline at end of file
index 65de814..4e81e2f 100644 (file)
@@ -15,5 +15,6 @@ if (TYPO3_MODE=='BE') {
        $TYPO3_CONF_VARS['EXTCONF']['lowlevel']['cleanerModules']['deleted'] = array('EXT:lowlevel/clmods/class.deleted.php:tx_lowlevel_deleted');
        $TYPO3_CONF_VARS['EXTCONF']['lowlevel']['cleanerModules']['versions'] = array('EXT:lowlevel/clmods/class.versions.php:tx_lowlevel_versions');   
        $TYPO3_CONF_VARS['EXTCONF']['lowlevel']['cleanerModules']['cleanflexform'] = array('EXT:lowlevel/clmods/class.cleanflexform.php:tx_lowlevel_cleanflexform');
+       $TYPO3_CONF_VARS['EXTCONF']['lowlevel']['cleanerModules']['syslog'] = array('EXT:lowlevel/clmods/class.syslog.php:tx_lowlevel_syslog');
 }
 ?>
\ No newline at end of file