Bug #18309 ยป 0007669.patch

Administrator Admin, 2008-02-26 14:31

View differences:

t3lib/class.t3lib_tstemplate.php (Arbeitskopie)
227 227
			// Sets the paths from where TypoScript resources are allowed to be used:
228 228
		$this->allowedPaths = Array ('media/','fileadmin/','uploads/','typo3temp/','t3lib/fonts/',TYPO3_mainDir.'ext/',TYPO3_mainDir.'sysext/','typo3conf/ext/');
229 229
		if ($GLOBALS['TYPO3_CONF_VARS']['FE']['addAllowedPaths'])	{
230
			$pathArr = t3lib_div::trimExplode(',',$GLOBALS['TYPO3_CONF_VARS']['FE']['addAllowedPaths'],1);
231
			while(list(,$p)=each($pathArr))	{
230
			$pathArr = t3lib_div::trimExplode(',', $GLOBALS['TYPO3_CONF_VARS']['FE']['addAllowedPaths'], true);
231
			foreach ($pathArr as $p) {
232 232
					// Once checked for path, but as this may run from typo3/mod/web/ts/ dir, that'll not work!! So the paths ar uncritically included here.
233 233
				$this->allowedPaths[] = $p;
234 234
			}
......
266 266
	 */
267 267
	function matching($cc)	{
268 268
		if (is_array($cc['all']))	{
269
			reset($cc['all']);
270 269
			$matchObj = t3lib_div::makeInstance('t3lib_matchCondition');
271 270
			$matchObj->altRootLine=$cc['rootLine'];
272
			while(list($key,$pre)=each($cc['all']))	{
271
			foreach ($cc['all'] as $key => $pre) {
273 272
				if ($matchObj->match($pre))	{
274 273
					$sectionsMatch[$key]=$pre;
275 274
				}
......
524 523
					$GLOBALS['TYPO3_DB']->sql_free_result($res);
525 524
				}
526 525
			} else {	// NORMAL OPERATION:
527
				$basedOnArr = t3lib_div::intExplode(',',$row['basedOn']);
528
				while(list(,$id)=each($basedOnArr))	{	// traversing list
526
				$basedOnArr = t3lib_div::intExplode(',', $row['basedOn']);
527
				foreach ($basedOnArr as $id) { // traversing list
529 528
					if (!t3lib_div::inList($idList,'sys_'.$id))	{	// if $id is not allready included ...
530 529
						$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_template', 'uid='.intval($id).' '.$this->whereClause);
531 530
						if ($subrow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))	{	// there was a template, then we fetch that
......
602 601
	function includeStaticTypoScriptSources($idList,$templateID,$pid,$row)	{
603 602
			// Static Template Records (static_template): include_static is a list of static templates to include
604 603
		if (trim($row['include_static']))	{
605
			$include_staticArr = t3lib_div::intExplode(',',$row['include_static']);
606
			reset($include_staticArr);
607
			while(list(,$id)=each($include_staticArr))	{	// traversing list
604
			$include_staticArr = t3lib_div::intExplode(',', $row['include_static']);
605
			foreach ($include_staticArr as $id) { // traversing list
608 606
				if (!t3lib_div::inList($idList,'static_'.$id))	{	// if $id is not allready included ...
609 607
					$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'static_template', 'uid='.intval($id));
610 608
					if ($subrow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))	{	// there was a template, then we fetch that
......
618 616

  
619 617
			// Static Template Files (Text files from extensions): include_static_file is a list of static files to include (from extensions)
620 618
		if (trim($row['include_static_file']))	{
621
			$include_static_fileArr = t3lib_div::trimExplode(',',$row['include_static_file'],1);
622
			reset($include_static_fileArr);
623
			while(list(,$ISF_file)=each($include_static_fileArr))	{	// traversing list
624
				$ISF_file = trim($ISF_file);
619
			$include_static_fileArr = t3lib_div::trimExplode(',', $row['include_static_file'], true);
620
			foreach ($include_static_fileArr as $ISF_file) { // traversing list
625 621
				if (substr($ISF_file,0,4)=='EXT:')	{
626 622
					list($ISF_extKey,$ISF_localPath) = explode('/',substr($ISF_file,4),2);
627 623
					if (strcmp($ISF_extKey,'') && t3lib_extMgm::isLoaded($ISF_extKey) && strcmp($ISF_localPath,''))	{
......
665 661
		global $TYPO3_LOADED_EXT;
666 662

  
667 663
		if ($row['static_file_mode']==1 || ($row['static_file_mode']==0 && substr($templateID,0,4)=='sys_' && $row['root']))	{
668
			reset($TYPO3_LOADED_EXT);
669
			while(list($extKey,$files)=each($TYPO3_LOADED_EXT))	{
664
			foreach ($TYPO3_LOADED_EXT as $extKey => $files) {
670 665
				if (is_array($files) && ($files['ext_typoscript_constants.txt'] || $files['ext_typoscript_setup.txt'] || $files['ext_typoscript_editorcfg.txt']))	{
671 666
					$mExtKey = str_replace('_','',$extKey);
672 667
					$subrow=array(
......
813 808

  
814 809
			// Searching for possible unsubstituted constants left (only for information)
815 810
		if (strstr($all,'{$'))	{
816
			$findConst = explode('{$',$all);
817
			$theConstList=Array();
818
			next($findConst);
819
			while(list(,$constVal)=each($findConst))	{
811
			$theConstList = array();
812
			$findConst = explode('{$', $all);
813
			array_shift($findConst);
814
			foreach ($findConst as $constVal) {
820 815
				$constLen=t3lib_div::intInRange(strcspn($constVal,'}'),0,50);
821 816
				$theConstList[]='{$'.substr($constVal,0,$constLen+1);
822 817
			}
......
883 878
		unset($this->setup['types.']);
884 879
		unset($this->setup['types']);
885 880
		if (is_array($this->setup)) {
886
			reset ($this->setup);
887
			while(list($theKey,)=each($this->setup))	{
888
				if ($this->setup[$theKey]=='PAGE')	{
889
					$tN = $this->setup[$theKey.'.']['typeNum'];
890
					if (isset($tN))	{
891
						$this->setup['types.'][$tN] = $theKey;
892
					} elseif(!$this->setup['types.'][0])	{	// If there is no type 0 yet and typeNum was not set, we use the current object as the default
893
						$this->setup['types.'][0] = $theKey;
881
			foreach ($this->setup as $key => $value) {
882
				if ($value=='PAGE')	{
883
						// Set the typeNum of the current page object:
884
					if (isset($this->setup[$key.'.']['typeNum'])) {
885
						$typeNum = $this->setup[$key.'.']['typeNum'];
886
						$this->setup['types.'][$typeNum] = $key;
887
						// If there is no type 0 yet and typeNum was not set, we use the current object as the default
888
					} elseif(!isset($this->setup['types.'][0]) || !$this->setup['types.'][0]) {
889
						$this->setup['types.'][0] = $key;
894 890
					}
895 891
				}
896 892
			}
......
911 907
	 * @return	void
912 908
	 * @see t3lib_TSparser, generateConfig()
913 909
	 */
914
	function procesIncludes()	{
915
		reset($this->constants);
916
		while(list($k)=each($this->constants))	{
917
			$this->constants[$k]=t3lib_TSparser::checkIncludeLines($this->constants[$k]);
910
	function procesIncludes() {
911
		foreach ($this->constants as &$value) {
912
			$value = t3lib_TSparser::checkIncludeLines($value);
918 913
		}
919 914

  
920
		reset($this->config);
921
		while(list($k)=each($this->config))	{
922
			$this->config[$k]=t3lib_TSparser::checkIncludeLines($this->config[$k]);
915
		foreach ($this->config as &$value) {
916
			$value = t3lib_TSparser::checkIncludeLines($value);
923 917
		}
924 918

  
925
		reset($this->editorcfg);
926
		while(list($k)=each($this->editorcfg))	{
927
			$this->editorcfg[$k]=t3lib_TSparser::checkIncludeLines($this->editorcfg[$k]);
919
		foreach ($this->editorcfg as &$value) {
920
			$value = t3lib_TSparser::checkIncludeLines($value);
928 921
		}
929 922
	}
930 923

  
......
966 959
	 */
967 960
	function flattenSetup($setupArray, $prefix, $resourceFlag)	{
968 961
		if (is_array($setupArray))	{
969
			reset($setupArray);
970
			while(list($key,$val)=each($setupArray))	{
962
			foreach ($setupArray as $key => $val) {
971 963
				if ($prefix || substr($key,0,16)!='TSConstantEditor')	{		// We don't want 'TSConstantEditor' in the flattend setup on the first level (190201)
972 964
					if (is_array($val))	{
973 965
						$this->flattenSetup($val,$prefix.$key, ($key=='file.'));
......
1152 1144
			if (@is_file($this->getFileName_backPath.$file))	{
1153 1145
				$outFile = $file;
1154 1146
				$fileInfo = t3lib_div::split_fileref($outFile);
1155
				reset($this->allowedPaths);
1156 1147
				$OK=0;
1157
				while(list(,$val)=each($this->allowedPaths))	{
1158
					if (substr($fileInfo['path'],0,strlen($val))==$val){$OK=1; break;}
1148
				foreach ($this->allowedPaths as $val) {
1149
					if (substr($fileInfo['path'], 0, strlen($val))==$val) {
1150
						$OK=1;
1151
						break;
1152
					}
1159 1153
				}
1160 1154
				if ($OK)	{
1161 1155
					$this->fileCache[$hash]=$outFile;
......
1188 1182
		} elseif (strstr($file,'*')) {
1189 1183
			$fileparts=explode('*',$file);
1190 1184
			$c=count($fileparts);
1191
			$files = explode(',',$res);
1192
			while(list(,$val)=each($files))	{
1193
				$test = trim($val);
1194
				if (ereg('^'.quotemeta($fileparts[0]).'.*'.quotemeta($fileparts[$c-1]).'$', $test))	{
1195
					$outFile = $test;
1185
			$files = t3lib_div::trimExplode(',', $res);
1186
			foreach ($files as $file) {
1187
				if (ereg('^'.quotemeta($fileparts[0]).'.*'.quotemeta($fileparts[$c-1]).'$', $file)) {
1188
					$outFile = $file;
1196 1189
					break;
1197 1190
				}
1198 1191
			}
......
1201 1194
	}
1202 1195

  
1203 1196
	/**
1204
	 * CheckFile runs through the $menuArr and checks every file-reference in $name
1205
	 * (Not used anywhere)
1206
	 *
1207
	 * @param	string		Property name in the menu array
1208
	 * @param	array		Menu array to traverse
1209
	 * @return	array		Modified menu array
1210
	 * @deprecated
1211
	 * @internal
1212
	 */
1213
	function checkFile($name,$menuArr)	{
1214
		reset ($menuArr);
1215
		while (list($aKey,)=each($menuArr))	{
1216
			$menuArr[$aKey][$name] = $this->getFileName($menuArr[$aKey][$name]);
1217
		}
1218
		return $menuArr;
1219
	}
1220

  
1221
	/**
1222 1197
	 * Compiles the content for the page <title> tag.
1223 1198
	 *
1224 1199
	 * @param	string		The input title string, typically the "title" field of a page's record.
......
1296 1271
	 * @return	array		An array with all integer properties listed in numeric order.
1297 1272
	 * @see tslib_cObj::cObjGet(), tslib_gifBuilder, tslib_imgmenu::makeImageMap()
1298 1273
	 */
1299
	function sortedKeyList($setupArr, $acceptOnlyProperties=FALSE)	{
1300
		$keyArr = Array();
1301

  
1302
		reset($setupArr);
1303
		while(list($key,)=each($setupArr))	{
1304
			$ikey = intval($key);
1305
			if (!strcmp($ikey,$key) || $acceptOnlyProperties)	{
1306
				$keyArr[] = $ikey;
1274
	function sortedKeyList($setupArr, $acceptOnlyProperties=false) {
1275
		$keyArr = array();
1276
		$setupArrKeys = array_keys($setupArr);
1277
		foreach ($setupArrKeys as $key) {
1278
			if ($acceptOnlyProperties || t3lib_div::testInt($key)) {
1279
				$keyArr[] = $key;
1307 1280
			}
1308 1281
		}
1309

  
1310 1282
		$keyArr = array_unique($keyArr);
1311 1283
		sort($keyArr);
1312 1284
		return $keyArr;
    (1-1/1)