[ Index ] |
PHP Cross Reference of moodle-2.8 |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * Zend Framework 5 * 6 * LICENSE 7 * 8 * This source file is subject to the new BSD license that is bundled 9 * with this package in the file LICENSE.txt. 10 * It is also available through the world-wide-web at this URL: 11 * http://framework.zend.com/license/new-bsd 12 * If you did not receive a copy of the license and are unable to 13 * obtain it through the world-wide-web, please send an email 14 * to [email protected] so we can send you a copy immediately. 15 * 16 * @category Zend 17 * @package Zend_Gdata 18 * @subpackage App 19 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) 20 * @license http://framework.zend.com/license/new-bsd New BSD License 21 * @version $Id$ 22 */ 23 24 /** 25 * @see Zend_Gdata_App_Entry 26 */ 27 require_once 'Zend/Gdata/App/Entry.php'; 28 29 /** 30 * @see Zend_Gdata_App_MediaSource 31 */ 32 require_once 'Zend/Gdata/App/MediaSource.php'; 33 34 /** 35 * @see Zend_Gdata_MediaMimeStream 36 */ 37 require_once 'Zend/Gdata/MediaMimeStream.php'; 38 39 /** 40 * Concrete class for working with Atom entries containing multi-part data. 41 * 42 * @category Zend 43 * @package Zend_Gdata 44 * @subpackage App 45 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) 46 * @license http://framework.zend.com/license/new-bsd New BSD License 47 */ 48 class Zend_Gdata_App_MediaEntry extends Zend_Gdata_App_Entry 49 { 50 /** 51 * The attached MediaSource/file 52 * 53 * @var Zend_Gdata_App_MediaSource 54 */ 55 protected $_mediaSource = null; 56 57 /** 58 * Constructs a new MediaEntry, representing XML data and optional 59 * file to upload 60 * 61 * @param DOMElement $element (optional) DOMElement from which this 62 * object should be constructed. 63 */ 64 public function __construct($element = null, $mediaSource = null) 65 { 66 parent::__construct($element); 67 $this->_mediaSource = $mediaSource; 68 } 69 70 /** 71 * Return the MIME multipart representation of this MediaEntry. 72 * 73 * @return string|Zend_Gdata_MediaMimeStream The MIME multipart 74 * representation of this MediaEntry. If the entry consisted only 75 * of XML, a string is returned. 76 */ 77 public function encode() 78 { 79 $xmlData = $this->saveXML(); 80 $mediaSource = $this->getMediaSource(); 81 if ($mediaSource === null) { 82 // No attachment, just send XML for entry 83 return $xmlData; 84 } else { 85 return new Zend_Gdata_MediaMimeStream($xmlData, 86 $mediaSource->getFilename(), $mediaSource->getContentType()); 87 } 88 } 89 90 /** 91 * Return the MediaSource object representing the file attached to this 92 * MediaEntry. 93 * 94 * @return Zend_Gdata_App_MediaSource The attached MediaSource/file 95 */ 96 public function getMediaSource() 97 { 98 return $this->_mediaSource; 99 } 100 101 /** 102 * Set the MediaSource object (file) for this MediaEntry 103 * 104 * @param Zend_Gdata_App_MediaSource $value The attached MediaSource/file 105 * @return Zend_Gdata_App_MediaEntry Provides a fluent interface 106 */ 107 public function setMediaSource($value) 108 { 109 if ($value instanceof Zend_Gdata_App_MediaSource) { 110 $this->_mediaSource = $value; 111 } else { 112 require_once 'Zend/Gdata/App/InvalidArgumentException.php'; 113 throw new Zend_Gdata_App_InvalidArgumentException( 114 'You must specify the media data as a class that conforms to Zend_Gdata_App_MediaSource.'); 115 } 116 return $this; 117 } 118 119 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 20:29:05 2014 | Cross-referenced by PHPXref 0.7.1 |