attribute_main.php

Go to the documentation of this file.
00001 <?php
00002 
00010 class Attribute_Main extends oxAdminDetails
00011 {
00018     public function render()
00019     {   $myConfig = $this->getConfig();
00020 
00021         parent::render();
00022 
00023         $soxId = oxConfig::getParameter( "oxid");
00024         // check if we right now saved a new entry
00025         $sSavedID = oxConfig::getParameter( "saved_oxid");
00026         if ( ($soxId == "-1" || !isset( $soxId)) && isset( $sSavedID) ) {
00027             $soxId = $sSavedID;
00028             oxSession::deleteVar( "saved_oxid");
00029             $this->_aViewData["oxid"] =  $soxId;
00030             // for reloading upper frame
00031             $this->_aViewData["updatelist"] =  "1";
00032         }
00033 
00034         $sArticleTable = getViewName('oxarticles');
00035 
00036         // copy this tree for our article choose
00037         $sChosenArtCat = oxConfig::getParameter( "artcat");
00038         if ( $soxId != "-1" && isset( $soxId)) {
00039             // generating category tree for select list
00040             $sChosenArtCat = $this->_getCategoryTree( "artcattree", $sChosenArtCat, $soxId);
00041 
00042             // load object
00043             $oAttr = oxNew( "oxattribute" );
00044             $oAttr->loadInLang( $this->_iEditLang, $soxId );
00045 
00046 
00047             $oOtherLang = $oAttr->getAvailableInLangs();
00048             if (!isset($oOtherLang[$this->_iEditLang])) {
00049                 // echo "language entry doesn't exist! using: ".key($oOtherLang);
00050                 $oAttr->loadInLang( key($oOtherLang), $soxId );
00051             }
00052 
00053             $this->_aViewData["edit"] =  $oAttr;
00054 
00055             // remove already created languages
00056             $aLang = array_diff ( oxLang::getInstance()->getLanguageNames(), $oOtherLang);
00057             if ( count( $aLang))
00058                 $this->_aViewData["posslang"] = $aLang;
00059 
00060             foreach ( $oOtherLang as $id => $language) {
00061                 $oLang= new oxStdClass();
00062                 $oLang->sLangDesc = $language;
00063                 $oLang->selected = ($id == $this->_iEditLang);
00064                 $this->_aViewData["otherlang"][$id] =  clone $oLang;
00065             }
00066         }
00067         if ( oxConfig::getParameter("aoc") ) {
00068 
00069             $aColumns = array();
00070             include_once 'inc/'.strtolower(__CLASS__).'.inc.php';
00071             $this->_aViewData['oxajax'] = $aColumns;
00072 
00073             return "popups/attribute_main.tpl";
00074         }
00075         return "attribute_main.tpl";
00076     }
00077 
00083     public function save()
00084     {
00085 
00086         $soxId   = oxConfig::getParameter( "oxid");
00087         $aParams = oxConfig::getParameter( "editval");
00088 
00089             // shopid
00090             $sShopID = oxSession::getVar( "actshop");
00091             $aParams['oxattribute__oxshopid'] = $sShopID;
00092         $oAttr = oxNew( "oxattribute" );
00093 
00094         if ( $soxId != "-1")
00095             $oAttr->loadInLang( $this->_iEditLang, $soxId );
00096         else
00097             $aParams['oxattribute__oxid'] = null;
00098         //$aParams = $oAttr->ConvertNameArray2Idx( $aParams);
00099 
00100 
00101         $oAttr->setLanguage(0);
00102         $oAttr->assign( $aParams);
00103         $oAttr->setLanguage($this->_iEditLang);
00104         $oAttr = oxUtilsFile::getInstance()->processFiles( $oAttr );
00105         $oAttr->save();
00106         $this->_aViewData["updatelist"] = "1";
00107 
00108         // set oxid if inserted
00109         if ( $soxId == "-1")
00110             oxSession::setVar( "saved_oxid", $oAttr->oxattribute__oxid->value);
00111 
00112         return $this->autosave();
00113     }
00114 
00120     public function saveinnlang()
00121     {
00122 
00123         $soxId      = oxConfig::getParameter( "oxid");
00124         $aParams    = oxConfig::getParameter( "editval");
00125 
00126             // shopid
00127             $sShopID = oxSession::getVar( "actshop");
00128             $aParams['oxattribute__oxshopid'] = $sShopID;
00129         $oAttr = oxNew( "oxattribute" );
00130 
00131         if ( $soxId != "-1")
00132             $oAttr->loadInLang( $this->_iEditLang, $soxId );
00133         else
00134             $aParams['oxattribute__oxid'] = null;
00135         //$aParams = $oAttr->ConvertNameArray2Idx( $aParams);
00136 
00137 
00138         $oAttr->setLanguage(0);
00139         $oAttr->assign( $aParams);
00140 
00141         // apply new language
00142         $sNewLanguage = oxConfig::getParameter( "new_lang");
00143         $oAttr->setLanguage( $sNewLanguage);
00144         $oAttr->save();
00145         $this->_aViewData["updatelist"] = "1";
00146 
00147         // set for reload
00148         oxSession::setVar( "new_lang", $sNewLanguage);
00149 
00150         // set oxid if inserted
00151         if ( $soxId == "-1")
00152             oxSession::setVar( "saved_oxid", $oAttr->oxattribute__oxid->value);
00153     }
00154 }

Generated on Thu Dec 4 12:04:55 2008 for OXID eShop CE by  doxygen 1.5.5