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-2008 Zend Technologies USA Inc. (http://www.zend.com)
20
* @license http://framework.zend.com/license/new-bsd New BSD License
24
* @see Zend_Gdata_App_MediaSource
26
require_once 'Zend/Gdata/App/MediaSource.php';
29
* Concrete class to use a file handle as an attachment within a MediaEntry.
33
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
34
* @license http://framework.zend.com/license/new-bsd New BSD License
36
abstract class Zend_Gdata_App_BaseMediaSource implements Zend_Gdata_App_MediaSource
40
* The content type for the attached file (example image/png)
44
protected $_contentType = null;
47
* The slug header value representing the attached file title, or null if
48
* no slug should be used. The slug header is only necessary in some cases,
49
* usually when a multipart upload is not being performed.
53
protected $_slug = null;
56
* The content type for the attached file (example image/png)
58
* @return string The content type
60
public function getContentType()
62
return $this->_contentType;
66
* Set the content type for the file attached (example image/png)
68
* @param string $value The content type
69
* @return Zend_Gdata_App_MediaFileSource Provides a fluent interface
71
public function setContentType($value)
73
$this->_contentType = $value;
78
* Returns the Slug header value. Used by some services to determine the
79
* title for the uploaded file. Returns null if no slug should be used.
83
public function getSlug(){
88
* Sets the Slug header value. Used by some services to determine the
89
* title for the uploaded file. A null value indicates no slug header.
91
* @var string The slug value
92
* @return Zend_Gdata_App_MediaSource Provides a fluent interface
94
public function setSlug($value){
95
$this->_slug = $value;
101
* Magic getter to allow acces like $source->foo to call $source->getFoo()
102
* Alternatively, if no getFoo() is defined, but a $_foo protected variable
103
* is defined, this is returned.
105
* TODO Remove ability to bypass getFoo() methods??
107
* @param string $name The variable name sought
109
public function __get($name)
111
$method = 'get'.ucfirst($name);
112
if (method_exists($this, $method)) {
113
return call_user_func(array(&$this, $method));
114
} else if (property_exists($this, "_${name}")) {
115
return $this->{'_' . $name};
117
require_once 'Zend/Gdata/App/InvalidArgumentException.php';
118
throw new Zend_Gdata_App_InvalidArgumentException(
119
'Property ' . $name . ' does not exist');
124
* Magic setter to allow acces like $source->foo='bar' to call
125
* $source->setFoo('bar') automatically.
127
* Alternatively, if no setFoo() is defined, but a $_foo protected variable
128
* is defined, this is returned.
130
* @param string $name
131
* @param string $value
133
public function __set($name, $val)
135
$method = 'set'.ucfirst($name);
136
if (method_exists($this, $method)) {
137
return call_user_func(array(&$this, $method), $val);
138
} else if (isset($this->{'_' . $name}) || is_null($this->{'_' . $name})) {
139
$this->{'_' . $name} = $val;
141
require_once 'Zend/Gdata/App/InvalidArgumentException.php';
142
throw new Zend_Gdata_App_InvalidArgumentException(
143
'Property ' . $name . ' does not exist');
148
* Magic __isset method
150
* @param string $name
152
public function __isset($name)
154
$rc = new ReflectionClass(get_class($this));
155
$privName = '_' . $name;
156
if (!($rc->hasProperty($privName))) {
157
require_once 'Zend/Gdata/App/InvalidArgumentException.php';
158
throw new Zend_Gdata_App_InvalidArgumentException(
159
'Property ' . $name . ' does not exist');
161
if (isset($this->{$privName})) {
162
if (is_array($this->{$privName})) {
163
if (count($this->{$privName}) > 0) {