File indexing completed on 2025-03-02 05:29:26
0001 <?php 0002 0003 /** 0004 * Zend Framework 0005 * 0006 * LICENSE 0007 * 0008 * This source file is subject to the new BSD license that is bundled 0009 * with this package in the file LICENSE.txt. 0010 * It is also available through the world-wide-web at this URL: 0011 * http://framework.zend.com/license/new-bsd 0012 * If you did not receive a copy of the license and are unable to 0013 * obtain it through the world-wide-web, please send an email 0014 * to license@zend.com so we can send you a copy immediately. 0015 * 0016 * @category Zend 0017 * @package Zend_Gdata 0018 * @subpackage App 0019 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0020 * @license http://framework.zend.com/license/new-bsd New BSD License 0021 * @version $Id$ 0022 */ 0023 0024 /** 0025 * @see Zend_Gdata_App_MediaSource 0026 */ 0027 // require_once 'Zend/Gdata/App/MediaSource.php'; 0028 0029 /** 0030 * Concrete class to use a file handle as an attachment within a MediaEntry. 0031 * 0032 * @category Zend 0033 * @package Zend_Gdata 0034 * @subpackage App 0035 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0036 * @license http://framework.zend.com/license/new-bsd New BSD License 0037 */ 0038 abstract class Zend_Gdata_App_BaseMediaSource implements Zend_Gdata_App_MediaSource 0039 { 0040 0041 /** 0042 * The content type for the attached file (example image/png) 0043 * 0044 * @var string 0045 */ 0046 protected $_contentType = null; 0047 0048 /** 0049 * The slug header value representing the attached file title, or null if 0050 * no slug should be used. The slug header is only necessary in some cases, 0051 * usually when a multipart upload is not being performed. 0052 * 0053 * @var string 0054 */ 0055 protected $_slug = null; 0056 0057 /** 0058 * The content type for the attached file (example image/png) 0059 * 0060 * @return string The content type 0061 */ 0062 public function getContentType() 0063 { 0064 return $this->_contentType; 0065 } 0066 0067 /** 0068 * Set the content type for the file attached (example image/png) 0069 * 0070 * @param string $value The content type 0071 * @return Zend_Gdata_App_MediaFileSource Provides a fluent interface 0072 */ 0073 public function setContentType($value) 0074 { 0075 $this->_contentType = $value; 0076 return $this; 0077 } 0078 0079 /** 0080 * Returns the Slug header value. Used by some services to determine the 0081 * title for the uploaded file. Returns null if no slug should be used. 0082 * 0083 * @return string 0084 */ 0085 public function getSlug(){ 0086 return $this->_slug; 0087 } 0088 0089 /** 0090 * Sets the Slug header value. Used by some services to determine the 0091 * title for the uploaded file. A null value indicates no slug header. 0092 * 0093 * @var string The slug value 0094 * @return Zend_Gdata_App_MediaSource Provides a fluent interface 0095 */ 0096 public function setSlug($value){ 0097 $this->_slug = $value; 0098 return $this; 0099 } 0100 0101 0102 /** 0103 * Magic getter to allow acces like $source->foo to call $source->getFoo() 0104 * Alternatively, if no getFoo() is defined, but a $_foo protected variable 0105 * is defined, this is returned. 0106 * 0107 * TODO Remove ability to bypass getFoo() methods?? 0108 * 0109 * @param string $name The variable name sought 0110 */ 0111 public function __get($name) 0112 { 0113 $method = 'get'.ucfirst($name); 0114 if (method_exists($this, $method)) { 0115 return call_user_func(array(&$this, $method)); 0116 } else if (property_exists($this, "_${name}")) { 0117 return $this->{'_' . $name}; 0118 } else { 0119 // require_once 'Zend/Gdata/App/InvalidArgumentException.php'; 0120 throw new Zend_Gdata_App_InvalidArgumentException( 0121 'Property ' . $name . ' does not exist'); 0122 } 0123 } 0124 0125 /** 0126 * Magic setter to allow acces like $source->foo='bar' to call 0127 * $source->setFoo('bar') automatically. 0128 * 0129 * Alternatively, if no setFoo() is defined, but a $_foo protected variable 0130 * is defined, this is returned. 0131 * 0132 * @param string $name 0133 * @param string $value 0134 */ 0135 public function __set($name, $val) 0136 { 0137 $method = 'set'.ucfirst($name); 0138 if (method_exists($this, $method)) { 0139 return call_user_func(array(&$this, $method), $val); 0140 } else if (isset($this->{'_' . $name}) || ($this->{'_' . $name} === null)) { 0141 $this->{'_' . $name} = $val; 0142 } else { 0143 // require_once 'Zend/Gdata/App/InvalidArgumentException.php'; 0144 throw new Zend_Gdata_App_InvalidArgumentException( 0145 'Property ' . $name . ' does not exist'); 0146 } 0147 } 0148 0149 /** 0150 * Magic __isset method 0151 * 0152 * @param string $name 0153 */ 0154 public function __isset($name) 0155 { 0156 $rc = new ReflectionClass(get_class($this)); 0157 $privName = '_' . $name; 0158 if (!($rc->hasProperty($privName))) { 0159 // require_once 'Zend/Gdata/App/InvalidArgumentException.php'; 0160 throw new Zend_Gdata_App_InvalidArgumentException( 0161 'Property ' . $name . ' does not exist'); 0162 } else { 0163 if (isset($this->{$privName})) { 0164 if (is_array($this->{$privName})) { 0165 if (count($this->{$privName}) > 0) { 0166 return true; 0167 } else { 0168 return false; 0169 } 0170 } else { 0171 return true; 0172 } 0173 } else { 0174 return false; 0175 } 0176 } 0177 } 0178 0179 }