object_seo.php

Go to the documentation of this file.
00001 <?php
00002 
00006 class Object_Seo extends oxAdminDetails
00007 {
00008 
00016     public function render()
00017     {
00018         parent::render();
00019 
00020         if ($sType = $this->_getType()) {
00021             $oObject = oxNew($sType);
00022             if ($oObject->load($this->getEditObjectId())) {
00023                 $oOtherLang = $oObject->getAvailableInLangs();
00024                 if (!isset($oOtherLang[$iLang])) {
00025                     $oObject->loadInLang(key($oOtherLang), $this->getEditObjectId());
00026                 }
00027                 $this->_aViewData['edit'] = $oObject;
00028             }
00029 
00030         }
00031 
00032         $iLang = $this->getEditLang();
00033         $aLangs = oxRegistry::getLang()->getLanguageNames();
00034         foreach ($aLangs as $sLangId => $sLanguage) {
00035             $oLang = new stdClass();
00036             $oLang->sLangDesc = $sLanguage;
00037             $oLang->selected = ($sLangId == $iLang);
00038             $this->_aViewData['otherlang'][$sLangId] = clone $oLang;
00039         }
00040 
00041         return 'object_seo.tpl';
00042     }
00043 
00047     public function save()
00048     {
00049         // saving/updating seo params
00050         if (($sOxid = $this->_getSaveObjectId())) {
00051             $aSeoData = oxRegistry::getConfig()->getRequestParameter('aSeoData');
00052             $iShopId = $this->getConfig()->getShopId();
00053             $iLang = $this->getEditLang();
00054 
00055             // checkbox handling
00056             if (!isset($aSeoData['oxfixed'])) {
00057                 $aSeoData['oxfixed'] = 0;
00058             }
00059 
00060             $sParams = $this->_getAdditionalParams($aSeoData);
00061 
00062             $oEncoder = $this->_getEncoder();
00063             // marking self and page links as expired
00064             $oEncoder->markAsExpired($sOxid, $iShopId, 1, $iLang, $sParams);
00065 
00066             // saving
00067             $oEncoder->addSeoEntry(
00068                 $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     }
00074 
00082     protected function _getAdditionalParams($aSeoData)
00083     {
00084         $sParams = null;
00085         if (isset($aSeoData['oxparams'])) {
00086             if (preg_match('/([a-z]*#)?(?<objectseo>[a-z0-9]+)(#[0-9])?/i', $aSeoData['oxparams'], $aMatches)) {
00087                 $sQuotedObjectSeoId = oxDb::getDb()->quote($aMatches['objectseo']);
00088                 $sParams = "oxparams = {$sQuotedObjectSeoId}";
00089             }
00090         }
00091         return $sParams;
00092     }
00093 
00099     protected function _getSaveObjectId()
00100     {
00101         return $this->getEditObjectId();
00102     }
00103 
00111     public function getEntryMetaData($sMetaType)
00112     {
00113         return $this->_getEncoder()->getMetaData($this->getEditObjectId(), $sMetaType, $this->getConfig()->getShopId(), $this->getEditLang());
00114     }
00115 
00121     public function isEntryFixed()
00122     {
00123         $iLang = (int) $this->getEditLang();
00124         $iShopId = $this->getConfig()->getShopId();
00125 
00126         $sQ = "select oxfixed from oxseo where
00127                    oxseo.oxobjectid = " . oxDb::getDb()->quote($this->getEditObjectId()) . " and
00128                    oxseo.oxshopid = '{$iShopId}' and oxseo.oxlang = {$iLang} and oxparams = '' ";
00129 
00130         return (bool) oxDb::getDb()->getOne($sQ, false, false);
00131     }
00132 
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 
00170     protected function _getAltSeoEntryId()
00171     {
00172     }
00173 
00179     protected function _getSeoEntryType()
00180     {
00181         return $this->_getType();
00182     }
00183 
00191     public function processParam($sParam)
00192     {
00193         return $sParam;
00194     }
00195 
00199     protected function _getEncoder()
00200     {
00201     }
00202 
00206     public function getEntryUri()
00207     {
00208     }
00209 
00215     public function isEntrySuffixed()
00216     {
00217         return false;
00218     }
00219 
00225     public function isSuffixSupported()
00226     {
00227         return false;
00228     }
00229 
00235     public function showCatSelect()
00236     {
00237         return false;
00238     }
00239 
00245     public function getActCatType()
00246     {
00247         return false;
00248     }
00249 }