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 = $sTplName;
00082 } else {
00083 $this->_aViewData['oxcid'] = $this->getContentId();
00084 $this->_aViewData['oContent'] = $this->getContent();
00085 }
00086
00087
00088 if ( $this->showPlainTemplate() ) {
00089 $this->_sThisTemplate = $this->_sThisPlainTemplate;
00090 }
00091
00092 return $this->_sThisTemplate;
00093 }
00094
00105 protected function _prepareMetaDescription( $sMeta, $iLength = 200, $blDescTag = false )
00106 {
00107 if ( !$sMeta ) {
00108 $sMeta = $this->getContent()->oxcontents__oxtitle->value;
00109 }
00110 return parent::_prepareMetaDescription( $sMeta, $iLength, $blDescTag );
00111 }
00112
00121 protected function _prepareMetaKeyword( $sKeywords )
00122 {
00123 if ( !$sKeywords ) {
00124 $sKeywords = $this->getContent()->oxcontents__oxtitle->value;
00125 }
00126 return parent::_prepareMetaKeyword( $sKeywords );
00127 }
00128
00134 public function getContentCategory()
00135 {
00136 if ( $this->_oContentCat === null ) {
00137
00138 $this->_oContentCat = false;
00139 if ( ( $oContent = $this->getContent() ) && $oContent->oxcontents__oxtype->value == 2 ) {
00140 $this->_oContentCat = $oContent;
00141 }
00142 }
00143 return $this->_oContentCat;
00144 }
00145
00151 public function showPlainTemplate()
00152 {
00153 return (bool) oxConfig::getParameter( 'plain' );
00154 }
00155
00161 protected function _getSeoObjectId()
00162 {
00163 return oxConfig::getParameter( 'oxcid' );
00164 }
00165
00172 public function getContentId()
00173 {
00174 if ( $this->_sContentId === null ) {
00175 $sContentId = oxConfig::getParameter( 'oxcid' );
00176
00177 if ( !$sContentId ) {
00178
00179
00180 $sContentId = oxConfig::getParameter( 'tpl' );
00181 }
00182
00183 if ( !$sContentId ) {
00184
00185 $sContentId = parent::getContentId();
00186 }
00187
00188 $this->_sContentId = false;
00189 $oContent = oxNew( 'oxcontent' );
00190 if ( $oContent->load( $sContentId ) && $oContent->oxcontents__oxactive->value ) {
00191 $this->_sContentId = $sContentId;
00192 $this->_oContent = $oContent;
00193 }
00194 }
00195 return $this->_sContentId;
00196 }
00197
00203 public function getContent()
00204 {
00205 if ( $this->_oContent === null ) {
00206 $this->_oContent = false;
00207 if ( $this->getContentId() ) {
00208 return $this->_oContent;
00209 }
00210 }
00211 return $this->_oContent;
00212 }
00213
00220 protected function _getSubject()
00221 {
00222 return $this->getContent();
00223 }
00224
00230 protected function _getTplName()
00231 {
00232
00233 $sTplName = oxConfig::getParameter( 'tpl');
00234
00235 if ( $sTplName ) {
00236
00237 $sTplName = basename( $sTplName );
00238
00239
00240 if ( !preg_match("/\.tpl$/", $sTplName) ) {
00241 $sTplName = null;
00242 }
00243 }
00244
00245 return $sTplName;
00246 }
00247 }