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