Commit ca941415 authored by Bernhard Kraft's avatar Bernhard Kraft
Browse files

Fixed bug #1685 partly: replaced ereg calls with preg pendants in...

Fixed bug #1685 partly: replaced ereg calls with preg pendants in t3lib_parsehtml.php and made some minor modifications to improve overall speed (report bugs with inproperly replaced markers or subparts with previously working setup or TV problems with HTML templates having no problems before at http://bugs.typo3.org/view.php?id=1685)


git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@954 709f56b5-9817-0410-a4d7-c38de5d9e867
parent 7f91d790
2005-12-27 Bernhard Kraft <kraftb@kraftb.at>
* Fixed bug #1685 partly: replaced ereg calls with preg pendants in t3lib_parsehtml.php and made some minor modifications to improve overall speed (report bugs with inproperly replaced markers or subparts with previously working setup or TV problems with HTML templates having no problems before at http://bugs.typo3.org/view.php?id=1685)
2005-12-27 Dmitry Dulepov <typo3@accio.lv>
* Workspace listing: CSS classes are added to system style sheet file
......
......@@ -43,3 +43,8 @@ Accessibility
* output of CSS styled content is now accessible by default
* (mailforms, menus, sitemaps)
Speed
=====
* HTML Parsing class got a speed improvement (faster preg instead of ereg, report bugs with inproperly replaced markers or subparts with previously working setup or TV problems with HTML templates having no problems before at http://bugs.typo3.org/view.php?id=1685)
This diff is collapsed.
......@@ -2848,6 +2848,7 @@ class tslib_cObj {
* Returns a subpart from the input content stream.
* A subpart is a part of the input stream which is encapsulated in a string matching the input string, $marker. If this string is found inside of HTML comment tags the start/end points of the content block returned will be that right outside that comment block.
* Example: The contennt string is "Hello <!--###sub1### begin--> World. How are <!--###sub1### end--> you?" If $marker is "###sub1###" then the content returned is " World. How are ". The input content string could just as well have been "Hello ###sub1### World. How are ###sub1### you?" and the result would be the same
* Wrapper for t3lib_parsehtml::getSubpart which behaves identical
*
* @param string The content stream, typically HTML template content.
* @param string The marker string, typically on the form "###[the marker string]###"
......@@ -2855,26 +2856,13 @@ class tslib_cObj {
* @see substituteSubpart(), t3lib_parsehtml::getSubpart()
*/
function getSubpart($content, $marker) {
if ($marker && strstr($content,$marker)) {
$start = strpos($content, $marker)+strlen($marker);
$stop = @strpos($content, $marker, $start+1);
$sub = substr($content, $start, $stop-$start);
$reg=Array();
ereg('^[^<]*-->',$sub,$reg);
$start+=strlen($reg[0]);
$reg=Array();
ereg('<!--[^>]*$',$sub,$reg);
$stop-=strlen($reg[0]);
return substr($content, $start, $stop-$start);
}
return t3lib_parsehtml::getSubpart($content, $marker);
}
/**
* Substitute subpart in input template stream.
* This function substitutes a subpart in $content with the content of $subpartContent.
* Wrapper for t3lib_parsehtml::substituteSubpart which behaves identical
*
* @param string The content stream, typically HTML template content.
* @param string The marker string, typically on the form "###[the marker string]###"
......@@ -2884,36 +2872,7 @@ class tslib_cObj {
* @see getSubpart(), t3lib_parsehtml::substituteSubpart()
*/
function substituteSubpart($content,$marker,$subpartContent,$recursive=1) {
$start = strpos($content, $marker);
$stop = @strpos($content, $marker, $start+1)+strlen($marker);
if ($start && $stop>$start) {
// code before
$before = substr($content, 0, $start);
$reg=Array();
ereg('<!--[^>]*$',$before,$reg);
$start-=strlen($reg[0]);
$before = substr($content, 0, $start);
// code after
$after = substr($content, $stop);
$reg=Array();
ereg('^[^<]*-->',$after,$reg);
$stop+=strlen($reg[0]);
$after = substr($content, $stop);
// replace?
if (is_array($subpartContent)) {
$substContent=$subpartContent[0].$this->getSubpart($content,$marker).$subpartContent[1];
} else {
$substContent=$subpartContent;
}
if ($recursive && strpos($after, $marker)) {
return $before.$substContent.$this->substituteSubpart($after,$marker,$subpartContent);
} else {
return $before.$substContent.$after;
}
} else {
return $content;
}
return t3lib_parsehtml::substituteSubpart($content, $marker, $subpartContent, $recursive);
}
/**
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment