[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/se3master/var/www/se3/includes/library/HTMLPurifier/AttrDef/CSS/ -> TextDecoration.php (source)

   1  <?php
   2  
   3  /**
   4   * Validates the value for the CSS property text-decoration
   5   * @note This class could be generalized into a version that acts sort of
   6   *       like Enum except you can compound the allowed values.
   7   */
   8  class HTMLPurifier_AttrDef_CSS_TextDecoration extends HTMLPurifier_AttrDef
   9  {
  10  
  11      /**
  12       * @param string $string
  13       * @param HTMLPurifier_Config $config
  14       * @param HTMLPurifier_Context $context
  15       * @return bool|string
  16       */
  17      public function validate($string, $config, $context)
  18      {
  19          static $allowed_values = array(
  20              'line-through' => true,
  21              'overline' => true,
  22              'underline' => true,
  23          );
  24  
  25          $string = strtolower($this->parseCDATA($string));
  26  
  27          if ($string === 'none') {
  28              return $string;
  29          }
  30  
  31          $parts = explode(' ', $string);
  32          $final = '';
  33          foreach ($parts as $part) {
  34              if (isset($allowed_values[$part])) {
  35                  $final .= $part . ' ';
  36              }
  37          }
  38          $final = rtrim($final);
  39          if ($final === '') {
  40              return false;
  41          }
  42          return $final;
  43      }
  44  }
  45  
  46  // vim: et sw=4 sts=4


Generated: Tue Mar 17 22:47:18 2015 Cross-referenced by PHPXref 0.7.1