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

system.verbs.builtins.radio.macros.editorsOnlyMenu

on editorsOnlyMenu (color="#FFFFFF") {
	<<Changes:
		<<11/1/01; 12:06:27 PM by DW
			<<Too fancy for what we're doing now. Call adminMenu and return what it returns.
		<<10/18/01; 8:25:36 PM by JES
			<<Fixed the System command: It wasn't properly preserving the menu switch, so you got a folderView page, but with a Home Editors Only menu, so there was no way to get to the other system pages.
		<<10/16/01; 1:06:33 AM by JES
			<<The link to a sub-menu is also a link to the first page under the sub-menu. This was initially implemented as a redirect in radio.webserver.responder, but there's a bug in IE for Windows which caused an infinite loop of redirects.
		<<10/15/01; 5:22:09 PM by JES
			<<Fixed a bug where the Home link wouldn't be boldface on the home page. The back link now navigates to the referring page, as well as changing the menu. This is the counterpart to navigating to the first page in a sub-menu when switching to the sub-menu. (See radio.webserver.responder for that code.)
		<<10/15/01; 1:52:40 AM by JES
			<<If a menu command links to the current page, embolden the command, and don't make it a link.
		<<10/9/01; 4:16:16 PM by DW
			<<If we're static rendering, replace the menu with a string that says when it was last updated. I know we should have another macro to do this, but I want to see if people like it first. This is a sneaky way to try the idea out. Shhh, don't tell anyone.
		<<9/19/01; 2:20:04 AM by JES
			<<Don't save the itemToEdit and d search args. Adding them to links in the menu, prevents the Weblog link from being used to clear the editing form, or to switch the archive calendar to the current date.
		<<8/31/01; 8:23:10 PM by JES
			<<Save the itemToEdit and d getArgs, and add them to the menu links, so that state will be preserved when changing menus.
		<<7/26/01; 3:35:56 PM by JES
			<<Fixed the Back link.
	return (radio.macros.adminMenu (color));
	
	
	local (pta = html.getpagetableaddress (), pc = file.getPathChar ());
	<<workspace.pt = pta^; edit (@workspace.pt)
	local (savedArgs = "");
	if pta^.radioResponder.flStaticRendering {
		return ("<font size=\"-1\" color=\"" + color + "\">Updated: " + date.netstandardstring (clock.now ())+ "</font>")};
	local (menuarg = "");
	if defined (pta^.radioResponder.getargs.menu) {
		menuarg =pta^.radioResponder.getargs.menu};
	local (f = pta^.radioResponder.fileBeingRendered);
	local (thisUrl = string.replaceAll (string.delete (string.popSuffix (f, '.'), 1, sizeOf (user.radio.prefs.wwwFolder)), pc, "/"));
	if string.lower (thisUrl) == "index" {
		thisUrl = "/"};
	if string.lower (thisUrl) endsWith "index" {
		thisUrl = string.popSuffix (thisUrl, "/") + "/"};
	local (folder = file.folderfrompath (f));
	local (menufile = radio.file.getSubFolder (radio.data.folderNames.wwwSystemSubfolderName + "/misc/") + "editorsOnlyMenu.opml");
	local (adrmenuxml = @system.temp.radio.menus.[menufile]);
	bundle { //read the XML text if necessary
		local (flread = true);
		if defined (adrmenuxml^) {
			if timeModified (adrmenuxml) == file.modified (menufile) {
				flread = false}};
		if flread {
			local (xmltext = string (file.readwholefile (menufile)));
			xml.compile (xmltext, adrmenuxml);
			settimemodified (adrmenuxml, file.modified (menufile))}};
	local (menustring, menuname = "Editors Only");
	bundle { //set menustring
		local (pipestring = " <b>|</b> ", itemnum = 1);
		local (adroutlinedocument = xml.getaddress (adrmenuxml, "opml"));
		local (adrbody = xml.getaddress (adroutlinedocument, "body"));
		bundle { //if the menu param is available, navigate, set global
			if menuarg != "" {
				local (i);
				for i = 1 to string.countfields (menuarg, ".") {
					adrbody = @adrbody^ [number (string.nthfield (menuarg, ".", i))];
					menuname = xml.getattribute (adrbody, "text")^}}};
		menustring = "";
		for adritem in adrbody {
			local (textatt, linkatt = "");
			if nameOf (adritem^) endsWith "\toutline" {
				local (s = xml.entityDecode (adritem^.["/atts"].text, true));
				try { //may not have a link attribute
					local (url = xml.entityDecode (adritem^.["/atts"].url, true));
					local (flLinkIsThisPage = false);
					bundle { //set flLinkIsThisPage
						if string.popLeading (string.lower (thisUrl), '/') == string.popLeading (string.lower (url), '/') {
							flLinkIsThisPage = true};
						if defined (pta^.radioResponder.getArgs.folderView) {
							if pta^.radioResponder.getArgs.folderView != "0" {
								if string.lower (url) contains "folderview=1" {
									flLinkIsThisPage = true}}}};
					if flLinkIsThisPage { //make it bold, but not a link
						s = " <b><font color=\"" + color + "\" size=\"-1\">" + s + "</font></b>"}
					else { //make the command a link
						local (flHomeLink = (url == "/"));
						if not flHomeLink {
							if url contains "?" {
								url = url + "&"}
							else {
								url = url + "?"};
							url = url + "menu=" + menuarg + savedArgs};
						s = " <a href=\"" + url + "\"><font color=\"" + color + "\" size=\"-1\">" + s + "</font></a>"}}
				else { //sub-menu -- link to the first sub-page, and switch the menu
					local (url = "");
					bundle { //set the path part of the url
						local (adrcommand);
						for adrcommand in adritem {
							if defined (adrcommand^.["/atts"].url) {
								url = adrcommand^.["/atts"].url;
								break}}};
					if url contains "?" {
						url = url + "&"}
					else {
						url = url + "?"};
					url = url + "menu=";
					if menuarg != "" {
						url = url + menuarg + "."};
					url = url + itemnum + savedArgs;
					s = "<a href=\"" + url + "\"><font color=\"" + color + "\" size=\"-1\">" + s + "</font></a>"};
				s = s + pipestring;
				menustring = menustring + s};
			itemnum++};
		if menuarg != "" { //add Back link
			local (url = "");
			if defined (pta^.requestHeaders.referer) {
				url = string.nthField (pta^.requestHeaders.referer, "?", 1)};
			if menuarg contains "." {
				url = url + "?menu=" + string.popsuffix (menuarg, ".")}
			else {
				url = url + "?menu="};
			url = url + savedArgs;
			menustring = menustring + "<a href=\"" + url + "\"><font color=\"" + color + "\" size=\"-1\">Back</font></a>"}
		else { //pop off last pipe
			menustring = string.mid (menustring, 1, sizeof (menustring) - sizeof (pipestring))}};
	return ("<font size=\"-1\" color=\"" + color + "\"><b>" + menuname + "</b>: " + menustring + "</font>")};
bundle { //test code
	local (pta = @workspace.pt);
	html.setpagetableaddress (pta);
	<<new (tabletype, @pta^.radioResponder.getargs)
	<<pta^.radioResponder.getargs.menu = "3"
	editorsonlymenu ()}



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.