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             $sChosenArtCat = $this->_getCategoryTree( "artcattree", oxConfig::getParameter( "artcat"));
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 ( oxLang::getInstance()->getLanguageNames(), $oOtherLang);
00042             if ( count( $aLang))
00043                 $this->_aViewData["posslang"] = $aLang;
00044 
00045             foreach ( $oOtherLang as $id => $language) {
00046                 $oLang= new oxStdClass();
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 
00055             $aColumns = array();
00056             include_once 'inc/'.strtolower(__CLASS__).'.inc.php';
00057             $this->_aViewData['oxajax'] = $aColumns;
00058 
00059             return "popups/manufacturer_main.tpl";
00060         }
00061         return "manufacturer_main.tpl";
00062     }
00063 
00069     public function save()
00070     {
00071 
00072         $soxId = $this->getEditObjectId();
00073         $aParams = oxConfig::getParameter( "editval");
00074 
00075         if ( !isset( $aParams['oxmanufacturers__oxactive']))
00076             $aParams['oxmanufacturers__oxactive'] = 0;
00077 
00078             // shopid
00079             $sShopID = oxSession::getVar( "actshop");
00080             $aParams['oxmanufacturers__oxshopid'] = $sShopID;
00081 
00082         $oManufacturer = oxNew( "oxmanufacturer" );
00083 
00084         if ( $soxId != "-1")
00085             $oManufacturer->loadInLang( $this->_iEditLang, $soxId );
00086         else {
00087             $aParams['oxmanufacturers__oxid'] = null;
00088         }
00089 
00090 
00091         //$aParams = $oManufacturer->ConvertNameArray2Idx( $aParams);
00092         $oManufacturer->setLanguage(0);
00093         $oManufacturer->assign( $aParams);
00094         $oManufacturer->setLanguage($this->_iEditLang);
00095         $oManufacturer = oxUtilsFile::getInstance()->processFiles( $oManufacturer );
00096         $oManufacturer->save();
00097 
00098         // set oxid if inserted
00099         $this->setEditObjectId( $oManufacturer->getId() );
00100     }
00101 
00107     public function saveinnlang()
00108     {
00109         $soxId = $this->getEditObjectId();
00110         $aParams    = oxConfig::getParameter( "editval");
00111 
00112         if ( !isset( $aParams['oxmanufacturers__oxactive']))
00113             $aParams['oxmanufacturers__oxactive'] = 0;
00114 
00115             // shopid
00116             $sShopID = oxSession::getVar( "actshop");
00117             $aParams['oxmanufacturers__oxshopid'] = $sShopID;
00118 
00119         $oManufacturer = oxNew( "oxmanufacturer" );
00120 
00121         if ( $soxId != "-1")
00122             $oManufacturer->loadInLang( $this->_iEditLang, $soxId );
00123         else {
00124             $aParams['oxmanufacturers__oxid'] = null;
00125         }
00126 
00127 
00128         //$aParams = $oManufacturer->ConvertNameArray2Idx( $aParams);
00129         $oManufacturer->setLanguage(0);
00130         $oManufacturer->assign( $aParams);
00131         $oManufacturer->setLanguage($this->_iEditLang);
00132         $oManufacturer = oxUtilsFile::getInstance()->processFiles( $oManufacturer );
00133         $oManufacturer->save();
00134 
00135         // set oxid if inserted
00136         $this->setEditObjectId( $oManufacturer->getId() );
00137     }
00138 }