00001 <?php
00002
00006 class Object_Seo extends oxAdminDetails
00007 {
00015 public function render()
00016 {
00017 parent::render();
00018
00019 if ( ( $oObject= $this->_getObject( oxConfig::getParameter( 'oxid' ) ) ) ) {
00020
00021 $iShopId = oxConfig::getInstance()->getShopId();
00022 $oOtherLang = $oObject->getAvailableInLangs();
00023 if (!isset($oOtherLang[$this->_iEditLang])) {
00024
00025 $oObject->loadInLang( key( $oOtherLang ), oxConfig::getParameter( 'oxid' ) );
00026 }
00027 $this->_aViewData['edit'] = $oObject;
00028
00029 $aLangs = oxLang::getInstance()->getLanguageNames();
00030 foreach ( $aLangs as $id => $language) {
00031 $oLang= new oxStdClass();
00032 $oLang->sLangDesc = $language;
00033 $oLang->selected = ($id == $this->_iEditLang);
00034 $this->_aViewData['otherlang'][$id] = clone $oLang;
00035 }
00036
00037
00038 $sQ = $this->_getSeoDataSql( $oObject, $iShopId, $this->_iEditLang );
00039 $aSeoData = oxDb::getDb(true)->getArray( $sQ );
00040 $aSeoData = ( is_array( $aSeoData ) && isset( $aSeoData[0] ) )?$aSeoData[0]:array();
00041
00042
00043 if ( !isset( $aSeoData['OXSEOURL'] ) || !$aSeoData['OXSEOURL'] ) {
00044 $aSeoData['OXSEOURL'] = $this->_getSeoUrl( $oObject );
00045 }
00046
00047
00048 $this->_aViewData['aSeoData'] = $aSeoData;
00049 }
00050
00051 return 'object_seo.tpl';
00052 }
00053
00063 protected function _getSeoDataSql( $oObject, $iShopId, $iLang )
00064 {
00065 return "select * from oxseo where oxobjectid = '".$oObject->getId()."' and
00066 oxshopid = '{$iShopId}' and oxlang = {$iLang} ";
00067 }
00068
00073 protected function _getSeoUrl( $oObject )
00074 {
00075 $iShopId = oxConfig::getInstance()->getShopId();
00076 $sQ = "select oxseourl from oxseo where oxobjectid = '".$oObject->getId()."' and oxshopid = '{$iShopId}' and oxlang = {$this->_iEditLang} ";
00077 return oxDb::getDb()->getOne( $sQ );
00078 }
00079
00084 protected function _getObject( $sOxid ) {}
00085
00090 protected function _getType() {}
00091
00096 protected function _getStdUrl( $sOxid ) {}
00097
00103 public function save()
00104 {
00105
00106 if ( ( $sOxid = oxConfig::getParameter( 'oxid' ) ) ) {
00107 $aSeoData = oxConfig::getParameter( 'aSeoData' );
00108 $iShopId = oxConfig::getInstance()->getShopId();
00109
00110
00111 if ( !isset( $aSeoData['oxfixed'] ) ) {
00112 $aSeoData['oxfixed'] = 0;
00113 }
00114
00115
00116 $oEncoder = oxSeoEncoder::getInstance();
00117 $oEncoder->addSeoEntry( $sOxid, $iShopId, $this->_iEditLang, $this->_getStdUrl( $sOxid ),
00118 $aSeoData['oxseourl'], $this->_getType(), $aSeoData['oxfixed'],
00119 $aSeoData['oxkeywords'], $aSeoData['oxdescription'], $aSeoData['oxparams'] );
00120
00121 }
00122
00123 return $this->autosave();
00124 }
00125 }