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 ( oxLang::getInstance()->getLanguageNames(), $oOtherLang);
00042             if ( count( $aLang))
00043                 $this->_aViewData["posslang"] = $aLang;
00044 
00045             foreach ( $oOtherLang as $id => $language) {
00046                 $oLang= new oxStdClass();
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 
00057             $aColumns = array();
00058             include_once 'inc/'.strtolower(__CLASS__).'.inc.php';
00059             $this->_aViewData['oxajax'] = $aColumns;
00060 
00061             return "popups/attribute_main.tpl";
00062         }
00063         return "attribute_main.tpl";
00064     }
00065 
00071     public function save()
00072     {
00073 
00074         $soxId = $this->getEditObjectId();
00075         $aParams = oxConfig::getParameter( "editval");
00076 
00077             // shopid
00078             $aParams['oxattribute__oxshopid'] = oxSession::getVar( "actshop" );
00079         $oAttr = oxNew( "oxattribute" );
00080 
00081         if ( $soxId != "-1")
00082             $oAttr->loadInLang( $this->_iEditLang, $soxId );
00083         else
00084             $aParams['oxattribute__oxid'] = null;
00085         //$aParams = $oAttr->ConvertNameArray2Idx( $aParams);
00086 
00087 
00088         $oAttr->setLanguage(0);
00089         $oAttr->assign( $aParams);
00090         $oAttr->setLanguage($this->_iEditLang);
00091         $oAttr = oxUtilsFile::getInstance()->processFiles( $oAttr );
00092         $oAttr->save();
00093 
00094         $this->setEditObjectId( $oAttr->getId() );
00095     }
00096 
00102     public function saveinnlang()
00103     {
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 }