| 
 | 
  Petar - 2007-10-21 06:11:47  
Hi 
 
 
Please try:  
 
$text = 'S XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'; 
$text = QuoteText($text) - all defaults ($line_break="\n"; $line_length=75; $line_prefix="> ";) 
 
At first: 
$wrapped="" - OK 
if(strlen($text_line=$lines[$line])) - Yes 
for(;strlen($text_line=$line_prefix.$text_line)>$line_length;) - the line with a bug.  
if(GetType($cut=strrpos(substr($text_line,0,$line_length)," "))!="integer") - Yes. 
... 
$wrapped.=substr($text_line,0,$cut).$line_break; 
$cut++; 
... 
$text_line=substr($text_line,$cut); 
 
and may be at that point start endless cicle, because now $text_line is 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', and what about for???? -->> $text_line will be '> XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' since the default $line_prefix is "> " 
 
Please fix it asap. Thanks 
 
 
 
 
 
 
  
  Petar - 2007-10-21 06:50:48 -  In reply to message 1 from Petar 
The fix: 
 
1. Replace  
 
if(GetType($cut=strrpos(substr($text_line,0,$line_length)," "))!="integer") 
 
With  
 
if(GetType($cut=strrpos(substr($text_line,strlen($line_prefix),$line_length)," "))!="integer") 
 
and  
 
Add 
 
$cut .= strlen($line_prefix); 
 
just before  
 
$wrapped.=substr($text_line,0,$cut).$line_break; 
 
New function should be: 
 
	Function WrapText($text,$line_length=0,$line_break="",$line_prefix="") 
	{ 
		if(strlen($line_break)==0) 
			$line_break=$this->line_break; 
		if($line_length==0) 
			$line_length=$this->line_length; 
		$lines=explode("\n",str_replace("\r","\n",str_replace("\r\n","\n",$text))); 
		for($wrapped="",$line=0;$line<count($lines);$line++) 
		{ 
			if(strlen($text_line=$lines[$line])) 
			{ 
				for(;strlen($text_line=$line_prefix.$text_line)>$line_length;) 
				{ 
//					if(GetType($cut=strrpos(substr($text_line,0,$line_length)," "))!="integer")	 
					if(GetType($cut=strrpos(substr($text_line,strlen($line_prefix),$line_length)," "))!="integer")	//	FIX  
					{ 
						if($this->break_long_lines) 
						{ 
							$wrapped.=substr($text_line,0,$line_length).$line_break; 
							$cut=$line_length; 
						} 
						elseif(GetType($cut=strpos($text_line," ",$line_length))=="integer") 
						{ 
							$wrapped.=substr($text_line, 0, $cut).$line_break; 
							$cut++; 
						} 
						else 
						{ 
							$wrapped.=$text_line.$line_break; 
							$cut=strlen($text_line); 
						} 
					} 
					else 
					{ 
						$cut .= strlen($line_prefix);    //	FIX  
						$wrapped.=substr($text_line,0,$cut).$line_break; 
						$cut++; 
					} 
					$text_line=substr($text_line,$cut); 
				} 
			} 
			$wrapped.=$text_line.$line_break; 
		} 
		return($wrapped); 
	} 
 
  
  Manuel Lemos - 2007-10-22 00:42:52 -  In reply to message 1 from Petar 
Yes, the class was confusing quote text spaces with spaces where to break long lines. 
 
The bug was fixed and the new version was uploaded. Thank you for reporting. 
  
   |