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 license@zend.com so we can send you a copy immediately.
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
25 * @see Zend_Gdata_App_MediaSource
27 require_once 'Zend/Gdata/App/MediaSource.php';
30 * Concrete class to use a file handle as an attachment within a MediaEntry.
35 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
36 * @license http://framework.zend.com/license/new-bsd New BSD License
38 abstract class Zend_Gdata_App_BaseMediaSource implements Zend_Gdata_App_MediaSource
42 * The content type for the attached file (example image/png)
46 protected $_contentType = null;
49 * The slug header value representing the attached file title, or null if
50 * no slug should be used. The slug header is only necessary in some cases,
51 * usually when a multipart upload is not being performed.
55 protected $_slug = null;
58 * The content type for the attached file (example image/png)
60 * @return string The content type
62 public function getContentType()
64 return $this->_contentType;
68 * Set the content type for the file attached (example image/png)
70 * @param string $value The content type
71 * @return Zend_Gdata_App_MediaFileSource Provides a fluent interface
73 public function setContentType($value)
75 $this->_contentType = $value;
80 * Returns the Slug header value. Used by some services to determine the
81 * title for the uploaded file. Returns null if no slug should be used.
85 public function getSlug(){
90 * Sets the Slug header value. Used by some services to determine the
91 * title for the uploaded file. A null value indicates no slug header.
93 * @var string The slug value
94 * @return Zend_Gdata_App_MediaSource Provides a fluent interface
96 public function setSlug($value){
97 $this->_slug = $value;
103 * Magic getter to allow acces like $source->foo to call $source->getFoo()
104 * Alternatively, if no getFoo() is defined, but a $_foo protected variable
105 * is defined, this is returned.
107 * TODO Remove ability to bypass getFoo() methods??
109 * @param string $name The variable name sought
111 public function __get($name)
113 $method = 'get'.ucfirst($name);
114 if (method_exists($this, $method)) {
115 return call_user_func(array(&$this, $method));
116 } else if (property_exists($this, "_${name}")) {
117 return $this->{'_' . $name};
119 require_once 'Zend/Gdata/App/InvalidArgumentException.php';
120 throw new Zend_Gdata_App_InvalidArgumentException(
121 'Property ' . $name . ' does not exist');
126 * Magic setter to allow acces like $source->foo='bar' to call
127 * $source->setFoo('bar') automatically.
129 * Alternatively, if no setFoo() is defined, but a $_foo protected variable
130 * is defined, this is returned.
132 * @param string $name
133 * @param string $value
135 public function __set($name, $val)
137 $method = 'set'.ucfirst($name);
138 if (method_exists($this, $method)) {
139 return call_user_func(array(&$this, $method), $val);
140 } else if (isset($this->{'_' . $name}) || ($this->{'_' . $name} === null)) {
141 $this->{'_' . $name} = $val;
143 require_once 'Zend/Gdata/App/InvalidArgumentException.php';
144 throw new Zend_Gdata_App_InvalidArgumentException(
145 'Property ' . $name . ' does not exist');
150 * Magic __isset method
152 * @param string $name
154 public function __isset($name)
156 $rc = new ReflectionClass(get_class($this));
157 $privName = '_' . $name;
158 if (!($rc->hasProperty($privName))) {
159 require_once 'Zend/Gdata/App/InvalidArgumentException.php';
160 throw new Zend_Gdata_App_InvalidArgumentException(
161 'Property ' . $name . ' does not exist');
163 if (isset($this->{$privName})) {
164 if (is_array($this->{$privName})) {
165 if (count($this->{$privName}) > 0) {