Go to the documentation of this file.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 $oDb = oxDb::getDb();
00027 $sArtId = oxConfig::getParameter( 'oxid' );
00028 $sSynchArtId = oxConfig::getParameter( 'synchoxid' );
00029
00030 $sAttrViewName = getViewName('oxattribute');
00031 if ( $sArtId ) {
00032
00033 $sQAdd = " from oxobject2attribute left join $sAttrViewName on $sAttrViewName.oxid=oxobject2attribute.oxattrid ";
00034 $sQAdd .= " where oxobject2attribute.oxobjectid = " . $oDb->quote( $sArtId ) . " ";
00035 } else {
00036 $sQAdd = " from $sAttrViewName where $sAttrViewName.oxid not in ( select oxobject2attribute.oxattrid from oxobject2attribute left join $sAttrViewName on $sAttrViewName.oxid=oxobject2attribute.oxattrid ";
00037 $sQAdd .= " where oxobject2attribute.oxobjectid = " . $oDb->quote( $sSynchArtId ) . " ) ";
00038 }
00039
00040 return $sQAdd;
00041 }
00042
00048 public function removeattr()
00049 {
00050 $aChosenArt = $this->_getActionIds( 'oxobject2attribute.oxid' );
00051 $sOxid = oxConfig::getParameter( 'oxid' );
00052 if ( oxConfig::getParameter( 'all' ) ) {
00053 $sQ = $this->_addFilter( "delete oxobject2attribute.* ".$this->_getQuery() );
00054 oxDb::getDb()->Execute( $sQ );
00055
00056 } elseif ( is_array( $aChosenArt ) ) {
00057 $sQ = "delete from oxobject2attribute where oxobject2attribute.oxid in (" . implode( ", ", oxDb::getInstance()->quoteArray( $aChosenArt ) ) . ") ";
00058 oxDb::getDb()->Execute( $sQ );
00059 }
00060 }
00061
00067 public function addattr()
00068 {
00069 $aAddCat = $this->_getActionIds( 'oxattribute.oxid' );
00070 $soxId = oxConfig::getParameter( 'synchoxid');
00071
00072 if ( oxConfig::getParameter( 'all' ) ) {
00073 $sAttrViewName = getViewName('oxattribute');
00074 $aAddCat = $this->_getAll( $this->_addFilter( "select $sAttrViewName.oxid ".$this->_getQuery() ) );
00075 }
00076
00077 if ( $soxId && $soxId != "-1" && is_array( $aAddCat ) ) {
00078 foreach ($aAddCat as $sAdd) {
00079 $oNew = oxNew( "oxbase" );
00080 $oNew->init( "oxobject2attribute" );
00081 $oNew->oxobject2attribute__oxobjectid = new oxField($soxId);
00082 $oNew->oxobject2attribute__oxattrid = new oxField($sAdd);
00083 $oNew->save();
00084 }
00085 }
00086 }
00087
00093 public function saveAttributeValue ()
00094 {
00095 $oDb = oxDb::getDb();
00096
00097 $soxId = oxConfig::getParameter( "oxid");
00098 $this->sAttributeOXID = oxConfig::getParameter( "attr_oxid");
00099 $sAttributeValue = oxConfig::getParameter( "attr_value");
00100 if (!$this->getConfig()->isUtf()) {
00101 $sAttributeValue = iconv( 'UTF-8', oxLang::getInstance()->translateString("charset"), $sAttributeValue );
00102 }
00103
00104 $oArticle = oxNew( "oxarticle" );
00105 if ( $oArticle->load( $soxId ) ) {
00106
00107
00108 $sLangTag = oxLang::getInstance()->getLanguageTag();
00109 if ( isset( $this->sAttributeOXID) && ("" != $this->sAttributeOXID)) {
00110 $oGroups = oxNew( "oxlist" );
00111 $oGroups->init( "oxbase", "oxobject2attribute" );
00112 $sSelect = "select * from oxobject2attribute where oxobject2attribute.oxobjectid= " . $oDb->quote( $oArticle->oxarticles__oxid->value ) . " and ";
00113 $sSelect .= " oxobject2attribute.oxattrid= " . $oDb->quote( $this->sAttributeOXID ) . " ";
00114 $oGroups->selectString( $sSelect );
00115 foreach ($oGroups as $oGroup) {
00116
00117 $sFieldName = "oxobject2attribute__oxvalue".$sLangTag;
00118 $oGroup->$sFieldName->setValue($sAttributeValue);
00119 $oGroup->save();
00120 }
00121 }
00122 }
00123 }
00124 }