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 
00084     protected function _getDataQuery( $sQ )
00085     {
00086         $sArtTable = getViewName('oxarticles');
00087         $sQ = parent::_getDataQuery( $sQ );
00088 
00089         // display variants or not ?
00090         $sQ .= $this->getConfig()->getConfigParam( 'blVariantsSelection' ) ? ' group by '.$sArtTable.'.oxid ' : '';
00091         return $sQ;
00092     }
00093 
00099     public function removeartfromsel()
00100     {
00101         $aChosenArt = $this->_getActionIds( 'oxobject2selectlist.oxid' );
00102         if ( oxConfig::getParameter( 'all' ) ) {
00103 
00104             $sQ = $this->_addFilter( "delete oxobject2selectlist.* ".$this->_getQuery() );
00105             oxDb::getDb()->Execute( $sQ );
00106 
00107         } elseif ( is_array( $aChosenArt ) ) {
00108             $sQ = "delete from oxobject2selectlist where oxobject2selectlist.oxid in (" . implode( ", ", oxDb::getInstance()->quoteArray( $aChosenArt ) ) . ") ";
00109             oxDb::getDb()->Execute( $sQ );
00110         }
00111     }
00112 
00118     public function addarttosel()
00119     {
00120         $aAddArticle = $this->_getActionIds( 'oxarticles.oxid' );
00121         $soxId       = oxConfig::getParameter( 'synchoxid');
00122 
00123         if ( oxConfig::getParameter( 'all' ) ) {
00124             $sArtTable = getViewName('oxarticles');
00125             $aAddArticle = $this->_getAll( $this->_addFilter( "select $sArtTable.oxid ".$this->_getQuery() ) );
00126         }
00127 
00128         if ( $soxId && $soxId != "-1" && is_array( $aAddArticle ) ) {
00129             $oDb = oxDb::getDb();
00130             foreach ($aAddArticle as $sAdd) {
00131                 $oNewGroup = oxNew( "oxbase" );
00132                 $oNewGroup->init( "oxobject2selectlist" );
00133                 $oNewGroup->oxobject2selectlist__oxobjectid = new oxField( $sAdd );
00134                 $oNewGroup->oxobject2selectlist__oxselnid = new oxField( $soxId );
00135                 $oNewGroup->oxobject2selectlist__oxsort   = new oxField( ( int ) $oDb->getOne( "select max(oxsort) + 1 from oxobject2selectlist where oxobjectid =  " . $oDb->quote( $sAdd ) . " " ) );
00136                 $oNewGroup->save();
00137             }
00138         }
00139     }
00140 
00147     protected function _getQueryCols()
00148     {
00149         $myConfig = $this->getConfig();
00150         $sLangTag = oxLang::getInstance()->getLanguageTag();
00151 
00152         $sQ = '';
00153         $blSep = false;
00154         $aVisiblecols = $this->_getVisibleColNames();
00155         foreach ( $aVisiblecols as $iCnt => $aCol ) {
00156             if ( $blSep )
00157                 $sQ .= ', ';
00158             $sViewTable = getViewName( $aCol[1] );
00159             // multilanguage
00160             $sCol = $aCol[3]?$aCol[0].$sLangTag:$aCol[0];
00161             if ( $myConfig->getConfigParam( 'blVariantsSelection' ) && $aCol[0] == 'oxtitle' ) {
00162                 $sVarSelect = "$sViewTable.oxvarselect".$sLangTag;
00163                 $sQ .= " IF( $sViewTable.$sCol != '', $sViewTable.$sCol, CONCAT((select oxart.$sCol from $sViewTable as oxart where oxart.oxid = $sViewTable.oxparentid),', ',$sVarSelect)) as _" . $iCnt;
00164             } else {
00165                 $sQ  .= $sViewTable . '.' . $sCol . ' as _' . $iCnt;
00166             }
00167             $blSep = true;
00168         }
00169 
00170         $aIdentCols = $this->_getIdentColNames();
00171         foreach ( $aIdentCols as $iCnt => $aCol ) {
00172             if ( $blSep )
00173                 $sQ .= ', ';
00174 
00175             // multilanguage
00176             $sCol = $aCol[3]?$aCol[0].$sLangTag:$aCol[0];
00177             $sQ  .= getViewName( $aCol[1] ) . '.' . $sCol . ' as _' . $iCnt;
00178         }
00179 
00180         return " $sQ ";
00181     }
00182 
00183 }

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