Go to the documentation of this file.00001 <?php
00002
00006 class selectlist_order_ajax extends ajaxListComponent
00007 {
00013 protected $_aColumns = array( 'container1' => array(
00014 array( 'oxtitle', 'oxselectlist', 1, 1, 0 ),
00015 array( 'oxsort', 'oxobject2selectlist', 1, 0, 0 ),
00016 array( 'oxident', 'oxselectlist', 0, 0, 0 ),
00017 array( 'oxvaldesc', 'oxselectlist', 0, 0, 0 ),
00018 array( 'oxid', 'oxobject2selectlist', 0, 0, 1 )
00019 )
00020 );
00021
00027 protected function _getQuery()
00028 {
00029 $sSelTable = $this->_getViewName('oxselectlist');
00030 $sArtId = oxConfig::getParameter( 'oxid' );
00031
00032 $sQAdd = " from $sSelTable left join oxobject2selectlist on oxobject2selectlist.oxselnid = $sSelTable.oxid where oxobjectid = '$sArtId' ";
00033
00034 return $sQAdd;
00035 }
00036
00042 protected function _getSorting()
00043 {
00044 return 'order by oxobject2selectlist.oxsort ';
00045 }
00046
00052 public function setSorting()
00053 {
00054 $sSelId = oxConfig::getParameter( 'oxid' );
00055 $sSelect = "select * from oxobject2selectlist where oxobjectid='$sSelId' order by oxsort";
00056
00057 $oList = oxNew( "oxlist" );
00058 $oList->init( "oxbase", "oxobject2selectlist" );
00059 $oList->selectString( $sSelect );
00060
00061
00062 $iSelCnt = 0;
00063 $aIdx2Id = array();
00064 foreach ( $oList as $sKey => $oSel ) {
00065
00066 if ( $oSel->oxobject2selectlist__oxsort->value != $iSelCnt ) {
00067 $oSel->oxobject2selectlist__oxsort->setValue($iSelCnt);
00068
00069
00070 $oSel->save();
00071 }
00072 $aIdx2Id[$iSelCnt] = $sKey;
00073 $iSelCnt++;
00074 }
00075
00076
00077 if ( ( $iKey = array_search( oxConfig::getParameter( 'sortoxid' ), $aIdx2Id ) ) !== false ) {
00078 $iDir = (oxConfig::getParameter( 'direction' ) == 'up')?($iKey-1):($iKey+1);
00079 if ( isset( $aIdx2Id[$iDir] ) ) {
00080
00081 $oDir1 = $oList->offsetGet( $aIdx2Id[$iDir] );
00082 $oDir2 = $oList->offsetGet( $aIdx2Id[$iKey] );
00083
00084 $iCopy = $oDir1->oxobject2selectlist__oxsort->value;
00085 $oDir1->oxobject2selectlist__oxsort->setValue($oDir2->oxobject2selectlist__oxsort->value);
00086 $oDir2->oxobject2selectlist__oxsort->setValue($iCopy);
00087
00088 $oDir1->save();
00089 $oDir2->save();
00090 }
00091 }
00092
00093 $sQAdd = $this->_getQuery();
00094
00095 $sQ = 'select ' . $this->_getQueryCols() . $sQAdd;
00096 $sCountQ = 'select count( * ) ' . $sQAdd;
00097
00098 $this->_outputResponse( $this->_getData( $sCountQ, $sQ ) );
00099 }
00100 }