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 ".getViewName( "oxgroups", $this->_iEditLang ) );
00031 
00032         $soxId = $this->_aViewData["oxid"] = $this->getEditObjectId();
00033         if ( $soxId != "-1" && isset( $soxId)) {
00034             // load object
00035             $oNews = oxNew( "oxnews" );
00036             $oNews->loadInLang( $this->_iEditLang, $soxId );
00037 
00038             $oOtherLang = $oNews->getAvailableInLangs();
00039             if (!isset($oOtherLang[$this->_iEditLang])) {
00040                 // echo "language entry doesn't exist! using: ".key($oOtherLang);
00041                 $oNews->loadInLang( key($oOtherLang), $soxId );
00042             }
00043             $this->_aViewData["edit"] =  $oNews;
00044 
00045 
00046             // remove already created languages
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 
00075         $soxId = $this->getEditObjectId();
00076         $aParams = oxConfig::getParameter( "editval");
00077         // checkbox handling
00078         if ( !isset( $aParams['oxnews__oxactive']))
00079             $aParams['oxnews__oxactive'] = 0;
00080 
00081             // shopid
00082             $sShopID = oxSession::getVar( "actshop");
00083             $aParams['oxnews__oxshopid'] = $sShopID;
00084         // creating fake object to save correct time value
00085         if (!$aParams['oxnews__oxdate'])
00086             $aParams['oxnews__oxdate'] = "";
00087 
00088         $oConvObject = new oxField();
00089         $oConvObject->fldmax_length = 0;
00090         $oConvObject->fldtype = "date";
00091         $oConvObject->value   = $aParams['oxnews__oxdate'];
00092         $aParams['oxnews__oxdate'] = oxDb::getInstance()->convertDBDate( $oConvObject, true);
00093 
00094         $oNews = oxNew( "oxnews" );
00095 
00096         if ( $soxId != "-1")
00097             $oNews->loadInLang( $this->_iEditLang, $soxId );
00098         else
00099             $aParams['oxnews__oxid'] = null;
00100 
00101 
00102         //$aParams = $oNews->ConvertNameArray2Idx( $aParams);
00103 
00104         $oNews->setLanguage(0);
00105         $oNews->assign( $aParams);
00106         $oNews->setLanguage($this->_iEditLang);
00107         $oNews->save();
00108 
00109         // set oxid if inserted
00110         $this->setEditObjectId( $oNews->getId() );
00111     }
00112 
00118     public function saveinnlang()
00119     {
00120         $soxId = $this->getEditObjectId();
00121         $aParams = oxConfig::getParameter( "editval");
00122         // checkbox handling
00123         if ( !isset( $aParams['oxnews__oxactive']))
00124             $aParams['oxnews__oxactive'] = 0;
00125 
00126 
00127             // shopid
00128             $sShopID = oxSession::getVar( "actshop");
00129             $aParams['oxnews__oxshopid'] = $sShopID;
00130         // creating fake object to save correct time value
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'] = oxDb::getInstance()->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         //$aParams = $oNews->ConvertNameArray2Idx( $aParams);
00149         $oNews->setLanguage(0);
00150         $oNews->assign( $aParams);
00151 
00152         // apply new language
00153         $oNews->setLanguage( oxConfig::getParameter( "new_lang" ) );
00154         $oNews->save();
00155 
00156         // set oxid if inserted
00157         $this->setEditObjectId( $oNews->getId() );
00158     }
00159 }