content.php
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 = 'content.tpl';
00025
00030 protected $_sThisPlainTemplate = 'content_plain.tpl';
00031
00036 protected $_oContentCat = null;
00037
00043 public function getViewId()
00044 {
00045 if ( !isset( $this->_sViewId ) ) {
00046 $this->_sViewId = parent::getViewId().'|'.oxConfig::getParameter( 'oxcid' );
00047 }
00048 return $this->_sViewId;
00049 }
00050
00061 public function render()
00062 {
00063 parent::render();
00064
00065 if ( $sTplName = $this->_getTplName() ) {
00066 $this->_sThisTemplate = $sTpl = $sTplName;
00067 } else {
00068 $this->_aViewData['oxcid'] = $sTpl = $this->getContentId();
00069 if ( !$sTpl ) {
00070 error_404_handler( );
00071 }
00072 $this->_aViewData['oContent'] = $this->getContent();
00073 }
00074
00075
00076 if ( $this->showPlainTemplate() ) {
00077 $this->_sThisTemplate = $this->_sThisPlainTemplate;
00078 }
00079
00080 $this->_aViewData['tpl'] = $sTpl;
00081 $this->getViewConfig()->setViewConfigParam( 'tpl', $sTpl );
00082 return $this->_sThisTemplate;
00083 }
00084
00095 protected function _prepareMetaDescription( $sMeta, $iLength = 200, $blDescTag = false )
00096 {
00097 if ( !$sMeta ) {
00098 $sMeta = $this->getContent()->oxcontents__oxtitle->value;
00099 }
00100 return parent::_prepareMetaDescription( $sMeta, $iLength, $blDescTag );
00101 }
00102
00112 protected function _prepareMetaKeyword( $sKeywords, $blRemoveDuplicatedWords = true )
00113 {
00114 if ( !$sKeywords ) {
00115 $sKeywords = $this->getContent()->oxcontents__oxtitle->value;
00116 }
00117 return parent::_prepareMetaKeyword( $sKeywords, $blRemoveDuplicatedWords );
00118 }
00119
00125 public function getContentCategory()
00126 {
00127 if ( $this->_oContentCat === null ) {
00128
00129 $this->_oContentCat = false;
00130 if ( ( $oContent = $this->getContent() ) && $oContent->oxcontents__oxtype->value == 2 ) {
00131 $this->_oContentCat = $oContent;
00132 }
00133 }
00134 return $this->_oContentCat;
00135 }
00136
00142 public function showPlainTemplate()
00143 {
00144 return (bool) oxConfig::getParameter( 'plain' );
00145 }
00146
00152 protected function _getSeoObjectId()
00153 {
00154 return oxConfig::getParameter( 'oxcid' );
00155 }
00156
00163 public function getContentId()
00164 {
00165 if ( $this->_sContentId === null ) {
00166 $sContentId = oxConfig::getParameter( 'oxcid' );
00167
00168 if ( !$sContentId ) {
00169
00170
00171 $sContentId = oxConfig::getParameter( 'tpl' );
00172 }
00173
00174 if ( !$sContentId ) {
00175
00176 $sContentId = parent::getContentId();
00177 }
00178
00179 $this->_sContentId = false;
00180 $oContent = oxNew( 'oxcontent' );
00181 if ( $oContent->load( $sContentId ) && $oContent->oxcontents__oxactive->value ) {
00182 $this->_sContentId = $sContentId;
00183 $this->_oContent = $oContent;
00184 }
00185 }
00186 return $this->_sContentId;
00187 }
00188
00194 public function getContent()
00195 {
00196 if ( $this->_oContent === null ) {
00197 $this->_oContent = false;
00198 if ( $this->getContentId() ) {
00199 return $this->_oContent;
00200 }
00201 }
00202 return $this->_oContent;
00203 }
00204
00213 protected function _getSubject( $iLang )
00214 {
00215 return $this->getContent();
00216 }
00217
00223 protected function _getTplName()
00224 {
00225
00226 $sTplName = oxConfig::getParameter( 'tpl');
00227
00228 if ( $sTplName ) {
00229
00230 $sTplName = basename( $sTplName );
00231
00232
00233 if ( !preg_match("/\.tpl$/", $sTplName) ) {
00234 $sTplName = null;
00235 }
00236 }
00237
00238 return $sTplName;
00239 }
00240 }