/** * Constructor for Zend_Gdata_Books_Extension_BooksLink which * Extends the base Link class with Books extensions * * @param string|null $href Linked resource URI * @param string|null $rel Forward relationship * @param string|null $type Resource MIME type * @param string|null $hrefLang Resource language * @param string|null $title Human-readable resource title * @param string|null $length Resource length in octets */ public function __construct($href = null, $rel = null, $type = null, $hrefLang = null, $title = null, $length = null) { foreach (Zend_Gdata_Books::$namespaces as $nsPrefix => $nsUri) { $this->registerNamespace($nsPrefix, $nsUri); } parent::__construct($href, $rel, $type, $hrefLang, $title, $length); }
/** * 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') . ':' . 'token': $token = new Zend_Gdata_YouTube_Extension_Token(); $token->transferFromDOM($child); $this->_token = $token; break; default: parent::takeChildFromDOM($child); break; } }
/** * 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('gCal') . ':' . 'webContent': $webContent = new Zend_Gdata_Calendar_Extension_WebContent(); $webContent->transferFromDOM($child); $this->_webContent = $webContent; break; default: parent::takeChildFromDOM($child); break; } }
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; } }
/** * Constructor for Zend_Gdata_Books_Extension_BooksLink which * Extends the base Link class with Books extensions * * @param string|null $href Linked resource URI * @param string|null $rel Forward relationship * @param string|null $type Resource MIME type * @param string|null $hrefLang Resource language * @param string|null $title Human-readable resource title * @param string|null $length Resource length in octets */ public function __construct($href = null, $rel = null, $type = null, $hrefLang = null, $title = null, $length = null) { $this->registerAllNamespaces(Zend_Gdata_Books::$namespaces); parent::__construct($href, $rel, $type, $hrefLang, $title, $length); }
/** * 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 'url': $this->_url = $attribute->nodeValue; break; case 'height': $this->_height = $attribute->nodeValue; break; case 'width': $this->_width = $attribute->nodeValue; break; default: parent::takeAttributeFromDOM($attribute); } }
private function _insert($productId, &$params) { $dryRun = Axis::config()->gbase->main->dryRun; $tableLanguage = Axis::single('locale/language'); $currentLanguage = $tableLanguage->find($params['language'])->current(); /* Get local product data */ $tableProduct = Axis::single('catalog/product'); $tableManufacture = Axis::single('catalog/product_manufacturer'); $currencyModel = Axis::single('locale/currency'); $zendCurrency = $currencyModel->getCurrency($params['currency']); $rate = $currencyModel->getData($params['currency'], 'rate'); $currencyOptions = array('position' => Zend_Currency::RIGHT, 'display' => Zend_Currency::USE_SHORTNAME); $product = $tableProduct->find($productId)->current(); $productUrl = $product->getHumanUrl(); $productDescription = $product->getDescription($params['language']); if ($product->manufacturer_id != '0') { $productManufacture = $tableManufacture->find($product->manufacturer_id)->current(); } $productCategories = $product->getCategories($params['language']); $entry = $this->_service->newItemEntry(); /* Atom namespace */ $entry->title = $this->_service->newTitle(trim($productDescription['name'])); $content = $productDescription['description'] == '' ? Axis::translate('catalog')->__('No description available') : trim($productDescription['description']); $entry->content = $this->_service->newContent($content); $entry->content->type = 'text'; $entry->itemType = Axis::config()->gbase->main->itemType; if (Axis::config()->gbase->main->link == 'Website' && ($siteUrl = $this->_getSiteUrl($params['site']))) { $link = new Zend_Gdata_App_Extension_Link(); $link->setHref(preg_replace('/\\s+/', '%20', trim($siteUrl . '/' . $this->view->catalogUrl . '/' . $productUrl))); $link->setRel('alternate'); $link->setType('text/html'); $link->setTitle(trim($productDescription['name'])); $linkArray[] = $link; $entry->setLink($linkArray); } else { $entry->addGbaseAttribute('payment_accepted', 'Google Checkout', 'text'); } /* G namespace */ //$price = $zendCurrency->toCurrency($product->price * $rate, $currencyOptions); $price = $product->price * $rate; $entry->addGbaseAttribute('price', $price, 'floatUnit'); $entry->addGbaseAttribute('condition', 'new', 'text'); $entry->addGbaseAttribute('id', $product->sku . '_' . $params['country'], 'text'); $entry->addGbaseAttribute('quantity', (int) $product->quantity, 'int'); $entry->addGbaseAttribute('weight', "{$product->weight} lbs", 'numberUnit'); //@TODO get weight unit if ($productManufacture) { $entry->addGbaseAttribute('brand', $productManufacture->name, 'text'); } $entry->addGbaseAttribute('target_country', $params['country'], 'text'); $entry->addGbaseAttribute('item_language', $currentLanguage->code, 'text'); if ($siteUrl) { $entry->addGbaseAttribute('image_link', preg_replace('/\\s+/', '%20', trim($siteUrl . '/media' . '/product' . $product->image_base)), 'url'); } foreach ($productCategories as $category) { $entry->addGbaseAttribute('product_type', $category['name'], 'text'); } foreach (Axis::config()->gbase->main->payment as $payment) { if ($payment != '') { $entry->addGbaseAttribute('payment', $payment, 'text'); } } if (Axis::config()->gbase->main->notes != '') { $entry->addGbaseAttribute('payment_notes', Axis::config()->gbase->main->notes, 'text'); } if (Axis::config()->gbase->main->application != '') { $entry->addGbaseAttribute('application', Axis::config()->gbase->main->application, 'text'); } $attributes = $this->_getProductAttributes($product, $params['language']); foreach ($attributes as $attr_id => $attribute) { $attrName = $attribute['optionName']; $attrValue = isset($attribute['valueName']) ? $attribute['valueName'] : $attribute['values']; $entry->addGbaseAttribute(preg_replace('/\\s+/', '_', $attrName), $attrValue, 'text'); } /* Private attributes */ $entry->addGbaseAttribute('site', $params['site'], 'int'); $array = $entry->getExtensionElements(); $privateAttr = array(); $privateAttr[0]['name'] = 'access'; $privateAttr[0]['value'] = 'private'; $privateAttr[1]['name'] = 'type'; $privateAttr[1]['value'] = 'int'; $localId = new Zend_Gdata_App_Extension_Element('local_id', 'g', 'http://base.google.com/ns/1.0', $product->id); $localId->setExtensionAttributes($privateAttr); $array[count($array)] = $localId; $entry->setExtensionElements($array); Axis::session('gbase')->last_exported = $productId; Axis::session('gbase')->processed_count++; try { $this->_service->insertGbaseItem($entry, $dryRun); Axis::session('gbase')->imported_count++; } catch (Exception $e) { Axis::message()->addError($this->view->escape($e->getMessage())); try { $log = new Zend_Log(new Zend_Log_Writer_Stream(Axis::config()->system->path . '/var/logs/gbase.log')); $log->err($e->getMessage()); } catch (Exception $e) { Axis::message()->addError($e->getMessage()); } } }