public function setDispositionParameter($label, $data)
{
$this->_dispParams[$label] = $data;
+
+ switch ($label) {
+ case 'size':
+ // RFC 2183 [2.7] - size parameter
+ $this->_bytes = intval($data);
+ break;
+ }
}
/**
}
/* Don't show Content-Disposition unless a disposition has explicitly
- * been set or there is a name parameter. If there is a name, but no
- * disposition, default to 'attachment'.
+ * been set or there are parameters.
+ * If there is a name, but no disposition, default to 'attachment'.
* RFC 2183 [2] indicates that default is no requested disposition -
* the receiving MUA is responsible for display choice. */
$disposition = $this->getDisposition();
+ $disp_params = $this->getAllDispositionParameters();
$name = $this->getName();
- if ($disposition || !empty($name)) {
- $headers->replaceHeader('Content-Disposition', $disposition ? $disposition : 'attachment', array('params' => (!empty($name) ? array('filename' => $name) : array())));
+ if ($disposition || !empty($name) || !empty($disp_params)) {
+ if (!$disposition) {
+ $disposition = 'attachment';
+ }
+ if ($name) {
+ $disp_params['filename'] = $name;
+ }
+ $headers->replaceHeader('Content-Disposition', $disposition, array('params' => $disp_params));
} else {
$headers->removeHeader('Content-Disposition');
}
*/
public function setBytes($bytes)
{
- $this->_bytes = $bytes;
+ $this->setDispositionParameter('size', $bytes);
}
/**
$ob->setContents($data['contents']);
}
+ if (isset($data['size'])) {
+ $ob->setBytes($data['size']);
+ }
+
if (isset($data['disposition'])) {
$ob->setDisposition($data['disposition']);
if (!empty($data['dparameters'])) {
}
}
- if (isset($data['size'])) {
- $ob->setBytes($data['size']);
- }
-
if (isset($data['id'])) {
$ob->setContentId($data['id']);
}
<api>alpha</api>
</stability>
<license uri="http://www.gnu.org/copyleft/lesser.html">LGPL</license>
- <notes>
-* Converted tests to PHPUnit.
+ <notes>* Honor the Content-Disposition 'size' parameter (RFC 2183 [2.7]).
+ * Converted tests to PHPUnit.
* Moved viewer code to horde/Mime_Viewer package.
* Removed Webcpp and Enscript viewers. Source code highlighting is now
exclusively handled by the Srchighlight driver.