news_main.php

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             // all usergroups
00028             $oGroups = oxNew( "oxlist" );
00029             $oGroups->init( "oxgroups" );
00030             $oGroups->selectString( "select * from oxgroups" );
00031 
00032         $soxId = oxConfig::getParameter( "oxid");
00033         // check if we right now saved a new entry
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             // for reloading upper frame
00040             $this->_aViewData["updatelist"] =  "1";
00041         }
00042 
00043         if ( $soxId != "-1" && isset( $soxId)) {
00044             // load object
00045             $oNews = oxNew( "oxnews" );
00046             $oNews->loadInLang( $this->_iEditLang, $soxId );
00047 
00048             $oOtherLang = $oNews->getAvailableInLangs();
00049             if (!isset($oOtherLang[$this->_iEditLang])) {
00050                 // echo "language entry doesn't exist! using: ".key($oOtherLang);
00051                 $oNews->loadInLang( key($oOtherLang), $soxId );
00052             }
00053             $this->_aViewData["edit"] =  $oNews;
00054 
00055 
00056             // remove already created languages
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         // checkbox handling
00088         if ( !isset( $aParams['oxnews__oxactive']))
00089             $aParams['oxnews__oxactive'] = 0;
00090 
00091             // shopid
00092             $sShopID = oxSession::getVar( "actshop");
00093             $aParams['oxnews__oxshopid'] = $sShopID;
00094         // creating fake object to save correct time value
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         //$aParams = $oNews->ConvertNameArray2Idx( $aParams);
00113 
00114         $oNews->setLanguage(0);
00115         $oNews->assign( $aParams);
00116         $oNews->setLanguage($this->_iEditLang);
00117         $oNews->save();
00118         $this->_aViewData["updatelist"] = "1";
00119 
00120         // set oxid if inserted
00121         if ( $soxId == "-1")
00122             oxSession::setVar( "saved_oxid", $oNews->oxnews__oxid->value);
00123     }
00124 
00130     public function saveinnlang()
00131     {
00132         $soxId      = oxConfig::getParameter( "oxid");
00133         $aParams    = oxConfig::getParameter( "editval");
00134         // checkbox handling
00135         if ( !isset( $aParams['oxnews__oxactive']))
00136             $aParams['oxnews__oxactive'] = 0;
00137 
00138 
00139             // shopid
00140             $sShopID = oxSession::getVar( "actshop");
00141             $aParams['oxnews__oxshopid'] = $sShopID;
00142         // creating fake object to save correct time value
00143         if (!$aParams['oxnews__oxdate'])
00144             $aParams['oxnews__oxdate'] = "";
00145 
00146         $oConvObject = new oxField();
00147         $oConvObject->fldmax_length = 0;
00148         $oConvObject->fldtype = "date";
00149         $oConvObject->value   = $aParams['oxnews__oxdate'];
00150         $aParams['oxnews__oxdate'] = oxDb::getInstance()->convertDBDate( $oConvObject, true );
00151 
00152         $oNews = oxNew( "oxnews" );
00153 
00154         if ( $soxId != "-1")
00155             $oNews->loadInLang( $this->_iEditLang, $soxId );
00156         else
00157             $aParams['oxnews__oxid'] = null;
00158 
00159 
00160         //$aParams = $oNews->ConvertNameArray2Idx( $aParams);
00161         $oNews->setLanguage(0);
00162         $oNews->assign( $aParams);
00163 
00164         // apply new language
00165         $sNewLanguage = oxConfig::getParameter( "new_lang");
00166         $oNews->setLanguage( $sNewLanguage);
00167         $oNews->save();
00168         $this->_aViewData["updatelist"] = "1";
00169 
00170         // set oxid if inserted
00171         if ( $soxId == "-1" ) {
00172             oxSession::setVar( "saved_oxid", $oNews->oxnews__oxid->value);
00173         }
00174     }
00175 }