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 ( oxLang::getInstance()->getLanguageNames(), $oOtherLang);
00048
00049 foreach ( $oOtherLang as $id => $language) {
00050 $oLang= new oxStdClass();
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
00058 $aColumns = array();
00059 include_once 'inc/'.strtolower(__CLASS__).'.inc.php';
00060 $this->_aViewData['oxajax'] = $aColumns;
00061
00062 return "popups/news_main.tpl";
00063 }
00064 return "news_main.tpl";
00065 }
00066
00072 public function save()
00073 {
00074 parent::save();
00075
00076 $soxId = $this->getEditObjectId();
00077 $aParams = oxConfig::getParameter( "editval");
00078
00079 if ( !isset( $aParams['oxnews__oxactive']))
00080 $aParams['oxnews__oxactive'] = 0;
00081
00082
00083 $sShopID = oxSession::getVar( "actshop");
00084 $aParams['oxnews__oxshopid'] = $sShopID;
00085
00086 if (!$aParams['oxnews__oxdate'])
00087 $aParams['oxnews__oxdate'] = "";
00088
00089 $oConvObject = new oxField();
00090 $oConvObject->fldmax_length = 0;
00091 $oConvObject->fldtype = "date";
00092 $oConvObject->value = $aParams['oxnews__oxdate'];
00093 $aParams['oxnews__oxdate'] = oxDb::getInstance()->convertDBDate( $oConvObject, true);
00094
00095 $oNews = oxNew( "oxnews" );
00096
00097 if ( $soxId != "-1")
00098 $oNews->loadInLang( $this->_iEditLang, $soxId );
00099 else
00100 $aParams['oxnews__oxid'] = null;
00101
00102
00103
00104
00105 $oNews->setLanguage(0);
00106 $oNews->assign( $aParams);
00107 $oNews->setLanguage($this->_iEditLang);
00108 $oNews->save();
00109
00110
00111 $this->setEditObjectId( $oNews->getId() );
00112 }
00113
00119 public function saveinnlang()
00120 {
00121 $soxId = $this->getEditObjectId();
00122 $aParams = oxConfig::getParameter( "editval");
00123
00124 if ( !isset( $aParams['oxnews__oxactive']))
00125 $aParams['oxnews__oxactive'] = 0;
00126
00127 parent::save();
00128
00129
00130 $sShopID = oxSession::getVar( "actshop");
00131 $aParams['oxnews__oxshopid'] = $sShopID;
00132
00133 if (!$aParams['oxnews__oxdate'])
00134 $aParams['oxnews__oxdate'] = "";
00135
00136 $oConvObject = new oxField();
00137 $oConvObject->fldmax_length = 0;
00138 $oConvObject->fldtype = "date";
00139 $oConvObject->value = $aParams['oxnews__oxdate'];
00140 $aParams['oxnews__oxdate'] = oxDb::getInstance()->convertDBDate( $oConvObject, true );
00141
00142 $oNews = oxNew( "oxnews" );
00143
00144 if ( $soxId != "-1")
00145 $oNews->loadInLang( $this->_iEditLang, $soxId );
00146 else
00147 $aParams['oxnews__oxid'] = null;
00148
00149
00150
00151 $oNews->setLanguage(0);
00152 $oNews->assign( $aParams);
00153
00154
00155 $oNews->setLanguage( oxConfig::getParameter( "new_lang" ) );
00156 $oNews->save();
00157
00158
00159 $this->setEditObjectId( $oNews->getId() );
00160 }
00161 }