Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.
   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