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                  ( isset( $aSeoData['OXEXPIRED'] ) && $aSeoData['OXEXPIRED'] ) ) {
00045                 $aSeoData['OXSEOURL'] = $this->_getSeoUrl( $oObject );
00046             }
00047 
00048             // passing to view
00049             $this->_aViewData['aSeoData'] = $aSeoData;
00050         }
00051 
00052         return 'object_seo.tpl';
00053     }
00054 
00064     protected function _getSeoDataSql( $oObject, $iShopId, $iLang )
00065     {
00066         return "select * from oxseo where oxobjectid = ".oxDb::getDb()->quote( $oObject->getId() )." and
00067                 oxshopid = '{$iShopId}' and oxlang = {$iLang} ";
00068     }
00069 
00077     protected function _getSeoUrl( $oObject )
00078     {
00079         return oxDb::getDb()->getOne( $this->_getSeoUrlQuery( $oObject, $this->getConfig()->getShopId() ) );
00080     }
00081 
00090      protected function _getSeoUrlQuery( $oObject, $iShopId )
00091      {
00092         return "select oxseourl from oxseo where oxobjectid = '".$oObject->getId()."' and oxshopid = '{$iShopId}' and oxlang = {$this->_iEditLang} ";
00093      }
00094 
00102     protected function _getObject( $sOxid )
00103     {
00104         if ( $this->_oObject === null && ( $sType = $this->_getType() ) ) {
00105             $this->_oObject = false;
00106 
00107             // load object
00108             $oObject = oxNew( $sType );
00109             if ( $oObject->loadInLang( $this->_iEditLang, $sOxid ) ) {
00110                 $this->_oObject = $oObject;
00111             }
00112         }
00113         return $this->_oObject;
00114     }
00115 
00121     protected function _getType()
00122     {
00123     }
00124 
00132     protected function _getStdUrl( $sOxid )
00133     {
00134         return $this->_getObject( $sOxid )->getBaseStdLink( $this->_iEditLang, true, false );
00135     }
00136 
00142     public function save()
00143     {
00144         // saving/updating seo params
00145         if ( ( $sOxid = $this->_getSeoEntryId() ) ) {
00146             $aSeoData = oxConfig::getParameter( 'aSeoData' );
00147             $iShopId  = $this->getConfig()->getShopId();
00148 
00149             // checkbox handling
00150             if ( !isset( $aSeoData['oxfixed'] ) ) {
00151                 $aSeoData['oxfixed'] = 0;
00152             }
00153 
00154             $oEncoder = $this->_getEncoder();
00155 
00156             // marking self and page links as expired
00157             $oEncoder->markAsExpired( $sOxid, $iShopId, 1, $this->getEditLang() );
00158 
00159             // saving
00160             $oEncoder->addSeoEntry( $sOxid, $iShopId, $this->getEditLang(), $this->_getStdUrl( $sOxid ),
00161                                     $aSeoData['oxseourl'], $this->_getSeoEntryType(), $aSeoData['oxfixed'],
00162                                     trim( $aSeoData['oxkeywords'] ), trim( $aSeoData['oxdescription'] ), $this->processParam( $aSeoData['oxparams'] ), true, $this->_getAltSeoEntryId() );
00163         }
00164     }
00165 
00171     public function getEditLang()
00172     {
00173         return $this->_iEditLang;
00174     }
00175 
00183     protected function getSeoEntryId()
00184     {
00185         return $this->_getSeoEntryId();
00186     }
00187 
00193     protected function _getSeoEntryId()
00194     {
00195         return oxConfig::getParameter( 'oxid' );
00196     }
00197 
00203     protected function _getSeoEntryType()
00204     {
00205         return $this->_getType();
00206     }
00207 
00215     public function processParam( $sParam )
00216     {
00217         return $sParam;
00218     }
00219 
00225     protected function _getEncoder()
00226     {
00227         return oxSeoEncoder::getInstance();
00228     }
00229 
00235     protected function _getAltSeoEntryId()
00236     {
00237     }
00238 }

Generated by  doxygen 1.6.2