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 ( defined( 'OXID_PHP_UNIT' ) ) {
00031             self::$_instance = modInstances::getMod( __CLASS__ );
00032         }
00033 
00034         if (!self::$_instance) {
00035             self::$_instance = oxNew("oxSeoEncoderVendor");
00036             if ( defined( 'OXID_PHP_UNIT' ) ) {
00037                 modInstances::addMod( __CLASS__, self::$_instance);
00038             }
00039         }
00040 
00041         if ( defined( 'OXID_PHP_UNIT' ) ) {
00042             // resetting cache
00043             self::$_instance->_aSeoCache = array();
00044         }
00045 
00046         return self::$_instance;
00047     }
00048 
00054     protected function _getUrlExtension()
00055     {
00056         return '/';
00057     }
00058 
00067     public function getVendorUri( $oVendor, $iLang = null )
00068     {
00069         if (!isset($iLang)) {
00070             $iLang = $oVendor->getLanguage();
00071         }
00072         // load from db
00073         if ( !( $sSeoUrl = $this->_loadFromDb( 'oxvendor', $oVendor->getId(), $iLang ) ) ) {
00074 
00075             if ($iLang != $oVendor->getLanguage()) {
00076                 $sId = $oVendor->getId();
00077                 $oVendor = oxNew('oxvendor');
00078                 $oVendor->loadInLang( $iLang, $sId );
00079             }
00080 
00081             $sSeoUrl = '';
00082             if ( $oVendor->getId() != 'root' ) {
00083                 if ( !isset( $this->_aRootVendorUri[$iLang] ) ) {
00084                     $oRootVendor = oxNew('oxvendor');
00085                     $oRootVendor->loadInLang( $iLang, 'root' );
00086                     $this->_aRootVendorUri[$iLang] = $this->getVendorUri( $oRootVendor, $iLang );
00087                 }
00088                 $sSeoUrl .= $this->_aRootVendorUri[$iLang];
00089             }
00090 
00091             $sSeoUrl .= $this->_prepareTitle( $oVendor->oxvendor__oxtitle->value ) .'/';
00092             $sSeoUrl  = $this->_processSeoUrl( $sSeoUrl, $oVendor->getId(), $iLang );
00093 
00094             // save to db
00095             $this->_saveToDb( 'oxvendor', $oVendor->getId(), $oVendor->getStdLink(), $sSeoUrl, $iLang );
00096         }
00097         return $sSeoUrl;
00098     }
00099 
00110     public function getVendorPageUrl( $oVendor, $iPage, $iLang = null, $blFixed = null )
00111     {
00112         if (!isset($iLang)) {
00113             $iLang = $oVendor->getLanguage();
00114         }
00115         $sStdUrl = $oVendor->getStdLink() . '&amp;pgNr=' . $iPage;
00116         $sParams = (int) ($iPage + 1);
00117 
00118         $sStdUrl = $this->_trimUrl( $sStdUrl, $iLang );
00119         $sSeoUrl = $this->getVendorUri( $oVendor, $iLang ) . $sParams . "/";
00120 
00121         if ( $blFixed === null ) {
00122             $blFixed = $this->_isFixed( 'oxvendor', $oVendor->getId(), $iLang );
00123         }
00124         return $this->_getFullUrl( $this->_getPageUri( $oVendor, 'oxvendor', $sStdUrl, $sSeoUrl, $sParams, $iLang, $blFixed ), $iLang );
00125     }
00126 
00135     public function getVendorUrl( $oVendor, $iLang = null )
00136     {
00137         if (!isset($iLang)) {
00138             $iLang = $oVendor->getLanguage();
00139         }
00140         return $this->_getFullUrl( $this->getVendorUri( $oVendor, $iLang ), $iLang );
00141     }
00142 
00150     public function onDeleteVendor($oVendor)
00151     {
00152         $sIdQuoted = oxDb::getDb()->quote($oVendor->getId());
00153         oxDb::getDb()->execute("delete from oxseo where oxobjectid = $sIdQuoted and oxtype = 'oxvendor'");
00154     }
00155 }

Generated by  doxygen 1.6.2