oxseoencodervendor.php

Go to the documentation of this file.
00001 <?php
00002 
00007 class oxSeoEncoderVendor extends oxSeoEncoder
00008 {
00014     protected static $_instance = null;
00015 
00021     protected $_aRootVendorUri = null;
00022 
00028     public static function getInstance()
00029     {
00030         if (!self::$_instance) {
00031             self::$_instance = oxNew("oxSeoEncoderVendor");
00032         }
00033         return self::$_instance;
00034     }
00035 
00044     public function getVendorUri( $oVendor, $iLang = null )
00045     {
00046         if (!isset($iLang)) {
00047             $iLang = $oVendor->getLanguage();
00048         }
00049         // load from db
00050         if ( !( $sSeoUrl = $this->_loadFromDb( 'oxvendor', $oVendor->getId(), $iLang ) ) ) {
00051 
00052             if ($iLang != $oVendor->getLanguage()) {
00053                 $sId = $oVendor->getId();
00054                 $oVendor = oxNew('oxvendor');
00055                 $oVendor->loadInLang( $iLang, $sId );
00056             }
00057 
00058             $sSeoUrl = '';
00059             if ( $oVendor->getId() != 'root' ) {
00060                 if ( !isset( $this->_aRootVendorUri[$iLang] ) ) {
00061                     $oRootVendor = oxNew('oxvendor');
00062                     $oRootVendor->loadInLang( $iLang, 'root' );
00063                     $this->_aRootVendorUri[$iLang] = $this->getVendorUri( $oRootVendor, $iLang );
00064                 }
00065                 $sSeoUrl .= $this->_aRootVendorUri[$iLang];
00066             }
00067 
00068             $sSeoUrl .= $this->_prepareTitle( $oVendor->oxvendor__oxtitle->value .'/' );
00069             $sSeoUrl  = $this->_getUniqueSeoUrl( $sSeoUrl, '/', $oVendor->getId(), $iLang );
00070 
00071             // save to db
00072             $this->_saveToDb( 'oxvendor', $oVendor->getId(), $oVendor->getStdLink(), $sSeoUrl, $iLang );
00073         }
00074         return $sSeoUrl;
00075     }
00076 
00087     public function getVendorPageUrl( $oVendor, $iPage, $iLang = null, $blFixed = false )
00088     {
00089         if (!isset($iLang)) {
00090             $iLang = $oVendor->getLanguage();
00091         }
00092         $sStdUrl = $oVendor->getStdLink() . '&amp;pgNr=' . $iPage;
00093         $sParams = sprintf( "%0" . ceil( $this->_iCntPages / 10 + 1 ) . "d", $iPage + 1 );
00094 
00095         $sStdUrl = $this->_trimUrl( $sStdUrl, $iLang );
00096         $sSeoUrl = $this->getVendorUri( $oVendor, $iLang ) . $sParams . "/";
00097 
00098         return $this->_getFullUrl( $this->_getPageUri( $oVendor, 'oxvendor', $sStdUrl, $sSeoUrl, $sParams, $iLang, $blFixed ), $iLang );
00099     }
00100 
00109     public function getVendorUrl( $oVendor, $iLang = null )
00110     {
00111         if (!isset($iLang)) {
00112             $iLang = $oVendor->getLanguage();
00113         }
00114         return $this->_getFullUrl( $this->getVendorUri( $oVendor, $iLang ), $iLang );
00115     }
00116 
00124     public function onDeleteVendor($oVendor)
00125     {
00126         $sId = oxDb::getDb()->quote($oVendor->getId());
00127         oxDb::getDb()->execute("delete from oxseo where oxobjectid = $sId and oxtype = 'oxvendor'");
00128     }
00129 }

Generated on Wed Jun 17 12:09:02 2009 for OXID eShop CE by  doxygen 1.5.5