[pLog-svn] r6470 - in plog/branches/lifetype-1.2/class/data/validator: . rules
Jon Daley
plogworld at jon.limedaley.com
Sat May 24 15:19:53 EDT 2008
Mark, is this what you meant?
On Sat, 24 May 2008, jondaley at devel.lifetype.net wrote:
> 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
>
> _______________________________________________
> pLog-svn mailing list
> pLog-svn at devel.lifetype.net
> http://limedaley.com/mailman/listinfo/plog-svn
>
--
Jon Daley
http://jon.limedaley.com/
Whether you believe you can, or whether you
believe you can't, you're absolutely right.
-- Henry Ford
More information about the pLog-svn
mailing list