Permalink
Browse files

"La touche finale!"

  • Loading branch information...
1 parent e3a658c commit d71b318f5e057f6736b278fcc6ed30ac0ff9b5bc @rymai committed Feb 1, 2010
Showing with 1,488 additions and 552 deletions.
  1. +12 −0 icms-ejb/src/java/icms_controller/GestionnairePagesBean.java
  2. +6 −0 icms-ejb/src/java/icms_controller/GestionnairePagesLocal.java
  3. +1 −1 icms-ejb/src/java/icms_ejb/Page.java
  4. +1 −1 icms-war/src/java/icms_helper/FlickrHelper.java
  5. +7 −3 icms-war/src/java/icms_helper/IPHelper.java
  6. +2 −2 icms-war/src/java/icms_helper/WeatherHelper.java
  7. +82 −0 icms-war/src/java/icms_servlet/BaseServlet.java
  8. +11 −42 icms-war/src/java/icms_servlet/PagesServlet.java
  9. +1 −1 icms-war/src/java/icms_servlet/SessionsServlet.java
  10. +16 −16 icms-war/src/java/icms_servlet/admin/AdvertisementServlet.java
  11. +14 −13 icms-war/src/java/icms_servlet/admin/PagesServlet.java
  12. +21 −20 icms-war/src/java/icms_servlet/admin/UsersServlet.java
  13. +9 −6 icms-war/src/java/icms_util/HtmlUtil.java
  14. +24 −0 icms-war/web/WEB-INF/web.xml
  15. +0 −1 icms-war/web/admin/advertisement_edit.jsp
  16. +17 −18 icms-war/web/admin/advertisements.jsp
  17. +0 −1 icms-war/web/admin/article_edit.jsp
  18. +15 −13 icms-war/web/admin/articles.jsp
  19. +0 −59 icms-war/web/admin/categories.jsp
  20. +0 −44 icms-war/web/admin/category_edit.jsp
  21. +2 −2 icms-war/web/admin/footer_admin.jsp
  22. +0 −53 icms-war/web/admin/section_edit.jsp
  23. +0 −66 icms-war/web/admin/sections.jsp
  24. +0 −1 icms-war/web/admin/tinyMCE.html
  25. +9 −9 icms-war/web/admin/users.jsp
  26. +5 −3 icms-war/web/article.jsp
  27. +1 −1 icms-war/web/article_template.jsp
  28. +2 −13 icms-war/web/category.jsp
  29. +6 −0 icms-war/web/category_template.jsp
  30. +2 −2 icms-war/web/footer.jsp
  31. +12 −4 icms-war/web/header.jsp
  32. +761 −0 icms-war/web/js/FancyZoom.js
  33. +318 −0 icms-war/web/js/FancyZoomHTML.js
  34. +1 −1 icms-war/web/js/behaviours.js
  35. BIN icms-war/web/js/images/zoom/closebox.png
  36. BIN icms-war/web/js/images/zoom/spacer.gif
  37. BIN icms-war/web/js/images/zoom/zoom-caption-fill.png
  38. BIN icms-war/web/js/images/zoom/zoom-caption-l.png
  39. BIN icms-war/web/js/images/zoom/zoom-caption-r.png
  40. BIN icms-war/web/js/images/zoom/zoom-shadow1.png
  41. BIN icms-war/web/js/images/zoom/zoom-shadow2.png
  42. BIN icms-war/web/js/images/zoom/zoom-shadow3.png
  43. BIN icms-war/web/js/images/zoom/zoom-shadow4.png
  44. BIN icms-war/web/js/images/zoom/zoom-shadow5.png
  45. BIN icms-war/web/js/images/zoom/zoom-shadow6.png
  46. BIN icms-war/web/js/images/zoom/zoom-shadow7.png
  47. BIN icms-war/web/js/images/zoom/zoom-shadow8.png
  48. BIN icms-war/web/js/images/zoom/zoom-spin-1.png
  49. BIN icms-war/web/js/images/zoom/zoom-spin-10.png
  50. BIN icms-war/web/js/images/zoom/zoom-spin-11.png
  51. BIN icms-war/web/js/images/zoom/zoom-spin-12.png
  52. BIN icms-war/web/js/images/zoom/zoom-spin-2.png
  53. BIN icms-war/web/js/images/zoom/zoom-spin-3.png
  54. BIN icms-war/web/js/images/zoom/zoom-spin-4.png
  55. BIN icms-war/web/js/images/zoom/zoom-spin-5.png
  56. BIN icms-war/web/js/images/zoom/zoom-spin-6.png
  57. BIN icms-war/web/js/images/zoom/zoom-spin-7.png
  58. BIN icms-war/web/js/images/zoom/zoom-spin-8.png
  59. BIN icms-war/web/js/images/zoom/zoom-spin-9.png
  60. +13 −8 icms-war/web/liste_articles.jsp
  61. +9 −2 icms-war/web/liste_sections.jsp
  62. +4 −2 icms-war/web/partials/_article.jsp
  63. +17 −0 icms-war/web/partials/_category.jsp
  64. +5 −28 icms-war/web/partials/_section.jsp
  65. +2 −3 icms-war/web/section.jsp
  66. +6 −0 icms-war/web/section_template.jsp
  67. BIN icms-war/web/stylesheets/images/Thumbs.db
  68. BIN icms-war/web/stylesheets/images/delete.png
  69. BIN icms-war/web/stylesheets/images/{img03.gif → menu_li_hover.gif}
  70. +74 −113 icms-war/web/stylesheets/style.css
@@ -160,4 +160,16 @@ private String makePermalink(String text, int page_id) {
return perme + (r == 0 ? "" : r);
}
+
+ public boolean isCategory(int id) {
+ return parent(id) == null;
+ }
+
+ public boolean isSection(int id) {
+ return children(id) != null && children(id).size() > 0;
+ }
+
+ public boolean isArticle(int id) {
+ return children(id) == null || children(id).size() == 0;
+ }
}
@@ -34,4 +34,10 @@ public boolean update(int id, String title, String permalink, String intro,
public List<Page> allSections();
public List<Page> allArticles();
+
+ public boolean isCategory(int id);
+
+ public boolean isSection(int id);
+
+ public boolean isArticle(int id);
}
@@ -78,7 +78,7 @@ public void update(String title, String permalink, String intro, String content,
setContent(content);
setPreferedSex(prefered_sex);
updatedAt = GregorianCalendar.getInstance().getTime();
- myParent = parent;
+ setMyParent(parent);
}
@@ -47,7 +47,7 @@ public void searchFlickr() {
flickrResults += "<td id=\"flickr_" + p.getId() + "\" class=\"flickr_item\">";
- flickrResults += "<a href=\"" + p.getUrl() + "\"><img id=\"thumb_flickr_" + p.getId() + "\" class=\"flickr_thumb\" src=\"" + p.
+ flickrResults += "<a href=\"" + p.getMediumUrl() + "\" title=\""+p.getTitle()+"\"><img id=\"thumb_flickr_" + p.getId() + "\" class=\"flickr_thumb\" src=\"" + p.
getSmallSquareUrl() + "\"></a>";
// Description (caché)
@@ -1,5 +1,6 @@
package icms_helper;
+import com.maxmind.geoip.Location;
import com.maxmind.geoip.LookupService;
import icms_servlet.SessionsServlet;
import java.io.BufferedReader;
@@ -25,14 +26,17 @@ public IPHelper() throws MalformedURLException, IOException {
ip = in.readLine().trim();
if (ip.length() >= 27) {
ip = ip.substring(ip.length() - 27, ip.length() - 12);
- ip = ip.substring(ip.indexOf(">")).substring(2);
+ if(ip.indexOf(">") != -1) {
+ ip = ip.substring(ip.indexOf(">")).substring(2);
+ }
}
LookupService cl = new LookupService(data, LookupService.GEOIP_MEMORY_CACHE);
SessionsServlet.setToSession("ip", ip);
- country = cl.getLocation(ip).countryName;
+ Location loc = cl.getLocation(ip);
+ country = loc == null ? "" : cl.getLocation(ip).countryName;
SessionsServlet.setToSession("ipCountry", country);
- city = cl.getLocation(ip).city;
+ city = loc == null ? "" : cl.getLocation(ip).city;
SessionsServlet.setToSession("ipCity", city);
}
}
@@ -25,12 +25,12 @@ public WeatherHelper(String city) throws MalformedURLException, IOException,
}
public String currentCondition() {
- return currentConditions().getChildNodes().item(0).getAttributes().getNamedItem("data").
+ return currentConditions() == null ? "" : currentConditions().getChildNodes().item(0).getAttributes().getNamedItem("data").
getTextContent();
}
public String currentTemperature() {
- return currentConditions().getChildNodes().item(2).getAttributes().getNamedItem("data").
+ return currentConditions() == null ? "" : currentConditions().getChildNodes().item(2).getAttributes().getNamedItem("data").
getTextContent();
}
@@ -0,0 +1,82 @@
+package icms_servlet;
+
+import icms_controller.*;
+import java.io.IOException;
+import icms_ejb.*;
+import icms_helper.IPHelper;
+import icms_plugin.advertisement.GestionnaireAdvertisementsLocal;
+import javax.ejb.EJB;
+import javax.servlet.ServletException;
+import javax.servlet.http.*;
+
+public class BaseServlet extends HttpServlet {
+
+ @EJB
+ protected GestionnairePagesLocal gestionnairePages;
+ @EJB
+ protected GestionnaireUsersLocal gestionnaireUsers;
+ @EJB
+ protected GestionnaireAdvertisementsLocal gestionnaireAdvertisements;
+ // Not EJB
+ protected String pagePath;
+ // Priority for the action parameter passed by the page, not by the servlet config
+ protected int action;
+ protected User user;
+
+ protected void processRequest(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ response.setContentType("text/html;charset=UTF-8");
+ SessionsServlet.getSession(request);
+ user = SessionsServlet.getUserFromSession(gestionnaireUsers);
+ request.setAttribute("current_user", user);
+
+ action = request.getParameter("action") != null ? Integer.parseInt(request.getParameter(
+ "action")) : getServletConfig().getInitParameter("action") != null ? Integer.
+ parseInt(getServletConfig().
+ getInitParameter("action")) : -1;
+
+ if (gestionnaireUsers.findAdmins().size() == 0) {
+ gestionnaireUsers.creerAdmin();
+ }
+
+ request.setAttribute("url", request.getRequestURL().toString());
+
+ new IPHelper();
+ }
+
+ // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
+ /**
+ * Handles the HTTP <code>GET</code> method.
+ * @param request servlet request
+ * @param response servlet response
+ * @throws ServletException if a servlet-specific error occurs
+ * @throws IOException if an I/O error occurs
+ */
+ @Override
+ protected void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ processRequest(request, response);
+ }
+
+ /**
+ * Handles the HTTP <code>POST</code> method.
+ * @param request servlet request
+ * @param response servlet response
+ * @throws ServletException if a servlet-specific error occurs
+ * @throws IOException if an I/O error occurs
+ */
+ @Override
+ protected void doPost(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+ processRequest(request, response);
+ }
+
+ /**
+ * Returns a short description of the servlet.
+ * @return a String containing servlet description
+ */
+ @Override
+ public String getServletInfo() {
+ return "Short description";
+ }// </editor-fold>
+}
@@ -1,53 +1,27 @@
package icms_servlet;
-import icms_plugin.advertisement.GestionnaireAdvertisementsLocal;
-import icms_controller.*;
import icms_ejb.*;
import icms_util.*;
import java.util.*;
-import javax.ejb.EJB;
import javax.servlet.*;
import javax.servlet.http.*;
-import icms_helper.IPHelper;
import java.io.*;
-public class PagesServlet extends HttpServlet {
-
- @EJB
- private GestionnairePagesLocal gestionnairePages;
- @EJB
- private GestionnaireUsersLocal gestionnaireUsers;
- @EJB
- private GestionnaireAdvertisementsLocal gestionnaireAdvertisements;
- // Not EJB
- private String pagePath;
+public class PagesServlet extends BaseServlet {
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
- response.setContentType("text/html;charset=UTF-8");
-
- SessionsServlet.getSession(request);
- User u = SessionsServlet.getUserFromSession(gestionnaireUsers);
- request.setAttribute("current_user", u);
+ super.processRequest(request, response);
- if (u == null) {
- User user = gestionnaireUsers.findAdminByLoginAndPassword("admin", "admin");
+ if (user == null) {
+ user = gestionnaireUsers.findAdminByLoginAndPassword("admin", "admin");
if (user != null) {
SessionsServlet.setUserToSession(user);
response.sendRedirect("/icms-war/admin/articles");
return;
}
}
- if (gestionnaireUsers.findAdmins().size() == 0) {
- gestionnaireUsers.creerAdmin();
- }
-
- // Priority for the action parameter passed by the page, not by the servlet config
- int action = request.getParameter("action") != null ? Integer.parseInt(request.getParameter(
- "action")) : getServletConfig().getInitParameter("action") != null ? Integer.
- parseInt(getServletConfig().
- getInitParameter("action")) : -1;
List<Page> sections = new ArrayList<Page>();
List<Page> articles = new ArrayList<Page>();
@@ -59,25 +33,22 @@ protected void processRequest(HttpServletRequest request, HttpServletResponse re
Page pageLoad = gestionnairePages.findByPermalink(perme);
if (pageLoad != null) {
- List<Page> myChildren = gestionnairePages.children((int) pageLoad.getId());
- Page myParent = ((Page) pageLoad).getMyParent();
-
- if (myChildren == null || myChildren.size() == 0) { // ARTICLE
+ int page_id = (int) pageLoad.getId();
+ if (gestionnairePages.isArticle(page_id)) { // ARTICLE
// AJAX or not
pagePath = RequestUtil.isAjaxRequest(request) ? "partials/_article.jsp" : "article.jsp";
- } else if (myParent != null) { // SECTION
- for (Page a : myChildren) {
- if (gestionnairePages.children(a.getId()) != null && gestionnairePages.
- children(a.getId()).size() > 0) {
+ } else if (gestionnairePages.isSection(page_id)) { // SECTION
+ for (Page a : gestionnairePages.children(page_id)) {
+ if (gestionnairePages.isSection(a.getId())) {
sections.add(a);
} else {
articles.add(a);
}
}
pagePath = "section.jsp";
- } else if (myParent == null) { // CATEGORY
+ } else if (gestionnairePages.isCategory(page_id)) { // CATEGORY
sections = gestionnairePages.children(pageLoad.getId());
pagePath = "category.jsp";
}
@@ -94,11 +65,9 @@ protected void processRequest(HttpServletRequest request, HttpServletResponse re
}
request.setAttribute("listCategories", gestionnairePages.allRoots());
request.setAttribute("listSections", sections);
- request.setAttribute("listPages", articles);
+ request.setAttribute("listArticles", articles);
request.setAttribute("listAdvertisements", gestionnaireAdvertisements.allAdvertisements());
- new IPHelper();
-
RequestDispatcher dp = request.getRequestDispatcher("/" + pagePath);
dp.forward(request, response);
@@ -43,7 +43,7 @@ protected void processRequest(HttpServletRequest request, HttpServletResponse re
break;
case Config.DESTROY:
- session.removeAttribute("user_id");
+ if(session != null) session.removeAttribute("user_id");
if (gestionnaireSessions.destroy()) {
response.sendRedirect("/icms-war/articles");
request.setAttribute("flash", "Vous êtes maintenant délogué!");
@@ -12,28 +12,28 @@
import javax.servlet.ServletException;
import javax.servlet.http.*;
-public class AdvertisementServlet extends HttpServlet {
+public class AdvertisementServlet extends BaseServlet {
- @EJB
- private GestionnaireAdvertisementsLocal gestionnaireAdvertisements;
- @EJB
- private GestionnaireUsersLocal gestionnaireUsers;
- // Not EJB
- private String page;
+// @EJB
+// private GestionnaireAdvertisementsLocal gestionnaireAdvertisements;
+// @EJB
+// private GestionnaireUsersLocal gestionnaireUsers;
+// // Not EJB
+// private String page;
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
- response.setContentType("text/html;charset=UTF-8");
+ super.processRequest(request, response);
if (!SecurityUtil.checkUserIsAuthenticated(request, response, gestionnaireUsers)) {
return;
}
// Priority for the action parameter passed by the page, not by the servlet config
- int action = request.getParameter("action") != null ? Integer.parseInt(request.getParameter(
- "action")) : getServletConfig().getInitParameter("action") != null ? Integer.
- parseInt(getServletConfig().
- getInitParameter("action")) : -1;
+// int action = request.getParameter("action") != null ? Integer.parseInt(request.getParameter(
+// "action")) : getServletConfig().getInitParameter("action") != null ? Integer.
+// parseInt(getServletConfig().
+// getInitParameter("action")) : -1;
switch (action) {
case Config.CREATE:
@@ -50,7 +50,7 @@ protected void processRequest(HttpServletRequest request, HttpServletResponse re
case Config.EDIT:
request.setAttribute("advertisement", gestionnaireAdvertisements.find(Integer.parseInt(
request.getParameter("id"))));
- page = "admin/advertisement_edit.jsp";
+ pagePath = "admin/advertisement_edit.jsp";
break;
case Config.UPDATE:
@@ -61,21 +61,21 @@ protected void processRequest(HttpServletRequest request, HttpServletResponse re
request.getParameter("service"),
request.getParameter("criteria"),
request.getParameter("criteria_value"));
- page = "admin/advertisements.jsp";
+ pagePath = "admin/advertisements.jsp";
break;
case Config.DESTROY:
gestionnaireAdvertisements.destroy(Integer.parseInt(request.getParameter("id")));
break;
default:
- page = "admin/advertisements.jsp"; // render
+ pagePath = "admin/advertisements.jsp"; // render
break;
}
request.setAttribute("listeAdvertisements", gestionnaireAdvertisements.allAdvertisements());
- RequestDispatcher dp = request.getRequestDispatcher("/" + page);
+ RequestDispatcher dp = request.getRequestDispatcher("/" + pagePath);
dp.forward(request, response);
}
Oops, something went wrong.

0 comments on commit d71b318

Please sign in to comment.