|
From: creedon <icr...@us...> - 2006-01-07 22:34:45
|
Update of /cvsroot/frontierkernel/odbs/frontierRoot/system/verbs/builtins/radio/prefs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31027 Modified Files: browser Log Message: minor formatting tweaks lowercase form method, add action to form, remove tr tag height XHTML compliance Index: browser =================================================================== RCS file: /cvsroot/frontierkernel/odbs/frontierRoot/system/verbs/builtins/radio/prefs/browser,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** browser 26 Mar 2005 19:43:20 -0000 1.1.1.1 --- browser 7 Jan 2006 22:34:30 -0000 1.2 *************** *** 1,3 **** FrontierVcsFile:1:scpt:system.verbs.builtins.radio.prefs.browser ! on browser (adroutline, pagename="Preferences", flAddSubmitButton=true, nextLinkText="Next", prevLinkText="Previous", submitButtonText="Submit") { ÇChanges Ç10/12/02; 1:44:56 AM by JES ÇThree new parameters to facilitate localization: nextLinkText, prevLinkText and submitButtonText. These parameters specify the text for the next and previous links, and the text for the submit button. Ç9/24/02; 12:51:38 AM by JES ÇDecode ampersand entities in category and topic names. Needed for localization. Ç6/26/02; 11:51:52 PM by JES ÇBefore adding the Submit button, check to see if pta^.flAddSubmitButton is defined. If defined and false, don't add the button. This allows macros in a prefs outline to suppress the Submit button, and add their own button(s) if desired. Ç2/5/02; 11:26:46 AM by PBS ÇConditionalized to work in Frontier. Ç1/9/02; 5:03:56 PM by JES ÇCall radio.prefs.compileIfDirty, instead of compiling the xml and caching home page text, next-prev links, and page titles here. Ç12/10/01; 10:21:06 PM by JES ÇInclude the full path in the link to sub-pages, since Opera doesn't know how to link to the same page, adding just the searchArgs. Fixes a bug where none of the Prefs or Help sub-pages could be reached in Opera. Ç11/24/01; 5:18:15 PM by JES ÇSet pta^.headTitle, which is used for the <%title%> in the header of the page (when rendered in the context of an #flUseHomeTitle true directive). ÇSee radio.webserver.setTemplate for the code that handles the #flUseHomeTitle directive. ÇNew optional parameter, flAddSubmitButton. If true, then the Submit button will be added at the bottom of the page. If false, there's no submit button. Default is true. This is needed in order to remove the Submit button from the bottom of the help pages. Ç11/23/01; 9:17:39 PM by DW ÇPut the address of the prefs outline into pta^.radioResponder.adrPrefsOutline. ÇIt's picked up in radio.prefs.seeAlso, to determine which element of the cache it should use. Ç11/23/01; 9:06:49 PM by DW ÇAdd a second parameter which is the name of the home page of the sub-site. Ç11/18/01; 5:48:45 PM by DW ÇNot content with my most recent one, now I'm swingin for the fences. ÇThis browser runs off a single outline. It's not XML. It's just an outline. ÇWhere it requires user input -- a checkbox or a number-entry box, it calls macros. ÇWe do a directory-like browser for prefs, breaking it down to sections. ÇThe key thing about this approach is that the writer gets to use a writing tool, not an XML editor, and not a bunch of scattered strings. This makes it possible for docs and settings to be mixed in a single presentation. This is how docs were supposed to work. local (pta = html.getpagetableaddress ()); if system.environment.isRadio { //PBS 02/05/02: conditionalized for Frontier pta^.radioResponder.adrPrefsOutline = adroutline} else { pta^.adrPrefsOutline = adroutline}; pta^.title = " "; local (titleBarColor = "#" + gainsboro, titleBarTextColor = "#" + black); titleBarColor = "#859EC9"; titleBarTextColor = "#" + white; //matches the coffee-cup background color titleBarcolor = "#C5CEDE"; titleBarcolor = "#" + whitesmoke; Çscratchpad.params = pta^ Ç1/9/02; 7:08:11 PM by JES: call radio.prefs.compileIfDirty to set home page cache, build next/prev's and get page titles ÇThis prevents a crash on Help pages which link to related Prefs pages, when the Prefs have not been viewed since Radio was launched. Çbundle //original code Çlocal (adrcache) Çbundle //find the cache for this outline Çlocal (adr = @system.temp.radio.prefsCache) Çif not defined (adr^) Çnew (tabletype, adr) Çadr = @adr^.[string (adroutline)] Çif not defined (adr^) Çnew (tabletype, adr) Çadrcache = adr Ç Çlocal (flcompile, adrxstruct = @adrcache^.xstruct) Çbundle //compile the outline if it changed Çflcompile = true Çif defined (adrxstruct^) Çif timemodified (adroutline) <= timemodified (adrxstruct) Çflcompile = false Çif flcompile Çxml.compile (op.outlinetoxml (adroutline), adrxstruct) Ç Çlocal (adropml = xml.getAddress (adrxstruct, "opml")) Çlocal (adrbody = xml.getAddress (adropml, "body")) Ç Çlocal (adrhomepagehtml = @adrcache^.homePageHtml, adrnextprevlist = @adrcache^.nextPrevList, adrpagetitles = @adrcache^.pagetitles) Çif flcompile //cache the text for the home page, create next-prevs list and cache it, and the page-titles table Çadrnextprevlist^ = {} Çnew (tabletype, adrpagetitles) Çlocal (htmltext = "", indentlevel = 0) Çon add (s) Çhtmltext = htmltext + string.filledstring ("\t", indentlevel) + s + "\r\n" Çlocal (adrcat, catnum = 1) Çfor adrcat in adrbody Çif not (nameof (adrcat^) beginswith "/") Çlocal (catname = xml.getattributevalue (adrcat, "text"), adrtopic, topicnum = 1) Çadd ("<h4>" + catname + "</h4>") Çadd ("<ul>"); indentlevel++ Çfor adrtopic in adrcat Çif not (nameof (adrtopic^) beginswith "/") Çlocal (dottedid = catnum + "." + topicnum) Çadrnextprevlist^ = adrnextprevlist^ + {dottedid} Çlocal (url = pta^.URI + "?page=" + dottedid) Çlocal (pagetitle = xml.getattributevalue (adrtopic, "text")) Çadrpagetitles^.[pagetitle] = dottedid Çadd ("<li><a href=\"" + url + "\">" + pagetitle + "</a></li>") Çtopicnum++ Çadd ("</ul>"); indentlevel-- Çcatnum++ Çadrhomepagehtml^ = htmltext local (adrcache = radio.prefs.compileIfDirty (adroutline)); local (adrxstruct = @adrcache^.xstruct); local (adropml = xml.getAddress (adrxstruct, "opml")); local (adrbody = xml.getAddress (adropml, "body")); local (adrhomepagehtml = @adrcache^.homePageHtml, adrnextprevlist = @adrcache^.nextPrevList); local (navigationpath = ""); if system.environment.isRadio { //PBS 02/05/02: conditionalized for Frontier if defined (pta^.radioresponder.getargs.page) { navigationpath = pta^.radioresponder.getargs.page}} else { if defined (pta^.searchArgTable.page) { navigationpath = pta^.searchArgTable.page}}; local (adrframe, fltoplevel); bundle { //set adrframe, fltoplevel local (ctfields = string.countfields (navigationpath, ".")); if ctfields >= 2 { local (i, ix, nomad = adrbody); for i = 1 to ctfields { ix = number (string.nthfield (navigationpath, ".", i)); if defined (nomad^.["/atts"]) { //skip over /atts ix++}; nomad = @nomad^ [ix]}; adrframe = nomad; fltoplevel = false} else { adrframe = adrbody; fltoplevel = true}}; local (htmltext = "", indentlevel = 0); on add (s) { htmltext = htmltext + string.filledstring ("\t", indentlevel) + s + "\r\n"}; bundle { //display the frame if fltoplevel { //adrframe points to the first category add (adrhomepagehtml^); pta^.headTitle = pagename; Çbundle //discarded method -- displays the topics in an array ÇToo bad the topic names are too long for this to look reasonable. Çlocal (adrcat, catnames = {}, tableofcontents) Çnew (tabletype, @tableofcontents) Ç Çfor adrcat in adrframe //loop over the top-level Çif not (nameof (adrcat^) beginswith "/") Çlocal (catname = xml.getattributevalue (adrcat, "text")) Çcatnames = catnames + {catname} Ç Çlocal (adrtopic, topics) Çnew (tabletype, @topics) Çfor adrtopic in adrcat Çif not (nameof (adrtopic^) beginswith "/") Çtopics.[string.padwithzeros (sizeof (topics), 3)] = xml.getattributevalue (adrtopic, "text") Çtableofcontents.[catname] = topics Çscratchpad.tableofcontents = tableofcontents Ç Çadd ("<table border=\"0\" cellspacing=\"0\" cellpadding=\"4\">"); indentlevel++ Çbundle //add top row of the table, the category names Çlocal (catname, width) Çwidth = 33 Çadd ("<tr>"); indentlevel++ Çfor catname in catnames Çadd ("<td width=\"" + width + "%\"><b>" + catname + "</b></td>") Çadd ("</tr>"); indentlevel-- Çbundle //add rows of topics Çlocal (rownum = 1, catname) Çloop //do a row Çlocal (rowtext = "<tr>", flallblank = true) Çfor catname in catnames Çmsg (sizeof (tableofcontents.[catname]) + " " + rownum); clock.waitseconds (1) Çif sizeof (tableofcontents.[catname]) >= rownum Çs = tableofcontents.[catname] [rownum] Çflallblank = false Çelse Çs = " " Çrowtext = rowtext + "<td>" + s + "</td>" Çrowtext = rowtext + "</tr>" Çif flallblank Çbreak Çadd (rowtext) Çrownum++ Çadd ("</table>"); indentlevel--} else { local (category); bundle { //set category local (categoryname = xml.getattributevalue (parentof (adrframe^), "text")); categoryname = string.replaceAll (categoryname, "&", "&"); category = categoryname}; local (nextprev); bundle { //set nextprev local (ixmyself, i); for i = 1 to sizeof (adrnextprevlist^) { if adrnextprevlist^ [i] == navigationpath { ixmyself = i; break}}; local (next, prev); if ixmyself == sizeof (adrnextprevlist^) { next = nextLinkText} else { next = "<a href=\"?page=" + adrnextprevlist^ [ixmyself + 1] + "\">" + nextLinkText + "</a>"}; if ixmyself == 1 { prev = prevLinkText} else { prev = "<a href=\"?page=" + adrnextprevlist^ [ixmyself - 1] + "\">" + prevLinkText + "</a>"}; nextprev = prev + "/" + next}; on blankLine () { return ("<tr height=\"15\"><td colspan=\"2\"> </td></tr>")}; on titleBar (s) { return ("<tr bgcolor=\"" + titleBarColor + "\"><td colspan=\"2\"><b><font color=\"" + titlebartextcolor + "\">" + s + "</font></b></td></tr>")}; add ("<form method=\"POST\">"); indentlevel++; add ("<table border=\"0\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\"><tr><td><a href=\"?page=1\">" + pagename + "</a> > " + category + "</td><td align=\"right\">" + nextprev + "</td></tr></table>"); add ("<h3>" + string.replaceAll (adrframe^.["/atts"].text, "&", "&") + "</h3>"); pta^.headTitle = category + ": " + adrframe^.["/atts"].text; add ("<table border=\"0\" cellspacing=\"0\" cellpadding=\"4\" width=\"100%\">"); indentlevel++; bundle { //add the sub-elements local (adr); for adr in adrframe { if not (nameof (adr^) beginswith "/") { local (s = xml.entitydecode (adr^.["/atts"].text, true)); if s beginswith "<%" { add (html.processmacros (s, adrPageTable:pta))} else { add ("<tr><td colspan=\"2\">" + html.processmacros (s, adrPageTable:pta) + "</td></tr>")}}}}; if defined (pta^.flAddSubmitButton) { //JES 6/26/02: allow macros to suppress the Submit button flAddSubmitButton = pta^.flAddSubmitButton}; if flAddSubmitButton { //add the Submit button add (blankline () + "<tr><td colspan=\"2\"><input type=\"submit\" value=\"" + submitButtonText + "\"></td></tr>")}; add ("</table>"); indentlevel--; add ("</form>"); indentlevel--}}; return (htmltext)}; Çbundle //test code Çhtml.setpagetableaddress (@workspace.pt) Çradio.prefs.browser ("") \ No newline at end of file --- 1,3 ---- FrontierVcsFile:1:scpt:system.verbs.builtins.radio.prefs.browser ! on browser (adroutline, pagename="Preferences", flAddSubmitButton=true, nextLinkText="Next", prevLinkText="Previous", submitButtonText="Submit") { ÇChanges Ç1/7/06; 12:56:08 PM by TAC Çminor formatting tweaks Çlowercase form method, add action to form, remove tr tag height XHTML compliance Ç2002 Ç10/12/02; 1:44:56 AM by JES ÇThree new parameters to facilitate localization: nextLinkText, prevLinkText and submitButtonText. These parameters specify the text for the next and previous links, and the text for the submit button. Ç9/24/02; 12:51:38 AM by JES ÇDecode ampersand entities in category and topic names. Needed for localization. Ç6/26/02; 11:51:52 PM by JES ÇBefore adding the Submit button, check to see if pta^.flAddSubmitButton is defined. If defined and false, don't add the button. This allows macros in a prefs outline to suppress the Submit button, and add their own button(s) if desired. Ç2/5/02; 11:26:46 AM by PBS ÇConditionalized to work in Frontier. Ç1/9/02; 5:03:56 PM by JES ÇCall radio.prefs.compileIfDirty, instead of compiling the xml and caching home page text, next-prev links, and page titles here. Ç2001 Ç12/10/01; 10:21:06 PM by JES ÇInclude the full path in the link to sub-pages, since Opera doesn't know how to link to the same page, adding just the searchArgs. Fixes a bug where none of the Prefs or Help sub-pages could be reached in Opera. Ç11/24/01; 5:18:15 PM by JES ÇSet pta^.headTitle, which is used for the <%title%> in the header of the page (when rendered in the context of an #flUseHomeTitle true directive). ÇSee radio.webserver.setTemplate for the code that handles the #flUseHomeTitle directive. ÇNew optional parameter, flAddSubmitButton. If true, then the Submit button will be added at the bottom of the page. If false, there's no submit button. Default is true. This is needed in order to remove the Submit button from the bottom of the help pages. Ç11/23/01; 9:17:39 PM by DW ÇPut the address of the prefs outline into pta^.radioResponder.adrPrefsOutline. ÇIt's picked up in radio.prefs.seeAlso, to determine which element of the cache it should use. Ç11/23/01; 9:06:49 PM by DW ÇAdd a second parameter which is the name of the home page of the sub-site. Ç11/18/01; 5:48:45 PM by DW ÇNot content with my most recent one, now I'm swingin for the fences. ÇThis browser runs off a single outline. It's not XML. It's just an outline. ÇWhere it requires user input -- a checkbox or a number-entry box, it calls macros. ÇWe do a directory-like browser for prefs, breaking it down to sections. ÇThe key thing about this approach is that the writer gets to use a writing tool, not an XML editor, and not a bunch of scattered strings. This makes it possible for docs and settings to be mixed in a single presentation. This is how docs were supposed to work. local (pta = html.getPageTableAddress ()); if system.environment.isRadio { //PBS 02/05/02: conditionalized for Frontier pta^.radioResponder.adrPrefsOutline = adroutline} else { pta^.adrPrefsOutline = adroutline}; pta^.title = " "; local (titleBarColor = "#" + gainsboro, titleBarTextColor = "#" + black); titleBarColor = "#859EC9"; titleBarTextColor = "#" + white; //matches the coffee-cup background color titleBarcolor = "#C5CEDE"; titleBarcolor = "#" + whitesmoke; Çscratchpad.pt = pta^ // enable for testing Ç1/9/02; 7:08:11 PM by JES: call radio.prefs.compileIfDirty to set home page cache, build next/prev's and get page titles ÇThis prevents a crash on Help pages which link to related Prefs pages, when the Prefs have not been viewed since Radio was launched. Çbundle //original code Çlocal (adrcache) Çbundle //find the cache for this outline Çlocal (adr = @system.temp.radio.prefsCache) Çif not defined (adr^) Çnew (tabletype, adr) Çadr = @adr^.[string (adroutline)] Çif not defined (adr^) Çnew (tabletype, adr) Çadrcache = adr Ç Çlocal (flcompile, adrxstruct = @adrcache^.xstruct) Çbundle //compile the outline if it changed Çflcompile = true Çif defined (adrxstruct^) Çif timemodified (adroutline) <= timemodified (adrxstruct) Çflcompile = false Çif flcompile Çxml.compile (op.outlinetoxml (adroutline), adrxstruct) Ç Çlocal (adropml = xml.getAddress (adrxstruct, "opml")) Çlocal (adrbody = xml.getAddress (adropml, "body")) Ç Çlocal (adrhomepagehtml = @adrcache^.homePageHtml, adrnextprevlist = @adrcache^.nextPrevList, adrpagetitles = @adrcache^.pagetitles) Çif flcompile //cache the text for the home page, create next-prevs list and cache it, and the page-titles table Çadrnextprevlist^ = {} Çnew (tabletype, adrpagetitles) Çlocal (htmlText = "", indentlevel = 0) Çon add (s) ÇhtmlText = htmlText + string.filledstring ("\t", indentlevel) + s + "\r\n" Çlocal (adrcat, catnum = 1) Çfor adrcat in adrbody Çif not (nameof (adrcat^) beginswith "/") Çlocal (catname = xml.getattributevalue (adrcat, "text"), adrtopic, topicnum = 1) Çadd ("<h4>" + catname + "</h4>") Çadd ("<ul>"); indentlevel++ Çfor adrtopic in adrcat Çif not (nameof (adrtopic^) beginswith "/") Çlocal (dottedid = catnum + "." + topicnum) Çadrnextprevlist^ = adrnextprevlist^ + {dottedid} Çlocal (url = pta^.URI + "?page=" + dottedid) Çlocal (pagetitle = xml.getattributevalue (adrtopic, "text")) Çadrpagetitles^.[pagetitle] = dottedid Çadd ("<li><a href=\"" + url + "\">" + pagetitle + "</a></li>") Çtopicnum++ Çadd ("</ul>"); indentlevel-- Çcatnum++ Çadrhomepagehtml^ = htmlText local (adrcache = radio.prefs.compileIfDirty (adroutline)); local (adrxstruct = @adrcache^.xstruct); local (adropml = xml.getAddress (adrxstruct, "opml")); local (adrbody = xml.getAddress (adropml, "body")); local (adrhomepagehtml = @adrcache^.homePageHtml, adrnextprevlist = @adrcache^.nextPrevList); local (navigationpath = ""); if system.environment.isRadio { //PBS 02/05/02: conditionalized for Frontier if defined (pta^.radioresponder.getargs.page) { navigationpath = pta^.radioresponder.getargs.page}} else { if defined (pta^.searchArgTable.page) { navigationpath = pta^.searchArgTable.page}}; local (adrframe, fltoplevel); bundle { //set adrframe, fltoplevel local (ctfields = string.countfields (navigationpath, ".")); if ctfields >= 2 { local (i, ix, nomad = adrbody); for i = 1 to ctfields { ix = number (string.nthfield (navigationpath, ".", i)); if defined (nomad^.["/atts"]) { //skip over /atts ix++}; nomad = @nomad^ [ix]}; adrframe = nomad; fltoplevel = false} else { adrframe = adrbody; fltoplevel = true}}; local (htmlText = "", indentlevel = 0); on add (s) { htmlText = htmlText + string.filledstring ("\t", indentlevel) + s + "\r\n"}; bundle { //display the frame if fltoplevel { //adrframe points to the first category add (adrhomepagehtml^); pta^.headTitle = pagename; Çbundle //discarded method -- displays the topics in an array ÇToo bad the topic names are too long for this to look reasonable. Çlocal (adrcat, catnames = {}, tableofcontents) Çnew (tabletype, @tableofcontents) Ç Çfor adrcat in adrframe //loop over the top-level Çif not (nameof (adrcat^) beginswith "/") Çlocal (catname = xml.getattributevalue (adrcat, "text")) Çcatnames = catnames + {catname} Ç Çlocal (adrtopic, topics) Çnew (tabletype, @topics) Çfor adrtopic in adrcat Çif not (nameof (adrtopic^) beginswith "/") Çtopics.[string.padwithzeros (sizeof (topics), 3)] = xml.getattributevalue (adrtopic, "text") Çtableofcontents.[catname] = topics Çscratchpad.tableofcontents = tableofcontents Ç Çadd ("<table border=\"0\" cellspacing=\"0\" cellpadding=\"4\">"); indentlevel++ Çbundle //add top row of the table, the category names Çlocal (catname, width) Çwidth = 33 Çadd ("<tr>"); indentlevel++ Çfor catname in catnames Çadd ("<td width=\"" + width + "%\"><b>" + catname + "</b></td>") Çadd ("</tr>"); indentlevel-- Çbundle //add rows of topics Çlocal (rownum = 1, catname) Çloop //do a row Çlocal (rowtext = "<tr>", flallblank = true) Çfor catname in catnames Çmsg (sizeof (tableofcontents.[catname]) + " " + rownum); clock.waitseconds (1) Çif sizeof (tableofcontents.[catname]) >= rownum Çs = tableofcontents.[catname] [rownum] Çflallblank = false Çelse Çs = " " Çrowtext = rowtext + "<td>" + s + "</td>" Çrowtext = rowtext + "</tr>" Çif flallblank Çbreak Çadd (rowtext) Çrownum++ Çadd ("</table>"); indentlevel--} else { local (category); bundle { //set category local (categoryname = xml.getattributevalue (parentof (adrframe^), "text")); categoryname = string.replaceAll (categoryname, "&", "&"); category = categoryname}; local (nextprev); bundle { //set nextprev local (ixmyself, i); for i = 1 to sizeof (adrnextprevlist^) { if adrnextprevlist^ [i] == navigationpath { ixmyself = i; break}}; local (next, prev); if ixmyself == sizeof (adrnextprevlist^) { next = nextLinkText} else { next = "<a href=\"?page=" + adrnextprevlist^ [ixmyself + 1] + "\">" + nextLinkText + "</a>"}; if ixmyself == 1 { prev = prevLinkText} else { prev = "<a href=\"?page=" + adrnextprevlist^ [ixmyself - 1] + "\">" + prevLinkText + "</a>"}; nextprev = prev + "/" + next}; on blankLine () { return ("<tr><td colspan=\"2\"> </td></tr>")}; on titleBar (s) { return ("<tr bgcolor=\"" + titleBarColor + "\"><td colspan=\"2\"><b><font color=\"" + titlebartextcolor + "\">" + s + "</font></b></td></tr>")}; add ("<form method=\"post\" action=\"\">"); indentlevel++; add ("<table border=\"0\" width=\"100%\" cellpadding=\"0\" cellspacing=\"0\"><tr><td><a href=\"?page=1\">" + pagename + "</a> > " + category + "</td><td align=\"right\">" + nextprev + "</td></tr></table>"); add ("<h3>" + string.replaceAll (adrframe^.["/atts"].text, "&", "&") + "</h3>"); pta^.headTitle = category + ": " + adrframe^.["/atts"].text; add ("<table border=\"0\" cellspacing=\"0\" cellpadding=\"4\" width=\"100%\">"); indentlevel++; bundle { //add the sub-elements local (adr); for adr in adrframe { if not (nameof (adr^) beginswith "/") { local (s = xml.entitydecode (adr^.["/atts"].text, true)); if s beginswith "<%" { add (html.processmacros (s, adrPageTable:pta))} else { add ("<tr><td colspan=\"2\">" + html.processmacros (s, adrPageTable:pta) + "</td></tr>")}}}}; if defined (pta^.flAddSubmitButton) { //JES 6/26/02: allow macros to suppress the Submit button flAddSubmitButton = pta^.flAddSubmitButton}; if flAddSubmitButton { //add the Submit button add (blankline () + "<tr><td colspan=\"2\"><input type=\"submit\" value=\"" + submitButtonText + "\" /></td></tr>")}; add ("</table>"); indentlevel--; add ("</form>"); indentlevel--}}; return (htmlText)}; Çbundle // testing Çhtml.setpagetableaddress (@workspace.pt) Çradio.prefs.browser ("") \ No newline at end of file |