manufacturer_main.php

Go to the documentation of this file.
00001 <?php
00002 
00007 class Manufacturer_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             $oManufacturer = oxNew("oxmanufacturer");
00025             $oManufacturer->loadInLang($this->_iEditLang, $soxId);
00026 
00027             $oOtherLang = $oManufacturer->getAvailableInLangs();
00028             if (!isset($oOtherLang[$this->_iEditLang])) {
00029                 // echo "language entry doesn't exist! using: ".key($oOtherLang);
00030                 $oManufacturer->loadInLang(key($oOtherLang), $soxId);
00031             }
00032             $this->_aViewData["edit"] = $oManufacturer;
00033 
00034             // category tree
00035             $this->_createCategoryTree("artcattree");
00036 
00037             //Disable editing for derived articles
00038             if ($oManufacturer->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             $oManufacturerMainAjax = oxNew('manufacturer_main_ajax');
00058             $this->_aViewData['oxajax'] = $oManufacturerMainAjax->getColumns();
00059 
00060             return "popups/manufacturer_main.tpl";
00061         }
00062 
00063         return "manufacturer_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['oxmanufacturers__oxactive'])) {
00079             $aParams['oxmanufacturers__oxactive'] = 0;
00080         }
00081 
00082         // shopid
00083         $sShopID = oxRegistry::getSession()->getVariable("actshop");
00084         $aParams['oxmanufacturers__oxshopid'] = $sShopID;
00085 
00086         $oManufacturer = oxNew("oxmanufacturer");
00087 
00088         if ($soxId != "-1") {
00089             $oManufacturer->loadInLang($this->_iEditLang, $soxId);
00090         } else {
00091             $aParams['oxmanufacturers__oxid'] = null;
00092         }
00093 
00094 
00095         //$aParams = $oManufacturer->ConvertNameArray2Idx( $aParams);
00096         $oManufacturer->setLanguage(0);
00097         $oManufacturer->assign($aParams);
00098         $oManufacturer->setLanguage($this->_iEditLang);
00099         $oManufacturer = oxRegistry::get("oxUtilsFile")->processFiles($oManufacturer);
00100         $oManufacturer->save();
00101 
00102         // set oxid if inserted
00103         $this->setEditObjectId($oManufacturer->getId());
00104     }
00105 
00111     public function saveinnlang()
00112     {
00113         $soxId = $this->getEditObjectId();
00114         $aParams = oxRegistry::getConfig()->getRequestParameter("editval");
00115 
00116         if (!isset($aParams['oxmanufacturers__oxactive'])) {
00117             $aParams['oxmanufacturers__oxactive'] = 0;
00118         }
00119 
00120         // shopid
00121         $sShopID = oxRegistry::getSession()->getVariable("actshop");
00122         $aParams['oxmanufacturers__oxshopid'] = $sShopID;
00123 
00124         $oManufacturer = oxNew("oxmanufacturer");
00125 
00126         if ($soxId != "-1") {
00127             $oManufacturer->loadInLang($this->_iEditLang, $soxId);
00128         } else {
00129             $aParams['oxmanufacturers__oxid'] = null;
00130         }
00131 
00132 
00133         //$aParams = $oManufacturer->ConvertNameArray2Idx( $aParams);
00134         $oManufacturer->setLanguage(0);
00135         $oManufacturer->assign($aParams);
00136         $oManufacturer->setLanguage($this->_iEditLang);
00137         $oManufacturer = oxRegistry::get("oxUtilsFile")->processFiles($oManufacturer);
00138         $oManufacturer->save();
00139 
00140         // set oxid if inserted
00141         $this->setEditObjectId($oManufacturer->getId());
00142     }
00143 }