OXID eShop CE  4.10.2
 All Classes Namespaces Files Functions Variables Pages
object_seo.php
Go to the documentation of this file.
1 <?php
2 
7 {
8 
16  public function render()
17  {
19 
20  if ($sType = $this->_getType()) {
21  $oObject = oxNew($sType);
22  if ($oObject->load($this->getEditObjectId())) {
23  $oOtherLang = $oObject->getAvailableInLangs();
24  if (!isset($oOtherLang[$iLang])) {
25  $oObject->loadInLang(key($oOtherLang), $this->getEditObjectId());
26  }
27  $this->_aViewData['edit'] = $oObject;
28  }
29 
30  }
31 
32  $iLang = $this->getEditLang();
33  $aLangs = oxRegistry::getLang()->getLanguageNames();
34  foreach ($aLangs as $sLangId => $sLanguage) {
35  $oLang = new stdClass();
36  $oLang->sLangDesc = $sLanguage;
37  $oLang->selected = ($sLangId == $iLang);
38  $this->_aViewData['otherlang'][$sLangId] = clone $oLang;
39  }
40 
41  return 'object_seo.tpl';
42  }
43 
47  public function save()
48  {
49  // saving/updating seo params
50  if (($sOxid = $this->_getSaveObjectId())) {
51  $aSeoData = oxRegistry::getConfig()->getRequestParameter('aSeoData');
52  $iShopId = $this->getConfig()->getShopId();
53  $iLang = $this->getEditLang();
54 
55  // checkbox handling
56  if (!isset($aSeoData['oxfixed'])) {
57  $aSeoData['oxfixed'] = 0;
58  }
59 
60  $sParams = $this->_getAdditionalParams($aSeoData);
61 
62  $oEncoder = $this->_getEncoder();
63  // marking self and page links as expired
64  $oEncoder->markAsExpired($sOxid, $iShopId, 1, $iLang, $sParams);
65 
66  // saving
67  $oEncoder->addSeoEntry(
68  $sOxid, $iShopId, $iLang, $this->_getStdUrl($sOxid),
69  $aSeoData['oxseourl'], $this->_getSeoEntryType(), $aSeoData['oxfixed'],
70  trim($aSeoData['oxkeywords']), trim($aSeoData['oxdescription']), $this->processParam($aSeoData['oxparams']), true, $this->_getAltSeoEntryId()
71  );
72  }
73  }
74 
82  protected function _getAdditionalParams($aSeoData)
83  {
84  $sParams = null;
85  if (isset($aSeoData['oxparams'])) {
86  if (preg_match('/([a-z]*#)?(?<objectseo>[a-z0-9]+)(#[0-9])?/i', $aSeoData['oxparams'], $aMatches)) {
87  $sQuotedObjectSeoId = oxDb::getDb()->quote($aMatches['objectseo']);
88  $sParams = "oxparams = {$sQuotedObjectSeoId}";
89  }
90  }
91  return $sParams;
92  }
93 
99  protected function _getSaveObjectId()
100  {
101  return $this->getEditObjectId();
102  }
103 
111  public function getEntryMetaData($sMetaType)
112  {
113  return $this->_getEncoder()->getMetaData($this->getEditObjectId(), $sMetaType, $this->getConfig()->getShopId(), $this->getEditLang());
114  }
115 
121  public function isEntryFixed()
122  {
123  $iLang = (int) $this->getEditLang();
124  $iShopId = $this->getConfig()->getShopId();
125 
126  $sQ = "select oxfixed from oxseo where
127  oxseo.oxobjectid = " . oxDb::getDb()->quote($this->getEditObjectId()) . " and
128  oxseo.oxshopid = '{$iShopId}' and oxseo.oxlang = {$iLang} and oxparams = '' ";
129 
130  return (bool) oxDb::getDb()->getOne($sQ, false, false);
131  }
132 
136  protected function _getType()
137  {
138  }
139 
147  protected function _getStdUrl($sOxid)
148  {
149  if ($sType = $this->_getType()) {
150  $oObject = oxNew($sType);
151  if ($oObject->load($sOxid)) {
152  return $oObject->getBaseStdLink($this->getEditLang(), true, false);
153  }
154  }
155  }
156 
162  public function getEditLang()
163  {
164  return $this->_iEditLang;
165  }
166 
170  protected function _getAltSeoEntryId()
171  {
172  }
173 
179  protected function _getSeoEntryType()
180  {
181  return $this->_getType();
182  }
183 
191  public function processParam($sParam)
192  {
193  return $sParam;
194  }
195 
199  protected function _getEncoder()
200  {
201  }
202 
206  public function getEntryUri()
207  {
208  }
209 
215  public function isEntrySuffixed()
216  {
217  return false;
218  }
219 
225  public function isSuffixSupported()
226  {
227  return false;
228  }
229 
235  public function showCatSelect()
236  {
237  return false;
238  }
239 
245  public function getActCatType()
246  {
247  return false;
248  }
249 }