OXID eShop CE  4.8.12
 All Classes Files Functions Variables Pages
adminlinks_main.php
Go to the documentation of this file.
1 <?php
2 
9 {
16  public function render()
17  {
18  $myConfig = $this->getConfig();
19 
21 
22  $soxId = $this->_aViewData["oxid"] = $this->getEditObjectId();
23  if ( $soxId != "-1" && isset( $soxId)) {
24  // load object
25  $oLinks = oxNew( "oxlinks", getViewName( 'oxlinks'));
26  $oLinks->loadInLang( $this->_iEditLang, $soxId );
27 
28  $oOtherLang = $oLinks->getAvailableInLangs();
29  if (!isset($oOtherLang[$this->_iEditLang])) {
30  // echo "language entry doesn't exist! using: ".key($oOtherLang);
31  $oLinks->loadInLang( key($oOtherLang), $soxId );
32  }
33  $this->_aViewData["edit"] = $oLinks;
34 
35  // remove already created languages
36  $this->_aViewData["posslang"] = array_diff (oxRegistry::getLang()->getLanguageNames(), $oOtherLang);
37 
38  foreach ( $oOtherLang as $id => $language) {
39  $oLang= new stdClass();
40  $oLang->sLangDesc = $language;
41  $oLang->selected = ($id == $this->_iEditLang);
42  $this->_aViewData["otherlang"][$id] = clone $oLang;
43  }
44  }
45 
46  // generate editor
47  $this->_aViewData["editor"] = $this->_generateTextEditor( "100%", 255, $oLinks, "oxlinks__oxurldesc", "links.tpl.css");
48 
49  return "adminlinks_main.tpl";
50  }
51 
57  public function save()
58  {
59  $soxId = $this->getEditObjectId();
60  $aParams = oxConfig::getParameter( "editval");
61  // checkbox handling
62  if ( !isset( $aParams['oxlinks__oxactive']))
63  $aParams['oxlinks__oxactive'] = 0;
64 
65  // adds space to the end of URL description to keep new added links visible
66  // if URL description left empty
67  if (isset($aParams['oxlinks__oxurldesc']) && strlen($aParams['oxlinks__oxurldesc']) == 0)
68  $aParams['oxlinks__oxurldesc'] .= " ";
69 
70  if ( !$aParams['oxlinks__oxinsert']) {
71  // sets default (?) date format to output
72  // else if possible - changes date format to system compatible
73  $sDate = date(oxRegistry::getLang()->translateString( "simpleDateFormat"));
74  if ($sDate == "simpleDateFormat")
75  $aParams['oxlinks__oxinsert'] = date( "Y-m-d");
76  else
77  $aParams['oxlinks__oxinsert'] = $sDate;
78  }
79 
80  $iEditLanguage = oxConfig::getParameter("editlanguage");
81  $oLinks = oxNew( "oxlinks", getViewName( 'oxlinks'));
82 
83  if ( $soxId != "-1") {
84  //$oLinks->load( $soxId );
85  $oLinks->loadInLang( $iEditLanguage, $soxId );
86 
87  } else {
88  $aParams['oxlinks__oxid'] = null;
89  }
90 
91  //$aParams = $oLinks->ConvertNameArray2Idx( $aParams);
92 
93  $oLinks->setLanguage(0);
94  $oLinks->assign( $aParams);
95  $oLinks->setLanguage( $iEditLanguage );
96  $oLinks->save();
97 
98  parent::save();
99 
100  // set oxid if inserted
101  $this->setEditObjectId( $oLinks->getId() );
102  }
103 
109  public function saveinnlang()
110  {
111  $soxId = $this->getEditObjectId();
112  $aParams = oxConfig::getParameter( "editval");
113  // checkbox handling
114  if ( !isset( $aParams['oxlinks__oxactive']))
115  $aParams['oxlinks__oxactive'] = 0;
116 
117  // shopid
118  $sShopID = oxSession::getVar( "actshop");
119  $aParams['oxlinks__oxshopid'] = $sShopID;
120  $oLinks = oxNew( "oxlinks", getViewName( 'oxlinks'));
121  $iEditLanguage = oxConfig::getParameter("editlanguage");
122 
123  if( $soxId != "-1")
124  $oLinks->loadInLang( $iEditLanguage, $soxId );
125  else
126  $aParams['oxlinks__oxid'] = null;
127  //$aParams = $oLinks->ConvertNameArray2Idx( $aParams);
128 
129 
130 
131  $oLinks->setLanguage(0);
132  $oLinks->assign( $aParams);
133 
134  // apply new language
135  $oLinks->setLanguage( oxConfig::getParameter( "new_lang" ) );
136  $oLinks->save();
137 
138  // set oxid if inserted
139  $this->setEditObjectId( $oLinks->getId() );
140  }
141 
153  /*protected function _getTextEditor( $iWidth, $iHeight, $oObject, $sField, $sStylesheet = null )
154  {
155  if ( $oEditor = parent::_getTextEditor( $iWidth, $iHeight, $oObject, $sField, $sStylesheet ) ) {
156  // setting empty value
157  $oEditor->emptyValue = ( $oEditor->lineReturns == 'P' ) ? "<p>&nbsp;</p>" : "<div>&nbsp;</div>";
158  }
159  return $oEditor;
160  }*/
161 }