vendor_main.php

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

Generated on Wed Apr 22 12:26:30 2009 for OXID eShop CE by  doxygen 1.5.5