From 06f945f27840b53e57795dadbc38e76f7e11ab1c Mon Sep 17 00:00:00 2001 From: Horus3 Date: Mon, 24 Feb 2014 16:42:14 +0100 Subject: init --- zend/library/Zend/Gdata/App/AuthException.php | 41 ++ .../Zend/Gdata/App/BadMethodCallException.php | 42 ++ zend/library/Zend/Gdata/App/Base.php | 572 +++++++++++++++++ zend/library/Zend/Gdata/App/BaseMediaSource.php | 179 ++++++ .../Zend/Gdata/App/CaptchaRequiredException.php | 94 +++ zend/library/Zend/Gdata/App/Entry.php | 389 ++++++++++++ zend/library/Zend/Gdata/App/Exception.php | 43 ++ zend/library/Zend/Gdata/App/Extension.php | 40 ++ zend/library/Zend/Gdata/App/Extension/Author.php | 43 ++ zend/library/Zend/Gdata/App/Extension/Category.php | 140 +++++ zend/library/Zend/Gdata/App/Extension/Content.php | 88 +++ .../Zend/Gdata/App/Extension/Contributor.php | 43 ++ zend/library/Zend/Gdata/App/Extension/Control.php | 98 +++ zend/library/Zend/Gdata/App/Extension/Draft.php | 50 ++ zend/library/Zend/Gdata/App/Extension/Edited.php | 49 ++ zend/library/Zend/Gdata/App/Extension/Element.php | 58 ++ zend/library/Zend/Gdata/App/Extension/Email.php | 49 ++ .../library/Zend/Gdata/App/Extension/Generator.php | 115 ++++ zend/library/Zend/Gdata/App/Extension/Icon.php | 49 ++ zend/library/Zend/Gdata/App/Extension/Id.php | 49 ++ zend/library/Zend/Gdata/App/Extension/Link.php | 219 +++++++ zend/library/Zend/Gdata/App/Extension/Logo.php | 49 ++ zend/library/Zend/Gdata/App/Extension/Name.php | 48 ++ zend/library/Zend/Gdata/App/Extension/Person.php | 163 +++++ .../library/Zend/Gdata/App/Extension/Published.php | 49 ++ zend/library/Zend/Gdata/App/Extension/Rights.php | 49 ++ zend/library/Zend/Gdata/App/Extension/Source.php | 46 ++ zend/library/Zend/Gdata/App/Extension/Subtitle.php | 43 ++ zend/library/Zend/Gdata/App/Extension/Summary.php | 43 ++ zend/library/Zend/Gdata/App/Extension/Text.php | 90 +++ zend/library/Zend/Gdata/App/Extension/Title.php | 43 ++ zend/library/Zend/Gdata/App/Extension/Updated.php | 49 ++ zend/library/Zend/Gdata/App/Extension/Uri.php | 49 ++ zend/library/Zend/Gdata/App/Feed.php | 352 +++++++++++ zend/library/Zend/Gdata/App/FeedEntryParent.php | 681 +++++++++++++++++++++ zend/library/Zend/Gdata/App/FeedSourceParent.php | 267 ++++++++ zend/library/Zend/Gdata/App/HttpException.php | 121 ++++ zend/library/Zend/Gdata/App/IOException.php | 43 ++ .../Zend/Gdata/App/InvalidArgumentException.php | 42 ++ .../Gdata/App/LoggingHttpClientAdapterSocket.php | 119 ++++ zend/library/Zend/Gdata/App/MediaEntry.php | 119 ++++ zend/library/Zend/Gdata/App/MediaFileSource.php | 146 +++++ zend/library/Zend/Gdata/App/MediaSource.php | 73 +++ zend/library/Zend/Gdata/App/Util.php | 112 ++++ zend/library/Zend/Gdata/App/VersionException.php | 42 ++ 45 files changed, 5288 insertions(+) create mode 100644 zend/library/Zend/Gdata/App/AuthException.php create mode 100644 zend/library/Zend/Gdata/App/BadMethodCallException.php create mode 100644 zend/library/Zend/Gdata/App/Base.php create mode 100644 zend/library/Zend/Gdata/App/BaseMediaSource.php create mode 100644 zend/library/Zend/Gdata/App/CaptchaRequiredException.php create mode 100644 zend/library/Zend/Gdata/App/Entry.php create mode 100644 zend/library/Zend/Gdata/App/Exception.php create mode 100644 zend/library/Zend/Gdata/App/Extension.php create mode 100644 zend/library/Zend/Gdata/App/Extension/Author.php create mode 100644 zend/library/Zend/Gdata/App/Extension/Category.php create mode 100644 zend/library/Zend/Gdata/App/Extension/Content.php create mode 100644 zend/library/Zend/Gdata/App/Extension/Contributor.php create mode 100644 zend/library/Zend/Gdata/App/Extension/Control.php create mode 100644 zend/library/Zend/Gdata/App/Extension/Draft.php create mode 100644 zend/library/Zend/Gdata/App/Extension/Edited.php create mode 100644 zend/library/Zend/Gdata/App/Extension/Element.php create mode 100644 zend/library/Zend/Gdata/App/Extension/Email.php create mode 100644 zend/library/Zend/Gdata/App/Extension/Generator.php create mode 100644 zend/library/Zend/Gdata/App/Extension/Icon.php create mode 100644 zend/library/Zend/Gdata/App/Extension/Id.php create mode 100644 zend/library/Zend/Gdata/App/Extension/Link.php create mode 100644 zend/library/Zend/Gdata/App/Extension/Logo.php create mode 100644 zend/library/Zend/Gdata/App/Extension/Name.php create mode 100644 zend/library/Zend/Gdata/App/Extension/Person.php create mode 100644 zend/library/Zend/Gdata/App/Extension/Published.php create mode 100644 zend/library/Zend/Gdata/App/Extension/Rights.php create mode 100644 zend/library/Zend/Gdata/App/Extension/Source.php create mode 100644 zend/library/Zend/Gdata/App/Extension/Subtitle.php create mode 100644 zend/library/Zend/Gdata/App/Extension/Summary.php create mode 100644 zend/library/Zend/Gdata/App/Extension/Text.php create mode 100644 zend/library/Zend/Gdata/App/Extension/Title.php create mode 100644 zend/library/Zend/Gdata/App/Extension/Updated.php create mode 100644 zend/library/Zend/Gdata/App/Extension/Uri.php create mode 100755 zend/library/Zend/Gdata/App/Feed.php create mode 100755 zend/library/Zend/Gdata/App/FeedEntryParent.php create mode 100644 zend/library/Zend/Gdata/App/FeedSourceParent.php create mode 100644 zend/library/Zend/Gdata/App/HttpException.php create mode 100644 zend/library/Zend/Gdata/App/IOException.php create mode 100644 zend/library/Zend/Gdata/App/InvalidArgumentException.php create mode 100644 zend/library/Zend/Gdata/App/LoggingHttpClientAdapterSocket.php create mode 100644 zend/library/Zend/Gdata/App/MediaEntry.php create mode 100644 zend/library/Zend/Gdata/App/MediaFileSource.php create mode 100644 zend/library/Zend/Gdata/App/MediaSource.php create mode 100644 zend/library/Zend/Gdata/App/Util.php create mode 100644 zend/library/Zend/Gdata/App/VersionException.php (limited to 'zend/library/Zend/Gdata/App') diff --git a/zend/library/Zend/Gdata/App/AuthException.php b/zend/library/Zend/Gdata/App/AuthException.php new file mode 100644 index 0000000..58fad73 --- /dev/null +++ b/zend/library/Zend/Gdata/App/AuthException.php @@ -0,0 +1,41 @@ + array( + 1 => array( + 0 => 'http://www.w3.org/2005/Atom' + ) + ), + 'app' => array( + 1 => array( + 0 => 'http://purl.org/atom/app#' + ), + 2 => array( + 0 => 'http://www.w3.org/2007/app' + ) + ) + ); + + public function __construct() + { + } + + /** + * Returns the child text node of this element + * This represents any raw text contained within the XML element + * + * @return string Child text node + */ + public function getText($trim = true) + { + if ($trim) { + return trim($this->_text); + } else { + return $this->_text; + } + } + + /** + * Sets the child text node of this element + * This represents any raw text contained within the XML element + * + * @param string $value Child text node + * @return Zend_Gdata_App_Base Returns an object of the same type as 'this' to provide a fluent interface. + */ + public function setText($value) + { + $this->_text = $value; + return $this; + } + + /** + * Returns an array of all elements not matched to data model classes + * during the parsing of the XML + * + * @return array All elements not matched to data model classes during parsing + */ + public function getExtensionElements() + { + return $this->_extensionElements; + } + + /** + * Sets an array of all elements not matched to data model classes + * during the parsing of the XML. This method can be used to add arbitrary + * child XML elements to any data model class. + * + * @param array $value All extension elements + * @return Zend_Gdata_App_Base Returns an object of the same type as 'this' to provide a fluent interface. + */ + public function setExtensionElements($value) + { + $this->_extensionElements = $value; + return $this; + } + + /** + * Returns an array of all extension attributes not transformed into data + * model properties during parsing of the XML. Each element of the array + * is a hashed array of the format: + * array('namespaceUri' => string, 'name' => string, 'value' => string); + * + * @return array All extension attributes + */ + public function getExtensionAttributes() + { + return $this->_extensionAttributes; + } + + /** + * Sets an array of all extension attributes not transformed into data + * model properties during parsing of the XML. Each element of the array + * is a hashed array of the format: + * array('namespaceUri' => string, 'name' => string, 'value' => string); + * This can be used to add arbitrary attributes to any data model element + * + * @param array $value All extension attributes + * @return Zend_Gdata_App_Base Returns an object of the same type as 'this' to provide a fluent interface. + */ + public function setExtensionAttributes($value) + { + $this->_extensionAttributes = $value; + return $this; + } + + /** + * Retrieves a DOMElement which corresponds to this element and all + * child properties. This is used to build an entry back into a DOM + * and eventually XML text for sending to the server upon updates, or + * for application storage/persistence. + * + * @param DOMDocument $doc The DOMDocument used to construct DOMElements + * @return DOMElement The DOMElement representing this element and all + * child properties. + */ + public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null) + { + if ($doc === null) { + $doc = new DOMDocument('1.0', 'utf-8'); + } + if ($this->_rootNamespaceURI != null) { + $element = $doc->createElementNS($this->_rootNamespaceURI, $this->_rootElement); + } elseif ($this->_rootNamespace !== null) { + if (strpos($this->_rootElement, ':') === false) { + $elementName = $this->_rootNamespace . ':' . $this->_rootElement; + } else { + $elementName = $this->_rootElement; + } + $element = $doc->createElementNS($this->lookupNamespace($this->_rootNamespace), $elementName); + } else { + $element = $doc->createElement($this->_rootElement); + } + if ($this->_text != null) { + $element->appendChild($element->ownerDocument->createTextNode($this->_text)); + } + foreach ($this->_extensionElements as $extensionElement) { + $element->appendChild($extensionElement->getDOM($element->ownerDocument)); + } + foreach ($this->_extensionAttributes as $attribute) { + $element->setAttribute($attribute['name'], $attribute['value']); + } + return $element; + } + + /** + * Given a child DOMNode, tries to determine how to map the data into + * object instance members. If no mapping is defined, Extension_Element + * objects are created and stored in an array. + * + * @param DOMNode $child The DOMNode needed to be handled + */ + protected function takeChildFromDOM($child) + { + if ($child->nodeType == XML_TEXT_NODE) { + $this->_text = $child->nodeValue; + } else { + $extensionElement = new Zend_Gdata_App_Extension_Element(); + $extensionElement->transferFromDOM($child); + $this->_extensionElements[] = $extensionElement; + } + } + + /** + * Given a DOMNode representing an attribute, tries to map the data into + * instance members. If no mapping is defined, the name and value are + * stored in an array. + * + * @param DOMNode $attribute The DOMNode attribute needed to be handled + */ + protected function takeAttributeFromDOM($attribute) + { + $arrayIndex = ($attribute->namespaceURI != '')?( + $attribute->namespaceURI . ':' . $attribute->name): + $attribute->name; + $this->_extensionAttributes[$arrayIndex] = + array('namespaceUri' => $attribute->namespaceURI, + 'name' => $attribute->localName, + 'value' => $attribute->nodeValue); + } + + /** + * Transfers each child and attribute into member variables. + * This is called when XML is received over the wire and the data + * model needs to be built to represent this XML. + * + * @param DOMNode $node The DOMNode that represents this object's data + */ + public function transferFromDOM($node) + { + foreach ($node->childNodes as $child) { + $this->takeChildFromDOM($child); + } + foreach ($node->attributes as $attribute) { + $this->takeAttributeFromDOM($attribute); + } + } + + /** + * Parses the provided XML text and generates data model classes for + * each know element by turning the XML text into a DOM tree and calling + * transferFromDOM($element). The first data model element with the same + * name as $this->_rootElement is used and the child elements are + * recursively parsed. + * + * @param string $xml The XML text to parse + */ + public function transferFromXML($xml) + { + if ($xml) { + // Load the feed as an XML DOMDocument object + @ini_set('track_errors', 1); + $doc = new DOMDocument(); + $success = @$doc->loadXML($xml); + @ini_restore('track_errors'); + if (!$success) { + require_once 'Zend/Gdata/App/Exception.php'; + throw new Zend_Gdata_App_Exception("DOMDocument cannot parse XML: $php_errormsg"); + } + $element = $doc->getElementsByTagName($this->_rootElement)->item(0); + if (!$element) { + require_once 'Zend/Gdata/App/Exception.php'; + throw new Zend_Gdata_App_Exception('No root <' . $this->_rootElement . '> element'); + } + $this->transferFromDOM($element); + } else { + require_once 'Zend/Gdata/App/Exception.php'; + throw new Zend_Gdata_App_Exception('XML passed to transferFromXML cannot be null'); + } + } + + /** + * Converts this element and all children into XML text using getDOM() + * + * @return string XML content + */ + public function saveXML() + { + $element = $this->getDOM(); + return $element->ownerDocument->saveXML($element); + } + + /** + * Alias for saveXML() returns XML content for this element and all + * children + * + * @return string XML content + */ + public function getXML() + { + return $this->saveXML(); + } + + /** + * Alias for saveXML() + * + * Can be overridden by children to provide more complex representations + * of entries. + * + * @return string Encoded string content + */ + public function encode() + { + return $this->saveXML(); + } + + /** + * Get the full version of a namespace prefix + * + * Looks up a prefix (atom:, etc.) in the list of registered + * namespaces and returns the full namespace URI if + * available. Returns the prefix, unmodified, if it's not + * registered. + * + * @param string $prefix The namespace prefix to lookup. + * @param integer $majorVersion The major protocol version in effect. + * Defaults to '1'. + * @param integer $minorVersion The minor protocol version in effect. + * Defaults to null (use latest). + * @return string + */ + public function lookupNamespace($prefix, + $majorVersion = 1, + $minorVersion = null) + { + // Check for a memoized result + $key = $prefix . ' ' . + ($majorVersion === null ? 'NULL' : $majorVersion) . + ' '. ($minorVersion === null ? 'NULL' : $minorVersion); + if (array_key_exists($key, self::$_namespaceLookupCache)) + return self::$_namespaceLookupCache[$key]; + // If no match, return the prefix by default + $result = $prefix; + + // Find tuple of keys that correspond to the namespace we should use + if (isset($this->_namespaces[$prefix])) { + // Major version search + $nsData = $this->_namespaces[$prefix]; + $foundMajorV = Zend_Gdata_App_Util::findGreatestBoundedValue( + $majorVersion, $nsData); + // Minor version search + $nsData = $nsData[$foundMajorV]; + $foundMinorV = Zend_Gdata_App_Util::findGreatestBoundedValue( + $minorVersion, $nsData); + // Extract NS + $result = $nsData[$foundMinorV]; + } + + // Memoize result + self::$_namespaceLookupCache[$key] = $result; + + return $result; + } + + /** + * Add a namespace and prefix to the registered list + * + * Takes a prefix and a full namespace URI and adds them to the + * list of registered namespaces for use by + * $this->lookupNamespace(). + * + * WARNING: Currently, registering a namespace will NOT invalidate any + * memoized data stored in $_namespaceLookupCache. Under normal + * use, this behavior is acceptable. If you are adding + * contradictory data to the namespace lookup table, you must + * call flushNamespaceLookupCache(). + * + * @param string $prefix The namespace prefix + * @param string $namespaceUri The full namespace URI + * @param integer $majorVersion The major protocol version in effect. + * Defaults to '1'. + * @param integer $minorVersion The minor protocol version in effect. + * Defaults to null (use latest). + * @return void + */ + public function registerNamespace($prefix, + $namespaceUri, + $majorVersion = 1, + $minorVersion = 0) + { + $this->_namespaces[$prefix][$majorVersion][$minorVersion] = + $namespaceUri; + } + + /** + * Flush namespace lookup cache. + * + * Empties the namespace lookup cache. Call this function if you have + * added data to the namespace lookup table that contradicts values that + * may have been cached during a previous call to lookupNamespace(). + */ + public static function flushNamespaceLookupCache() + { + self::$_namespaceLookupCache = array(); + } + + /** + * Add an array of namespaces to the registered list. + * + * Takes an array in the format of: + * namespace prefix, namespace URI, major protocol version, + * minor protocol version and adds them with calls to ->registerNamespace() + * + * @param array $namespaceArray An array of namespaces. + * @return void + */ + public function registerAllNamespaces($namespaceArray) + { + foreach($namespaceArray as $namespace) { + $this->registerNamespace( + $namespace[0], $namespace[1], $namespace[2], $namespace[3]); + } + } + + + /** + * Magic getter to allow access like $entry->foo to call $entry->getFoo() + * Alternatively, if no getFoo() is defined, but a $_foo protected variable + * is defined, this is returned. + * + * TODO Remove ability to bypass getFoo() methods?? + * + * @param string $name The variable name sought + */ + public function __get($name) + { + $method = 'get'.ucfirst($name); + if (method_exists($this, $method)) { + return call_user_func(array(&$this, $method)); + } else if (property_exists($this, "_${name}")) { + return $this->{'_' . $name}; + } else { + require_once 'Zend/Gdata/App/InvalidArgumentException.php'; + throw new Zend_Gdata_App_InvalidArgumentException( + 'Property ' . $name . ' does not exist'); + } + } + + /** + * Magic setter to allow acces like $entry->foo='bar' to call + * $entry->setFoo('bar') automatically. + * + * Alternatively, if no setFoo() is defined, but a $_foo protected variable + * is defined, this is returned. + * + * TODO Remove ability to bypass getFoo() methods?? + * + * @param string $name + * @param string $value + */ + public function __set($name, $val) + { + $method = 'set'.ucfirst($name); + if (method_exists($this, $method)) { + return call_user_func(array(&$this, $method), $val); + } else if (isset($this->{'_' . $name}) || ($this->{'_' . $name} === null)) { + $this->{'_' . $name} = $val; + } else { + require_once 'Zend/Gdata/App/InvalidArgumentException.php'; + throw new Zend_Gdata_App_InvalidArgumentException( + 'Property ' . $name . ' does not exist'); + } + } + + /** + * Magic __isset method + * + * @param string $name + */ + public function __isset($name) + { + $rc = new ReflectionClass(get_class($this)); + $privName = '_' . $name; + if (!($rc->hasProperty($privName))) { + require_once 'Zend/Gdata/App/InvalidArgumentException.php'; + throw new Zend_Gdata_App_InvalidArgumentException( + 'Property ' . $name . ' does not exist'); + } else { + if (isset($this->{$privName})) { + if (is_array($this->{$privName})) { + if (count($this->{$privName}) > 0) { + return true; + } else { + return false; + } + } else { + return true; + } + } else { + return false; + } + } + } + + /** + * Magic __unset method + * + * @param string $name + */ + public function __unset($name) + { + if (isset($this->{'_' . $name})) { + if (is_array($this->{'_' . $name})) { + $this->{'_' . $name} = array(); + } else { + $this->{'_' . $name} = null; + } + } + } + + /** + * Magic toString method allows using this directly via echo + * Works best in PHP >= 4.2.0 + * + * @return string The text representation of this object + */ + public function __toString() + { + return $this->getText(); + } + +} diff --git a/zend/library/Zend/Gdata/App/BaseMediaSource.php b/zend/library/Zend/Gdata/App/BaseMediaSource.php new file mode 100644 index 0000000..9190465 --- /dev/null +++ b/zend/library/Zend/Gdata/App/BaseMediaSource.php @@ -0,0 +1,179 @@ +_contentType; + } + + /** + * Set the content type for the file attached (example image/png) + * + * @param string $value The content type + * @return Zend_Gdata_App_MediaFileSource Provides a fluent interface + */ + public function setContentType($value) + { + $this->_contentType = $value; + return $this; + } + + /** + * Returns the Slug header value. Used by some services to determine the + * title for the uploaded file. Returns null if no slug should be used. + * + * @return string + */ + public function getSlug(){ + return $this->_slug; + } + + /** + * Sets the Slug header value. Used by some services to determine the + * title for the uploaded file. A null value indicates no slug header. + * + * @var string The slug value + * @return Zend_Gdata_App_MediaSource Provides a fluent interface + */ + public function setSlug($value){ + $this->_slug = $value; + return $this; + } + + + /** + * Magic getter to allow acces like $source->foo to call $source->getFoo() + * Alternatively, if no getFoo() is defined, but a $_foo protected variable + * is defined, this is returned. + * + * TODO Remove ability to bypass getFoo() methods?? + * + * @param string $name The variable name sought + */ + public function __get($name) + { + $method = 'get'.ucfirst($name); + if (method_exists($this, $method)) { + return call_user_func(array(&$this, $method)); + } else if (property_exists($this, "_${name}")) { + return $this->{'_' . $name}; + } else { + require_once 'Zend/Gdata/App/InvalidArgumentException.php'; + throw new Zend_Gdata_App_InvalidArgumentException( + 'Property ' . $name . ' does not exist'); + } + } + + /** + * Magic setter to allow acces like $source->foo='bar' to call + * $source->setFoo('bar') automatically. + * + * Alternatively, if no setFoo() is defined, but a $_foo protected variable + * is defined, this is returned. + * + * @param string $name + * @param string $value + */ + public function __set($name, $val) + { + $method = 'set'.ucfirst($name); + if (method_exists($this, $method)) { + return call_user_func(array(&$this, $method), $val); + } else if (isset($this->{'_' . $name}) || ($this->{'_' . $name} === null)) { + $this->{'_' . $name} = $val; + } else { + require_once 'Zend/Gdata/App/InvalidArgumentException.php'; + throw new Zend_Gdata_App_InvalidArgumentException( + 'Property ' . $name . ' does not exist'); + } + } + + /** + * Magic __isset method + * + * @param string $name + */ + public function __isset($name) + { + $rc = new ReflectionClass(get_class($this)); + $privName = '_' . $name; + if (!($rc->hasProperty($privName))) { + require_once 'Zend/Gdata/App/InvalidArgumentException.php'; + throw new Zend_Gdata_App_InvalidArgumentException( + 'Property ' . $name . ' does not exist'); + } else { + if (isset($this->{$privName})) { + if (is_array($this->{$privName})) { + if (count($this->{$privName}) > 0) { + return true; + } else { + return false; + } + } else { + return true; + } + } else { + return false; + } + } + } + +} diff --git a/zend/library/Zend/Gdata/App/CaptchaRequiredException.php b/zend/library/Zend/Gdata/App/CaptchaRequiredException.php new file mode 100644 index 0000000..b09e668 --- /dev/null +++ b/zend/library/Zend/Gdata/App/CaptchaRequiredException.php @@ -0,0 +1,94 @@ +captchaToken = $captchaToken; + $this->captchaUrl = Zend_Gdata_App_CaptchaRequiredException::ACCOUNTS_URL . $captchaUrl; + parent::__construct('CAPTCHA challenge issued by server'); + } + + /** + * Retrieves the token identifier as provided by the server. + * + * @return string + */ + public function getCaptchaToken() { + return $this->captchaToken; + } + + /** + * Retrieves the URL CAPTCHA image as provided by the server. + * + * @return string + */ + public function getCaptchaUrl() { + return $this->captchaUrl; + } + +} diff --git a/zend/library/Zend/Gdata/App/Entry.php b/zend/library/Zend/Gdata/App/Entry.php new file mode 100644 index 0000000..1a24f3b --- /dev/null +++ b/zend/library/Zend/Gdata/App/Entry.php @@ -0,0 +1,389 @@ +_content != null) { + $element->appendChild($this->_content->getDOM($element->ownerDocument)); + } + if ($this->_published != null) { + $element->appendChild($this->_published->getDOM($element->ownerDocument)); + } + if ($this->_source != null) { + $element->appendChild($this->_source->getDOM($element->ownerDocument)); + } + if ($this->_summary != null) { + $element->appendChild($this->_summary->getDOM($element->ownerDocument)); + } + if ($this->_control != null) { + $element->appendChild($this->_control->getDOM($element->ownerDocument)); + } + if ($this->_edited != null) { + $element->appendChild($this->_edited->getDOM($element->ownerDocument)); + } + return $element; + } + + protected function takeChildFromDOM($child) + { + $absoluteNodeName = $child->namespaceURI . ':' . $child->localName; + switch ($absoluteNodeName) { + case $this->lookupNamespace('atom') . ':' . 'content': + $content = new Zend_Gdata_App_Extension_Content(); + $content->transferFromDOM($child); + $this->_content = $content; + break; + case $this->lookupNamespace('atom') . ':' . 'published': + $published = new Zend_Gdata_App_Extension_Published(); + $published->transferFromDOM($child); + $this->_published = $published; + break; + case $this->lookupNamespace('atom') . ':' . 'source': + $source = new Zend_Gdata_App_Extension_Source(); + $source->transferFromDOM($child); + $this->_source = $source; + break; + case $this->lookupNamespace('atom') . ':' . 'summary': + $summary = new Zend_Gdata_App_Extension_Summary(); + $summary->transferFromDOM($child); + $this->_summary = $summary; + break; + case $this->lookupNamespace('app') . ':' . 'control': + $control = new Zend_Gdata_App_Extension_Control(); + $control->transferFromDOM($child); + $this->_control = $control; + break; + case $this->lookupNamespace('app') . ':' . 'edited': + $edited = new Zend_Gdata_App_Extension_Edited(); + $edited->transferFromDOM($child); + $this->_edited = $edited; + break; + default: + parent::takeChildFromDOM($child); + break; + } + } + + /** + * Uploads changes in this entry to the server using Zend_Gdata_App + * + * @param string|null $uri The URI to send requests to, or null if $data + * contains the URI. + * @param string|null $className The name of the class that should we + * deserializing the server response. If null, then + * 'Zend_Gdata_App_Entry' will be used. + * @param array $extraHeaders Extra headers to add to the request, as an + * array of string-based key/value pairs. + * @return Zend_Gdata_App_Entry The updated entry. + * @throws Zend_Gdata_App_Exception + */ + public function save($uri = null, $className = null, $extraHeaders = array()) + { + return $this->getService()->updateEntry($this, + $uri, + $className, + $extraHeaders); + } + + /** + * Deletes this entry to the server using the referenced + * Zend_Http_Client to do a HTTP DELETE to the edit link stored in this + * entry's link collection. + * + * @return void + * @throws Zend_Gdata_App_Exception + */ + public function delete() + { + $this->getService()->delete($this); + } + + /** + * Reload the current entry. Returns a new copy of the entry as returned + * by the server, or null if no changes exist. This does not + * modify the current entry instance. + * + * @param string|null The URI to send requests to, or null if $data + * contains the URI. + * @param string|null The name of the class that should we deserializing + * the server response. If null, then 'Zend_Gdata_App_Entry' will + * be used. + * @param array $extraHeaders Extra headers to add to the request, as an + * array of string-based key/value pairs. + * @return mixed A new instance of the current entry with updated data, or + * null if the server reports that no changes have been made. + * @throws Zend_Gdata_App_Exception + */ + public function reload($uri = null, $className = null, $extraHeaders = array()) + { + // Get URI + $editLink = $this->getEditLink(); + if (($uri === null) && $editLink != null) { + $uri = $editLink->getHref(); + } + + // Set classname to current class, if not otherwise set + if ($className === null) { + $className = get_class($this); + } + + // Append ETag, if present (Gdata v2 and above, only) and doesn't + // conflict with existing headers + if ($this->_etag != null + && !array_key_exists('If-Match', $extraHeaders) + && !array_key_exists('If-None-Match', $extraHeaders)) { + $extraHeaders['If-None-Match'] = $this->_etag; + } + + // If an HTTP 304 status (Not Modified)is returned, then we return + // null. + $result = null; + try { + $result = $this->service->importUrl($uri, $className, $extraHeaders); + } catch (Zend_Gdata_App_HttpException $e) { + if ($e->getResponse()->getStatus() != '304') + throw $e; + } + + return $result; + } + + /** + * Gets the value of the atom:content element + * + * @return Zend_Gdata_App_Extension_Content + */ + public function getContent() + { + return $this->_content; + } + + /** + * Sets the value of the atom:content element + * + * @param Zend_Gdata_App_Extension_Content $value + * @return Zend_Gdata_App_Entry Provides a fluent interface + */ + public function setContent($value) + { + $this->_content = $value; + return $this; + } + + /** + * Sets the value of the atom:published element + * This represents the publishing date for an entry + * + * @return Zend_Gdata_App_Extension_Published + */ + public function getPublished() + { + return $this->_published; + } + + /** + * Sets the value of the atom:published element + * This represents the publishing date for an entry + * + * @param Zend_Gdata_App_Extension_Published $value + * @return Zend_Gdata_App_Entry Provides a fluent interface + */ + public function setPublished($value) + { + $this->_published = $value; + return $this; + } + + /** + * Gets the value of the atom:source element + * + * @return Zend_Gdata_App_Extension_Source + */ + public function getSource() + { + return $this->_source; + } + + /** + * Sets the value of the atom:source element + * + * @param Zend_Gdata_App_Extension_Source $value + * @return Zend_Gdata_App_Entry Provides a fluent interface + */ + public function setSource($value) + { + $this->_source = $value; + return $this; + } + + /** + * Gets the value of the atom:summary element + * This represents a textual summary of this entry's content + * + * @return Zend_Gdata_App_Extension_Summary + */ + public function getSummary() + { + return $this->_summary; + } + + /** + * Sets the value of the atom:summary element + * This represents a textual summary of this entry's content + * + * @param Zend_Gdata_App_Extension_Summary $value + * @return Zend_Gdata_App_Entry Provides a fluent interface + */ + public function setSummary($value) + { + $this->_summary = $value; + return $this; + } + + /** + * Gets the value of the app:control element + * + * @return Zend_Gdata_App_Extension_Control + */ + public function getControl() + { + return $this->_control; + } + + /** + * Sets the value of the app:control element + * + * @param Zend_Gdata_App_Extension_Control $value + * @return Zend_Gdata_App_Entry Provides a fluent interface + */ + public function setControl($value) + { + $this->_control = $value; + return $this; + } + +} diff --git a/zend/library/Zend/Gdata/App/Exception.php b/zend/library/Zend/Gdata/App/Exception.php new file mode 100644 index 0000000..bcfe255 --- /dev/null +++ b/zend/library/Zend/Gdata/App/Exception.php @@ -0,0 +1,43 @@ +_term = $term; + $this->_scheme = $scheme; + $this->_label = $label; + } + + public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null) + { + $element = parent::getDOM($doc, $majorVersion, $minorVersion); + if ($this->_term !== null) { + $element->setAttribute('term', $this->_term); + } + if ($this->_scheme !== null) { + $element->setAttribute('scheme', $this->_scheme); + } + if ($this->_label !== null) { + $element->setAttribute('label', $this->_label); + } + return $element; + } + + protected function takeAttributeFromDOM($attribute) + { + switch ($attribute->localName) { + case 'term': + $this->_term = $attribute->nodeValue; + break; + case 'scheme': + $this->_scheme = $attribute->nodeValue; + break; + case 'label': + $this->_label = $attribute->nodeValue; + break; + default: + parent::takeAttributeFromDOM($attribute); + } + } + + /** + * @return string|null + */ + public function getTerm() + { + return $this->_term; + } + + /** + * @param string|null $value + * @return Zend_Gdata_App_Extension_Category Provides a fluent interface + */ + public function setTerm($value) + { + $this->_term = $value; + return $this; + } + + /** + * @return string|null + */ + public function getScheme() + { + return $this->_scheme; + } + + /** + * @param string|null $value + * @return Zend_Gdata_App_Extension_Category Provides a fluent interface + */ + public function setScheme($value) + { + $this->_scheme = $value; + return $this; + } + + /** + * @return string|null + */ + public function getLabel() + { + return $this->_label; + } + + /** + * @param string|null $value + * @return Zend_Gdata_App_Extension_Category Provides a fluent interface + */ + public function setLabel($value) + { + $this->_label = $value; + return $this; + } + +} diff --git a/zend/library/Zend/Gdata/App/Extension/Content.php b/zend/library/Zend/Gdata/App/Extension/Content.php new file mode 100644 index 0000000..36ff99a --- /dev/null +++ b/zend/library/Zend/Gdata/App/Extension/Content.php @@ -0,0 +1,88 @@ +_src = $src; + } + + public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null) + { + $element = parent::getDOM($doc, $majorVersion, $minorVersion); + if ($this->_src !== null) { + $element->setAttribute('src', $this->_src); + } + return $element; + } + + protected function takeAttributeFromDOM($attribute) + { + switch ($attribute->localName) { + case 'src': + $this->_src = $attribute->nodeValue; + break; + default: + parent::takeAttributeFromDOM($attribute); + } + } + + /** + * @return string + */ + public function getSrc() + { + return $this->_src; + } + + /** + * @param string $value + * @return Zend_Gdata_App_Entry Provides a fluent interface + */ + public function setSrc($value) + { + $this->_src = $value; + return $this; + } + +} diff --git a/zend/library/Zend/Gdata/App/Extension/Contributor.php b/zend/library/Zend/Gdata/App/Extension/Contributor.php new file mode 100644 index 0000000..7f5f1c5 --- /dev/null +++ b/zend/library/Zend/Gdata/App/Extension/Contributor.php @@ -0,0 +1,43 @@ +_draft = $draft; + } + + public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null) + { + $element = parent::getDOM($doc, $majorVersion, $minorVersion); + if ($this->_draft != null) { + $element->appendChild($this->_draft->getDOM($element->ownerDocument)); + } + return $element; + } + + protected function takeChildFromDOM($child) + { + $absoluteNodeName = $child->namespaceURI . ':' . $child->localName; + switch ($absoluteNodeName) { + case $this->lookupNamespace('app') . ':' . 'draft': + $draft = new Zend_Gdata_App_Extension_Draft(); + $draft->transferFromDOM($child); + $this->_draft = $draft; + break; + default: + parent::takeChildFromDOM($child); + break; + } + } + + /** + * @return Zend_Gdata_App_Extension_Draft + */ + public function getDraft() + { + return $this->_draft; + } + + /** + * @param Zend_Gdata_App_Extension_Draft $value + * @return Zend_Gdata_App_Entry Provides a fluent interface + */ + public function setDraft($value) + { + $this->_draft = $value; + return $this; + } + +} diff --git a/zend/library/Zend/Gdata/App/Extension/Draft.php b/zend/library/Zend/Gdata/App/Extension/Draft.php new file mode 100644 index 0000000..62a91ea --- /dev/null +++ b/zend/library/Zend/Gdata/App/Extension/Draft.php @@ -0,0 +1,50 @@ +_text = $text; + } + +} diff --git a/zend/library/Zend/Gdata/App/Extension/Edited.php b/zend/library/Zend/Gdata/App/Extension/Edited.php new file mode 100644 index 0000000..1a3a74a --- /dev/null +++ b/zend/library/Zend/Gdata/App/Extension/Edited.php @@ -0,0 +1,49 @@ +_text = $text; + } + +} diff --git a/zend/library/Zend/Gdata/App/Extension/Element.php b/zend/library/Zend/Gdata/App/Extension/Element.php new file mode 100644 index 0000000..f473d90 --- /dev/null +++ b/zend/library/Zend/Gdata/App/Extension/Element.php @@ -0,0 +1,58 @@ +_rootElement = $rootElement; + $this->_rootNamespace = $rootNamespace; + $this->_rootNamespaceURI = $rootNamespaceURI; + $this->_text = $text; + } + + public function transferFromDOM($node) + { + parent::transferFromDOM($node); + $this->_rootNamespace = null; + $this->_rootNamespaceURI = $node->namespaceURI; + $this->_rootElement = $node->localName; + } + +} diff --git a/zend/library/Zend/Gdata/App/Extension/Email.php b/zend/library/Zend/Gdata/App/Extension/Email.php new file mode 100644 index 0000000..48fdb4d --- /dev/null +++ b/zend/library/Zend/Gdata/App/Extension/Email.php @@ -0,0 +1,49 @@ +_text = $text; + } + +} diff --git a/zend/library/Zend/Gdata/App/Extension/Generator.php b/zend/library/Zend/Gdata/App/Extension/Generator.php new file mode 100644 index 0000000..2f521d6 --- /dev/null +++ b/zend/library/Zend/Gdata/App/Extension/Generator.php @@ -0,0 +1,115 @@ +_text = $text; + $this->_uri = $uri; + $this->_version = $version; + } + + public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null) + { + $element = parent::getDOM($doc, $majorVersion, $minorVersion); + if ($this->_uri !== null) { + $element->setAttribute('uri', $this->_uri); + } + if ($this->_version !== null) { + $element->setAttribute('version', $this->_version); + } + return $element; + } + + protected function takeAttributeFromDOM($attribute) + { + switch ($attribute->localName) { + case 'uri': + $this->_uri = $attribute->nodeValue; + break; + case 'version': + $this->_version= $attribute->nodeValue; + break; + default: + parent::takeAttributeFromDOM($attribute); + } + } + + /** + * @return Zend_Gdata_App_Extension_Uri + */ + public function getUri() + { + return $this->_uri; + } + + /** + * @param Zend_Gdata_App_Extension_Uri $value + * @return Zend_Gdata_App_Entry Provides a fluent interface + */ + public function setUri($value) + { + $this->_uri = $value; + return $this; + } + + /** + * @return Zend_Gdata_App_Extension_Version + */ + public function getVersion() + { + return $this->_version; + } + + /** + * @param Zend_Gdata_App_Extension_Version $value + * @return Zend_Gdata_App_Entry Provides a fluent interface + */ + public function setVersion($value) + { + $this->_version = $value; + return $this; + } + +} diff --git a/zend/library/Zend/Gdata/App/Extension/Icon.php b/zend/library/Zend/Gdata/App/Extension/Icon.php new file mode 100644 index 0000000..3e55cbb --- /dev/null +++ b/zend/library/Zend/Gdata/App/Extension/Icon.php @@ -0,0 +1,49 @@ +_text = $text; + } + +} diff --git a/zend/library/Zend/Gdata/App/Extension/Id.php b/zend/library/Zend/Gdata/App/Extension/Id.php new file mode 100644 index 0000000..bdac0cd --- /dev/null +++ b/zend/library/Zend/Gdata/App/Extension/Id.php @@ -0,0 +1,49 @@ +_text = $text; + } + +} diff --git a/zend/library/Zend/Gdata/App/Extension/Link.php b/zend/library/Zend/Gdata/App/Extension/Link.php new file mode 100644 index 0000000..ee76700 --- /dev/null +++ b/zend/library/Zend/Gdata/App/Extension/Link.php @@ -0,0 +1,219 @@ +_href = $href; + $this->_rel = $rel; + $this->_type = $type; + $this->_hrefLang = $hrefLang; + $this->_title = $title; + $this->_length = $length; + } + + public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null) + { + $element = parent::getDOM($doc, $majorVersion, $minorVersion); + if ($this->_href !== null) { + $element->setAttribute('href', $this->_href); + } + if ($this->_rel !== null) { + $element->setAttribute('rel', $this->_rel); + } + if ($this->_type !== null) { + $element->setAttribute('type', $this->_type); + } + if ($this->_hrefLang !== null) { + $element->setAttribute('hreflang', $this->_hrefLang); + } + if ($this->_title !== null) { + $element->setAttribute('title', $this->_title); + } + if ($this->_length !== null) { + $element->setAttribute('length', $this->_length); + } + return $element; + } + + protected function takeAttributeFromDOM($attribute) + { + switch ($attribute->localName) { + case 'href': + $this->_href = $attribute->nodeValue; + break; + case 'rel': + $this->_rel = $attribute->nodeValue; + break; + case 'type': + $this->_type = $attribute->nodeValue; + break; + case 'hreflang': + $this->_hrefLang = $attribute->nodeValue; + break; + case 'title': + $this->_title = $attribute->nodeValue; + break; + case 'length': + $this->_length = $attribute->nodeValue; + break; + default: + parent::takeAttributeFromDOM($attribute); + } + } + + /** + * @return string|null + */ + public function getHref() + { + return $this->_href; + } + + /** + * @param string|null $value + * @return Zend_Gdata_App_Entry Provides a fluent interface + */ + public function setHref($value) + { + $this->_href = $value; + return $this; + } + + /** + * @return string|null + */ + public function getRel() + { + return $this->_rel; + } + + /** + * @param string|null $value + * @return Zend_Gdata_App_Entry Provides a fluent interface + */ + public function setRel($value) + { + $this->_rel = $value; + return $this; + } + + /** + * @return string|null + */ + public function getType() + { + return $this->_type; + } + + /** + * @param string|null $value + * @return Zend_Gdata_App_Entry Provides a fluent interface + */ + public function setType($value) + { + $this->_type = $value; + return $this; + } + + /** + * @return string|null + */ + public function getHrefLang() + { + return $this->_hrefLang; + } + + /** + * @param string|null $value + * @return Zend_Gdata_App_Entry Provides a fluent interface + */ + public function setHrefLang($value) + { + $this->_hrefLang = $value; + return $this; + } + + /** + * @return string|null + */ + public function getTitle() + { + return $this->_title; + } + + /** + * @param string|null $value + * @return Zend_Gdata_App_Entry Provides a fluent interface + */ + public function setTitle($value) + { + $this->_title = $value; + return $this; + } + + /** + * @return string|null + */ + public function getLength() + { + return $this->_length; + } + + /** + * @param string|null $value + * @return Zend_Gdata_App_Entry Provides a fluent interface + */ + public function setLength($value) + { + $this->_length = $value; + return $this; + } + +} diff --git a/zend/library/Zend/Gdata/App/Extension/Logo.php b/zend/library/Zend/Gdata/App/Extension/Logo.php new file mode 100644 index 0000000..956f2f4 --- /dev/null +++ b/zend/library/Zend/Gdata/App/Extension/Logo.php @@ -0,0 +1,49 @@ +_text = $text; + } + +} diff --git a/zend/library/Zend/Gdata/App/Extension/Name.php b/zend/library/Zend/Gdata/App/Extension/Name.php new file mode 100644 index 0000000..c851028 --- /dev/null +++ b/zend/library/Zend/Gdata/App/Extension/Name.php @@ -0,0 +1,48 @@ +_text = $text; + } +} diff --git a/zend/library/Zend/Gdata/App/Extension/Person.php b/zend/library/Zend/Gdata/App/Extension/Person.php new file mode 100644 index 0000000..7f5c2bf --- /dev/null +++ b/zend/library/Zend/Gdata/App/Extension/Person.php @@ -0,0 +1,163 @@ +_name = $name; + $this->_email = $email; + $this->_uri = $uri; + } + + public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null) + { + $element = parent::getDOM($doc, $majorVersion, $minorVersion); + if ($this->_name != null) { + $element->appendChild($this->_name->getDOM($element->ownerDocument)); + } + if ($this->_email != null) { + $element->appendChild($this->_email->getDOM($element->ownerDocument)); + } + if ($this->_uri != null) { + $element->appendChild($this->_uri->getDOM($element->ownerDocument)); + } + return $element; + } + + protected function takeChildFromDOM($child) + { + $absoluteNodeName = $child->namespaceURI . ':' . $child->localName; + switch ($absoluteNodeName) { + case $this->lookupNamespace('atom') . ':' . 'name': + $name = new Zend_Gdata_App_Extension_Name(); + $name->transferFromDOM($child); + $this->_name = $name; + break; + case $this->lookupNamespace('atom') . ':' . 'email': + $email = new Zend_Gdata_App_Extension_Email(); + $email->transferFromDOM($child); + $this->_email = $email; + break; + case $this->lookupNamespace('atom') . ':' . 'uri': + $uri = new Zend_Gdata_App_Extension_Uri(); + $uri->transferFromDOM($child); + $this->_uri = $uri; + break; + default: + parent::takeChildFromDOM($child); + break; + } + } + + /** + * @return Zend_Gdata_App_Extension_Name + */ + public function getName() + { + return $this->_name; + } + + /** + * @param Zend_Gdata_App_Extension_Name $value + * @return Zend_Gdata_App_Entry Provides a fluent interface + */ + public function setName($value) + { + $this->_name = $value; + return $this; + } + + /** + * @return Zend_Gdata_App_Extension_Email + */ + public function getEmail() + { + return $this->_email; + } + + /** + * @param Zend_Gdata_App_Extension_Email $value + * @return Zend_Gdata_App_Extension_Person Provides a fluent interface + */ + public function setEmail($value) + { + $this->_email = $value; + return $this; + } + + /** + * @return Zend_Gdata_App_Extension_Uri + */ + public function getUri() + { + return $this->_uri; + } + + /** + * @param Zend_Gdata_App_Extension_Uri $value + * @return Zend_Gdata_App_Extension_Person Provides a fluent interface + */ + public function setUri($value) + { + $this->_uri = $value; + return $this; + } + +} diff --git a/zend/library/Zend/Gdata/App/Extension/Published.php b/zend/library/Zend/Gdata/App/Extension/Published.php new file mode 100644 index 0000000..2442284 --- /dev/null +++ b/zend/library/Zend/Gdata/App/Extension/Published.php @@ -0,0 +1,49 @@ +_text = $text; + } + +} diff --git a/zend/library/Zend/Gdata/App/Extension/Rights.php b/zend/library/Zend/Gdata/App/Extension/Rights.php new file mode 100644 index 0000000..d8a5a39 --- /dev/null +++ b/zend/library/Zend/Gdata/App/Extension/Rights.php @@ -0,0 +1,49 @@ +_text = $text; + } + +} diff --git a/zend/library/Zend/Gdata/App/Extension/Source.php b/zend/library/Zend/Gdata/App/Extension/Source.php new file mode 100644 index 0000000..1779c17 --- /dev/null +++ b/zend/library/Zend/Gdata/App/Extension/Source.php @@ -0,0 +1,46 @@ +_text = $text; + $this->_type = $type; + } + + public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null) + { + $element = parent::getDOM($doc, $majorVersion, $minorVersion); + if ($this->_type !== null) { + $element->setAttribute('type', $this->_type); + } + return $element; + } + + protected function takeAttributeFromDOM($attribute) + { + switch ($attribute->localName) { + case 'type': + $this->_type = $attribute->nodeValue; + break; + default: + parent::takeAttributeFromDOM($attribute); + } + } + + /* + * @return Zend_Gdata_App_Extension_Type + */ + public function getType() + { + return $this->_type; + } + + /* + * @param string $value + * @return Zend_Gdata_App_Extension_Text Provides a fluent interface + */ + public function setType($value) + { + $this->_type = $value; + return $this; + } + +} diff --git a/zend/library/Zend/Gdata/App/Extension/Title.php b/zend/library/Zend/Gdata/App/Extension/Title.php new file mode 100644 index 0000000..69899bb --- /dev/null +++ b/zend/library/Zend/Gdata/App/Extension/Title.php @@ -0,0 +1,43 @@ +_text = $text; + } + +} diff --git a/zend/library/Zend/Gdata/App/Extension/Uri.php b/zend/library/Zend/Gdata/App/Extension/Uri.php new file mode 100644 index 0000000..2168b1a --- /dev/null +++ b/zend/library/Zend/Gdata/App/Extension/Uri.php @@ -0,0 +1,49 @@ +_text = $text; + } + +} diff --git a/zend/library/Zend/Gdata/App/Feed.php b/zend/library/Zend/Gdata/App/Feed.php new file mode 100755 index 0000000..1f8ef84 --- /dev/null +++ b/zend/library/Zend/Gdata/App/Feed.php @@ -0,0 +1,352 @@ +entries as $entry) or foreach + * ($feed->entry as $entry). + * + * @param string $var The property to get. + * @return mixed + */ + public function __get($var) + { + switch ($var) { + case 'entries': + return $this; + default: + return parent::__get($var); + } + } + + /** + * Retrieves the DOM model representing this object and all children + * + * @param DOMDocument $doc + * @return DOMElement + */ + public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null) + { + $element = parent::getDOM($doc, $majorVersion, $minorVersion); + foreach ($this->_entry as $entry) { + $element->appendChild($entry->getDOM($element->ownerDocument)); + } + return $element; + } + + /** + * Creates individual Entry objects of the appropriate type and + * stores them in the $_entry array based upon DOM data. + * + * @param DOMNode $child The DOMNode to process + */ + protected function takeChildFromDOM($child) + { + $absoluteNodeName = $child->namespaceURI . ':' . $child->localName; + switch ($absoluteNodeName) { + case $this->lookupNamespace('atom') . ':' . 'entry': + $newEntry = new $this->_entryClassName($child); + $newEntry->setHttpClient($this->getHttpClient()); + $newEntry->setMajorProtocolVersion($this->getMajorProtocolVersion()); + $newEntry->setMinorProtocolVersion($this->getMinorProtocolVersion()); + $this->_entry[] = $newEntry; + break; + default: + parent::takeChildFromDOM($child); + break; + } + } + + /** + * Get the number of entries in this feed object. + * + * @return integer Entry count. + */ + public function count() + { + return count($this->_entry); + } + + /** + * Required by the Iterator interface. + * + * @return void + */ + public function rewind() + { + $this->_entryIndex = 0; + } + + /** + * Required by the Iterator interface. + * + * @return mixed The current row, or null if no rows. + */ + public function current() + { + return $this->_entry[$this->_entryIndex]; + } + + /** + * Required by the Iterator interface. + * + * @return mixed The current row number (starts at 0), or NULL if no rows + */ + public function key() + { + return $this->_entryIndex; + } + + /** + * Required by the Iterator interface. + * + * @return mixed The next row, or null if no more rows. + */ + public function next() + { + ++$this->_entryIndex; + } + + /** + * Required by the Iterator interface. + * + * @return boolean Whether the iteration is valid + */ + public function valid() + { + return 0 <= $this->_entryIndex && $this->_entryIndex < $this->count(); + } + + /** + * Gets the array of atom:entry elements contained within this + * atom:feed representation + * + * @return array Zend_Gdata_App_Entry array + */ + public function getEntry() + { + return $this->_entry; + } + + /** + * Sets the array of atom:entry elements contained within this + * atom:feed representation + * + * @param array $value The array of Zend_Gdata_App_Entry elements + * @return Zend_Gdata_App_Feed Provides a fluent interface + */ + public function setEntry($value) + { + $this->_entry = $value; + return $this; + } + + /** + * Adds an entry representation to the array of entries + * contained within this feed + * + * @param Zend_Gdata_App_Entry An individual entry to add. + * @return Zend_Gdata_App_Feed Provides a fluent interface + */ + public function addEntry($value) + { + $this->_entry[] = $value; + return $this; + } + + /** + * Required by the ArrayAccess interface + * + * @param int $key The index to set + * @param Zend_Gdata_App_Entry $value The value to set + * @return void + */ + public function offsetSet($key, $value) + { + $this->_entry[$key] = $value; + } + + /** + * Required by the ArrayAccess interface + * + * @param int $key The index to get + * @param Zend_Gdata_App_Entry $value The value to set + */ + public function offsetGet($key) + { + if (array_key_exists($key, $this->_entry)) { + return $this->_entry[$key]; + } + } + + /** + * Required by the ArrayAccess interface + * + * @param int $key The index to set + * @param Zend_Gdata_App_Entry $value The value to set + */ + public function offsetUnset($key) + { + if (array_key_exists($key, $this->_entry)) { + unset($this->_entry[$key]); + } + } + + /** + * Required by the ArrayAccess interface + * + * @param int $key The index to check for existence + * @return boolean + */ + public function offsetExists($key) + { + return (array_key_exists($key, $this->_entry)); + } + + /** + * Retrieve the next set of results from this feed. + * + * @throws Zend_Gdata_App_Exception + * @return mixed|null Returns the next set of results as a feed of the same + * class as this feed, or null if no results exist. + */ + public function getNextFeed() + { + $nextLink = $this->getNextLink(); + if (!$nextLink) { + require_once 'Zend/Gdata/App/HttpException.php'; + throw new Zend_Gdata_App_Exception('No link to next set ' . + 'of results found.'); + } + $nextLinkHref = $nextLink->getHref(); + $service = new Zend_Gdata_App($this->getHttpClient()); + + return $service->getFeed($nextLinkHref, get_class($this)); + } + + /** + * Retrieve the previous set of results from this feed. + * + * @throws Zend_Gdata_App_Exception + * @return mixed|null Returns the previous set of results as a feed of + * the same class as this feed, or null if no results exist. + */ + public function getPreviousFeed() + { + $previousLink = $this->getPreviousLink(); + if (!$previousLink) { + require_once 'Zend/Gdata/App/HttpException.php'; + throw new Zend_Gdata_App_Exception('No link to previous set ' . + 'of results found.'); + } + $previousLinkHref = $previousLink->getHref(); + $service = new Zend_Gdata_App($this->getHttpClient()); + + return $service->getFeed($previousLinkHref, get_class($this)); + } + + /** + * Set the major protocol version that should be used. Values < 1 will + * cause a Zend_Gdata_App_InvalidArgumentException to be thrown. + * + * This value will be propogated to all child entries. + * + * @see _majorProtocolVersion + * @param (int|NULL) $value The major protocol version to use. + * @throws Zend_Gdata_App_InvalidArgumentException + */ + public function setMajorProtocolVersion($value) + { + parent::setMajorProtocolVersion($value); + foreach ($this->entries as $entry) { + $entry->setMajorProtocolVersion($value); + } + } + + /** + * Set the minor protocol version that should be used. If set to NULL, no + * minor protocol version will be sent to the server. Values < 0 will + * cause a Zend_Gdata_App_InvalidArgumentException to be thrown. + * + * This value will be propogated to all child entries. + * + * @see _minorProtocolVersion + * @param (int|NULL) $value The minor protocol version to use. + * @throws Zend_Gdata_App_InvalidArgumentException + */ + public function setMinorProtocolVersion($value) + { + parent::setMinorProtocolVersion($value); + foreach ($this->entries as $entry) { + $entry->setMinorProtocolVersion($value); + } + } + +} diff --git a/zend/library/Zend/Gdata/App/FeedEntryParent.php b/zend/library/Zend/Gdata/App/FeedEntryParent.php new file mode 100755 index 0000000..51ff913 --- /dev/null +++ b/zend/library/Zend/Gdata/App/FeedEntryParent.php @@ -0,0 +1,681 @@ += 1 is considered valid. + * + * @see setMajorProtocolVersion() + * @see getMajorProtocolVersion() + */ + protected $_majorProtocolVersion = 1; + + /** + * Indicates the minor protocol version that should be used. Can be set + * to either an integer >= 0, or NULL if no minor version should be sent + * to the server. + * + * @see setMinorProtocolVersion() + * @see getMinorProtocolVersion() + */ + protected $_minorProtocolVersion = null; + + /** + * Constructs a Feed or Entry + */ + public function __construct($element = null) + { + if (!($element instanceof DOMElement)) { + if ($element) { + $this->transferFromXML($element); + } + } else { + $this->transferFromDOM($element); + } + } + + /** + * Set the HTTP client instance + * + * Sets the HTTP client object to use for retrieving the feed. + * + * @deprecated Deprecated as of Zend Framework 1.7. Use + * setService() instead. + * @param Zend_Http_Client $httpClient + * @return Zend_Gdata_App_FeedEntryParent Provides a fluent interface + */ + public function setHttpClient(Zend_Http_Client $httpClient) + { + if (!$this->_service) { + $this->_service = new Zend_Gdata_App(); + } + $this->_service->setHttpClient($httpClient); + return $this; + } + + /** + * Gets the HTTP client object. If none is set, a new Zend_Http_Client + * will be used. + * + * @deprecated Deprecated as of Zend Framework 1.7. Use + * getService() instead. + * @return Zend_Http_Client_Abstract + */ + public function getHttpClient() + { + if (!$this->_service) { + $this->_service = new Zend_Gdata_App(); + } + $client = $this->_service->getHttpClient(); + return $client; + } + + /** + * Set the active service instance for this object. This will be used to + * perform network requests, such as when calling save() and delete(). + * + * @param Zend_Gdata_App $instance The new service instance. + * @return Zend_Gdata_App_FeedEntryParent Provides a fluent interface. + */ + public function setService($instance) + { + $this->_service = $instance; + return $this; + } + + /** + * Get the active service instance for this object. This will be used to + * perform network requests, such as when calling save() and delete(). + * + * @return Zend_Gdata_App|null The current service instance, or null if + * not set. + */ + public function getService() + { + return $this->_service; + } + + public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null) + { + $element = parent::getDOM($doc, $majorVersion, $minorVersion); + foreach ($this->_author as $author) { + $element->appendChild($author->getDOM($element->ownerDocument)); + } + foreach ($this->_category as $category) { + $element->appendChild($category->getDOM($element->ownerDocument)); + } + foreach ($this->_contributor as $contributor) { + $element->appendChild($contributor->getDOM($element->ownerDocument)); + } + if ($this->_id != null) { + $element->appendChild($this->_id->getDOM($element->ownerDocument)); + } + foreach ($this->_link as $link) { + $element->appendChild($link->getDOM($element->ownerDocument)); + } + if ($this->_rights != null) { + $element->appendChild($this->_rights->getDOM($element->ownerDocument)); + } + if ($this->_title != null) { + $element->appendChild($this->_title->getDOM($element->ownerDocument)); + } + if ($this->_updated != null) { + $element->appendChild($this->_updated->getDOM($element->ownerDocument)); + } + return $element; + } + + protected function takeChildFromDOM($child) + { + $absoluteNodeName = $child->namespaceURI . ':' . $child->localName; + switch ($absoluteNodeName) { + case $this->lookupNamespace('atom') . ':' . 'author': + $author = new Zend_Gdata_App_Extension_Author(); + $author->transferFromDOM($child); + $this->_author[] = $author; + break; + case $this->lookupNamespace('atom') . ':' . 'category': + $category = new Zend_Gdata_App_Extension_Category(); + $category->transferFromDOM($child); + $this->_category[] = $category; + break; + case $this->lookupNamespace('atom') . ':' . 'contributor': + $contributor = new Zend_Gdata_App_Extension_Contributor(); + $contributor->transferFromDOM($child); + $this->_contributor[] = $contributor; + break; + case $this->lookupNamespace('atom') . ':' . 'id': + $id = new Zend_Gdata_App_Extension_Id(); + $id->transferFromDOM($child); + $this->_id = $id; + break; + case $this->lookupNamespace('atom') . ':' . 'link': + $link = new Zend_Gdata_App_Extension_Link(); + $link->transferFromDOM($child); + $this->_link[] = $link; + break; + case $this->lookupNamespace('atom') . ':' . 'rights': + $rights = new Zend_Gdata_App_Extension_Rights(); + $rights->transferFromDOM($child); + $this->_rights = $rights; + break; + case $this->lookupNamespace('atom') . ':' . 'title': + $title = new Zend_Gdata_App_Extension_Title(); + $title->transferFromDOM($child); + $this->_title = $title; + break; + case $this->lookupNamespace('atom') . ':' . 'updated': + $updated = new Zend_Gdata_App_Extension_Updated(); + $updated->transferFromDOM($child); + $this->_updated = $updated; + break; + default: + parent::takeChildFromDOM($child); + break; + } + } + + /** + * @return Zend_Gdata_App_Extension_Author + */ + public function getAuthor() + { + return $this->_author; + } + + /** + * Sets the list of the authors of this feed/entry. In an atom feed, each + * author is represented by an atom:author element + * + * @param array $value + * @return Zend_Gdata_App_FeedEntryParent Provides a fluent interface + */ + public function setAuthor($value) + { + $this->_author = $value; + return $this; + } + + /** + * Returns the array of categories that classify this feed/entry. Each + * category is represented in an atom feed by an atom:category element. + * + * @return array Array of Zend_Gdata_App_Extension_Category + */ + public function getCategory() + { + return $this->_category; + } + + /** + * Sets the array of categories that classify this feed/entry. Each + * category is represented in an atom feed by an atom:category element. + * + * @param array $value Array of Zend_Gdata_App_Extension_Category + * @return Zend_Gdata_App_FeedEntryParent Provides a fluent interface + */ + public function setCategory($value) + { + $this->_category = $value; + return $this; + } + + /** + * Returns the array of contributors to this feed/entry. Each contributor + * is represented in an atom feed by an atom:contributor XML element + * + * @return array An array of Zend_Gdata_App_Extension_Contributor + */ + public function getContributor() + { + return $this->_contributor; + } + + /** + * Sets the array of contributors to this feed/entry. Each contributor + * is represented in an atom feed by an atom:contributor XML element + * + * @param array $value + * @return Zend_Gdata_App_FeedEntryParent Provides a fluent interface + */ + public function setContributor($value) + { + $this->_contributor = $value; + return $this; + } + + /** + * @return Zend_Gdata_App_Extension_Id + */ + public function getId() + { + return $this->_id; + } + + /** + * @param Zend_Gdata_App_Extension_Id $value + * @return Zend_Gdata_App_FeedEntryParent Provides a fluent interface + */ + public function setId($value) + { + $this->_id = $value; + return $this; + } + + /** + * Given a particular 'rel' value, this method returns a matching + * Zend_Gdata_App_Extension_Link element. If the 'rel' value + * is not provided, the full array of Zend_Gdata_App_Extension_Link + * elements is returned. In an atom feed, each link is represented + * by an atom:link element. The 'rel' value passed to this function + * is the atom:link/@rel attribute. Example rel values include 'self', + * 'edit', and 'alternate'. + * + * @param string $rel The rel value of the link to be found. If null, + * the array of Zend_Gdata_App_Extension_link elements is returned + * @return mixed Either a single Zend_Gdata_App_Extension_link element, + * an array of the same or null is returned depending on the rel value + * supplied as the argument to this function + */ + public function getLink($rel = null) + { + if ($rel == null) { + return $this->_link; + } else { + foreach ($this->_link as $link) { + if ($link->rel == $rel) { + return $link; + } + } + return null; + } + } + + /** + * Returns the Zend_Gdata_App_Extension_Link element which represents + * the URL used to edit this resource. This link is in the atom feed/entry + * as an atom:link with a rel attribute value of 'edit'. + * + * @return Zend_Gdata_App_Extension_Link The link, or null if not found + */ + public function getEditLink() + { + return $this->getLink('edit'); + } + + /** + * Returns the Zend_Gdata_App_Extension_Link element which represents + * the URL used to retrieve the next chunk of results when paging through + * a feed. This link is in the atom feed as an atom:link with a + * rel attribute value of 'next'. + * + * @return Zend_Gdata_App_Extension_Link The link, or null if not found + */ + public function getNextLink() + { + return $this->getLink('next'); + } + + /** + * Returns the Zend_Gdata_App_Extension_Link element which represents + * the URL used to retrieve the previous chunk of results when paging + * through a feed. This link is in the atom feed as an atom:link with a + * rel attribute value of 'previous'. + * + * @return Zend_Gdata_App_Extension_Link The link, or null if not found + */ + public function getPreviousLink() + { + return $this->getLink('previous'); + } + + /** + * @return Zend_Gdata_App_Extension_Link + */ + public function getLicenseLink() + { + return $this->getLink('license'); + } + + /** + * Returns the Zend_Gdata_App_Extension_Link element which represents + * the URL used to retrieve the entry or feed represented by this object + * This link is in the atom feed/entry as an atom:link with a + * rel attribute value of 'self'. + * + * @return Zend_Gdata_App_Extension_Link The link, or null if not found + */ + public function getSelfLink() + { + return $this->getLink('self'); + } + + /** + * Returns the Zend_Gdata_App_Extension_Link element which represents + * the URL for an alternate view of the data represented by this feed or + * entry. This alternate view is commonly a user-facing webpage, blog + * post, etc. The MIME type for the data at the URL is available from the + * returned Zend_Gdata_App_Extension_Link element. + * This link is in the atom feed/entry as an atom:link with a + * rel attribute value of 'self'. + * + * @return Zend_Gdata_App_Extension_Link The link, or null if not found + */ + public function getAlternateLink() + { + return $this->getLink('alternate'); + } + + /** + * @param array $value The array of Zend_Gdata_App_Extension_Link elements + * @return Zend_Gdata_App_FeedEntryParent Provides a fluent interface + */ + public function setLink($value) + { + $this->_link = $value; + return $this; + } + + /** + * @return Zend_Gdata_AppExtension_Rights + */ + public function getRights() + { + return $this->_rights; + } + + /** + * @param Zend_Gdata_App_Extension_Rights $value + * @return Zend_Gdata_App_FeedEntryParent Provides a fluent interface + */ + public function setRights($value) + { + $this->_rights = $value; + return $this; + } + + /** + * Returns the title of this feed or entry. The title is an extremely + * short textual representation of this resource and is found as + * an atom:title element in a feed or entry + * + * @return Zend_Gdata_App_Extension_Title + */ + public function getTitle() + { + return $this->_title; + } + + /** + * Returns a string representation of the title of this feed or entry. + * The title is an extremely short textual representation of this + * resource and is found as an atom:title element in a feed or entry + * + * @return string + */ + public function getTitleValue() + { + if (($titleObj = $this->getTitle()) != null) { + return $titleObj->getText(); + } else { + return null; + } + } + + /** + * Returns the title of this feed or entry. The title is an extremely + * short textual representation of this resource and is found as + * an atom:title element in a feed or entry + * + * @param Zend_Gdata_App_Extension_Title $value + * @return Zend_Gdata_App_FeedEntryParent Provides a fluent interface + */ + public function setTitle($value) + { + $this->_title = $value; + return $this; + } + + /** + * @return Zend_Gdata_App_Extension_Updated + */ + public function getUpdated() + { + return $this->_updated; + } + + /** + * @param Zend_Gdata_App_Extension_Updated $value + * @return Zend_Gdata_App_FeedEntryParent Provides a fluent interface + */ + public function setUpdated($value) + { + $this->_updated = $value; + return $this; + } + + /** + * Set the Etag for the current entry to $value. Setting $value to null + * unsets the Etag. + * + * @param string|null $value + * @return Zend_Gdata_App_Entry Provides a fluent interface + */ + public function setEtag($value) { + $this->_etag = $value; + return $this; + } + + /** + * Return the Etag for the current entry, or null if not set. + * + * @return string|null + */ + public function getEtag() { + return $this->_etag; + } + + /** + * Set the major protocol version that should be used. Values < 1 + * (excluding NULL) will cause a Zend_Gdata_App_InvalidArgumentException + * to be thrown. + * + * @see _majorProtocolVersion + * @param (int|NULL) $value The major protocol version to use. + * @throws Zend_Gdata_App_InvalidArgumentException + */ + public function setMajorProtocolVersion($value) + { + if (!($value >= 1) && ($value !== null)) { + require_once('Zend/Gdata/App/InvalidArgumentException.php'); + throw new Zend_Gdata_App_InvalidArgumentException( + 'Major protocol version must be >= 1'); + } + $this->_majorProtocolVersion = $value; + } + + /** + * Get the major protocol version that is in use. + * + * @see _majorProtocolVersion + * @return (int|NULL) The major protocol version in use. + */ + public function getMajorProtocolVersion() + { + return $this->_majorProtocolVersion; + } + + /** + * Set the minor protocol version that should be used. If set to NULL, no + * minor protocol version will be sent to the server. Values < 0 will + * cause a Zend_Gdata_App_InvalidArgumentException to be thrown. + * + * @see _minorProtocolVersion + * @param (int|NULL) $value The minor protocol version to use. + * @throws Zend_Gdata_App_InvalidArgumentException + */ + public function setMinorProtocolVersion($value) + { + if (!($value >= 0)) { + require_once('Zend/Gdata/App/InvalidArgumentException.php'); + throw new Zend_Gdata_App_InvalidArgumentException( + 'Minor protocol version must be >= 0 or null'); + } + $this->_minorProtocolVersion = $value; + } + + /** + * Get the minor protocol version that is in use. + * + * @see _minorProtocolVersion + * @return (int|NULL) The major protocol version in use, or NULL if no + * minor version is specified. + */ + public function getMinorProtocolVersion() + { + return $this->_minorProtocolVersion; + } + + /** + * Get the full version of a namespace prefix + * + * Looks up a prefix (atom:, etc.) in the list of registered + * namespaces and returns the full namespace URI if + * available. Returns the prefix, unmodified, if it's not + * registered. + * + * The current entry or feed's version will be used when performing the + * namespace lookup unless overridden using $majorVersion and + * $minorVersion. If the entry/fee has a null version, then the latest + * protocol version will be used by default. + * + * @param string $prefix The namespace prefix to lookup. + * @param integer $majorVersion The major protocol version in effect. + * Defaults to null (auto-select). + * @param integer $minorVersion The minor protocol version in effect. + * Defaults to null (auto-select). + * @return string + */ + public function lookupNamespace($prefix, + $majorVersion = null, + $minorVersion = null) + { + // Auto-select current version + if ($majorVersion === null) { + $majorVersion = $this->getMajorProtocolVersion(); + } + if ($minorVersion === null) { + $minorVersion = $this->getMinorProtocolVersion(); + } + + // Perform lookup + return parent::lookupNamespace($prefix, $majorVersion, $minorVersion); + } + +} diff --git a/zend/library/Zend/Gdata/App/FeedSourceParent.php b/zend/library/Zend/Gdata/App/FeedSourceParent.php new file mode 100644 index 0000000..e61e41d --- /dev/null +++ b/zend/library/Zend/Gdata/App/FeedSourceParent.php @@ -0,0 +1,267 @@ +_entry as $entry) { + $entry->setHttpClient($httpClient); + } + return $this; + } + + /** + * Set the active service instance for this feed and all enclosed entries. + * This will be used to perform network requests, such as when calling + * save() and delete(). + * + * @param Zend_Gdata_App $instance The new service instance. + * @return Zend_Gdata_App_FeedEntryParent Provides a fluent interface. + */ + public function setService($instance) + { + parent::setService($instance); + foreach ($this->_entry as $entry) { + $entry->setService($instance); + } + return $this; + } + + /** + * Make accessing some individual elements of the feed easier. + * + * Special accessors 'entry' and 'entries' are provided so that if + * you wish to iterate over an Atom feed's entries, you can do so + * using foreach ($feed->entries as $entry) or foreach + * ($feed->entry as $entry). + * + * @param string $var The property to access. + * @return mixed + */ + public function __get($var) + { + switch ($var) { + default: + return parent::__get($var); + } + } + + + public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null) + { + $element = parent::getDOM($doc, $majorVersion, $minorVersion); + if ($this->_generator != null) { + $element->appendChild($this->_generator->getDOM($element->ownerDocument)); + } + if ($this->_icon != null) { + $element->appendChild($this->_icon->getDOM($element->ownerDocument)); + } + if ($this->_logo != null) { + $element->appendChild($this->_logo->getDOM($element->ownerDocument)); + } + if ($this->_subtitle != null) { + $element->appendChild($this->_subtitle->getDOM($element->ownerDocument)); + } + return $element; + } + + /** + * Creates individual Entry objects of the appropriate type and + * stores them in the $_entry array based upon DOM data. + * + * @param DOMNode $child The DOMNode to process + */ + protected function takeChildFromDOM($child) + { + $absoluteNodeName = $child->namespaceURI . ':' . $child->localName; + switch ($absoluteNodeName) { + case $this->lookupNamespace('atom') . ':' . 'generator': + $generator = new Zend_Gdata_App_Extension_Generator(); + $generator->transferFromDOM($child); + $this->_generator = $generator; + break; + case $this->lookupNamespace('atom') . ':' . 'icon': + $icon = new Zend_Gdata_App_Extension_Icon(); + $icon->transferFromDOM($child); + $this->_icon = $icon; + break; + case $this->lookupNamespace('atom') . ':' . 'logo': + $logo = new Zend_Gdata_App_Extension_Logo(); + $logo->transferFromDOM($child); + $this->_logo = $logo; + break; + case $this->lookupNamespace('atom') . ':' . 'subtitle': + $subtitle = new Zend_Gdata_App_Extension_Subtitle(); + $subtitle->transferFromDOM($child); + $this->_subtitle = $subtitle; + break; + default: + parent::takeChildFromDOM($child); + break; + } + } + + /** + * @return Zend_Gdata_AppExtension_Generator + */ + public function getGenerator() + { + return $this->_generator; + } + + /** + * @param Zend_Gdata_App_Extension_Generator $value + * @return Zend_Gdata_App_FeedSourceParent Provides a fluent interface + */ + public function setGenerator($value) + { + $this->_generator = $value; + return $this; + } + + /** + * @return Zend_Gdata_AppExtension_Icon + */ + public function getIcon() + { + return $this->_icon; + } + + /** + * @param Zend_Gdata_App_Extension_Icon $value + * @return Zend_Gdata_App_FeedSourceParent Provides a fluent interface + */ + public function setIcon($value) + { + $this->_icon = $value; + return $this; + } + + /** + * @return Zend_Gdata_AppExtension_logo + */ + public function getlogo() + { + return $this->_logo; + } + + /** + * @param Zend_Gdata_App_Extension_logo $value + * @return Zend_Gdata_App_FeedSourceParent Provides a fluent interface + */ + public function setlogo($value) + { + $this->_logo = $value; + return $this; + } + + /** + * @return Zend_Gdata_AppExtension_Subtitle + */ + public function getSubtitle() + { + return $this->_subtitle; + } + + /** + * @param Zend_Gdata_App_Extension_Subtitle $value + * @return Zend_Gdata_App_FeedSourceParent Provides a fluent interface + */ + public function setSubtitle($value) + { + $this->_subtitle = $value; + return $this; + } + +} diff --git a/zend/library/Zend/Gdata/App/HttpException.php b/zend/library/Zend/Gdata/App/HttpException.php new file mode 100644 index 0000000..4ea6147 --- /dev/null +++ b/zend/library/Zend/Gdata/App/HttpException.php @@ -0,0 +1,121 @@ +_httpClientException = $e; + $this->_response = $response; + parent::__construct($message); + } + + /** + * Get the Zend_Http_Client_Exception. + * + * @return Zend_Http_Client_Exception + */ + public function getHttpClientException() + { + return $this->_httpClientException; + } + + /** + * Set the Zend_Http_Client_Exception. + * + * @param Zend_Http_Client_Exception $value + */ + public function setHttpClientException($value) + { + $this->_httpClientException = $value; + return $this; + } + + /** + * Set the Zend_Http_Response. + * + * @param Zend_Http_Response $response + */ + public function setResponse($response) + { + $this->_response = $response; + return $this; + } + + /** + * Get the Zend_Http_Response. + * + * @return Zend_Http_Response + */ + public function getResponse() + { + return $this->_response; + } + + /** + * Get the body of the Zend_Http_Response + * + * @return string + */ + public function getRawResponseBody() + { + if ($this->getResponse()) { + $response = $this->getResponse(); + return $response->getRawBody(); + } + return null; + } + +} diff --git a/zend/library/Zend/Gdata/App/IOException.php b/zend/library/Zend/Gdata/App/IOException.php new file mode 100644 index 0000000..6fe1a62 --- /dev/null +++ b/zend/library/Zend/Gdata/App/IOException.php @@ -0,0 +1,43 @@ +log_handle == null) { + $this->log_handle = fopen($this->config['logfile'], 'a'); + } + fwrite($this->log_handle, $message); + } + + /** + * Connect to the remote server + * + * @param string $host + * @param int $port + * @param boolean $secure + * @param int $timeout + */ + public function connect($host, $port = 80, $secure = false) + { + $this->log("Connecting to: ${host}:${port}"); + return parent::connect($host, $port, $secure); + } + + /** + * Send request to the remote server + * + * @param string $method + * @param Zend_Uri_Http $uri + * @param string $http_ver + * @param array $headers + * @param string $body + * @return string Request as string + */ + public function write($method, $uri, $http_ver = '1.1', $headers = array(), $body = '') + { + $request = parent::write($method, $uri, $http_ver, $headers, $body); + $this->log("\n\n" . $request); + return $request; + } + + /** + * Read response from server + * + * @return string + */ + public function read() + { + $response = parent::read(); + $this->log("${response}\n\n"); + return $response; + } + + /** + * Close the connection to the server + * + */ + public function close() + { + $this->log("Closing socket\n\n"); + parent::close(); + } + +} diff --git a/zend/library/Zend/Gdata/App/MediaEntry.php b/zend/library/Zend/Gdata/App/MediaEntry.php new file mode 100644 index 0000000..68b47b1 --- /dev/null +++ b/zend/library/Zend/Gdata/App/MediaEntry.php @@ -0,0 +1,119 @@ +_mediaSource = $mediaSource; + } + + /** + * Return the MIME multipart representation of this MediaEntry. + * + * @return string|Zend_Gdata_MediaMimeStream The MIME multipart + * representation of this MediaEntry. If the entry consisted only + * of XML, a string is returned. + */ + public function encode() + { + $xmlData = $this->saveXML(); + $mediaSource = $this->getMediaSource(); + if ($mediaSource === null) { + // No attachment, just send XML for entry + return $xmlData; + } else { + return new Zend_Gdata_MediaMimeStream($xmlData, + $mediaSource->getFilename(), $mediaSource->getContentType()); + } + } + + /** + * Return the MediaSource object representing the file attached to this + * MediaEntry. + * + * @return Zend_Gdata_App_MediaSource The attached MediaSource/file + */ + public function getMediaSource() + { + return $this->_mediaSource; + } + + /** + * Set the MediaSource object (file) for this MediaEntry + * + * @param Zend_Gdata_App_MediaSource $value The attached MediaSource/file + * @return Zend_Gdata_App_MediaEntry Provides a fluent interface + */ + public function setMediaSource($value) + { + if ($value instanceof Zend_Gdata_App_MediaSource) { + $this->_mediaSource = $value; + } else { + require_once 'Zend/Gdata/App/InvalidArgumentException.php'; + throw new Zend_Gdata_App_InvalidArgumentException( + 'You must specify the media data as a class that conforms to Zend_Gdata_App_MediaSource.'); + } + return $this; + } + +} diff --git a/zend/library/Zend/Gdata/App/MediaFileSource.php b/zend/library/Zend/Gdata/App/MediaFileSource.php new file mode 100644 index 0000000..e37bd75 --- /dev/null +++ b/zend/library/Zend/Gdata/App/MediaFileSource.php @@ -0,0 +1,146 @@ +setFilename($filename); + } + + /** + * Return the MIME multipart representation of this MediaEntry. + * + * @return string + * @throws Zend_Gdata_App_IOException + */ + public function encode() + { + if ($this->getFilename() !== null && + is_readable($this->getFilename())) { + + // Retrieves the file, using the include path + $fileHandle = fopen($this->getFilename(), 'r', true); + $result = fread($fileHandle, filesize($this->getFilename())); + if ($result === false) { + require_once 'Zend/Gdata/App/IOException.php'; + throw new Zend_Gdata_App_IOException("Error reading file - " . + $this->getFilename() . '. Read failed.'); + } + fclose($fileHandle); + return $result; + } else { + require_once 'Zend/Gdata/App/IOException.php'; + throw new Zend_Gdata_App_IOException("Error reading file - " . + $this->getFilename() . '. File is not readable.'); + } + } + + /** + * Get the filename associated with this reader. + * + * @return string + */ + public function getFilename() + { + return $this->_filename; + } + + /** + * Set the filename which is to be read. + * + * @param string $value The desired file handle. + * @return Zend_Gdata_App_MediaFileSource Provides a fluent interface. + */ + public function setFilename($value) + { + $this->_filename = $value; + return $this; + } + + /** + * The content type for the file attached (example image/png) + * + * @return string The content type + */ + public function getContentType() + { + return $this->_contentType; + } + + /** + * Set the content type for the file attached (example image/png) + * + * @param string $value The content type + * @return Zend_Gdata_App_MediaFileSource Provides a fluent interface + */ + public function setContentType($value) + { + $this->_contentType = $value; + return $this; + } + + /** + * Alias for getFilename(). + * + * @return string + */ + public function __toString() + { + return $this->getFilename(); + } + +} diff --git a/zend/library/Zend/Gdata/App/MediaSource.php b/zend/library/Zend/Gdata/App/MediaSource.php new file mode 100644 index 0000000..b99a939 --- /dev/null +++ b/zend/library/Zend/Gdata/App/MediaSource.php @@ -0,0 +1,73 @@ + 0) { + // timestamp is already properly formatted + return $timestamp; + } else { + $ts = strtotime($timestamp); + if ($ts === false) { + require_once 'Zend/Gdata/App/InvalidArgumentException.php'; + throw new Zend_Gdata_App_InvalidArgumentException("Invalid timestamp: $timestamp."); + } + return date('Y-m-d\TH:i:s', $ts); + } + } + + /** Find the greatest key that is less than or equal to a given upper + * bound, and return the value associated with that key. + * + * @param integer|null $maximumKey The upper bound for keys. If null, the + * maxiumum valued key will be found. + * @param array $collection An two-dimensional array of key/value pairs + * to search through. + * @returns mixed The value corresponding to the located key. + * @throws Zend_Gdata_App_Exception Thrown if $collection is empty. + */ + public static function findGreatestBoundedValue($maximumKey, $collection) + { + $found = false; + $foundKey = $maximumKey; + + // Sanity check: Make sure that the collection isn't empty + if (sizeof($collection) == 0) { + require_once 'Zend/Gdata/App/Exception.php'; + throw new Zend_Gdata_App_Exception("Empty namespace collection encountered."); + } + + if ($maximumKey === null) { + // If the key is null, then we return the maximum available + $keys = array_keys($collection); + sort($keys); + $found = true; + $foundKey = end($keys); + } else { + // Otherwise, we optimistically guess that the current version + // will have a matching namespce. If that fails, we decrement the + // version until we find a match. + while (!$found && $foundKey >= 0) { + if (array_key_exists($foundKey, $collection)) + $found = true; + else + $foundKey--; + } + } + + // Guard: A namespace wasn't found. Either none were registered, or + // the current protcol version is lower than the maximum namespace. + if (!$found) { + require_once 'Zend/Gdata/App/Exception.php'; + throw new Zend_Gdata_App_Exception("Namespace compatible with current protocol not found."); + } + + return $foundKey; + } + +} diff --git a/zend/library/Zend/Gdata/App/VersionException.php b/zend/library/Zend/Gdata/App/VersionException.php new file mode 100644 index 0000000..4212b9e --- /dev/null +++ b/zend/library/Zend/Gdata/App/VersionException.php @@ -0,0 +1,42 @@ +