<% /****************************************************************************** * Copyright (c) 2000-2006 e-Deal * * e-Deal S.A. * 55 rue Brillat Savarin * 75013 Paris * France * * T: +33 (0)1 53 80 80 30 * F: +33 (0)1 73 01 69 77 * http://www.e-deal.com * * La diffusion de ce code source sous quelque forme que ce soit sans * l'autorisation de E-DEAL est interdite. * * Vous êtes autorisés à modifier ce code source uniquement pour votre usage * propre et sous réserve que les mentions de copyright demeurent intactes. * * Ce code est fourni en l'état. Aucune garantie d'aucune sorte, explicite ou * implicite n'est donnée. En aucun cas E-DEAL ne pourra être tenu pour * responsable des dommages pouvant résulter de l'utilisation de ce code * source. ******************************************************************************/ %><%@page session="true" contentType="text/plain;charset=UTF-8"%> <%@ page import="com.edeal.frontline.*" %> <%@ page import="com.edeal.frontline.navigation.FlRequest" %> <%@ page import="java.util.Vector" %> <%@ page import="java.util.Hashtable" %> <%@ page import="java.text.DecimalFormat" %> <%@ page import="com.edeal.frontline.FlLocale" %> <%@ page import="com.edeal.frontline.Utils" %> <% final org.apache.commons.logging.Log logger = org.apache.commons.logging.LogFactory.getLog(getClass()); FlRequest flRequest = new FlRequest(request); FlContext context = flRequest.getContext(); boolean isOracle = "Oracle".equalsIgnoreCase(context.getContextParameter("DatabaseVendor")); Vector pages = (Vector)flRequest.getAttribute("pages"); String id = (String)flRequest.getAttribute("id"); StringBuffer tableBuf = new StringBuffer(); tableBuf.append(""); boolean isBlue = true; if (id != null) { boolean pageMode = false; if (pages != null && pages.size() > 0) { pageMode = true; } if (pageMode) { String[] lseFields = {"LseID" , "LseScriptElementID" , "LseScriptElementID:SceLabel", "LsePosition", "LsePageID", "LsePageID:ScpCode", "LsePageID:ScpTitre", "LsePageID:ScpPosition"}; String[][] lseQuery = {{"LseScriptID = " + Utils.formatToSQL(context, id)}}; String[] lseOrderBy = {"LsePageID:ScpPosition", "LsePosition"}; Vector elements = LinkScriptElementBean.listSummary(session, lseFields, lseQuery, lseOrderBy); String oldPageID = ""; Vector usedPages = new Vector(); tableBuf.append(""); tableBuf.append(""); } else { //get all script elements linked to this script, and for each one, count the number of transitions String query; if (isOracle) { query = "SELECT LseID, LseScriptElementID, SceLabel, LsePosition, COUNT(SetID)\n" + "FROM LinkScriptElement, ScriptElement, ScriptElementTransition\n" + "WHERE LseScriptElementID = SceID (+)\n" + "AND LseID = SetLse1ID (+)\n" + "AND LseScriptID = " + Utils.formatToSQL(context, id) + "\n" + "GROUP BY LseID, LseScriptElementID, SceLabel, LsePosition\n" + "ORDER BY LsePosition\n"; } else { query = "SELECT LseID, LseScriptElementID, SceLabel, LsePosition, COUNT(SetID)\n" + "FROM LinkScriptElement\n" + "LEFT OUTER JOIN ScriptElement ON SceID = LseScriptElementID\n" + "LEFT OUTER JOIN ScriptElementTransition ON SetLse1ID = LseID\n" + "WHERE LseScriptID = " + Utils.formatToSQL(context, id) + "\n" + "GROUP BY LseID, LseScriptElementID, SceLabel, LsePosition\n" + "ORDER BY LsePosition\n"; } String[] fields = {"LseID" , "LseScriptElementID" , "LseScriptElementID:SceLabel", "LsePosition", "CountTransitions"}; Vector linksList = LinkScriptElementBean.listSQL(session, fields, query); if (linksList != null && linksList.size() > 0) { tableBuf.append(""); } else { tableBuf.append(""); tableBuf.append(""); } } } tableBuf.append("
"); tableBuf.append(""); for (int i = 0; i < elements.size(); i++) { Hashtable row = (Hashtable)elements.elementAt(i); String lseID = (String)row.get("LseID"); String elementID = (String)row.get("LseScriptElementID"); String elementLabel = (String)row.get("LseScriptElementID:SceLabel"); Number lsePosition = (Number)row.get("LsePosition"); String pageID = (String)row.get("LsePageID"); String pageTitle = (String)row.get("LsePageID:ScpTitre"); String pageCode = (String)row.get("LsePageID:ScpCode"); // detection de la coupure boolean coupure = false; if (i == 0) { coupure = true; } else if ("".equals(oldPageID)) { coupure = pageID != null; } else if (pageID == null) { coupure = !"".equals(oldPageID); } else { coupure = !oldPageID.equals(pageID); } if (coupure) { if (pageID == null) { tableBuf.append(""); tableBuf.append(""); tableBuf.append(""); tableBuf.append(""); tableBuf.append(""); tableBuf.append(""); } else { usedPages.addElement(pageID); tableBuf.append(""); tableBuf.append(""); tableBuf.append(""); tableBuf.append(""); tableBuf.append(""); tableBuf.append(""); } oldPageID = pageID != null ? pageID : ""; } // get all LinkScriptElements attached to this page tableBuf.append(""); tableBuf.append(""); tableBuf.append(""); tableBuf.append(""); tableBuf.append(""); }//End for each elements boolean messageShown = false; for (int i = 0; i < pages.size(); i++) { Hashtable row = (Hashtable)pages.elementAt(i); String pageID = (String)row.get("ScpID"); String pageTitle = (String)row.get("ScpTitre"); String pageCode = (String)row.get("ScpCode"); if (!usedPages.contains(pageID)) { if (!messageShown) { messageShown = true; tableBuf.append(""); tableBuf.append(""); tableBuf.append(""); tableBuf.append(""); tableBuf.append(""); } tableBuf.append(""); tableBuf.append(""); tableBuf.append(""); tableBuf.append(""); tableBuf.append(""); } isBlue = !isBlue; } tableBuf.append("
"+Utils.getMessage(session, "L6310", true, "Attention : Tous les éléments doivent être rattachés à une page.")+"
"); tableBuf.append(Utils.getMessage(session, "L6418", true, "Eléments non attachés")); tableBuf.append("
"); tableBuf.append("\\\"\\\""); tableBuf.append(""); tableBuf.append(Utils.formatToWeb(pageCode, false)+( pageCode != null && pageTitle != null ? " - " : "" ) + ( Utils.formatToWeb(pageTitle, false) )); tableBuf.append("
"); // tableBuf.append("\\\"\\\""); tableBuf.append(""+ lsePosition + "" + Utils.formatToJavascript(Utils.formatToWeb(elementLabel, false)) + "
"+Utils.getMessage(session, "L6311", true, "Les pages ci-dessous ne seront pas affichées car elles ne contiennent aucun élément de script.")+"
\\\"\\\""); tableBuf.append("\\\"\\\""); tableBuf.append(""); tableBuf.append(Utils.formatToJavascript(Utils.formatToWeb(pageCode, false)) + (pageCode != null && pageTitle != null ? " - " : "" )+ Utils.formatToJavascript(Utils.formatToWeb(pageTitle, false))); tableBuf.append("
"); tableBuf.append(""); tableBuf.append(""); tableBuf.append(""); tableBuf.append(""); tableBuf.append(""); tableBuf.append(""); //for each link found, display a row for (int i=0 ; i < linksList.size() ; i++) { Hashtable curLink = (Hashtable) linksList.elementAt(i); String curLseScriptElementID = (String) curLink.get("LseScriptElementID"); String sceLabel = (String) curLink.get("LseScriptElementID:SceLabel"); int lsePosition = ((Number) curLink.get("LsePosition")).intValue(); String lseID = (String)curLink.get("LseID"); int count = ((Number)curLink.get("CountTransitions")).intValue(); tableBuf.append(""); tableBuf.append(""); tableBuf.append(""); isBlue = !isBlue; } tableBuf.append("
"+Utils.getMessage(session, "L6417", true, "Pos.")+""+Utils.getMessage(session, "F6089", true, "Nb. transitions")+""+Utils.getMessage(session, "L61EF", true, "Elément de script")+"
" + lsePosition +""+ count +""+ Utils.formatToJavascript(Utils.formatToWeb(sceLabel, false)) +"
"); tableBuf.append(Utils.getMessage(session, "L61FF", true, "Aucun élément de script n'est rattaché à ce script.")); tableBuf.append("
"); %>var f = document.getElementById('ELTSCRIPT1'); f.innerHTML = '<%= tableBuf.toString() %>';