manufacturer_main.php

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