Go to the documentation of this file.00001 <?php
00002
00003
00004
00005
00006
00012 class News_Main extends oxAdminDetails
00013 {
00021 public function render()
00022 {
00023 $myConfig = $this->getConfig();
00024
00025 parent::render();
00026
00027
00028 $oGroups = oxNew( "oxlist" );
00029 $oGroups->init( "oxgroups" );
00030 $oGroups->selectString( "select * from ".getViewName( "oxgroups", $this->_iEditLang ) );
00031
00032 $soxId = $this->_aViewData["oxid"] = $this->getEditObjectId();
00033 if ( $soxId != "-1" && isset( $soxId)) {
00034
00035 $oNews = oxNew( "oxnews" );
00036 $oNews->loadInLang( $this->_iEditLang, $soxId );
00037
00038 $oOtherLang = $oNews->getAvailableInLangs();
00039 if (!isset($oOtherLang[$this->_iEditLang])) {
00040
00041 $oNews->loadInLang( key($oOtherLang), $soxId );
00042 }
00043 $this->_aViewData["edit"] = $oNews;
00044
00045
00046
00047 $this->_aViewData["posslang"] = array_diff ( oxRegistry::getLang()->getLanguageNames(), $oOtherLang);
00048
00049 foreach ( $oOtherLang as $id => $language) {
00050 $oLang= new stdClass();
00051 $oLang->sLangDesc = $language;
00052 $oLang->selected = ($id == $this->_iEditLang);
00053 $this->_aViewData["otherlang"][$id] = clone $oLang;
00054 }
00055 }
00056 if ( oxConfig::getParameter("aoc") ) {
00057 $oNewsMainAjax = oxNew( 'news_main_ajax' );
00058 $this->_aViewData['oxajax'] = $oNewsMainAjax->getColumns();
00059
00060 return "popups/news_main.tpl";
00061 }
00062 return "news_main.tpl";
00063 }
00064
00070 public function save()
00071 {
00072 parent::save();
00073
00074 $soxId = $this->getEditObjectId();
00075 $aParams = oxConfig::getParameter( "editval");
00076
00077 if ( !isset( $aParams['oxnews__oxactive']))
00078 $aParams['oxnews__oxactive'] = 0;
00079
00080
00081 $sShopID = oxSession::getVar( "actshop");
00082 $aParams['oxnews__oxshopid'] = $sShopID;
00083
00084 if (!$aParams['oxnews__oxdate'])
00085 $aParams['oxnews__oxdate'] = "";
00086
00087 $oConvObject = new oxField();
00088 $oConvObject->fldmax_length = 0;
00089 $oConvObject->fldtype = "date";
00090 $oConvObject->value = $aParams['oxnews__oxdate'];
00091 $aParams['oxnews__oxdate'] = oxRegistry::get("oxUtilsDate")->convertDBDate( $oConvObject, true);
00092
00093 $oNews = oxNew( "oxnews" );
00094
00095 if ( $soxId != "-1")
00096 $oNews->loadInLang( $this->_iEditLang, $soxId );
00097 else
00098 $aParams['oxnews__oxid'] = null;
00099
00100
00101
00102
00103 $oNews->setLanguage(0);
00104 $oNews->assign( $aParams);
00105 $oNews->setLanguage($this->_iEditLang);
00106 $oNews->save();
00107
00108
00109 $this->setEditObjectId( $oNews->getId() );
00110 }
00111
00117 public function saveinnlang()
00118 {
00119 $soxId = $this->getEditObjectId();
00120 $aParams = oxConfig::getParameter( "editval");
00121
00122 if ( !isset( $aParams['oxnews__oxactive']))
00123 $aParams['oxnews__oxactive'] = 0;
00124
00125 parent::save();
00126
00127
00128 $sShopID = oxSession::getVar( "actshop");
00129 $aParams['oxnews__oxshopid'] = $sShopID;
00130
00131 if (!$aParams['oxnews__oxdate'])
00132 $aParams['oxnews__oxdate'] = "";
00133
00134 $oConvObject = new oxField();
00135 $oConvObject->fldmax_length = 0;
00136 $oConvObject->fldtype = "date";
00137 $oConvObject->value = $aParams['oxnews__oxdate'];
00138 $aParams['oxnews__oxdate'] = oxRegistry::get("oxUtilsDate")->convertDBDate( $oConvObject, true );
00139
00140 $oNews = oxNew( "oxnews" );
00141
00142 if ( $soxId != "-1")
00143 $oNews->loadInLang( $this->_iEditLang, $soxId );
00144 else
00145 $aParams['oxnews__oxid'] = null;
00146
00147
00148
00149 $oNews->setLanguage(0);
00150 $oNews->assign( $aParams);
00151
00152
00153 $oNews->setLanguage( oxConfig::getParameter( "new_lang" ) );
00154 $oNews->save();
00155
00156
00157 $this->setEditObjectId( $oNews->getId() );
00158 }
00159 }