[ Index ]
 

Code source de Symfony 1.0.0

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/lib/validator/ -> sfHtmlValidator.class.php (source)

   1  <?php
   2  
   3  /*
   4   * This file is part of the symfony package.
   5   * (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
   6   * (c) 2004-2006 Sean Kerr.
   7   * 
   8   * For the full copyright and license information, please view the LICENSE
   9   * file that was distributed with this source code.
  10   */
  11  
  12  /**
  13   *
  14   * @package    symfony
  15   * @subpackage validator
  16   * @author     Fabien Potencier <fabien.potencier@symfony-project.com>
  17   * @author     Sean Kerr <skerr@mojavi.org>
  18   * @version    SVN: $Id: sfHtmlValidator.class.php 3233 2007-01-11 21:01:08Z fabien $
  19   */
  20  class sfHtmlValidator extends sfValidator
  21  {
  22    /**
  23     * Executes this validator.
  24     *
  25     * @param mixed A file or parameter value/array
  26     * @param error An error message reference
  27     *
  28     * @return bool true, if this validator executes successfully, otherwise false
  29     */
  30    public function execute(&$value, &$error)
  31    {
  32      if (trim(strip_tags($value)) == '')
  33      {
  34        // If page contains an object or an image, it's ok
  35        if (preg_match('/<img/i', $value) || preg_match('/<object/i', $value))
  36          return true;
  37        else
  38        {
  39          $error = $this->getParameterHolder()->get('html_error');
  40          return false;
  41        }
  42      }
  43  
  44      return true;
  45    }
  46  
  47    /**
  48     * Initializes this validator.
  49     *
  50     * @param sfContext The current application context
  51     * @param array   An associative array of initialization parameters
  52     *
  53     * @return bool true, if initialization completes successfully, otherwise false
  54     */
  55    public function initialize($context, $parameters = null)
  56    {
  57      // initialize parent
  58      parent::initialize($context);
  59  
  60      // set defaults
  61      $this->getParameterHolder()->set('html_error', 'Invalid input');
  62  
  63      $this->getParameterHolder()->add($parameters);
  64  
  65      return true;
  66    }
  67  }


Généré le : Fri Mar 16 22:42:14 2007 par Balluche grâce à PHPXref 0.7