oxseoencodercontent.php

Go to the documentation of this file.
00001 <?php
00002 
00007 class oxSeoEncoderContent extends oxSeoEncoder
00008 {
00012     protected static $_instance = null;
00013 
00019     public static function getInstance()
00020     {
00021         if (!self::$_instance) {
00022             self::$_instance = oxNew("oxSeoEncoderContent");
00023         }
00024 
00025         if ( defined( 'OXID_PHP_UNIT' ) ) {
00026             // resetting cache
00027             self::$_instance->_aSeoCache = array();
00028         }
00029 
00030         return self::$_instance;
00031     }
00032 
00042     protected function _getContentUri( $oCont, $iLang = null)
00043     {
00044         if (!isset($iLang)) {
00045             $iLang = $oCont->getLanguage();
00046         }
00047         //load details link from DB
00048         if ( !( $sSeoUrl = $this->_loadFromDb( 'oxcontent', $oCont->getId(), $iLang ) ) ) {
00049 
00050             if ( $iLang != $oCont->getLanguage() ) {
00051                 $oCont->loadInLang( $iLang, $oCont->getId() );
00052             }
00053 
00054             $sSeoUrl = '';
00055             if ( $oCont->oxcontents__oxcatid->value ) {
00056                 $oCat = oxNew( 'oxcategory' );
00057                 if ( $oCat->loadInLang( $iLang, $oCont->oxcontents__oxcatid->value ) ) {
00058                     if ( $oCat->oxcategories__oxparentid->value && $oCat->oxcategories__oxparentid->value != 'oxrootid' ) {
00059                         $oParentCat = oxNew( 'oxcategory' );
00060                         if ( $oParentCat->loadInLang( $iLang, $oCat->oxcategories__oxparentid->value ) ) {
00061                             $sSeoUrl .= oxSeoEncoderCategory::getInstance()->getCategoryUri( $oParentCat );
00062                         }
00063                     }
00064                 }
00065             }
00066 
00067             $sSeoUrl .= $this->_prepareTitle( $oCont->oxcontents__oxtitle->value . '/' );
00068             $sSeoUrl  = $this->_getUniqueSeoUrl( $sSeoUrl, '/', $oCont->getId(), $iLang );
00069 
00070             $this->_saveToDb( 'oxcontent', $oCont->getId(), $oCont->getStdLink(), $sSeoUrl, $iLang );
00071         }
00072         return $sSeoUrl;
00073     }
00074 
00085     public function getContentUrl( $oCont, $iLang = null)
00086     {
00087         if (!isset($iLang)) {
00088             $iLang = $oCont->getLanguage();
00089         }
00090         return $this->_getFullUrl( $this->_getContentUri( $oCont, $iLang ), $iLang );
00091     }
00092 
00100     public function onDeleteContent($oCont)
00101     {
00102         $sId = oxDb::getDb()->quote($oCont->getId());
00103         oxDb::getDb()->execute("delete from oxseo where oxobjectid = $sId and oxtype = 'oxcontent'");
00104     }
00105 }

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