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         parent::save();
00074 
00075         $soxId = $this->getEditObjectId();
00076         $aParams = oxConfig::getParameter( "editval");
00077 
00078             // shopid
00079             $aParams['oxattribute__oxshopid'] = oxSession::getVar( "actshop" );
00080         $oAttr = oxNew( "oxattribute" );
00081 
00082         if ( $soxId != "-1")
00083             $oAttr->loadInLang( $this->_iEditLang, $soxId );
00084         else
00085             $aParams['oxattribute__oxid'] = null;
00086         //$aParams = $oAttr->ConvertNameArray2Idx( $aParams);
00087 
00088 
00089         $oAttr->setLanguage(0);
00090         $oAttr->assign( $aParams);
00091         $oAttr->setLanguage($this->_iEditLang);
00092         $oAttr = oxUtilsFile::getInstance()->processFiles( $oAttr );
00093         $oAttr->save();
00094 
00095         $this->setEditObjectId( $oAttr->getId() );
00096     }
00097 
00103     public function saveinnlang()
00104     {
00105         parent::save();
00106 
00107         $soxId = $this->getEditObjectId();
00108         $aParams = oxConfig::getParameter( "editval");
00109 
00110             // shopid
00111             $aParams['oxattribute__oxshopid'] = oxSession::getVar( "actshop");
00112         $oAttr = oxNew( "oxattribute" );
00113 
00114         if ( $soxId != "-1") {
00115             $oAttr->loadInLang( $this->_iEditLang, $soxId );
00116         } else {
00117             $aParams['oxattribute__oxid'] = null;
00118         }
00119 
00120 
00121         $oAttr->setLanguage(0);
00122         $oAttr->assign( $aParams);
00123 
00124         // apply new language
00125         $oAttr->setLanguage( oxConfig::getParameter( "new_lang" ) );
00126         $oAttr->save();
00127 
00128         // set oxid if inserted
00129         $this->setEditObjectId( $oAttr->getId() );
00130     }
00131 }