article_selection.inc.php

Go to the documentation of this file.
00001 <?php
00002 
00003 $aColumns = array( 'container1' => array(    // field , table,         visible, multilanguage, ident
00004                                         array( 'oxtitle',   'oxselectlist', 1, 1, 0 ),
00005                                         array( 'oxident',   'oxselectlist', 1, 0, 0 ),
00006                                         array( 'oxvaldesc', 'oxselectlist', 1, 0, 0 ),
00007                                         array( 'oxid',      'oxselectlist', 0, 0, 1 )
00008                                         ),
00009                      'container2' => array(
00010                                         array( 'oxtitle',   'oxselectlist', 1, 1, 0 ),
00011                                         array( 'oxident',   'oxselectlist', 1, 0, 0 ),
00012                                         array( 'oxvaldesc', 'oxselectlist', 1, 0, 0 ),
00013                                         array( 'oxid',      'oxobject2selectlist', 0, 0, 1 )
00014                                         )
00015                     );
00019 class ajaxComponent extends ajaxListComponent
00020 {
00026     protected function _getQuery()
00027     {
00028         $sSLViewName = getViewName('oxselectlist');
00029         $sArtViewName = getViewName('oxarticles');
00030 
00031         $sArtId      = oxConfig::getParameter( 'oxid' );
00032         $sSynchArtId = oxConfig::getParameter( 'synchoxid' );
00033 
00034         $sOxid = ( $sArtId ) ? $sArtId : $sSynchArtId;
00035         $sQ = "select oxparentid from $sArtViewName where oxid = '$sOxid' and oxparentid != '' ";
00036         $sQ .= "and (select count(oxobjectid) from oxobject2selectlist where oxobjectid = '$sOxid') = 0";
00037         $sParentId = oxDb::getDb()->getOne( $sQ );
00038 
00039         // all selectlists article is in
00040         $sQAdd  = " from oxobject2selectlist left join $sSLViewName on $sSLViewName.oxid=oxobject2selectlist.oxselnid ";
00041         $sQAdd .= " where oxobject2selectlist.oxobjectid = '$sOxid' ";
00042         if ( $sParentId ) {
00043             $sQAdd .= "or oxobject2selectlist.oxobjectid = '$sParentId' ";
00044         }
00045         // all not assigned selectlists
00046         if ( $sSynchArtId ) {
00047             $sQAdd  = " from $sSLViewName  where $sSLViewName.oxid not in ( select oxobject2selectlist.oxselnid $sQAdd ) ";
00048         }
00049 
00050         return $sQAdd;
00051     }
00052 
00058     public function removesel()
00059     {
00060         $aChosenArt = $this->_getActionIds( 'oxobject2selectlist.oxid' );
00061         if ( oxConfig::getParameter( 'all' ) ) {
00062 
00063             $sQ = $this->_addFilter( "delete oxobject2selectlist.* ".$this->_getQuery() );
00064             oxDb::getDb()->Execute( $sQ );
00065 
00066         } elseif ( is_array( $aChosenArt ) ) {
00067             $sQ = "delete from oxobject2selectlist where oxobject2selectlist.oxid in ('" . implode( "', '", $aChosenArt ) . "') ";
00068             oxDb::getDb()->Execute( $sQ );
00069         }
00070     }
00071 
00077     public function addsel()
00078     {
00079         $aAddSel = $this->_getActionIds( 'oxselectlist.oxid' );
00080         $soxId   = oxConfig::getParameter( 'synchoxid');
00081 
00082         // adding
00083         if ( oxConfig::getParameter( 'all' ) ) {
00084             $sSLViewName = getViewName('oxselectlist');
00085             $aAddSel = $this->_getAll( $this->_addFilter( "select $sSLViewName.oxid ".$this->_getQuery() ) );
00086         }
00087 
00088         if ( $soxId && $soxId != "-1" && is_array( $aAddSel ) ) {
00089             foreach ($aAddSel as $sAdd) {
00090                 $oNew = oxNew( "oxbase" );
00091                 $oNew->init( "oxobject2selectlist" );
00092                 $oNew->oxobject2selectlist__oxobjectid = new oxField($soxId);
00093                 $oNew->oxobject2selectlist__oxselnid   = new oxField($sAdd);
00094                 $oNew->save();
00095             }
00096         }
00097     }
00098 }

Generated on Tue Aug 18 09:21:04 2009 for OXID eShop CE by  doxygen 1.5.5