attribute_main.inc.php

Go to the documentation of this file.
00001 <?php
00002 
00003 $aColumns = array( 'container1' => array(    // field , table,         visible, multilanguage, ident
00004                                         array( 'oxartnum', 'oxarticles', 1, 0, 0 ),
00005                                         array( 'oxtitle',  'oxarticles', 1, 1, 0 ),
00006                                         array( 'oxean',    'oxarticles', 1, 0, 0 ),
00007                                         array( 'oxprice',  'oxarticles', 0, 0, 0 ),
00008                                         array( 'oxstock',  'oxarticles', 0, 0, 0 ),
00009                                         array( 'oxid',     'oxarticles', 0, 0, 1 )
00010                                         ),
00011                      'container2' => array(
00012                                         array( 'oxartnum', 'oxarticles', 1, 0, 0 ),
00013                                         array( 'oxtitle',  'oxarticles', 1, 1, 0 ),
00014                                         array( 'oxean',    'oxarticles', 1, 0, 0 ),
00015                                         array( 'oxprice',  'oxarticles', 0, 0, 0 ),
00016                                         array( 'oxstock',  'oxarticles', 0, 0, 0 ),
00017                                         array( 'oxid',     'oxobject2attribute', 0, 0, 1 )
00018                                         )
00019                     );
00020 
00021 
00025 class ajaxComponent extends ajaxListComponent
00026 {
00032     protected function _getQuery()
00033     {
00034         $myConfig = $this->getConfig();
00035 
00036         $sArticleTable = getViewName('oxarticles');
00037         $sO2CView      = getViewName('oxobject2category');
00038 
00039         $sDelId      = oxConfig::getParameter( 'oxid' );
00040         $sSynchDelId = oxConfig::getParameter( 'synchoxid' );
00041 
00042         // category selected or not ?
00043         if ( !$sDelId) {
00044             // dodger performance
00045             $sQAdd  = " from $sArticleTable where 1 ";
00046             $sQAdd .= $myConfig->getConfigParam( 'blVariantsSelection' )?'':" and $sArticleTable.oxparentid = '' ";
00047         } else {
00048             // selected category ?
00049             if ( $sSynchDelId && $sDelId != $sSynchDelId ) {
00050                 $sQAdd  = " from $sO2CView as oxobject2category left join $sArticleTable on ";
00051                 $sQAdd .= $myConfig->getConfigParam( 'blVariantsSelection' )?" ( $sArticleTable.oxid=oxobject2category.oxobjectid or $sArticleTable.oxparentid=oxobject2category.oxobjectid)":" $sArticleTable.oxid=oxobject2category.oxobjectid ";
00052                 $sQAdd .= " where oxobject2category.oxcatnid = '$sDelId' ";
00053             } else {
00054                 $sQAdd  = " from oxobject2attribute left join $sArticleTable on $sArticleTable.oxid=oxobject2attribute.oxobjectid ";
00055                 $sQAdd .= " where oxobject2attribute.oxattrid = '$sDelId' and $sArticleTable.oxid is not null ";
00056             }
00057         }
00058 
00059         if ( $sSynchDelId && $sSynchDelId != $sDelId ) {
00060             $sQAdd .= " and $sArticleTable.oxid not in ( select oxobject2attribute.oxobjectid from oxobject2attribute where oxobject2attribute.oxattrid = '$sSynchDelId' ) ";
00061         }
00062 
00063         return $sQAdd;
00064     }
00065 
00071     public function removeattrarticle()
00072     {
00073         $aChosenCat = $this->_getActionIds( 'oxobject2attribute.oxid' );
00074         if ( oxConfig::getParameter( 'all' ) ) {
00075 
00076             $sQ = $this->_addFilter( "delete oxobject2attribute.* ".$this->_getQuery() );
00077             oxDb::getDb()->Execute( $sQ );
00078 
00079         } elseif ( is_array( $aChosenCat ) ) {
00080             $sQ = "delete from oxobject2attribute where oxobject2attribute.oxid in ('" . implode( "', '", $aChosenCat ) . "') ";
00081             oxDb::getDb()->Execute( $sQ );
00082         }
00083     }
00084 
00090     public function addattrarticle()
00091     {
00092         $aAddArticle = $this->_getActionIds( 'oxarticles.oxid' );
00093         $soxId       = oxConfig::getParameter( 'synchoxid' );
00094 
00095         // adding
00096         if ( oxConfig::getParameter( 'all' ) ) {
00097             $sArticleTable = getViewName( 'oxarticles' );
00098             $aAddArticle = $this->_getAll( $this->_addFilter( "select $sArticleTable.oxid ".$this->_getQuery() ) );
00099         }
00100 
00101         $oCategory = oxNew( "oxattribute" );
00102 
00103 
00104         if ( $oCategory->load( $soxId) && is_array( $aAddArticle ) ) {
00105             foreach ($aAddArticle as $sAdd) {
00106                 $oNewGroup = oxNew( "oxbase" );
00107                 $oNewGroup->init( "oxobject2attribute" );
00108                 $oNewGroup->oxobject2attribute__oxobjectid = new oxField($sAdd);
00109                 $oNewGroup->oxobject2attribute__oxattrid   = new oxField($oCategory->oxattribute__oxid->value);
00110                 $oNewGroup->save();
00111             }
00112         }
00113     }
00114 
00121     protected function _getQueryCols()
00122     {
00123         $myConfig = $this->getConfig();
00124         $sLangTag = oxLang::getInstance()->getLanguageTag();
00125 
00126         $sQ = '';
00127         $blSep = false;
00128         $aVisiblecols = $this->_getVisibleColNames();
00129         foreach ( $aVisiblecols as $iCnt => $aCol ) {
00130             if ( $blSep )
00131                 $sQ .= ', ';
00132             $sViewTable = getViewName( $aCol[1] );
00133             // multilanguage
00134             $sCol = $aCol[3]?$aCol[0].$sLangTag:$aCol[0];
00135             if ( $myConfig->getConfigParam( 'blVariantsSelection' ) && $aCol[0] == 'oxtitle' ) {
00136                 $sVarSelect = "$sViewTable.oxvarselect".$sLangTag;
00137                 $sQ .= " IF( $sViewTable.$sCol != '', $sViewTable.$sCol, CONCAT((select oxart.$sCol from $sViewTable as oxart where oxart.oxid = $sViewTable.oxparentid),', ',$sVarSelect)) as _" . $iCnt;
00138             } else {
00139                 $sQ  .= $sViewTable . '.' . $sCol . ' as _' . $iCnt;
00140             }
00141             $blSep = true;
00142         }
00143 
00144         $aIdentCols = $this->_getIdentColNames();
00145         foreach ( $aIdentCols as $iCnt => $aCol ) {
00146             if ( $blSep )
00147                 $sQ .= ', ';
00148 
00149             // multilanguage
00150             $sCol = $aCol[3]?$aCol[0].$sLangTag:$aCol[0];
00151             $sQ  .= getViewName( $aCol[1] ) . '.' . $sCol . ' as _' . $iCnt;
00152         }
00153 
00154         return " $sQ ";
00155     }
00156 
00157 }

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