OXID eShop CE  4.10.2
 All Classes Namespaces Files Functions Variables Pages
wrapping_main.php
Go to the documentation of this file.
1 <?php
2 
9 {
10 
18  public function render()
19  {
21 
22  $soxId = $this->_aViewData["oxid"] = $this->getEditObjectId();
23  if ($soxId != "-1" && isset($soxId)) {
24  // load object
25  $oWrapping = oxNew("oxwrapping");
26  $oWrapping->loadInLang($this->_iEditLang, $soxId);
27 
28  $oOtherLang = $oWrapping->getAvailableInLangs();
29  if (!isset($oOtherLang[$this->_iEditLang])) {
30  // echo "language entry doesn't exist! using: ".key($oOtherLang);
31  $oWrapping->loadInLang(key($oOtherLang), $soxId);
32  }
33  $this->_aViewData["edit"] = $oWrapping;
34 
35 
36  // remove already created languages
37  $aLang = array_diff(oxRegistry::getLang()->getLanguageNames(), $oOtherLang);
38  if (count($aLang)) {
39  $this->_aViewData["posslang"] = $aLang;
40  }
41 
42  foreach ($oOtherLang as $id => $language) {
43  $oLang = new stdClass();
44  $oLang->sLangDesc = $language;
45  $oLang->selected = ($id == $this->_iEditLang);
46  $this->_aViewData["otherlang"][$id] = clone $oLang;
47  }
48  }
49 
50  return "wrapping_main.tpl";
51  }
52 
58  public function save()
59  {
60  parent::save();
61 
62  $soxId = $this->getEditObjectId();
63  $aParams = oxRegistry::getConfig()->getRequestParameter("editval");
64 
65  // checkbox handling
66  if (!isset($aParams['oxwrapping__oxactive'])) {
67  $aParams['oxwrapping__oxactive'] = 0;
68  }
69 
70  // shopid
71  $aParams['oxwrapping__oxshopid'] = oxRegistry::getSession()->getVariable("actshop");
72 
73  $oWrapping = oxNew("oxwrapping");
74 
75  if ($soxId != "-1") {
76  $oWrapping->loadInLang($this->_iEditLang, $soxId);
77  // #1173M - not all pic are deleted, after article is removed
78  oxRegistry::get("oxUtilsPic")->overwritePic($oWrapping, 'oxwrapping', 'oxpic', 'WP', '0', $aParams, $this->getConfig()->getPictureDir(false));
79  } else {
80  $aParams['oxwrapping__oxid'] = null;
81  //$aParams = $oWrapping->ConvertNameArray2Idx( $aParams);
82  }
83 
84 
85  $oWrapping->setLanguage(0);
86  $oWrapping->assign($aParams);
87  $oWrapping->setLanguage($this->_iEditLang);
88 
89  $oWrapping = oxRegistry::get("oxUtilsFile")->processFiles($oWrapping);
90  $oWrapping->save();
91 
92  // set oxid if inserted
93  $this->setEditObjectId($oWrapping->getId());
94  }
95 
101  public function saveinnlang()
102  {
103  $soxId = $this->getEditObjectId();
104  $aParams = oxRegistry::getConfig()->getRequestParameter("editval");
105 
106  // checkbox handling
107  if (!isset($aParams['oxwrapping__oxactive'])) {
108  $aParams['oxwrapping__oxactive'] = 0;
109  }
110 
111  // shopid
112  $aParams['oxwrapping__oxshopid'] = oxRegistry::getSession()->getVariable("actshop");
113 
114  $oWrapping = oxNew("oxwrapping");
115 
116  if ($soxId != "-1") {
117  $oWrapping->load($soxId);
118  } else {
119  $aParams['oxwrapping__oxid'] = null;
120  //$aParams = $oWrapping->ConvertNameArray2Idx( $aParams);
121  }
122 
123 
124  $oWrapping->setLanguage(0);
125  $oWrapping->assign($aParams);
126  $oWrapping->setLanguage($this->_iEditLang);
127 
128  $oWrapping = oxRegistry::get("oxUtilsFile")->processFiles($oWrapping);
129  $oWrapping->save();
130 
131  // set oxid if inserted
132  $this->setEditObjectId($oWrapping->getId());
133  }
134 }