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 oxUtils::getInstance()->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 $this->getViewConfig()->setViewConfigParam( 'tpl', $sTpl );
00134 return $this->_sThisTemplate;
00135 }
00136
00144 protected function _canShowContent( $sContentIdent )
00145 {
00146 $blCan = true;
00147 if ( $this->isEnabledPrivateSales() &&
00148 !$this->getUser() && !in_array( $sContentIdent, $this->_aPsAllowedContents ) ) {
00149 $blCan = false;
00150 }
00151 return $blCan;
00152 }
00153
00164 protected function _prepareMetaDescription( $sMeta, $iLength = 200, $blDescTag = false )
00165 {
00166 if ( !$sMeta ) {
00167 $sMeta = $this->getContent()->oxcontents__oxtitle->value;
00168 }
00169 return parent::_prepareMetaDescription( $sMeta, $iLength, $blDescTag );
00170 }
00171
00181 protected function _prepareMetaKeyword( $sKeywords, $blRemoveDuplicatedWords = true )
00182 {
00183 if ( !$sKeywords ) {
00184 $sKeywords = $this->getContent()->oxcontents__oxtitle->value;
00185 }
00186 return parent::_prepareMetaKeyword( $sKeywords, $blRemoveDuplicatedWords );
00187 }
00188
00194 public function getContentCategory()
00195 {
00196 if ( $this->_oContentCat === null ) {
00197
00198 $this->_oContentCat = false;
00199 if ( ( $oContent = $this->getContent() ) && $oContent->oxcontents__oxtype->value == 2 ) {
00200 $this->_oContentCat = $oContent;
00201 }
00202 }
00203 return $this->_oContentCat;
00204 }
00205
00212 public function showPlainTemplate()
00213 {
00214 $blPlain = (bool) oxConfig::getParameter( 'plain' );
00215 if ( $blPlain === false ) {
00216 $oUser = $this->getUser();
00217 if ( $this->isEnabledPrivateSales() &&
00218 ( !$oUser || ( $oUser && !$oUser->isTermsAccepted() ) ) ) {
00219 $blPlain = true;
00220 }
00221 }
00222
00223 return (bool) $blPlain;
00224 }
00225
00231 protected function _getSeoObjectId()
00232 {
00233 return oxConfig::getParameter( 'oxcid' );
00234 }
00235
00242 public function getContentId()
00243 {
00244 if ( $this->_sContentId === null ) {
00245 $sContentId = oxConfig::getParameter( 'oxcid' );
00246
00247 if ( !$sContentId ) {
00248
00249
00250 $sContentId = oxConfig::getParameter( 'tpl' );
00251 }
00252
00253 if ( !$sContentId ) {
00254
00255 $sContentId = parent::getContentId();
00256 }
00257
00258 $this->_sContentId = false;
00259 $oContent = oxNew( 'oxcontent' );
00260 if ( $oContent->load( $sContentId ) ) {
00261
00262
00263 if ( $oContent->oxcontents__oxloadid->value === "oxcredits" &&
00264 $oContent->getLanguage() !== oxConfig::getParameter( "lang" ) ) {
00265 $oContent->setLanguage( (int) oxConfig::getParameter( "lang" ) );
00266 $oContent->load( $oContent->getId() );
00267 }
00268
00269 if ( $oContent->oxcontents__oxactive->value ) {
00270 $this->_sContentId = $sContentId;
00271 $this->_oContent = $oContent;
00272 }
00273 }
00274 }
00275 return $this->_sContentId;
00276 }
00277
00283 public function getContent()
00284 {
00285 if ( $this->_oContent === null ) {
00286 $this->_oContent = false;
00287 if ( $this->getContentId() ) {
00288 return $this->_oContent;
00289 }
00290 }
00291 return $this->_oContent;
00292 }
00293
00302 protected function _getSubject( $iLang )
00303 {
00304 return $this->getContent();
00305 }
00306
00312 protected function _getTplName()
00313 {
00314
00315 $sTplName = oxConfig::getParameter( 'tpl');
00316
00317 if ( $sTplName ) {
00318
00319 $sTplName = basename( $sTplName );
00320
00321
00322 if ( !getStr()->preg_match("/\.tpl$/", $sTplName) ) {
00323 $sTplName = null;
00324 } else {
00325 $sTplName = 'message/'.$sTplName;
00326 }
00327 }
00328
00329 return $sTplName;
00330 }
00331
00337 public function getBreadCrumb()
00338 {
00339 $oContent = $this->getContent();
00340
00341 $aPaths = array();
00342 $aPath = array();
00343
00344 $aPath['title'] = $oContent->oxcontents__oxtitle->value;
00345 $aPath['link'] = $this->getLink();
00346 $aPaths[] = $aPath;
00347
00348 return $aPaths;
00349 }
00350
00356 public function getTitle()
00357 {
00358 if ( $this->_sContentTitle === null ) {
00359 $oContent = $this->getContent();
00360 $this->_sContentTitle = $oContent->oxcontents__oxtitle->value;
00361 }
00362
00363 return $this->_sContentTitle;
00364 }
00365
00371 public function showRdfa()
00372 {
00373 return $this->getConfig()->getConfigParam( 'blRDFaEmbedding' );
00374 }
00375
00382 public function getContentPageTpl()
00383 {
00384 $aTemplate = array();
00385 $sContentId = $this->getContent()->oxcontents__oxloadid->value;
00386 $myConfig = $this->getConfig();
00387 if ( $sContentId == $myConfig->getConfigParam( 'sRDFaBusinessEntityLoc' )) {
00388 $aTemplate[] = $this->_sBusinessTemplate;
00389 }
00390 if ( $sContentId == $myConfig->getConfigParam( 'sRDFaDeliveryChargeSpecLoc' )) {
00391 $aTemplate[] = $this->_sDeliveryTemplate;
00392 }
00393 if ( $sContentId == $myConfig->getConfigParam( 'sRDFaPaymentChargeSpecLoc' )) {
00394 $aTemplate[] = $this->_sPaymentTemplate;
00395 }
00396 return $aTemplate;
00397 }
00398
00404 public function getBusinessEntityExtends()
00405 {
00406 $myConfig = $this->getConfig();
00407 $aExtends = array();
00408
00409 foreach ( $this->_aBusinessEntityExtends as $sExtend ) {
00410 $aExtends[$sExtend] = $myConfig->getConfigParam($sExtend);
00411 }
00412
00413 return $aExtends;
00414 }
00415
00423 public function getNotMappedToRDFaPayments()
00424 {
00425 $oPayments = oxNew("oxpaymentlist");
00426 $oPayments->loadNonRDFaPaymentList();
00427 return $oPayments;
00428 }
00429
00437 public function getNotMappedToRDFaDeliverySets()
00438 {
00439 $oDelSets = oxNew("oxdeliverysetlist");
00440 $oDelSets->loadNonRDFaDeliverySetList();
00441 return $oDelSets;
00442 }
00443
00449 public function getDeliveryChargeSpecs()
00450 {
00451 $aDeliveryChargeSpecs = array();
00452 $oDeliveryChargeSpecs = $this->getDeliveryList();
00453 foreach ($oDeliveryChargeSpecs as $oDeliveryChargeSpec) {
00454 if ($oDeliveryChargeSpec->oxdelivery__oxaddsumtype->value == "abs") {
00455 $oDelSets = oxNew("oxdeliverysetlist");
00456 $oDelSets->loadRDFaDeliverySetList($oDeliveryChargeSpec->getId());
00457 $oDeliveryChargeSpec->deliverysetmethods = $oDelSets;
00458 $aDeliveryChargeSpecs[] = $oDeliveryChargeSpec;
00459 }
00460 }
00461 return $aDeliveryChargeSpecs;
00462 }
00463
00469 public function getDeliveryList()
00470 {
00471 if ( $this->_oDelList === null ) {
00472 $this->_oDelList = oxNew( 'oxdeliverylist' );
00473 $this->_oDelList->getList();
00474 }
00475 return $this->_oDelList;
00476 }
00477
00483 public function getRdfaVAT()
00484 {
00485 return $this->getConfig()->getConfigParam( 'iRDFaVAT' );
00486 }
00487
00493 public function getRdfaPriceValidity()
00494 {
00495 $iDays = $this->getConfig()->getConfigParam( 'iRDFaPriceValidity' );
00496 $iFrom = oxUtilsDate::getInstance()->getTime();
00497 $iThrough = $iFrom + ($iDays * 24 * 60 * 60);
00498 $oPriceValidity = array();
00499 $oPriceValidity['validfrom'] = date('Y-m-d\TH:i:s', $iFrom)."Z";
00500 $oPriceValidity['validthrough'] = date('Y-m-d\TH:i:s', $iThrough)."Z";
00501 return $oPriceValidity;
00502 }
00503
00509 public function getParsedContent()
00510 {
00511 return oxUtilsView::getInstance()->parseThroughSmarty( $this->getContent()->oxcontents__oxcontent->value );
00512 }
00513
00514 }