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         $oDb      = oxDb::getDb();
00036 
00037         $sArticleTable = getViewName('oxarticles');
00038         $sO2CView      = getViewName('oxobject2category');
00039 
00040         $sDelId      = oxConfig::getParameter( 'oxid' );
00041         $sSynchDelId = oxConfig::getParameter( 'synchoxid' );
00042 
00043         // category selected or not ?
00044         if ( !$sDelId) {
00045             // dodger performance
00046             $sQAdd  = " from $sArticleTable where 1 ";
00047             $sQAdd .= $myConfig->getConfigParam( 'blVariantsSelection' )?'':" and $sArticleTable.oxparentid = '' ";
00048         } else {
00049             // selected category ?
00050             if ( $sSynchDelId && $sDelId != $sSynchDelId ) {
00051                 $sQAdd  = " from $sO2CView as oxobject2category left join $sArticleTable on ";
00052                 $sQAdd .= $myConfig->getConfigParam( 'blVariantsSelection' )?" ( $sArticleTable.oxid=oxobject2category.oxobjectid or $sArticleTable.oxparentid=oxobject2category.oxobjectid)":" $sArticleTable.oxid=oxobject2category.oxobjectid ";
00053                 $sQAdd .= " where oxobject2category.oxcatnid = " . $oDb->quote( $sDelId ) . " ";
00054             } else {
00055                 $sQAdd  = " from oxobject2attribute left join $sArticleTable on $sArticleTable.oxid=oxobject2attribute.oxobjectid ";
00056                 $sQAdd .= " where oxobject2attribute.oxattrid = " . $oDb->quote( $sDelId ) . " and $sArticleTable.oxid is not null ";
00057             }
00058         }
00059 
00060         if ( $sSynchDelId && $sSynchDelId != $sDelId ) {
00061             $sQAdd .= " and $sArticleTable.oxid not in ( select oxobject2attribute.oxobjectid from oxobject2attribute where oxobject2attribute.oxattrid = " . $oDb->quote( $sSynchDelId ) . " ) ";
00062         }
00063 
00064         return $sQAdd;
00065     }
00066 
00074     protected function _getDataQuery( $sQ )
00075     {
00076         $sArtTable = getViewName('oxarticles');
00077         $sQ = parent::_getDataQuery( $sQ );
00078 
00079         // display variants or not ?
00080         $sQ .= $this->getConfig()->getConfigParam( 'blVariantsSelection' ) ? ' group by '.$sArtTable.'.oxid ' : '';
00081         return $sQ;
00082     }
00083 
00089     public function removeattrarticle()
00090     {
00091         $aChosenCat = $this->_getActionIds( 'oxobject2attribute.oxid' );
00092         if ( oxConfig::getParameter( 'all' ) ) {
00093 
00094             $sQ = $this->_addFilter( "delete oxobject2attribute.* ".$this->_getQuery() );
00095             oxDb::getDb()->Execute( $sQ );
00096 
00097         } elseif ( is_array( $aChosenCat ) ) {
00098             $sQ = "delete from oxobject2attribute where oxobject2attribute.oxid in (" . implode( ", ", oxDb::getInstance()->quoteArray( $aChosenCat ) ) . ") ";
00099             oxDb::getDb()->Execute( $sQ );
00100         }
00101     }
00102 
00108     public function addattrarticle()
00109     {
00110         $aAddArticle = $this->_getActionIds( 'oxarticles.oxid' );
00111         $soxId       = oxConfig::getParameter( 'synchoxid' );
00112 
00113         // adding
00114         if ( oxConfig::getParameter( 'all' ) ) {
00115             $sArticleTable = getViewName( 'oxarticles' );
00116             $aAddArticle = $this->_getAll( $this->_addFilter( "select $sArticleTable.oxid ".$this->_getQuery() ) );
00117         }
00118 
00119         $oCategory = oxNew( "oxattribute" );
00120 
00121 
00122         if ( $oCategory->load( $soxId) && is_array( $aAddArticle ) ) {
00123             foreach ($aAddArticle as $sAdd) {
00124                 $oNewGroup = oxNew( "oxbase" );
00125                 $oNewGroup->init( "oxobject2attribute" );
00126                 $oNewGroup->oxobject2attribute__oxobjectid = new oxField($sAdd);
00127                 $oNewGroup->oxobject2attribute__oxattrid   = new oxField($oCategory->oxattribute__oxid->value);
00128                 $oNewGroup->save();
00129             }
00130         }
00131     }
00132 
00139     protected function _getQueryCols()
00140     {
00141         $myConfig = $this->getConfig();
00142         $sLangTag = oxLang::getInstance()->getLanguageTag();
00143 
00144         $sQ = '';
00145         $blSep = false;
00146         $aVisiblecols = $this->_getVisibleColNames();
00147         foreach ( $aVisiblecols as $iCnt => $aCol ) {
00148             if ( $blSep )
00149                 $sQ .= ', ';
00150             $sViewTable = getViewName( $aCol[1] );
00151             // multilanguage
00152             $sCol = $aCol[3]?$aCol[0].$sLangTag:$aCol[0];
00153             if ( $myConfig->getConfigParam( 'blVariantsSelection' ) && $aCol[0] == 'oxtitle' ) {
00154                 $sVarSelect = "$sViewTable.oxvarselect".$sLangTag;
00155                 $sQ .= " IF( $sViewTable.$sCol != '', $sViewTable.$sCol, CONCAT((select oxart.$sCol from $sViewTable as oxart where oxart.oxid = $sViewTable.oxparentid),', ',$sVarSelect)) as _" . $iCnt;
00156             } else {
00157                 $sQ  .= $sViewTable . '.' . $sCol . ' as _' . $iCnt;
00158             }
00159             $blSep = true;
00160         }
00161 
00162         $aIdentCols = $this->_getIdentColNames();
00163         foreach ( $aIdentCols as $iCnt => $aCol ) {
00164             if ( $blSep )
00165                 $sQ .= ', ';
00166 
00167             // multilanguage
00168             $sCol = $aCol[3]?$aCol[0].$sLangTag:$aCol[0];
00169             $sQ  .= getViewName( $aCol[1] ) . '.' . $sCol . ' as _' . $iCnt;
00170         }
00171 
00172         return " $sQ ";
00173     }
00174 
00175 }

Generated on Tue Sep 29 16:45:12 2009 for OXID eShop CE by  doxygen 1.5.5