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         $sQ = '';
00125         $blSep = false;
00126         $aVisiblecols = $this->_getVisibleColNames();
00127         foreach ( $aVisiblecols as $iCnt => $aCol ) {
00128             if ( $blSep )
00129                 $sQ .= ', ';
00130             $sViewTable = getViewName( $aCol[1] );
00131             // multilanguage
00132             $sCol = $aCol[3]?$aCol[0].oxLang::getInstance()->getLanguageTag():$aCol[0];
00133             if ( $myConfig->getConfigParam( 'blVariantsSelection' ) && $aCol[0] == 'oxtitle' ) {
00134                 $sVarSelect = "$sViewTable.oxvarselect".oxLang::getInstance()->getLanguageTag();
00135                 $sQ .= " IF( $sViewTable.$sCol != '', $sViewTable.$sCol, CONCAT((select oxart.$sCol from $sViewTable as oxart where oxart.oxid = $sViewTable.oxparentid),', ',$sVarSelect)) as _" . $iCnt;
00136             } else {
00137                 $sQ  .= $sViewTable . '.' . $sCol . ' as _' . $iCnt;
00138             }
00139             $blSep = true;
00140         }
00141 
00142         $aIdentCols = $this->_getIdentColNames();
00143         foreach ( $aIdentCols as $iCnt => $aCol ) {
00144             if ( $blSep )
00145                 $sQ .= ', ';
00146 
00147             // multilanguage
00148             $sCol = $aCol[3]?$aCol[0].oxLang::getInstance()->getLanguageTag():$aCol[0];
00149             $sQ  .= getViewName( $aCol[1] ) . '.' . $sCol . ' as _' . $iCnt;
00150         }
00151 
00152         return " $sQ ";
00153     }
00154 
00155 }

Generated on Thu Dec 4 12:04:55 2008 for OXID eShop CE by  doxygen 1.5.5