Fixed bug #10735: Wrong returnUrl with clipboard actions
[Packages/TYPO3.CMS.git] / t3lib / class.t3lib_tsparser_ext.php
old mode 100755 (executable)
new mode 100644 (file)
index 5daa53d..9fbdf79
@@ -2,7 +2,7 @@
 /***************************************************************
 *  Copyright notice
 *
-*  (c) 1999-2006 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
@@ -440,6 +440,7 @@ class t3lib_tsparser_ext extends t3lib_TStemplate   {
                                                        $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 '#'.
+                                                       $comment = $this->makeHtmlspecialchars($comment);       // Masking HTML Tags: Replace < with &lt; and > with &gt;
                                                        $HTML.= ' <span class="comment">'.trim($comment).'</span>';
                                                }
                                        }
@@ -589,41 +590,49 @@ class t3lib_tsparser_ext extends t3lib_TStemplate {
                reset($keyArr);
                $a=0;
                $c=count($keyArr);
+               static $i;
                while (list($key,)=each($keyArr))       {
-                       $HTML='';
+                       $HTML = '';
                        $a++;
-                       $deeper = is_array($arr[$key.'.']);
-                       $row=$arr[$key];
+                       $deeper = is_array($arr[$key . '.']);
+                       $row = $arr[$key];
 
                        $PM = 'join';
-                       $LN = ($a==$c)?'blank':'line';
-                       $BTM = ($a==$c)?'top':'';
+                       $LN = ($a==$c) ? 'blank' : 'line';
+                       $BTM = ($a==$c) ? 'top' : '';
                        $PM = 'join';
 
-                       $HTML.=$depthData;
-                       $icon = substr($row['templateID'],0,3)=='sys' ? t3lib_iconWorks::getIcon('sys_template',array('root'=>$row['root'])) :
-                                                       (substr($row['templateID'],0,6)=='static' ? t3lib_iconWorks::getIcon('static_template',array()) : 'gfx/i/default.gif');
-                       $alttext= '['.$row['templateID'].']';
-                       $alttext.= $row['pid'] ? ' - '.t3lib_BEfunc::getRecordPath($row['pid'],$GLOBALS['SOBE']->perms_clause,20) : '';
-                       if (in_array($row['templateID'],$this->clearList_const) || in_array($row['templateID'],$this->clearList_setup)) {
-                               $A_B='<a href="index.php?id='.$GLOBALS['SOBE']->id.'&template='.$row['templateID'].'">';
-                               $A_E='</a>';
+                       $HTML .= $depthData;
+                       $icon = substr($row['templateID'],0,3) == 'sys' ? t3lib_iconWorks::getIcon('sys_template', array('root' => $row['root'])) :
+                                                       (substr($row['templateID'], 0, 6) == 'static' ? t3lib_iconWorks::getIcon('static_template', array()) : 'gfx/i/default.gif');
+                       $alttext = '[' . $row['templateID'] . ']';
+                       $alttext .= $row['pid'] ? ' - ' . t3lib_BEfunc::getRecordPath($row['pid'], $GLOBALS['SOBE']->perms_clause, 20) : '';
+                       if (in_array($row['templateID'], $this->clearList_const) || in_array($row['templateID'], $this->clearList_setup)) {
+                               $A_B = '<a href="index.php?id=' . $GLOBALS['SOBE']->id . '&template=' . $row['templateID'] . '">';
+                               $A_E = '</a>';
+                               if (t3lib_div::_GP('template') == $row['templateID']) {
+                                       $A_B = '<strong>' . $A_B;
+                                       $A_E .= '</strong>';
+                               }
                        } else {
-                               $A_B='';
-                               $A_E='';
+                               $A_B = '';
+                               $A_E = '';
                        }
-                       $HTML.=($first?'':'<IMG src="'.$GLOBALS['BACK_PATH'].'gfx/ol/'.$PM.$BTM.'.gif" width="18" height="16" align="top" border=0>').'<IMG src="'.$GLOBALS['BACK_PATH'].$icon.'" width="18" height="16" align="top" title="'.$alttext.'">'.$A_B.t3lib_div::fixed_lgd_cs($row['title'],$GLOBALS['BE_USER']->uc['titleLen']).$A_E.'&nbsp;&nbsp;';
+                       $HTML .= ($first ? '' : '<img src="' . $GLOBALS['BACK_PATH'] . 'gfx/ol/' . $PM . $BTM . '.gif" width="18" height="16" align="top" border="0" />') .
+                               '<img ' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], $icon) . ' align="top" title="' . $alttext.'" /> ' .
+                               $A_B . t3lib_div::fixed_lgd_cs($row['title'], $GLOBALS['BE_USER']->uc['titleLen']) . $A_E . '&nbsp;&nbsp;';
                        $RL = $this->ext_getRootlineNumber($row['pid']);
-                       $keyArray[] = '<tr>
-                                                       <td nowrap>'.$HTML.'</td>
-                                                       <td align=center>'.($row['root']?'<b>X</b>':'').'&nbsp;&nbsp;</td>
-                                                       <td align=center'.$row['bgcolor_setup'].'>'.fw(($row['clConf']?'<b>X</b>':'').'&nbsp;&nbsp;').'</td>
-                                                       <td align=center'.$row['bgcolor_const'].'>'.fw(($row['clConst']?'<b>X</b>':'').'&nbsp;&nbsp;').'</td>
-                                                       <td>'.($row['pid']?'&nbsp;'.$row['pid'].(strcmp($RL,'')?' ('.$RL.')':'').'&nbsp;&nbsp;':'').'</td>
-                                                       <td>'.($row['next']?'&nbsp;'.$row['next'].'&nbsp;&nbsp;':'').'</td>
+                       $keyArray[] = '<tr class="' . ($i++ % 2 == 0 ? 'bgColor4' : 'bgColor6') . '">
+                                                       <td nowrap>' . $HTML . '</td>
+                                                       <td align="center" class="bgColor5">' . ($row['root'] ? '<img' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/perm-allowed.gif', 'width="10" height="9"') . ' align="top" alt="" />' : '') . '&nbsp;&nbsp;</td>
+                                                       <td align="center">' . fw(($row['clConf'] ? '<img' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'],'gfx/perm-allowed.gif', 'width="10" height="9"') . ' align="top" alt="" />' :'') . '&nbsp;&nbsp;') . '</td>
+                                                       <td align="center" class="bgColor5">' . fw(($row['clConst'] ? '<img' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/perm-allowed.gif', 'width="10" height="9"') . ' align="top" alt="" />' : '') . '&nbsp;&nbsp;') . '</td>
+                                                       <td align="center">' . ($row['pid'] ? $row['pid'] : '') . '</td>
+                                                       <td align="center" class="bgColor5">' . (strcmp($RL, '') ? $RL : '') . '</td>
+                                                       <td>' . ($row['next'] ? '&nbsp;' . $row['next'] . '&nbsp;&nbsp;' : '') . '</td>
                                                </tr>';
                        if ($deeper)    {
-                               $keyArray = $this->ext_getTemplateHierarchyArr($arr[$key.'.'], $depthData.($first?'':'<IMG src="'.$GLOBALS['BACK_PATH'].'gfx/ol/'.$LN.'.gif" width="18" height="16" align="top">'), $keyArray);
+                               $keyArray = $this->ext_getTemplateHierarchyArr($arr[$key . '.'], $depthData . ($first ? '' : '<img src="' . $GLOBALS['BACK_PATH'] . 'gfx/ol/' . $LN . '.gif" width="18" height="16" align="top" />'), $keyArray);
                        }
                }
                return $keyArray;
@@ -697,7 +706,11 @@ class t3lib_tsparser_ext extends t3lib_TStemplate  {
        function ext_fixed_lgd($string,$chars)  {
                if ($chars >= 4)        {
                        if(strlen($string)>$chars)  {
-                               return substr($string, 0, $chars-3).'...';
+                               if(strlen($string)>24 && substr($string,0,12) == '##'.$this->Cmarker.'_B##') {
+                                       return '##'.$this->Cmarker.'_B##'.t3lib_div::fixed_lgd_cs(substr($string,12,-12), $chars-3).'##'.$this->Cmarker.'_E##';
+                               } else {
+                                       return t3lib_div::fixed_lgd_cs($string, $chars-3);
+                               }
                        }
                }
                return $string;
@@ -846,6 +859,14 @@ class t3lib_tsparser_ext extends t3lib_TStemplate  {
                                                                                        // label
                                                                                $editableComments[$const]['label'] = trim($keyValPair[1]);
                                                                        break;
+                                                                       case 'customsubcategory':
+                                                                                       // custom subCategory label
+                                                                               $customSubcategory = explode('=',$keyValPair[1],2);
+                                                                               if (trim($customSubcategory[0])) {
+                                                                                       $subCategoryKey = strtolower($customSubcategory[0]);
+                                                                                       $this->subCategories[$subCategoryKey][0] = $GLOBALS['LANG']->sL($customSubcategory[1]);
+                                                                               }
+                                                                       break;
                                                                }
                                                        }
                                                }
@@ -1076,7 +1097,7 @@ class t3lib_tsparser_ext extends t3lib_TStemplate {
                                while($entry=$d->read()) {
                                        if ($entry!='.' && $entry!='..')        {
                                                $wholePath = $path.'/'.$entry;          // Because of odd PHP-error where  <BR>-tag is sometimes placed after a filename!!
-                                               if (@file_exists($wholePath) && (!$type || filetype($wholePath)==$type))        {
+                                               if (file_exists($wholePath) && (!$type || filetype($wholePath)==$type)) {
                                                        $fI = t3lib_div::split_fileref($wholePath);
                                                        $this->dirResources[]=substr($wholePath,strlen(PATH_site));
                                                }
@@ -1307,7 +1328,7 @@ class t3lib_tsparser_ext extends t3lib_TStemplate {
                                                                }
 
                                                                if ($copyFile && @is_file($copyFile))   {
-                                                                       $p_field.='<img src="clear.gif" width="20" height="1" alt="" /><img'.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'],'gfx/clip_copy.gif','width="12" height="12"').' border="0" alt="" /><input type="checkbox" name="_copyResource['.$params['name'].']" value="'.htmlspecialchars($copyFile).'" onClick="uFormUrl('.$aname.');if (this.checked) {alert(unescape(\''.rawurlencode(sprintf("This will make a copy of the current file, '%s'. Do you really want that?",$params['value'])).'\'));}" />';
+                                                                       $p_field .= '<img src="clear.gif" width="20" ' . 'height="1" alt="" /><img' . t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/clip_copy.gif', 'width="12" height="12"') . ' border="0" alt="" /><input type="checkbox" ' . 'name="_copyResource[' . $params['name'] . ']" value="' . htmlspecialchars($copyFile) . '" onclick="uFormUrl(' . $aname . ');if (this.checked && !confirm(\'' . t3lib_div::slashJS(htmlspecialchars(sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_tsparser.xml:tsparser_ext.make_copy'), $params['value']))) . '\')) this.checked=false;" />';
                                                                }
 
                                                                // Upload?
@@ -1354,7 +1375,7 @@ class t3lib_tsparser_ext extends t3lib_TStemplate {
                                                }
 
 
-                        $deleteIconHTML = '<img class="typo3-tstemplate-ceditor-control undoIcon" '.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/undo.gif').' alt="Revert to default Constant" title="Revert to default Constant" rel="'.$params['name'].'" />';
+                                               $deleteIconHTML = '<img class="typo3-tstemplate-ceditor-control undoIcon" '.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/undo.gif').' alt="Revert to default Constant" title="Revert to default Constant" rel="'.$params['name'].'" />';
                                                $editIconHTML   = '<img class="typo3-tstemplate-ceditor-control editIcon" '.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/edit2.gif').' alt="Edit this Constant" title="Edit this Constant" rel="'.$params['name'].'" />';
                                                $constantCheckbox = '<input type="hidden" name="'.$checkboxName.'" id="'.$checkboxID.'" value="'.$checkboxValue.'"/>';
 
@@ -1564,8 +1585,8 @@ class t3lib_tsparser_ext extends t3lib_TStemplate {
                                                                }
                                                        break;
                                                        case 'int+':
-                                                               $var=t3lib_div::intInRange($var,0,10000);
-                                                       break;
+                                                               $var = max(0, intval($var));
+                                                               break;
                                                        case 'color':
                                                                $col=array();
                                                                if($var && !t3lib_div::inList($this->HTMLcolorList,strtolower($var)))   {
@@ -1574,8 +1595,8 @@ class t3lib_tsparser_ext extends t3lib_TStemplate {
 
                                                                        $col[]=HexDec(substr($var,0,1));
                                                                        $col[]=HexDec(substr($var,1,1));
-                                                                       $col[]=HexDec(substr($var,2,1));                                                                        
-                                                                       
+                                                                       $col[]=HexDec(substr($var,2,1));
+
                                                                        if($useFullHex) {
                                                                                $col[]=HexDec(substr($var,3,1));
                                                                                $col[]=HexDec(substr($var,4,1));
@@ -1586,7 +1607,7 @@ class t3lib_tsparser_ext extends t3lib_TStemplate {
                                                                        if($useFullHex) {
                                                                                $var .= substr('0'.DecHex($col[3]),-1).substr('0'.DecHex($col[4]),-1).substr('0'.DecHex($col[5]),-1);
                                                                        }
-                                                                       
+
                                                                        $var = '#'.strtoupper($var);
                                                                }
                                                        break;
@@ -1770,4 +1791,5 @@ class t3lib_tsparser_ext extends t3lib_TStemplate {
 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_tsparser_ext.php'])     {
        include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_tsparser_ext.php']);
 }
-?>
+
+?>
\ No newline at end of file