OXID eShop CE  4.9.6
 All Classes Files Functions Variables Pages
news_main.php
Go to the documentation of this file.
1 <?php
2 
3 
9 class News_Main extends oxAdminDetails
10 {
11 
19  public function render()
20  {
21  $myConfig = $this->getConfig();
22 
24 
25  // all usergroups
26  $oGroups = oxNew("oxlist");
27  $oGroups->init("oxgroups");
28  $oGroups->selectString("select * from " . getViewName("oxgroups", $this->_iEditLang));
29 
30  $soxId = $this->_aViewData["oxid"] = $this->getEditObjectId();
31  if ($soxId != "-1" && isset($soxId)) {
32  // load object
33  $oNews = oxNew("oxnews");
34  $oNews->loadInLang($this->_iEditLang, $soxId);
35 
36  $oOtherLang = $oNews->getAvailableInLangs();
37  if (!isset($oOtherLang[$this->_iEditLang])) {
38  // echo "language entry doesn't exist! using: ".key($oOtherLang);
39  $oNews->loadInLang(key($oOtherLang), $soxId);
40  }
41  $this->_aViewData["edit"] = $oNews;
42 
43 
44  // remove already created languages
45  $this->_aViewData["posslang"] = array_diff(oxRegistry::getLang()->getLanguageNames(), $oOtherLang);
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  if (oxRegistry::getConfig()->getRequestParameter("aoc")) {
55  $oNewsMainAjax = oxNew('news_main_ajax');
56  $this->_aViewData['oxajax'] = $oNewsMainAjax->getColumns();
57 
58  return "popups/news_main.tpl";
59  }
60 
61  return "news_main.tpl";
62  }
63 
69  public function save()
70  {
71  parent::save();
72 
73  $soxId = $this->getEditObjectId();
74  $aParams = oxRegistry::getConfig()->getRequestParameter("editval");
75  // checkbox handling
76  if (!isset($aParams['oxnews__oxactive'])) {
77  $aParams['oxnews__oxactive'] = 0;
78  }
79 
80  // shopid
81  $sShopID = oxRegistry::getSession()->getVariable("actshop");
82  $aParams['oxnews__oxshopid'] = $sShopID;
83  // creating fake object to save correct time value
84  if (!$aParams['oxnews__oxdate']) {
85  $aParams['oxnews__oxdate'] = "";
86  }
87 
88  $oConvObject = new oxField();
89  $oConvObject->fldmax_length = 0;
90  $oConvObject->fldtype = "date";
91  $oConvObject->value = $aParams['oxnews__oxdate'];
92  $aParams['oxnews__oxdate'] = oxRegistry::get("oxUtilsDate")->convertDBDate($oConvObject, true);
93 
94  $oNews = oxNew("oxnews");
95 
96  if ($soxId != "-1") {
97  $oNews->loadInLang($this->_iEditLang, $soxId);
98  } else {
99  $aParams['oxnews__oxid'] = null;
100  }
101 
102 
103  //$aParams = $oNews->ConvertNameArray2Idx( $aParams);
104 
105  $oNews->setLanguage(0);
106  $oNews->assign($aParams);
107  $oNews->setLanguage($this->_iEditLang);
108  $oNews->save();
109 
110  // set oxid if inserted
111  $this->setEditObjectId($oNews->getId());
112  }
113 
119  public function saveinnlang()
120  {
121  $soxId = $this->getEditObjectId();
122  $aParams = oxRegistry::getConfig()->getRequestParameter("editval");
123  // checkbox handling
124  if (!isset($aParams['oxnews__oxactive'])) {
125  $aParams['oxnews__oxactive'] = 0;
126  }
127 
128  parent::save();
129 
130  // shopid
131  $sShopID = oxRegistry::getSession()->getVariable("actshop");
132  $aParams['oxnews__oxshopid'] = $sShopID;
133  // creating fake object to save correct time value
134  if (!$aParams['oxnews__oxdate']) {
135  $aParams['oxnews__oxdate'] = "";
136  }
137 
138  $oConvObject = new oxField();
139  $oConvObject->fldmax_length = 0;
140  $oConvObject->fldtype = "date";
141  $oConvObject->value = $aParams['oxnews__oxdate'];
142  $aParams['oxnews__oxdate'] = oxRegistry::get("oxUtilsDate")->convertDBDate($oConvObject, true);
143 
144  $oNews = oxNew("oxnews");
145 
146  if ($soxId != "-1") {
147  $oNews->loadInLang($this->_iEditLang, $soxId);
148  } else {
149  $aParams['oxnews__oxid'] = null;
150  }
151 
152 
153  //$aParams = $oNews->ConvertNameArray2Idx( $aParams);
154  $oNews->setLanguage(0);
155  $oNews->assign($aParams);
156 
157  // apply new language
158  $oNews->setLanguage(oxRegistry::getConfig()->getRequestParameter("new_lang"));
159  $oNews->save();
160 
161  // set oxid if inserted
162  $this->setEditObjectId($oNews->getId());
163  }
164 }