OXID eShop CE  4.8.11
 All Classes Files Functions Variables Pages
object_seo.php
Go to the documentation of this file.
1 <?php
2 
7 {
15  public function render()
16  {
18 
19  if ( $sType = $this->_getType() ) {
20  $oObject = oxNew( $sType );
21  if ( $oObject->load( $this->getEditObjectId() ) ) {
22  $oOtherLang = $oObject->getAvailableInLangs();
23  if ( !isset( $oOtherLang[$iLang] ) ) {
24  $oObject->loadInLang( key( $oOtherLang ), $this->getEditObjectId() );
25  }
26  $this->_aViewData['edit'] = $oObject;
27  }
28 
29  }
30 
31  $iLang = $this->getEditLang();
32  $aLangs = oxRegistry::getLang()->getLanguageNames();
33  foreach ( $aLangs as $sLangId => $sLanguage ) {
34  $oLang = new stdClass();
35  $oLang->sLangDesc = $sLanguage;
36  $oLang->selected = ( $sLangId == $iLang );
37  $this->_aViewData['otherlang'][$sLangId] = clone $oLang;
38  }
39 
40  return 'object_seo.tpl';
41  }
42 
48  public function save()
49  {
50  // saving/updating seo params
51  if ( ( $sOxid = $this->_getSaveObjectId() ) ) {
52  $aSeoData = oxConfig::getParameter( 'aSeoData' );
53  $iShopId = $this->getConfig()->getShopId();
54  $iLang = $this->getEditLang();
55 
56  // checkbox handling
57  if ( !isset( $aSeoData['oxfixed'] ) ) {
58  $aSeoData['oxfixed'] = 0;
59  }
60 
61  $sParams = $this->_getAdditionalParams($aSeoData);
62 
63  $oEncoder = $this->_getEncoder();
64  // marking self and page links as expired
65  $oEncoder->markAsExpired($sOxid, $iShopId, 1, $iLang, $sParams);
66 
67  // saving
68  $oEncoder->addSeoEntry( $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 
81  protected function _getAdditionalParams($aSeoData)
82  {
83  $sParams = null;
84  if (isset($aSeoData['oxparams'])) {
85  if (preg_match('/([a-z]*#)?(?<objectseo>[a-z0-9]+)(#[0-9])?/i', $aSeoData['oxparams'], $aMatches)) {
86  $sQuotedObjectSeoId = oxDb::getDb()->quote($aMatches['objectseo']);
87  $sParams = "oxparams = {$sQuotedObjectSeoId}";
88  }
89  }
90  return $sParams;
91  }
92 
98  protected function _getSaveObjectId()
99  {
100  return $this->getEditObjectId();
101  }
102 
110  public function getEntryMetaData( $sMetaType )
111  {
112  return $this->_getEncoder()->getMetaData( $this->getEditObjectId(), $sMetaType, $this->getConfig()->getShopId(), $this->getEditLang() );
113  }
114 
120  public function isEntryFixed()
121  {
122  $iLang = (int) $this->getEditLang();
123  $iShopId = $this->getConfig()->getShopId();
124 
125  $sQ = "select oxfixed from oxseo where
126  oxseo.oxobjectid = ".oxDb::getDb()->quote( $this->getEditObjectId() )." and
127  oxseo.oxshopid = '{$iShopId}' and oxseo.oxlang = {$iLang} and oxparams = '' ";
128  return (bool) oxDb::getDb()->getOne( $sQ, false, false );
129  }
130 
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 
172  protected function _getAltSeoEntryId()
173  {
174  }
175 
181  protected function _getSeoEntryType()
182  {
183  return $this->_getType();
184  }
185 
193  public function processParam( $sParam )
194  {
195  return $sParam;
196  }
197 
203  protected function _getEncoder()
204  {
205  }
206 
212  public function getEntryUri()
213  {
214  }
215 
221  public function isEntrySuffixed()
222  {
223  return false;
224  }
225 
231  public function isSuffixSupported()
232  {
233  return false;
234  }
235 
241  public function showCatSelect()
242  {
243  return false;
244  }
245 
251  public function getActCatType()
252  {
253  return false;
254  }
255 
256 }