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   * Copyright 2015-2017 Horde LLC (http://www.horde.org/)
   4   *
   5   * See the enclosed file LICENSE for license information (LGPL). If you
   6   * did not receive this file, see http://www.horde.org/licenses/lgpl21.
   7   *
   8   * @category  Horde
   9   * @copyright 2015-2017 Horde LLC
  10   * @license   http://www.horde.org/licenses/lgpl21 LGPL 2.1
  11   * @package   Mime
  12   */
  13  
  14  /**
  15   * This class represents the Content-Language header value (RFC 3282).
  16   *
  17   * @author    Michael Slusarz <slusarz@horde.org>
  18   * @category  Horde
  19   * @copyright 2015-2017 Horde LLC
  20   * @license   http://www.horde.org/licenses/lgpl21 LGPL 2.1
  21   * @package   Mime
  22   * @since     2.8.0
  23   *
  24   * @property-read array $langs  The list of languages.
  25   */
  26  class Horde_Mime_Headers_ContentLanguage
  27  extends Horde_Mime_Headers_Element_Single
  28  implements Horde_Mime_Headers_Extension_Mime
  29  {
  30      /**
  31       */
  32      public function __construct($name, $value)
  33      {
  34          parent::__construct('Content-Language', $value);
  35      }
  36  
  37      /**
  38       */
  39      public function __get($name)
  40      {
  41          switch ($name) {
  42          case 'full_value':
  43          case 'value':
  44          case 'value_single':
  45              return implode(',', $this->_values);
  46  
  47          case 'langs':
  48              return $this->_values;
  49          }
  50  
  51          return parent::__get($name);
  52      }
  53  
  54      /**
  55       * @param mixed $value  Either a single language or an array of languages.
  56       */
  57      protected function _setValue($value)
  58      {
  59          if ($value instanceof Horde_Mime_Headers_Element) {
  60              $value = $value->value;
  61          }
  62  
  63          if (!is_array($value)) {
  64              $value = array_map('trim', explode(',', $value));
  65          }
  66  
  67          $this->_values = array();
  68          foreach ($value as $val) {
  69              $this->_values[] = Horde_String::lower(
  70                  $this->_sanityCheck(Horde_Mime::decode($val))
  71              );
  72          }
  73      }
  74  
  75      /**
  76       */
  77      public static function getHandles()
  78      {
  79          return array(
  80              'content-language'
  81          );
  82      }
  83  
  84  }