selectlist_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', 0, 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', 0, 0, 0 ),
00015                                         array( 'oxprice',  'oxarticles', 0, 0, 0 ),
00016                                         array( 'oxstock',  'oxarticles', 0, 0, 0 ),
00017                                         array( 'oxid',     'oxobject2selectlist', 0, 0, 1 ),
00018                                         array( 'oxid',     'oxarticles', 0, 0, 1 )
00019                                         ),
00020                      'container3' => array(
00021                                         array( 'oxtitle',   'oxselectlist', 1, 1, 0 ),
00022                                         array( 'oxsort',    'oxobject2selectlist', 1, 0, 0 ),
00023                                         array( 'oxident',   'oxselectlist', 0, 0, 0 ),
00024                                         array( 'oxvaldesc', 'oxselectlist', 0, 0, 0 ),
00025                                         array( 'oxid',      'oxselectlist', 0, 0, 1 )
00026                                                                                             )
00027                                     );
00028 
00032 class ajaxComponent extends ajaxListComponent
00033 {
00039     protected function _getQuery()
00040     {
00041         $myConfig = $this->getConfig();
00042 
00043         // looking for table/view
00044         $sArtTable = getViewName('oxarticles');
00045         $sCatTable = getViewName('oxcategories');
00046         $sO2CView  = getViewName('oxobject2category');
00047 
00048         $sSelId      = oxConfig::getParameter( 'oxid' );
00049         $sSynchSelId = oxConfig::getParameter( 'synchoxid' );
00050 
00051         // category selected or not ?
00052         if ( !$sSelId) {
00053             // dodger performance
00054             $sQAdd  = " from $sArtTable where 1 ";
00055             $sQAdd .= $myConfig->getConfigParam( 'blVariantsSelection' )?'':" and $sArtTable.oxparentid = '' ";
00056         } else {
00057             // selected category ?
00058             if ( $sSynchSelId && $sSelId != $sSynchSelId ) {
00059                 $sQAdd  = " from $sO2CView as oxobject2category left join $sArtTable on ";
00060                 $sQAdd .= $myConfig->getConfigParam( 'blVariantsSelection' )?" ( $sArtTable.oxid=oxobject2category.oxobjectid or $sArtTable.oxparentid=oxobject2category.oxobjectid ) ":" $sArtTable.oxid=oxobject2category.oxobjectid ";
00061                 $sQAdd .= " where oxobject2category.oxcatnid = '$sSelId' ";
00062             } else {
00063                 $sQAdd  = " from $sArtTable left join oxobject2selectlist on $sArtTable.oxid=oxobject2selectlist.oxobjectid ";
00064                 $sQAdd .= " where oxobject2selectlist.oxselnid = '$sSelId' ";
00065             }
00066         }
00067 
00068         if ( $sSynchSelId && $sSynchSelId != $sSelId ) {
00069             // dodger performance
00070             $sQAdd .= " and $sArtTable.oxid not in ( select oxobject2selectlist.oxobjectid from oxobject2selectlist ";
00071             $sQAdd .= " where oxobject2selectlist.oxselnid = '$sSynchSelId' ) ";
00072         }
00073 
00074         return $sQAdd;
00075     }
00076 
00082     public function removeartfromsel()
00083     {
00084         $aChosenArt = $this->_getActionIds( 'oxobject2selectlist.oxid' );
00085         if ( oxConfig::getParameter( 'all' ) ) {
00086 
00087             $sQ = $this->_addFilter( "delete oxobject2selectlist.* ".$this->_getQuery() );
00088             oxDb::getDb()->Execute( $sQ );
00089 
00090         } elseif ( is_array( $aChosenArt ) ) {
00091             $sQ = "delete from oxobject2selectlist where oxobject2selectlist.oxid in ('" . implode( "', '", $aChosenArt ) . "') ";
00092             oxDb::getDb()->Execute( $sQ );
00093         }
00094     }
00095 
00101     public function addarttosel()
00102     {
00103         $aAddArticle = $this->_getActionIds( 'oxarticles.oxid' );
00104         $soxId       = oxConfig::getParameter( 'synchoxid');
00105 
00106         if ( oxConfig::getParameter( 'all' ) ) {
00107             $sArtTable = getViewName('oxarticles');
00108             $aAddArticle = $this->_getAll( $this->_addFilter( "select $sArtTable.oxid ".$this->_getQuery() ) );
00109         }
00110 
00111         if ( $soxId && $soxId != "-1" && is_array( $aAddArticle ) ) {
00112             $oDb = oxDb::getDb();
00113             foreach ($aAddArticle as $sAdd) {
00114                 $oNewGroup = oxNew( "oxbase" );
00115                 $oNewGroup->init( "oxobject2selectlist" );
00116                 $oNewGroup->oxobject2selectlist__oxobjectid = new oxField( $sAdd );
00117                 $oNewGroup->oxobject2selectlist__oxselnid = new oxField( $soxId );
00118                 $oNewGroup->oxobject2selectlist__oxsort   = new oxField( ( int ) $oDb->getOne( "select max(oxsort) + 1 from oxobject2selectlist where oxobjectid = '$sAdd' " ) );
00119                 $oNewGroup->save();
00120             }
00121         }
00122     }
00123 
00130     protected function _getQueryCols()
00131     {
00132         $myConfig = $this->getConfig();
00133         $sLangTag = oxLang::getInstance()->getLanguageTag();
00134 
00135         $sQ = '';
00136         $blSep = false;
00137         $aVisiblecols = $this->_getVisibleColNames();
00138         foreach ( $aVisiblecols as $iCnt => $aCol ) {
00139             if ( $blSep )
00140                 $sQ .= ', ';
00141             $sViewTable = getViewName( $aCol[1] );
00142             // multilanguage
00143             $sCol = $aCol[3]?$aCol[0].$sLangTag:$aCol[0];
00144             if ( $myConfig->getConfigParam( 'blVariantsSelection' ) && $aCol[0] == 'oxtitle' ) {
00145                 $sVarSelect = "$sViewTable.oxvarselect".$sLangTag;
00146                 $sQ .= " IF( $sViewTable.$sCol != '', $sViewTable.$sCol, CONCAT((select oxart.$sCol from $sViewTable as oxart where oxart.oxid = $sViewTable.oxparentid),', ',$sVarSelect)) as _" . $iCnt;
00147             } else {
00148                 $sQ  .= $sViewTable . '.' . $sCol . ' as _' . $iCnt;
00149             }
00150             $blSep = true;
00151         }
00152 
00153         $aIdentCols = $this->_getIdentColNames();
00154         foreach ( $aIdentCols as $iCnt => $aCol ) {
00155             if ( $blSep )
00156                 $sQ .= ', ';
00157 
00158             // multilanguage
00159             $sCol = $aCol[3]?$aCol[0].$sLangTag:$aCol[0];
00160             $sQ  .= getViewName( $aCol[1] ) . '.' . $sCol . ' as _' . $iCnt;
00161         }
00162 
00163         return " $sQ ";
00164     }
00165 
00166 }

Generated on Wed Apr 22 12:26:29 2009 for OXID eShop CE by  doxygen 1.5.5