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

Generated on Mon Oct 26 20:07:15 2009 for OXID eShop CE by  doxygen 1.5.5