oxcontent.php
Go to the documentation of this file.00001 <?php
00002
00008 class oxContent extends oxI18n implements oxIUrl
00009 {
00015 protected $_sCoreTbl = 'oxcontents';
00016
00022 protected $_sClassName = 'oxcontent';
00023
00030 protected $_aSkipSaveFields = array( 'oxtimestamp' );
00031
00037 protected $_aSeoUrls = array();
00038
00044 protected $_sParentCatId = null;
00045
00051 protected $_blExpanded = null;
00052
00058 protected $_blIsSeoObject = true;
00059
00067 public function __get( $sName )
00068 {
00069 switch ( $sName ) {
00070 case 'expanded':
00071 return $this->getExpanded();
00072 break;
00073 }
00074 return parent::__get( $sName );
00075 }
00076
00080 public function __construct()
00081 {
00082 parent::__construct();
00083 $this->init( 'oxcontents' );
00084 }
00085
00091 public function getExpanded()
00092 {
00093 if ( !isset( $this->_blExpanded ) ) {
00094 $this->_blExpanded = ( $this->getId() == oxConfig::getParameter( 'oxcid' ) );
00095 }
00096 return $this->_blExpanded;
00097 }
00098
00106 public function loadByIdent( $sLoadId )
00107 {
00108 $sSelect = $this->buildSelectString( array( 'oxcontents.oxloadid' => $sLoadId,
00109 'oxcontents.'.$this->getSqlFieldName( 'oxactive' ) => '1',
00110 'oxcontents.oxshopid' => $this->getConfig()->getShopId() ) );
00111
00112 return $this->assignRecord( $sSelect );
00113 }
00114
00122 public function assign( $dbRecord )
00123 {
00124
00125 parent::assign( $dbRecord );
00126 $this->oxcontents__oxcontent->setValue(str_replace( '&', '&', $this->oxcontents__oxcontent->value ), oxField::T_RAW);
00127
00128 $this->oxcontents__oxcontent->setValue(str_replace( '&lang=', '&lang=', $this->oxcontents__oxcontent->value ), oxField::T_RAW);
00129 }
00130
00138 public function getBaseSeoLink( $iLang )
00139 {
00140 return oxSeoEncoderContent::getInstance()->getContentUrl( $this, $iLang );
00141 }
00142
00150 public function getLink( $iLang = null )
00151 {
00152 if ( !oxUtils::getInstance()->seoIsActive() ) {
00153 return $this->getStdLink( $iLang );
00154 }
00155
00156 if ( $iLang === null ) {
00157 $iLang = $this->getLanguage();
00158 }
00159
00160 if ( !isset( $this->_aSeoUrls[$iLang] ) ) {
00161 $this->_aSeoUrls[$iLang] = $this->getBaseSeoLink( $iLang );
00162 }
00163
00164 return $this->_aSeoUrls[$iLang];
00165 }
00166
00176 public function getBaseStdLink( $iLang, $blAddId = true, $blFull = true )
00177 {
00178 $sUrl = '';
00179 if ( $blFull ) {
00180
00181 $sUrl = $this->getConfig()->getShopUrl( $iLang, false );
00182 }
00183
00184 $sUrl .= "index.php?cl=content";
00185 if ( $blAddId ) {
00186 $sUrl .= "&oxcid=".$this->getId();
00187
00188 if ( $this->_sParentCatId !== false &&
00189 $this->oxcontents__oxcatid->value && $this->oxcontents__oxcatid->value != 'oxrootid' ) {
00190
00191 if ( $this->_sParentCatId === null ) {
00192 $this->_sParentCatId = false;
00193 $oDb = oxDb::getDb();
00194 $sParentId = $oDb->getOne( "select oxparentid from oxcategories where oxid = ".$oDb->quote( $this->oxcontents__oxcatid->value ) );
00195 if ( $sParentId && 'oxrootid' != $sParentId ) {
00196 $this->_sParentCatId = $sParentId;
00197 }
00198 }
00199
00200 if ( $this->_sParentCatId ) {
00201 $sUrl .= "&cnid=".$this->_sParentCatId;
00202 }
00203 }
00204 }
00205
00206
00207 return $sUrl;
00208 }
00209
00218 public function getStdLink( $iLang = null, $aParams = array() )
00219 {
00220 if ( $iLang === null ) {
00221 $iLang = $this->getLanguage();
00222 }
00223
00224 return oxUtilsUrl::getInstance()->processStdUrl( $this->getBaseStdLink( $iLang ), $aParams, $iLang, $iLang != $this->getLanguage() );
00225 }
00226
00236 protected function _setFieldData( $sFieldName, $sValue, $iDataType = oxField::T_TEXT)
00237 {
00238 if ('oxcontent' === strtolower($sFieldName) || 'oxcontents__oxcontent' === strtolower($sFieldName)) {
00239 $iDataType = oxField::T_RAW;
00240 }
00241
00242 return parent::_setFieldData($sFieldName, $sValue, $iDataType);
00243 }
00244
00252 public function delete( $sOXID = null)
00253 {
00254 if ( !$sOXID ) {
00255 $sOXID = $this->getId();
00256 }
00257 if (parent::delete($sOXID)) {
00258 oxSeoEncoderContent::getInstance()->onDeleteContent($sOXID);
00259 return true;
00260 }
00261 return false;
00262 }
00263 }