[pLog-svn] r6470 - in plog/branches/lifetype-1.2/class/data/validator: . rules

jondaley at devel.lifetype.net jondaley at devel.lifetype.net
Sat May 24 15:09:51 EDT 2008


Author: jondaley
Date: 2008-05-24 15:09:51 -0400 (Sat, 24 May 2008)
New Revision: 6470

Added:
   plog/branches/lifetype-1.2/class/data/validator/rules/nohtmlrule.class.php
Modified:
   plog/branches/lifetype-1.2/class/data/validator/stringvalidator.class.php
Log:
extend stringvalidator to allow html or not.  Disable by default.  This breaks a couple places where we want to allow html.  More checkins shortly

Added: plog/branches/lifetype-1.2/class/data/validator/rules/nohtmlrule.class.php
===================================================================
--- plog/branches/lifetype-1.2/class/data/validator/rules/nohtmlrule.class.php	                        (rev 0)
+++ plog/branches/lifetype-1.2/class/data/validator/rules/nohtmlrule.class.php	2008-05-24 19:09:51 UTC (rev 6470)
@@ -0,0 +1,25 @@
+<?php
+
+    lt_include( PLOG_CLASS_PATH."class/data/validator/rules/rule.class.php");
+    lt_include( PLOG_CLASS_PATH."class/data/textfilter.class.php");
+
+    /**
+	 * \ingroup Validator_Rules
+	 *
+	 * Checks for HTML in the string
+	 */
+    class NoHtmlRule extends Rule
+    {
+        /**
+		 * Validates that the given string doesn't contain any HTML/javascript
+		 *
+		 * @param value The string to validate
+		 * @return True if there isn't any HTML in the string or false otherwise
+         */
+        function validate($value)
+        {
+            $filtered = Textfilter::filterAllHtml($value);
+            return ($filtered == $value);
+        }
+    }
+?>

Modified: plog/branches/lifetype-1.2/class/data/validator/stringvalidator.class.php
===================================================================
--- plog/branches/lifetype-1.2/class/data/validator/stringvalidator.class.php	2008-05-24 16:38:24 UTC (rev 6469)
+++ plog/branches/lifetype-1.2/class/data/validator/stringvalidator.class.php	2008-05-24 19:09:51 UTC (rev 6470)
@@ -2,6 +2,7 @@
 
 	lt_include( PLOG_CLASS_PATH."class/data/validator/validator.class.php" );
 	lt_include( PLOG_CLASS_PATH."class/data/validator/rules/nonemptyrule.class.php" );
+	lt_include( PLOG_CLASS_PATH."class/data/validator/rules/nohtmlrule.class.php" );
 
     /**
      * \ingroup Validator
@@ -12,11 +13,15 @@
      */
     class StringValidator extends Validator 
     {
-    	function StringValidator()
+    	function StringValidator( $allowHtml = false )
         {
         	$this->Validator();
         	
         	$this->addRule( new NonEmptyRule());
+
+            if(!$allowHtml){
+                $this->addRule( new NoHtmlRule() );
+            }
         }
     }
 ?>
\ No newline at end of file



More information about the pLog-svn mailing list