00001 <?php
00002
00006 class Article_Seo extends Object_Seo
00007 {
00013 protected $_sActCatId = null;
00014
00020 protected $_sActCatType = null;
00021
00027 protected $_oArtCategories = null;
00028
00034 protected $_oArtVendors = null;
00035
00041 protected $_oArtManufacturers = null;
00042
00048 protected $_oArticle = null;
00049
00056 public function render()
00057 {
00058 $oArticle = $this->_getObject( oxConfig::getParameter( 'oxid' ) );
00059
00060 $this->_aViewData["edit"] = $oArticle;
00061 $this->_aViewData["blShowCatSelect"] = true;
00062 $this->_aViewData["oCategories"] = $this->_getCategoryList( $oArticle );
00063 $this->_aViewData["oVendors"] = $this->_getVendorList( $oArticle );
00064 $this->_aViewData["oManufacturers"] = $this->_getManufacturerList( $oArticle );
00065 $this->_aViewData["sCatId"] = $this->getActCategory();
00066 $this->_aViewData["sCatType"] = $this->_sActCatType;
00067
00068 return parent::render();
00069 }
00070
00076 protected function _getSeoDataSql( $oObject, $iShopId, $iLang )
00077 {
00078
00079 $sParam = ( $sCat = $this->getActCategory() ) ? " and oxparams = '$sCat' " : '';
00080 $sQ = "select * from oxseo where oxobjectid = '".$oObject->getId()."' and
00081 oxshopid = '{$iShopId}' and oxlang = {$iLang} {$sParam} ";
00082 return $sQ;
00083 }
00084
00090 protected function _getCategoryList( $oArticle )
00091 {
00092 if ( $this->_oArtCategories === null ) {
00093 $this->_oArtCategories = ( $oArticle ) ? oxSeoEncoderArticle::getInstance()->getSeoCategories( $oArticle ) : false;
00094 }
00095
00096 return $this->_oArtCategories;
00097 }
00098
00104 protected function _getVendorList( $oArticle )
00105 {
00106 if ( $this->_oArtVendors === null ) {
00107 $this->_oArtVendors = false;
00108
00109 if ( $oArticle->oxarticles__oxvendorid->value ) {
00110 $oVendor = oxNew( 'oxvendor' );
00111 if ( $oVendor->loadInLang( $this->_iEditLang, $oArticle->oxarticles__oxvendorid->value ) ) {
00112 $this->_oArtVendors = oxNew( 'oxList', 'oxvendor' );
00113 $this->_oArtVendors[] = $oVendor;
00114 }
00115 }
00116 }
00117 return $this->_oArtVendors;
00118 }
00119
00125 protected function _getManufacturerList( $oArticle )
00126 {
00127 if ( $this->_oArtManufacturers === null ) {
00128 $this->_oArtManufacturers = false;
00129
00130 if ( $oArticle->oxarticles__oxmanufacturerid->value ) {
00131 $oManufacturer = oxNew( 'oxmanufacturer' );
00132 if ( $oManufacturer->loadInLang( $this->_iEditLang, $oArticle->oxarticles__oxmanufacturerid->value ) ) {
00133 $this->_oArtManufacturers = oxNew( 'oxList', 'oxmanufacturer' );
00134 $this->_oArtManufacturers[] = $oManufacturer;
00135 }
00136 }
00137 }
00138 return $this->_oArtManufacturers;
00139 }
00140
00146 public function getActCategory()
00147 {
00148 if ( $this->_sActCatId === null) {
00149 $this->_sActCatId = false;
00150 $this->_sActCatType = false;
00151
00152 $aSeoData = oxConfig::getParameter( 'aSeoData' );
00153 if ( $aSeoData && isset( $aSeoData['oxparams'] ) ) {
00154 if ( $sData = $aSeoData['oxparams'] ) {
00155 $this->_sActCatId = substr( $sData, strpos( $sData, '#' ) + 1 );
00156 $this->_sActCatType = substr( $sData, 0, strpos( $sData, '#' ) );
00157 }
00158 } else {
00159 $oArticle = $this->_getObject( oxConfig::getParameter( 'oxid' ) );
00160 if ( $this->_getCategoryList( $oArticle )->count() ) {
00161 $this->_sActCatType = 'oxcategories';
00162 $this->_sActCatId = $this->_getCategoryList( $oArticle )->current()->oxcategories__oxrootid->value;
00163 } elseif ( $this->_getVendorList( $oArticle ) && $this->_getVendorList( $oArticle )->count() ) {
00164 $this->_sActCatType = 'oxvendor';
00165 $this->_sActCatId = $this->_getVendorList( $oArticle )->current()->getId();
00166 } elseif ( $this->_getManufacturerList( $oArticle ) && $this->_getManufacturerList( $oArticle )->count() ) {
00167 $this->_sActCatType = 'oxmanufacturer';
00168 $this->_sActCatId = $this->_getManufacturerList( $oArticle )->current()->getId();
00169 }
00170 }
00171 }
00172
00173 return $this->_sActCatId;
00174 }
00175
00181 protected function _getSeoUrl( $oArticle )
00182 {
00183
00184 $this->getActCategory();
00185
00186
00187 switch ( $this->_sActCatType ) {
00188 case 'oxvendor':
00189 $sType = 1;
00190 break;
00191 case 'oxmanufacturer':
00192 $sType = 2;
00193 break;
00194 default:
00195 $sType = 0;
00196 }
00197
00198 oxSeoEncoderArticle::getInstance()->getArticleUrl( $oArticle, null, $sType );
00199 return parent::_getSeoUrl( $oArticle );
00200 }
00201
00209 protected function _getSeoUrlQuery( $oObject, $iShopId )
00210 {
00211 return "select oxseourl from oxseo where oxobjectid = '".$oObject->getId()."'
00212 and oxshopid = '{$iShopId}' and oxlang = {$this->_iEditLang}
00213 and oxparams = '{$this->_sActCatId}' ";
00214 }
00215
00220 protected function _getType()
00221 {
00222 return 'oxarticle';
00223 }
00224
00229 protected function _getStdUrl( $sOxid )
00230 {
00231 $oArticle = oxNew( 'oxarticle' );
00232 $oArticle->loadInLang( $this->_iEditLang, $sOxid );
00233 $sStdLink = $oArticle->getLink();
00234
00235
00236 switch ( $this->_sActCatType ) {
00237 case 'oxvendor':
00238 $sStdLink .= '&cnid=v_'.$this->getActCategory();
00239 break;
00240 case 'oxmanufacturer':
00241 $sStdLink .= '&mnid='.$this->getActCategory();
00242 break;
00243 }
00244
00245 return $sStdLink;
00246 }
00247
00255 public function processParam( $sParam )
00256 {
00257 return trim( substr( $sParam, strpos( $sParam, '#') ), '#' );
00258 }
00259 }