Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.10.x will end 8 November 2021 (12 months).
  • Bug fixes for security issues in 3.10.x will end 9 May 2022 (18 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.
   1  <?php
   2  
   3  class HTMLPurifier_AttrDef_CSS_AlphaValue extends HTMLPurifier_AttrDef_CSS_Number
   4  {
   5  
   6      public function __construct()
   7      {
   8          parent::__construct(false); // opacity is non-negative, but we will clamp it

   9      }
  10  
  11      /**

  12       * @param string $number

  13       * @param HTMLPurifier_Config $config

  14       * @param HTMLPurifier_Context $context

  15       * @return string

  16       */
  17      public function validate($number, $config, $context)
  18      {
  19          $result = parent::validate($number, $config, $context);
  20          if ($result === false) {
  21              return $result;
  22          }
  23          $float = (float)$result;
  24          if ($float < 0.0) {
  25              $result = '0';
  26          }
  27          if ($float > 1.0) {
  28              $result = '1';
  29          }
  30          return $result;
  31      }
  32  }
  33  
  34  // vim: et sw=4 sts=4