/** * * @since 3 */ protected function _getValueFromRow($sColumnName, array $aRow, $mDefault = null, $aScheduleTask = array('locale' => '', 'asin' => '', 'associate_id' => '')) { $_mValue = $this->getElement($aRow, array($sColumnName), null); $_bIsSet = !is_null($_mValue); $_mValue = $_bIsSet ? maybe_unserialize($_mValue) : $mDefault; // Now schedule a background task to retrieve product info. $_bScheduleTask = !$this->isEmpty(array_filter($aScheduleTask)); $_sModifiedTime = $this->getElement($aRow, array('modified_time'), '0000-00-00 00:00:00'); $_iCacheDuration = (int) $this->oUnitOption->get('cache_duration'); $_iExpirationTime = strtotime($_sModifiedTime) + $_iCacheDuration; $_bIsExpired = $this->isExpired($_iExpirationTime); if ($_bScheduleTask && $_bIsExpired) { AmazonAutoLinks_Event_Scheduler::getProductInfo($aScheduleTask['associate_id'], $aScheduleTask['asin'], $aScheduleTask['locale'], $_iCacheDuration); } // Now schedule a debug info to be inserted at the bottom of the product output. if (!$_bIsSet && $this->oOption->isDebug()) { $this->_setColumnItemDebugInfo($sColumnName, $aScheduleTask['asin'] . '_' . $aScheduleTask['locale'], array('column_name' => $sColumnName, 'value' => 'NULL', 'cache_duration' => $_iCacheDuration, 'expiry_time' => $_iExpirationTime, 'now' => time(), 'is_expired' => $_bIsExpired) + $aScheduleTask); } return $_mValue; }
/** * * @since 3 * @return string */ public function formatUserRating($sASIN, $sLocale, $sAssociateID, array $aRow = array()) { $_sEncodedHTML = $this->_getValueFromRow('rating_html', $aRow, null, array('asin' => $sASIN, 'locale' => $sLocale, 'associate_id' => $sAssociateID)); // If the value is null, it means the value does not exist in the database table. if (null === $_sEncodedHTML) { AmazonAutoLinks_Event_Scheduler::getProductInfo($sAssociateID, $sASIN, $sLocale, (int) $this->oUnitOption->get('cache_duration')); return $this->oUnitOption->get('show_now_retrieving_message') ? '<p>' . __('Now retrieving the rating.', 'amazon-auto-links') . '</p>' : ''; } if ('' === $_sEncodedHTML) { return ''; } // Now modify the raw output. $_oScraper = new AmazonAutoLinks_ScraperDOM_UserRating($_sEncodedHTML, true); return "<div class='amazon-customer-rating-stars'>" . $_oScraper->get() . "</div>"; }