/* * macro for rendering a part of the content. */ function content_macro(param) { // moved the check for old property layout to // objectFunctions.js/getContentPart() because // this function is called directly sometimes [ts] if (param.as == "editor") { // this is a first trial to add a title like // "Re: title of previous posting" to a new posting // (works only if autoresponse="true" is set in the macro) if (param.autoresponse == "true" && param.part == "title" && !this.content) { if (path.comment && path.comment.title) param.value = "Re: " + path.comment.title; else if (path.story && path.story.title) param.value = "Re: " + path.story.title; } else param.value = this.getContentPart(param.part); // if there's still no value get it from request.data if available: if (!param.value && req.data[param.part]) param.value = unescape(req.data[param.part]); param.name = "content_" + param.part; delete(param.part); if (!param.height || parseInt(param.height,10) == 1) renderInputText(param); else renderInputTextarea(param); } else if (param.as == "image") { var part = this.getContentPart (param.part); if (part && this.site.images[part]) { delete (param.part); renderImage (this.site.images[part], param); } // see comment at the beginning of this function // } else if (!this.content) { // return; } else { var part = this.getRenderedContentPart (param.part); if (!part && param.fallback) part = this.getRenderedContentPart (param.fallback); if (param.as == "link") { if (this._prototype != "comment") openLink(this.href()); else openLink(this.story.href()+"#"+this._id); if (!part && param.part == "title") { part = this.getRenderedContentPart ("text"); param.limit = "20"; } } if (!param.limit) res.write(part); else res.write(softwrap(clipText(part, param.limit, param.clipping))); if (param.as == "link") closeLink(); } } /** * macro rendering title of story */ function title_macro(param) { param.part = "title"; this.content_macro (param); } /** * macro rendering text of story */ function text_macro(param) { param.part = "text"; this.content_macro (param); } /** * macro rendering online-status of story */ function online_macro(param) { if (param.as == "editor") { var options = new Array("offline","online in topic","online in weblog"); renderDropDownBox("online",options,this.online); } else { if (!this.online) res.write("offline"); else if (this.online < 2) { res.write("online in "); openLink(this.site.topics.get(this.topic).href()); res.write(this.topic); closeLink(); } else res.write("online in weblog"); } } /** * macro rendering createtime of story, either as editor, * plain text or as link to the frontpage of the day */ function createtime_macro(param) { if (param.as == "editor") { if (this.createtime) param.value = formatTimestamp(this.createtime, "yyyy-MM-dd HH:mm"); else param.value = formatTimestamp(new Date(), "yyyy-MM-dd HH:mm"); param.name = "createtime"; renderInputText(param); } else if (this.createtime) { var text = formatTimestamp(this.createtime,param.format); if (param.as == "link" && this.online == 2) { openLink(this.site.get(String(this.day)).href()); res.write(text); closeLink(); } else res.write(text); } return; } /** * macro renders the name of the author * !!! left for backwards-compatibility !!! */ function author_macro(param) { this.creator_macro(param); } /** * macro renders the name of the modifier */ function modifier_macro(param) { if (!this.modifier) return; if (param.as == "link" && this.modifier.url) { openLink(this.modifier.url); res.write(this.modifier.name); closeLink(); } else res.write(this.modifier.name); } /** * macro renders the url of this story */ function url_macro(param) { res.write(this.href()); } /** * macro rendering a link to edit * if user is allowed to edit */ function editlink_macro(param) { if (session.user && !this.isEditDenied(session.user,req.data.memberlevel)) { openLink(this.href("edit")); if (param.image && this.site.images.get(param.image)) this.site.renderImage(this.site.images.get(param.image),param); else res.write(param.text ? param.text : "edit"); closeLink(); } } /** * macro rendering a link to delete * if user is creator of this story */ function deletelink_macro(param) { if (session.user && !this.isDeleteDenied(session.user,req.data.memberlevel)) { openLink(this.href("delete")); if (param.image && this.site.images.get(param.image)) this.site.renderImage(this.site.images.get(param.image),param); else res.write(param.text ? param.text : "delete"); closeLink(); } } /** * macro renders a link to * toggle the online-status of this story */ function onlinelink_macro(param) { if (session.user && !this.isEditDenied(session.user,req.data.memberlevel)) { if (this.online && param.mode != "toggle") return; param.linkto = "edit"; param.urlparam = "set=" + (this.online ? "offline" : "online"); openMarkupElement("a",this.createLinkParam(param)); if (param.image && this.site.images.get(param.image)) this.site.renderImage(this.site.images.get(param.image),param); else res.write(this.online ? "set offline" : "set online"); closeMarkupElement("a"); } } /** * macro renders a link to the story */ function viewlink_macro(param) { if (session.user && this.isViewDenied(session.user,req.data.memberlevel)) return; openLink(this.href()); if (param.image && this.site.images.get(param.image)) this.site.renderImage(this.site.images.get(param.image),param); else res.write(param.text ? param.text : "view"); closeLink(); } /** * macro rendering link to comments */ function commentlink_macro(param) { if (!this.discussions || !this.site.discussions) return; openLink(this.href(param.to ? param.to : "comment")); res.write(param.text ? param.text : "place your comment"); closeLink(); } /** * macro renders number of comments * options: text to use when no comment * text to use when one comment * text to use when more than one comment * action to link to (default: main) */ function commentcounter_macro(param) { if (!this.discussions) return; var commentCnt = this.comments.count(); if (!param.linkto) param.linkto = "main"; // cloning the param object to remove the macro-specific // attributes from the clone for valid markup output: var param2 = cloneObject(param); delete param2.one; delete param2.more; delete param2.no; var linkflag = (param.as == "link" && param.as != "text" || !param.as && commentCnt > 0); if (linkflag) openMarkupElement("a", this.createLinkParam(param2)); if (commentCnt == 0) res.write(param.no ? param.no : "0 comments"); else if (commentCnt == 1) res.write(param.one ? param.one : "1 comment"); else res.write(commentCnt + (param.more ? param.more : " comments")); if (linkflag) closeMarkupElement("a"); return; } /** * macro loops over comments and renders them */ function comments_macro(param) { var s = this.story ? this.story : this; if (!s.discussions) return; this.comments.prefetchChildren(); for (var i=0;i