news_main.php

Go to the documentation of this file.
00001 <?php
00002 
00003 
00009 class News_Main extends oxAdminDetails
00010 {
00011 
00019     public function render()
00020     {
00021         $myConfig = $this->getConfig();
00022 
00023         parent::render();
00024 
00025         // all usergroups
00026         $oGroups = oxNew("oxlist");
00027         $oGroups->init("oxgroups");
00028         $oGroups->selectString("select * from " . getViewName("oxgroups", $this->_iEditLang));
00029 
00030         $soxId = $this->_aViewData["oxid"] = $this->getEditObjectId();
00031         if ($soxId != "-1" && isset($soxId)) {
00032             // load object
00033             $oNews = oxNew("oxnews");
00034             $oNews->loadInLang($this->_iEditLang, $soxId);
00035 
00036             $oOtherLang = $oNews->getAvailableInLangs();
00037             if (!isset($oOtherLang[$this->_iEditLang])) {
00038                 // echo "language entry doesn't exist! using: ".key($oOtherLang);
00039                 $oNews->loadInLang(key($oOtherLang), $soxId);
00040             }
00041             $this->_aViewData["edit"] = $oNews;
00042 
00043 
00044             // remove already created languages
00045             $this->_aViewData["posslang"] = array_diff(oxRegistry::getLang()->getLanguageNames(), $oOtherLang);
00046 
00047             foreach ($oOtherLang as $id => $language) {
00048                 $oLang = new stdClass();
00049                 $oLang->sLangDesc = $language;
00050                 $oLang->selected = ($id == $this->_iEditLang);
00051                 $this->_aViewData["otherlang"][$id] = clone $oLang;
00052             }
00053         }
00054         if (oxRegistry::getConfig()->getRequestParameter("aoc")) {
00055             $oNewsMainAjax = oxNew('news_main_ajax');
00056             $this->_aViewData['oxajax'] = $oNewsMainAjax->getColumns();
00057 
00058             return "popups/news_main.tpl";
00059         }
00060 
00061         return "news_main.tpl";
00062     }
00063 
00069     public function save()
00070     {
00071         parent::save();
00072 
00073         $soxId = $this->getEditObjectId();
00074         $aParams = oxRegistry::getConfig()->getRequestParameter("editval");
00075         // checkbox handling
00076         if (!isset($aParams['oxnews__oxactive'])) {
00077             $aParams['oxnews__oxactive'] = 0;
00078         }
00079 
00080         // shopid
00081         $sShopID = oxRegistry::getSession()->getVariable("actshop");
00082         $aParams['oxnews__oxshopid'] = $sShopID;
00083         // creating fake object to save correct time value
00084         if (!$aParams['oxnews__oxdate']) {
00085             $aParams['oxnews__oxdate'] = "";
00086         }
00087 
00088         $oConvObject = new oxField();
00089         $oConvObject->fldmax_length = 0;
00090         $oConvObject->fldtype = "date";
00091         $oConvObject->value = $aParams['oxnews__oxdate'];
00092         $aParams['oxnews__oxdate'] = oxRegistry::get("oxUtilsDate")->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 
00103         //$aParams = $oNews->ConvertNameArray2Idx( $aParams);
00104 
00105         $oNews->setLanguage(0);
00106         $oNews->assign($aParams);
00107         $oNews->setLanguage($this->_iEditLang);
00108         $oNews->save();
00109 
00110         // set oxid if inserted
00111         $this->setEditObjectId($oNews->getId());
00112     }
00113 
00119     public function saveinnlang()
00120     {
00121         $soxId = $this->getEditObjectId();
00122         $aParams = oxRegistry::getConfig()->getRequestParameter("editval");
00123         // checkbox handling
00124         if (!isset($aParams['oxnews__oxactive'])) {
00125             $aParams['oxnews__oxactive'] = 0;
00126         }
00127 
00128         parent::save();
00129 
00130         // shopid
00131         $sShopID = oxRegistry::getSession()->getVariable("actshop");
00132         $aParams['oxnews__oxshopid'] = $sShopID;
00133         // creating fake object to save correct time value
00134         if (!$aParams['oxnews__oxdate']) {
00135             $aParams['oxnews__oxdate'] = "";
00136         }
00137 
00138         $oConvObject = new oxField();
00139         $oConvObject->fldmax_length = 0;
00140         $oConvObject->fldtype = "date";
00141         $oConvObject->value = $aParams['oxnews__oxdate'];
00142         $aParams['oxnews__oxdate'] = oxRegistry::get("oxUtilsDate")->convertDBDate($oConvObject, true);
00143 
00144         $oNews = oxNew("oxnews");
00145 
00146         if ($soxId != "-1") {
00147             $oNews->loadInLang($this->_iEditLang, $soxId);
00148         } else {
00149             $aParams['oxnews__oxid'] = null;
00150         }
00151 
00152 
00153         //$aParams = $oNews->ConvertNameArray2Idx( $aParams);
00154         $oNews->setLanguage(0);
00155         $oNews->assign($aParams);
00156 
00157         // apply new language
00158         $oNews->setLanguage(oxRegistry::getConfig()->getRequestParameter("new_lang"));
00159         $oNews->save();
00160 
00161         // set oxid if inserted
00162         $this->setEditObjectId($oNews->getId());
00163     }
00164 }