Monday, November 08, 2010 at 12:04 AM.

system.verbs.builtins.mainResponder.discuss.listTopics

on listTopics (channelname="", url=nil) {
	<<Changes
		<<Mon, 01 Mar 1999 15:15:05 GMT by AR
			<<Minor optimizations in the for loop for the flonemonth==true case
			<<Also changed valign=center to valign=middle
		<<Wed, 26 May 1999 01:22:21 GMT by AR
			<<Real names of message authors are now looked up in the membership group specified thru pta^.responderAttributes.defaultMembershipGroup instead of formerly config.mainresponder.globals.defaultMembershipGroup, allowing greater flexibility while retaining backwards-compatibility.
		<<Saturday, August 21, 1999 at 9:14:02 PM by PBS
			<<Undeclared local variable adrStorage now declared.
		<<04/12/00; 12:56:00 PM by JES
			<<Localized using mainResponder.getString
			<<Localized date display
		<<05/22/00; 5:01:30 PM by JES
			<<work around problem with cached table rows -- when you change the language, they needed to be re-rendered.
	local (pta = html.getPageTableAddress ());
	if url == nil {
		url = pta^.responderattributes.urls^.discussMsgReader};
	local (flTopLevelTopics = channelname == "");
	local (htmltext = "", indentlevel = 0);
	local (membershipGroup = pta^.responderAttributes.defaultMembershipGroup);
	on add (s) {
		htmltext = htmltext + string.filledString ("\t", indentlevel) + s + "\r"};
	on td (s, align="") {
		add ("<td nowrap " + align + " valign=\"middle\"><font size=\"-1\">  " + s + "  </font></td>")};
	on shortenstring (s, maxlen=35) {
		if sizeof (s) <= maxlen {
			return (s)};
		return (string.mid (s, 1, maxlen - 3) + "...")};
	local (adrroot = mainresponder.discuss.openroot ());
	local (adrmsgs = @adrroot^.messages);
	local (i, ct = sizeof (adrmsgs^), fllist);
	local (flonemonth = false, firstdate = nil, firstmonth);
	if defined (pta^.oneMonthTopicList) {
		flonemonth = pta^.oneMonthTopicList};
	add ("<table cellspacing=\"3\">"); indentlevel++;
	bundle { //column headings; 4/13/00 JES: localized headings
		add ("<tr>"); indentlevel++;
		td ("<b>" + mainResponder.getString ("listHeaders.date") + "</b>");
		td ("<b>" + mainResponder.getString ("listHeaders.subject") + "</b>");
		td ("<b>" + mainResponder.getString ("listHeaders.originator") + "</b>");
		add ("</tr>"); indentlevel--};
	local (sitelanguage = nameOf (mainResponder.localization.getLanguageTableAddress ()^)); // 05/22/00 JES: get the current rendering language
	for i = ct downto 1 {
		local (adrstorage); //PBS 8/21/99
		adrstorage = @adrmsgs^ [i];
		if flonemonth { //break if we're in the next month
			if firstdate == nil {
				firstdate = adrstorage^.posttime;
				firstmonth = date.month (firstdate)};
			if firstmonth != date.month (adrstorage^.posttime) {
				break}};
		fllist = false;
		if flTopLevelTopics { //list all top level topics
			fllist = adrstorage^.inResponseTo == 0}
		else {
			if defined (adrstorage^.alsoListedIn) {
				fllist = adrstorage^.alsoListedIn contains channelname}};
		if defined (adrstorage^.fldeleted) {
			if adrstorage^.fldeleted {
				fllist = false}};
		if fllist {
			local (adrcache, adrcachelanguage);
			if flTopLevelTopics {
				adrcache = @adrstorage^.topTopicsCache;
				adrcachelanguage = @adrstorage^.topTopicsCacheLanguage}
			else {
				adrcache = @adrstorage^.[channelname + "Cache"];
				adrcachelanguage = @adrstorage^.[channelname + "CacheLanguage"]};
			if not defined (adrcachelanguage^) {
				adrcachelanguage^ = sitelanguage};
			if defined (adrcache^) and (string.lower (adrcachelanguage^) == string.lower (sitelanguage)) {
				add (adrcache^)}
			else {
				local (ixhtmltext = sizeof (htmltext));
				add ("<tr>"); indentlevel++;
				td (mainResponder.localization.shortDateString (adrstorage^.posttime)); // 4/13/00 JES: localized
				td (mainresponder.discuss.linkToMessage (adrstorage, url, 40));
				td (mainResponder.members.getMemberName (membershipGroup, adrstorage^.member));
				add ("</tr>"); indentlevel--;
				
				local (s = string.delete (htmltext, 1, ixhtmltext));
				adrcache^ = string.delete (s, sizeof (s), 1);
				adrcachelanguage^ = sitelanguage}}};
	add ("</table>"); indentlevel--;
	return (htmltext)}



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.