| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232 |
- <?php
- /**
- * Zend Framework
- *
- * LICENSE
- *
- * This source file is subject to the new BSD license that is bundled
- * with this package in the file LICENSE.txt.
- * It is also available through the world-wide-web at this URL:
- * http://framework.zend.com/license/new-bsd
- * If you did not receive a copy of the license and are unable to
- * obtain it through the world-wide-web, please send an email
- * to license@zend.com so we can send you a copy immediately.
- *
- * @category Zend
- * @package Zend_Gdata
- * @subpackage Health
- * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
- * @license http://framework.zend.com/license/new-bsd New BSD License
- * @version $Id$
- */
- /**
- * @see Zend_Gdata_Entry
- */
- require_once 'Zend/Gdata/Entry.php';
- /**
- * @see Zend_Gdata_YouTube_Extension_VideoId
- */
- require_once 'Zend/Gdata/YouTube/Extension/VideoId.php';
- /**
- * @see Zend_Gdata_YouTube_Extension_Username
- */
- require_once 'Zend/Gdata/YouTube/Extension/Username.php';
- /**
- * @see Zend_Gdata_YouTube_Extension_Rating
- */
- require_once 'Zend/Gdata/Extension/Rating.php';
- /**
- * A concrete class for working with YouTube user activity entries.
- *
- * @link http://code.google.com/apis/youtube/
- *
- * @category Zend
- * @package Zend_Gdata
- * @subpackage YouTube
- * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
- * @license http://framework.zend.com/license/new-bsd New BSD License
- */
- class Zend_Gdata_YouTube_ActivityEntry extends Zend_Gdata_Entry
- {
- const ACTIVITY_CATEGORY_SCHEME =
- 'http://gdata.youtube.com/schemas/2007/userevents.cat';
- /**
- * The classname for individual user activity entry elements.
- *
- * @var string
- */
- protected $_entryClassName = 'Zend_Gdata_YouTube_ActivityEntry';
- /**
- * The ID of the video that was part of the activity
- *
- * @var Zend_Gdata_YouTube_VideoId
- */
- protected $_videoId = null;
- /**
- * The username for the user that was part of the activity
- *
- * @var Zend_Gdata_YouTube_Username
- */
- protected $_username = null;
- /**
- * The rating element that was part of the activity
- *
- * @var Zend_Gdata_Extension_Rating
- */
- protected $_rating = null;
- /**
- * Constructs a new Zend_Gdata_YouTube_ActivityEntry object.
- * @param DOMElement $element (optional) The DOMElement on which to
- * base this object.
- */
- public function __construct($element = null)
- {
- $this->registerAllNamespaces(Zend_Gdata_YouTube::$namespaces);
- parent::__construct($element);
- }
- /**
- * 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 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)
- {
- $element = parent::getDOM($doc, $majorVersion, $minorVersion);
- if ($this->_videoId !== null) {
- $element->appendChild($this->_videoId->getDOM(
- $element->ownerDocument));
- }
- if ($this->_username !== null) {
- $element->appendChild($this->_username->getDOM(
- $element->ownerDocument));
- }
- if ($this->_rating !== null) {
- $element->appendChild($this->_rating->getDOM(
- $element->ownerDocument));
- }
- return $element;
- }
- /**
- * Creates individual Entry objects of the appropriate type and
- * stores them as members of this entry 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('yt') . ':' . 'videoid':
- $videoId = new Zend_Gdata_YouTube_Extension_VideoId();
- $videoId->transferFromDOM($child);
- $this->_videoId = $videoId;
- break;
- case $this->lookupNamespace('yt') . ':' . 'username':
- $username = new Zend_Gdata_YouTube_Extension_Username();
- $username->transferFromDOM($child);
- $this->_username = $username;
- break;
- case $this->lookupNamespace('gd') . ':' . 'rating':
- $rating = new Zend_Gdata_Extension_Rating();
- $rating->transferFromDOM($child);
- $this->_rating = $rating;
- break;
- default:
- parent::takeChildFromDOM($child);
- break;
- }
- }
- /**
- * Returns the video ID for this activity entry.
- *
- * @return null|Zend_Gdata_YouTube_Extension_VideoId
- */
- public function getVideoId()
- {
- return $this->_videoId;
- }
- /**
- * Returns the username for this activity entry.
- *
- * @return null|Zend_Gdata_YouTube_Extension_Username
- */
- public function getUsername()
- {
- return $this->_username;
- }
- /**
- * Returns the rating for this activity entry.
- *
- * @return null|Zend_Gdata_YouTube_Extension_Rating
- */
- public function getRating()
- {
- return $this->_rating;
- }
- /**
- * Return the value of the rating for this video entry.
- *
- * Convenience method to save needless typing.
- *
- * @return integer|null The value of the rating that was created, if found.
- */
- public function getRatingValue()
- {
- $rating = $this->_rating;
- if ($rating) {
- return $rating->getValue();
- }
- return null;
- }
- /**
- * Return the activity type that was performed.
- *
- * Convenience method that inspects category where scheme is
- * http://gdata.youtube.com/schemas/2007/userevents.cat.
- *
- * @return string|null The activity category if found.
- */
- public function getActivityType()
- {
- $categories = $this->getCategory();
- foreach($categories as $category) {
- if ($category->getScheme() == self::ACTIVITY_CATEGORY_SCHEME) {
- return $category->getTerm();
- }
- }
- return null;
- }
- /**
- * Convenience method to quickly get access to the author of the activity
- *
- * @return string The author of the activity
- */
- public function getAuthorName()
- {
- $authors = $this->getAuthor();
- return $authors[0]->getName()->getText();
- }
- }
|