/* * 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 if (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); param.name = "content_" + param.part; delete(param.part); if (!param.height || parseInt(param.height) == 1) { param.value = encodeForm(param.value ? param.value : ""); 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.part == "title" && param.as == "link" && !part) { part = this.getRenderedContentPart ("text"); param.limit = "20"; } if (param.as == "link") { if (this._prototype != "comment") openLink(this.href()); else openLink(this.story.href()+"#"+this._id); } if (!param.limit) res.write(format(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.isOnline()) res.write("offline"); else if (parseInt(this.online,10) < 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 */ 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) return; res.write(formatTimestamp(this.createtime,param.format)); } } /** * macro rendering modifytime of story */ function modifytime_macro(param) { if (this.modifytime) { res.write(formatTimestamp(this.modifytime,param.format)); } } /** * 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 (!this.isEditDenied(session.user)) { 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 (!this.isDeleteDenied(session.user)) { 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 (!this.isEditDenied(session.user)) { param.linkto = "edit"; param.urlparam = "set=" + (this.isOnline() ? "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.isOnline() ? "set offline" : "set online"); closeMarkupElement("a"); } } /** * macro renders a link to the story */ function viewlink_macro(param) { if (this.isViewDenied(session.user)) 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.hasDiscussions()) 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.hasDiscussions()) 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(commentCnt + (param.no ? param.no : " comments")); else if (commentCnt == 1) res.write(commentCnt + (param.one ? param.one : " 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.hasDiscussions()) return; this.comments.prefetchChildren(); for (var i=0;i