Index: t3lib/class.t3lib_tsparser_ext.php =================================================================== --- t3lib/class.t3lib_tsparser_ext.php (revision 9100) +++ t3lib/class.t3lib_tsparser_ext.php (revision ) @@ -1,29 +1,29 @@ array(), // Constants of superior importance for the template-layout. This is dimensions, imagefiles and enabling of various features. The most basic constants, which you would almost always want to configure. + 'basic' => array(), // Constants of superior importance for the template-layout. This is dimensions, imagefiles and enabling of various features. The most basic constants, which you would almost always want to configure. - 'menu' => array(), // Menu setup. This includes fontfiles, sizes, background images. Depending on the menutype. + 'menu' => array(), // Menu setup. This includes fontfiles, sizes, background images. Depending on the menutype. - 'content' => array(), // All constants related to the display of pagecontent elements + 'content' => array(), // All constants related to the display of pagecontent elements - 'page' => array(), // General configuration like metatags, link targets + 'page' => array(), // General configuration like metatags, link targets - 'advanced' => array(), // Advanced functions, which are used very seldomly. + 'advanced' => array(), // Advanced functions, which are used very seldomly. - 'all' => array() // All constants are put here also! + 'all' => array() // All constants are put here also! - ); // This will be filled with the available categories of the current template. + ); // This will be filled with the available categories of the current template. var $subCategories = array( - // Standard categories: + // Standard categories: 'enable' => Array('Enable features', 'a'), 'dims' => Array('Dimensions, widths, heights, pixels', 'b'), 'file' => Array('Files', 'c'), - 'typo' => Array('Typography', 'd'), + 'typo' => Array('Typography', 'd'), 'color' => Array('Colors', 'e'), 'links' => Array('Links and targets', 'f'), 'language' => Array('Language specific constants', 'g'), - // subcategories based on the default content elements + // subcategories based on the default content elements 'cheader' => Array('Content: \'Header\'', 'ma'), 'cheader_g' => Array('Content: \'Header\', Graphical', 'ma'), 'ctext' => Array('Content: \'Text\'', 'mb'), @@ -148,35 +142,35 @@ var $resourceDimensions = array(); var $dirResources = array(); - var $backend_info=1; + var $backend_info = 1; // tsconstanteditor - var $ext_inBrace=0; + var $ext_inBrace = 0; // tsbrowser var $tsbrowser_searchKeys = array(); var $tsbrowser_depthKeys = array(); - var $constantMode=''; + var $constantMode = ''; - var $regexMode=''; + var $regexMode = ''; - var $fixedLgd=''; + var $fixedLgd = ''; - var $resourceCheck=0; + var $resourceCheck = 0; - var $ext_lineNumberOffset=0; + var $ext_lineNumberOffset = 0; - var $ext_localGfxPrefix=''; + var $ext_localGfxPrefix = ''; - var $ext_localWebGfxPrefix=''; + var $ext_localWebGfxPrefix = ''; - var $ext_expandAllNotes=0; + var $ext_expandAllNotes = 0; - var $ext_noPMicons=0; + var $ext_noPMicons = 0; - var $ext_noSpecialCharsOnLabels=0; + var $ext_noSpecialCharsOnLabels = 0; - var $ext_listOfTemplatesArr=array(); + var $ext_listOfTemplatesArr = array(); - var $ext_lineNumberOffset_mode=''; + var $ext_lineNumberOffset_mode = ''; - var $ext_dontCheckIssetValues=0; // Dont change... + var $ext_dontCheckIssetValues = 0; // Dont change... - var $ext_noCEUploadAndCopying=0; + var $ext_noCEUploadAndCopying = 0; - var $ext_printAll=0; + var $ext_printAll = 0; - var $ext_CEformName='forms[0]'; + var $ext_CEformName = 'forms[0]'; - var $ext_defaultOnlineResourceFlag=0; + var $ext_defaultOnlineResourceFlag = 0; var $doNotSortCategoriesBeforeMakingForm = FALSE; // ts analyzer - var $templateTitles=array(); + var $templateTitles = array(); /** @@ -188,20 +182,21 @@ * @param [type] $resourceFlag: ... * @return [type] ... */ - function flattenSetup($setupArray, $prefix, $resourceFlag) { + function flattenSetup($setupArray, $prefix, $resourceFlag) { - if (is_array($setupArray)) { + if (is_array($setupArray)) { - $this->getFileName_backPath=PATH_site; // Setting absolute prefixed path for relative resources. + $this->getFileName_backPath = PATH_site; // Setting absolute prefixed path for relative resources. foreach ($setupArray as $key => $val) { - if ($prefix || substr($key,0,16)!='TSConstantEditor') { // We don't want 'TSConstantEditor' in the flattend setup. + if ($prefix || substr($key, 0, 16) != 'TSConstantEditor') { // We don't want 'TSConstantEditor' in the flattend setup. - if (is_array($val)) { + if (is_array($val)) { - $this->flattenSetup($val,$prefix.$key, ($key=='file.')); + $this->flattenSetup($val, $prefix . $key, ($key == 'file.')); } elseif ($resourceFlag && $this->resourceCheck) { - $this->flatSetup[$prefix.$key] = $this->getFileName($val); + $this->flatSetup[$prefix . $key] = $this->getFileName($val); - if ($this->removeFromGetFilePath && substr($this->flatSetup[$prefix.$key],0,strlen($this->removeFromGetFilePath))==$this->removeFromGetFilePath) { + if ($this->removeFromGetFilePath && + substr($this->flatSetup[$prefix . $key], 0, strlen($this->removeFromGetFilePath)) == $this->removeFromGetFilePath) { - $this->flatSetup[$prefix.$key] = substr($this->flatSetup[$prefix.$key],strlen($this->removeFromGetFilePath)); + $this->flatSetup[$prefix . $key] = substr($this->flatSetup[$prefix . $key], strlen($this->removeFromGetFilePath)); } } else { - $this->flatSetup[$prefix.$key] = $val; + $this->flatSetup[$prefix . $key] = $val; } } } @@ -214,8 +209,8 @@ * @param [type] $all: ... * @return [type] ... */ - function substituteConstants($all) { + function substituteConstants($all) { - $this->Cmarker = substr(md5(uniqid('')),0,6); + $this->Cmarker = substr(md5(uniqid('')), 0, 6); return preg_replace_callback('/\{\$(.[^}]+)\}/', array($this, 'substituteConstantsCallBack'), $all); } @@ -228,24 +223,24 @@ * @see substituteConstants() */ function substituteConstantsCallBack($matches) { - switch($this->constantMode) { + switch ($this->constantMode) { case 'const': - $ret_val = isset($this->flatSetup[$matches[1]]) && !is_array($this->flatSetup[$matches[1]]) ? + $ret_val = isset($this->flatSetup[$matches[1]]) && !is_array($this->flatSetup[$matches[1]]) ? - '##'.$this->Cmarker.'_B##'.$matches[0].'##'.$this->Cmarker.'_E##' : + '##' . $this->Cmarker . '_B##' . $matches[0] . '##' . $this->Cmarker . '_E##' : - $matches[0]; - break; + $matches[0]; + break; case 'subst': - $ret_val = isset($this->flatSetup[$matches[1]]) && !is_array($this->flatSetup[$matches[1]]) ? + $ret_val = isset($this->flatSetup[$matches[1]]) && !is_array($this->flatSetup[$matches[1]]) ? - '##'.$this->Cmarker.'_B##'.$this->flatSetup[$matches[1]].'##'.$this->Cmarker.'_E##' : + '##' . $this->Cmarker . '_B##' . $this->flatSetup[$matches[1]] . '##' . $this->Cmarker . '_E##' : - $matches[0]; - break; + $matches[0]; + break; case 'untouched': $ret_val = $matches[0]; - break; + break; default: - $ret_val = isset($this->flatSetup[$matches[1]]) && !is_array($this->flatSetup[$matches[1]]) ? + $ret_val = isset($this->flatSetup[$matches[1]]) && !is_array($this->flatSetup[$matches[1]]) ? - $this->flatSetup[$matches[1]] : - $matches[0]; + $this->flatSetup[$matches[1]] : + $matches[0]; } return $ret_val; @@ -257,15 +252,15 @@ * @param [type] $all: ... * @return [type] ... */ - function substituteCMarkers($all) { + function substituteCMarkers($all) { - switch($this->constantMode) { + switch ($this->constantMode) { case 'const': - $all = str_replace('##'.$this->Cmarker.'_B##', '', $all); + $all = str_replace('##' . $this->Cmarker . '_B##', '', $all); - $all = str_replace('##'.$this->Cmarker.'_E##', '', $all); + $all = str_replace('##' . $this->Cmarker . '_E##', '', $all); break; case 'subst': - $all = str_replace('##'.$this->Cmarker.'_B##', '', $all); + $all = str_replace('##' . $this->Cmarker . '_B##', '', $all); - $all = str_replace('##'.$this->Cmarker.'_E##', '', $all); + $all = str_replace('##' . $this->Cmarker . '_E##', '', $all); break; default: $all = $all; @@ -280,40 +275,40 @@ * * @return [type] ... */ - function generateConfig_constants() { + function generateConfig_constants() { // These vars are also set lateron... $this->setup['resources'] = $this->resources; $this->setup['sitetitle'] = $this->sitetitle; // parse constants $constants = t3lib_div::makeInstance('t3lib_TSparser'); - $constants->regComments=1; // Register comments! + $constants->regComments = 1; // Register comments! $constants->setup = $this->const; $constants->setup = $this->mergeConstantsFromPageTSconfig($constants->setup); /* @var $matchObj t3lib_matchCondition_frontend */ $matchObj = t3lib_div::makeInstance('t3lib_matchCondition_frontend'); - $matchObj->setSimulateMatchResult(true); // Matches ALL conditions in TypoScript + $matchObj->setSimulateMatchResult(TRUE); // Matches ALL conditions in TypoScript - $c=0; + $c = 0; - $cc=count($this->constants); + $cc = count($this->constants); foreach ($this->constants as $str) { $c++; - if ($c==$cc) { + if ($c == $cc) { - if (strstr($str,$this->edit_divider)) { + if (strstr($str, $this->edit_divider)) { - $parts = explode($this->edit_divider,$str,2); + $parts = explode($this->edit_divider, $str, 2); - $str=$parts[1]; + $str = $parts[1]; - $constants->parse($parts[0],$matchObj); + $constants->parse($parts[0], $matchObj); } $this->flatSetup = Array(); - $this->flattenSetup($constants->setup,'',''); + $this->flattenSetup($constants->setup, '', ''); - $defaultConstants=$this->flatSetup; + $defaultConstants = $this->flatSetup; } - $constants->parse($str,$matchObj); + $constants->parse($str, $matchObj); } $this->flatSetup = Array(); - $this->flattenSetup($constants->setup,'',''); + $this->flattenSetup($constants->setup, '', ''); $this->setup['constants'] = $constants->setup; return $this->ext_compareFlatSetups($defaultConstants); @@ -326,19 +321,19 @@ * @param [type] $theKey: ... * @return [type] ... */ - function ext_getSetup($theSetup,$theKey) { + function ext_getSetup($theSetup, $theKey) { - $parts = explode('.',$theKey,2); + $parts = explode('.', $theKey, 2); - if (strcmp($parts[0],'') && is_array($theSetup[$parts[0].'.'])) { + if (strcmp($parts[0], '') && is_array($theSetup[$parts[0] . '.'])) { - if (strcmp(trim($parts[1]),'')) { + if (strcmp(trim($parts[1]), '')) { - return $this->ext_getSetup($theSetup[$parts[0].'.'],trim($parts[1])); + return $this->ext_getSetup($theSetup[$parts[0] . '.'], trim($parts[1])); } else { - return array($theSetup[$parts[0].'.'], $theSetup[$parts[0]]); + return array($theSetup[$parts[0] . '.'], $theSetup[$parts[0]]); } } else { - if (strcmp(trim($theKey),'')) { + if (strcmp(trim($theKey), '')) { - return array(array(),$theSetup[$theKey]); + return array(array(), $theSetup[$theKey]); } else { - return array($theSetup,''); + return array($theSetup, ''); } } } @@ -354,103 +349,114 @@ * @param boolean $alphaSort sorts the array keys / tree by alphabet when set to 1 * @return [type] ... */ - function ext_getObjTree($arr, $depth_in, $depthData, $parentType='',$parentValue='', $alphaSort='0') { + function ext_getObjTree($arr, $depth_in, $depthData, $parentType = '', $parentValue = '', $alphaSort = '0') { - $HTML=''; + $HTML = ''; - $a=0; + $a = 0; - if($alphaSort == '1') { + if ($alphaSort == '1') { ksort($arr); } - $keyArr_num=array(); + $keyArr_num = array(); - $keyArr_alpha=array(); + $keyArr_alpha = array(); foreach ($arr as $key => $value) { - if (substr($key,-2)!='..') { // Don't do anything with comments / linenumber registrations... + if (substr($key, -2) != '..') { // Don't do anything with comments / linenumber registrations... - $key=preg_replace('/\.$/','',$key); + $key = preg_replace('/\.$/', '', $key); - if (substr($key,-1)!='.') { + if (substr($key, -1) != '.') { - if (t3lib_div::testInt($key)) { + if (t3lib_div::testInt($key)) { - $keyArr_num[$key]=$arr[$key]; + $keyArr_num[$key] = $arr[$key]; } else { - $keyArr_alpha[$key]=$arr[$key]; + $keyArr_alpha[$key] = $arr[$key]; } } } } ksort($keyArr_num); - $keyArr=$keyArr_num+$keyArr_alpha; + $keyArr = $keyArr_num + $keyArr_alpha; - $c=count($keyArr); + $c = count($keyArr); - if ($depth_in) {$depth_in = $depth_in.'.';} + if ($depth_in) { + $depth_in = $depth_in . '.'; + } foreach ($keyArr as $key => $value) { $a++; - $depth=$depth_in.$key; + $depth = $depth_in . $key; - if ($this->bType!='const' || substr($depth,0,1)!='_') { // this excludes all constants starting with '_' from being shown. + if ($this->bType != 'const' || substr($depth, 0, 1) != '_') { // this excludes all constants starting with '_' from being shown. - $goto = substr(md5($depth),0,6); + $goto = substr(md5($depth), 0, 6); - $deeper = (is_array($arr[$key.'.']) && ($this->tsbrowser_depthKeys[$depth] || $this->ext_expandAllNotes)) ? 1 : 0; + $deeper = (is_array($arr[$key . '.']) && ($this->tsbrowser_depthKeys[$depth] || $this->ext_expandAllNotes)) ? 1 : 0; $PM = 'join'; - $LN = ($a==$c)?'blank':'line'; + $LN = ($a == $c) ? 'blank' : 'line'; - $BTM = ($a==$c)?'bottom':''; + $BTM = ($a == $c) ? 'bottom' : ''; - $PM = is_array($arr[$key.'.']) && !$this->ext_noPMicons ? ($deeper ? 'minus':'plus') : 'join'; + $PM = is_array($arr[$key . '.']) && !$this->ext_noPMicons ? ($deeper ? 'minus' : 'plus') : 'join'; - $HTML.=$depthData; + $HTML .= $depthData; - $theIcon=''; + $theIcon = ''; - if ($PM=='join') { + if ($PM == 'join') { - $HTML.=$theIcon; + $HTML .= $theIcon; } else { - $aHref='index.php?id=' . $GLOBALS['SOBE']->id . + $aHref = 'index.php?id=' . $GLOBALS['SOBE']->id . - '&tsbr[' . $depth.']=' . ($deeper ? 0 : 1) . + '&tsbr[' . $depth . ']=' . ($deeper ? 0 : 1) . - (t3lib_div::_GP("breakPointLN") ? '&breakPointLN=' . t3lib_div::_GP("breakPointLN") : '') . + (t3lib_div::_GP("breakPointLN") ? '&breakPointLN=' . t3lib_div::_GP("breakPointLN") : '') . - '#' .$goto; + '#' . $goto; - $HTML.=''.$theIcon.''; + $HTML .= '' . $theIcon . ''; } $label = $key; - if (t3lib_div::inList('types,resources,sitetitle',$depth) && $this->bType=='setup') { // Read only... + if (t3lib_div::inList('types,resources,sitetitle', $depth) && $this->bType == 'setup') { // Read only... - $label=''.$label.''; + $label = '' . $label . ''; } else { - if ($this->linkObjects) { + if ($this->linkObjects) { - $aHref = 'index.php?id='.$GLOBALS['SOBE']->id . + $aHref = 'index.php?id=' . $GLOBALS['SOBE']->id . - '&sObj=' . $depth . - (t3lib_div::_GP("breakPointLN") ? '&breakPointLN=' . t3lib_div::_GP("breakPointLN") : ''); + '&sObj=' . $depth . + (t3lib_div::_GP("breakPointLN") ? '&breakPointLN=' . t3lib_div::_GP("breakPointLN") : ''); - if ($this->bType!='const') { + if ($this->bType != 'const') { - $ln = is_array($arr[$key.'.ln..']) ? 'Defined in: '.$this->lineNumberToScript($arr[$key.'.ln..']) : 'N/A'; + $ln = is_array($arr[$key . '.ln..']) ? 'Defined in: ' . $this->lineNumberToScript($arr[$key . '.ln..']) : 'N/A'; } else { $ln = ''; } - if ($this->tsbrowser_searchKeys[$depth] & 4) { $label = ''.$label.''; } // The key has matched the search string + if ($this->tsbrowser_searchKeys[$depth] & 4) { + $label = '' . $label . ''; + } // The key has matched the search string - $label = ''.$label.''; + $label = '' . $label . ''; } } - $HTML.='['.$label.']'; + $HTML .= '[' . $label . ']'; - if (isset($arr[$key])) { + if (isset($arr[$key])) { $theValue = $arr[$key]; - if ($this->fixedLgd) { + if ($this->fixedLgd) { - $imgBlocks = ceil(1+strlen($depthData)/77); + $imgBlocks = ceil(1 + strlen($depthData) / 77); - $lgdChars = 68-ceil(strlen('['.$key.']')*0.8)-$imgBlocks*3; + $lgdChars = 68 - ceil(strlen('[' . $key . ']') * 0.8) - $imgBlocks * 3; - $theValue = $this->ext_fixed_lgd($theValue,$lgdChars); + $theValue = $this->ext_fixed_lgd($theValue, $lgdChars); } - if ($this->tsbrowser_searchKeys[$depth] & 2) { // The value has matched the search string + if ($this->tsbrowser_searchKeys[$depth] & 2) { // The value has matched the search string - $HTML.=' = '.$this->makeHtmlspecialchars($theValue).''; + $HTML .= ' = ' . $this->makeHtmlspecialchars($theValue) . ''; } else { - $HTML.=' = '.$this->makeHtmlspecialchars($theValue).''; + $HTML .= ' = ' . $this->makeHtmlspecialchars($theValue) . ''; } - if ($this->ext_regComments && isset($arr[$key.'..'])) { + if ($this->ext_regComments && isset($arr[$key . '..'])) { - $comment = $arr[$key.'..']; + $comment = $arr[$key . '..']; - if (!preg_match('/### makeHtmlspecialchars($comment); // Masking HTML Tags: Replace < with < and > with > + $comment = $this->makeHtmlspecialchars($comment); // Masking HTML Tags: Replace < with < and > with > - $HTML.= ' '.trim($comment).''; + $HTML .= ' ' . trim($comment) . ''; } } } - $HTML.='
'; + $HTML .= '
'; - if ($deeper) { + if ($deeper) { - $HTML.=$this->ext_getObjTree($arr[$key.'.'], $depth, $depthData.'', '' /* not used: $validate_info[$key] */, $arr[$key], $alphaSort); + $HTML .= $this->ext_getObjTree( + $arr[$key . '.'], + $depth, + $depthData . '', + '' /* not used: $validate_info[$key] */, + $arr[$key], + $alphaSort + ); } } } @@ -463,29 +469,29 @@ * @param [type] $lnArr: ... * @return [type] ... */ - function lineNumberToScript($lnArr) { + function lineNumberToScript($lnArr) { - if (!is_array($this->lnToScript)) { + if (!is_array($this->lnToScript)) { $this->lnToScript = array(); - $c=1; + $c = 1; - $c+=substr_count($GLOBALS['TYPO3_CONF_VARS']['FE']['defaultTypoScript_setup'],LF)+2; + $c += substr_count($GLOBALS['TYPO3_CONF_VARS']['FE']['defaultTypoScript_setup'], LF) + 2; $this->lnToScript[$c] = '[Default]'; - foreach($this->hierarchyInfoToRoot as $info) { + foreach ($this->hierarchyInfoToRoot as $info) { - $c+=$info['configLines']+1; + $c += $info['configLines'] + 1; $this->lnToScript[$c] = $info['title']; } } - foreach($lnArr as $k => $ln) { + foreach ($lnArr as $k => $ln) { - foreach($this->lnToScript as $endLn => $title) { + foreach ($this->lnToScript as $endLn => $title) { - if ($endLn >= intval($ln)) { + if ($endLn >= intval($ln)) { - $lnArr[$k] = '"'.$title.'", '.$ln; + $lnArr[$k] = '"' . $title . '", ' . $ln; break; } } } - return implode('; ',$lnArr); + return implode('; ', $lnArr); } /** @@ -494,7 +500,7 @@ * @param [type] $theValue: ... * @return [type] ... */ - function makeHtmlspecialchars($theValue){ + function makeHtmlspecialchars($theValue) { return $this->ext_noSpecialCharsOnLabels ? $theValue : htmlspecialchars($theValue); } @@ -507,47 +513,49 @@ * @param [type] $keyArray: ... * @return [type] ... */ - function ext_getSearchKeys($arr, $depth_in, $searchString, $keyArray) { + function ext_getSearchKeys($arr, $depth_in, $searchString, $keyArray) { - $keyArr=array(); + $keyArr = array(); foreach ($arr as $key => $value) { - $key=preg_replace('/\.$/','',$key); + $key = preg_replace('/\.$/', '', $key); - if (substr($key,-1)!='.') { + if (substr($key, -1) != '.') { - $keyArr[$key]=1; + $keyArr[$key] = 1; } } - $c=count($keyArr); + $c = count($keyArr); - if ($depth_in) { $depth_in = $depth_in.'.'; } + if ($depth_in) { + $depth_in = $depth_in . '.'; + } foreach ($keyArr as $key => $value) { - $depth=$depth_in.$key; + $depth = $depth_in . $key; - $deeper = is_array($arr[$key.'.']); + $deeper = is_array($arr[$key . '.']); - if ($this->regexMode) { + if ($this->regexMode) { - if (preg_match('/'.$searchString.'/',$arr[$key])) { // The value has matched + if (preg_match('/' . $searchString . '/', $arr[$key])) { // The value has matched - $this->tsbrowser_searchKeys[$depth]+=2; + $this->tsbrowser_searchKeys[$depth] += 2; } - if (preg_match('/'.$searchString.'/',$key)) { // The key has matched + if (preg_match('/' . $searchString . '/', $key)) { // The key has matched - $this->tsbrowser_searchKeys[$depth]+=4; + $this->tsbrowser_searchKeys[$depth] += 4; } - if (preg_match('/'.$searchString.'/',$depth_in)) { // Just open this subtree if the parent key has matched the search + if (preg_match('/' . $searchString . '/', $depth_in)) { // Just open this subtree if the parent key has matched the search - $this->tsbrowser_searchKeys[$depth]=1; + $this->tsbrowser_searchKeys[$depth] = 1; } } else { - if (stristr($arr[$key],$searchString)) { // The value has matched + if (stristr($arr[$key], $searchString)) { // The value has matched - $this->tsbrowser_searchKeys[$depth]+=2; + $this->tsbrowser_searchKeys[$depth] += 2; } - if (stristr($key,$searchString)) { // The key has matches + if (stristr($key, $searchString)) { // The key has matches - $this->tsbrowser_searchKeys[$depth]+=4; + $this->tsbrowser_searchKeys[$depth] += 4; } - if (stristr($depth_in,$searchString)) { // Just open this subtree if the parent key has matched the search + if (stristr($depth_in, $searchString)) { // Just open this subtree if the parent key has matched the search - $this->tsbrowser_searchKeys[$depth]=1; + $this->tsbrowser_searchKeys[$depth] = 1; } } - if ($deeper) { + if ($deeper) { $cS = count($this->tsbrowser_searchKeys); - $keyArray = $this->ext_getSearchKeys($arr[$key.'.'], $depth, $searchString, $keyArray); + $keyArray = $this->ext_getSearchKeys($arr[$key . '.'], $depth, $searchString, $keyArray); - if ($cS != count($this->tsbrowser_searchKeys)) { + if ($cS != count($this->tsbrowser_searchKeys)) { - $keyArray[$depth]=1; + $keyArray[$depth] = 1; } } } @@ -560,13 +568,15 @@ * @param [type] $pid: ... * @return [type] ... */ - function ext_getRootlineNumber($pid) { + function ext_getRootlineNumber($pid) { - if ($pid && is_array($GLOBALS['rootLine'])) { + if ($pid && is_array($GLOBALS['rootLine'])) { foreach ($GLOBALS['rootLine'] as $key => $val) { - if ($val['uid']==$pid) return $key; + if ($val['uid'] == $pid) { + return $key; - } - } - } + } + } + } + } /** * [Describe function...] @@ -577,16 +587,16 @@ * @param [type] $first: ... * @return [type] ... */ - function ext_getTemplateHierarchyArr($arr,$depthData, $keyArray,$first=0) { + function ext_getTemplateHierarchyArr($arr, $depthData, $keyArray, $first = 0) { - $keyArr=array(); + $keyArr = array(); foreach ($arr as $key => $value) { - $key=preg_replace('/\.$/','',$key); + $key = preg_replace('/\.$/', '', $key); - if (substr($key,-1)!='.') { + if (substr($key, -1) != '.') { - $keyArr[$key]=1; + $keyArr[$key] = 1; } } - $a=0; + $a = 0; - $c=count($keyArr); + $c = count($keyArr); static $i = 0; foreach ($keyArr as $key => $value) { $HTML = ''; @@ -595,8 +605,8 @@ $row = $arr[$key]; $PM = 'join'; - $LN = ($a==$c) ? 'blank' : 'line'; + $LN = ($a == $c) ? 'blank' : 'line'; - $BTM = ($a==$c) ? 'top' : ''; + $BTM = ($a == $c) ? 'top' : ''; $PM = 'join'; $HTML .= $depthData; @@ -604,10 +614,10 @@ $alttext = '[' . $row['templateID'] . ']'; $alttext .= $row['pid'] ? ' - ' . t3lib_BEfunc::getRecordPath($row['pid'], $GLOBALS['SOBE']->perms_clause, 20) : ''; - $icon = (substr($row['templateID'],0,3) == 'sys' ? + $icon = (substr($row['templateID'], 0, 3) == 'sys' ? - t3lib_iconWorks::getSpriteIconForRecord('sys_template', $row, array('title' => $alttext)) - : t3lib_iconWorks::getSpriteIcon('mimetypes-x-content-template-static', array('title' => $alttext)) - ); + t3lib_iconWorks::getSpriteIconForRecord('sys_template', $row, array('title' => $alttext)) + : t3lib_iconWorks::getSpriteIcon('mimetypes-x-content-template-static', array('title' => $alttext)) + ); if (in_array($row['templateID'], $this->clearList_const) || in_array($row['templateID'], $this->clearList_setup)) { $A_B = ''; $A_E = ''; @@ -620,20 +630,24 @@ $A_E = ''; } $HTML .= ($first ? '' : '') . - $icon . - $A_B . htmlspecialchars(t3lib_div::fixed_lgd_cs($row['title'], $GLOBALS['BE_USER']->uc['titleLen'])) . $A_E . '  '; + $icon . + $A_B . htmlspecialchars(t3lib_div::fixed_lgd_cs($row['title'], $GLOBALS['BE_USER']->uc['titleLen'])) . $A_E . '  '; $RL = $this->ext_getRootlineNumber($row['pid']); $keyArray[] = ' ' . $HTML . ' ' . ($row['root'] ? t3lib_iconWorks::getSpriteIcon('status-status-checked') : '') . '   - ' . ($row['clConf'] ? t3lib_iconWorks::getSpriteIcon('status-status-checked') :'') . '  ' . ' + ' . ($row['clConf'] ? t3lib_iconWorks::getSpriteIcon('status-status-checked') : '') . '  ' . ' ' . ($row['clConst'] ? t3lib_iconWorks::getSpriteIcon('status-status-checked') : '') . '  ' . ' ' . ($row['pid'] ? $row['pid'] : '') . ' ' . (strcmp($RL, '') ? $RL : '') . ' ' . ($row['next'] ? ' ' . $row['next'] . '  ' : '') . ' '; - if ($deeper) { + if ($deeper) { - $keyArray = $this->ext_getTemplateHierarchyArr($arr[$key . '.'], $depthData . ($first ? '' : ''), $keyArray); + $keyArray = $this->ext_getTemplateHierarchyArr( + $arr[$key . '.'], + $depthData . ($first ? '' : ''), + $keyArray + ); } } return $keyArray; @@ -646,21 +660,21 @@ * @param [type] $pointer: ... * @return [type] ... */ - function ext_process_hierarchyInfo($depthDataArr,&$pointer) { + function ext_process_hierarchyInfo($depthDataArr, &$pointer) { - $parent = $this->hierarchyInfo[$pointer-1]['templateParent']; + $parent = $this->hierarchyInfo[$pointer - 1]['templateParent']; - while ($pointer>0 && $this->hierarchyInfo[$pointer-1]['templateParent']==$parent) { + while ($pointer > 0 && $this->hierarchyInfo[$pointer - 1]['templateParent'] == $parent) { $pointer--; $row = $this->hierarchyInfo[$pointer]; - $depthDataArr[$row['templateID']]=$row; + $depthDataArr[$row['templateID']] = $row; - $depthDataArr[$row['templateID']]['bgcolor_setup'] = isset($this->clearList_setup_temp[$row['templateID']])?' class="bgColor5"':''; + $depthDataArr[$row['templateID']]['bgcolor_setup'] = isset($this->clearList_setup_temp[$row['templateID']]) ? ' class="bgColor5"' : ''; - $depthDataArr[$row['templateID']]['bgcolor_const'] = isset($this->clearList_const_temp[$row['templateID']])?' class="bgColor5"':''; + $depthDataArr[$row['templateID']]['bgcolor_const'] = isset($this->clearList_const_temp[$row['templateID']]) ? ' class="bgColor5"' : ''; unset($this->clearList_setup_temp[$row['templateID']]); unset($this->clearList_const_temp[$row['templateID']]); - $this->templateTitles[$row['templateID']]=$row['title']; + $this->templateTitles[$row['templateID']] = $row['title']; - if ($row['templateID']==$this->hierarchyInfo[$pointer-1]['templateParent']) { + if ($row['templateID'] == $this->hierarchyInfo[$pointer - 1]['templateParent']) { - $depthDataArr[$row['templateID'].'.'] = $this->ext_process_hierarchyInfo(array(), $pointer); + $depthDataArr[$row['templateID'] . '.'] = $this->ext_process_hierarchyInfo(array(), $pointer); } } return $depthDataArr; @@ -677,21 +691,21 @@ * @param [type] $syntaxHLBlockmode: ... * @return [type] ... */ - function ext_outputTS($config, $lineNumbers=0, $comments=0, $crop=0, $syntaxHL=0, $syntaxHLBlockmode=0) { + function ext_outputTS($config, $lineNumbers = 0, $comments = 0, $crop = 0, $syntaxHL = 0, $syntaxHLBlockmode = 0) { - $all=''; + $all = ''; foreach ($config as $str) { - $all .= LF .'[GLOBAL]' . LF . $str; + $all .= LF . '[GLOBAL]' . LF . $str; } - if ($syntaxHL) { + if ($syntaxHL) { - $all = preg_replace('/^[^'.LF.']*./','',$all); + $all = preg_replace('/^[^' . LF . ']*./', '', $all); $all = chop($all); $tsparser = t3lib_div::makeInstance('t3lib_TSparser'); - $tsparser->lineNumberOffset=$this->ext_lineNumberOffset+1; + $tsparser->lineNumberOffset = $this->ext_lineNumberOffset + 1; $tsparser->parentObject = $this; - return $tsparser->doSyntaxHighlight($all,$lineNumbers?array($this->ext_lineNumberOffset+1):'',$syntaxHLBlockmode); + return $tsparser->doSyntaxHighlight($all, $lineNumbers ? array($this->ext_lineNumberOffset + 1) : '', $syntaxHLBlockmode); } else { - return $this->ext_formatTS($all,$lineNumbers,$comments,$crop); + return $this->ext_formatTS($all, $lineNumbers, $comments, $crop); } } @@ -704,13 +718,13 @@ * @param [type] $chars: ... * @return [type] ... */ - function ext_fixed_lgd($string,$chars) { + function ext_fixed_lgd($string, $chars) { - if ($chars >= 4) { + if ($chars >= 4) { - if(strlen($string)>$chars) { + if (strlen($string) > $chars) { - if(strlen($string)>24 && substr($string,0,12) == '##'.$this->Cmarker.'_B##') { + 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##'; + 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 t3lib_div::fixed_lgd_cs($string, $chars - 3); } } } @@ -724,8 +738,8 @@ * @param [type] $str: ... * @return [type] ... */ - function ext_lnBreakPointWrap($ln,$str) { + function ext_lnBreakPointWrap($ln, $str) { - return ''.$str.''; + return '' . $str . ''; } /** @@ -737,26 +751,30 @@ * @param [type] $crop: ... * @return [type] ... */ - function ext_formatTS($input, $ln, $comments=1, $crop=0) { + function ext_formatTS($input, $ln, $comments = 1, $crop = 0) { - $input = preg_replace('/^[^'.LF.']*./','',$input); + $input = preg_replace('/^[^' . LF . ']*./', '', $input); $input = chop($input); - $cArr = explode(LF,$input); + $cArr = explode(LF, $input); - $n = ceil(log10(count($cArr)+$this->ext_lineNumberOffset)); + $n = ceil(log10(count($cArr) + $this->ext_lineNumberOffset)); - $lineNum=''; + $lineNum = ''; foreach ($cArr as $k => $v) { - $lln=$k+$this->ext_lineNumberOffset+1; + $lln = $k + $this->ext_lineNumberOffset + 1; - if ($ln) $lineNum = $this->ext_lnBreakPointWrap($lln,str_replace(' ',' ',sprintf('% '.$n.'d',$lln))).': '; + if ($ln) { + $lineNum = $this->ext_lnBreakPointWrap($lln, str_replace(' ', ' ', sprintf('% ' . $n . 'd', $lln))) . ': '; + } - $v=htmlspecialchars($v); + $v = htmlspecialchars($v); - if ($crop) {$v=$this->ext_fixed_lgd($v,($ln?71:77));} + if ($crop) { + $v = $this->ext_fixed_lgd($v, ($ln ? 71 : 77)); + } - $cArr[$k] = $lineNum.str_replace(' ',' ',$v); + $cArr[$k] = $lineNum . str_replace(' ', ' ', $v); - $firstChar = substr(trim($v),0,1); + $firstChar = substr(trim($v), 0, 1); - if ($firstChar=='[') { + if ($firstChar == '[') { - $cArr[$k] = ''.$cArr[$k].''; + $cArr[$k] = '' . $cArr[$k] . ''; - } elseif ($firstChar=='/' || $firstChar=='#') { + } elseif ($firstChar == '/' || $firstChar == '#') { - if ($comments) { + if ($comments) { - $cArr[$k] = ''.$cArr[$k].''; + $cArr[$k] = '' . $cArr[$k] . ''; } else { unset($cArr[$k]); } @@ -764,7 +782,7 @@ } - $output = implode($cArr, '
').'
'; + $output = implode($cArr, '
') . '
'; return $output; } @@ -775,17 +793,17 @@ * @param [type] $template_uid: ... * @return [type] ... */ - function ext_getFirstTemplate($id,$template_uid=0) { + function ext_getFirstTemplate($id, $template_uid = 0) { // Query is taken from the runThroughTemplates($theRootLine) function in the parent class. - if (intval($id)) { + if (intval($id)) { - if ($template_uid) { + if ($template_uid) { - $addC = ' AND uid='.$template_uid; + $addC = ' AND uid=' . $template_uid; } - $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_template', 'pid='.intval($id).$addC.' '.$this->whereClause, '', 'sorting', '1'); + $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_template', 'pid=' . intval($id) . $addC . ' ' . $this->whereClause, '', 'sorting', '1'); $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res); - t3lib_BEfunc::workspaceOL('sys_template',$row); + t3lib_BEfunc::workspaceOL('sys_template', $row); $GLOBALS['TYPO3_DB']->sql_free_result($res); - return $row; // Returns the template row if found. + return $row; // Returns the template row if found. } } @@ -795,17 +813,19 @@ * @param [type] $id: ... * @return [type] ... */ - function ext_getAllTemplates($id) { + function ext_getAllTemplates($id) { // Query is taken from the runThroughTemplates($theRootLine) function in the parent class. - if (intval($id)) { + if (intval($id)) { - $outRes=array(); + $outRes = array(); - $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_template', 'pid='.intval($id).' '.$this->whereClause, '', 'sorting'); + $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_template', 'pid=' . intval($id) . ' ' . $this->whereClause, '', 'sorting'); - while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { + while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { - t3lib_BEfunc::workspaceOL('sys_template',$row); + t3lib_BEfunc::workspaceOL('sys_template', $row); - if (is_array($row)) $outRes[] = $row; + if (is_array($row)) { + $outRes[] = $row; - } + } + } $GLOBALS['TYPO3_DB']->sql_free_result($res); - return $outRes; // Returns the template rows in an array. + return $outRes; // Returns the template rows in an array. } } @@ -816,43 +836,36 @@ * @param [type] $default: ... * @return [type] ... */ - function ext_compareFlatSetups($default) { + function ext_compareFlatSetups($default) { - $editableComments=array(); + $editableComments = array(); reset($this->flatSetup); foreach ($this->flatSetup as $const => $value) { - if (substr($const,-2)!='..' && isset($this->flatSetup[$const.'..'])) { + if (substr($const, -2) != '..' && isset($this->flatSetup[$const . '..'])) { - $comment = trim($this->flatSetup[$const.'..']); + $comment = trim($this->flatSetup[$const . '..']); - $c_arr = explode(LF,$comment); + $c_arr = explode(LF, $comment); foreach ($c_arr as $k => $v) { - $line=trim(preg_replace('/^[#\/]*/','',$v)); + $line = trim(preg_replace('/^[#\/]*/', '', $v)); - if ($line) { + if ($line) { $parts = explode(';', $line); foreach ($parts as $par) { - if (strstr($par,'=')) { + if (strstr($par, '=')) { - $keyValPair =explode('=',$par,2); + $keyValPair = explode('=', $par, 2); - switch(trim(strtolower($keyValPair[0]))) { + switch (trim(strtolower($keyValPair[0]))) { case 'type': // Type: - /* - int (range; low-high, list: item,item,item = selector), - boolean (check), - string (default), - wrap, - html-color ..., - file - */ $editableComments[$const]['type'] = trim($keyValPair[1]); break; case 'cat': // list of categories. - $catSplit=explode('/',strtolower($keyValPair[1])); + $catSplit = explode('/', strtolower($keyValPair[1])); $editableComments[$const]['cat'] = trim($catSplit[0]); - $catSplit[1]=trim($catSplit[1]); // This is the subcategory. Must be a key in $this->subCategories[]. catSplit[2] represents the search-order within the subcat. + $catSplit[1] = trim($catSplit[1]); // This is the subcategory. Must be a key in $this->subCategories[]. catSplit[2] represents the search-order within the subcat. - if ($catSplit[1] && isset($this->subCategories[$catSplit[1]])) { + if ($catSplit[1] && isset($this->subCategories[$catSplit[1]])) { - $editableComments[$const]['subcat_name']=$catSplit[1]; + $editableComments[$const]['subcat_name'] = $catSplit[1]; - $editableComments[$const]['subcat']=$this->subCategories[$catSplit[1]][1].'/'.$catSplit[1].'/'.trim($catSplit[2]).'z'; + $editableComments[$const]['subcat'] = $this->subCategories[$catSplit[1]][1] . '/' . + $catSplit[1] . '/' . trim($catSplit[2]) . 'z'; } else { - $editableComments[$const]['subcat']='x'.'/'.trim($catSplit[2]).'z'; + $editableComments[$const]['subcat'] = 'x' . '/' . trim($catSplit[2]) . 'z'; } break; case 'label': @@ -861,7 +874,7 @@ break; case 'customsubcategory': // custom subCategory label - $customSubcategory = explode('=',$keyValPair[1],2); + $customSubcategory = explode('=', $keyValPair[1], 2); if (trim($customSubcategory[0])) { $subCategoryKey = strtolower($customSubcategory[0]); $this->subCategories[$subCategoryKey][0] = $GLOBALS['LANG']->sL($customSubcategory[1]); @@ -873,11 +886,11 @@ } } } - if (isset($editableComments[$const])) { + if (isset($editableComments[$const])) { - $editableComments[$const]['name']=$const; + $editableComments[$const]['name'] = $const; - $editableComments[$const]['value']=trim($value); + $editableComments[$const]['value'] = trim($value); - if (isset($default[$const])) { + if (isset($default[$const])) { - $editableComments[$const]['default_value']=trim($default[$const]); + $editableComments[$const]['default_value'] = trim($default[$const]); } } } @@ -890,17 +903,17 @@ * @param [type] $editConstArray: ... * @return [type] ... */ - function ext_categorizeEditableConstants($editConstArray) { + function ext_categorizeEditableConstants($editConstArray) { - // Runs through the available constants and fills the $this->categories array with pointers and priority-info + // Runs through the available constants and fills the $this->categories array with pointers and priority-info foreach ($editConstArray as $constName => $constData) { if (!$constData['type']) { - $constData['type']='string'; + $constData['type'] = 'string'; } - $cats = explode(',',$constData['cat']); + $cats = explode(',', $constData['cat']); - foreach ($cats as $theCat) { // if = only one category, while allows for many. We have agreed on only one category is the most basic way... + foreach ($cats as $theCat) { // if = only one category, while allows for many. We have agreed on only one category is the most basic way... - $theCat=trim($theCat); + $theCat = trim($theCat); - if ($theCat) { + if ($theCat) { - $this->categories[$theCat][$constName]=$constData['subcat']; + $this->categories[$theCat][$constName] = $constData['subcat']; } } } @@ -911,12 +924,12 @@ * * @return [type] ... */ - function ext_getCategoryLabelArray() { + function ext_getCategoryLabelArray() { - // Returns array used for labels in the menu. + // Returns array used for labels in the menu. $retArr = array(); foreach ($this->categories as $k => $v) { - if (count($v)) { + if (count($v)) { - $retArr[$k]=strtoupper($k).' ('.count($v).')'; + $retArr[$k] = strtoupper($k) . ' (' . count($v) . ')'; } } return $retArr; @@ -928,33 +941,33 @@ * @param [type] $type: ... * @return [type] ... */ - function ext_getTypeData($type) { + function ext_getTypeData($type) { $retArr = array(); - $type=trim($type); + $type = trim($type); - if (!$type) { + if (!$type) { - $retArr['type']='string'; + $retArr['type'] = 'string'; } else { - $m=strcspn ($type,' ['); + $m = strcspn($type, ' ['); - $retArr['type']=strtolower(substr($type,0,$m)); + $retArr['type'] = strtolower(substr($type, 0, $m)); - if (t3lib_div::inList('int,options,file,boolean,offset,user', $retArr['type'])) { + if (t3lib_div::inList('int,options,file,boolean,offset,user', $retArr['type'])) { - $p=trim(substr($type,$m)); + $p = trim(substr($type, $m)); $reg = array(); - preg_match('/\[(.*)\]/',$p,$reg); + preg_match('/\[(.*)\]/', $p, $reg); - $p=trim($reg[1]); + $p = trim($reg[1]); - if ($p) { + if ($p) { - $retArr['paramstr']=$p; + $retArr['paramstr'] = $p; - switch($retArr['type']) { + switch ($retArr['type']) { case 'int': - if (substr($retArr['paramstr'],0,1)=='-') { + if (substr($retArr['paramstr'], 0, 1) == '-') { - $retArr['params']=t3lib_div::intExplode('-',substr($retArr['paramstr'],1)); + $retArr['params'] = t3lib_div::intExplode('-', substr($retArr['paramstr'], 1)); - $retArr['params'][0]=intval('-'.$retArr['params'][0]); + $retArr['params'][0] = intval('-' . $retArr['params'][0]); } else { - $retArr['params']=t3lib_div::intExplode('-',$retArr['paramstr']); + $retArr['params'] = t3lib_div::intExplode('-', $retArr['paramstr']); } - $retArr['paramstr']=$retArr['params'][0].' - '.$retArr['params'][1]; + $retArr['paramstr'] = $retArr['params'][0] . ' - ' . $retArr['params'][1]; break; case 'options': - $retArr['params']=explode(',',$retArr['paramstr']); + $retArr['params'] = explode(',', $retArr['paramstr']); break; } } @@ -969,12 +982,12 @@ * @param [type] $category: ... * @return [type] ... */ - function ext_getTSCE_config($category) { + function ext_getTSCE_config($category) { - $catConf=$this->setup['constants']['TSConstantEditor.'][$category.'.']; + $catConf = $this->setup['constants']['TSConstantEditor.'][$category . '.']; - $out=array(); + $out = array(); - if (is_array($catConf)) { + if (is_array($catConf)) { foreach ($catConf as $key => $val) { - switch($key) { + switch ($key) { case 'image': $out['imagetag'] = $this->ext_getTSCE_config_image($catConf['image']); break; @@ -984,12 +997,12 @@ $out[$key] = $val; break; default: - if (t3lib_div::testInt($key)) { + if (t3lib_div::testInt($key)) { - $constRefs = explode(',',$val); + $constRefs = explode(',', $val); foreach ($constRefs as $const) { - $const=trim($const); + $const = trim($const); - if ($const && $const<=20) { + if ($const && $const <= 20) { - $out['constants'][$const].=$this->ext_getKeyImage($key); + $out['constants'][$const] .= $this->ext_getKeyImage($key); } } } @@ -997,7 +1010,7 @@ } } } - $this->helpConfig=$out; + $this->helpConfig = $out; } /** @@ -1006,8 +1019,8 @@ * @param [type] $key: ... * @return [type] ... */ - function ext_getKeyImage($key) { + function ext_getKeyImage($key) { - return ''; + return ''; } /** @@ -1016,23 +1029,23 @@ * @param [type] $imgConf: ... * @return [type] ... */ - function ext_getTSCE_config_image($imgConf) { + function ext_getTSCE_config_image($imgConf) { - if (substr($imgConf,0,4)=='gfx/') { + if (substr($imgConf, 0, 4) == 'gfx/') { - $iFile=$this->ext_localGfxPrefix.$imgConf; + $iFile = $this->ext_localGfxPrefix . $imgConf; - $tFile=$this->ext_localWebGfxPrefix.$imgConf; + $tFile = $this->ext_localWebGfxPrefix . $imgConf; - } elseif (substr($imgConf,0,4)=='EXT:') { + } elseif (substr($imgConf, 0, 4) == 'EXT:') { $iFile = t3lib_div::getFileAbsFileName($imgConf); - if ($iFile) { + if ($iFile) { - $f = substr($iFile,strlen(PATH_site)); + $f = substr($iFile, strlen(PATH_site)); - $tFile=$GLOBALS['BACK_PATH'].'../'.$f; + $tFile = $GLOBALS['BACK_PATH'] . '../' . $f; } } else { - $f = 'uploads/tf/'.$this->extractFromResources($this->setup['resources'],$imgConf); + $f = 'uploads/tf/' . $this->extractFromResources($this->setup['resources'], $imgConf); - $iFile=PATH_site.$f; + $iFile = PATH_site . $f; - $tFile=$GLOBALS['BACK_PATH'].'../'.$f; + $tFile = $GLOBALS['BACK_PATH'] . '../' . $f; } - $imageInfo=@getImagesize($iFile); + $imageInfo = @getImagesize($iFile); - return ''; + return ''; } /** @@ -1040,25 +1053,25 @@ * * @return [type] ... */ - function ext_resourceDims() { + function ext_resourceDims() { - if ($this->setup['resources']) { + if ($this->setup['resources']) { - $rArr=explode(',',$this->setup['resources']); + $rArr = explode(',', $this->setup['resources']); foreach ($rArr as $c => $val) { - $val=trim($val); + $val = trim($val); - $theFile = PATH_site.'uploads/tf/'.$val; + $theFile = PATH_site . 'uploads/tf/' . $val; - if ($val && @is_file($theFile)) { + if ($val && @is_file($theFile)) { $imgInfo = @getimagesize($theFile); } - if (is_array($imgInfo)) { + if (is_array($imgInfo)) { - $this->resourceDimensions[$val]=' ('.$imgInfo[0].'x'.$imgInfo[1].')'; + $this->resourceDimensions[$val] = ' (' . $imgInfo[0] . 'x' . $imgInfo[1] . ')'; } } } foreach ($this->dirResources as $c => $val) { - $val=trim($val); + $val = trim($val); - $imgInfo = @getimagesize(PATH_site.$val); + $imgInfo = @getimagesize(PATH_site . $val); - if (is_array($imgInfo)) { + if (is_array($imgInfo)) { - $this->resourceDimensions[$val]=' ('.$imgInfo[0].'x'.$imgInfo[1].')'; + $this->resourceDimensions[$val] = ' (' . $imgInfo[0] . 'x' . $imgInfo[1] . ')'; } } } @@ -1069,9 +1082,9 @@ * @param [type] $path: ... * @return [type] ... */ - function ext_readDirResources($path) { + function ext_readDirResources($path) { $path = trim($path); - if ($path && strstr($path, $GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir'])) { + if ($path && strstr($path, $GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir'])) { $path = rtrim($path, '/'); $this->readDirectory(PATH_site . $path); } @@ -1084,17 +1097,17 @@ * @param [type] $type: ... * @return [type] ... */ - function readDirectory($path,$type='file') { + function readDirectory($path, $type = 'file') { - if(@is_dir($path)) { + if (@is_dir($path)) { $d = @dir($path); - $tempArray=Array(); + $tempArray = Array(); - if (is_object($d)) { + if (is_object($d)) { - while($entry=$d->read()) { + while ($entry = $d->read()) { - if ($entry!='.' && $entry!='..') { + if ($entry != '.' && $entry != '..') { - $wholePath = $path.'/'.$entry; // Because of odd PHP-error where
-tag is sometimes placed after a filename!! + $wholePath = $path . '/' . $entry; // Because of odd PHP-error where
-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)); + $this->dirResources[] = substr($wholePath, strlen(PATH_site)); } } } @@ -1109,15 +1122,15 @@ * @param [type] $params: ... * @return [type] ... */ - function ext_fNandV($params) { + function ext_fNandV($params) { - $fN='data['.$params['name'].']'; + $fN = 'data[' . $params['name'] . ']'; - $fV=$params['value']; + $fV = $params['value']; - if (preg_match('/^{[\$][a-zA-Z0-9\.]*}$/',trim($fV),$reg)) { // Values entered from the constantsedit cannot be constants! 230502; removed \{ and set { + if (preg_match('/^{[\$][a-zA-Z0-9\.]*}$/', trim($fV), $reg)) { // Values entered from the constantsedit cannot be constants! 230502; removed \{ and set { - $fV=''; + $fV = ''; } - $fV=htmlspecialchars($fV); + $fV = htmlspecialchars($fV); - return array($fN,$fV,$params); + return array($fN, $fV, $params); } /** @@ -1127,231 +1140,271 @@ * @param [type] $category: ... * @return [type] ... */ - function ext_printFields($theConstants,$category) { + function ext_printFields($theConstants, $category) { reset($theConstants); - $output=' + $output = ' '; - $subcat=''; + $subcat = ''; - if (is_array($this->categories[$category])) { + if (is_array($this->categories[$category])) { - $help=$this->helpConfig; + $help = $this->helpConfig; - $this->rArr=explode(',',$this->setup['resources'].','.implode($this->dirResources,',')); + $this->rArr = explode(',', $this->setup['resources'] . ',' . implode($this->dirResources, ',')); - if (!$this->doNotSortCategoriesBeforeMakingForm) asort($this->categories[$category]); + if (!$this->doNotSortCategoriesBeforeMakingForm) { + asort($this->categories[$category]); + } foreach ($this->categories[$category] as $name => $type) { $params = $theConstants[$name]; - if (is_array($params)) { + if (is_array($params)) { - if ($subcat!=$params['subcat_name']) { + if ($subcat != $params['subcat_name']) { - $subcat=$params['subcat_name']; + $subcat = $params['subcat_name']; $subcat_name = $params['subcat_name'] ? $this->subCategories[$params['subcat_name']][0] : 'Others'; - $output.='

'.$subcat_name.'

'; + $output .= '

' . $subcat_name . '

'; } - $label=$GLOBALS['LANG']->sL($params['label']); + $label = $GLOBALS['LANG']->sL($params['label']); - $label_parts = explode(':',$label,2); + $label_parts = explode(':', $label, 2); - if (count($label_parts)==2) { + if (count($label_parts) == 2) { - $head=trim($label_parts[0]); + $head = trim($label_parts[0]); - $body=trim($label_parts[1]); + $body = trim($label_parts[1]); } else { - $head=trim($label_parts[0]); + $head = trim($label_parts[0]); - $body=''; + $body = ''; } - if (strlen($head)>35) { + if (strlen($head) > 35) { - if (!$body) {$body=$head;} + if (!$body) { + $body = $head; + } - $head=t3lib_div::fixed_lgd_cs($head,35); + $head = t3lib_div::fixed_lgd_cs($head, 35); } - $typeDat=$this->ext_getTypeData($params['type']); + $typeDat = $this->ext_getTypeData($params['type']); - $checked=''; + $checked = ''; - $p_field=''; + $p_field = ''; - $raname = substr(md5($params['name']),0,10); + $raname = substr(md5($params['name']), 0, 10); - $aname='\''.$raname.'\''; + $aname = '\'' . $raname . '\''; - list($fN,$fV,$params)=$this->ext_fNandV($params); + list($fN, $fV, $params) = $this->ext_fNandV($params); - switch($typeDat['type']) { + switch ($typeDat['type']) { case 'int': case 'int+': - $p_field='formWidth(5).' onChange="uFormUrl('.$aname.')" />'; + $p_field = 'formWidth(5) . ' onChange="uFormUrl(' . $aname . ')" />'; - if ($typeDat['paramstr']) { + if ($typeDat['paramstr']) { - $p_field.=' Range: '.$typeDat['paramstr']; + $p_field .= ' Range: ' . $typeDat['paramstr']; - } elseif ($typeDat['type']=='int+') { + } elseif ($typeDat['type'] == 'int+') { - $p_field.=' Range: 0 - '; + $p_field .= ' Range: 0 - '; } else { - $p_field.=' (Integer)'; + $p_field .= ' (Integer)'; } break; case 'color': - $colorNames=explode(',',','.$this->HTMLcolorList); + $colorNames = explode(',', ',' . $this->HTMLcolorList); - $p_field=''; + $p_field = ''; foreach ($colorNames as $val) { - $sel=''; + $sel = ''; - if ($val==strtolower($params['value'])) { + if ($val == strtolower($params['value'])) { $sel = ' selected'; } - $p_field.=''; + $p_field .= ''; } - $p_field=''; + $p_field = ''; - $p_field.='formWidth(7).' onChange="uFormUrl('.$aname.')" />'; + $p_field .= 'formWidth(7) . ' onChange="uFormUrl(' . $aname . ')" />'; break; case 'wrap': - $wArr = explode('|',$fV); + $wArr = explode('|', $fV); - $p_field='formWidth(29).' onChange="uFormUrl('.$aname.')" />'; + $p_field = 'formWidth(29) . ' onChange="uFormUrl(' . $aname . ')" />'; - $p_field.=' | '; + $p_field .= ' | '; - $p_field.='formWidth(15).' onChange="uFormUrl('.$aname.')" />'; + $p_field .= 'formWidth(15) . ' onChange="uFormUrl(' . $aname . ')" />'; break; case 'offset': - $wArr = explode(',',$fV); + $wArr = explode(',', $fV); - $labels = t3lib_div::trimExplode(',',$typeDat['paramstr']); + $labels = t3lib_div::trimExplode(',', $typeDat['paramstr']); - $p_field=($labels[0]?$labels[0]:'x').':formWidth(4).' onChange="uFormUrl('.$aname.')" />'; + $p_field = ($labels[0] ? $labels[0] : 'x') . ':formWidth(4) . ' onChange="uFormUrl(' . $aname . ')" />'; - $p_field.=' , '; + $p_field .= ' , '; - $p_field.=($labels[1]?$labels[1]:'y').':formWidth(4).' onChange="uFormUrl('.$aname.')" />'; + $p_field .= ($labels[1] ? $labels[1] : 'y') . ':formWidth(4) . ' onChange="uFormUrl(' . $aname . ')" />'; - for ($aa=2;$aaformWidth(4).' onChange="uFormUrl('.$aname.')" />'; + $p_field .= ' , ' . $labels[$aa] . ':formWidth(4) . ' onChange="uFormUrl(' . $aname . ')" />'; } else { - $p_field.=''; + $p_field .= ''; } } break; case 'options': - if (is_array($typeDat['params'])) { + if (is_array($typeDat['params'])) { - $p_field=''; + $p_field = ''; foreach ($typeDat['params'] as $val) { - $vParts = explode('=',$val,2); + $vParts = explode('=', $val, 2); $label = $vParts[0]; $val = isset($vParts[1]) ? $vParts[1] : $vParts[0]; - // option tag: + // option tag: - $sel=''; + $sel = ''; - if ($val==$params['value']) { + if ($val == $params['value']) { - $sel=' selected'; + $sel = ' selected'; } - $p_field.=''; + $p_field .= ''; } - $p_field=''; + $p_field = ''; } break; case 'boolean': - $p_field=''; + $p_field = ''; - $sel=''; + $sel = ''; - if ($fV) { + if ($fV) { - $sel=' checked'; + $sel = ' checked'; } - $p_field.=''; + $p_field .= ''; break; case 'comment': - $p_field=''; + $p_field = ''; - $sel=''; + $sel = ''; - if (!$fV) { + if (!$fV) { - $sel=' checked'; + $sel = ' checked'; } - $p_field.=''; + $p_field .= ''; break; case 'file': - $p_field=''; + $p_field = ''; - $theImage=''; + $theImage = ''; - $selectThisFile = $this->extractFromResources($this->setup['resources'],$params['value']); + $selectThisFile = $this->extractFromResources($this->setup['resources'], $params['value']); - if ($params['value'] && !$selectThisFile) { + if ($params['value'] && !$selectThisFile) { - if (in_array($params['value'],$this->dirResources)) { + if (in_array($params['value'], $this->dirResources)) { - $selectThisFile=$params['value']; + $selectThisFile = $params['value']; } } - // extensionlist + // extensionlist $extList = $typeDat['paramstr']; - $p_field=''; + $p_field = ''; - if ($extList=='IMAGE_EXT') { + if ($extList == 'IMAGE_EXT') { $extList = $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext']; } reset($this->rArr); - $onlineResourceFlag=$this->ext_defaultOnlineResourceFlag; + $onlineResourceFlag = $this->ext_defaultOnlineResourceFlag; foreach ($this->rArr as $c => $val) { - $val=trim($val); + $val = trim($val); - $fI=t3lib_div::split_fileref($val); + $fI = t3lib_div::split_fileref($val); - if ($val && (!$extList || t3lib_div::inList($extList,$fI['fileext']))) { + if ($val && (!$extList || t3lib_div::inList($extList, $fI['fileext']))) { if ($onlineResourceFlag <= 0 && strstr($fI['path'], $GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir'])) { - if ($onlineResourceFlag<0) { + if ($onlineResourceFlag < 0) { - $p_field.=''; + $p_field .= ''; } - $p_field.=''; + $p_field .= ''; - $onlineResourceFlag=1; + $onlineResourceFlag = 1; } - $dims=$this->resourceDimensions[$val]; + $dims = $this->resourceDimensions[$val]; - $sel=''; + $sel = ''; - // Check if $params['value'] is in the list of resources. + // Check if $params['value'] is in the list of resources. - if ($selectThisFile && $selectThisFile==$val) { + if ($selectThisFile && $selectThisFile == $val) { - $sel=' selected'; + $sel = ' selected'; - if ($onlineResourceFlag<=0) { + if ($onlineResourceFlag <= 0) { - $theImage=t3lib_BEfunc::thumbCode(array('resources'=>$selectThisFile),'sys_template','resources',$GLOBALS['BACK_PATH'],''); + $theImage = t3lib_BEfunc::thumbCode( + array( + 'resources' => $selectThisFile + ), + 'sys_template', + 'resources', + $GLOBALS['BACK_PATH'], + '' + ); } else { - $theImage=t3lib_BEfunc::thumbCode(array('resources'=>$fI['file']),'sys_template','resources',$GLOBALS['BACK_PATH'],'',$fI['path']); + $theImage = t3lib_BEfunc::thumbCode( + array( + 'resources' => $fI['file'] + ), + 'sys_template', + 'resources', + $GLOBALS['BACK_PATH'], + '', + $fI['path'] + ); } } - if ($onlineResourceFlag<=0) { + if ($onlineResourceFlag <= 0) { $onlineResourceFlag--; - // Value is set with a * + // Value is set with a * $val = $this->ext_setStar($val); - $p_field.=''; + $p_field .= ''; } else { - $p_field.=''; + $p_field .= ''; } } } - if (trim($params['value']) && !$selectThisFile) { + if (trim($params['value']) && !$selectThisFile) { $val = $params['value']; - $p_field.=''; + $p_field .= ''; - $p_field.=''; + $p_field .= ''; } - $p_field=''; + $p_field = ''; - $p_field.=$theImage; + $p_field .= $theImage; - if (!$this->ext_noCEUploadAndCopying) { + if (!$this->ext_noCEUploadAndCopying) { - // Copy a resource + // Copy a resource - $copyFile = $this->extractFromResources($this->setup['resources'],$params['value']); + $copyFile = $this->extractFromResources($this->setup['resources'], $params['value']); - if (!$copyFile) { + if (!$copyFile) { - if ($params['value']) { + if ($params['value']) { - $copyFile=PATH_site.$this->ext_detectAndFixExtensionPrefix($params['value']); + $copyFile = PATH_site . $this->ext_detectAndFixExtensionPrefix($params['value']); } } else { - $copyFile=''; + $copyFile = ''; } - if ($copyFile && @is_file($copyFile)) { + if ($copyFile && @is_file($copyFile)) { - $p_field .= '' . t3lib_iconWorks::getSpriteIcon('actions-edit-copy') . ''; + $p_field .= '' . + t3lib_iconWorks::getSpriteIcon('actions-edit-copy') . ''; } - // Upload? + // Upload? - $p_field.='
'; + $p_field .= '
'; - $p_field.='formWidth().' onChange="uFormUrl('.$aname.')" size="50" />'; + $p_field .= 'formWidth() . + ' onChange="uFormUrl(' . $aname . ')" size="50" />'; } break; case 'user': - $userFunction = $typeDat['paramstr']; + $userFunction = $typeDat['paramstr']; $userFunctionParams = array('fieldName' => $fN, 'fieldValue' => $fV); - $p_field = t3lib_div::callUserFunction($userFunction, $userFunctionParams, $this, ''); + $p_field = t3lib_div::callUserFunction($userFunction, $userFunctionParams, $this, ''); break; case 'small': default: - $fwidth= $typeDat['type']=='small' ? 10 : 46; + $fwidth = $typeDat['type'] == 'small' ? 10 : 46; - $p_field='formWidth($fwidth).' onChange="uFormUrl('.$aname.')" />'; + $p_field = 'formWidth($fwidth) . ' onChange="uFormUrl(' . $aname . ')" />'; break; } - // Define default names and IDs + // Define default names and IDs - $userTyposcriptID = 'userTS-'.$params['name']; + $userTyposcriptID = 'userTS-' . $params['name']; - $defaultTyposcriptID = 'defaultTS-'.$params['name']; + $defaultTyposcriptID = 'defaultTS-' . $params['name']; - $checkboxName = 'check['.$params['name'].']'; + $checkboxName = 'check[' . $params['name'] . ']'; $checkboxID = $checkboxName; - // Handle type=color specially + // Handle type=color specially - if ($typeDat['type']=='color' && substr($params['value'],0,2)!='{$') { + if ($typeDat['type'] == 'color' && substr($params['value'], 0, 2) != '{$') { - $color = '
 
'; + $color = '
 
'; } else { $color = ''; } @@ -1359,7 +1412,7 @@ if (!$this->ext_dontCheckIssetValues) { /* Set the default styling options */ - if(isset($this->objReg[$params['name']])) { + if (isset($this->objReg[$params['name']])) { $checkboxValue = 'checked'; $userTyposcriptStyle = ''; $defaultTyposcriptStyle = 'style="display:none;"'; @@ -1370,27 +1423,47 @@ } - $deleteIconHTML = t3lib_iconWorks::getSpriteIcon('actions-edit-undo',array('class'=>"typo3-tstemplate-ceditor-control undoIcon",'alt'=>"Revert to default Constant",'title'=>"Revert to default Constant",'rel'=>$params['name'])); - $editIconHTML = t3lib_iconWorks::getSpriteIcon('actions-document-open',array('class'=>"typo3-tstemplate-ceditor-control editIcon",'alt'=>"Edit this Constant",'title'=>"Edit this Constant",'rel'=>$params['name'])); + $deleteIconHTML = t3lib_iconWorks::getSpriteIcon( + 'actions-edit-undo', + array( + 'class' => "typo3-tstemplate-ceditor-control undoIcon", + 'alt' => "Revert to default Constant", + 'title' => "Revert to default Constant", + 'rel' => $params['name'] + ) + ); + $editIconHTML = t3lib_iconWorks::getSpriteIcon( + 'actions-document-open', + array( + 'class' => "typo3-tstemplate-ceditor-control editIcon", + 'alt' => "Edit this Constant", + 'title' => "Edit this Constant", + 'rel' => $params['name'] + ) + ); - $constantCheckbox = ''; + $constantCheckbox = ''; - // If there's no default value for the field, use a static label. + // If there's no default value for the field, use a static label. - if(!$params['default_value']) { + if (!$params['default_value']) { $params['default_value'] = '[Empty]'; } - $constantDefaultRow='
'.$editIconHTML.htmlspecialchars($params['default_value']).$color.'
'; + $constantDefaultRow = '
' . $editIconHTML . + htmlspecialchars($params['default_value']) . $color . '
'; } - $constantEditRow = '
'.$deleteIconHTML.$p_field.$color.'
'; + $constantEditRow = '
' . $deleteIconHTML . $p_field . $color . '
'; - $constantLabel = '
'.htmlspecialchars($head).'
'; + $constantLabel = '
' . htmlspecialchars($head) . '
'; - $constantName = '
['.$params['name'].']
'; + $constantName = '
[' . $params['name'] . ']
'; - $constantDescription = $body ? '
'.htmlspecialchars($body).'
' : ''; + $constantDescription = $body ? '
' . htmlspecialchars($body) . '
' : ''; - $constantData = '
'.$constantCheckbox.$constantEditRow.$constantDefaultRow.'
'; + $constantData = '
' . $constantCheckbox . $constantEditRow . $constantDefaultRow . '
'; - $output.=''.$help['constants'][$params['name']]; + $output .= '' . $help['constants'][$params['name']]; - $output.='
'.$constantLabel.$constantName.$constantDescription.$constantData.'
'; + $output .= '
' . $constantLabel . $constantName . + $constantDescription . $constantData . '
'; } else { debug('Error. Constant did not exist. Should not happen.'); } @@ -1400,16 +1473,6 @@ } - - - - - - - - - - /*************************** * * Processing input values @@ -1420,12 +1483,13 @@ * @param [type] $constants: ... * @return [type] ... */ - function ext_regObjectPositions($constants) { + function ext_regObjectPositions($constants) { - // This runs through the lines of the constants-field of the active template and registers the constants-names and linepositions in an array, $this->objReg + // This runs through the lines of the constants-field of the active template and registers the constants-names + // and linepositions in an array, $this->objReg - $this->raw = explode(LF,$constants); + $this->raw = explode(LF, $constants); - $this->rawP=0; + $this->rawP = 0; - $this->objReg=array(); // resetting the objReg if the divider is found!! + $this->objReg = array(); // resetting the objReg if the divider is found!! $this->ext_regObjects(''); } @@ -1435,36 +1499,36 @@ * @param [type] $pre: ... * @return [type] ... */ - function ext_regObjects($pre) { + function ext_regObjects($pre) { // works with regObjectPositions. "expands" the names of the TypoScript objects - while (isset($this->raw[$this->rawP])) { + while (isset($this->raw[$this->rawP])) { $line = ltrim($this->raw[$this->rawP]); - if (strstr($line,$this->edit_divider)) { + if (strstr($line, $this->edit_divider)) { - $this->objReg=array(); // resetting the objReg if the divider is found!! + $this->objReg = array(); // resetting the objReg if the divider is found!! } $this->rawP++; - if ($line) { + if ($line) { - if (substr($line,0,1)=='[') { + if (substr($line, 0, 1) == '[') { -// return $line; + // return $line; - } elseif (strcspn($line,'}#/')!=0) { + } elseif (strcspn($line, '}#/') != 0) { - $varL = strcspn($line,' {=<'); + $varL = strcspn($line, ' {=<'); - $var=substr($line,0,$varL); + $var = substr($line, 0, $varL); - $line = ltrim(substr($line,$varL)); + $line = ltrim(substr($line, $varL)); - switch(substr($line,0,1)) { + switch (substr($line, 0, 1)) { case '=': - $this->objReg[$pre.$var]=$this->rawP-1; + $this->objReg[$pre . $var] = $this->rawP - 1; break; case '{': $this->ext_inBrace++; - $this->ext_regObjects($pre.$var.'.'); + $this->ext_regObjects($pre . $var . '.'); break; } - $this->lastComment=''; + $this->lastComment = ''; - } elseif (substr($line,0,1)=='}') { + } elseif (substr($line, 0, 1) == '}') { - $this->lastComment=''; + $this->lastComment = ''; $this->ext_inBrace--; - if ($this->ext_inBrace<0) { + if ($this->ext_inBrace < 0) { - $this->ext_inBrace=0; + $this->ext_inBrace = 0; } else { break; } @@ -1480,21 +1544,21 @@ * @param [type] $var: ... * @return [type] ... */ - function ext_putValueInConf($key, $var) { + function ext_putValueInConf($key, $var) { // Puts the value $var to the TypoScript value $key in the current lines of the templates. // If the $key is not found in the template constants field, a new line is inserted in the bottom. - $theValue = ' '.trim($var); + $theValue = ' ' . trim($var); - if (isset($this->objReg[$key])) { + if (isset($this->objReg[$key])) { $lineNum = $this->objReg[$key]; - $parts = explode('=',$this->raw[$lineNum],2); + $parts = explode('=', $this->raw[$lineNum], 2); - if (count($parts)==2) { + if (count($parts) == 2) { - $parts[1]= $theValue; + $parts[1] = $theValue; } - $this->raw[$lineNum]=implode($parts,'='); + $this->raw[$lineNum] = implode($parts, '='); } else { - $this->raw[]=$key.' ='.$theValue; + $this->raw[] = $key . ' =' . $theValue; } - $this->changed=1; + $this->changed = 1; } /** @@ -1503,13 +1567,13 @@ * @param [type] $key: ... * @return [type] ... */ - function ext_removeValueInConf($key) { + function ext_removeValueInConf($key) { // Removes the value in the configuration - if (isset($this->objReg[$key])) { + if (isset($this->objReg[$key])) { $lineNum = $this->objReg[$key]; unset($this->raw[$lineNum]); } - $this->changed=1; + $this->changed = 1; } /** @@ -1519,22 +1583,22 @@ * @param [type] $settings: ... * @return [type] ... */ - function ext_depthKeys($arr,$settings) { + function ext_depthKeys($arr, $settings) { - $tsbrArray=array(); + $tsbrArray = array(); foreach ($arr as $theK => $theV) { - $theKeyParts = explode('.',$theK); + $theKeyParts = explode('.', $theK); - $depth=''; + $depth = ''; - $c=count($theKeyParts); + $c = count($theKeyParts); - $a=0; + $a = 0; foreach ($theKeyParts as $p) { $a++; - $depth.=($depth?'.':'').$p; + $depth .= ($depth ? '.' : '') . $p; - $tsbrArray[$depth]= ($c==$a) ? $theV : 1; + $tsbrArray[$depth] = ($c == $a) ? $theV : 1; } } // Modify settings foreach ($tsbrArray as $theK => $theV) { - if ($theV) { + if ($theV) { $settings[$theK] = 1; } else { unset($settings[$theK]); @@ -1552,80 +1616,80 @@ * @param [type] $tplRow: ... * @return [type] ... */ - function ext_procesInput($http_post_vars,$http_post_files,$theConstants,$tplRow) { + function ext_procesInput($http_post_vars, $http_post_files, $theConstants, $tplRow) { - $data=$http_post_vars['data']; + $data = $http_post_vars['data']; - $check=$http_post_vars['check']; + $check = $http_post_vars['check']; - $copyResource=$http_post_vars['_copyResource']; + $copyResource = $http_post_vars['_copyResource']; - $Wdata=$http_post_vars['Wdata']; + $Wdata = $http_post_vars['Wdata']; - $W2data=$http_post_vars['W2data']; + $W2data = $http_post_vars['W2data']; - $W3data=$http_post_vars['W3data']; + $W3data = $http_post_vars['W3data']; - $W4data=$http_post_vars['W4data']; + $W4data = $http_post_vars['W4data']; - $W5data=$http_post_vars['W5data']; + $W5data = $http_post_vars['W5data']; - if (is_array($data)) { + if (is_array($data)) { foreach ($data as $key => $var) { - if (isset($theConstants[$key])) { + if (isset($theConstants[$key])) { - if ($this->ext_dontCheckIssetValues || isset($check[$key])) { // If checkbox is set, update the value + if ($this->ext_dontCheckIssetValues || isset($check[$key])) { // If checkbox is set, update the value - list($var) = explode(LF,$var); // exploding with linebreak, just to make sure that no multiline input is given! + list($var) = explode(LF, $var); // exploding with linebreak, just to make sure that no multiline input is given! - $typeDat=$this->ext_getTypeData($theConstants[$key]['type']); + $typeDat = $this->ext_getTypeData($theConstants[$key]['type']); - switch($typeDat['type']) { + switch ($typeDat['type']) { case 'int': - if ($typeDat['paramstr']) { + if ($typeDat['paramstr']) { - $var=t3lib_div::intInRange($var,$typeDat['params'][0],$typeDat['params'][1]); + $var = t3lib_div::intInRange($var, $typeDat['params'][0], $typeDat['params'][1]); } else { - $var=intval($var); + $var = intval($var); } break; case 'int+': $var = max(0, intval($var)); - break; + break; case 'color': - $col=array(); + $col = array(); - if($var && !t3lib_div::inList($this->HTMLcolorList,strtolower($var))) { + if ($var && !t3lib_div::inList($this->HTMLcolorList, strtolower($var))) { - $var = preg_replace('/[^A-Fa-f0-9]*/','',$var); + $var = preg_replace('/[^A-Fa-f0-9]*/', '', $var); $useFullHex = strlen($var) > 3; - $col[]=HexDec(substr($var,0,1)); + $col[] = HexDec(substr($var, 0, 1)); - $col[]=HexDec(substr($var,1,1)); + $col[] = HexDec(substr($var, 1, 1)); - $col[]=HexDec(substr($var,2,1)); + $col[] = HexDec(substr($var, 2, 1)); - if($useFullHex) { + if ($useFullHex) { - $col[]=HexDec(substr($var,3,1)); + $col[] = HexDec(substr($var, 3, 1)); - $col[]=HexDec(substr($var,4,1)); + $col[] = HexDec(substr($var, 4, 1)); - $col[]=HexDec(substr($var,5,1)); + $col[] = HexDec(substr($var, 5, 1)); } - $var = substr('0'.DecHex($col[0]),-1).substr('0'.DecHex($col[1]),-1).substr('0'.DecHex($col[2]),-1); + $var = substr('0' . DecHex($col[0]), -1) . substr('0' . DecHex($col[1]), -1) . substr('0' . DecHex($col[2]), -1); - if($useFullHex) { + if ($useFullHex) { - $var .= substr('0'.DecHex($col[3]),-1).substr('0'.DecHex($col[4]),-1).substr('0'.DecHex($col[5]),-1); + $var .= substr('0' . DecHex($col[3]), -1) . substr('0' . DecHex($col[4]), -1) . substr('0' . DecHex($col[5]), -1); } - $var = '#'.strtoupper($var); + $var = '#' . strtoupper($var); } break; case 'comment': - if ($var) { + if ($var) { - $var='#'; + $var = '#'; } else { - $var=''; + $var = ''; } break; case 'wrap': - if (isset($Wdata[$key])) { + if (isset($Wdata[$key])) { - $var.='|'.$Wdata[$key]; + $var .= '|' . $Wdata[$key]; } break; case 'offset': - if (isset($Wdata[$key])) { + if (isset($Wdata[$key])) { - $var=intval($var).','.intval($Wdata[$key]); + $var = intval($var) . ',' . intval($Wdata[$key]); - if (isset($W2data[$key])) { + if (isset($W2data[$key])) { - $var.=','.intval($W2data[$key]); + $var .= ',' . intval($W2data[$key]); - if (isset($W3data[$key])) { + if (isset($W3data[$key])) { - $var.=','.intval($W3data[$key]); + $var .= ',' . intval($W3data[$key]); - if (isset($W4data[$key])) { + if (isset($W4data[$key])) { - $var.=','.intval($W4data[$key]); + $var .= ',' . intval($W4data[$key]); - if (isset($W5data[$key])) { + if (isset($W5data[$key])) { - $var.=','.intval($W5data[$key]); + $var .= ',' . intval($W5data[$key]); } } } @@ -1633,13 +1697,13 @@ } break; case 'boolean': - if ($var) { + if ($var) { $var = $typeDat['paramstr'] ? $typeDat['paramstr'] : 1; } break; case 'file': - if (!$this->ext_noCEUploadAndCopying) { + if (!$this->ext_noCEUploadAndCopying) { - if ($http_post_files['upload_data']['name'][$key] && $http_post_files['upload_data']['tmp_name'][$key]!='none') { + if ($http_post_files['upload_data']['name'][$key] && $http_post_files['upload_data']['tmp_name'][$key] != 'none') { $var = $this->upload_copy_file( $typeDat, $tplRow, @@ -1647,7 +1711,7 @@ $http_post_files['upload_data']['tmp_name'][$key] ); } - if ($copyResource[$key]) { + if ($copyResource[$key]) { $var = $this->upload_copy_file( $typeDat, $tplRow, @@ -1658,10 +1722,10 @@ } break; } - if ($this->ext_printAll || strcmp($theConstants[$key]['value'],$var)) { + if ($this->ext_printAll || strcmp($theConstants[$key]['value'], $var)) { - $this->ext_putValueInConf($key, $var); // Put value in, if changed. + $this->ext_putValueInConf($key, $var); // Put value in, if changed. } - unset($check[$key]); // Remove the entry because it has been "used" + unset($check[$key]); // Remove the entry because it has been "used" } else { $this->ext_removeValueInConf($key); } @@ -1669,9 +1733,9 @@ } } // Remaining keys in $check indicates fields that are just clicked "on" to be edited. Therefore we get the default value and puts that in the template as a start... - if (!$this->ext_dontCheckIssetValues && is_array($check)) { + if (!$this->ext_dontCheckIssetValues && is_array($check)) { foreach ($check as $key => $var) { - if (isset($theConstants[$key])) { + if (isset($theConstants[$key])) { $dValue = $theConstants[$key]['default_value']; $this->ext_putValueInConf($key, $dValue); } @@ -1688,39 +1752,39 @@ * @param [type] $tmp_name: ... * @return [type] ... */ - function upload_copy_file($typeDat,&$tplRow,$theRealFileName,$tmp_name) { + function upload_copy_file($typeDat, &$tplRow, $theRealFileName, $tmp_name) { // extensions $extList = $typeDat['paramstr']; - if ($extList=='IMAGE_EXT') { + if ($extList == 'IMAGE_EXT') { $extList = $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext']; } - $fI=t3lib_div::split_fileref($theRealFileName); + $fI = t3lib_div::split_fileref($theRealFileName); - if ($theRealFileName && (!$extList || t3lib_div::inList($extList,$fI['fileext']))) { + if ($theRealFileName && (!$extList || t3lib_div::inList($extList, $fI['fileext']))) { - $tmp_upload_name = t3lib_div::upload_to_tempfile($tmp_name); // If there is an uploaded file, move it for the sake of safe_mode. + $tmp_upload_name = t3lib_div::upload_to_tempfile($tmp_name); // If there is an uploaded file, move it for the sake of safe_mode. // Saving resource - $alternativeFileName=array(); + $alternativeFileName = array(); $alternativeFileName[$tmp_upload_name] = $theRealFileName; // Making list of resources $resList = $tplRow['resources']; - $resList = $tmp_upload_name.','.$resList; + $resList = $tmp_upload_name . ',' . $resList; - $resList=implode(t3lib_div::trimExplode(',',$resList,1),','); + $resList = implode(t3lib_div::trimExplode(',', $resList, 1), ','); // Making data-array $saveId = $tplRow['_ORIG_uid'] ? $tplRow['_ORIG_uid'] : $tplRow['uid']; - $recData=array(); + $recData = array(); $recData['sys_template'][$saveId]['resources'] = $resList; // Saving $tce = t3lib_div::makeInstance('t3lib_TCEmain'); - $tce->stripslashes_values=0; + $tce->stripslashes_values = 0; $tce->alternativeFileName = $alternativeFileName; - $tce->start($recData,Array()); + $tce->start($recData, Array()); $tce->process_datamap(); t3lib_div::unlink_tempfile($tmp_upload_name); - $tmpRow = t3lib_BEfunc::getRecordWSOL('sys_template',$saveId,'resources'); + $tmpRow = t3lib_BEfunc::getRecordWSOL('sys_template', $saveId, 'resources'); $tplRow['resources'] = $tmpRow['resources']; @@ -1737,10 +1801,10 @@ * @param [type] $perms_clause: ... * @return [type] ... */ - function ext_prevPageWithTemplate($id,$perms_clause) { + function ext_prevPageWithTemplate($id, $perms_clause) { - $rootLine = t3lib_BEfunc::BEgetRootLine($id,$perms_clause?' AND '.$perms_clause:''); + $rootLine = t3lib_BEfunc::BEgetRootLine($id, $perms_clause ? ' AND ' . $perms_clause : ''); foreach ($rootLine as $p) { - if ($this->ext_getFirstTemplate($p['uid'])) { + if ($this->ext_getFirstTemplate($p['uid'])) { return $p; } } @@ -1752,9 +1816,9 @@ * @param [type] $val: ... * @return [type] ... */ - function ext_setStar($val) { + function ext_setStar($val) { - $fParts = explode('.',strrev($val),2); + $fParts = explode('.', strrev($val), 2); - $val=preg_replace('/_[0-9][0-9]$/','',strrev($fParts[1])).'*.'.strrev($fParts[0]); + $val = preg_replace('/_[0-9][0-9]$/', '', strrev($fParts[1])) . '*.' . strrev($fParts[0]); return $val; } @@ -1764,12 +1828,12 @@ * @param [type] $value: ... * @return [type] ... */ - function ext_detectAndFixExtensionPrefix($value) { + function ext_detectAndFixExtensionPrefix($value) { - if (substr($value,0,4)=='EXT:') { + if (substr($value, 0, 4) == 'EXT:') { - $parts = explode('/',substr($value,4),2); + $parts = explode('/', substr($value, 4), 2); $extPath = t3lib_extMgm::siteRelPath($parts[0]); - $value = $extPath.$parts[1]; + $value = $extPath . $parts[1]; return $value; } else { return $value; @@ -1778,7 +1842,7 @@ } -if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_tsparser_ext.php']) { +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']); }