/** * Singleton method * * @return oxSeoEncoderManufacturer */ public static function getInstance() { if (defined('OXID_PHP_UNIT')) { self::$_instance = modInstances::getMod(__CLASS__); } if (!self::$_instance) { self::$_instance = oxNew("oxSeoEncoderManufacturer"); if (defined('OXID_PHP_UNIT')) { modInstances::addMod(__CLASS__, self::$_instance); } } if (defined('OXID_PHP_UNIT')) { // resetting cache self::$_instance->_aSeoCache = array(); } return self::$_instance; }
/** * Processes manufacturer category URLs * * @return null */ protected function _seoSetManufacturerData() { // only when SEO id on and in front end if (oxUtils::getInstance()->seoIsActive() && !$this->isAdmin()) { $oEncoder = oxSeoEncoderManufacturer::getInstance(); // preparing root manufacturer category if ($this->_oRoot) { $oEncoder->getManufacturerUrl($this->_oRoot); } // encoding manufacturer category foreach ($this as $sVndId => $value) { $oEncoder->getManufacturerUrl($this->_aArray[$sVndId]); } } }
/** * Returns current object type seo encoder object * * @return oxSeoEncoderManufacturer */ protected function _getEncoder() { return oxSeoEncoderManufacturer::getInstance(); }
/** * Sets details locator data for articles that came from Manufacturer list. * * @param oxubase $oLocatorTarget oxubase object * @param oxarticle $oCurrArticle current article * * @return null */ protected function _setManufacturerLocatorData($oLocatorTarget, $oCurrArticle) { if ($oManufacturer = $oLocatorTarget->getActManufacturer()) { $sManufacturerId = $oManufacturer->getId(); $myUtils = oxUtils::getInstance(); $blSeo = $myUtils->seoIsActive(); // loading data for article navigation $oIdList = oxNew("oxarticlelist"); if ($oLocatorTarget->showSorting()) { $oLocatorTarget->prepareSortColumns(); $oIdList->setCustomSorting($oLocatorTarget->getSortingSql("{$sManufacturerId}:manufacturer")); } $oIdList->loadManufacturerIds($sManufacturerId); //page number $iPage = $this->_findActPageNumber($oLocatorTarget->getActPage(), $oIdList, $oCurrArticle); $sAdd = null; if (!$blSeo) { $sAdd = 'listtype=manufacturer&mnid=' . $sManufacturerId; } // setting product position in list, amount of articles etc $oManufacturer->iCntOfProd = $oIdList->count(); $oManufacturer->iProductPos = $this->_getProductPos($oCurrArticle, $oIdList, $oLocatorTarget); if ($blSeo && $iPage) { $oManufacturer->toListLink = oxSeoEncoderManufacturer::getInstance()->getManufacturerPageUrl($oManufacturer, $iPage); } else { $oManufacturer->toListLink = $this->_makeLink($oManufacturer->getLink(), $this->_getPageNumber($iPage)); } $oManufacturer->nextProductLink = $this->_oNextProduct ? $this->_makeLink($this->_oNextProduct->getLink(), $sAdd) : null; $oManufacturer->prevProductLink = $this->_oBackProduct ? $this->_makeLink($this->_oBackProduct->getLink(), $sAdd) : null; // active Manufacturer $oLocatorTarget->setActiveCategory($oManufacturer); // Manufacturer path if ($oManufacturerTree = $oLocatorTarget->getManufacturerTree()) { $oLocatorTarget->setCatTreePath($oManufacturerTree->getPath()); } } }
/** * Delete this object from the database, returns true on success. * * @param string $sOXID Object ID(default null) * * @return bool */ public function delete($sOXID = null) { if (parent::delete($sOXID)) { oxSeoEncoderManufacturer::getInstance()->onDeleteManufacturer($this); return true; } return false; }
/** * Returns manufacturer seo uri for current article * * @param oxarticle $oArticle article object * @param int $iLang language id * @param bool $blRegenerate if TRUE forces seo url regeneration * * @return string */ public function getArticleManufacturerUri($oArticle, $iLang, $blRegenerate = false) { $sSeoUri = null; startProfile(__FUNCTION__); if ($oManufacturer = $this->_getManufacturer($oArticle, $iLang)) { //load details link from DB if ($blRegenerate || !($sSeoUri = $this->_loadFromDb('oxarticle', $oArticle->getId(), $iLang, null, $oManufacturer->getId(), true))) { $oArticle = $this->_getProductForLang($oArticle, $iLang); // create title part for uri $sTitle = $this->_prepareArticleTitle($oArticle); // create uri for all categories $sSeoUri = oxSeoEncoderManufacturer::getInstance()->getManufacturerUri($oManufacturer, $iLang); $sSeoUri = $this->_processSeoUrl($sSeoUri . $sTitle, $oArticle->getId(), $iLang); $aStdParams = array('mnid' => $oManufacturer->getId(), 'listtype' => $this->_getListType()); $this->_saveToDb('oxarticle', $oArticle->getId(), oxUtilsUrl::getInstance()->appendUrl($oArticle->getBaseStdLink($iLang), $aStdParams), $sSeoUri, $iLang, null, 0, $oManufacturer->getId()); } stopProfile(__FUNCTION__); } return $sSeoUri; }