[pLog-svn] r784 - plog/trunk/class/data
oscar at devel.plogworld.net
oscar at devel.plogworld.net
Fri Jan 21 17:25:23 GMT 2005
Author: oscar
Date: 2005-01-21 17:25:22 +0000 (Fri, 21 Jan 2005)
New Revision: 784
Modified:
plog/trunk/class/data/textfilter.class.php
Log:
converted Textfilter::filterJavascript and Textfilter::filterAllHTML to static methods
Modified: plog/trunk/class/data/textfilter.class.php
===================================================================
--- plog/trunk/class/data/textfilter.class.php 2005-01-21 10:17:24 UTC (rev 783)
+++ plog/trunk/class/data/textfilter.class.php 2005-01-21 17:25:22 UTC (rev 784)
@@ -44,6 +44,7 @@
*
* @param text The text we want to filter
* @return Returns the filtered text
+ * @static
*/
function filterJavaScript( $text )
{
@@ -89,12 +90,13 @@
*
* @param string The string we would like to filter
* @return The filtered text.
+ * @static
*/
function filterAllHTML( $string )
{
$tmp = strip_tags( $string );
// y luego eliminamos el javascript
- $filteredString = $this->filterJavaScript( $tmp );
+ $filteredString = Textfilter::filterJavaScript( $tmp );
return $filteredString;
}
@@ -133,77 +135,7 @@
return $string;
}
-
- /**
- * Very dirty function that cuts the text after as many words
- * as $maxWords, <b>respecting</b> HTML and XML tags. Tags that are not
- * cut are <a>, <b>, <i>
- *
- * @param text Text we would like to cut
- * @param maxWords This function counts based on words and <b>not</b> on bytes!!
- * @return A string of $maxWords words long, but respecting some html tags.
- */
- function CutText( $text, $maxWords )
- {
- $parts = split( ' ', $text );
-
- //$not_split_tags = Array( "a", "b", "i" );
- $not_split_tags = Array();
-
- $inside = false;
- $i = 0;
- $total = 0;
- $total2 = 0;
- $result = "";
-
- while( ($i < count($parts)) && ($total < $maxWords)) {
-
- $part = $parts[$i];
- //print(htmlentities($part)."-");
- $last = substr( $part, -4 );
-
- //print("part: ".htmlentities($part)." - last: ".$last."<br/>");
-
- foreach( $not_split_tags as $tag ) {
- if($part == ("<".$tag)) {
- $inside=true;
- $total2=0;
- print("inside!!");
- }
- }
-
- foreach( $not_split_tags as $tag ) {
- $start = substr($part, 0,3 );
- if ($start == ("<".$tag.">")) {
- print("inside 2!!");
- $inside=true;
- }
- }
-
- foreach( $not_split_tags as $tag ) {
- if( $last == ("</".$tag.">" )) {
- $inside=false;
- print("outside! - part:".$part);
- $total += $total2;
- //$total--;
- }
- }
-
- if( !$inside)
- $total++;
- else
- $total2++;
-
- $result .= $part." ";
-
- $i++;
- }
-
- $result = rtrim($result);
- //print("result=".$result);
- return $result;
- }
-
+
/**
* Translates all the >a href="..."< tags of a text to include the
* target="blank_" parameter so that they will open in a new window
More information about the pLog-svn
mailing list