attribute_main.php

Go to the documentation of this file.
00001 <?php
00002 
00009 class Attribute_Main extends oxAdminDetails
00010 {
00017     public function render()
00018     {   $myConfig = $this->getConfig();
00019 
00020         parent::render();
00021         $oAttr = oxNew( "oxattribute" );
00022         $soxId = $this->_aViewData["oxid"] = $this->getEditObjectId();
00023         $sArticleTable = getViewName('oxarticles');
00024 
00025         // copy this tree for our article choose
00026         $sChosenArtCat = oxConfig::getParameter( "artcat");
00027         if ( $soxId != "-1" && isset( $soxId)) {
00028             // generating category tree for select list
00029             $sChosenArtCat = $this->_getCategoryTree( "artcattree", $sChosenArtCat, $soxId);
00030             // load object
00031             $oAttr->loadInLang( $this->_iEditLang, $soxId );
00032 
00033 
00034             $oOtherLang = $oAttr->getAvailableInLangs();
00035             if (!isset($oOtherLang[$this->_iEditLang])) {
00036                 // echo "language entry doesn't exist! using: ".key($oOtherLang);
00037                 $oAttr->loadInLang( key($oOtherLang), $soxId );
00038             }
00039 
00040             // remove already created languages
00041             $aLang = array_diff ( oxRegistry::getLang()->getLanguageNames(), $oOtherLang);
00042             if ( count( $aLang))
00043                 $this->_aViewData["posslang"] = $aLang;
00044 
00045             foreach ( $oOtherLang as $id => $language) {
00046                 $oLang= new stdClass();
00047                 $oLang->sLangDesc = $language;
00048                 $oLang->selected = ($id == $this->_iEditLang);
00049                 $this->_aViewData["otherlang"][$id] =  clone $oLang;
00050             }
00051         }
00052 
00053         $this->_aViewData["edit"] =  $oAttr;
00054 
00055         if ( oxConfig::getParameter("aoc") ) {
00056             $oAttributeMainAjax = oxNew( 'attribute_main_ajax' );
00057             $this->_aViewData['oxajax'] = $oAttributeMainAjax->getColumns();
00058 
00059             return "popups/attribute_main.tpl";
00060         }
00061         return "attribute_main.tpl";
00062     }
00063 
00069     public function save()
00070     {
00071         parent::save();
00072 
00073         $soxId = $this->getEditObjectId();
00074         $aParams = oxConfig::getParameter( "editval");
00075 
00076             // shopid
00077             $aParams['oxattribute__oxshopid'] = oxSession::getVar( "actshop" );
00078         $oAttr = oxNew( "oxattribute" );
00079 
00080         if ( $soxId != "-1")
00081             $oAttr->loadInLang( $this->_iEditLang, $soxId );
00082         else
00083             $aParams['oxattribute__oxid'] = null;
00084         //$aParams = $oAttr->ConvertNameArray2Idx( $aParams);
00085 
00086 
00087         $oAttr->setLanguage(0);
00088         $oAttr->assign( $aParams);
00089         $oAttr->setLanguage($this->_iEditLang);
00090         $oAttr = oxRegistry::get("oxUtilsFile")->processFiles( $oAttr );
00091         $oAttr->save();
00092 
00093         $this->setEditObjectId( $oAttr->getId() );
00094     }
00095 
00101     public function saveinnlang()
00102     {
00103         parent::save();
00104 
00105         $soxId = $this->getEditObjectId();
00106         $aParams = oxConfig::getParameter( "editval");
00107 
00108             // shopid
00109             $aParams['oxattribute__oxshopid'] = oxSession::getVar( "actshop");
00110         $oAttr = oxNew( "oxattribute" );
00111 
00112         if ( $soxId != "-1") {
00113             $oAttr->loadInLang( $this->_iEditLang, $soxId );
00114         } else {
00115             $aParams['oxattribute__oxid'] = null;
00116         }
00117 
00118 
00119         $oAttr->setLanguage(0);
00120         $oAttr->assign( $aParams);
00121 
00122         // apply new language
00123         $oAttr->setLanguage( oxConfig::getParameter( "new_lang" ) );
00124         $oAttr->save();
00125 
00126         // set oxid if inserted
00127         $this->setEditObjectId( $oAttr->getId() );
00128     }
00129 }