Go to the documentation of this file.00001 <?php
00002
00008 class Content_Main extends oxAdminDetails
00009 {
00016 public function render()
00017 {
00018 $myConfig = $this->getConfig();
00019
00020 parent::render();
00021
00022 $soxId = $this->_aViewData["oxid"] = $this->getEditObjectId();
00023
00024
00025 $oCatTree = oxNew( "oxCategoryList" );
00026 $oCatTree->buildList($myConfig->getConfigParam( 'bl_perfLoadCatTree' ));
00027
00028 $oContent = oxNew( "oxcontent" );
00029 if ( $soxId != "-1" && isset( $soxId)) {
00030
00031 $oContent->loadInLang( $this->_iEditLang, $soxId );
00032
00033 $oOtherLang = $oContent->getAvailableInLangs();
00034 if (!isset($oOtherLang[$this->_iEditLang])) {
00035
00036 $oContent->loadInLang( key($oOtherLang), $soxId );
00037 }
00038
00039
00040 $aLang = array_diff ( oxRegistry::getLang()->getLanguageNames(), $oOtherLang );
00041 if ( count( $aLang))
00042 $this->_aViewData["posslang"] = $aLang;
00043 foreach ( $oOtherLang as $id => $language) {
00044 $oLang= new stdClass();
00045 $oLang->sLangDesc = $language;
00046 $oLang->selected = ($id == $this->_iEditLang);
00047 $this->_aViewData["otherlang"][$id] = clone $oLang;
00048 }
00049
00050 if ( $oContent->oxcontents__oxcatid->value && isset( $oCatTree[$oContent->oxcontents__oxcatid->value] ) ) {
00051 $oCatTree[$oContent->oxcontents__oxcatid->value]->selected = 1;
00052 }
00053
00054 } else {
00055
00056 $sUId = oxUtilsObject::getInstance()->generateUId();
00057 $oContent->oxcontents__oxloadid = new oxField( $sUId );
00058 }
00059
00060 $this->_aViewData["edit"] = $oContent;
00061 $this->_aViewData["link"] = "[{ oxgetseourl ident="".$oContent->oxcontents__oxloadid->value."" type="oxcontent" }]";
00062 $this->_aViewData["cattree"] = $oCatTree;
00063
00064
00065 $sCSS = "content.tpl.css";
00066 if ( $oContent->oxcontents__oxsnippet->value == '1') {
00067 $sCSS = null;
00068 }
00069
00070 $this->_aViewData["editor"] = $this->_generateTextEditor( "100%", 300, $oContent, "oxcontents__oxcontent", $sCSS);
00071 $this->_aViewData["afolder"] = $myConfig->getConfigParam( 'aCMSfolder' );
00072
00073 return "content_main.tpl";
00074 }
00075
00081 public function save()
00082 {
00083 parent::save();
00084
00085 $myConfig = $this->getConfig();
00086
00087 $soxId = $this->getEditObjectId();
00088 $aParams = oxConfig::getParameter( "editval");
00089
00090 if ( isset( $aParams['oxcontents__oxloadid'] ) ) {
00091 $aParams['oxcontents__oxloadid'] = $this->_prepareIdent( $aParams['oxcontents__oxloadid'] );
00092 }
00093
00094
00095 if ( $this->_checkIdent( $aParams['oxcontents__oxloadid'], $soxId ) ) {
00096
00097 $this->_aViewData["blLoadError"] = true;
00098
00099 $oContent = oxNew( "oxcontent" );
00100 if ( $soxId != '-1') {
00101 $oContent->load( $soxId );
00102 }
00103 $oContent->assign( $aParams );
00104 $this->_aViewData["edit"] = $oContent;
00105 return;
00106 }
00107
00108
00109 if ( !isset( $aParams['oxcontents__oxactive']))
00110 $aParams['oxcontents__oxactive'] = 0;
00111
00112
00113 if ( $aParams['oxcontents__oxtype'] == 0)
00114 $aParams['oxcontents__oxsnippet'] = 1;
00115 else
00116 $aParams['oxcontents__oxsnippet'] = 0;
00117
00118
00119 if ( $aParams['oxcontents__oxfolder'] == 'CMSFOLDER_NONE' ) {
00120 $aParams['oxcontents__oxfolder'] = '';
00121 }
00122
00123
00124 $sShopID = oxSession::getVar( "actshop");
00125 $aParams['oxcontents__oxshopid'] = $sShopID;
00126 $oContent = oxNew( "oxcontent" );
00127
00128 if ( $soxId != "-1")
00129 $oContent->loadInLang( $this->_iEditLang, $soxId );
00130 else
00131 $aParams['oxcontents__oxid'] = null;
00132
00133
00134
00135 $oContent->setLanguage(0);
00136 $oContent->assign( $aParams);
00137 $oContent->setLanguage($this->_iEditLang);
00138 $oContent->save();
00139
00140
00141 $this->setEditObjectId( $oContent->getId() );
00142 }
00143
00149 public function saveinnlang()
00150 {
00151 parent::save();
00152
00153 $myConfig = $this->getConfig();
00154
00155 $soxId = $this->getEditObjectId();
00156 $aParams = oxConfig::getParameter( "editval");
00157
00158 if ( isset( $aParams['oxcontents__oxloadid'] ) ) {
00159 $aParams['oxcontents__oxloadid'] = $this->_prepareIdent( $aParams['oxcontents__oxloadid'] );
00160 }
00161
00162
00163 if ( !isset( $aParams['oxcontents__oxactive']))
00164 $aParams['oxcontents__oxactive'] = 0;
00165
00166
00167 $sShopID = oxSession::getVar( "actshop");
00168 $aParams['oxcontents__oxshopid'] = $sShopID;
00169
00170 $oContent = oxNew( "oxcontent" );
00171
00172 if ( $soxId != "-1")
00173 $oContent->loadInLang( $this->_iEditLang, $soxId );
00174 else
00175 $aParams['oxcontents__oxid'] = null;
00176
00177 $oContent->setLanguage(0);
00178 $oContent->assign( $aParams);
00179
00180
00181 $oContent->setLanguage( oxConfig::getParameter( "new_lang" ) );
00182 $oContent->save();
00183
00184
00185 $this->setEditObjectId( $oContent->getId() );
00186 }
00187
00195 protected function _prepareIdent( $sIdent )
00196 {
00197 if ( $sIdent ) {
00198 return getStr()->preg_replace( "/[^a-zA-Z0-9_]*/", "", $sIdent );
00199 }
00200 }
00201
00210 protected function _checkIdent( $sIdent, $sOxId )
00211 {
00212 $blAllow = false;
00213 $oDb = oxDb::getDb();
00214
00215 if ( !strlen( $sIdent ) ) {
00216 $blAllow = true;
00217 } elseif ( $oDb->getOne( "select oxid from oxcontents where oxloadid = ".$oDb->quote( $sIdent ) ." and oxid != ".$oDb->quote( $sOxId ) ." and oxshopid = '".$this->getConfig()->getShopId()."'", false, false ) ) {
00218 $blAllow = true;
00219 }
00220 return $blAllow;
00221 }
00222 }