web/lib/Zend/Gdata/Gbase/Entry.php
changeset 807 877f952ae2bd
parent 207 621fa6caec0c
child 1230 68c69c656a2c
equal deleted inserted replaced
805:5e7a0fedabdf 807:877f952ae2bd
    14  * to license@zend.com so we can send you a copy immediately.
    14  * to license@zend.com so we can send you a copy immediately.
    15  *
    15  *
    16  * @category   Zend
    16  * @category   Zend
    17  * @package    Zend_Gdata
    17  * @package    Zend_Gdata
    18  * @subpackage Gbase
    18  * @subpackage Gbase
    19  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
    19  * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
    20  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    20  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    21  * @version    $Id: Entry.php 20096 2010-01-06 02:05:09Z bkarwin $
    21  * @version    $Id: Entry.php 24777 2012-05-08 18:50:23Z adamlundrigan $
    22  */
    22  */
       
    23 
       
    24 /**
       
    25  * @see Zend_Exception
       
    26  */
       
    27 require_once 'Zend/Exception.php';
    23 
    28 
    24 /**
    29 /**
    25  * @see Zend_Gdata_Entry
    30  * @see Zend_Gdata_Entry
    26  */
    31  */
    27 require_once 'Zend/Gdata/Entry.php';
    32 require_once 'Zend/Gdata/Entry.php';
    28 
       
    29 /**
       
    30  * @see Zend_Gdata_Gbase_Extension_BaseAttribute
       
    31  */
       
    32 require_once 'Zend/Gdata/Gbase/Extension/BaseAttribute.php';
       
    33 
    33 
    34 /**
    34 /**
    35  * Base class for working with Google Base entries.
    35  * Base class for working with Google Base entries.
    36  *
    36  *
    37  * @link http://code.google.com/apis/base/
    37  * @link http://code.google.com/apis/base/
    38  *
    38  *
    39  * @category   Zend
    39  * @category   Zend
    40  * @package    Zend_Gdata
    40  * @package    Zend_Gdata
    41  * @subpackage Gbase
    41  * @subpackage Gbase
    42  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
    42  * @copyright  Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
    43  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    43  * @license    http://framework.zend.com/license/new-bsd     New BSD License
    44  */
    44  */
    45 class Zend_Gdata_Gbase_Entry extends Zend_Gdata_Entry
    45 class Zend_Gdata_Gbase_Entry extends Zend_Gdata_Entry
    46 {
    46 {
    47 
       
    48     /**
       
    49      * Name of the base class for Google Base entries
       
    50      *
       
    51      * var @string
       
    52      */
       
    53     protected $_entryClassName = 'Zend_Gdata_Gbase_Entry';
       
    54 
       
    55     /**
       
    56      * Google Base attribute elements in the 'g' namespace
       
    57      *
       
    58      * @var array
       
    59      */
       
    60     protected $_baseAttributes = array();
       
    61 
       
    62     /**
    47     /**
    63      * Constructs a new Zend_Gdata_Gbase_ItemEntry object.
    48      * Constructs a new Zend_Gdata_Gbase_ItemEntry object.
    64      * @param DOMElement $element (optional) The DOMElement on which to base this object.
    49      * @param DOMElement $element (optional) The DOMElement on which to base this object.
    65      */
    50      */
    66     public function __construct($element = null)
    51     public function __construct($element = null)
    67     {
    52     {
    68         $this->registerAllNamespaces(Zend_Gdata_Gbase::$namespaces);
    53         throw new Zend_Exception(
    69         parent::__construct($element);
    54             'Google Base API has been discontinued by Google and was removed'
       
    55             . ' from Zend Framework in 1.12.0.  For more information see: '
       
    56             . 'http://googlemerchantblog.blogspot.ca/2010/12/new-shopping-apis-and-deprecation-of.html'
       
    57         );    
    70     }
    58     }
    71 
       
    72     /**
       
    73      * Retrieves a DOMElement which corresponds to this element and all
       
    74      * child properties.  This is used to build an entry back into a DOM
       
    75      * and eventually XML text for application storage/persistence.
       
    76      *
       
    77      * @param DOMDocument $doc The DOMDocument used to construct DOMElements
       
    78      * @return DOMElement The DOMElement representing this element and all
       
    79      *          child properties.
       
    80      */
       
    81     public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
       
    82     {
       
    83         $element = parent::getDOM($doc, $majorVersion, $minorVersion);
       
    84         foreach ($this->_baseAttributes as $baseAttribute) {
       
    85             $element->appendChild($baseAttribute->getDOM($element->ownerDocument));
       
    86         }
       
    87         return $element;
       
    88     }
       
    89 
       
    90     /**
       
    91      * Creates individual Entry objects of the appropriate type and
       
    92      * stores them as members of this entry based upon DOM data.
       
    93      *
       
    94      * @param DOMNode $child The DOMNode to process
       
    95      */
       
    96     protected function takeChildFromDOM($child)
       
    97     {
       
    98         $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
       
    99 
       
   100         if (strstr($absoluteNodeName, $this->lookupNamespace('g') . ':')) {
       
   101             $baseAttribute = new Zend_Gdata_Gbase_Extension_BaseAttribute();
       
   102             $baseAttribute->transferFromDOM($child);
       
   103             $this->_baseAttributes[] = $baseAttribute;
       
   104         } else {
       
   105             parent::takeChildFromDOM($child);
       
   106         }
       
   107     }
       
   108 
       
   109     /**
       
   110      * Get the value of the itme_type
       
   111      *
       
   112      * @return Zend_Gdata_Gbase_Extension_ItemType The requested object.
       
   113      */
       
   114     public function getItemType()
       
   115     {
       
   116         $itemType = $this->getGbaseAttribute('item_type');
       
   117         if (is_object($itemType[0])) {
       
   118           return $itemType[0];
       
   119         } else {
       
   120           return null;
       
   121         }
       
   122     }
       
   123 
       
   124     /**
       
   125      * Return all the Base attributes
       
   126      * @return Zend_Gdata_Gbase_Extension_BaseAttribute
       
   127      */
       
   128     public function getGbaseAttributes() {
       
   129         return $this->_baseAttributes;
       
   130     }
       
   131 
       
   132     /**
       
   133      * Return an array of Base attributes that match the given attribute name
       
   134      *
       
   135      * @param string $name The name of the Base attribute to look for
       
   136      * @return array $matches Array that contains the matching list of Base attributes
       
   137      */
       
   138     public function getGbaseAttribute($name)
       
   139     {
       
   140         $matches = array();
       
   141         for ($i = 0; $i < count($this->_baseAttributes); $i++) {
       
   142             $baseAttribute = $this->_baseAttributes[$i];
       
   143             if ($baseAttribute->rootElement == $name &&
       
   144                 $baseAttribute->rootNamespaceURI == $this->lookupNamespace('g')) {
       
   145                 $matches[] = &$this->_baseAttributes[$i];
       
   146             }
       
   147         }
       
   148         return $matches;
       
   149     }
       
   150 
       
   151 }
    59 }