<%@ page import="ez.*, ez.core.*, ez.dom.*, ez.util.*, revize.util.*" %><% //***** TODO: move to RZTagSupport *****\\ /** * Determine topsection id for some plugins (e.g. flash banner, slideshow) **/ String topsectionid = rz.pagesectionid; if (!topsectionid.equals("")) { String myparentid = rz.pageparentid; int cnt = 0; while (true && !rz.pagerecordid.equals("")) //not top section or home page { cnt++; rz.fetch("links","linktosectionid", "_recordid="+topsectionid); if (rz.content.equals("0")) break; //parent section is home topsectionid = rz.content; if (cnt == 10) break; } } %><%-- __________________________________________________________________________________________ 08-29-2012 created new methods for debug output: -debug_open(String PLUGIN_NAME, String VERSION) -debug_print(String msg) -debug_println(String msg) -debug_close() -------------------- Description & Notes: -------------------- Currently only non jsp:includes are supported as shown above. Ultimately code probably should go in RZTagSupport & probably .../util/setup_common_header.jsp Below are list of plugin files that contain a direct include which must be removed when this code is moved and direct include is not required and will throw exception. ----- TODO: ----- 1. Must determine how to input debugOptions: (cannot use session for templates) -perhaps new singleton with HashMap using webspace as key -currently must hardcode debugOptions 2. Pass debug output back to Admin Panel -currently using hidden div on published page __________________________________________________________________________________________ --%><% //----- Initialize class variables /* debug_rz = rz; debug_out = out; debug_session = request.getSession(); */ debug_mode = false; debug_detail = new StringBuffer(); debug_line_buffer = new StringBuffer(); %><%! //----- Declare class variables RZTagSupport debug_rz; JspWriter debug_out; HttpSession debug_session; boolean debug_mode; StringBuffer debug_line_buffer; StringBuffer debug_detail; /** * Called at start of plugin **/ boolean debug_open(String PLUGIN_NAME, String VERSION) throws Exception { if (true) return false; debug_mode = false; String mode = ""; String name = ""; String pageid = ""; while (true) { //----- Get plugin_debug setting using reflection in case plugin_debug not defined // (e.g. before_endhead.*include.jsp missing when called via leftnav_init.jsp) try { //out.println("class:" + this.getClass().getName()); java.lang.reflect.Field debugField = this.getClass().getDeclaredField("plugin_debug"); debug_mode = debugField.getBoolean(this); if (debug_mode) break; } catch (Exception e) { //out.println("Exception: " + e.getMessage()); //e.printStackTrace(); } //----- Get debug options String debugOptions = ""; //debug_session.getAttribute("REVIZE_DEBUG_PLUGIN") + ""; /***************************************************/ /*BOOKMARK ***** hardcode debugOptions below ******/ /*************************************************/ debugOptions = "mode=burlington,name=,pageid=news_list"; debugOptions = "mode=reidsville,name=,pageid=news_list"; debugOptions = "mode=reidsville,name=,pageid=links-64"; mode = debug_rz.getvalue(debugOptions,"mode"); name = debug_rz.getvalue(debugOptions,"name"); if (name.equals("[all]")) name = ""; pageid = debug_rz.getvalue(debugOptions,"pageid"); if (!mode.equals(debug_rz.webspace)) break; if (name.length() > 0 && PLUGIN_NAME.indexOf(name) == -1) break; if (pageid.length() > 0 && !pageid.equals(debug_rz.pageid)) break; debug_mode = true; break; } //debug_out.println("webspace="+debug_rz.webspace+" pageid="+debug_rz.pageid+" PLUGIN_NAME="+PLUGIN_NAME); //debug_out.println("mode="+mode+" name="+name+" pageid="+pageid+" debug_mode="+debug_mode); debug_println("DEBUG enabled for: " + PLUGIN_NAME + " " + VERSION); return debug_mode; } /** **/ void debug_print(String msg) { if (!debug_mode) return; debug_line_buffer.append(msg); } /** **/ void debug_println(String msg) { if (!debug_mode) return; //convert leading spaces to   msg = msg.replaceFirst("^( )*","$1".replaceAll(" "," ")); debug_line_buffer.append(msg); //append to current line debug_line_buffer.append("@@\n"); //end line debug_detail.append(debug_line_buffer); //append to detail debug_line_buffer = new StringBuffer(); //clear current line } /** * Called at end of plugin to save debug output **/ void debug_close() throws Exception { if (!debug_mode) return; debug_println(""); //flush debug_line_buffer if (debug_detail == null || debug_detail.length() == 0) return; String detail = "
" + debug_detail + "
"; debug_out.println(detail); } %>