typo3core_bugfix_5896_trunk.patch

Administrator Admin, 2010-12-06 04:14

Download (7.57 KB)

View differences:

t3lib/class.t3lib_parsehtml_proc.php (copie de travail)
91 91
class t3lib_parsehtml_proc extends t3lib_parsehtml {
92 92

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

  
96 96
		// Internal, static:
97 97
	var $recPid = 0; // Set this to the pid of the record manipulated by the class.
......
898 898
						}
899 899
					break;
900 900
					default:
901
							// Eliminate true linebreaks inside other headlist tags and after hr tag
901
							// Eliminate true linebreaks inside other headlist tags
902 902
						$blockSplit[$k] = preg_replace('/[' . preg_quote(LF . CR) . ']+/', ' ', $this->transformStyledATags($blockSplit[$k])) . $lastBR;
903 903
					break;
904 904
				}
905 905
			} else { // NON-block:
906 906
				if (strcmp(trim($blockSplit[$k]), '')) {
907
					$blockSplit[$k] = $this->divideIntoLines(preg_replace('/[' . preg_quote(LF . CR) . ']+/', ' ', $blockSplit[$k])) . $lastBR;
907
						// Remove linebreaks following hr tags
908
					$blockSplit[$k] = preg_replace('/<(hr)(\s[^>\/]*)?[[:space:]]*\/?>[' . preg_quote(LF . CR) . ']+/', '<$1$2 />', $blockSplit[$k]);
909
						// Replace other linebreaks with space
910
					$blockSplit[$k] = preg_replace('/[' . preg_quote(LF . CR) . ']+/', ' ', $blockSplit[$k]);
911
					$blockSplit[$k] = $this->divideIntoLines($blockSplit[$k]) . $lastBR;
908 912
					$blockSplit[$k] = $this->transformStyledATags($blockSplit[$k]);
909 913
				} else {
910 914
					unset($blockSplit[$k]);
......
1222 1226
		}
1223 1227

  
1224 1228
			// Setting configuration for processing:
1225
		$allowTagsOutside = t3lib_div::trimExplode(',', strtolower($this->procOptions['allowTagsOutside'] ? $this->procOptions['allowTagsOutside'] : 'img'), 1);
1229
		$allowTagsOutside = t3lib_div::trimExplode(',', strtolower($this->procOptions['allowTagsOutside'] ? 'hr,' . $this->procOptions['allowTagsOutside'] : 'hr,img'), 1);
1226 1230
		$remapParagraphTag = strtoupper($this->procOptions['remapParagraphTag']);
1227 1231
		$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...?
1228 1232

  
......
1234 1238

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

  
1240 1248
			// 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], '')) {
1327 1339
					unset($divSplit[$k]);
1328 1340
				} // Remove part if it's empty
......
1364 1376
				}
1365 1377
			}
1366 1378

  
1367
				// Wrapping the line in <$dT> is not already wrapped:
1368
			$testStr = strtolower(trim($parts[$k]));
1369
			if (substr($testStr, 0, 4) != '<div' || substr($testStr, -6) != '</div>') {
1370
				if (substr($testStr, 0, 2) != '<p' || substr($testStr, -4) != '</p>') {
1371
					// Only set p-tags if there is not already div or p tags:
1372
					$parts[$k] = '<' . $dT . '>' . $parts[$k] . '</' . $dT . '>';
1379
				// Wrapping the line in <$dT> if not already wrapped and does not contain an hr tag
1380
			if (!preg_match('/<(hr)(\s[^>\/]*)?[[:space:]]*\/?>/i', $parts[$k])) {
1381
				$testStr = strtolower(trim($parts[$k]));
1382
				if (substr($testStr, 0, 4) != '<div' || substr($testStr, -6) != '</div>') {
1383
					if (substr($testStr, 0, 2) != '<p' || substr($testStr, -4) != '</p>') {
1384
						// Only set p-tags if there is not already div or p tags:
1385
						$parts[$k] = '<' . $dT . '>' . $parts[$k] . '</' . $dT . '>';
1386
					}
1373 1387
				}
1374 1388
			}
1375 1389
		}
typo3/sysext/cms/tslib/class.tslib_content.php (copie de travail)
4418 4418
						$contentAccumP++;
4419 4419
						$treated = 1;
4420 4420
							// in-out-tag: img and other empty tags
4421
						if ($tag[0] == 'img' || substr($tag[1], -3, 2) == ' /') {
4421
						if (preg_match('/^(area|base|br|col|hr|img|input|meta|param)$/i', $tag[0])) {
4422 4422
							$tag['out'] = 1;
4423 4423
						}
4424 4424
					}
......
4523 4523

  
4524 4524
		foreach ($lParts as $k => $l) {
4525 4525
			$sameBeginEnd = 0;
4526
			$emptyTag = 0;
4526 4527
			$l = trim($l);
4527 4528
			$attrib = array();
4528 4529
			$nWrapped = 0;
4529
			$byPass = 0;
4530 4530
			if (substr($l, 0, 1) == '<' && substr($l, -1) == '>') {
4531 4531
				$fwParts = explode('>', substr($l, 1), 2);
4532
				$backParts = t3lib_div::revExplode('<', substr($fwParts[1], 0, -1), 2);
4533
				$attrib = t3lib_div::get_tag_attributes('<' . $fwParts[0] . '>');
4534
				list ($tagName) = explode(' ', $fwParts[0]);
4535
				$str_content = $backParts[0];
4536
				$sameBeginEnd = (substr(strtolower($backParts[1]), 1, strlen($tagName)) == strtolower($tagName));
4532
				list($tagName, $tagParams) = explode(' ',$fwParts[0], 2);
4533
				if (!$fwParts[1]) {
4534
					if (substr($tagName, -1) == '/') {
4535
						$tagName = substr($tagName, 0, -1);
4536
					}
4537
					if (substr($fwParts[0], -1) == '/') {
4538
						$sameBeginEnd = 1;
4539
						$emptyTag = 1;
4540
						$attrib = t3lib_div::get_tag_attributes('<'.substr($fwParts[0], 0, -1).'>');
4541
					}
4542
				} else {
4543
					$backParts = t3lib_div::revExplode('<', substr($fwParts[1],0,-1), 2);
4544
					$attrib = t3lib_div::get_tag_attributes('<'.$fwParts[0].'>');
4545
					$str_content = $backParts[0];
4546
					$sameBeginEnd = (substr(strtolower($backParts[1]),1,strlen($tagName))==strtolower($tagName));
4547
				}
4537 4548
			}
4538 4549

  
4539 4550
			if ($sameBeginEnd && in_array(strtolower($tagName), $encapTags)) {
......
4577 4588
					$attrib['align'] = $defaultAlign;
4578 4589

  
4579 4590
				$params = t3lib_div::implodeAttributes($attrib, 1);
4580
				if ($conf['removeWrapping']) {
4591
				if ($conf['removeWrapping'] && !($emptyTag && $conf['removeWrapping.']['keepSingleTag'])) {
4581 4592
					$str_content = $str_content;
4582 4593
				} else {
4583
					$str_content = '<' . strtolower($uTagName) . (trim($params) ? ' ' . trim($params) : '') . '>' .
4584
						$str_content .
4585
						'</' . strtolower($uTagName) . '>';
4594
					if ($emptyTag) {
4595
						$str_content='<'.strtolower($uTagName).(trim($params)?' '.trim($params):'').' />';
4596
					} else {
4597
						$str_content='<'.strtolower($uTagName).(trim($params)?' '.trim($params):'').'>'.$str_content.'</'.strtolower($uTagName).'>';
4598
					}
4586 4599
				}
4587 4600
			}
4588 4601

  
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;