OXID eShop CE  4.8.12
 All Classes Files Functions Variables Pages
vendor_main.php
Go to the documentation of this file.
1 <?php
2 
8 {
16  public function render()
17  {
19 
20  $soxId = $this->_aViewData["oxid"] = $this->getEditObjectId();
21  if ( $soxId != "-1" && isset( $soxId)) {
22  // load object
23  $oVendor = oxNew( "oxvendor" );
24  $oVendor->loadInLang( $this->_iEditLang, $soxId );
25 
26  $oOtherLang = $oVendor->getAvailableInLangs();
27  if (!isset($oOtherLang[$this->_iEditLang])) {
28  // echo "language entry doesn't exist! using: ".key($oOtherLang);
29  $oVendor->loadInLang( key($oOtherLang), $soxId );
30  }
31  $this->_aViewData["edit"] = $oVendor;
32 
33  // category tree
34  $this->_createCategoryTree( "artcattree");
35 
36  //Disable editing for derived articles
37  if ($oVendor->isDerived())
38  $this->_aViewData['readonly'] = true;
39 
40  // remove already created languages
41  $aLang = array_diff ( oxRegistry::getLang()->getLanguageNames(), $oOtherLang);
42  if ( count( $aLang))
43  $this->_aViewData["posslang"] = $aLang;
44 
45  foreach ( $oOtherLang as $id => $language) {
46  $oLang= new stdClass();
47  $oLang->sLangDesc = $language;
48  $oLang->selected = ($id == $this->_iEditLang);
49  $this->_aViewData["otherlang"][$id] = clone $oLang;
50  }
51  }
52 
53  if ( oxConfig::getParameter( "aoc" ) ) {
54  $oVendorMainAjax = oxNew( 'vendor_main_ajax' );
55  $this->_aViewData['oxajax'] = $oVendorMainAjax->getColumns();
56 
57  return "popups/vendor_main.tpl";
58  }
59  return "vendor_main.tpl";
60  }
61 
67  public function save()
68  {
69  parent::save();
70 
71  $soxId = $this->getEditObjectId();
72  $aParams = oxConfig::getParameter( "editval" );
73 
74  if ( !isset( $aParams['oxvendor__oxactive'] ) ) {
75  $aParams['oxvendor__oxactive'] = 0;
76  }
77 
78  // shopid
79  $aParams['oxvendor__oxshopid'] = oxSession::getVar( "actshop");
80 
81  $oVendor = oxNew( "oxvendor" );
82  if ( $soxId != "-1" )
83  $oVendor->loadInLang( $this->_iEditLang, $soxId );
84  else {
85  $aParams['oxvendor__oxid'] = null;
86  }
87 
88 
89  $oVendor->setLanguage(0);
90  $oVendor->assign( $aParams );
91  $oVendor->setLanguage( $this->_iEditLang );
92  $oVendor = oxRegistry::get("oxUtilsFile")->processFiles( $oVendor );
93  $oVendor->save();
94 
95  // set oxid if inserted
96  $this->setEditObjectId( $oVendor->getId() );
97  }
98 
104  public function saveinnlang()
105  {
106  $soxId = $this->getEditObjectId();
107  $aParams = oxConfig::getParameter( "editval" );
108 
109  if ( !isset( $aParams['oxvendor__oxactive'] ) ) {
110  $aParams['oxvendor__oxactive'] = 0;
111  }
112 
113  // shopid
114  $aParams['oxvendor__oxshopid'] = oxSession::getVar( "actshop" );
115 
116  $oVendor = oxNew( "oxvendor" );
117 
118  if ( $soxId != "-1")
119  $oVendor->loadInLang( $this->_iEditLang, $soxId );
120  else {
121  $aParams['oxvendor__oxid'] = null;
122  }
123 
124 
125  $oVendor->setLanguage(0);
126  $oVendor->assign( $aParams );
127  $oVendor->setLanguage( $this->_iEditLang );
128  $oVendor = oxRegistry::get("oxUtilsFile")->processFiles( $oVendor );
129  $oVendor->save();
130 
131  // set oxid if inserted
132  $this->setEditObjectId( $oVendor->getId() );
133  }
134 }