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         $soxId = oxConfig::getParameter( "oxid");
00032         // check if we right now saved a new entry
00033         $sSavedID = oxConfig::getParameter( "saved_oxid");
00034         if ( ($soxId == "-1" || !isset( $soxId)) && isset( $sSavedID) ) {
00035             $soxId = $sSavedID;
00036             oxSession::deleteVar( "saved_oxid");
00037             $this->_aViewData["oxid"] =  $soxId;
00038             // for reloading upper frame
00039             $this->_aViewData["updatelist"] =  "1";
00040         }
00041 
00042         if ( $soxId != "-1" && isset( $soxId)) {
00043             // load object
00044             $oNews = oxNew( "oxnews" );
00045             $oNews->loadInLang( $this->_iEditLang, $soxId );
00046 
00047             $oOtherLang = $oNews->getAvailableInLangs();
00048             if (!isset($oOtherLang[$this->_iEditLang])) {
00049                 // echo "language entry doesn't exist! using: ".key($oOtherLang);
00050                 $oNews->loadInLang( key($oOtherLang), $soxId );
00051             }
00052             $this->_aViewData["edit"] =  $oNews;
00053 
00054 
00055             // remove already created languages
00056             $this->_aViewData["posslang"] =  array_diff ( oxLang::getInstance()->getLanguageNames(), $oOtherLang);
00057 
00058             foreach ( $oOtherLang as $id => $language) {
00059                 $oLang= new oxStdClass();
00060                 $oLang->sLangDesc = $language;
00061                 $oLang->selected = ($id == $this->_iEditLang);
00062                 $this->_aViewData["otherlang"][$id] = clone $oLang;
00063             }
00064         }
00065         if ( oxConfig::getParameter("aoc") ) {
00066 
00067             $aColumns = array();
00068             include_once 'inc/'.strtolower(__CLASS__).'.inc.php';
00069             $this->_aViewData['oxajax'] = $aColumns;
00070 
00071             return "popups/news_main.tpl";
00072         }
00073         return "news_main.tpl";
00074     }
00075 
00081     public function save()
00082     {
00083 
00084         $soxId      = oxConfig::getParameter( "oxid");
00085         $aParams    = oxConfig::getParameter( "editval");
00086         // checkbox handling
00087         if ( !isset( $aParams['oxnews__oxactive']))
00088             $aParams['oxnews__oxactive'] = 0;
00089 
00090             // shopid
00091             $sShopID = oxSession::getVar( "actshop");
00092             $aParams['oxnews__oxshopid'] = $sShopID;
00093         // creating fake object to save correct time value
00094         if (!$aParams['oxnews__oxdate'])
00095             $aParams['oxnews__oxdate'] = "";
00096 
00097         $oConvObject = new oxField();
00098         $oConvObject->fldmax_length = 0;
00099         $oConvObject->fldtype = "date";
00100         $oConvObject->value   = $aParams['oxnews__oxdate'];
00101         $aParams['oxnews__oxdate'] = oxDb::getInstance()->convertDBDate( $oConvObject, true);
00102 
00103         $oNews = oxNew( "oxnews" );
00104 
00105         if ( $soxId != "-1")
00106             $oNews->loadInLang( $this->_iEditLang, $soxId );
00107         else
00108             $aParams['oxnews__oxid'] = null;
00109 
00110 
00111         //$aParams = $oNews->ConvertNameArray2Idx( $aParams);
00112 
00113         $oNews->setLanguage(0);
00114         $oNews->assign( $aParams);
00115         $oNews->setLanguage($this->_iEditLang);
00116         $oNews->save();
00117         $this->_aViewData["updatelist"] = "1";
00118 
00119         // set oxid if inserted
00120         if ( $soxId == "-1")
00121             oxSession::setVar( "saved_oxid", $oNews->oxnews__oxid->value);
00122     }
00123 
00129     public function saveinnlang()
00130     {
00131         $soxId      = oxConfig::getParameter( "oxid");
00132         $aParams    = oxConfig::getParameter( "editval");
00133         // checkbox handling
00134         if ( !isset( $aParams['oxnews__oxactive']))
00135             $aParams['oxnews__oxactive'] = 0;
00136 
00137 
00138             // shopid
00139             $sShopID = oxSession::getVar( "actshop");
00140             $aParams['oxnews__oxshopid'] = $sShopID;
00141         // creating fake object to save correct time value
00142         if (!$aParams['oxnews__oxdate'])
00143             $aParams['oxnews__oxdate'] = "";
00144 
00145         $oConvObject = new oxField();
00146         $oConvObject->fldmax_length = 0;
00147         $oConvObject->fldtype = "date";
00148         $oConvObject->value   = $aParams['oxnews__oxdate'];
00149         $aParams['oxnews__oxdate'] = oxDb::getInstance()->convertDBDate( $oConvObject, true );
00150 
00151         $oNews = oxNew( "oxnews" );
00152 
00153         if ( $soxId != "-1")
00154             $oNews->loadInLang( $this->_iEditLang, $soxId );
00155         else
00156             $aParams['oxnews__oxid'] = null;
00157 
00158 
00159         //$aParams = $oNews->ConvertNameArray2Idx( $aParams);
00160         $oNews->setLanguage(0);
00161         $oNews->assign( $aParams);
00162 
00163         // apply new language
00164         $sNewLanguage = oxConfig::getParameter( "new_lang");
00165         $oNews->setLanguage( $sNewLanguage);
00166         $oNews->save();
00167         $this->_aViewData["updatelist"] = "1";
00168 
00169         // set oxid if inserted
00170         if ( $soxId == "-1")
00171             oxSession::setVar( "saved_oxid", $oNews->oxnews__oxid->value);
00172     }
00173 }

Generated on Tue Sep 29 16:45:12 2009 for OXID eShop CE by  doxygen 1.5.5