OXID eShop CE  4.10.7
 All Classes Namespaces Files Functions Variables Pages
content.php
Go to the documentation of this file.
1 <?php
2 
6 class Content extends oxUBase
7 {
8 
14  protected $_sContentId = null;
15 
21  protected $_oContent = null;
22 
28  protected $_sThisTemplate = 'page/info/content.tpl';
29 
35  protected $_sThisPlainTemplate = 'page/info/content_plain.tpl';
36 
42  protected $_oContentCat = null;
43 
49  protected $_aPsAllowedContents = array("oxagb", "oxrightofwithdrawal", "oximpressum");
50 
56  protected $_sContentTitle = null;
57 
63  protected $_blBargainAction = true;
64 
70  protected $_sBusinessTemplate = 'rdfa/content/inc/business_entity.tpl';
71 
77  protected $_sDeliveryTemplate = 'rdfa/content/inc/delivery_charge.tpl';
78 
84  protected $_sPaymentTemplate = 'rdfa/content/inc/payment_charge.tpl';
85 
92  protected $_aBusinessEntityExtends = array("sRDFaLogoUrl",
93  "sRDFaLongitude",
94  "sRDFaLatitude",
95  "sRDFaGLN",
96  "sRDFaNAICS",
97  "sRDFaISIC",
98  "sRDFaDUNS");
99 
105  public function getViewId()
106  {
107  if (!isset($this->_sViewId)) {
108  $this->_sViewId = parent::getViewId() . '|' . oxRegistry::getConfig()->getRequestParameter('oxcid');
109  }
110 
111  return $this->_sViewId;
112  }
113 
121  public function render()
122  {
123  parent::render();
124 
125  $oContent = $this->getContent();
126  if ($oContent && !$this->_canShowContent($oContent->oxcontents__oxloadid->value)) {
127  oxRegistry::getUtils()->redirect($this->getConfig()->getShopHomeURL() . 'cl=account');
128  }
129 
130  $sTpl = false;
131  if ($sTplName = $this->_getTplName()) {
132  $this->_sThisTemplate = $sTpl = $sTplName;
133  } elseif ($oContent) {
134  $sTpl = $oContent->getId();
135  }
136 
137  if (!$sTpl) {
138  error_404_handler();
139  }
140 
141  // sometimes you need to display plain templates (e.g. when showing popups)
142  if ($this->showPlainTemplate()) {
143  $this->_sThisTemplate = $this->_sThisPlainTemplate;
144  }
145 
146  if ($oContent) {
147  $this->getViewConfig()->setViewConfigParam('oxloadid', $oContent->getLoadId());
148  }
149 
150  return $this->_sThisTemplate;
151  }
152 
160  protected function _canShowContent($sContentIdent)
161  {
162  $blCan = true;
163  if ($this->isEnabledPrivateSales() &&
164  !$this->getUser() && !in_array($sContentIdent, $this->_aPsAllowedContents)
165  ) {
166  $blCan = false;
167  }
168 
169  return $blCan;
170  }
171 
182  protected function _prepareMetaDescription($sMeta, $iLength = 200, $blDescTag = false)
183  {
184  if (!$sMeta) {
185  $sMeta = $this->getContent()->oxcontents__oxtitle->value;
186  }
187 
188  return parent::_prepareMetaDescription($sMeta, $iLength, $blDescTag);
189  }
190 
200  protected function _prepareMetaKeyword($sKeywords, $blRemoveDuplicatedWords = true)
201  {
202  if (!$sKeywords) {
203  $sKeywords = $this->getContent()->oxcontents__oxtitle->value;
204  }
205 
206  return parent::_prepareMetaKeyword($sKeywords, $blRemoveDuplicatedWords);
207  }
208 
214  public function getContentCategory()
215  {
216  if ($this->_oContentCat === null) {
217  // setting default status ..
218  $this->_oContentCat = false;
219  if (($oContent = $this->getContent()) && $oContent->oxcontents__oxtype->value == 2) {
220  $this->_oContentCat = $oContent;
221  }
222  }
223 
224  return $this->_oContentCat;
225  }
226 
233  public function showPlainTemplate()
234  {
235  $blPlain = (bool) oxRegistry::getConfig()->getRequestParameter('plain');
236  if ($blPlain === false) {
237  $oUser = $this->getUser();
238  if ($this->isEnabledPrivateSales() &&
239  (!$oUser || ($oUser && !$oUser->isTermsAccepted()))
240  ) {
241  $blPlain = true;
242  }
243  }
244 
245  return (bool) $blPlain;
246  }
247 
253  protected function _getSeoObjectId()
254  {
255  return oxRegistry::getConfig()->getRequestParameter('oxcid');
256  }
257 
264  public function getContentId()
265  {
266  if ($this->_sContentId === null) {
267 
268  $sContentId = oxRegistry::getConfig()->getRequestParameter('oxcid');
269  $sLoadId = oxRegistry::getConfig()->getRequestParameter('oxloadid');
270 
271  $this->_sContentId = false;
272  $oContent = oxNew('oxContent');
273  $blRes = false;
274 
275  if ($sLoadId) {
276  $blRes = $oContent->loadByIdent($sLoadId);
277  } elseif ($sContentId) {
278  $blRes = $oContent->load($sContentId);
279  } else {
280  //get default content (impressum)
281  $blRes = $oContent->loadByIdent('oximpressum');
282  }
283 
284  if ($blRes && $oContent->oxcontents__oxactive->value) {
285  $this->_sContentId = $oContent->oxcontents__oxid->value;
286  $this->_oContent = $oContent;
287  }
288  }
289 
290  return $this->_sContentId;
291  }
292 
298  public function getContent()
299  {
300  if ($this->_oContent === null) {
301  $this->_oContent = false;
302  if ($this->getContentId()) {
303  return $this->_oContent;
304  }
305  }
306 
307  return $this->_oContent;
308  }
309 
318  protected function _getSubject($iLang)
319  {
320  return $this->getContent();
321  }
322 
328  protected function _getTplName()
329  {
330  // assign template name
331  $sTplName = oxRegistry::getConfig()->getRequestParameter('tpl');
332 
333  if ($sTplName) {
334  // security fix so that you cant access files from outside template dir
335  $sTplName = basename($sTplName);
336 
337  //checking if it is template name, not content id
338  if (!getStr()->preg_match("/\.tpl$/", $sTplName)) {
339  $sTplName = null;
340  } else {
341  $sTplName = 'message/' . $sTplName;
342  }
343  }
344 
345  return $sTplName;
346  }
347 
353  public function getBreadCrumb()
354  {
355  $oContent = $this->getContent();
356 
357  $aPaths = array();
358  $aPath = array();
359 
360  $aPath['title'] = $oContent->oxcontents__oxtitle->value;
361  $aPath['link'] = $this->getLink();
362  $aPaths[] = $aPath;
363 
364  return $aPaths;
365  }
366 
372  public function getTitle()
373  {
374  if ($this->_sContentTitle === null) {
375  $oContent = $this->getContent();
376  $this->_sContentTitle = $oContent->oxcontents__oxtitle->value;
377  }
378 
379  return $this->_sContentTitle;
380  }
381 
387  public function showRdfa()
388  {
389  return $this->getConfig()->getConfigParam('blRDFaEmbedding');
390  }
391 
398  public function getContentPageTpl()
399  {
400  $aTemplate = array();
401  $sContentId = $this->getContent()->oxcontents__oxloadid->value;
402  $myConfig = $this->getConfig();
403  if ($sContentId == $myConfig->getConfigParam('sRDFaBusinessEntityLoc')) {
404  $aTemplate[] = $this->_sBusinessTemplate;
405  }
406  if ($sContentId == $myConfig->getConfigParam('sRDFaDeliveryChargeSpecLoc')) {
407  $aTemplate[] = $this->_sDeliveryTemplate;
408  }
409  if ($sContentId == $myConfig->getConfigParam('sRDFaPaymentChargeSpecLoc')) {
410  $aTemplate[] = $this->_sPaymentTemplate;
411  }
412 
413  return $aTemplate;
414  }
415 
421  public function getBusinessEntityExtends()
422  {
423  $myConfig = $this->getConfig();
424  $aExtends = array();
425 
426  foreach ($this->_aBusinessEntityExtends as $sExtend) {
427  $aExtends[$sExtend] = $myConfig->getConfigParam($sExtend);
428  }
429 
430  return $aExtends;
431  }
432 
440  public function getNotMappedToRDFaPayments()
441  {
442  $oPayments = oxNew("oxPaymentList");
443  $oPayments->loadNonRDFaPaymentList();
444 
445  return $oPayments;
446  }
447 
456  {
457  $oDelSets = oxNew("oxDeliverySetList");
458  $oDelSets->loadNonRDFaDeliverySetList();
459 
460  return $oDelSets;
461  }
462 
468  public function getDeliveryChargeSpecs()
469  {
470  $aDeliveryChargeSpecs = array();
471  $oDeliveryChargeSpecs = $this->getDeliveryList();
472  foreach ($oDeliveryChargeSpecs as $oDeliveryChargeSpec) {
473  if ($oDeliveryChargeSpec->oxdelivery__oxaddsumtype->value == "abs") {
474  $oDelSets = oxNew("oxdeliverysetlist");
475  $oDelSets->loadRDFaDeliverySetList($oDeliveryChargeSpec->getId());
476  $oDeliveryChargeSpec->deliverysetmethods = $oDelSets;
477  $aDeliveryChargeSpecs[] = $oDeliveryChargeSpec;
478  }
479  }
480 
481  return $aDeliveryChargeSpecs;
482  }
483 
489  public function getDeliveryList()
490  {
491  if ($this->_oDelList === null) {
492  $this->_oDelList = oxNew('oxDeliveryList');
493  $this->_oDelList->getList();
494  }
495 
496  return $this->_oDelList;
497  }
498 
504  public function getRdfaVAT()
505  {
506  return $this->getConfig()->getConfigParam('iRDFaVAT');
507  }
508 
514  public function getRdfaPriceValidity()
515  {
516  $iDays = $this->getConfig()->getConfigParam('iRDFaPriceValidity');
517  $iFrom = oxRegistry::get("oxUtilsDate")->getTime();
518  $iThrough = $iFrom + ($iDays * 24 * 60 * 60);
519  $oPriceValidity = array();
520  $oPriceValidity['validfrom'] = date('Y-m-d\TH:i:s', $iFrom) . "Z";
521  $oPriceValidity['validthrough'] = date('Y-m-d\TH:i:s', $iThrough) . "Z";
522 
523  return $oPriceValidity;
524  }
525 
531  public function getParsedContent()
532  {
534  $oUtilsView = oxRegistry::get("oxUtilsView");
535  return $oUtilsView->parseThroughSmarty($this->getContent()->oxcontents__oxcontent->value, $this->getContent()->getId(), null, true);
536  }
537 }