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 ( ( $oObject= $this->_getObject( oxConfig::getParameter( 'oxid' ) ) ) ) {
00020 
00021             $iShopId  = $this->getConfig()->getShopId();
00022             $oOtherLang = $oObject->getAvailableInLangs();
00023             if (!isset($oOtherLang[$this->_iEditLang])) {
00024                 // echo "language entry doesn't exist! using: ".key($oOtherLang);
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             // loading SEO part
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             // setting default values if empty
00043             if ( !isset( $aSeoData['OXSEOURL'] ) || !$aSeoData['OXSEOURL'] ) {
00044                 $aSeoData['OXSEOURL'] = $this->_getSeoUrl( $oObject );
00045             }
00046 
00047             // passing to view
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 
00076     protected function _getSeoUrl( $oObject )
00077     {
00078         $iShopId  = $this->getConfig()->getShopId();
00079         return oxDb::getDb()->getOne( $this->_getSeoUrlQuery( $oObject, $iShopId ) );
00080     }
00081 
00089      protected function _getSeoUrlQuery( $oObject, $iShopId )
00090      {
00091         return "select oxseourl from oxseo where oxobjectid = '".$oObject->getId()."' and oxshopid = '{$iShopId}' and oxlang = {$this->_iEditLang} ";
00092      }
00093 
00098     protected function _getObject( $sOxid )
00099     {
00100         if ( $this->_oObject === null ) {
00101             // load object
00102             $this->_oObject = oxNew( $this->_getType() );
00103             if ( !$this->_oObject->loadInLang( $this->_iEditLang, $sOxid ) ) {
00104                 $this->_oObject = false;
00105             }
00106         }
00107         return $this->_oObject;
00108     }
00109 
00114     protected function _getType() {}
00115 
00120     protected function _getStdUrl( $sOxid )
00121     {
00122         return $this->_getObject( $sOxid )->getLink();
00123     }
00124 
00130     public function save()
00131     {
00132         // saving/updating seo params
00133         if ( ( $sOxid = oxConfig::getParameter( 'oxid' ) ) ) {
00134             $aSeoData = oxConfig::getParameter( 'aSeoData' );
00135             $iShopId  = $this->getConfig()->getShopId();
00136 
00137             // checkbox handling
00138             if ( !isset( $aSeoData['oxfixed'] ) ) {
00139                 $aSeoData['oxfixed'] = 0;
00140             }
00141 
00142             // saving
00143             $oEncoder = oxSeoEncoder::getInstance();
00144             $oEncoder->addSeoEntry( $sOxid, $iShopId, $this->_iEditLang, $this->_getStdUrl( $sOxid ),
00145                                     $aSeoData['oxseourl'], $this->_getType(), $aSeoData['oxfixed'],
00146                                     trim( $aSeoData['oxkeywords'] ), trim( $aSeoData['oxdescription'] ), $this->processParam( $aSeoData['oxparams'] ) );
00147         }
00148     }
00149 
00157     public function processParam( $sParam )
00158     {
00159         return $sParam;
00160     }
00161 }

Generated on Wed May 13 13:25:50 2009 for OXID eShop CE by  doxygen 1.5.5