Monday, November 08, 2010 at 12:05 AM.
system.verbs.builtins.radio.weblog.viewCategories
on viewCategories () { <<Changes <<1/15/02; 12:11:24 AM by JES <<Only add the last upload date if the category has been uploaded (published) at least once. <<1/6/02; 4:38:12 AM by JES <<Added table css classes. <<12/8/01; 5:36:23 PM by JES <<Use a fully-qualified URL for the referer searchArg, since some browsers won't redirect properly with only the path. <<12/2/01; 10:58:11 PM by JES <<Changed help link to link to the correct page. <<11/14/01; 10:08:00 AM by DW <<Localized. <<2/24/01; 8:49:25 PM by PBS <<Help link. <<Terminology: stories, not items. <<1/21/01; 5:30:06 PM by DW <<Allow the user to delete categories from this page. <<1/19/01; 3:27:47 PM by PBS <<Change site URL from /myUserLand/ to /UserLand/. <<1/13/01; 8:21:55 PM by DW <<Change link on XML icon, point to the local viewXmlSource page, use local resources. <<1/11/01; 5:47:43 PM by PBS <<Add a link for creating a new category. <<1/11/01; 4:48:10 PM by PBS <<No more Edit With Radio button for editing categories. <<The description changed -- it doesn't mention the outliner. It tells how to edit a category (by clicking on its name). <<Get the category's display name, which may not be the same as the table's name. local (pta = html.getpagetableaddress ()); pta^.title = radio.string.getlocalizedstring ("categories.title"); local (xmlImg = radio.images.systemImageRef ("icons/xml")); local (helplink = radio.userinterface.helplink ("The Categories page")); local (adrdata = radio.weblog.init ()); local (now = clock.now ()); local (htmltext = "", indentlevel = 0); on add (s) { htmltext = htmltext + string.filledstring ("\t", indentlevel) + s + "\r\n"}; if pta^.method == "POST" { local (args); new (tabletype, @args); webserver.parseargs (pta^.requestBody, @args); <<scratchpad.args = args; edit (@scratchpad.args) local (adr, catname); for adr in @args { catname = nameof (adr^); adrcat = @adrdata^.categories.[catname]; if defined (adrcat^) { adrdata^.trash.[catname] = adrcat^; delete (adrcat)}}}; add ("<form method=\"POST\">"); indentlevel++; bundle { //add the Delete button add ("<table align=\"right\" cellspacing=\"0\" cellpadding=\"1\"><tr><td valign=\"top\"> <input type=\"submit\" value=\"" + radio.string.getlocalizedstring ("categories.deleteButton") + "\"></td></tr></table>")}; bundle { //add intro local (args); new (tabletype, @args); args.referer = "http://" + pta^.host + pta^.uri; local (t); new (tabletype, @t); t.newcategoryurl = "editCategory?" + webserver.encodeargs (@args); add ("<p>" + radio.string.getlocalizedstring ("categories.intro", @t) + " " + helplink + "<p>")}; add ("<table class=\"dwsFrameTable\" cellspacing=\"0\" cellpadding=\"0\"><tr bgcolor=\"" + radio.data.htmlColors.framecolor + "\"><td>"); indentlevel++; add ("<table class=\"dwsTableCell\" border=\"0\" cellspacing=\"1\" cellpadding=\"5\">"); indentlevel++; local (adr); for adr in @adrdata^.categories { local (catname = nameOf (adr^)); add ("<tr bgcolor=\"" + radio.data.htmlColors.cellbgcolor + "\">"); indentlevel++; bundle { //add checkbox add ("<td class=\"dwsTableCell\" valign=\"top\"><input type=\"checkbox\" name=\"" + catname + "\" value=" + "xxx " + "></td>")}; local (url); bundle { //set url local (args); new (tabletype, @args); args.catname = catname; args.referer = "http://" + pta^.host + pta^.uri; url = "editCategory" + "?" + webserver.encodeArgs (@args)}; add ("<td class=\"dwsTableCell\" valign=\"top\" nowrap><a href=\"" + url + "\">" + adr^.displayName + "</a></td>"); add ("<td class=\"dwsTableCell\" valign=\"top\">" + adr^.description + "</td>"); bundle { //add last update local (s = " "); if defined (adr^.dateLastUpload) { if adr^.dateLastUpload != date (0) { //1/15/02 JES: only add the date if the category has been uploaded at least once local (day, month, year, hour, minute, second, nowday, nowmonth, nowyear); date.get (adr^.dateLastUpload, @day, @month, @year, @hour, @minute, @second); date.get (now, @nowday, @nowmonth, @nowyear, @hour, @minute, @second); if (day == nowday) and (month == nowmonth) and (year == nowyear) { s = date.timestring (adr^.dateLastUpload)} else { s = date.shortstring (adr^.dateLastUpload)}}}; add ("<td class=\"dwsTableCell\" nowrap valign=\"top\"><center>" + s + "</center></td>")}; bundle { //add item count local (s = " "); if defined (adr^.storyList) { s = sizeof (adr^.storyList)}; add ("<td class=\"dwsTableCell\" nowrap valign=\"top\" align=\"right\">" + s + "</td>")}; bundle { //add XML button local (s = " "); if defined (adr^.rssUrl) { <<local (args); new (tabletype, @args); args.catname = nameof (adr^) <<local (url = "viewXmlSource.wsf?" + webserver.encodeargs (@args)) s = "<a href=\"" + adr^.rssUrl + "\" title=\"" + radio.data.strings.xmlToolTip + "\">" + xmlImg + "</a>"}; add ("<td class=\"dwsTableCell\" nowrap valign=\"top\">" + s + "</td>")}; add ("</tr>"); indentlevel--}; add ("</table>"); indentlevel--; add ("</table>"); indentlevel--; add ("</form>"); indentlevel--; return (htmltext)} <<bundle //test code <<viewCategories ()
This listing is for code that runs in the OPML Editor environment. I created these listings because I wanted the search engines to index it, so that when I want to look up something in my codebase I don't have to use the much slower search functionality in my object database. Dave Winer.