OXID eShop CE  4.9.5
 All Classes Files Functions Variables Pages
manufacturer_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  $oManufacturer = oxNew("oxmanufacturer");
25  $oManufacturer->loadInLang($this->_iEditLang, $soxId);
26 
27  $oOtherLang = $oManufacturer->getAvailableInLangs();
28  if (!isset($oOtherLang[$this->_iEditLang])) {
29  // echo "language entry doesn't exist! using: ".key($oOtherLang);
30  $oManufacturer->loadInLang(key($oOtherLang), $soxId);
31  }
32  $this->_aViewData["edit"] = $oManufacturer;
33 
34  // category tree
35  $this->_createCategoryTree("artcattree");
36 
37  //Disable editing for derived articles
38  if ($oManufacturer->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  $oManufacturerMainAjax = oxNew('manufacturer_main_ajax');
58  $this->_aViewData['oxajax'] = $oManufacturerMainAjax->getColumns();
59 
60  return "popups/manufacturer_main.tpl";
61  }
62 
63  return "manufacturer_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['oxmanufacturers__oxactive'])) {
79  $aParams['oxmanufacturers__oxactive'] = 0;
80  }
81 
82  // shopid
83  $sShopID = oxRegistry::getSession()->getVariable("actshop");
84  $aParams['oxmanufacturers__oxshopid'] = $sShopID;
85 
86  $oManufacturer = oxNew("oxmanufacturer");
87 
88  if ($soxId != "-1") {
89  $oManufacturer->loadInLang($this->_iEditLang, $soxId);
90  } else {
91  $aParams['oxmanufacturers__oxid'] = null;
92  }
93 
94 
95  //$aParams = $oManufacturer->ConvertNameArray2Idx( $aParams);
96  $oManufacturer->setLanguage(0);
97  $oManufacturer->assign($aParams);
98  $oManufacturer->setLanguage($this->_iEditLang);
99  $oManufacturer = oxRegistry::get("oxUtilsFile")->processFiles($oManufacturer);
100  $oManufacturer->save();
101 
102  // set oxid if inserted
103  $this->setEditObjectId($oManufacturer->getId());
104  }
105 
111  public function saveinnlang()
112  {
113  $soxId = $this->getEditObjectId();
114  $aParams = oxRegistry::getConfig()->getRequestParameter("editval");
115 
116  if (!isset($aParams['oxmanufacturers__oxactive'])) {
117  $aParams['oxmanufacturers__oxactive'] = 0;
118  }
119 
120  // shopid
121  $sShopID = oxRegistry::getSession()->getVariable("actshop");
122  $aParams['oxmanufacturers__oxshopid'] = $sShopID;
123 
124  $oManufacturer = oxNew("oxmanufacturer");
125 
126  if ($soxId != "-1") {
127  $oManufacturer->loadInLang($this->_iEditLang, $soxId);
128  } else {
129  $aParams['oxmanufacturers__oxid'] = null;
130  }
131 
132 
133  //$aParams = $oManufacturer->ConvertNameArray2Idx( $aParams);
134  $oManufacturer->setLanguage(0);
135  $oManufacturer->assign($aParams);
136  $oManufacturer->setLanguage($this->_iEditLang);
137  $oManufacturer = oxRegistry::get("oxUtilsFile")->processFiles($oManufacturer);
138  $oManufacturer->save();
139 
140  // set oxid if inserted
141  $this->setEditObjectId($oManufacturer->getId());
142  }
143 }