00001 <?php
00002
00003 $aColumns = array( 'container1' => array(
00004 array( 'oxtitle', 'oxattribute', 1, 1, 0 ),
00005 array( 'oxid', 'oxattribute', 0, 0, 1 )
00006 ),
00007 'container2' => array(
00008 array( 'oxtitle', 'oxattribute', 1, 1, 0 ),
00009 array( 'oxid', 'oxobject2attribute', 0, 0, 1 ),
00010 array( 'oxvalue', 'oxobject2attribute', 0, 1, 1 ),
00011 array( 'oxattrid', 'oxobject2attribute', 0, 0, 1 ),
00012 )
00013 );
00017 class ajaxComponent extends ajaxListComponent
00018 {
00024 protected function _getQuery()
00025 {
00026 $sArtId = oxConfig::getParameter( 'oxid' );
00027 $sSynchArtId = oxConfig::getParameter( 'synchoxid' );
00028
00029 $sAttrViewName = getViewName('oxattribute');
00030 if ( $sArtId ) {
00031
00032 $sQAdd = " from oxobject2attribute left join $sAttrViewName on $sAttrViewName.oxid=oxobject2attribute.oxattrid ";
00033 $sQAdd .= " where oxobject2attribute.oxobjectid = '$sArtId' ";
00034 } else {
00035 $sQAdd = " from $sAttrViewName where $sAttrViewName.oxid not in ( select oxobject2attribute.oxattrid from oxobject2attribute left join $sAttrViewName on $sAttrViewName.oxid=oxobject2attribute.oxattrid ";
00036 $sQAdd .= " where oxobject2attribute.oxobjectid = '$sSynchArtId' ) ";
00037 }
00038
00039 return $sQAdd;
00040 }
00041
00047 public function removeattr()
00048 {
00049 $aChosenArt = $this->_getActionIds( 'oxobject2attribute.oxid' );
00050 $sOxid = oxConfig::getParameter( 'oxid' );
00051 if ( oxConfig::getParameter( 'all' ) ) {
00052 $sQ = $this->_addFilter( "delete oxobject2attribute.* ".$this->_getQuery() );
00053 oxDb::getDb()->Execute( $sQ );
00054
00055 } elseif ( is_array( $aChosenArt ) ) {
00056 $sQ = "delete from oxobject2attribute where oxobject2attribute.oxid in ('" . implode( "', '", $aChosenArt ) . "') ";
00057 oxDb::getDb()->Execute( $sQ );
00058 }
00059 }
00060
00066 public function addattr()
00067 {
00068 $aAddCat = $this->_getActionIds( 'oxattribute.oxid' );
00069 $soxId = oxConfig::getParameter( 'synchoxid');
00070
00071 if ( oxConfig::getParameter( 'all' ) ) {
00072 $sAttrViewName = getViewName('oxattribute');
00073 $aAddCat = $this->_getAll( $this->_addFilter( "select $sAttrViewName.oxid ".$this->_getQuery() ) );
00074 }
00075
00076 if ( $soxId && $soxId != "-1" && is_array( $aAddCat ) ) {
00077 foreach ($aAddCat as $sAdd) {
00078 $oNew = oxNew( "oxbase" );
00079 $oNew->init( "oxobject2attribute" );
00080 $oNew->oxobject2attribute__oxobjectid = new oxField($soxId);
00081 $oNew->oxobject2attribute__oxattrid = new oxField($sAdd);
00082 $oNew->save();
00083 }
00084 }
00085 }
00086
00092 public function saveAttributeValue ()
00093 {
00094
00095 $this->sAttributeOXID = oxConfig::getParameter( "attr_oxid");
00096 $sAttributeValue = oxConfig::getParameter( "attr_value");
00097 $soxId = oxConfig::getParameter( "oxid");
00098
00099 $oArticle = oxNew( "oxarticle" );
00100 if ( $oArticle->load( $soxId ) ) {
00101
00102
00103 $sLangTag = oxLang::getInstance()->getLanguageTag();
00104 if ( isset( $this->sAttributeOXID) && ("" != $this->sAttributeOXID)) {
00105 $oGroups = oxNew( "oxlist" );
00106 $oGroups->init( "oxbase", "oxobject2attribute" );
00107 $sSelect = "select * from oxobject2attribute where oxobject2attribute.oxobjectid='".$oArticle->oxarticles__oxid->value."' and ";
00108 $sSelect .= " oxobject2attribute.oxattrid='".$this->sAttributeOXID."' ";
00109 $oGroups->selectString( $sSelect );
00110 foreach ($oGroups as $oGroup) {
00111
00112 $sFieldName = "oxobject2attribute__oxvalue".$sLangTag;
00113 $oGroup->$sFieldName->setValue($sAttributeValue);
00114 $oGroup->save();
00115 }
00116 }
00117 }
00118 }
00119 }