Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.2.x will end 22 April 2024 (12 months).
  • Bug fixes for security issues in 4.2.x will end 7 October 2024 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.1.x is supported too.

Differences Between: [Versions 310 and 402] [Versions 311 and 402] [Versions 39 and 402] [Versions 400 and 402]

   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      #[ReturnTypeWillChange]
  94      public function offsetSet($offset, $value)
  95      {
  96          if (strcasecmp($offset, 'size') === 0) {
  97              // RFC 2183 [2.7] - size parameter
  98              $value = intval($this->_sanityCheck($value));
  99          }
 100  
 101          parent::offsetSet($offset, $value);
 102      }
 103  
 104  }