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 ( defined( 'OXID_PHP_UNIT' ) ) {
00022             self::$_instance = modInstances::getMod( __CLASS__ );
00023         }
00024 
00025         if (!self::$_instance) {
00026             self::$_instance = oxNew("oxSeoEncoderContent");
00027             if ( defined( 'OXID_PHP_UNIT' ) ) {
00028                 modInstances::addMod( __CLASS__, self::$_instance);
00029             }
00030         }
00031 
00032         if ( defined( 'OXID_PHP_UNIT' ) ) {
00033             // resetting cache
00034             self::$_instance->_aSeoCache = array();
00035         }
00036 
00037         return self::$_instance;
00038     }
00039 
00045     protected function _getUrlExtension()
00046     {
00047         return '/';
00048     }
00049 
00059     protected function _getContentUri( $oCont, $iLang = null)
00060     {
00061         if (!isset($iLang)) {
00062             $iLang = $oCont->getLanguage();
00063         }
00064         //load details link from DB
00065         if ( !( $sSeoUrl = $this->_loadFromDb( 'oxcontent', $oCont->getId(), $iLang ) ) ) {
00066 
00067             if ( $iLang != $oCont->getLanguage() ) {
00068                 $sId = $oCont->getId();
00069                 $oCont = oxNew('oxcontent');
00070                 $oCont->loadInLang( $iLang, $sId );
00071             }
00072 
00073             $sSeoUrl = '';
00074             if ( $oCont->oxcontents__oxcatid->value ) {
00075                 $oCat = oxNew( 'oxcategory' );
00076                 if ( $oCat->loadInLang( $iLang, $oCont->oxcontents__oxcatid->value ) ) {
00077                     if ( $oCat->oxcategories__oxparentid->value && $oCat->oxcategories__oxparentid->value != 'oxrootid' ) {
00078                         $oParentCat = oxNew( 'oxcategory' );
00079                         if ( $oParentCat->loadInLang( $iLang, $oCat->oxcategories__oxparentid->value ) ) {
00080                             $sSeoUrl .= oxSeoEncoderCategory::getInstance()->getCategoryUri( $oParentCat );
00081                         }
00082                     }
00083                 }
00084             }
00085 
00086             $sSeoUrl .= $this->_prepareTitle( $oCont->oxcontents__oxtitle->value ) . '/';
00087             $sSeoUrl  = $this->_processSeoUrl( $sSeoUrl, $oCont->getId(), $iLang );
00088 
00089             $this->_saveToDb( 'oxcontent', $oCont->getId(), $oCont->getStdLink(), $sSeoUrl, $iLang );
00090         }
00091         return $sSeoUrl;
00092     }
00093 
00104     public function getContentUrl( $oCont, $iLang = null)
00105     {
00106         if (!isset($iLang)) {
00107             $iLang = $oCont->getLanguage();
00108         }
00109         return $this->_getFullUrl( $this->_getContentUri( $oCont, $iLang ), $iLang );
00110     }
00111 
00119     public function onDeleteContent($sId)
00120     {
00121         $sIdQuoted = oxDb::getDb()->quote($sId);
00122         oxDb::getDb()->execute("delete from oxseo where oxobjectid = $sIdQuoted and oxtype = 'oxcontent'");
00123     }
00124 }

Generated by  doxygen 1.6.2