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( 'oxmpn', 'oxarticles', 0, 0, 0 ),
00008 array( 'oxprice', 'oxarticles', 0, 0, 0 ),
00009 array( 'oxstock', 'oxarticles', 0, 0, 0 ),
00010 array( 'oxid', 'oxarticles', 0, 0, 1 )
00011 ),
00012 'container2' => array(
00013 array( 'oxartnum', 'oxarticles', 1, 0, 0 ),
00014 array( 'oxtitle', 'oxarticles', 1, 1, 0 ),
00015 array( 'oxean', 'oxarticles', 1, 0, 0 ),
00016 array( 'oxmpn', 'oxarticles', 0, 0, 0 ),
00017 array( 'oxprice', 'oxarticles', 0, 0, 0 ),
00018 array( 'oxstock', 'oxarticles', 0, 0, 0 ),
00019 array( 'oxid', 'oxobject2article', 0, 0, 1 )
00020 )
00021 );
00022
00026 class ajaxComponent extends ajaxListComponent
00027 {
00033 protected $_blAllowExtColumns = true;
00034
00040 protected function _getQuery()
00041 {
00042 $myConfig = $this->getConfig();
00043 $sArticleTable = $this->_getViewName( 'oxarticles' );
00044 $sO2CView = $this->_getViewName( 'oxobject2category' );
00045
00046 $sSelId = oxConfig::getParameter( 'oxid' );
00047 $sSynchSelId = oxConfig::getParameter( 'synchoxid' );
00048 $oDb = oxDb::getDb();
00049
00050
00051 if ( !$sSelId ) {
00052 $sQAdd = " from $sArticleTable where 1 ";
00053 $sQAdd .= $myConfig->getConfigParam( 'blVariantsSelection' )? '':" and $sArticleTable.oxparentid = '' ";
00054 } else {
00055
00056 if ( $sSynchSelId && $sSelId != $sSynchSelId ) {
00057 $sQAdd = " from $sO2CView as oxobject2category left join $sArticleTable on ";
00058 $sQAdd .= $myConfig->getConfigParam( 'blVariantsSelection' )?" ($sArticleTable.oxid=oxobject2category.oxobjectid or $sArticleTable.oxparentid=oxobject2category.oxobjectid)":" $sArticleTable.oxid=oxobject2category.oxobjectid ";
00059 $sQAdd .= " where oxobject2category.oxcatnid = " . $oDb->quote( $sSelId ) . " ";
00060 } else {
00061
00062 if ( $myConfig->getConfigParam( 'blBidirectCross' ) ) {
00063 $sQAdd = " from oxobject2article ";
00064 $sQAdd .= " inner join $sArticleTable on ( oxobject2article.oxobjectid = $sArticleTable.oxid ";
00065 $sQAdd .= " or oxobject2article.oxarticlenid = $sArticleTable.oxid ) ";
00066 $sQAdd .= " where ( oxobject2article.oxarticlenid = " . $oDb->quote( $sSelId ) . " or oxobject2article.oxobjectid = " . $oDb->quote( $sSelId ) . " ) ";
00067 $sQAdd .= " and $sArticleTable.oxid != " . $oDb->quote( $sSelId ) . " ";
00068 } else {
00069 $sQAdd = " from oxobject2article left join $sArticleTable on oxobject2article.oxobjectid=$sArticleTable.oxid ";
00070 $sQAdd .= " where oxobject2article.oxarticlenid = " . $oDb->quote( $sSelId ) . " ";
00071 }
00072 }
00073 }
00074 if ( $sSynchSelId && $sSynchSelId != $sSelId) {
00075 if ( $myConfig->getConfigParam( 'blBidirectCross' ) ) {
00076 $sSubSelect = "select $sArticleTable.oxid from oxobject2article left join $sArticleTable on (oxobject2article.oxobjectid=$sArticleTable.oxid or oxobject2article.oxarticlenid=$sArticleTable.oxid) ";
00077 $sSubSelect .= "where (oxobject2article.oxarticlenid = " . $oDb->quote( $sSynchSelId ) . " or oxobject2article.oxobjectid = " . $oDb->quote( $sSynchSelId ) . " )";
00078 } else {
00079 $sSubSelect = "select $sArticleTable.oxid from oxobject2article left join $sArticleTable on oxobject2article.oxobjectid=$sArticleTable.oxid ";
00080 $sSubSelect .= "where oxobject2article.oxarticlenid = " . $oDb->quote( $sSynchSelId ) . " ";
00081 }
00082
00083 $sSubSelect .= " and $sArticleTable.oxid IS NOT NULL ";
00084 $sQAdd .= " and $sArticleTable.oxid not in ( $sSubSelect ) ";
00085 }
00086
00087
00088 $sQAdd .= " and $sArticleTable.oxid IS NOT NULL ";
00089
00090
00091 $sId = ( $sSelId ) ? $sSelId : $sSynchSelId ;
00092 $sQAdd .= " and $sArticleTable.oxid != " . $oDb->quote( $sId ) . " ";
00093
00094 return $sQAdd ;
00095 }
00096
00102 public function removearticlecross()
00103 {
00104 $aChosenArt = $this->_getActionIds( 'oxobject2article.oxid' );
00105
00106 if ( oxConfig::getParameter( 'all' ) ) {
00107
00108 $sQ = $this->_addFilter( "delete oxobject2article.* ".$this->_getQuery() );
00109 oxDb::getDb()->Execute( $sQ );
00110
00111 } elseif ( is_array( $aChosenArt ) ) {
00112 $sQ = "delete from oxobject2article where oxobject2article.oxid in (" . implode( ", ", oxDb::getInstance()->quoteArray( $aChosenArt ) ) . ") ";
00113 oxDb::getDb()->Execute( $sQ );
00114 }
00115 }
00116
00122 public function addarticlecross()
00123 {
00124 $aChosenArt = $this->_getActionIds( 'oxarticles.oxid' );
00125 $soxId = oxConfig::getParameter( 'synchoxid');
00126
00127
00128 if ( oxConfig::getParameter( 'all' ) ) {
00129 $sArtTable = $this->_getViewName('oxarticles');
00130 $aChosenArt = $this->_getAll( parent::_addFilter( "select $sArtTable.oxid ".$this->_getQuery() ) );
00131 }
00132
00133 $oArticle = oxNew( "oxarticle" );
00134 if ( $oArticle->load( $soxId) && $soxId && $soxId != "-1" && is_array( $aChosenArt ) ) {
00135 foreach ( $aChosenArt as $sAdd ) {
00136 $oNewGroup = oxNew( 'oxbase' );
00137 $oNewGroup->init( 'oxobject2article' );
00138 $oNewGroup->oxobject2article__oxobjectid = new oxField($sAdd);
00139 $oNewGroup->oxobject2article__oxarticlenid = new oxField($oArticle->oxarticles__oxid->value);
00140 $oNewGroup->oxobject2article__oxsort = new oxField(0);
00141 $oNewGroup->save();
00142 }
00143 }
00144 }
00145 }