OXID eShop CE  4.10.6
 All Classes Namespaces Files Functions Variables Pages
actions_main.php
Go to the documentation of this file.
1 <?php
2 
10 {
11 
18  public function render()
19  {
21 
22  // check if we right now saved a new entry
23  $soxId = $this->_aViewData["oxid"] = $this->getEditObjectId();
24  if ($soxId != "-1" && isset($soxId)) {
25  // load object
26  $oAction = oxNew("oxactions");
27  $oAction->loadInLang($this->_iEditLang, $soxId);
28 
29  $oOtherLang = $oAction->getAvailableInLangs();
30  if (!isset($oOtherLang[$this->_iEditLang])) {
31  // echo "language entry doesn't exist! using: ".key($oOtherLang);
32  $oAction->loadInLang(key($oOtherLang), $soxId);
33  }
34 
35  $this->_aViewData["edit"] = $oAction;
36 
37  // remove already created languages
38  $aLang = array_diff(oxRegistry::getLang()->getLanguageNames(), $oOtherLang);
39 
40  if (count($aLang)) {
41  $this->_aViewData["posslang"] = $aLang;
42  }
43 
44  foreach ($oOtherLang as $id => $language) {
45  $oLang = new stdClass();
46  $oLang->sLangDesc = $language;
47  $oLang->selected = ($id == $this->_iEditLang);
48  $this->_aViewData["otherlang"][$id] = clone $oLang;
49  }
50  }
51 
52  if (oxRegistry::getConfig()->getRequestParameter("aoc")) {
53  // generating category tree for select list
54  $this->_createCategoryTree("artcattree", $soxId);
55 
56  $oActionsMainAjax = oxNew('actions_main_ajax');
57  $this->_aViewData['oxajax'] = $oActionsMainAjax->getColumns();
58 
59  return "popups/actions_main.tpl";
60  }
61 
62 
63  if (($oPromotion = $this->getViewDataElement("edit"))) {
64  if (($oPromotion->oxactions__oxtype->value == 2) || ($oPromotion->oxactions__oxtype->value == 3)) {
65  if ($iAoc = oxRegistry::getConfig()->getRequestParameter("oxpromotionaoc")) {
66  $sPopup = false;
67  switch ($iAoc) {
68  case 'article':
69  // generating category tree for select list
70  $this->_createCategoryTree("artcattree", $soxId);
71 
72  if ($oArticle = $oPromotion->getBannerArticle()) {
73  $this->_aViewData['actionarticle_artnum'] = $oArticle->oxarticles__oxartnum->value;
74  $this->_aViewData['actionarticle_title'] = $oArticle->oxarticles__oxtitle->value;
75  }
76 
77  $sPopup = 'actions_article';
78  break;
79  case 'groups':
80  $sPopup = 'actions_groups';
81  break;
82  }
83 
84  if ($sPopup) {
85  $aColumns = array();
86  $oActionsArticleAjax = oxNew($sPopup . '_ajax');
87  $this->_aViewData['oxajax'] = $oActionsArticleAjax->getColumns();
88 
89  return "popups/{$sPopup}.tpl";
90  }
91  } else {
92  if ($oPromotion->oxactions__oxtype->value == 2) {
93  $this->_aViewData["editor"] = $this->_generateTextEditor(
94  "100%",
95  300,
96  $oPromotion,
97  "oxactions__oxlongdesc",
98  "details.tpl.css"
99  );
100  }
101  }
102  }
103  }
104 
105  return "actions_main.tpl";
106  }
107 
108 
114  public function save()
115  {
116  $myConfig = $this->getConfig();
117 
118 
119  parent::save();
120 
121  $soxId = $this->getEditObjectId();
122  $aParams = oxRegistry::getConfig()->getRequestParameter("editval");
123 
124  $oPromotion = oxNew("oxactions");
125  if ($soxId != "-1") {
126  $oPromotion->load($soxId);
127  } else {
128  $aParams['oxactions__oxid'] = null;
129  }
130 
131  if (!$aParams['oxactions__oxactive']) {
132  $aParams['oxactions__oxactive'] = 0;
133  }
134 
135  $oPromotion->setLanguage(0);
136  $oPromotion->assign($aParams);
137  $oPromotion->setLanguage($this->_iEditLang);
138  $oPromotion = oxRegistry::get("oxUtilsFile")->processFiles($oPromotion);
139  $oPromotion->save();
140 
141  // set oxid if inserted
142  $this->setEditObjectId($oPromotion->getId());
143  }
144 
148  public function saveinnlang()
149  {
150  $this->save();
151  }
152 }