00001 <?php
00002
00003 $aColumns = array( 'container1' => array(
00004 array( 'oxartnum', 'oxarticles', 1, 0, 0 ),
00005 array( 'oxtitle', 'oxarticles', 1, 1, 0 ),
00006 array( 'oxpos', 'oxobject2category', 1, 0, 0 ),
00007 array( 'oxean', 'oxarticles', 0, 0, 0 ),
00008 array( 'oxmpn', 'oxarticles', 0, 0, 0 ),
00009 array( 'oxprice', 'oxarticles', 0, 0, 0 ),
00010 array( 'oxstock', 'oxarticles', 0, 0, 0 ),
00011 array( 'oxid', 'oxarticles', 0, 0, 1 )
00012 ),
00013 'container2' => array(
00014 array( 'oxartnum', 'oxarticles', 1, 0, 0 ),
00015 array( 'oxtitle', 'oxarticles', 1, 1, 0 ),
00016 array( 'oxean', 'oxarticles', 0, 0, 0 ),
00017 array( 'oxmpn', 'oxarticles', 0, 0, 0 ),
00018 array( 'oxprice', 'oxarticles', 0, 0, 0 ),
00019 array( 'oxstock', 'oxarticles', 0, 0, 0 ),
00020 array( 'oxid', 'oxarticles', 0, 0, 1 )
00021 )
00022 );
00023
00027 class ajaxComponent extends ajaxListComponent
00028 {
00034 protected function _getQuery()
00035 {
00036
00037 $sArtTable = getViewName( 'oxarticles' );
00038 $sO2CView = getViewName( 'oxobject2category' );
00039
00040
00041 if ( $sSynchOxid = oxConfig::getParameter( 'synchoxid' ) ) {
00042 $sQAdd = " from $sArtTable left join $sO2CView on $sArtTable.oxid=$sO2CView.oxobjectid where $sO2CView.oxcatnid = '$sSynchOxid' ";
00043 if ( $aSkipArt = oxSession::getVar( 'neworder_sess' ) ) {
00044 $sQAdd .= " and $sArtTable.oxid not in ( ".implode( ", ", oxDb::getInstance()->quoteArray( $aSkipArt ) )." ) ";
00045 }
00046 } else {
00047
00048 $sQAdd = " from $sArtTable where ";
00049 if ( $aSkipArt = oxSession::getVar( 'neworder_sess') ) {
00050 $sQAdd .= " $sArtTable.oxid in ( ".implode( ", ", oxDb::getInstance()->quoteArray( $aSkipArt ) )." ) ";
00051 } else {
00052 $sQAdd .= " 1 = 0 ";
00053 }
00054 }
00055
00056 return $sQAdd;
00057 }
00058
00064 protected function _getSorting()
00065 {
00066 $sOrder = '';
00067 if ( oxConfig::getParameter( 'synchoxid' ) ) {
00068 $sOrder = parent::_getSorting();
00069 } elseif ( ( $aSkipArt = oxSession::getVar( 'neworder_sess' ) ) ) {
00070 $sOrderBy = '';
00071 $sArtTable = getViewName( 'oxarticles' );
00072 $sSep = '';
00073 foreach ( $aSkipArt as $sId ) {
00074 $sOrderBy = " $sArtTable.oxid=" . oxDb::getDb()->quote( $sId ) . " ".$sSep.$sOrderBy;
00075 $sSep = ", ";
00076 }
00077 $sOrder = "order by ".$sOrderBy;
00078 }
00079
00080 return $sOrder;
00081 }
00082
00088 public function removecatorderarticle()
00089 {
00090 $aRemoveArt = $this->_getActionIds( 'oxarticles.oxid' );
00091 $soxId = oxConfig::getParameter( 'oxid' );
00092 $aSkipArt = oxSession::getVar( 'neworder_sess' );
00093
00094 if ( is_array( $aRemoveArt ) && is_array( $aSkipArt ) ) {
00095 foreach ( $aRemoveArt as $sRem ) {
00096 if ( ( $iKey = array_search( $sRem, $aSkipArt ) ) !== false ) {
00097 unset( $aSkipArt[$iKey] );
00098 }
00099 }
00100 oxSession::setVar( 'neworder_sess', $aSkipArt );
00101
00102 $sArticleTable = getViewName('oxarticles');
00103 $sO2CView = getViewName('oxobject2category');
00104
00105
00106 $sSelect = "select 1 from $sArticleTable left join $sO2CView on $sArticleTable.oxid=$sO2CView.oxobjectid ";
00107 $sSelect .= "where $sO2CView.oxcatnid = '$soxId' and $sArticleTable.oxparentid = '' and $sArticleTable.oxid ";
00108 $sSelect .= "not in ( ".implode( ", ", oxDb::getInstance()->quoteArray( $aSkipArt ) )." ) ";
00109
00110
00111 echo (int) oxDb::getDb()->getOne( $sSelect );
00112 }
00113 }
00114
00120 public function addcatorderarticle()
00121 {
00122 $aAddArticle = $this->_getActionIds( 'oxarticles.oxid' );
00123 $soxId = oxConfig::getParameter( 'synchoxid' );
00124
00125 $aOrdArt = oxSession::getVar( 'neworder_sess' );
00126 if ( !is_array( $aOrdArt ) )
00127 $aOrdArt = array();
00128
00129 $blEnable = false;
00130
00131 if ( is_array( $aAddArticle ) ) {
00132
00133 foreach ($aAddArticle as $sAdd) {
00134 if ( array_search( $sAdd, $aOrdArt ) === false )
00135 $aOrdArt[] = $sAdd;
00136 }
00137 oxSession::setVar( 'neworder_sess', $aOrdArt );
00138
00139 $sArticleTable = getViewName('oxarticles');
00140 $sO2CView = getViewName('oxobject2category');
00141
00142
00143 $sSelect = "select 1 from $sArticleTable left join $sO2CView on $sArticleTable.oxid=$sO2CView.oxobjectid ";
00144 $sSelect .= "where $sO2CView.oxcatnid = '$soxId' and $sArticleTable.oxparentid = '' and $sArticleTable.oxid ";
00145 $sSelect .= "not in ( ".implode( ", ", oxDb::getInstance()->quoteArray( $aOrdArt ) )." ) ";
00146
00147
00148 echo (int) oxDb::getDb()->getOne( $sSelect );
00149 }
00150 }
00151
00157 public function saveneworder()
00158 {
00159 $oCategory = oxNew( "oxcategory" );
00160 if ( $oCategory->load( oxConfig::getParameter( "oxid" ) ) ) {
00161
00162
00163 $aNewOrder = oxSession::getVar( "neworder_sess" );
00164 if ( is_array( $aNewOrder ) && count( $aNewOrder ) ) {
00165 $sO2CView = getViewName('oxobject2category');
00166 $sSelect = "select * from $sO2CView where $sO2CView.oxcatnid='".$oCategory->getId()."' and $sO2CView.oxobjectid in (".implode( ", ", oxDb::getInstance()->quoteArray( $aNewOrder ) )." )";
00167 $oList = oxNew( "oxlist" );
00168 $oList->init( "oxbase", "oxobject2category" );
00169 $oList->selectString( $sSelect );
00170
00171
00172 foreach ( $oList as $oObj ) {
00173 if ( ( $iNewPos = array_search( $oObj->oxobject2category__oxobjectid->value, $aNewOrder ) ) !== false ) {
00174 $oObj->oxobject2category__oxpos->setValue($iNewPos);
00175 $oObj->save();
00176 }
00177 }
00178
00179 oxSession::setVar( 'neworder_sess', null );
00180 }
00181 }
00182 }
00183
00189 public function remneworder()
00190 {
00191 $oCategory = oxNew( "oxcategory" );
00192 if ( $oCategory->load( oxConfig::getParameter( "oxid" ) ) ) {
00193
00194
00195 $sSelect = "update oxobject2category set oxpos = '0' where oxobject2category.oxcatnid='" . $oCategory->getId() . "'";
00196 oxDb::getInstance()->getDb()->execute( $sSelect );
00197
00198 oxSession::setVar( 'neworder_sess', null );
00199 }
00200 }
00201 }