OXID eShop CE  4.8.11
 All Classes Files Functions Variables Pages
news_main.php
Go to the documentation of this file.
1 <?php
2 
3 
4 
5 
6 
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 ( oxConfig::getParameter("aoc") ) {
57  $oNewsMainAjax = oxNew( 'news_main_ajax' );
58  $this->_aViewData['oxajax'] = $oNewsMainAjax->getColumns();
59 
60  return "popups/news_main.tpl";
61  }
62  return "news_main.tpl";
63  }
64 
70  public function save()
71  {
72  parent::save();
73 
74  $soxId = $this->getEditObjectId();
75  $aParams = oxConfig::getParameter( "editval");
76  // checkbox handling
77  if ( !isset( $aParams['oxnews__oxactive']))
78  $aParams['oxnews__oxactive'] = 0;
79 
80  // shopid
81  $sShopID = oxSession::getVar( "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  $oConvObject = new oxField();
88  $oConvObject->fldmax_length = 0;
89  $oConvObject->fldtype = "date";
90  $oConvObject->value = $aParams['oxnews__oxdate'];
91  $aParams['oxnews__oxdate'] = oxRegistry::get("oxUtilsDate")->convertDBDate( $oConvObject, true);
92 
93  $oNews = oxNew( "oxnews" );
94 
95  if ( $soxId != "-1")
96  $oNews->loadInLang( $this->_iEditLang, $soxId );
97  else
98  $aParams['oxnews__oxid'] = null;
99 
100 
101  //$aParams = $oNews->ConvertNameArray2Idx( $aParams);
102 
103  $oNews->setLanguage(0);
104  $oNews->assign( $aParams);
105  $oNews->setLanguage($this->_iEditLang);
106  $oNews->save();
107 
108  // set oxid if inserted
109  $this->setEditObjectId( $oNews->getId() );
110  }
111 
117  public function saveinnlang()
118  {
119  $soxId = $this->getEditObjectId();
120  $aParams = oxConfig::getParameter( "editval");
121  // checkbox handling
122  if ( !isset( $aParams['oxnews__oxactive']))
123  $aParams['oxnews__oxactive'] = 0;
124 
125  parent::save();
126 
127  // shopid
128  $sShopID = oxSession::getVar( "actshop");
129  $aParams['oxnews__oxshopid'] = $sShopID;
130  // creating fake object to save correct time value
131  if (!$aParams['oxnews__oxdate'])
132  $aParams['oxnews__oxdate'] = "";
133 
134  $oConvObject = new oxField();
135  $oConvObject->fldmax_length = 0;
136  $oConvObject->fldtype = "date";
137  $oConvObject->value = $aParams['oxnews__oxdate'];
138  $aParams['oxnews__oxdate'] = oxRegistry::get("oxUtilsDate")->convertDBDate( $oConvObject, true );
139 
140  $oNews = oxNew( "oxnews" );
141 
142  if ( $soxId != "-1")
143  $oNews->loadInLang( $this->_iEditLang, $soxId );
144  else
145  $aParams['oxnews__oxid'] = null;
146 
147 
148  //$aParams = $oNews->ConvertNameArray2Idx( $aParams);
149  $oNews->setLanguage(0);
150  $oNews->assign( $aParams);
151 
152  // apply new language
153  $oNews->setLanguage( oxConfig::getParameter( "new_lang" ) );
154  $oNews->save();
155 
156  // set oxid if inserted
157  $this->setEditObjectId( $oNews->getId() );
158  }
159 }