00001 <?php
00002
00003
00004
00005
00006
00013 class News_Main extends oxAdminDetails
00014 {
00022 public function render()
00023 {
00024 $myConfig = $this->getConfig();
00025
00026 parent::render();
00027
00028
00029 $oGroups = oxNew( "oxlist" );
00030 $oGroups->init( "oxgroups" );
00031 $oGroups->selectString( "select * from oxgroups" );
00032 $soxId = oxConfig::getParameter( "oxid");
00033
00034 $sSavedID = oxConfig::getParameter( "saved_oxid");
00035 if ( ($soxId == "-1" || !isset( $soxId)) && isset( $sSavedID) ) {
00036 $soxId = $sSavedID;
00037 oxSession::deleteVar( "saved_oxid");
00038 $this->_aViewData["oxid"] = $soxId;
00039
00040 $this->_aViewData["updatelist"] = "1";
00041 }
00042
00043 if ( $soxId != "-1" && isset( $soxId)) {
00044
00045 $oNews = oxNew( "oxnews" );
00046 $oNews->loadInLang( $this->_iEditLang, $soxId );
00047
00048 $oOtherLang = $oNews->getAvailableInLangs();
00049 if (!isset($oOtherLang[$this->_iEditLang])) {
00050
00051 $oNews->loadInLang( key($oOtherLang), $soxId );
00052 }
00053 $this->_aViewData["edit"] = $oNews;
00054
00055
00056
00057 $this->_aViewData["posslang"] = array_diff ( oxLang::getInstance()->getLanguageNames(), $oOtherLang);
00058
00059 foreach ( $oOtherLang as $id => $language) {
00060 $oLang= new oxStdClass();
00061 $oLang->sLangDesc = $language;
00062 $oLang->selected = ($id == $this->_iEditLang);
00063 $this->_aViewData["otherlang"][$id] = clone $oLang;
00064 }
00065 }
00066 if ( oxConfig::getParameter("aoc") ) {
00067
00068 $aColumns = array();
00069 include_once 'inc/'.strtolower(__CLASS__).'.inc.php';
00070 $this->_aViewData['oxajax'] = $aColumns;
00071
00072 return "popups/news_main.tpl";
00073 }
00074 return "news_main.tpl";
00075 }
00076
00082 public function save()
00083 {
00084
00085 $soxId = oxConfig::getParameter( "oxid");
00086 $aParams = oxConfig::getParameter( "editval");
00087
00088 if ( !isset( $aParams['oxnews__oxactive']))
00089 $aParams['oxnews__oxactive'] = 0;
00090
00091
00092 $sShopID = oxSession::getVar( "actshop");
00093 $aParams['oxnews__oxshopid'] = $sShopID;
00094
00095 if (!$aParams['oxnews__oxdate'])
00096 $aParams['oxnews__oxdate'] = "";
00097
00098 $oConvObject = new oxField();
00099 $oConvObject->fldmax_length = 0;
00100 $oConvObject->fldtype = "date";
00101 $oConvObject->value = $aParams['oxnews__oxdate'];
00102 $aParams['oxnews__oxdate'] = oxDb::getInstance()->convertDBDate( $oConvObject, true);
00103
00104 $oNews = oxNew( "oxnews" );
00105
00106 if ( $soxId != "-1")
00107 $oNews->loadInLang( $this->_iEditLang, $soxId );
00108 else
00109 $aParams['oxnews__oxid'] = null;
00110
00111
00112
00113
00114 $oNews->setLanguage(0);
00115 $oNews->assign( $aParams);
00116 $oNews->setLanguage($this->_iEditLang);
00117 $oNews->save();
00118 $this->_aViewData["updatelist"] = "1";
00119
00120
00121 if ( $soxId == "-1")
00122 oxSession::setVar( "saved_oxid", $oNews->oxnews__oxid->value);
00123
00124 return $this->autosave();
00125 }
00126
00132 public function saveinnlang()
00133 {
00134 $soxId = oxConfig::getParameter( "oxid");
00135 $aParams = oxConfig::getParameter( "editval");
00136
00137 if ( !isset( $aParams['oxnews__oxactive']))
00138 $aParams['oxnews__oxactive'] = 0;
00139
00140
00141
00142 $sShopID = oxSession::getVar( "actshop");
00143 $aParams['oxnews__oxshopid'] = $sShopID;
00144
00145 if (!$aParams['oxnews__oxdate'])
00146 $aParams['oxnews__oxdate'] = "";
00147
00148 $oConvObject = new oxField();
00149 $oConvObject->fldmax_length = 0;
00150 $oConvObject->fldtype = "date";
00151 $oConvObject->value = $aParams['oxnews__oxdate'];
00152 $aParams['oxnews__oxdate'] = oxDb::getInstance()->convertDBDate( $oConvObject, true );
00153
00154 $oNews = oxNew( "oxnews" );
00155
00156 if ( $soxId != "-1")
00157 $oNews->loadInLang( $this->_iEditLang, $soxId );
00158 else
00159 $aParams['oxnews__oxid'] = null;
00160
00161
00162
00163 $oNews->setLanguage(0);
00164 $oNews->assign( $aParams);
00165
00166
00167 $sNewLanguage = oxConfig::getParameter( "new_lang");
00168 $oNews->setLanguage( $sNewLanguage);
00169 $oNews->save();
00170 $this->_aViewData["updatelist"] = "1";
00171
00172
00173 if ( $soxId == "-1")
00174 oxSession::setVar( "saved_oxid", $oNews->oxnews__oxid->value);
00175 }
00176 }