oxseoencodermanufacturer.php

Go to the documentation of this file.
00001 <?php
00002 
00007 class oxSeoEncoderManufacturer extends oxSeoEncoder
00008 {
00009 
00015     protected $_aRootManufacturerUri = null;
00016 
00022     protected function _getUrlExtension()
00023     {
00024         return '/';
00025     }
00026 
00036     public function getManufacturerUri($oManufacturer, $iLang = null, $blRegenerate = false)
00037     {
00038         if (!isset($iLang)) {
00039             $iLang = $oManufacturer->getLanguage();
00040         }
00041         // load from db
00042         if ($blRegenerate || !($sSeoUrl = $this->_loadFromDb('oxmanufacturer', $oManufacturer->getId(), $iLang))) {
00043 
00044             if ($iLang != $oManufacturer->getLanguage()) {
00045                 $sId = $oManufacturer->getId();
00046                 $oManufacturer = oxNew('oxmanufacturer');
00047                 $oManufacturer->loadInLang($iLang, $sId);
00048             }
00049 
00050             $sSeoUrl = '';
00051             if ($oManufacturer->getId() != 'root') {
00052                 if (!isset($this->_aRootManufacturerUri[$iLang])) {
00053                     $oRootManufacturer = oxNew('oxmanufacturer');
00054                     $oRootManufacturer->loadInLang($iLang, 'root');
00055                     $this->_aRootManufacturerUri[$iLang] = $this->getManufacturerUri($oRootManufacturer, $iLang);
00056                 }
00057                 $sSeoUrl .= $this->_aRootManufacturerUri[$iLang];
00058             }
00059 
00060             $sSeoUrl .= $this->_prepareTitle($oManufacturer->oxmanufacturers__oxtitle->value, false, $oManufacturer->getLanguage()) . '/';
00061             $sSeoUrl = $this->_processSeoUrl($sSeoUrl, $oManufacturer->getId(), $iLang);
00062 
00063             // save to db
00064             $this->_saveToDb('oxmanufacturer', $oManufacturer->getId(), $oManufacturer->getBaseStdLink($iLang), $sSeoUrl, $iLang);
00065         }
00066 
00067         return $sSeoUrl;
00068     }
00069 
00080     public function getManufacturerPageUrl($oManufacturer, $iPage, $iLang = null, $blFixed = null)
00081     {
00082         if (!isset($iLang)) {
00083             $iLang = $oManufacturer->getLanguage();
00084         }
00085         $sStdUrl = $oManufacturer->getBaseStdLink($iLang) . '&amp;pgNr=' . $iPage;
00086         $sParams = $sParams = (int) ($iPage + 1);
00087 
00088         $sStdUrl = $this->_trimUrl($sStdUrl, $iLang);
00089         $sSeoUrl = $this->getManufacturerUri($oManufacturer, $iLang) . $sParams . "/";
00090 
00091         if ($blFixed === null) {
00092             $blFixed = $this->_isFixed('oxmanufacturers', $oManufacturer->getId(), $iLang);
00093         }
00094 
00095         return $this->_getFullUrl($this->_getPageUri($oManufacturer, 'oxmanufacturers', $sStdUrl, $sSeoUrl, $sParams, $iLang, $blFixed), $iLang);
00096     }
00097 
00106     public function getManufacturerUrl($oManufacturer, $iLang = null)
00107     {
00108         if (!isset($iLang)) {
00109             $iLang = $oManufacturer->getLanguage();
00110         }
00111 
00112         return $this->_getFullUrl($this->getManufacturerUri($oManufacturer, $iLang), $iLang);
00113     }
00114 
00120     public function onDeleteManufacturer($oManufacturer)
00121     {
00122         $oDb = oxDb::getDb();
00123         $sIdQuoted = $oDb->quote($oManufacturer->getId());
00124         $oDb->execute("delete from oxseo where oxobjectid = $sIdQuoted and oxtype = 'oxmanufacturer'");
00125         $oDb->execute("delete from oxobject2seodata where oxobjectid = $sIdQuoted");
00126     }
00127 
00136     protected function _getAltUri($sObjectId, $iLang)
00137     {
00138         $sSeoUrl = null;
00139         $oManufacturer = oxNew("oxmanufacturer");
00140         if ($oManufacturer->loadInLang($iLang, $sObjectId)) {
00141             $sSeoUrl = $this->getManufacturerUri($oManufacturer, $iLang, true);
00142         }
00143 
00144         return $sSeoUrl;
00145     }
00146 }