Monday, November 08, 2010 at 12:04 AM.
system.verbs.builtins.mainResponder.adminSite.macros.listSites
on listSites () { <<Changes <<12/12/03; 11:50:10 PM by JES <<If the last-modified time can't be converted to a date type, just return it as a string. <<9/8/02; 4:55:26 PM by JES <<Use the local globe icon instead of the one hosted at UserLand. <<9/3/02; 4:33:36 AM by JES <<Added a small padlock icon next to the name of editors only sites. <<8/20/02; 4:16:45 PM by JES <<Added links to multiple pages for servers that have more than 25 sites. local (pta); try {pta = html.getPageTableAddress ()}; local (bgcolor1, bgcolor2, ctitems=0, thisPageUrl=""); try {bgcolor1 = pta^.trbg1; bgcolor2 = pta^.trbg2; tisPageUrl = pta^.uri}; local (start = 1, count = 25); bundle { //get start and count from pta^.searchArgTable, if present if defined (pta^.searchArgTable.s) { try {start = number (pta^.searchArgTable.s)}}; if defined (pta^.searchArgTable.m) { try {count = number (pta^.searchArgTable.m)}}}; local (globeicon, lockicon); bundle { //set globeicon and lockicon globeicon = "<img src=\"mainResponderResources/userlandIcons/remote\" width=\"11\" height=\"11\" border=\"0\">"; lockicon = "<img src=\"/mainResponderResources/icons/lock\" width=\"9\" height=\"12\" border=\"0\">"}; local (htmlText = "", indentlevel = 0); on add (s) { htmlText = htmlText + (string.filledString ("\t", indentlevel) + s + "\r");}; local (flFoundSites = false); local (adrcache = mainResponder.adminSite.macros.initSiteListCache ()); local (adrincache = @adrcache^.sites); if sizeOf (adrincache) > 0 { flFoundSites = true}; bundle { //description add ("<p>Below is a list of Manila sites on this server. For more detailed information and managerial functions, click a site's name. To view a site, click the globe icon. You can also <a href=\"" + mainResponder.adminSite.urls.newSite + "\">create a new site</a>.</p>")}; bundle { //build the table that gets rendered as HTML if flFoundSites { local (yesterday = date.yesterday (clock.now ())); on shortDateTime (d) { try { if d < yesterday { return (date.shortString (d))} else { return (string.timeString (d))}} else { return (d)}}; bundle { //start the table add ("<table cellpadding=\"10\" cellspacing=\"0\" boreder=\"0\" width=\"99%\">"); indentlevel++}; <<Loop through the table of info about the sites on this server. local (numSites = sizeOf (adrincache^)); for i = start to (start + count - 1) { if i > numSites { break}; local (bgcolor); if i % 2 == 1 { bgcolor = bgcolor1} else { bgcolor = bgcolor2}; local (adrItem = @adrincache^[i]); local (editor = adrItem^.managingEditor); local (tagline = string.replaceAll (adrItem^.tagline, "\"", """)); local (editUrl = thisPageUrl + "?site=" + string.urlEncode (adrItem^.site)); local (editLink = "<a href=\"" + editUrl + "\" title=\"" + tagline + "\">" + adrItem^.displaySiteName + "</a>"); bundle { //add lock icon for editors only sites if defined (adrItem^.adrSite^.["#newsSite"].flEditorsOnlyAccessToSite) { if adrItem^.adrSite^.["#newsSite"].flEditorsOnlyAccessToSite { editLink = editLink + " " + lockicon}}}; local (siteLink, editorLink); bundle { //set siteLink, editorLink, tagline if adrItem^.flInstalled { siteLink = "<a href=\"" + adrItem^.siteUrl + "\" title=\"" + tagline + "\">" + globeIcon + "</a>"; editorLink = html.getLink (editor, adrItem^.profilesUrl + editor); try { //get the real name of the editor, if possible //PBS06/05/01: was a bundle, now a try, so errors aren't fatal local (groupName = adrItem^.membershipGroupName); local (adrInfo = mainResponder.members.getMemberTable (groupName, editor)); if (defined (adrInfo^.personalInfo.name)) and (adrInfo^.personalInfo.name != "") { editorLink = html.getLink (adrInfo^.personalInfo.name, adrItem^.profilesUrl + editor)}}} else { siteLink = ""; editorLink = string.replace (editor, "@", "\\@")}}; bundle { //add the info for this site add ("<tr bgcolor=\"" + bgcolor + "\">"); indentlevel++; add ("<td valign=\"bottom\" style=\"padding-bottom: 0px;\"><span style=\"width:11;\">" + siteLink + "</span> <b>" + editLink + "</b></td>"); add ("<td valign=\"bottom\" style=\"padding-bottom: 0px;\" class=\"small\" valign=\"bottom\"><nobr><b>" + shortDateTime (adrItem^.modified) + "</b></nobr></td>"); add ("<td valign=\"bottom\" style=\"padding-bottom: 0px;\" class=\"small\" style=\"padding-top: 0px;\" align=\"right\"><nobr><b>" + string.addCommas (adrItem^.totalHits) + "</b> hits; <b>" + adrItem^.hitsToday + "</b> today</nobr>" + "</td>"); add ("</tr>"); indentlevel--; add ("<tr bgcolor=\"" + bgcolor + "\">"); indentlevel++; add ("<td valign=\"bottom\" style=\"padding-top: 0px;\" class=\"small\">Owner: <b>" + editorLink + "</b></td>"); local (memberstring = "members"); if adrItem^.ctMembers == 1 { memberstring = "member"}; add ("<td class=\"small\" style=\"padding-top: 0px;\"><b>" + string.addCommas (adrItem^.ctMembers) + "</b> " + memberstring + "</td>"); add ("<td class=\"small\" style=\"padding-top: 0px;\" align=\"right\"><b>" + string.addCommas (adrItem^.ctMessages) + "</b> messages</td>"); add ("</tr>"); indentlevel--}}; add ("</table>"); indentlevel--}}; if not flFoundSites { add ("<hr size=\"0\" /><p>There are no sites to list at this time.</p>")}; if flFoundSites { //possibly add links to more pages local (ctsites = sizeOf (adrincache^)); if ctsites > count { add ("<b> More sites:</b>"); local (ctpages = 0); local (n = 1); while n <= ctsites { ctpages++; if n < start or n >= (start + count) { //link add ("<a href=\"" + pta^.uri + "?s=" + n + "&m=" + count + "\">" + ctpages + "</a>")} else { add ("<b>" + ctpages + "</b>")}; n = n + count}}}; return (htmlText)}; <<bundle //test code <<listSites ()
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.