typo3core_bugfix_5896_typo3_4-4.patch

Administrator Admin, 2010-12-06 04:59

Download (7.66 KB)

View differences:

t3lib/class.t3lib_parsehtml_proc.php (copie de travail)
102 102
class t3lib_parsehtml_proc extends t3lib_parsehtml {
103 103

  
104 104
		// Static:
105
	var $blockElementList = 'PRE,UL,OL,H1,H2,H3,H4,H5,H6,HR,ADDRESS,DL,DD';	// List of tags for these elements
105
	var $blockElementList = 'PRE,UL,OL,H1,H2,H3,H4,H5,H6,ADDRESS,DL,DD'; // List of tags for these elements
106 106

  
107 107
		// Internal, static:
108 108
	var $recPid = 0;				// Set this to the pid of the record manipulated by the class.
......
914 914
						}
915 915
					break;
916 916
					default:
917
							// Eliminate true linebreaks inside other headlist tags and after hr tag
917
							// Eliminate true linebreaks inside other headlist tags
918 918
						$blockSplit[$k]=preg_replace('/['.preg_quote(LF.CR).']+/',' ',$this->transformStyledATags($blockSplit[$k])).$lastBR;
919 919
					break;
920 920
				}
921 921
			} else {	// NON-block:
922 922
				if (strcmp(trim($blockSplit[$k]),''))	{
923
					$blockSplit[$k]=$this->divideIntoLines(preg_replace('/['.preg_quote(LF.CR).']+/',' ',$blockSplit[$k])).$lastBR;
923
						// Remove linebreaks following hr tags
924
					$blockSplit[$k] = preg_replace('/<(hr)(\s[^>\/]*)?[[:space:]]*\/?>[' . preg_quote(LF . CR) . ']+/', '<$1$2 />', $blockSplit[$k]);
925
						// Replace other linebreaks with space
926
					$blockSplit[$k] = preg_replace('/[' . preg_quote(LF . CR) . ']+/', ' ', $blockSplit[$k]);
927
					$blockSplit[$k] = $this->divideIntoLines($blockSplit[$k]) . $lastBR;
924 928
					$blockSplit[$k]=$this->transformStyledATags($blockSplit[$k]);
925 929
				} else unset($blockSplit[$k]);
926 930
			}
......
1228 1232
		if ($this->procOptions['internalizeFontTags'])	{$value = $this->internalizeFontTags($value);}
1229 1233

  
1230 1234
			// Setting configuration for processing:
1231
		$allowTagsOutside = t3lib_div::trimExplode(',',strtolower($this->procOptions['allowTagsOutside']?$this->procOptions['allowTagsOutside']:'img'),1);
1235
		$allowTagsOutside = t3lib_div::trimExplode(',', strtolower($this->procOptions['allowTagsOutside'] ? 'hr,' . $this->procOptions['allowTagsOutside'] : 'hr,img'), 1);
1232 1236
		$remapParagraphTag = strtoupper($this->procOptions['remapParagraphTag']);
1233 1237
		$divSplit = $this->splitIntoBlock('div,p',$value,1);	// Setting the third param to 1 will eliminate false end-tags. Maybe this is a good thing to do...?
1234 1238

  
......
1240 1244

  
1241 1245
			// Returns plainly the value if there was no div/p sections in it
1242 1246
		if (count($divSplit)<=1 || $count<=0)	{
1243
			return $value;
1247
				// Wrap hr tags with LF's
1248
			$newValue = preg_replace('/<(hr)(\s[^>\/]*)?[[:space:]]*\/?>/i', LF . '<$1$2 />' . LF, $value);
1249
			$newValue = preg_replace('/' . preg_quote(LF . LF) . '/i', LF, $newValue);
1250
			$newValue = preg_replace('/(^' . preg_quote(LF) . ')|(' . preg_quote(LF) . '$)/i', '', $newValue);
1251
			return $newValue;
1244 1252
		}
1245 1253

  
1246 1254
			// Traverse the splitted sections:
......
1323 1331
			} else {	// outside div:
1324 1332
					// Remove positions which are outside div/p tags and without content
1325 1333
				$divSplit[$k]=trim(strip_tags($divSplit[$k],'<'.implode('><',$allowTagsOutside).'>'));
1334
					// Wrap hr tags with LF's
1335
				$divSplit[$k] = preg_replace('/<(hr)(\s[^>\/]*)?[[:space:]]*\/?>/i', LF . '<$1$2 />' . LF, $divSplit[$k]);
1336
				$divSplit[$k] = preg_replace('/' . preg_quote(LF . LF) . '/i', LF, $divSplit[$k]);
1337
				$divSplit[$k] = preg_replace('/(^' . preg_quote(LF) . ')|(' . preg_quote(LF) . '$)/i', '', $divSplit[$k]);
1326 1338
				if (!strcmp($divSplit[$k],''))	unset($divSplit[$k]);	// Remove part if it's empty
1327 1339
			}
1328 1340
		}
......
1359 1371
				$parts[$k]=$this->HTMLcleaner($parts[$k],$keepTags,$kUknown,$hSC);
1360 1372
				if ($convNBSP)	$parts[$k]=str_replace('&amp;nbsp;','&nbsp;',$parts[$k]);
1361 1373
			}
1362

  
1363
				// Wrapping the line in <$dT> is not already wrapped:
1364
			$testStr = strtolower(trim($parts[$k]));
1365
			if (substr($testStr,0,4)!='<div' || substr($testStr,-6)!='</div>')	{
1366
				if (substr($testStr,0,2)!='<p' || substr($testStr,-4)!='</p>')	{
1374
				// Wrapping the line in <$dT> if not already wrapped and does not contain an hr tag
1375
			if (!preg_match('/<(hr)(\s[^>\/]*)?[[:space:]]*\/?>/i', $parts[$k])) {
1376
				$testStr = strtolower(trim($parts[$k]));
1377
				if (substr($testStr, 0, 4) != '<div' || substr($testStr, -6) != '</div>') {
1378
					if (substr($testStr, 0, 2) != '<p' || substr($testStr, -4) != '</p>') {
1367 1379
						// Only set p-tags if there is not already div or p tags:
1368
					$parts[$k]='<'.$dT.'>'.$parts[$k].'</'.$dT.'>';
1369
				}
1370
			}
1380
						$parts[$k] = '<' . $dT . '>' . $parts[$k] . '</' . $dT . '>';
1381
					}
1382
 				}
1383
 			}
1371 1384
		}
1372 1385

  
1373 1386
			// Implode result:
typo3/sysext/cms/tslib/class.tslib_content.php (copie de travail)
5089 5089
 						$contentAccumP++;
5090 5090
 						$treated=1;
5091 5091
							// in-out-tag: img and other empty tags
5092
						if ($tag[0]=='img' || substr($tag[1],-3,2)==' /')	{
5092
						if (preg_match('/^(area|base|br|col|hr|img|input|meta|param)$/i', $tag[0])) {
5093 5093
							$tag['out']=1;
5094 5094
						}
5095 5095
 					}
......
5183 5183

  
5184 5184
		foreach ($lParts as $k => $l) {
5185 5185
			$sameBeginEnd=0;
5186
			$emptyTag = 0;
5186 5187
			$l=trim($l);
5187 5188
			$attrib=array();
5188 5189
			$nWrapped=0;
5189
			$byPass=0;
5190 5190
			if (substr($l,0,1)=='<' && substr($l,-1)=='>')	{
5191 5191
				$fwParts = explode('>',substr($l,1),2);
5192
				$backParts = t3lib_div::revExplode('<', substr($fwParts[1],0,-1), 2);
5193
				$attrib = t3lib_div::get_tag_attributes('<'.$fwParts[0].'>');
5194
				list($tagName) = explode(' ',$fwParts[0]);
5195
				$str_content = $backParts[0];
5196
				$sameBeginEnd = (substr(strtolower($backParts[1]),1,strlen($tagName))==strtolower($tagName));
5192
				list($tagName, $tagParams) = explode(' ',$fwParts[0], 2);
5193
				if (!$fwParts[1]) {
5194
					if (substr($tagName, -1) == '/') {
5195
						$tagName = substr($tagName, 0, -1);
5196
					}
5197
					if (substr($fwParts[0], -1) == '/') {
5198
						$sameBeginEnd = 1;
5199
						$emptyTag = 1;
5200
						$attrib = t3lib_div::get_tag_attributes('<'.substr($fwParts[0], 0, -1).'>');
5201
					}
5202
				} else {
5203
					$backParts = t3lib_div::revExplode('<', substr($fwParts[1],0,-1), 2);
5204
					$attrib = t3lib_div::get_tag_attributes('<'.$fwParts[0].'>');
5205
					$str_content = $backParts[0];
5206
					$sameBeginEnd = (substr(strtolower($backParts[1]),1,strlen($tagName))==strtolower($tagName));
5207
				}
5197 5208
			}
5198 5209

  
5199 5210
			if ($sameBeginEnd && in_array(strtolower($tagName),$encapTags))	{
......
5230 5241
				if (!$attrib['align'] && $defaultAlign)	$attrib['align']=$defaultAlign;
5231 5242

  
5232 5243
				$params = t3lib_div::implodeAttributes($attrib,1);
5233
				if ($conf['removeWrapping'])	{
5244
				if ($conf['removeWrapping'] && !($emptyTag && $conf['removeWrapping.']['keepSingleTag'])) {
5234 5245
					$str_content=$str_content;
5235 5246
				} else {
5236
					$str_content='<'.strtolower($uTagName).(trim($params)?' '.trim($params):'').'>'.$str_content.'</'.strtolower($uTagName).'>';
5247
					if ($emptyTag) {
5248
						$str_content='<'.strtolower($uTagName).(trim($params)?' '.trim($params):'').' />';
5249
					} else {
5250
						$str_content='<'.strtolower($uTagName).(trim($params)?' '.trim($params):'').'>'.$str_content.'</'.strtolower($uTagName).'>';
5251
					}
5237 5252
				}
5238 5253
			}
5239 5254

  
typo3/sysext/css_styled_content/static/setup.txt (copie de travail)
123 123
		div.callRecursive = 1 
124 124
	}
125 125
	nonTypoTagStdWrap.encapsLines {
126
		encapsTagList = p,pre,h1,h2,h3,h4,h5,h6
126
		encapsTagList = p,pre,h1,h2,h3,h4,h5,h6,hr
127 127
		remapTag.DIV = P
128 128
		nonWrappedTag = P
129 129
		innerStdWrap_all.ifBlank = &nbsp;