object_seo.php

Go to the documentation of this file.
00001 <?php
00002 
00006 class Object_Seo extends oxAdminDetails
00007 {
00015     public function render()
00016     {
00017         parent::render();
00018 
00019         if ( $sType = $this->_getType() ) {
00020             $oObject = oxNew( $sType );
00021             if ( $oObject->load( $this->getEditObjectId() ) ) {
00022                 $oOtherLang = $oObject->getAvailableInLangs();
00023                 if ( !isset( $oOtherLang[$iLang] ) ) {
00024                     $oObject->loadInLang( key( $oOtherLang ), $this->getEditObjectId() );
00025                 }
00026                 $this->_aViewData['edit'] = $oObject;
00027             }
00028 
00029         }
00030 
00031         $iLang  = $this->getEditLang();
00032         $aLangs = oxRegistry::getLang()->getLanguageNames();
00033         foreach ( $aLangs as $sLangId => $sLanguage ) {
00034             $oLang = new stdClass();
00035             $oLang->sLangDesc = $sLanguage;
00036             $oLang->selected  = ( $sLangId == $iLang );
00037             $this->_aViewData['otherlang'][$sLangId] = clone $oLang;
00038         }
00039 
00040         return 'object_seo.tpl';
00041     }
00042 
00048     public function save()
00049     {
00050         // saving/updating seo params
00051         if ( ( $sOxid = $this->_getSaveObjectId() ) ) {
00052             $aSeoData = oxConfig::getParameter( 'aSeoData' );
00053             $iShopId  = $this->getConfig()->getShopId();
00054             $iLang    = $this->getEditLang();
00055 
00056             // checkbox handling
00057             if ( !isset( $aSeoData['oxfixed'] ) ) {
00058                 $aSeoData['oxfixed'] = 0;
00059             }
00060 
00061             $sParams = $this->_getAdditionalParams($aSeoData);
00062 
00063             $oEncoder = $this->_getEncoder();
00064             // marking self and page links as expired
00065             $oEncoder->markAsExpired($sOxid, $iShopId, 1, $iLang, $sParams);
00066 
00067             // saving
00068             $oEncoder->addSeoEntry( $sOxid, $iShopId, $iLang, $this->_getStdUrl( $sOxid ),
00069                                     $aSeoData['oxseourl'], $this->_getSeoEntryType(), $aSeoData['oxfixed'],
00070                                     trim( $aSeoData['oxkeywords'] ), trim( $aSeoData['oxdescription'] ), $this->processParam( $aSeoData['oxparams'] ), true, $this->_getAltSeoEntryId() );
00071         }
00072     }
00073 
00081     protected function _getAdditionalParams($aSeoData)
00082     {
00083         $sParams = null;
00084         if (isset($aSeoData['oxparams'])) {
00085             if (preg_match('/([a-z]*#)?(?<objectseo>[a-z0-9]+)(#[0-9])?/i', $aSeoData['oxparams'], $aMatches)) {
00086                 $sQuotedObjectSeoId = oxDb::getDb()->quote($aMatches['objectseo']);
00087                 $sParams = "oxparams = {$sQuotedObjectSeoId}";
00088             }
00089         }
00090         return $sParams;
00091     }
00092 
00098     protected function _getSaveObjectId()
00099     {
00100         return $this->getEditObjectId();
00101     }
00102 
00110     public function getEntryMetaData( $sMetaType )
00111     {
00112         return $this->_getEncoder()->getMetaData( $this->getEditObjectId(), $sMetaType, $this->getConfig()->getShopId(), $this->getEditLang() );
00113     }
00114 
00120     public function isEntryFixed()
00121     {
00122         $iLang   = (int) $this->getEditLang();
00123         $iShopId = $this->getConfig()->getShopId();
00124 
00125         $sQ = "select oxfixed from oxseo where
00126                    oxseo.oxobjectid = ".oxDb::getDb()->quote( $this->getEditObjectId() )." and
00127                    oxseo.oxshopid = '{$iShopId}' and oxseo.oxlang = {$iLang} and oxparams = '' ";
00128         return (bool) oxDb::getDb()->getOne( $sQ, false, false );
00129     }
00130 
00136     protected function _getType()
00137     {
00138     }
00139 
00147     protected function _getStdUrl( $sOxid )
00148     {
00149         if ( $sType = $this->_getType() ) {
00150             $oObject = oxNew( $sType );
00151             if ( $oObject->load( $sOxid ) ) {
00152                return $oObject->getBaseStdLink( $this->getEditLang(), true, false );
00153             }
00154         }
00155     }
00156 
00162     public function getEditLang()
00163     {
00164         return $this->_iEditLang;
00165     }
00166 
00172     protected function _getAltSeoEntryId()
00173     {
00174     }
00175 
00181     protected function _getSeoEntryType()
00182     {
00183         return $this->_getType();
00184     }
00185 
00193     public function processParam( $sParam )
00194     {
00195         return $sParam;
00196     }
00197 
00203     protected function _getEncoder()
00204     {
00205     }
00206 
00212     public function getEntryUri()
00213     {
00214     }
00215 
00221     public function isEntrySuffixed()
00222     {
00223         return false;
00224     }
00225 
00231     public function isSuffixSupported()
00232     {
00233         return false;
00234     }
00235 
00241     public function showCatSelect()
00242     {
00243         return false;
00244     }
00245 
00251     public function getActCatType()
00252     {
00253         return false;
00254     }
00255 
00256 }