Go to the documentation of this file.00001 <?php
00002
00006 class Content extends oxUBase
00007 {
00012 protected $_sContentId = null;
00013
00018 protected $_oContent = null;
00019
00024 protected $_sThisTemplate = 'page/info/content.tpl';
00025
00030 protected $_sThisPlainTemplate = 'page/info/content_plain.tpl';
00031
00036 protected $_oContentCat = null;
00037
00042 protected $_aPsAllowedContents = array( "oxagb", "oxrightofwithdrawal", "oximpressum" );
00043
00048 protected $_sContentTitle = null;
00049
00054 protected $_blBargainAction = true;
00055
00060 protected $_sBusinessTemplate = 'rdfa/content/inc/business_entity.tpl';
00061
00066 protected $_sDeliveryTemplate = 'rdfa/content/inc/delivery_charge.tpl';
00067
00072 protected $_sPaymentTemplate = 'rdfa/content/inc/payment_charge.tpl';
00073
00080 protected $_aBusinessEntityExtends = array( "sRDFaLogoUrl",
00081 "sRDFaLongitude",
00082 "sRDFaLatitude",
00083 "sRDFaGLN",
00084 "sRDFaNAICS",
00085 "sRDFaISIC",
00086 "sRDFaDUNS");
00087
00093 public function getViewId()
00094 {
00095 if ( !isset( $this->_sViewId ) ) {
00096 $this->_sViewId = parent::getViewId().'|'.oxConfig::getParameter( 'oxcid' );
00097 }
00098 return $this->_sViewId;
00099 }
00100
00108 public function render()
00109 {
00110 parent::render();
00111
00112 $oContent = $this->getContent();
00113 if ( $oContent && !$this->_canShowContent( $oContent->oxcontents__oxloadid->value ) ) {
00114 oxRegistry::getUtils()->redirect( $this->getConfig()->getShopHomeURL() . 'cl=account' );
00115 }
00116
00117 $sTpl = false;
00118 if ( $sTplName = $this->_getTplName() ) {
00119 $this->_sThisTemplate = $sTpl = $sTplName;
00120 } elseif ( $oContent ) {
00121 $sTpl = $oContent->getId();
00122 }
00123
00124 if ( !$sTpl ) {
00125 error_404_handler();
00126 }
00127
00128
00129 if ( $this->showPlainTemplate() ) {
00130 $this->_sThisTemplate = $this->_sThisPlainTemplate;
00131 }
00132
00133 if ( $oContent ) {
00134 $this->getViewConfig()->setViewConfigParam( 'oxloadid', $oContent->getLoadId() );
00135 }
00136
00137 return $this->_sThisTemplate;
00138 }
00139
00147 protected function _canShowContent( $sContentIdent )
00148 {
00149 $blCan = true;
00150 if ( $this->isEnabledPrivateSales() &&
00151 !$this->getUser() && !in_array( $sContentIdent, $this->_aPsAllowedContents ) ) {
00152 $blCan = false;
00153 }
00154 return $blCan;
00155 }
00156
00167 protected function _prepareMetaDescription( $sMeta, $iLength = 200, $blDescTag = false )
00168 {
00169 if ( !$sMeta ) {
00170 $sMeta = $this->getContent()->oxcontents__oxtitle->value;
00171 }
00172 return parent::_prepareMetaDescription( $sMeta, $iLength, $blDescTag );
00173 }
00174
00184 protected function _prepareMetaKeyword( $sKeywords, $blRemoveDuplicatedWords = true )
00185 {
00186 if ( !$sKeywords ) {
00187 $sKeywords = $this->getContent()->oxcontents__oxtitle->value;
00188 }
00189 return parent::_prepareMetaKeyword( $sKeywords, $blRemoveDuplicatedWords );
00190 }
00191
00197 public function getContentCategory()
00198 {
00199 if ( $this->_oContentCat === null ) {
00200
00201 $this->_oContentCat = false;
00202 if ( ( $oContent = $this->getContent() ) && $oContent->oxcontents__oxtype->value == 2 ) {
00203 $this->_oContentCat = $oContent;
00204 }
00205 }
00206 return $this->_oContentCat;
00207 }
00208
00215 public function showPlainTemplate()
00216 {
00217 $blPlain = (bool) oxConfig::getParameter( 'plain' );
00218 if ( $blPlain === false ) {
00219 $oUser = $this->getUser();
00220 if ( $this->isEnabledPrivateSales() &&
00221 ( !$oUser || ( $oUser && !$oUser->isTermsAccepted() ) ) ) {
00222 $blPlain = true;
00223 }
00224 }
00225
00226 return (bool) $blPlain;
00227 }
00228
00234 protected function _getSeoObjectId()
00235 {
00236 return oxConfig::getParameter( 'oxcid' );
00237 }
00238
00245 public function getContentId()
00246 {
00247 if ( $this->_sContentId === null ) {
00248
00249 $sContentId = oxConfig::getParameter( 'oxcid' );
00250 $sLoadId = oxConfig::getParameter( 'oxloadid' );
00251
00252 $this->_sContentId = false;
00253 $oContent = oxNew( 'oxContent' );
00254 $blRes = false;
00255
00256 if ( $sLoadId ) {
00257 $blRes = $oContent->loadByIdent( $sLoadId );
00258 } elseif ( $sContentId ) {
00259 $blRes = $oContent->load( $sContentId );
00260 } else {
00261
00262 $blRes = $oContent->loadByIdent( 'oximpressum' );
00263 }
00264
00265 if ( $blRes && $oContent->oxcontents__oxactive->value ) {
00266 $this->_sContentId = $oContent->oxcontents__oxid->value;
00267 $this->_oContent = $oContent;
00268 }
00269 }
00270
00271 return $this->_sContentId;
00272 }
00273
00279 public function getContent()
00280 {
00281 if ( $this->_oContent === null ) {
00282 $this->_oContent = false;
00283 if ( $this->getContentId() ) {
00284 return $this->_oContent;
00285 }
00286 }
00287 return $this->_oContent;
00288 }
00289
00298 protected function _getSubject( $iLang )
00299 {
00300 return $this->getContent();
00301 }
00302
00308 protected function _getTplName()
00309 {
00310
00311 $sTplName = oxConfig::getParameter( 'tpl');
00312
00313 if ( $sTplName ) {
00314
00315 $sTplName = basename( $sTplName );
00316
00317
00318 if ( !getStr()->preg_match("/\.tpl$/", $sTplName) ) {
00319 $sTplName = null;
00320 } else {
00321 $sTplName = 'message/'.$sTplName;
00322 }
00323 }
00324
00325 return $sTplName;
00326 }
00327
00333 public function getBreadCrumb()
00334 {
00335 $oContent = $this->getContent();
00336
00337 $aPaths = array();
00338 $aPath = array();
00339
00340 $aPath['title'] = $oContent->oxcontents__oxtitle->value;
00341 $aPath['link'] = $this->getLink();
00342 $aPaths[] = $aPath;
00343
00344 return $aPaths;
00345 }
00346
00352 public function getTitle()
00353 {
00354 if ( $this->_sContentTitle === null ) {
00355 $oContent = $this->getContent();
00356 $this->_sContentTitle = $oContent->oxcontents__oxtitle->value;
00357 }
00358
00359 return $this->_sContentTitle;
00360 }
00361
00367 public function showRdfa()
00368 {
00369 return $this->getConfig()->getConfigParam( 'blRDFaEmbedding' );
00370 }
00371
00378 public function getContentPageTpl()
00379 {
00380 $aTemplate = array();
00381 $sContentId = $this->getContent()->oxcontents__oxloadid->value;
00382 $myConfig = $this->getConfig();
00383 if ( $sContentId == $myConfig->getConfigParam( 'sRDFaBusinessEntityLoc' )) {
00384 $aTemplate[] = $this->_sBusinessTemplate;
00385 }
00386 if ( $sContentId == $myConfig->getConfigParam( 'sRDFaDeliveryChargeSpecLoc' )) {
00387 $aTemplate[] = $this->_sDeliveryTemplate;
00388 }
00389 if ( $sContentId == $myConfig->getConfigParam( 'sRDFaPaymentChargeSpecLoc' )) {
00390 $aTemplate[] = $this->_sPaymentTemplate;
00391 }
00392 return $aTemplate;
00393 }
00394
00400 public function getBusinessEntityExtends()
00401 {
00402 $myConfig = $this->getConfig();
00403 $aExtends = array();
00404
00405 foreach ( $this->_aBusinessEntityExtends as $sExtend ) {
00406 $aExtends[$sExtend] = $myConfig->getConfigParam($sExtend);
00407 }
00408
00409 return $aExtends;
00410 }
00411
00419 public function getNotMappedToRDFaPayments()
00420 {
00421 $oPayments = oxNew("oxPaymentList");
00422 $oPayments->loadNonRDFaPaymentList();
00423 return $oPayments;
00424 }
00425
00433 public function getNotMappedToRDFaDeliverySets()
00434 {
00435 $oDelSets = oxNew("oxDeliverySetList");
00436 $oDelSets->loadNonRDFaDeliverySetList();
00437 return $oDelSets;
00438 }
00439
00445 public function getDeliveryChargeSpecs()
00446 {
00447 $aDeliveryChargeSpecs = array();
00448 $oDeliveryChargeSpecs = $this->getDeliveryList();
00449 foreach ($oDeliveryChargeSpecs as $oDeliveryChargeSpec) {
00450 if ($oDeliveryChargeSpec->oxdelivery__oxaddsumtype->value == "abs") {
00451 $oDelSets = oxNew("oxdeliverysetlist");
00452 $oDelSets->loadRDFaDeliverySetList($oDeliveryChargeSpec->getId());
00453 $oDeliveryChargeSpec->deliverysetmethods = $oDelSets;
00454 $aDeliveryChargeSpecs[] = $oDeliveryChargeSpec;
00455 }
00456 }
00457 return $aDeliveryChargeSpecs;
00458 }
00459
00465 public function getDeliveryList()
00466 {
00467 if ( $this->_oDelList === null ) {
00468 $this->_oDelList = oxNew( 'oxDeliveryList' );
00469 $this->_oDelList->getList();
00470 }
00471 return $this->_oDelList;
00472 }
00473
00479 public function getRdfaVAT()
00480 {
00481 return $this->getConfig()->getConfigParam( 'iRDFaVAT' );
00482 }
00483
00489 public function getRdfaPriceValidity()
00490 {
00491 $iDays = $this->getConfig()->getConfigParam( 'iRDFaPriceValidity' );
00492 $iFrom = oxRegistry::get("oxUtilsDate")->getTime();
00493 $iThrough = $iFrom + ($iDays * 24 * 60 * 60);
00494 $oPriceValidity = array();
00495 $oPriceValidity['validfrom'] = date('Y-m-d\TH:i:s', $iFrom)."Z";
00496 $oPriceValidity['validthrough'] = date('Y-m-d\TH:i:s', $iThrough)."Z";
00497 return $oPriceValidity;
00498 }
00499
00505 public function getParsedContent()
00506 {
00507 return oxRegistry::get("oxUtilsView")->parseThroughSmarty( $this->getContent()->oxcontents__oxcontent->value, $this->getContent()->getId() );
00508 }
00509
00510 }