vendor_main.php

Go to the documentation of this file.
00001 <?php
00002 
00007 class Vendor_Main extends oxAdminDetails
00008 {
00009 
00017     public function render()
00018     {
00019         parent::render();
00020 
00021         $soxId = $this->_aViewData["oxid"] = $this->getEditObjectId();
00022         if ($soxId != "-1" && isset($soxId)) {
00023             // load object
00024             $oVendor = oxNew("oxvendor");
00025             $oVendor->loadInLang($this->_iEditLang, $soxId);
00026 
00027             $oOtherLang = $oVendor->getAvailableInLangs();
00028             if (!isset($oOtherLang[$this->_iEditLang])) {
00029                 // echo "language entry doesn't exist! using: ".key($oOtherLang);
00030                 $oVendor->loadInLang(key($oOtherLang), $soxId);
00031             }
00032             $this->_aViewData["edit"] = $oVendor;
00033 
00034             // category tree
00035             $this->_createCategoryTree("artcattree");
00036 
00037             //Disable editing for derived articles
00038             if ($oVendor->isDerived()) {
00039                 $this->_aViewData['readonly'] = true;
00040             }
00041 
00042             // remove already created languages
00043             $aLang = array_diff(oxRegistry::getLang()->getLanguageNames(), $oOtherLang);
00044             if (count($aLang)) {
00045                 $this->_aViewData["posslang"] = $aLang;
00046             }
00047 
00048             foreach ($oOtherLang as $id => $language) {
00049                 $oLang = new stdClass();
00050                 $oLang->sLangDesc = $language;
00051                 $oLang->selected = ($id == $this->_iEditLang);
00052                 $this->_aViewData["otherlang"][$id] = clone $oLang;
00053             }
00054         }
00055 
00056         if (oxRegistry::getConfig()->getRequestParameter("aoc")) {
00057             $oVendorMainAjax = oxNew('vendor_main_ajax');
00058             $this->_aViewData['oxajax'] = $oVendorMainAjax->getColumns();
00059 
00060             return "popups/vendor_main.tpl";
00061         }
00062 
00063         return "vendor_main.tpl";
00064     }
00065 
00071     public function save()
00072     {
00073         parent::save();
00074 
00075         $soxId = $this->getEditObjectId();
00076         $aParams = oxRegistry::getConfig()->getRequestParameter("editval");
00077 
00078         if (!isset($aParams['oxvendor__oxactive'])) {
00079             $aParams['oxvendor__oxactive'] = 0;
00080         }
00081 
00082         // shopid
00083         $aParams['oxvendor__oxshopid'] = oxRegistry::getSession()->getVariable("actshop");
00084 
00085         $oVendor = oxNew("oxvendor");
00086         if ($soxId != "-1") {
00087             $oVendor->loadInLang($this->_iEditLang, $soxId);
00088         } else {
00089             $aParams['oxvendor__oxid'] = null;
00090         }
00091 
00092 
00093         $oVendor->setLanguage(0);
00094         $oVendor->assign($aParams);
00095         $oVendor->setLanguage($this->_iEditLang);
00096         $oVendor = oxRegistry::get("oxUtilsFile")->processFiles($oVendor);
00097         $oVendor->save();
00098 
00099         // set oxid if inserted
00100         $this->setEditObjectId($oVendor->getId());
00101     }
00102 
00108     public function saveinnlang()
00109     {
00110         $soxId = $this->getEditObjectId();
00111         $aParams = oxRegistry::getConfig()->getRequestParameter("editval");
00112 
00113         if (!isset($aParams['oxvendor__oxactive'])) {
00114             $aParams['oxvendor__oxactive'] = 0;
00115         }
00116 
00117         // shopid
00118         $aParams['oxvendor__oxshopid'] = oxRegistry::getSession()->getVariable("actshop");
00119 
00120         $oVendor = oxNew("oxvendor");
00121 
00122         if ($soxId != "-1") {
00123             $oVendor->loadInLang($this->_iEditLang, $soxId);
00124         } else {
00125             $aParams['oxvendor__oxid'] = null;
00126         }
00127 
00128 
00129         $oVendor->setLanguage(0);
00130         $oVendor->assign($aParams);
00131         $oVendor->setLanguage($this->_iEditLang);
00132         $oVendor = oxRegistry::get("oxUtilsFile")->processFiles($oVendor);
00133         $oVendor->save();
00134 
00135         // set oxid if inserted
00136         $this->setEditObjectId($oVendor->getId());
00137     }
00138 }