oxseoencodercontent.php

Go to the documentation of this file.
00001 <?php
00002 
00007 class oxSeoEncoderContent extends oxSeoEncoder
00008 {
00009 
00015     protected function _getUrlExtension()
00016     {
00017         return '/';
00018     }
00019 
00030     public function getContentUri($oCont, $iLang = null, $blRegenerate = false)
00031     {
00032         if (!isset($iLang)) {
00033             $iLang = $oCont->getLanguage();
00034         }
00035         //load details link from DB
00036         if ($blRegenerate || !($sSeoUrl = $this->_loadFromDb('oxContent', $oCont->getId(), $iLang))) {
00037 
00038             if ($iLang != $oCont->getLanguage()) {
00039                 $sId = $oCont->getId();
00040                 $oCont = oxNew('oxContent');
00041                 $oCont->loadInLang($iLang, $sId);
00042             }
00043 
00044             $sSeoUrl = '';
00045             if ($oCont->getCategoryId() && $oCont->getType() === 2) {
00046                 $oCat = oxNew('oxCategory');
00047                 if ($oCat->loadInLang($iLang, $oCont->oxcontents__oxcatid->value)) {
00048                     $sParentId = $oCat->oxcategories__oxparentid->value;
00049                     if ($sParentId && $sParentId != 'oxrootid') {
00050                         $oParentCat = oxNew('oxCategory');
00051                         if ($oParentCat->loadInLang($iLang, $oCat->oxcategories__oxparentid->value)) {
00052                             $sSeoUrl .= oxRegistry::get("oxSeoEncoderCategory")->getCategoryUri($oParentCat);
00053                         }
00054                     }
00055                 }
00056             }
00057 
00058             $sSeoUrl .= $this->_prepareTitle($oCont->oxcontents__oxtitle->value, false, $oCont->getLanguage()) . '/';
00059             $sSeoUrl = $this->_processSeoUrl($sSeoUrl, $oCont->getId(), $iLang);
00060 
00061             $this->_saveToDb('oxcontent', $oCont->getId(), $oCont->getBaseStdLink($iLang), $sSeoUrl, $iLang);
00062         }
00063 
00064         return $sSeoUrl;
00065     }
00066 
00075     public function getContentUrl($oCont, $iLang = null)
00076     {
00077         if (!isset($iLang)) {
00078             $iLang = $oCont->getLanguage();
00079         }
00080 
00081         return $this->_getFullUrl($this->getContentUri($oCont, $iLang), $iLang);
00082     }
00083 
00089     public function onDeleteContent($sId)
00090     {
00091         $oDb = oxDb::getDb();
00092         $sIdQuoted = $oDb->quote($sId);
00093         $oDb->execute("delete from oxseo where oxobjectid = $sIdQuoted and oxtype = 'oxcontent'");
00094         $oDb->execute("delete from oxobject2seodata where oxobjectid = $sIdQuoted");
00095     }
00096 
00105     protected function _getAltUri($sObjectId, $iLang)
00106     {
00107         $sSeoUrl = null;
00109         $oCont = oxNew("oxcontent");
00110         if ($oCont->loadInLang($iLang, $sObjectId)) {
00111             $sSeoUrl = $this->getContentUri($oCont, $iLang, true);
00112         }
00113 
00114         return $sSeoUrl;
00115     }
00116 }