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 
00038     protected function _getUrlExtension()
00039     {
00040         return '/';
00041     }
00042 
00052     protected function _getContentUri( $oCont, $iLang = null)
00053     {
00054         if (!isset($iLang)) {
00055             $iLang = $oCont->getLanguage();
00056         }
00057         //load details link from DB
00058         if ( !( $sSeoUrl = $this->_loadFromDb( 'oxcontent', $oCont->getId(), $iLang ) ) ) {
00059 
00060             if ( $iLang != $oCont->getLanguage() ) {
00061                 $oCont->loadInLang( $iLang, $oCont->getId() );
00062             }
00063 
00064             $sSeoUrl = '';
00065             if ( $oCont->oxcontents__oxcatid->value ) {
00066                 $oCat = oxNew( 'oxcategory' );
00067                 if ( $oCat->loadInLang( $iLang, $oCont->oxcontents__oxcatid->value ) ) {
00068                     if ( $oCat->oxcategories__oxparentid->value && $oCat->oxcategories__oxparentid->value != 'oxrootid' ) {
00069                         $oParentCat = oxNew( 'oxcategory' );
00070                         if ( $oParentCat->loadInLang( $iLang, $oCat->oxcategories__oxparentid->value ) ) {
00071                             $sSeoUrl .= oxSeoEncoderCategory::getInstance()->getCategoryUri( $oParentCat );
00072                         }
00073                     }
00074                 }
00075             }
00076 
00077             $sSeoUrl .= $this->_prepareTitle( $oCont->oxcontents__oxtitle->value ) . '/';
00078             $sSeoUrl  = $this->_processSeoUrl( $sSeoUrl, $oCont->getId(), $iLang );
00079 
00080             $this->_saveToDb( 'oxcontent', $oCont->getId(), $oCont->getStdLink(), $sSeoUrl, $iLang );
00081         }
00082         return $sSeoUrl;
00083     }
00084 
00095     public function getContentUrl( $oCont, $iLang = null)
00096     {
00097         if (!isset($iLang)) {
00098             $iLang = $oCont->getLanguage();
00099         }
00100         return $this->_getFullUrl( $this->_getContentUri( $oCont, $iLang ), $iLang );
00101     }
00102 
00110     public function onDeleteContent($sId)
00111     {
00112         $sIdQuoted = oxDb::getDb()->quote($sId);
00113         oxDb::getDb()->execute("delete from oxseo where oxobjectid = $sIdQuoted and oxtype = 'oxcontent'");
00114     }
00115 }

Generated on Mon Oct 26 20:07:17 2009 for OXID eShop CE by  doxygen 1.5.5