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