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 $_sNoparamlink = null;
00038 
00044     protected $_blExpanded = null;
00045 
00051     protected $_blIsSeoObject = true;
00052 
00060     public function __get( $sName )
00061     {
00062         switch ( $sName ) {
00063             case 'expanded':
00064                 return $this->getExpanded();
00065                 break;
00066         }
00067         return parent::__get( $sName );
00068     }
00069 
00073     public function __construct()
00074     {
00075         parent::__construct();
00076         $this->init( 'oxcontents' );
00077     }
00078 
00084     public function getExpanded()
00085     {
00086         if ( !isset( $this->_blExpanded ) ) {
00087             $this->_blExpanded = ( $this->getId() == oxConfig::getParameter( 'oxcid' ) );
00088         }
00089         return $this->_blExpanded;
00090     }
00091 
00099     public function loadByIdent( $sLoadId )
00100     {
00101         $sSelect = $this->buildSelectString( array( 'oxcontents.oxloadid' => $sLoadId,
00102                                                     'oxcontents.'.$this->getSqlFieldName( 'oxactive' ) => '1',
00103                                                     'oxcontents.oxshopid' => $this->getConfig()->getShopId() ) );
00104 
00105         $sRes = $this->assignRecord( $sSelect );
00106         return $sRes;
00107     }
00108 
00116     public function assign( $dbRecord )
00117     {
00118 
00119         parent::assign( $dbRecord );
00120         $this->oxcontents__oxcontent->setValue(str_replace( '&amp;', '&', $this->oxcontents__oxcontent->value ), oxField::T_RAW);
00121         // workaround for firefox showing &lang= as &9001;= entity, mantis#0001272
00122         $this->oxcontents__oxcontent->setValue(str_replace( '&lang=', '&amp;lang=', $this->oxcontents__oxcontent->value ), oxField::T_RAW);
00123     }
00124 
00133     public function getLink($iLang = null)
00134     {
00135         if (isset($iLang)) {
00136             $iLang = (int) $iLang;
00137             if ($iLang == (int) $this->getLanguage()) {
00138                 $iLang = null;
00139             }
00140         }
00141         if ( $this->_sNoparamlink === null || isset($iLang) ) {
00142             if ( oxUtils::getInstance()->seoIsActive() ) {
00143                 $sNoparamlink = oxSeoEncoderContent::getInstance()->getContentUrl( $this, $iLang );
00144             } else {
00145                 $sNoparamlink = $this->getStdLink($iLang);
00146             }
00147 
00148             if (isset($iLang)) {
00149                 return $sNoparamlink;
00150             } else {
00151                 $this->_sNoparamlink = $sNoparamlink;
00152             }
00153         }
00154 
00155         return $this->_sNoparamlink;
00156     }
00157 
00166     public function getStdLink( $iLang = null, $aParams = array() )
00167     {
00168         $sAdd = '';
00169 
00170         if (isset($iLang) && !oxUtils::getInstance()->seoIsActive()) {
00171             $iLang = (int) $iLang;
00172             if ($iLang != (int) $this->getLanguage()) {
00173                 $sAdd .= "&amp;lang={$iLang}";
00174             }
00175         }
00176         if ($this->oxcontents__oxcatid->value && $this->oxcontents__oxcatid->value != 'oxrootid') {
00177             $oDb = oxDb::getDb();
00178             $sParentId = $oDb->getOne("select oxparentid from oxcategories where oxid = ".$oDb->quote($this->oxcontents__oxcatid->value));
00179             if ($sParentId && 'oxrootid' != $sParentId) {
00180                 $sAdd .= "&amp;cnid=$sParentId";
00181             }
00182         }
00183         return $this->getConfig()->getShopHomeURL() . "cl=content&amp;oxcid=" . $this->getId() . $sAdd;
00184     }
00185 
00195     protected function _setFieldData( $sFieldName, $sValue, $iDataType = oxField::T_TEXT)
00196     {
00197         if ('oxcontent' === strtolower($sFieldName) || 'oxcontents__oxcontent' === strtolower($sFieldName)) {
00198             $iDataType = oxField::T_RAW;
00199         }
00200 
00201         return parent::_setFieldData($sFieldName, $sValue, $iDataType);
00202     }
00203 
00211     public function delete( $sOXID = null)
00212     {
00213         if ( !$sOXID ) {
00214             $sOXID = $this->getId();
00215         }
00216         if (parent::delete($sOXID)) {
00217             oxSeoEncoderContent::getInstance()->onDeleteContent($sOXID);
00218             return true;
00219         }
00220         return false;
00221     }
00222 }

Generated on Mon Oct 26 20:07:16 2009 for OXID eShop CE by  doxygen 1.5.5