web/lib/Zend/Gdata/Media/Extension/MediaGroup.php
changeset 64 162c1de6545a
parent 19 1c2f13fd785c
child 68 ecaf28ffe26e
equal deleted inserted replaced
63:5b37998e522e 64:162c1de6545a
       
     1 <?php
       
     2 
       
     3 /**
       
     4  * Zend Framework
       
     5  *
       
     6  * LICENSE
       
     7  *
       
     8  * This source file is subject to the new BSD license that is bundled
       
     9  * with this package in the file LICENSE.txt.
       
    10  * It is also available through the world-wide-web at this URL:
       
    11  * http://framework.zend.com/license/new-bsd
       
    12  * If you did not receive a copy of the license and are unable to
       
    13  * obtain it through the world-wide-web, please send an email
       
    14  * to license@zend.com so we can send you a copy immediately.
       
    15  *
       
    16  * @category   Zend
       
    17  * @package    Zend_Gdata
       
    18  * @subpackage Media
       
    19  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
       
    20  * @license    http://framework.zend.com/license/new-bsd     New BSD License
       
    21  * @version    $Id: MediaGroup.php 20096 2010-01-06 02:05:09Z bkarwin $
       
    22  */
       
    23 
       
    24 /**
       
    25  * @see Zend_Gdata_Extension
       
    26  */
       
    27 require_once 'Zend/Gdata/Extension.php';
       
    28 
       
    29 /**
       
    30  * @see Zend_Gdata_Entry
       
    31  */
       
    32 require_once 'Zend/Gdata/Entry.php';
       
    33 
       
    34 /**
       
    35  * @see Zend_Gdata_Media_Extension_MediaContent
       
    36  */
       
    37 require_once 'Zend/Gdata/Media/Extension/MediaContent.php';
       
    38 
       
    39 /**
       
    40  * @see Zend_Gdata_Media_Extension_MediaCategory
       
    41  */
       
    42 require_once 'Zend/Gdata/Media/Extension/MediaCategory.php';
       
    43 
       
    44 /**
       
    45  * @see Zend_Gdata_Media_Extension_MediaCopyright
       
    46  */
       
    47 require_once 'Zend/Gdata/Media/Extension/MediaCopyright.php';
       
    48 
       
    49 /**
       
    50  * @see Zend_Gdata_Media_Extension_MediaCredit
       
    51  */
       
    52 require_once 'Zend/Gdata/Media/Extension/MediaCredit.php';
       
    53 
       
    54 /**
       
    55  * @see Zend_Gdata_Media_Extension_MediaDescription
       
    56  */
       
    57 require_once 'Zend/Gdata/Media/Extension/MediaDescription.php';
       
    58 
       
    59 /**
       
    60  * @see Zend_Gdata_Media_Extension_MediaHash
       
    61  */
       
    62 require_once 'Zend/Gdata/Media/Extension/MediaHash.php';
       
    63 
       
    64 /**
       
    65  * @see Zend_Gdata_Media_Extension_MediaKeywords
       
    66  */
       
    67 require_once 'Zend/Gdata/Media/Extension/MediaKeywords.php';
       
    68 
       
    69 /**
       
    70  * @see Zend_Gdata_Media_Extension_MediaPlayer
       
    71  */
       
    72 require_once 'Zend/Gdata/Media/Extension/MediaPlayer.php';
       
    73 
       
    74 /**
       
    75  * @see Zend_Gdata_Media_Extension_MediaRating
       
    76  */
       
    77 require_once 'Zend/Gdata/Media/Extension/MediaRating.php';
       
    78 
       
    79 /**
       
    80  * @see Zend_Gdata_Media_Extension_MediaRestriction
       
    81  */
       
    82 require_once 'Zend/Gdata/Media/Extension/MediaRestriction.php';
       
    83 
       
    84 /**
       
    85  * @see Zend_Gdata_Media_Extension_MediaText
       
    86  */
       
    87 require_once 'Zend/Gdata/Media/Extension/MediaText.php';
       
    88 
       
    89 /**
       
    90  * @see Zend_Gdata_Media_Extension_MediaThumbnail
       
    91  */
       
    92 require_once 'Zend/Gdata/Media/Extension/MediaThumbnail.php';
       
    93 
       
    94 /**
       
    95  * @see Zend_Gdata_Media_Extension_MediaTitle
       
    96  */
       
    97 require_once 'Zend/Gdata/Media/Extension/MediaTitle.php';
       
    98 
       
    99 
       
   100 /**
       
   101  * This class represents the media:group element of Media RSS.
       
   102  * It allows the grouping of media:content elements that are
       
   103  * different representations of the same content.  When it exists,
       
   104  * it is a child of an Entry (Atom) or Item (RSS).
       
   105  *
       
   106  * @category   Zend
       
   107  * @package    Zend_Gdata
       
   108  * @subpackage Media
       
   109  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
       
   110  * @license    http://framework.zend.com/license/new-bsd     New BSD License
       
   111  */
       
   112 class Zend_Gdata_Media_Extension_MediaGroup extends Zend_Gdata_Extension
       
   113 {
       
   114 
       
   115     protected $_rootElement = 'group';
       
   116     protected $_rootNamespace = 'media';
       
   117 
       
   118     /**
       
   119      * @var array
       
   120      */
       
   121     protected $_content = array();
       
   122 
       
   123     /**
       
   124      * @var array
       
   125      */
       
   126     protected $_category = array();
       
   127 
       
   128     /**
       
   129      * @var Zend_Gdata_Media_Extension_MediaCopyright
       
   130      */
       
   131     protected $_copyright = null;
       
   132 
       
   133     /**
       
   134      * @var array
       
   135      */
       
   136     protected $_credit = array();
       
   137 
       
   138     /**
       
   139      * @var Zend_Gdata_Media_Extension_MediaDescription
       
   140      */
       
   141     protected $_description = null;
       
   142 
       
   143     /**
       
   144      * @var array
       
   145      */
       
   146     protected $_hash = array();
       
   147 
       
   148     /**
       
   149      * @var Zend_Gdata_Media_Extension_MediaKeywords
       
   150      */
       
   151     protected $_keywords = null;
       
   152 
       
   153     /**
       
   154      * @var array
       
   155      */
       
   156     protected $_player = array();
       
   157 
       
   158     /**
       
   159      * @var array
       
   160      */
       
   161     protected $_rating = array();
       
   162 
       
   163     /**
       
   164      * @var array
       
   165      */
       
   166     protected $_restriction = array();
       
   167 
       
   168     /**
       
   169      * @var array
       
   170      */
       
   171     protected $_mediaText = array();
       
   172 
       
   173     /**
       
   174      * @var array
       
   175      */
       
   176     protected $_thumbnail = array();
       
   177 
       
   178     /**
       
   179      * @var string
       
   180      */
       
   181     protected $_title = null;
       
   182 
       
   183     /**
       
   184      * Creates an individual MediaGroup object.
       
   185      */
       
   186     public function __construct($element = null)
       
   187     {
       
   188         $this->registerAllNamespaces(Zend_Gdata_Media::$namespaces);
       
   189         parent::__construct($element);
       
   190     }
       
   191 
       
   192     /**
       
   193      * Retrieves a DOMElement which corresponds to this element and all
       
   194      * child properties.  This is used to build an entry back into a DOM
       
   195      * and eventually XML text for sending to the server upon updates, or
       
   196      * for application storage/persistence.
       
   197      *
       
   198      * @param DOMDocument $doc The DOMDocument used to construct DOMElements
       
   199      * @return DOMElement The DOMElement representing this element and all
       
   200      * child properties.
       
   201      */
       
   202     public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
       
   203     {
       
   204         $element = parent::getDOM($doc, $majorVersion, $minorVersion);
       
   205         foreach ($this->_content as $content) {
       
   206             $element->appendChild($content->getDOM($element->ownerDocument));
       
   207         }
       
   208         foreach ($this->_category as $category) {
       
   209             $element->appendChild($category->getDOM($element->ownerDocument));
       
   210         }
       
   211         foreach ($this->_credit as $credit) {
       
   212             $element->appendChild($credit->getDOM($element->ownerDocument));
       
   213         }
       
   214         foreach ($this->_player as $player) {
       
   215             $element->appendChild($player->getDOM($element->ownerDocument));
       
   216         }
       
   217         foreach ($this->_rating as $rating) {
       
   218             $element->appendChild($rating->getDOM($element->ownerDocument));
       
   219         }
       
   220         foreach ($this->_restriction as $restriction) {
       
   221             $element->appendChild($restriction->getDOM($element->ownerDocument));
       
   222         }
       
   223         foreach ($this->_mediaText as $text) {
       
   224             $element->appendChild($text->getDOM($element->ownerDocument));
       
   225         }
       
   226         foreach ($this->_thumbnail as $thumbnail) {
       
   227             $element->appendChild($thumbnail->getDOM($element->ownerDocument));
       
   228         }
       
   229         if ($this->_copyright != null) {
       
   230             $element->appendChild(
       
   231                     $this->_copyright->getDOM($element->ownerDocument));
       
   232         }
       
   233         if ($this->_description != null) {
       
   234             $element->appendChild(
       
   235                     $this->_description->getDOM($element->ownerDocument));
       
   236         }
       
   237         foreach ($this->_hash as $hash) {
       
   238             $element->appendChild($hash->getDOM($element->ownerDocument));
       
   239         }
       
   240         if ($this->_keywords != null) {
       
   241             $element->appendChild(
       
   242                     $this->_keywords->getDOM($element->ownerDocument));
       
   243         }
       
   244         if ($this->_title != null) {
       
   245             $element->appendChild(
       
   246                     $this->_title->getDOM($element->ownerDocument));
       
   247         }
       
   248         return $element;
       
   249     }
       
   250 
       
   251     /**
       
   252      * Creates individual Entry objects of the appropriate type and
       
   253      * stores them in the $_entry array based upon DOM data.
       
   254      *
       
   255      * @param DOMNode $child The DOMNode to process
       
   256      */
       
   257     protected function takeChildFromDOM($child)
       
   258     {
       
   259         $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
       
   260         switch ($absoluteNodeName) {
       
   261             case $this->lookupNamespace('media') . ':' . 'content';
       
   262                 $content = new Zend_Gdata_Media_Extension_MediaContent();
       
   263                 $content->transferFromDOM($child);
       
   264                 $this->_content[] = $content;
       
   265                 break;
       
   266             case $this->lookupNamespace('media') . ':' . 'category';
       
   267                 $category = new Zend_Gdata_Media_Extension_MediaCategory();
       
   268                 $category->transferFromDOM($child);
       
   269                 $this->_category[] = $category;
       
   270                 break;
       
   271             case $this->lookupNamespace('media') . ':' . 'copyright';
       
   272                 $copyright = new Zend_Gdata_Media_Extension_MediaCopyright();
       
   273                 $copyright->transferFromDOM($child);
       
   274                 $this->_copyright = $copyright;
       
   275                 break;
       
   276             case $this->lookupNamespace('media') . ':' . 'credit';
       
   277                 $credit = new Zend_Gdata_Media_Extension_MediaCredit();
       
   278                 $credit->transferFromDOM($child);
       
   279                 $this->_credit[] = $credit;
       
   280                 break;
       
   281             case $this->lookupNamespace('media') . ':' . 'description';
       
   282                 $description = new Zend_Gdata_Media_Extension_MediaDescription();
       
   283                 $description->transferFromDOM($child);
       
   284                 $this->_description = $description;
       
   285                 break;
       
   286             case $this->lookupNamespace('media') . ':' . 'hash';
       
   287                 $hash = new Zend_Gdata_Media_Extension_MediaHash();
       
   288                 $hash->transferFromDOM($child);
       
   289                 $this->_hash[] = $hash;
       
   290                 break;
       
   291             case $this->lookupNamespace('media') . ':' . 'keywords';
       
   292                 $keywords = new Zend_Gdata_Media_Extension_MediaKeywords();
       
   293                 $keywords->transferFromDOM($child);
       
   294                 $this->_keywords = $keywords;
       
   295                 break;
       
   296             case $this->lookupNamespace('media') . ':' . 'player';
       
   297                 $player = new Zend_Gdata_Media_Extension_MediaPlayer();
       
   298                 $player->transferFromDOM($child);
       
   299                 $this->_player[] = $player;
       
   300                 break;
       
   301             case $this->lookupNamespace('media') . ':' . 'rating';
       
   302                 $rating = new Zend_Gdata_Media_Extension_MediaRating();
       
   303                 $rating->transferFromDOM($child);
       
   304                 $this->_rating[] = $rating;
       
   305                 break;
       
   306             case $this->lookupNamespace('media') . ':' . 'restriction';
       
   307                 $restriction = new Zend_Gdata_Media_Extension_MediaRestriction();
       
   308                 $restriction->transferFromDOM($child);
       
   309                 $this->_restriction[] = $restriction;
       
   310                 break;
       
   311             case $this->lookupNamespace('media') . ':' . 'text';
       
   312                 $text = new Zend_Gdata_Media_Extension_MediaText();
       
   313                 $text->transferFromDOM($child);
       
   314                 $this->_mediaText[] = $text;
       
   315                 break;
       
   316             case $this->lookupNamespace('media') . ':' . 'thumbnail';
       
   317                 $thumbnail = new Zend_Gdata_Media_Extension_MediaThumbnail();
       
   318                 $thumbnail->transferFromDOM($child);
       
   319                 $this->_thumbnail[] = $thumbnail;
       
   320                 break;
       
   321             case $this->lookupNamespace('media') . ':' . 'title';
       
   322                 $title = new Zend_Gdata_Media_Extension_MediaTitle();
       
   323                 $title->transferFromDOM($child);
       
   324                 $this->_title = $title;
       
   325                 break;
       
   326         default:
       
   327             parent::takeChildFromDOM($child);
       
   328             break;
       
   329         }
       
   330     }
       
   331 
       
   332     /**
       
   333      * @return array
       
   334      */
       
   335     public function getContent()
       
   336     {
       
   337         return $this->_content;
       
   338     }
       
   339 
       
   340     /**
       
   341      * @param array $value
       
   342      * @return Zend_Gdata_Media_MediaGroup Provides a fluent interface
       
   343      */
       
   344     public function setContent($value)
       
   345     {
       
   346         $this->_content = $value;
       
   347         return $this;
       
   348     }
       
   349 
       
   350     /**
       
   351      * @return array
       
   352      */
       
   353     public function getCategory()
       
   354     {
       
   355         return $this->_category;
       
   356     }
       
   357 
       
   358     /**
       
   359      * @param array $value
       
   360      * @return Zend_Gdata_Media_Extension_MediaGroup
       
   361      */
       
   362     public function setCategory($value)
       
   363     {
       
   364         $this->_category = $value;
       
   365         return $this;
       
   366     }
       
   367 
       
   368     /**
       
   369      * @return Zend_Gdata_Media_Extension_MediaCopyright
       
   370      */
       
   371     public function getCopyright()
       
   372     {
       
   373         return $this->_copyright;
       
   374     }
       
   375 
       
   376     /**
       
   377      * @param Zend_Gdata_Media_Extension_MediaCopyright $value
       
   378      * @return Zend_Gdata_Media_Extension_MediaGroup
       
   379      */
       
   380     public function setCopyright($value)
       
   381     {
       
   382         $this->_copyright = $value;
       
   383         return $this;
       
   384     }
       
   385 
       
   386     /**
       
   387      * @return array
       
   388      */
       
   389     public function getCredit()
       
   390     {
       
   391         return $this->_credit;
       
   392     }
       
   393 
       
   394     /**
       
   395      * @param array $value
       
   396      * @return Zend_Gdata_Media_Extension_MediaGroup
       
   397      */
       
   398     public function setCredit($value)
       
   399     {
       
   400         $this->_credit = $value;
       
   401         return $this;
       
   402     }
       
   403 
       
   404     /**
       
   405      * @return Zend_Gdata_Media_Extension_MediaTitle
       
   406      */
       
   407     public function getTitle()
       
   408     {
       
   409         return $this->_title;
       
   410     }
       
   411 
       
   412     /**
       
   413      * @param Zend_Gdata_Media_Extension_MediaTitle $value
       
   414      * @return Zend_Gdata_Media_Extension_MediaGroup
       
   415      */
       
   416     public function setTitle($value)
       
   417     {
       
   418         $this->_title = $value;
       
   419         return $this;
       
   420     }
       
   421 
       
   422     /**
       
   423      * @return Zend_Gdata_Media_Extension_MediaDescription
       
   424      */
       
   425     public function getDescription()
       
   426     {
       
   427         return $this->_description;
       
   428     }
       
   429 
       
   430     /**
       
   431      * @param Zend_Gdata_Media_Extension_MediaDescription $value
       
   432      * @return Zend_Gdata_Media_Extension_MediaGroup
       
   433      */
       
   434     public function setDescription($value)
       
   435     {
       
   436         $this->_description = $value;
       
   437         return $this;
       
   438     }
       
   439 
       
   440     /**
       
   441      * @return array
       
   442      */
       
   443     public function getHash()
       
   444     {
       
   445         return $this->_hash;
       
   446     }
       
   447 
       
   448     /**
       
   449      * @param array $value
       
   450      * @return Zend_Gdata_Media_Extension_MediaGroup
       
   451      */
       
   452     public function setHash($value)
       
   453     {
       
   454         $this->_hash = $value;
       
   455         return $this;
       
   456     }
       
   457 
       
   458     /**
       
   459      * @return Zend_Gdata_Media_Extension_MediaKeywords
       
   460      */
       
   461     public function getKeywords()
       
   462     {
       
   463         return $this->_keywords;
       
   464     }
       
   465 
       
   466     /**
       
   467      * @param array $value
       
   468      * @return Zend_Gdata_Media_Extension_MediaGroup Provides a fluent interface
       
   469      */
       
   470     public function setKeywords($value)
       
   471     {
       
   472         $this->_keywords = $value;
       
   473         return $this;
       
   474     }
       
   475 
       
   476     /**
       
   477      * @return array
       
   478      */
       
   479     public function getPlayer()
       
   480     {
       
   481         return $this->_player;
       
   482     }
       
   483 
       
   484     /**
       
   485      * @param array
       
   486      * @return Zend_Gdata_Media_Extension_MediaGroup
       
   487      */
       
   488     public function setPlayer($value)
       
   489     {
       
   490         $this->_player = $value;
       
   491         return $this;
       
   492     }
       
   493 
       
   494     /**
       
   495      * @return array
       
   496      */
       
   497     public function getRating()
       
   498     {
       
   499         return $this->_rating;
       
   500     }
       
   501 
       
   502     /**
       
   503      * @param array
       
   504      * @return Zend_Gdata_Media_Extension_MediaGroup
       
   505      */
       
   506     public function setRating($value)
       
   507     {
       
   508         $this->_rating = $value;
       
   509         return $this;
       
   510     }
       
   511 
       
   512     /**
       
   513      * @return array
       
   514      */
       
   515     public function getRestriction()
       
   516     {
       
   517         return $this->_restriction;
       
   518     }
       
   519 
       
   520     /**
       
   521      * @param array
       
   522      * @return Zend_Gdata_Media_Extension_MediaGroup
       
   523      */
       
   524     public function setRestriction($value)
       
   525     {
       
   526         $this->_restriction = $value;
       
   527         return $this;
       
   528     }
       
   529 
       
   530     /**
       
   531      * @return array
       
   532      */
       
   533     public function getThumbnail()
       
   534     {
       
   535         return $this->_thumbnail;
       
   536     }
       
   537 
       
   538     /**
       
   539      * @param array
       
   540      * @return Zend_Gdata_Media_Extension_MediaGroup
       
   541      */
       
   542     public function setThumbnail($value)
       
   543     {
       
   544         $this->_thumbnail = $value;
       
   545         return $this;
       
   546     }
       
   547 
       
   548     /**
       
   549      * @return array
       
   550      */
       
   551     public function getMediaText()
       
   552     {
       
   553         return $this->_mediaText;
       
   554     }
       
   555 
       
   556     /**
       
   557      * @param array
       
   558      * @return Zend_Gdata_Media_Extension_MediaGroup
       
   559      */
       
   560     public function setMediaText($value)
       
   561     {
       
   562         $this->_mediaText = $value;
       
   563         return $this;
       
   564     }
       
   565 
       
   566 }