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;
     }
 }
Ejemplo n.º 2
0
 /**
  * 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();
 }
Ejemplo n.º 3
0
 /**
  * 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);
 }
Ejemplo n.º 4
0
 /**
  * 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)
 {
     switch ($attribute->localName) {
         case 'errorCode':
             $this->_errorCode = $attribute->nodeValue;
             break;
         case 'reason':
             $this->_reason = $attribute->nodeValue;
             break;
         case 'invalidInput':
             $this->_invalidInput = $attribute->nodeValue;
             break;
         default:
             parent::takeAttributeFromDOM($attribute);
     }
 }
Ejemplo n.º 5
0
 public function testLookupNamespaceObeysParentBehavior()
 {
     $prefix = 'test';
     $testString10 = 'TEST-v1-0';
     $testString20 = 'TEST-v2-0';
     $testString11 = 'TEST-v1-1';
     $testString21 = 'TEST-v2-1';
     $testString12 = 'TEST-v1-2';
     $testString22 = 'TEST-v2-2';
     Zend_Gdata_App_Base::flushNamespaceLookupCache();
     $entry = $this->service->newEntry();
     $entry->registerNamespace($prefix, $testString10, 1, 0);
     $entry->registerNamespace($prefix, $testString20, 2, 0);
     $entry->registerNamespace($prefix, $testString11, 1, 1);
     $entry->registerNamespace($prefix, $testString21, 2, 1);
     $entry->registerNamespace($prefix, $testString12, 1, 2);
     $entry->registerNamespace($prefix, $testString22, 2, 2);
     // Assumes default version (1)
     $result = $entry->lookupNamespace($prefix, 1, null);
     $this->assertEquals($testString12, $result);
     $result = $entry->lookupNamespace($prefix, 2, null);
     $this->assertEquals($testString22, $result);
     $result = $entry->lookupNamespace($prefix, 1, 1);
     $this->assertEquals($testString11, $result);
     $result = $entry->lookupNamespace($prefix, 2, 1);
     $this->assertEquals($testString21, $result);
     $result = $entry->lookupNamespace($prefix, null, null);
     $this->assertEquals($testString12, $result);
     $result = $entry->lookupNamespace($prefix, null, 1);
     $this->assertEquals($testString11, $result);
     // Override to retrieve latest version
     $entry->setMajorProtocolVersion(null);
     $result = $entry->lookupNamespace($prefix, null, null);
     $this->assertEquals($testString22, $result);
     $result = $entry->lookupNamespace($prefix, null, 1);
     $this->assertEquals($testString21, $result);
 }