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