OXID eShop CE  4.10.5
 All Classes Namespaces Files Functions Variables Pages
adminlinks_main.php
Go to the documentation of this file.
1 <?php
2 
9 {
10 
17  public function render()
18  {
19  $myConfig = $this->getConfig();
20 
22 
23  $soxId = $this->_aViewData["oxid"] = $this->getEditObjectId();
24  if ($soxId != "-1" && isset($soxId)) {
25  // load object
26  $oLinks = oxNew("oxlinks", getViewName('oxlinks'));
27  $oLinks->loadInLang($this->_iEditLang, $soxId);
28 
29  $oOtherLang = $oLinks->getAvailableInLangs();
30  if (!isset($oOtherLang[$this->_iEditLang])) {
31  // echo "language entry doesn't exist! using: ".key($oOtherLang);
32  $oLinks->loadInLang(key($oOtherLang), $soxId);
33  }
34  $this->_aViewData["edit"] = $oLinks;
35 
36  // remove already created languages
37  $this->_aViewData["posslang"] = array_diff(oxRegistry::getLang()->getLanguageNames(), $oOtherLang);
38 
39  foreach ($oOtherLang as $id => $language) {
40  $oLang = new stdClass();
41  $oLang->sLangDesc = $language;
42  $oLang->selected = ($id == $this->_iEditLang);
43  $this->_aViewData["otherlang"][$id] = clone $oLang;
44  }
45  }
46 
47  // generate editor
48  $this->_aViewData["editor"] = $this->_generateTextEditor(
49  "100%",
50  255,
51  $oLinks,
52  "oxlinks__oxurldesc",
53  "links.tpl.css"
54  );
55 
56  return "adminlinks_main.tpl";
57  }
58 
64  public function save()
65  {
66  $soxId = $this->getEditObjectId();
67  $aParams = oxRegistry::getConfig()->getRequestParameter("editval");
68  // checkbox handling
69  if (!isset($aParams['oxlinks__oxactive'])) {
70  $aParams['oxlinks__oxactive'] = 0;
71  }
72 
73  // adds space to the end of URL description to keep new added links visible
74  // if URL description left empty
75  if (isset($aParams['oxlinks__oxurldesc']) && strlen($aParams['oxlinks__oxurldesc']) == 0) {
76  $aParams['oxlinks__oxurldesc'] .= " ";
77  }
78 
79  if (!$aParams['oxlinks__oxinsert']) {
80  // sets default (?) date format to output
81  // else if possible - changes date format to system compatible
82  $sDate = date(oxRegistry::getLang()->translateString("simpleDateFormat"));
83  if ($sDate == "simpleDateFormat") {
84  $aParams['oxlinks__oxinsert'] = date("Y-m-d");
85  } else {
86  $aParams['oxlinks__oxinsert'] = $sDate;
87  }
88  }
89 
90  $iEditLanguage = oxRegistry::getConfig()->getRequestParameter("editlanguage");
91  $oLinks = oxNew("oxlinks", getViewName('oxlinks'));
92 
93  if ($soxId != "-1") {
94  //$oLinks->load( $soxId );
95  $oLinks->loadInLang($iEditLanguage, $soxId);
96 
97  } else {
98  $aParams['oxlinks__oxid'] = null;
99  }
100 
101  //$aParams = $oLinks->ConvertNameArray2Idx( $aParams);
102 
103  $oLinks->setLanguage(0);
104  $oLinks->assign($aParams);
105  $oLinks->setLanguage($iEditLanguage);
106  $oLinks->save();
107 
108  parent::save();
109 
110  // set oxid if inserted
111  $this->setEditObjectId($oLinks->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['oxlinks__oxactive'])) {
125  $aParams['oxlinks__oxactive'] = 0;
126  }
127 
128  // shopid
129  $sShopID = oxRegistry::getSession()->getVariable("actshop");
130  $aParams['oxlinks__oxshopid'] = $sShopID;
131  $oLinks = oxNew("oxlinks", getViewName('oxlinks'));
132  $iEditLanguage = oxRegistry::getConfig()->getRequestParameter("editlanguage");
133 
134  if ($soxId != "-1") {
135  $oLinks->loadInLang($iEditLanguage, $soxId);
136  } else {
137  $aParams['oxlinks__oxid'] = null;
138  //$aParams = $oLinks->ConvertNameArray2Idx( $aParams);
139  }
140 
141 
142 
143  $oLinks->setLanguage(0);
144  $oLinks->assign($aParams);
145 
146  // apply new language
147  $oLinks->setLanguage(oxRegistry::getConfig()->getRequestParameter("new_lang"));
148  $oLinks->save();
149 
150  // set oxid if inserted
151  $this->setEditObjectId($oLinks->getId());
152  }
153 
165  /*protected function _getTextEditor( $iWidth, $iHeight, $oObject, $sField, $sStylesheet = null )
166  {
167  if ( $oEditor = parent::_getTextEditor( $iWidth, $iHeight, $oObject, $sField, $sStylesheet ) ) {
168  // setting empty value
169  $oEditor->emptyValue = ( $oEditor->lineReturns == 'P' ) ? "<p>&nbsp;</p>" : "<div>&nbsp;</div>";
170  }
171  return $oEditor;
172  }*/
173 }