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 init()
00044 {
00045 if ( oxUtils::getInstance()->seoIsActive() ) {
00046
00047 $this->setSessionCategoryId( null );
00048 }
00049
00050 parent::init();
00051 }
00052
00058 public function getViewId()
00059 {
00060 if ( !isset( $this->_sViewId ) ) {
00061 $this->_sViewId = parent::getViewId().'|'.oxConfig::getParameter( 'oxcid' );
00062 }
00063 return $this->_sViewId;
00064 }
00065
00076 public function render()
00077 {
00078 parent::render();
00079
00080 if ( $sTplName = $this->_getTplName() ) {
00081 $this->_sThisTemplate = $sTpl = $sTplName;
00082 } else {
00083 $this->_aViewData['oxcid'] = $sTpl = $this->getContentId();
00084 $this->_aViewData['oContent'] = $this->getContent();
00085 }
00086
00087
00088 if ( $this->showPlainTemplate() ) {
00089 $this->_sThisTemplate = $this->_sThisPlainTemplate;
00090 }
00091
00092 $this->_aViewData['tpl'] = $sTpl;
00093 return $this->_sThisTemplate;
00094 }
00095
00106 protected function _prepareMetaDescription( $sMeta, $iLength = 200, $blDescTag = false )
00107 {
00108 if ( !$sMeta ) {
00109 $sMeta = $this->getContent()->oxcontents__oxtitle->value;
00110 }
00111 return parent::_prepareMetaDescription( $sMeta, $iLength, $blDescTag );
00112 }
00113
00123 protected function _prepareMetaKeyword( $sKeywords, $blRemoveDuplicatedWords = true )
00124 {
00125 if ( !$sKeywords ) {
00126 $sKeywords = $this->getContent()->oxcontents__oxtitle->value;
00127 }
00128 return parent::_prepareMetaKeyword( $sKeywords, $blRemoveDuplicatedWords );
00129 }
00130
00136 public function getContentCategory()
00137 {
00138 if ( $this->_oContentCat === null ) {
00139
00140 $this->_oContentCat = false;
00141 if ( ( $oContent = $this->getContent() ) && $oContent->oxcontents__oxtype->value == 2 ) {
00142 $this->_oContentCat = $oContent;
00143 }
00144 }
00145 return $this->_oContentCat;
00146 }
00147
00153 public function showPlainTemplate()
00154 {
00155 return (bool) oxConfig::getParameter( 'plain' );
00156 }
00157
00163 protected function _getSeoObjectId()
00164 {
00165 return oxConfig::getParameter( 'oxcid' );
00166 }
00167
00174 public function getContentId()
00175 {
00176 if ( $this->_sContentId === null ) {
00177 $sContentId = oxConfig::getParameter( 'oxcid' );
00178
00179 if ( !$sContentId ) {
00180
00181
00182 $sContentId = oxConfig::getParameter( 'tpl' );
00183 }
00184
00185 if ( !$sContentId ) {
00186
00187 $sContentId = parent::getContentId();
00188 }
00189
00190 $this->_sContentId = false;
00191 $oContent = oxNew( 'oxcontent' );
00192 if ( $oContent->load( $sContentId ) && $oContent->oxcontents__oxactive->value ) {
00193 $this->_sContentId = $sContentId;
00194 $this->_oContent = $oContent;
00195 }
00196 }
00197 return $this->_sContentId;
00198 }
00199
00205 public function getContent()
00206 {
00207 if ( $this->_oContent === null ) {
00208 $this->_oContent = false;
00209 if ( $this->getContentId() ) {
00210 return $this->_oContent;
00211 }
00212 }
00213 return $this->_oContent;
00214 }
00215
00224 protected function _getSubject( $iLang )
00225 {
00226 return $this->getContent();
00227 }
00228
00234 protected function _getTplName()
00235 {
00236
00237 $sTplName = oxConfig::getParameter( 'tpl');
00238
00239 if ( $sTplName ) {
00240
00241 $sTplName = basename( $sTplName );
00242
00243
00244 if ( !preg_match("/\.tpl$/", $sTplName) ) {
00245 $sTplName = null;
00246 }
00247 }
00248
00249 return $sTplName;
00250 }
00251 }