Monday, November 08, 2010 at 12:05 AM.
system.verbs.builtins.radio.html.addCategoryCheckboxes
on addCategoryCheckboxes (adrblog, adrstory, bgcolor=radio.data.htmlColors.cellBgColor) {
<<Changes
<<2/5/02; 6:40:50 PM by JES
<<Always use a four-column display.
<<2/3/02; 12:17:12 AM by JES
<<Changed the category links to go to the Edit Category page for the given category.
<<1/25/02; 2:30:42 PM by JES
<<Make Home Page the first category in the table.
<<1/6/02; 11:37:39 PM by JES
<<Add a <font size="-2"> to all of the category cells, since the CSS class addition blasted the font size adjustment applied by <td class="small">.
<<1/6/02; 3:46:47 AM by JES
<<Added table css classes.
<<12/22/01; 10:26:06 PM by JES
<<Fixed an error: displayName has not been defined.
<<12/22/01; 8:11:42 PM by JES
<<Don't link category names whose rssUrl is the empty string.
<<12/17/01; 12:12:33 PM by JES
<<Category names are now links to the category's upstreamed RSS file.
<<12/10/01; 12:59:31 PM by JES
<<If flRenderHtml is false, don't make the category name a link.
<<12/10/01; 12:58:42 PM by JES
<<Put the class="small" on the td tag for each category, instead of enclosing them in a <div class="small">. Minor nit, but it makes the HTML smaller.
<<10/29/01; 5:02:25 PM by JES
<<Added optional parameter, bgcolor.
<<10/28/01; 9:05:11 AM by DW
<<Enclose each category in <div class="small">.
<<Instead of putting out five s at the end of every category name, just put out two.
<<3/4/01; 3:09:55 PM by JES
<<Use the category's displayName for the link, instead of the name of the category's table. Don't replace spaces with in the name attribute.
<<2/24/01; 6:12:40 PM by JES
<<Replace spaces in the category name with so they won't break to the next line.
<<1/25/01; 2:40:30 PM by DW
<<For each category, if it has an htmlUrl, hot-up the name of the category.
<<1/20/01; 9:28:03 PM by DW
<<Created. Add a checkbox for each of the categories. Factored some code out of addRemove, going to use it on the main blog page.
local (pta = html.getPageTableAddress ());
<<local (globeicon = radio.images.systemImageRef ("qbullet/remote", flFileUrl:pta^.radioResponder.flSameMachine, alt:"globe"))
<<local (check = radio.images.systemImageRef ("icons/checkmark", flFileUrl:pta^.radioResponder.flSameMachine, alt:"check"))
local (adrcats = nil);
if adrstory != nil {
adrcats = @adrstory^.categories;
if not defined (adrcats^) {
new (tabletype, adrcats)}};
local (catlist = {""}); //the empty catname is the home page
local (cols = 4);
bundle { //fill catlist
local (adr);
for adr in @adrblog^.categories {
local (name = nameOf (adr^));
catlist = catlist + {name}}};
<<if sizeOf (name) > 25
<<cols = 3
local (htmltext = "\r", indentlevel = 0);
on add (s) {
htmltext = htmltext + string.filledstring ("\t", indentlevel) + s + "\r\n"};
local (catname);
local (i, j, ix, itemsincol = (sizeof (catlist) + (cols - 1)) / cols);
for i = 1 to itemsincol {
add ("<tr bgcolor=\"" + bgcolor + "\">"); indentlevel++;
for j = 1 to cols {
ix = i + ((j - 1) * itemsincol);
if ix <= sizeof (catlist) {
local (checkboxval = "xxx ");
local (name = catlist [ix]);
if name == "" { //the home page category
local (checkedtext = "", flOnHomePage = true);
if adrstory != nil { //get the checkbox from the post
if defined (adrstory^.flNotOnHomePage) {
if adrstory^.flNotOnHomePage {
flOnHomePage = false}}};
if flOnHomePage {
checkedtext = " checked"};
<<local (link = "<a href=\"" + radio.data.systemUrls.weblogEditor + "\" title=\"" + adrblog^.prefs.title + "\">" + radio.string.getlocalizedstring ("weblogPostForm.homePageCategoryName") + "</a>")
local (link = "<b>" + radio.string.getlocalizedstring ("weblogPostForm.homePageCategoryName") + "</b>");
<<link = link + " <a href=\"" + radio.weblog.getUrl (adrblog) + "\" title=\"Click this link to go to your main weblog home page.\">" + globeicon + "</a>"
<<if adrblog^.prefs.flPublicBlog
<<link = link + " " + check
add ("<td class=\"dwsTableCell\"><font size=\"-2\"><input type=\"checkbox\" name=\"flPostToHomePage\"" + checkedtext + ">" + link + " </font></td>")}
else { //a normal category
if defined (adrcats^.[name]) {
if adrcats^.[name] {
checkboxval = checkboxval + "checked"}};
local (adrcat = @adrblog^.categories.[name]);
local (displayName = string.replaceAll (adrcat^.displayName, " ", " "));
local (link = displayName );
bundle { //set link
<<if defined (adrcat^.rssUrl)
<<if adrcat^.rssUrl != ""
<<link = "<a href=\"" + adrcat^.rssUrl + "\" title=\"Click this link to view this category in XML.\">" + displayName + "</a>"
local (url);
bundle { //set url
local (args);
new (tabletype, @args);
args.catname = name;
args.referer = "http://" + pta^.host + pta^.uri;
url = radio.data.systemUrls.newCategory + "?" + webserver.encodeArgs (@args)};
link = "<a href=\"" + url + "\" title=\"" + string.replaceAll (adrcat^.description, "\"", """) + "\">" + displayName + "</a>"};
<<if adrcat^.flRenderHtml
<<link = link + " <a href=\"" + radio.upstream.getFileUrl (radio.weblog.file.getCategoryFolder (nameOf (adrcat^), adrblog)) + "\" title=\"Click this link to go to the HTML home page for this category.\">" + globeicon + "</a>"
<<if adrcat^.flNotifyWeblogsCom
<<link = link + " " + check
add ("<td class=\"dwsTableCell\"><font size=\"-2\"><nobr><input type=\"checkbox\" name=\"cat:" + name + "\" value=" + checkboxval + ">" + link + " </font></nobr></td>")}}};
add ("</tr>"); indentlevel--};
return (htmltext)}
<<bundle //test code
<<addCategoryCheckboxes (@weblogData.posts.["00000003"])
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.