/** * Singleton method * * @return oxSeoEncoderVendor */ public static function getInstance() { if (defined('OXID_PHP_UNIT')) { self::$_instance = modInstances::getMod(__CLASS__); } if (!self::$_instance) { self::$_instance = oxNew("oxSeoEncoderVendor"); if (defined('OXID_PHP_UNIT')) { modInstances::addMod(__CLASS__, self::$_instance); } } if (defined('OXID_PHP_UNIT')) { // resetting cache self::$_instance->_aSeoCache = array(); } return self::$_instance; }
/** * 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)) { oxSeoEncoderVendor::getInstance()->onDeleteVendor($this); return true; } return false; }
/** * Returns current object type seo encoder object * * @return oxSeoEncoderVendor */ protected function _getEncoder() { return oxSeoEncoderVendor::getInstance(); }
/** * Processes vendor category URLs * * @return null */ protected function _seoSetVendorData() { // only when SEO id on and in front end if (oxUtils::getInstance()->seoIsActive() && !$this->isAdmin()) { $oEncoder = oxSeoEncoderVendor::getInstance(); // preparing root vendor category if ($this->_oRoot) { $oEncoder->getVendorUrl($this->_oRoot); } // encoding vendor category foreach ($this as $sVndId => $value) { $oEncoder->getVendorUrl($this->_aArray[$sVndId]); } } }
/** * Sets details locator data for articles that came from vendor list. * * @param oxubase $oLocatorTarget oxubase object * @param oxarticle $oCurrArticle current article * * @return null */ protected function _setVendorLocatorData($oLocatorTarget, $oCurrArticle) { if ($oVendor = $oLocatorTarget->getActVendor()) { $sVendorId = $oVendor->getId(); $myUtils = oxUtils::getInstance(); $blSeo = $myUtils->seoIsActive(); // loading data for article navigation $oIdList = oxNew("oxarticlelist"); if ($oLocatorTarget->showSorting()) { $oLocatorTarget->prepareSortColumns(); $oIdList->setCustomSorting($oLocatorTarget->getSortingSql("{$sVendorId}:vendor")); } $oIdList->loadVendorIds($sVendorId); //page number $iPage = $this->_findActPageNumber($oLocatorTarget->getActPage(), $oIdList, $oCurrArticle); $sAdd = null; if (!$blSeo) { $sAdd = 'listtype=vendor&cnid=v_' . $sVendorId; } // setting product position in list, amount of articles etc $oVendor->iCntOfProd = $oIdList->count(); $oVendor->iProductPos = $this->_getProductPos($oCurrArticle, $oIdList, $oLocatorTarget); if ($blSeo && $iPage) { $oVendor->toListLink = oxSeoEncoderVendor::getInstance()->getVendorPageUrl($oVendor, $iPage); } else { $oVendor->toListLink = $this->_makeLink($oVendor->getLink(), $this->_getPageNumber($iPage)); } $oVendor->nextProductLink = $this->_oNextProduct ? $this->_makeLink($this->_oNextProduct->getLink(), $sAdd) : null; $oVendor->prevProductLink = $this->_oBackProduct ? $this->_makeLink($this->_oBackProduct->getLink(), $sAdd) : null; // active vendor $oLocatorTarget->setActiveCategory($oVendor); // vendor path if ($oVendorTree = $oLocatorTarget->getVendorTree()) { $oLocatorTarget->setCatTreePath($oVendorTree->getPath()); } } }
/** * Returns vendor 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 getArticleVendorUri($oArticle, $iLang, $blRegenerate = false) { startProfile(__FUNCTION__); $sSeoUri = null; if ($oVendor = $this->_getVendor($oArticle, $iLang)) { //load details link from DB if ($blRegenerate || !($sSeoUri = $this->_loadFromDb('oxarticle', $oArticle->getId(), $iLang, null, $oVendor->getId(), true))) { $oArticle = $this->_getProductForLang($oArticle, $iLang); // create title part for uri $sTitle = $this->_prepareArticleTitle($oArticle); // create uri for all categories $sSeoUri = oxSeoEncoderVendor::getInstance()->getVendorUri($oVendor, $iLang); $sSeoUri = $this->_processSeoUrl($sSeoUri . $sTitle, $oArticle->getId(), $iLang); $aStdParams = array('cnid' => "v_" . $oVendor->getId(), 'listtype' => $this->_getListType()); $this->_saveToDb('oxarticle', $oArticle->getId(), oxUtilsUrl::getInstance()->appendUrl($oArticle->getBaseStdLink($iLang), $aStdParams), $sSeoUri, $iLang, null, 0, $oVendor->getId()); } stopProfile(__FUNCTION__); } return $sSeoUri; }