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 = $this->_aViewData["oxid"] = $this->getEditObjectId();
00021         if ( $soxId != "-1" && isset( $soxId)) {
00022             // load object
00023             $oVendor = oxNew( "oxvendor" );
00024             $oVendor->loadInLang( $this->_iEditLang, $soxId );
00025 
00026             $oOtherLang = $oVendor->getAvailableInLangs();
00027             if (!isset($oOtherLang[$this->_iEditLang])) {
00028                 // echo "language entry doesn't exist! using: ".key($oOtherLang);
00029                 $oVendor->loadInLang( key($oOtherLang), $soxId );
00030             }
00031             $this->_aViewData["edit"] =  $oVendor;
00032 
00033             // category tree
00034             $this->_createCategoryTree( "artcattree");
00035 
00036             //Disable editing for derived articles
00037             if ($oVendor->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             $oVendorMainAjax = oxNew( 'vendor_main_ajax' );
00055             $this->_aViewData['oxajax'] = $oVendorMainAjax->getColumns();
00056 
00057             return "popups/vendor_main.tpl";
00058         }
00059         return "vendor_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['oxvendor__oxactive'] ) ) {
00075             $aParams['oxvendor__oxactive'] = 0;
00076         }
00077 
00078             // shopid
00079             $aParams['oxvendor__oxshopid'] = oxSession::getVar( "actshop");
00080 
00081         $oVendor = oxNew( "oxvendor" );
00082         if ( $soxId != "-1" )
00083             $oVendor->loadInLang( $this->_iEditLang, $soxId );
00084         else {
00085             $aParams['oxvendor__oxid'] = null;
00086         }
00087 
00088 
00089         $oVendor->setLanguage(0);
00090         $oVendor->assign( $aParams );
00091         $oVendor->setLanguage( $this->_iEditLang );
00092         $oVendor = oxRegistry::get("oxUtilsFile")->processFiles( $oVendor );
00093         $oVendor->save();
00094 
00095         // set oxid if inserted
00096         $this->setEditObjectId( $oVendor->getId() );
00097     }
00098 
00104     public function saveinnlang()
00105     {
00106         $soxId = $this->getEditObjectId();
00107         $aParams = oxConfig::getParameter( "editval" );
00108 
00109         if ( !isset( $aParams['oxvendor__oxactive'] ) ) {
00110             $aParams['oxvendor__oxactive'] = 0;
00111         }
00112 
00113             // shopid
00114             $aParams['oxvendor__oxshopid'] = oxSession::getVar( "actshop" );
00115 
00116         $oVendor = oxNew( "oxvendor" );
00117 
00118         if ( $soxId != "-1")
00119             $oVendor->loadInLang( $this->_iEditLang, $soxId );
00120         else {
00121             $aParams['oxvendor__oxid'] = null;
00122         }
00123 
00124 
00125         $oVendor->setLanguage(0);
00126         $oVendor->assign( $aParams );
00127         $oVendor->setLanguage( $this->_iEditLang );
00128         $oVendor = oxRegistry::get("oxUtilsFile")->processFiles( $oVendor );
00129         $oVendor->save();
00130 
00131         // set oxid if inserted
00132         $this->setEditObjectId( $oVendor->getId() );
00133     }
00134 }