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', 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', 'oxobject2article', 0, 0, 1 )
00018 )
00019 );
00020
00024 class ajaxComponent extends ajaxListComponent
00025 {
00031 protected function _getQuery()
00032 {
00033 $myConfig = $this->getConfig();
00034 $sArticleTable = getViewName( 'oxarticles' );
00035 $sO2CView = getViewName( 'oxobject2category' );
00036
00037 $sSelId = oxConfig::getParameter( 'oxid' );
00038 $sSynchSelId = oxConfig::getParameter( 'synchoxid' );
00039
00040
00041 if ( !$sSelId ) {
00042 $sQAdd = " from $sArticleTable where 1 ";
00043 $sQAdd .= $myConfig->getConfigParam( 'blVariantsSelection' )?'':" and $sArticleTable.oxparentid = '' ";
00044 } else {
00045
00046 if ( $sSynchSelId && $sSelId != $sSynchSelId ) {
00047 $sQAdd = " from $sO2CView as oxobject2category left join $sArticleTable on ";
00048 $sQAdd .= $myConfig->getConfigParam( 'blVariantsSelection' )?" ($sArticleTable.oxid=oxobject2category.oxobjectid or $sArticleTable.oxparentid=oxobject2category.oxobjectid)":" $sArticleTable.oxid=oxobject2category.oxobjectid ";
00049 $sQAdd .= " where oxobject2category.oxcatnid = '$sSelId' ";
00050 } else {
00051
00052 if ( $myConfig->getConfigParam( 'blBidirectCross' ) ) {
00053 $sQAdd = " from oxobject2article ";
00054 $sQAdd .= " inner join $sArticleTable on ( oxobject2article.oxobjectid = $sArticleTable.oxid ";
00055 $sQAdd .= " or oxobject2article.oxarticlenid = $sArticleTable.oxid ) ";
00056 $sQAdd .= " where ( oxobject2article.oxarticlenid = '$sSelId' or oxobject2article.oxobjectid = '$sSelId' ) ";
00057 $sQAdd .= " and $sArticleTable.oxid != '$sSelId' ";
00058 } else {
00059 $sQAdd = " from oxobject2article left join $sArticleTable on oxobject2article.oxobjectid=$sArticleTable.oxid ";
00060 $sQAdd .= " where oxobject2article.oxarticlenid = '$sSelId' ";
00061 }
00062 }
00063 }
00064 if ( $sSynchSelId && $sSynchSelId != $sSelId) {
00065 if ( $myConfig->getConfigParam( 'blBidirectCross' ) ) {
00066 $sSubSelect = "select $sArticleTable.oxid from oxobject2article left join $sArticleTable on (oxobject2article.oxobjectid=$sArticleTable.oxid or oxobject2article.oxarticlenid=$sArticleTable.oxid) ";
00067 $sSubSelect .= "where (oxobject2article.oxarticlenid = '$sSynchSelId' or oxobject2article.oxobjectid = '$sSynchSelId' )";
00068 } else {
00069 $sSubSelect = "select $sArticleTable.oxid from oxobject2article left join $sArticleTable on oxobject2article.oxobjectid=$sArticleTable.oxid ";
00070 $sSubSelect .= "where oxobject2article.oxarticlenid = '$sSynchSelId' ";
00071 }
00072
00073 $sSubSelect .= " and $sArticleTable.oxid IS NOT NULL ";
00074 $sQAdd .= " and $sArticleTable.oxid not in ( $sSubSelect ) ";
00075 }
00076
00077
00078 $sQAdd .= " and $sArticleTable.oxid IS NOT NULL ";
00079
00080
00081 $sQAdd .= " and $sArticleTable.oxid != '".( $sSelId ? $sSelId: $sSynchSelId )."' ";
00082
00083 return $sQAdd;
00084 }
00085
00091 public function removearticlecross()
00092 {
00093 $aChosenArt = $this->_getActionIds( 'oxobject2article.oxid' );
00094
00095 if ( oxConfig::getParameter( 'all' ) ) {
00096
00097 $sQ = $this->_addFilter( "delete oxobject2article.* ".$this->_getQuery() );
00098 oxDb::getDb()->Execute( $sQ );
00099
00100 } elseif ( is_array( $aChosenArt ) ) {
00101 $sQ = "delete from oxobject2article where oxobject2article.oxid in ('" . implode( "', '", $aChosenArt ) . "') ";
00102 oxDb::getDb()->Execute( $sQ );
00103 }
00104 }
00105
00111 public function addarticlecross()
00112 {
00113 $aChosenArt = $this->_getActionIds( 'oxarticles.oxid' );
00114 $soxId = oxConfig::getParameter( 'synchoxid');
00115
00116
00117 if ( oxConfig::getParameter( 'all' ) ) {
00118 $sArtTable = getViewName('oxarticles');
00119 $aChosenArt = $this->_getAll( $this->_addFilter( "select $sArtTable.oxid ".$this->_getQuery() ) );
00120 }
00121
00122 $oArticle = oxNew( "oxarticle" );
00123 if ( $oArticle->load( $soxId) && $soxId && $soxId != "-1" && is_array( $aChosenArt ) ) {
00124 foreach ( $aChosenArt as $sAdd ) {
00125 $oNewGroup = oxNew( 'oxbase' );
00126 $oNewGroup->init( 'oxobject2article' );
00127 $oNewGroup->oxobject2article__oxobjectid = new oxField($sAdd);
00128 $oNewGroup->oxobject2article__oxarticlenid = new oxField($oArticle->oxarticles__oxid->value);
00129 $oNewGroup->oxobject2article__oxsort = new oxField(0);
00130 $oNewGroup->save();
00131 }
00132 }
00133 }
00134
00141 protected function _getQueryCols()
00142 {
00143 $myConfig = $this->getConfig();
00144 $sLangTag = oxLang::getInstance()->getLanguageTag();
00145
00146 $sQ = '';
00147 $blSep = false;
00148 $aVisiblecols = $this->_getVisibleColNames();
00149 foreach ( $aVisiblecols as $iCnt => $aCol ) {
00150 if ( $blSep )
00151 $sQ .= ', ';
00152 $sViewTable = getViewName( $aCol[1] );
00153
00154 $sCol = $aCol[3]?$aCol[0].$sLangTag:$aCol[0];
00155 if ( $myConfig->getConfigParam( 'blVariantsSelection' ) && $aCol[0] == 'oxtitle' ) {
00156 $sVarSelect = "$sViewTable.oxvarselect".$sLangTag;
00157 $sQ .= " IF( $sViewTable.$sCol != '', $sViewTable.$sCol, CONCAT((select oxart.$sCol from $sViewTable as oxart where oxart.oxid = $sViewTable.oxparentid),', ',$sVarSelect)) as _" . $iCnt;
00158 } else {
00159 $sQ .= $sViewTable . '.' . $sCol . ' as _' . $iCnt;
00160 }
00161 $blSep = true;
00162 }
00163
00164 $aIdentCols = $this->_getIdentColNames();
00165 foreach ( $aIdentCols as $iCnt => $aCol ) {
00166 if ( $blSep )
00167 $sQ .= ', ';
00168
00169
00170 $sCol = $aCol[3]?$aCol[0].$sLangTag:$aCol[0];
00171 $sQ .= getViewName( $aCol[1] ) . '.' . $sCol . ' as _' . $iCnt;
00172 }
00173
00174 return " $sQ ";
00175 }
00176
00177 }