Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

Differences Between: [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403]

   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 a Content-Disposition MIME header (RFC 2183).
  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  class Horde_Mime_Headers_ContentParam_ContentDisposition
  25  extends Horde_Mime_Headers_ContentParam
  26  {
  27      /**
  28       */
  29      public function __construct($name, $value)
  30      {
  31          parent::__construct('Content-Disposition', $value);
  32      }
  33  
  34      /**
  35       */
  36      public function __get($name)
  37      {
  38          $val = parent::__get($name);
  39  
  40          switch ($name) {
  41          case 'full_value':
  42              $val = parent::__get($name);
  43              if (substr(ltrim($val), 0, 1) === ';') {
  44                  $val = 'attachment' . $val;
  45              }
  46              break;
  47          }
  48  
  49          return $val;
  50      }
  51  
  52      /**
  53       */
  54      public function setContentParamValue($data)
  55      {
  56          parent::setContentParamValue($data);
  57  
  58          if (strlen($val = $this->value)) {
  59              if (strcasecmp($val, 'attachment') === 0) {
  60                  $val2 = 'attachment';
  61              } elseif (strcasecmp($val, 'inline') === 0) {
  62                  $val2 = 'inline';
  63              } else {
  64                  $val2 = '';
  65              }
  66  
  67              if ($val !== $val2) {
  68                  parent::setContentParamValue($val2);
  69              }
  70          }
  71      }
  72  
  73      /**
  74       */
  75      public function isDefault()
  76      {
  77          return !($this->full_value);
  78      }
  79  
  80      /**
  81       */
  82      public static function getHandles()
  83      {
  84          return array(
  85              'content-disposition'
  86          );
  87      }
  88  
  89      /* ArrayAccess methods */
  90  
  91      /**
  92       */
  93      public function offsetSet($offset, $value)
  94      {
  95          if (strcasecmp($offset, 'size') === 0) {
  96              // RFC 2183 [2.7] - size parameter
  97              $value = intval($this->_sanityCheck($value));
  98          }
  99  
 100          parent::offsetSet($offset, $value);
 101      }
 102  
 103  }