KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > geinuke > module > admin > home > HomePage


1
2  /*
3  -- GeiNuke --
4 Copyright (c) 2005 by Roberto Sidoti [geinuke@users.sourceforge.net]
5  http://www.hostingjava.it/-geinuke/
6
7 This file is part of GeiNuke.
8
9     GeiNuke is free software; you can redistribute it and/or modify
10     it under the terms of the GNU General Public License as published by
11     the Free Software Foundation; either version 2 of the License, or
12     (at your option) any later version.
13
14     GeiNuke is distributed in the hope that it will be useful,
15     but WITHOUT ANY WARRANTY; without even the implied warranty of
16     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17     GNU General Public License for more details.
18
19     You should have received a copy of the GNU General Public License
20     along with GeiNuke; if not, write to the Free Software
21     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 */

23 package com.geinuke.module.admin.home;
24
25 import java.util.ArrayList JavaDoc;
26 import java.util.Enumeration JavaDoc;
27 import java.util.Locale JavaDoc;
28
29 import javax.servlet.http.HttpServletRequest JavaDoc;
30 import javax.servlet.http.HttpServletResponse JavaDoc;
31
32 import org.apache.velocity.context.Context;
33
34 import com.geinuke.bizlogic.BlockBL;
35 import com.geinuke.bizlogic.ModuleBL;
36 import com.geinuke.common.EditorFactory;
37 import com.geinuke.common.GlobalConfigurationI;
38 import com.geinuke.common.ModuleWidgetI;
39 import com.geinuke.common.NukeModuleI;
40 import com.geinuke.common.UserI;
41 import com.geinuke.middle.IBlockBL;
42 import com.geinuke.middle.IModuleBL;
43 import com.geinuke.middle.IPortalCFGBL;
44 import com.geinuke.middle.IUserBL;
45 import com.geinuke.module.ModuleWriter;
46 import com.geinuke.servlet.GeiServlet;
47 import com.geinuke.util.NukeResource;
48 import com.geinuke.util.TextUtil;
49 import com.geinuke.vo.BlockDBVO;
50 import com.geinuke.vo.ModuleDBVO;
51 import com.geinuke.vo.PortalCFGVO;
52
53
54 public class HomePage implements ModuleWidgetI{
55
56     public NukeModuleI handleAction(ModuleDBVO module, Context ctx,HttpServletRequest JavaDoc req, HttpServletResponse JavaDoc res, UserI user, GlobalConfigurationI gConf) throws Exception JavaDoc {
57         ArrayList JavaDoc list=null;
58         String JavaDoc moduleTempName=null;
59         String JavaDoc upd=req.getParameter("upd");
60         PortalCFGVO po=null;
61         IPortalCFGBL pbl=(IPortalCFGBL)GeiServlet.getBL("IPortalCFGBL");
62         po=pbl.getPortalCFG();
63         
64         /*
65         String path=GeiServlet.getNukePath();
66         String style=po.getPortalStyle();
67         path=path+"/WEB-INF/templates/themes/";
68         list=NukeResource.getDirectories(path);
69         ctx.put("style",style);
70         ctx.put("themes",list);
71         */

72         
73         //System.out.println("\nHomePage.handleHaction A"+po.getSessionHits());
74
if(upd!=null){
75             String JavaDoc smtpHost=req.getParameter("smtphost");
76             String JavaDoc portalEmail=req.getParameter("portalemail");
77             String JavaDoc portalTitle=req.getParameter("portaltitle");
78             String JavaDoc homeText=req.getParameter("hometext");
79             String JavaDoc portalStyle=req.getParameter("pStyle");
80             String JavaDoc portalLogo=req.getParameter("portalLogo");
81             String JavaDoc portalLocale=req.getParameter("portalLocale");
82             String JavaDoc portalURL=req.getParameter("portalUrl");
83             String JavaDoc sessionHits=req.getParameter("sessionHits");
84             
85             IBlockBL bbl=(IBlockBL)GeiServlet.getBL("IBlockBL");
86             BlockDBVO blo=null;
87             if(! TextUtil.isEmpty( portalStyle)){
88                 GeiServlet.fixStyle(req.getSession(true),portalStyle);
89                 IUserBL ubl=(IUserBL)GeiServlet.getBL("IUserBL");
90                 ubl.updateAllDefStyle(portalStyle);
91                 blo=bbl.getBlockByName("ChangeTheme");
92                 if(blo.isActive()){
93                     bbl.updateSingleBlock(blo.getId(),"active");
94                 }
95             }
96             if(! TextUtil.isEmpty( portalLocale)){
97                 
98                 blo=bbl.getBlockByName("Languages");
99                 if(blo.isActive()){
100                     bbl.updateSingleBlock(blo.getId(),"active");
101                 }
102             }
103             //po=new PortalCFGVO();
104
//if(!homeText.trim().equals(""))
105
po.setHomeText(homeText.trim());
106             po.setPortalEmail(portalEmail);
107             po.setPortalTitle(portalTitle);
108             po.setSmtpHost(smtpHost);
109             po.setPortalStyle(portalStyle);
110             po.setPortalLocale(portalLocale);
111             po.setPortalURL(portalURL);
112             po.setPortalLogo(portalLogo);
113             try{
114                 po.setSessionHits( Integer.parseInt(sessionHits) );
115             }catch(Exception JavaDoc nop){}
116             
117             //System.out.println("\nHomePage.handleHaction B"+po.getSessionHits());
118
pbl.updatePortalCFG(po);
119             //System.out.println("\nHomePage.handleHaction C"+po.getSessionHits());
120
}
121         po=pbl.getPortalCFG();
122         
123         String JavaDoc path=GeiServlet.getNukePath();
124         String JavaDoc style=po.getPortalStyle();
125         path=path+"/WEB-INF/templates/themes/";
126         list=NukeResource.getDirectories(path);
127         ctx.put("style",style);
128         ctx.put("themes",list);
129         
130         String JavaDoc ind=NukeResource.getLocale(req,res).getLanguage();
131         String JavaDoc target=null,aux=null;
132         Locale JavaDoc loc=null,xx=null;
133         if(! TextUtil.isEmpty(po.getPortalLocale() )){
134             ind=((Locale JavaDoc)NukeResource.locales.get(po.getPortalLocale())).getLanguage();
135         
136             Enumeration JavaDoc en=NukeResource.locales.keys();
137             
138             
139             while(en.hasMoreElements() && target==null){
140                 aux=(String JavaDoc)en.nextElement();
141                 loc=(Locale JavaDoc)NukeResource.locales.get(aux);
142                 target=loc.getLanguage();
143                 if(target.equals(ind)){
144                     target=aux;
145                     xx=loc;
146                 }else{
147                     target=null;
148                 }
149             }
150             NukeResource.cache.put("Locale",xx);
151         }else{
152             target="";
153             NukeResource.cache.remove("Locale");
154         }
155         
156         
157         ctx.put("lang",target);
158         ctx.put("languages",NukeResource.locales.keys());
159         ctx.put("locales",NukeResource.locales);
160         //System.out.println("\nHomePage.handleHaction D"+po.getSessionHits());
161
EditorFactory ef=new EditorFactory(req,"");
162         
163         ctx.put("factory",ef);
164         ctx.put("cfg",po);
165         
166         moduleTempName=gConf.getModulePage(module.getName(),req);
167         return ModuleWriter.fill(ctx,module,moduleTempName);
168     }
169
170 }
171
Popular Tags