00001 <?php
00002
00003 $aColumns = array( 'container1' => array(
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
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
00052 if ( !$sSelId) {
00053
00054 $sQAdd = " from $sArtTable where 1 ";
00055 $sQAdd .= $myConfig->getConfigParam( 'blVariantsSelection' )?'':" and $sArtTable.oxparentid = '' ";
00056 } else {
00057
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
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 foreach ($aAddArticle as $sAdd) {
00113 $oNewGroup = oxNew( "oxbase" );
00114 $oNewGroup->init( "oxobject2selectlist" );
00115 $oNewGroup->oxobject2selectlist__oxobjectid = new oxField( $sAdd );
00116 $oNewGroup->oxobject2selectlist__oxselnid = new oxField( $soxId );
00117 $oNewGroup->oxobject2selectlist__oxsort = new oxField( ( int ) oxDb::getDb()->getOne( "select max(oxsort) + 1 from oxobject2selectlist where oxobjectid = '$sAdd' " ) );
00118 $oNewGroup->save();
00119 }
00120 }
00121 }
00122
00129 protected function _getQueryCols()
00130 {
00131 $myConfig = $this->getConfig();
00132 $sQ = '';
00133 $blSep = false;
00134 $aVisiblecols = $this->_getVisibleColNames();
00135 foreach ( $aVisiblecols as $iCnt => $aCol ) {
00136 if ( $blSep )
00137 $sQ .= ', ';
00138 $sViewTable = getViewName( $aCol[1] );
00139
00140 $sCol = $aCol[3]?$aCol[0].oxLang::getInstance()->getLanguageTag():$aCol[0];
00141 if ( $myConfig->getConfigParam( 'blVariantsSelection' ) && $aCol[0] == 'oxtitle' ) {
00142 $sVarSelect = "$sViewTable.oxvarselect".oxLang::getInstance()->getLanguageTag();
00143 $sQ .= " IF( $sViewTable.$sCol != '', $sViewTable.$sCol, CONCAT((select oxart.$sCol from $sViewTable as oxart where oxart.oxid = $sViewTable.oxparentid),', ',$sVarSelect)) as _" . $iCnt;
00144 } else {
00145 $sQ .= $sViewTable . '.' . $sCol . ' as _' . $iCnt;
00146 }
00147 $blSep = true;
00148 }
00149
00150 $aIdentCols = $this->_getIdentColNames();
00151 foreach ( $aIdentCols as $iCnt => $aCol ) {
00152 if ( $blSep )
00153 $sQ .= ', ';
00154
00155
00156 $sCol = $aCol[3]?$aCol[0].oxLang::getInstance()->getLanguageTag():$aCol[0];
00157 $sQ .= getViewName( $aCol[1] ) . '.' . $sCol . ' as _' . $iCnt;
00158 }
00159
00160 return " $sQ ";
00161 }
00162
00163 }