content.php

Go to the documentation of this file.
00001 <?php
00002 
00006 class Content extends oxUBase
00007 {
00008 
00014     protected $_sContentId = null;
00015 
00021     protected $_oContent = null;
00022 
00028     protected $_sThisTemplate = 'page/info/content.tpl';
00029 
00035     protected $_sThisPlainTemplate = 'page/info/content_plain.tpl';
00036 
00042     protected $_oContentCat = null;
00043 
00049     protected $_aPsAllowedContents = array("oxagb", "oxrightofwithdrawal", "oximpressum");
00050 
00056     protected $_sContentTitle = null;
00057 
00063     protected $_blBargainAction = true;
00064 
00070     protected $_sBusinessTemplate = 'rdfa/content/inc/business_entity.tpl';
00071 
00077     protected $_sDeliveryTemplate = 'rdfa/content/inc/delivery_charge.tpl';
00078 
00084     protected $_sPaymentTemplate = 'rdfa/content/inc/payment_charge.tpl';
00085 
00092     protected $_aBusinessEntityExtends = array("sRDFaLogoUrl",
00093                                                "sRDFaLongitude",
00094                                                "sRDFaLatitude",
00095                                                "sRDFaGLN",
00096                                                "sRDFaNAICS",
00097                                                "sRDFaISIC",
00098                                                "sRDFaDUNS");
00099 
00105     public function getViewId()
00106     {
00107         if (!isset($this->_sViewId)) {
00108             $this->_sViewId = parent::getViewId() . '|' . oxRegistry::getConfig()->getRequestParameter('oxcid');
00109         }
00110 
00111         return $this->_sViewId;
00112     }
00113 
00121     public function render()
00122     {
00123         parent::render();
00124 
00125         $oContent = $this->getContent();
00126         if ($oContent && !$this->_canShowContent($oContent->oxcontents__oxloadid->value)) {
00127             oxRegistry::getUtils()->redirect($this->getConfig()->getShopHomeURL() . 'cl=account');
00128         }
00129 
00130         $sTpl = false;
00131         if ($sTplName = $this->_getTplName()) {
00132             $this->_sThisTemplate = $sTpl = $sTplName;
00133         } elseif ($oContent) {
00134             $sTpl = $oContent->getId();
00135         }
00136 
00137         if (!$sTpl) {
00138             error_404_handler();
00139         }
00140 
00141         // sometimes you need to display plain templates (e.g. when showing popups)
00142         if ($this->showPlainTemplate()) {
00143             $this->_sThisTemplate = $this->_sThisPlainTemplate;
00144         }
00145 
00146         if ($oContent) {
00147             $this->getViewConfig()->setViewConfigParam('oxloadid', $oContent->getLoadId());
00148         }
00149 
00150         return $this->_sThisTemplate;
00151     }
00152 
00160     protected function _canShowContent($sContentIdent)
00161     {
00162         $blCan = true;
00163         if ($this->isEnabledPrivateSales() &&
00164             !$this->getUser() && !in_array($sContentIdent, $this->_aPsAllowedContents)
00165         ) {
00166             $blCan = false;
00167         }
00168 
00169         return $blCan;
00170     }
00171 
00182     protected function _prepareMetaDescription($sMeta, $iLength = 200, $blDescTag = false)
00183     {
00184         if (!$sMeta) {
00185             $sMeta = $this->getContent()->oxcontents__oxtitle->value;
00186         }
00187 
00188         return parent::_prepareMetaDescription($sMeta, $iLength, $blDescTag);
00189     }
00190 
00200     protected function _prepareMetaKeyword($sKeywords, $blRemoveDuplicatedWords = true)
00201     {
00202         if (!$sKeywords) {
00203             $sKeywords = $this->getContent()->oxcontents__oxtitle->value;
00204         }
00205 
00206         return parent::_prepareMetaKeyword($sKeywords, $blRemoveDuplicatedWords);
00207     }
00208 
00214     public function getContentCategory()
00215     {
00216         if ($this->_oContentCat === null) {
00217             // setting default status ..
00218             $this->_oContentCat = false;
00219             if (($oContent = $this->getContent()) && $oContent->oxcontents__oxtype->value == 2) {
00220                 $this->_oContentCat = $oContent;
00221             }
00222         }
00223 
00224         return $this->_oContentCat;
00225     }
00226 
00233     public function showPlainTemplate()
00234     {
00235         $blPlain = (bool) oxRegistry::getConfig()->getRequestParameter('plain');
00236         if ($blPlain === false) {
00237             $oUser = $this->getUser();
00238             if ($this->isEnabledPrivateSales() &&
00239                 (!$oUser || ($oUser && !$oUser->isTermsAccepted()))
00240             ) {
00241                 $blPlain = true;
00242             }
00243         }
00244 
00245         return (bool) $blPlain;
00246     }
00247 
00253     protected function _getSeoObjectId()
00254     {
00255         return oxRegistry::getConfig()->getRequestParameter('oxcid');
00256     }
00257 
00264     public function getContentId()
00265     {
00266         if ($this->_sContentId === null) {
00267 
00268             $sContentId = oxRegistry::getConfig()->getRequestParameter('oxcid');
00269             $sLoadId = oxRegistry::getConfig()->getRequestParameter('oxloadid');
00270 
00271             $this->_sContentId = false;
00272             $oContent = oxNew('oxContent');
00273             $blRes = false;
00274 
00275             if ($sLoadId) {
00276                 $blRes = $oContent->loadByIdent($sLoadId);
00277             } elseif ($sContentId) {
00278                 $blRes = $oContent->load($sContentId);
00279             } else {
00280                 //get default content (impressum)
00281                 $blRes = $oContent->loadByIdent('oximpressum');
00282             }
00283 
00284             if ($blRes && $oContent->oxcontents__oxactive->value) {
00285                 $this->_sContentId = $oContent->oxcontents__oxid->value;
00286                 $this->_oContent = $oContent;
00287             }
00288         }
00289 
00290         return $this->_sContentId;
00291     }
00292 
00298     public function getContent()
00299     {
00300         if ($this->_oContent === null) {
00301             $this->_oContent = false;
00302             if ($this->getContentId()) {
00303                 return $this->_oContent;
00304             }
00305         }
00306 
00307         return $this->_oContent;
00308     }
00309 
00318     protected function _getSubject($iLang)
00319     {
00320         return $this->getContent();
00321     }
00322 
00328     protected function _getTplName()
00329     {
00330         // assign template name
00331         $sTplName = oxRegistry::getConfig()->getRequestParameter('tpl');
00332 
00333         if ($sTplName) {
00334             // security fix so that you cant access files from outside template dir
00335             $sTplName = basename($sTplName);
00336 
00337             //checking if it is template name, not content id
00338             if (!getStr()->preg_match("/\.tpl$/", $sTplName)) {
00339                 $sTplName = null;
00340             } else {
00341                 $sTplName = 'message/' . $sTplName;
00342             }
00343         }
00344 
00345         return $sTplName;
00346     }
00347 
00353     public function getBreadCrumb()
00354     {
00355         $oContent = $this->getContent();
00356 
00357         $aPaths = array();
00358         $aPath = array();
00359 
00360         $aPath['title'] = $oContent->oxcontents__oxtitle->value;
00361         $aPath['link'] = $this->getLink();
00362         $aPaths[] = $aPath;
00363 
00364         return $aPaths;
00365     }
00366 
00372     public function getTitle()
00373     {
00374         if ($this->_sContentTitle === null) {
00375             $oContent = $this->getContent();
00376             $this->_sContentTitle = $oContent->oxcontents__oxtitle->value;
00377         }
00378 
00379         return $this->_sContentTitle;
00380     }
00381 
00387     public function showRdfa()
00388     {
00389         return $this->getConfig()->getConfigParam('blRDFaEmbedding');
00390     }
00391 
00398     public function getContentPageTpl()
00399     {
00400         $aTemplate = array();
00401         $sContentId = $this->getContent()->oxcontents__oxloadid->value;
00402         $myConfig = $this->getConfig();
00403         if ($sContentId == $myConfig->getConfigParam('sRDFaBusinessEntityLoc')) {
00404             $aTemplate[] = $this->_sBusinessTemplate;
00405         }
00406         if ($sContentId == $myConfig->getConfigParam('sRDFaDeliveryChargeSpecLoc')) {
00407             $aTemplate[] = $this->_sDeliveryTemplate;
00408         }
00409         if ($sContentId == $myConfig->getConfigParam('sRDFaPaymentChargeSpecLoc')) {
00410             $aTemplate[] = $this->_sPaymentTemplate;
00411         }
00412 
00413         return $aTemplate;
00414     }
00415 
00421     public function getBusinessEntityExtends()
00422     {
00423         $myConfig = $this->getConfig();
00424         $aExtends = array();
00425 
00426         foreach ($this->_aBusinessEntityExtends as $sExtend) {
00427             $aExtends[$sExtend] = $myConfig->getConfigParam($sExtend);
00428         }
00429 
00430         return $aExtends;
00431     }
00432 
00440     public function getNotMappedToRDFaPayments()
00441     {
00442         $oPayments = oxNew("oxPaymentList");
00443         $oPayments->loadNonRDFaPaymentList();
00444 
00445         return $oPayments;
00446     }
00447 
00455     public function getNotMappedToRDFaDeliverySets()
00456     {
00457         $oDelSets = oxNew("oxDeliverySetList");
00458         $oDelSets->loadNonRDFaDeliverySetList();
00459 
00460         return $oDelSets;
00461     }
00462 
00468     public function getDeliveryChargeSpecs()
00469     {
00470         $aDeliveryChargeSpecs = array();
00471         $oDeliveryChargeSpecs = $this->getDeliveryList();
00472         foreach ($oDeliveryChargeSpecs as $oDeliveryChargeSpec) {
00473             if ($oDeliveryChargeSpec->oxdelivery__oxaddsumtype->value == "abs") {
00474                 $oDelSets = oxNew("oxdeliverysetlist");
00475                 $oDelSets->loadRDFaDeliverySetList($oDeliveryChargeSpec->getId());
00476                 $oDeliveryChargeSpec->deliverysetmethods = $oDelSets;
00477                 $aDeliveryChargeSpecs[] = $oDeliveryChargeSpec;
00478             }
00479         }
00480 
00481         return $aDeliveryChargeSpecs;
00482     }
00483 
00489     public function getDeliveryList()
00490     {
00491         if ($this->_oDelList === null) {
00492             $this->_oDelList = oxNew('oxDeliveryList');
00493             $this->_oDelList->getList();
00494         }
00495 
00496         return $this->_oDelList;
00497     }
00498 
00504     public function getRdfaVAT()
00505     {
00506         return $this->getConfig()->getConfigParam('iRDFaVAT');
00507     }
00508 
00514     public function getRdfaPriceValidity()
00515     {
00516         $iDays = $this->getConfig()->getConfigParam('iRDFaPriceValidity');
00517         $iFrom = oxRegistry::get("oxUtilsDate")->getTime();
00518         $iThrough = $iFrom + ($iDays * 24 * 60 * 60);
00519         $oPriceValidity = array();
00520         $oPriceValidity['validfrom'] = date('Y-m-d\TH:i:s', $iFrom) . "Z";
00521         $oPriceValidity['validthrough'] = date('Y-m-d\TH:i:s', $iThrough) . "Z";
00522 
00523         return $oPriceValidity;
00524     }
00525 
00531     public function getParsedContent()
00532     {
00534         $oUtilsView = oxRegistry::get("oxUtilsView");
00535         return $oUtilsView->parseThroughSmarty($this->getContent()->oxcontents__oxcontent->value, $this->getContent()->getId(), null, true);
00536     }
00537 }