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             $sChosenArtCat = $this->_getCategoryTree( "artcattree", oxConfig::getParameter( "artcat"));
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 ( 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/vendor_main.tpl";
00060         }
00061         return "vendor_main.tpl";
00062     }
00063 
00069     public function save()
00070     {
00071         parent::save();
00072 
00073         $soxId = $this->getEditObjectId();
00074         $aParams = oxConfig::getParameter( "editval" );
00075 
00076         if ( !isset( $aParams['oxvendor__oxactive'] ) ) {
00077             $aParams['oxvendor__oxactive'] = 0;
00078         }
00079 
00080             // shopid
00081             $aParams['oxvendor__oxshopid'] = oxSession::getVar( "actshop");
00082 
00083         $oVendor = oxNew( "oxvendor" );
00084         if ( $soxId != "-1" )
00085             $oVendor->loadInLang( $this->_iEditLang, $soxId );
00086         else {
00087             $aParams['oxvendor__oxid'] = null;
00088         }
00089 
00090 
00091         $oVendor->setLanguage(0);
00092         $oVendor->assign( $aParams );
00093         $oVendor->setLanguage( $this->_iEditLang );
00094         $oVendor = oxUtilsFile::getInstance()->processFiles( $oVendor );
00095         $oVendor->save();
00096 
00097         // set oxid if inserted
00098         $this->setEditObjectId( $oVendor->getId() );
00099     }
00100 
00106     public function saveinnlang()
00107     {
00108         $soxId = $this->getEditObjectId();
00109         $aParams = oxConfig::getParameter( "editval" );
00110 
00111         if ( !isset( $aParams['oxvendor__oxactive'] ) ) {
00112             $aParams['oxvendor__oxactive'] = 0;
00113         }
00114 
00115             // shopid
00116             $aParams['oxvendor__oxshopid'] = oxSession::getVar( "actshop" );
00117 
00118         $oVendor = oxNew( "oxvendor" );
00119 
00120         if ( $soxId != "-1")
00121             $oVendor->loadInLang( $this->_iEditLang, $soxId );
00122         else {
00123             $aParams['oxvendor__oxid'] = null;
00124         }
00125 
00126 
00127         $oVendor->setLanguage(0);
00128         $oVendor->assign( $aParams );
00129         $oVendor->setLanguage( $this->_iEditLang );
00130         $oVendor = oxUtilsFile::getInstance()->processFiles( $oVendor );
00131         $oVendor->save();
00132 
00133         // set oxid if inserted
00134         $this->setEditObjectId( $oVendor->getId() );
00135     }
00136 }