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         return self::$_instance;
00025     }
00026 
00036     protected function _getContentUri( $oCont, $iLang = null)
00037     {
00038         if (!isset($iLang)) {
00039             $iLang = $oCont->getLanguage();
00040         }
00041         //load details link from DB
00042         if ( !( $sSeoUrl = $this->_loadFromDb( 'oxcontent', $oCont->getId(), $iLang ) ) ) {
00043 
00044             if ( $iLang != $oCont->getLanguage() ) {
00045                 $oCont->loadInLang( $iLang, $oCont->getId() );
00046             }
00047 
00048             $sSeoUrl = '';
00049             if ( $oCont->oxcontents__oxcatid->value ) {
00050                 $oCat = oxNew( 'oxcategory' );
00051                 if ( $oCat->loadInLang( $iLang, $oCont->oxcontents__oxcatid->value ) ) {
00052                     if ( $oCat->oxcategories__oxparentid->value && $oCat->oxcategories__oxparentid->value != 'oxrootid' ) {
00053                         $oParentCat = oxNew( 'oxcategory' );
00054                         if ( $oParentCat->loadInLang( $iLang, $oCat->oxcategories__oxparentid->value ) ) {
00055                             $sSeoUrl .= oxSeoEncoderCategory::getInstance()->getCategoryUri( $oParentCat );
00056                         }
00057                     }
00058                 }
00059             }
00060 
00061             $sSeoUrl .= $this->_prepareTitle( $oCont->oxcontents__oxtitle->value . '/' );
00062             $sSeoUrl  = $this->_getUniqueSeoUrl( $sSeoUrl, '/', $oCont->getId(), $iLang );
00063 
00064             $this->_saveToDb( 'oxcontent', $oCont->getId(), $oCont->getStdLink(), $sSeoUrl, $iLang );
00065         }
00066         return $sSeoUrl;
00067     }
00068 
00079     public function getContentUrl( $oCont, $iLang = null)
00080     {
00081         if (!isset($iLang)) {
00082             $iLang = $oCont->getLanguage();
00083         }
00084         return $this->_getFullUrl( $this->_getContentUri( $oCont, $iLang ), $iLang );
00085     }
00086 
00094     public function onDeleteContent($oCont)
00095     {
00096         $sId = oxDb::getDb()->quote($oCont->getId());
00097         oxDb::getDb()->execute("delete from oxseo where oxobjectid = $sId and oxtype = 'oxcontent'");
00098     }
00099 }

Generated on Wed Apr 22 12:26:31 2009 for OXID eShop CE by  doxygen 1.5.5