Macros for the Blog application
Log-in
|
Blog
:
Welcome to your wiki
>
Wiki blog
>
Macros for the Blog application
Top Menu
Show
:
Comments
Attachments
History
Information
Stampa
:
Stampa
Anteprima di stampa
Esporta come PDF
Esporta in formato RTF
Esporta come HTML
Esporta in formato XAR
Wiki source code of
Macros for the Blog application
Show line numbers
#includeMacros("Blog.BlogParameters") ## ## ## ## Import the blog skin and javascripts. $!xwiki.ssx.use($blogStyleDocumentName)## $!xwiki.jsx.use($blogScriptsDocumentName)## ## ## ## #** * Prints a blog. This is the main macro used in the BlogSheet. * * @param blogDoc the XDocument holding the blog definition object. *### #macro(printBlog $blogDoc) #getBlogEntries($blogDoc $entries) #displayBlog($entries ’index’ true) #displayNavigationLinks($blogDoc) #includeInContext(’Blog.CreatePost’) #end ## ## ## #** * Shows blog information. In view mode, the title and description are printed. In inline edit mode, allows changing * blog settings: title, description, blog type (global or in-space), index display type (fixed size pagination, weekly * index, monthly index, all entries). * * @param blogDoc The blog document. It should contain a <tt>Blog.BlogClass</tt> object. *### #macro(showBlogInfo $blogDoc) #if($blogDoc.getObject($blogClassname)) #if($context.action == ’inline’) #macro(displayProperty $blogDoc $propname) <dt>#displayPropName($xwiki.getClass($blogClassname).get($propname)):</dt> <dd>$blogDoc.display($propname)</dd> #end <dl> #displayProperty($blogDoc ’title’) #displayProperty($blogDoc ’description’) #displayProperty($blogDoc ’blogType’) #displayProperty($blogDoc ’displayType’) #displayProperty($blogDoc ’itemsPerPage’) </dl> #else #getBlogTitle($blogDoc $title) #if($title != "") 1 $title #end $blogDoc.display(’description’) #end #elseif($doc.fullName == $blogSheet) 1 $msg.get("xe.blog.code.blogsheet") $msg.get("xe.blog.code.sheetexplanation") #else #warning($msg.get("xe.blog.code.notblog")) #end #end ## ## ## #** * Retrieve the blog document, which usually is either <tt><Space>.WebHome</tt> for whole-spaces blogs, or * <tt><Space>.Blog</tt> for in-space blogs. If none of these documents contains a blog object, then the first * (alphabetically) document in the target space that contains one is returned. Finally, if no document in the current * space contains a blog object, then <tt>Blog.WebHome</tt> is returned as the default blog. * * @param space A <tt>String</tt>, the name of the space where to search. * @param blogDoc The resulting XDocument. *### #macro(getBlogDocument $space $blogDoc) ## First, try the Space.WebHome, for a whole-space blog #set($blogDoc = $xwiki.getDocument("${space}.WebHome")) #if(!$blogDoc.getObject($blogClassname)) ## Second, try the Space.Blog document #set($blogDoc = $xwiki.getDocument("${space}.Blog")) #if(!$blogDoc.getObject($blogClassname)) ## Third, try searching for a blog document in the current space #set($blogDocs = $xwiki.searchDocuments(", BaseObject obj where doc.space = ’${space}’ and obj.name = doc.fullName and obj.className = ’$blogClassname’ order by doc.name")) #if($blogDocs.size() > 0) #set($blogDoc = $xwiki.getDocument($blogDocs.get(0))) #else ## Last, fallback to Blog.WebHome, the default blog #set($blogDoc = $xwiki.getDocument(’Blog.WebHome’)) #end #end #end #end ## ## ## #** * Retrieve the blog title. * * @param blogDoc The blog document. It should contain a <tt>Blog.BlogClass<tt> object with the <tt>title</tt> property set. * @param title The resulting title. *### #macro(getBlogTitle $blogDoc $title) #getBlogProperty($blogDoc ’title’ $!blogDoc.displayTitle $title) #end ## ## ## #** * Retrieve the blog description. * * @param blogDoc The blog document. It should contain a <tt>Blog.BlogClass</tt> object with the <tt>description</tt> * property set. * @param description The resulting description. *### #macro(getBlogDescription $blogDoc $description) #getBlogProperty($blogDoc ’description’ ’’ $description) #end ## ## ## #** * Retrieves a list of entries to be displayed. The entries are either part of the blog’s space, or have the blog * document set as a parent. The number and range of entries returned (from all those belonging to this blog) depends on * the blog display type: paginated (fixed number of entries), weekly (all entries in a week), monthly (all entries in a * month), or all. * * @param blogDoc The blog document. It should contain a <tt>Blog.BlogClass</tt> object. * @param entries The resulting list of entries to display, a list of XDocument names. *### #macro(getBlogEntries $blogDoc $entries) #getBlogEntriesBaseQuery($query) #isBlogGlobal($blogDoc $isGlobal) #if(!$isGlobal) #set($query = "${query} and (doc.space = ’${blogDoc.space}’ or doc.parent = ’${blogDoc.fullName}’)") #end #getBlogDisplayType($blogDoc $displayType) #if($displayType == ’weekly’) #getWeeklyBlogEntries($blogDoc $query $entries) #elseif($displayType == ’monthly’) #getMonthlyBlogEntries($blogDoc $query $entries) #elseif($displayType == ’all’) #getAllBlogEntries($blogDoc $query $entries) #else #getPagedBlogEntries($blogDoc $query $entries) #end #end ## ## ## #** * Retrieves a list of entries to be displayed. The entries are taken from a "page" of the blog, a sequence of documents * defined by the request parameters <tt>ipp</tt> (items per page) and <tt>page</tt> (the current page). Initially the * first page is displayed, with the number of entries defined in the blog object in the <tt>itemsPerPage</tt> property * (10 if not defined). * * @param blogDoc The blog document. It should contain a <tt>Blog.BlogClass</tt> object. * @param query The base query for selecting entries. Apart from the base query that selects entries, it can further be * refined to restrict to a given space, or to a given search criteria, etc. * @param entries The resulting list of entries to display, a list of XDocument names. *### #macro(getPagedBlogEntries $blogDoc $query $entries) #set($totalEntries = $xwiki.countDocuments(${query})) #getBlogProperty($blogDoc ’itemsPerPage’ ’10’ $defaultItemsPerPage) #set($defaultItemsPerPage = $util.parseInt($defaultItemsPerPage)) ## This macro is defined in the default macros.vm library. It also sets $itemsPerPage and $startAt. #preparePagedViewParams($totalEntries $defaultItemsPerPage) #set($entries = $xwiki.searchDocuments("${query} order by publishDate.value desc", $itemsPerPage, $startAt)) #end ## ## ## #** * Retrieves a list of entries to be displayed. The entries are taken from a week of the blog. The target week is * defined by the request parameters <tt>week</tt> (the week number in the year, from 1 to 52) and <tt>year</tt> (4 * digit year). Initially the current week is displayed. * * @param blogDoc The blog document. It should contain a <tt>Blog.BlogClass</tt> object. * @param query The base query for selecting entries. Apart from the base query that selects entries, it can further be * refined to restrict to a given space, or to a given search criteria, etc. * @param entries The resulting list of entries to display, a list of XDocument names. *### #macro(getWeeklyBlogEntries $blogDoc $query $entries) #getRequestedWeek($weekDate) #set($dateFormatter = $xwiki.jodatime.getDateTimeFormatterForPattern("yyyy-MM-dd")) #set($minDay = $dateFormatter.print($weekDate.toMutableDateTime().weekOfWeekyear().roundFloor())) #set($maxDay = $dateFormatter.print($weekDate.toMutableDateTime().weekOfWeekyear().roundCeiling())) #set($query = "${query} and publishDate.value >= ’$minDay’ and publishDate.value < ’$maxDay’") #set($totalEntries = $xwiki.countDocuments(${query})) #set($entries = $xwiki.searchDocuments("${query} order by publishDate.value desc")) #end ## ## ## #** * Retrieves a list of entries to be displayed. The entries are taken from a month of the blog. The target month is * defined by the request parameters <tt>month</tt> (the month number, from 1 to 12) and <tt>year</tt> (4 * digit year). Initially the current month is displayed. * * @param blogDoc The blog document. It should contain a <tt>Blog.BlogClass</tt> object. * @param query The base query for selecting entries. Apart from the base query that selects entries, it can further be * refined to restrict to a given space, or to a given search criteria, etc. * @param entries The resulting list of entries to display, a list of XDocument names. *### #macro(getMonthlyBlogEntries $blogDoc $query $entries) #getRequestedMonth($monthDate) #set($dateFormatter = $xwiki.jodatime.getDateTimeFormatterForPattern("yyyy-MM-dd")) #set($minDay = $dateFormatter.print($monthDate.toMutableDateTime().monthOfYear().roundFloor())) #set($maxDay = $dateFormatter.print($monthDate.toMutableDateTime().monthOfYear().roundCeiling())) #set($query = "${query} and publishDate.value >= ’$minDay’ and publishDate.value < ’$maxDay’") #set($totalEntries = $xwiki.countDocuments(${query})) #set($entries = $xwiki.searchDocuments("${query} order by publishDate.value desc")) #end ## ## ## #** * Retrieves a list of entries to be displayed. All entries belonging to the current blog are returned. * * @param blogDoc The blog document. It should contain a <tt>Blog.BlogClass</tt> object. * @param query The base query for selecting entries. Apart from the base query that selects entries, it can further be * refined to restrict to a given space, or to a given search criteria, etc. * @param entries The resulting list of entries to display, a list of XDocument names. *### #macro(getAllBlogEntries $blogDoc $query $entries) #set($totalEntries = $xwiki.countDocuments(${query})) #set($entries = $xwiki.searchDocuments("${query} order by publishDate.value desc")) #end ## ## ## #** * Retrieves a list of entries to be displayed. Only (and all) unpublished entries are returned. * * @param blogDoc The blog document. It should contain a <tt>Blog.BlogClass</tt> object. * @param query The base query for selecting entries. Apart from the base query that selects entries, it can further be * refined to restrict to a given space, or to a given search criteria, etc. * @param entries The resulting list of entries to display, a list of XDocument names. *### #macro(getUnpublishedBlogEntries $blogDoc $query $entries) #set($query = "${query} and isPublished.value = 0") #set($totalEntries = $xwiki.countDocuments(${query})) #set($entries = $xwiki.searchDocuments("${query} order by publishDate.value desc")) #end ## ## ## #** * Retrieves a list of entries to be displayed. The entries are taken from all the wiki, and not from a specific blog. * * @param entries The resulting list of entries to display, a list of XDocument names. *### #macro(getGlobalBlogEntries $entries) #getBlogEntriesBaseQuery($query) #set($totalEntries = $xwiki.countDocuments(${query})) #set($defaultItemsPerPage = 20) ## This macro is defined in the default macros.vm library. It also sets $itemsPerPage and $startAt. #preparePagedViewParams($totalEntries $defaultItemsPerPage) #set($entries = $xwiki.searchDocuments("${query} order by publishDate.value desc", $itemsPerPage, $startAt)) #end ## ## ## #** * Return the base query for selecting blog entries. It filters only visible entries, but does not bind to a specific * blog, nor specify a range or an ordering criteria. * * @param query The basic query for selecting blog entries. *### #macro(getBlogEntriesBaseQuery $query) #set ($query = ", BaseObject obj, IntegerProperty isPublished, IntegerProperty hidden, DateProperty publishDate where doc.fullName <> ’Blog.BlogPostTemplate’ and obj.name = doc.fullName and obj.className = ’${blogPostClassname}’ and publishDate.id.id = obj.id and publishDate.id.name = ’publishDate’ and isPublished.id.id = obj.id and isPublished.id.name = ’published’ and hidden.id.id = obj.id and hidden.id.name = ’hidden’ and (doc.creator = ’$context.user’ or (isPublished.value = 1 and hidden.value = 0))") #end ## ## ## #** * Checks if the provided blog is global or in-space. * * @param blogDoc The blog document. It should contain a <tt>Blog.BlogClass</tt> object with the <tt>blogType</tt> property set. * @param isGlobal The resulting boolean. If the blog object does not define anything, it is considered in-space. *### #macro(isBlogGlobal $blogDoc $isGlobal) #set($isGlobal = false) #getBlogProperty($blogDoc ’blogType’ ’’ $discard) #if($discard == ’global’) #set($isGlobal = true) #end #end ## ## ## #** * Determines how is the blog index split into pages: paginated (fixed number of entries), weekly (all entries in a * week), monthly (all entries in a month), or all. * * @param blogDoc The blog document. It should contain a <tt>Blog.BlogClass</tt> object with the <tt>displayType</tt> * property set. * @param displayType The resulting string. If the blog object does not define anything, it is considered paginated. *### #macro(getBlogDisplayType $blogDoc $displayType) #getBlogProperty($blogDoc ’displayType’ ’paginated’ $displayType) #end ## ## ## #** * Displays a list of entries. * * @param entries The entries to display, a list of XDocument names. * @param displaying What exactly is displayed: blog index, a single blog entry, a blog category, search results, * unpublished entries, etc. This will be used as the classname(s) for the container div (hfeed). Currently * used values: index, single, category, search, unpublished, hidden. * @param onlyExtract If <tt>true</tt>, only display the extract of articles where available, otherwise display the full content. *### #macro(displayBlog $entries $displaying $onlyExtract) #set($blogDay = "") <div class="hfeed $!{displaying}"> <div class="blogDay"> #foreach ($entry in $entries) #set($entryDoc = $xwiki.getDocument($entry)) ## This fails if the document is not accessible, due to access rights. #if($entryDoc.fullName == $entry) #getEntryObject($entryDoc $entryObj) ## Although all entries should have one of the two objects, better check to be sure. #if("$!{entryObj}" != ’’) #getEntryDate($entryDoc $entryObj $entryDate) ## Display a "calendar sheet" for each day. All entries posted on the same day share one such sheet. #set($entryDateStr = $xwiki.formatDate($entryDate, ’yyyyMMMMdd’)) #if($blogDay != $entryDateStr) #if($blogDay != ’’) </div> <div class="blogDay"> #end #displayBlogDate($entryDate) #set ($blogDay = $entryDateStr) #end ## Finally, display the entry. #displayEntry($entryDoc $entryObj $onlyExtract) #end #end #end </div> ## blogDay </div> ## hfeed #end ## ## ## #** * Get the entry object, either a new BlogPost or an old Article. * * @param entryDoc The xdocument of the blog post. Each post resides in its own document. * @param entryObj The resulting xobject of the blog post. *### #macro(getEntryObject $entryDoc $entryObj) #set($entryObj = ’’) #set($entryObj = $entryDoc.getObject("${blogPostClassname}")) #if("$!{entryObj}" == ’’) #set($entryObj = $entryDoc.getObject("${oldArticleClassname}")) #end #end ## ## ## #** * Gets the date associated with a blog entry. This is the publication date. For unpublished entries, initially this is * the document creation date, but can be edited by the user. * * @param entryDoc The xdocument of the blog post. Each post resides in its own document. * @param entryObj The xobject of the blog post, an instance of the <tt>Blog.BlogPostClass</tt> xclass. * @param result The resulting date, an instance of <tt>java.util.Date</tt>. *### #macro(getEntryDate $entryDoc $entryObj $result) #set($result = $entryObj.getProperty(’publishDate’).value) #end ## ## ## #** * Displays a date, nicely formatted as a calendar page. * * @param date The date to display, an instance of <tt>java.util.Date</tt>. *### #macro(displayBlogDate $date) #set($year = $xwiki.formatDate($date, "yyyy")) ## 3 letter month name, like Jan, Dec. #set($month = $xwiki.formatDate($date, "MMM")) ## Uncomment to get a full length month name, like January, December. ## TODO: this could be defined somewhere in the blog style. ## #set($month = $xwiki.formatDate($date, "MMMM")) #set($day = $xwiki.formatDate($date, "dd")) <h2 class="blogdate">## title="#formatdateISO($date)"> <span class="month">$month</span> <span class="day">$day</span> <span class="year">$year</span> </h2> #end ## ## ## #** * Displays a blog article: management tools, header, content, footer. * * @param entryDoc The xdocument of the blog post. Each post resides in its own document. * @param entryObj The xobject of the blog post, an instance of the <tt>Blog.BlogPostClass</tt> xclass. * @param onlyExtract If <tt>true</tt>, try to display only a summary of the entry, instead of the full content. *### #macro(displayEntry $entryDoc $entryObj $onlyExtract) ## Only articles with an explicit hidden setting or an explicit unpublished setting are hidden #isPublished($entryObj $isPublished) #isHidden($entryObj $isHidden) #if($doc.fullName == $entryDoc.fullName) <div class="hentry single-article"> #else <div class="hentry#if(!$isPublished) unpublished-article#elseif($isHidden) hidden-article#end"> #end #displayEntryTools($entryDoc $entryObj) #displayEntryTitle($entryDoc $entryObj) #if($doc.fullName == $entryDoc.fullName) #if(!$isPublished) #warning($msg.get("xe.blog.code.published")) #elseif($isHidden) #warning($msg.get("xe.blog.code.hidden")) #end #end #displayEntryContent($entryDoc $entryObj $onlyExtract) #displayEntryFooter($entryDoc $entryObj) </div> ## hentry #end ## ## ## #** * Checks if the provided blog is published or not. * * @param entryObj The xobject of the blog post, an instance of the <tt>Blog.BlogPostClass</tt> xclass. * @param isPublished The resulting boolean, true if the entry is considered published. *### #macro(isPublished $entryObj $isPublished) ## This should work for both old articles, which don’t have the ’published’ property at all, and ## are considered published by default, and new entries, that should have 1 if published. #set($isPublished = ("$!{entryObj.getProperty(’published’).value}" != ’0’)) #end ## ## ## #** * Checks if the provided blog is hidden or not. * * @param entryObj The xobject of the blog post, an instance of the <tt>Blog.BlogPostClass<tt> xclass. * @param isHiddel The resulting boolean, true if the entry is considered hidden. *### #macro(isHidden $entryObj $isHidden) ## This should work for both old articles, which don’t have the ’hidden’ property at all, and ## are considered visible by default, and new entries, that should have 1 if hidden. #set($isHidden = ("$!{entryObj.getProperty(’hidden’).value}" == ’1’)) #end ## ## ## #** * Displays several "tools" for manipulating blog posts: hide/show, publish, edit. * * @param entryDoc The xdocument of the blog post. Each post resides in its own document. * @param entryObj The xobject of the blog post, an instance of the <tt>Blog.BlogPostClass</tt> xclass. *### #macro(displayEntryTools $entryDoc $entryObj) #if($context.action != ’preview’) <div class="blog-entry-toolbox"> #displayPublishButton($entryDoc $entryObj) #displayHideShowButton($entryDoc $entryObj) #displayEditButton($entryDoc $entryObj) #displayDeleteButton($entryDoc $entryObj) </div> #end #end ## ## ## #** * Displays the publish button to the entry <strong>creator</strong>, if the article is not published yet. * * @param entryDoc The xdocument of the blog post. Each post resides in its own document. * @param entryObj The xobject of the blog post, an instance of the <tt>Blog.BlogPostClass</tt> xclass. * @todo AJAX calls. *### #macro(displayPublishButton $entryDoc $entryObj) #isPublished($entryObj $isPublished) #if(!$isPublished && $entryDoc.creator == $context.user && $xwiki.hasAccessLevel("edit", $context.user, $entryDoc.fullName)) <a href="$blogPublisher.getURL(’view’, "entryName=${util.encodeURI($entryDoc.fullName)}&xredirect=${util.encodeURI($thisURL)}")" title="$msg.get("xe.blog.code.notpublished")">#toolImage(’publish.png’ ’publish ’)</a>## #end #end ## ## ## #** * Displays the hide or show button to the entry <strong>creator</strong>, if the article is already published. * * @param entryDoc The xdocument of the blog post. Each post resides in its own document. * @param entryObj The xobject of the blog post, an instance of the <tt>Blog.BlogPostClass</tt> xclass. *### #macro(displayHideShowButton $entryDoc $entryObj) #isPublished($entryObj $isPublished) #isHidden($entryObj $isHidden) ## Only published articles can be hidden. Unpublished articles are considered already hidden. #if($isPublished && $entryDoc.creator == $context.user && $xwiki.hasAccessLevel(’edit’, $context.user, $entryDoc.fullName)) #if ($isHidden) <a class="blog-tool-show" href="$entryDoc.getURL(’save’, "${entryObj.getxWikiClass().getName()}_${entryObj.number}_hidden=0&comment=$msg.get(’xe.blog.code.madevisible’)&xredirect=${util.encodeURI($thisURL)}")" title="$msg.get("xe.blog.code.makevisible")">#toolImage(’show.png’, ’show ’)</a>## #else <a class="blog-tool-hide" href="$entryDoc.getURL(’save’, "${entryObj.getxWikiClass().getName()}_${entryObj.number}_hidden=1&comment=$msg.get(’xe.blog.code.hid’)&xredirect=${util.encodeURI($thisURL)}")" title="$msg.get("xe.blog.code.hide")">#toolImage(’hide.png’ ’hide ’)</a>## #end #end #end ## ## ## #** * Displays the edit button to those that can edit the article. * * @param entryDoc The xdocument of the blog post. Each post resides in its own document. * @param entryObj The xobject of the blog post, an instance of the <tt>Blog.BlogPostClass</tt> xclass. *### #macro(displayEditButton $entryDoc $entryObj) #if($xwiki.hasAccessLevel("edit", $context.user, $entryDoc.fullName)) <a href="$entryDoc.getURL(’inline’)" title="$msg.get("xe.blog.code.editpost")">#toolImage(’edit.png’ ’edit ’)</a>## #end #end ## ## ## #** * Displays the delete button to those that can edit the article. * * @param entryDoc The xdocument of the blog post. Each post resides in its own document. * @param entryObj The xobject of the blog post, an instance of the <tt>Blog.BlogPostClass</tt> xclass. * @todo AJAX calls. *### #macro(displayDeleteButton $entryDoc $entryObj) #if($xwiki.hasAccessLevel("delete", $context.user, $entryDoc.fullName)) <a href="$entryDoc.getURL(’delete’)" title="$msg.get("xe.blog.code.deletepost")">#toolImage(’delete.png’ ’delete ’)</a>## #end #end ## ## ## #** * Displays the title of the entry. * * @param entryDoc The xdocument of the blog post. Each post resides in its own document. * @param entryObj The xobject of the blog post, an instance of the <tt>Blog.BlogPostClass</tt> xclass. *### #macro(displayEntryTitle $entryDoc $entryObj) #if($doc.fullName == $entryDoc.fullName) <h1 class="entry-title">$entryDoc.display(’title’, ’view’, $entryObj)</h1> #else <h3 class="entry-title"><a href="$entryDoc.getURL()">$entryDoc.display(’title’, ’view’, $entryObj)</a></h3> #end #end ## ## ## #** * Displays the body of the entry. * * @param entryDoc The xdocument of the blog post. Each post resides in its own document. * @param entryObj The xobject of the blog post, an instance of the <tt>Blog.BlogPostClass</tt> xclass. * @param onlyExtract If <tt>true</tt>, try to display only a summary of the entry, instead of the full content. *### #macro(displayEntryContent $entryDoc $entryObj $onlyExtract) <div class="#if($onlyExtract)entry-summary#{else}entry-content#end"> #getEntryContent($entryDoc $entryObj $onlyExtract $entryContent) ## $doc.display does not render non-1.0 syntaxes. #if($!entryDoc.syntaxId == ’xwiki/1.0’) $entryContent #else $entryDoc.getRenderedContent($entryContent, $entryDoc.getSyntaxId()) #end </div> ## entry-content #end ## ## ## #** * Extracts the body of the entry that should be displayed. If <tt>onlyExtract</tt> is <tt>true</tt>, display the content * of the <tt>extract</tt> field (if not empty). * * @param entryDoc The xdocument of the blog post. Each post resides in its own document. * @param entryObj The xobject of the blog post, an instance of the <tt>Blog.BlogPostClass</tt> xclass. * @param onlyExtract If <tt>true</tt>, try to display only a summary of the entry, instead of the full content. * @param entryContent The resulting content. *### #macro(getEntryContent $entryDoc $entryObj $onlyExtract $entryContent) #if($onlyExtract) #set($entryContent = $entryDoc.display(’extract’, ’view’, $entryObj)) #end #if("$!entryContent" == ’’) #set($entryContent = $entryDoc.display(’content’, ’view’, $entryObj)) #* Disabled until the content can be cleanly cut. * #if($onlyExtract && $content.length()>$maxchars) * #set($i = $content.lastIndexOf(" ", $maxchars)) * #set($i = $i + 1) * #set($content = "${content.substring(0,$i)} *[...>${entryDoc.fullName}]*") * #end ## *### #else #set($entryContent = "${entryContent} <a href=’${entryDoc.getURL()}’ title=’$msg.get(’xe.blog.code.readpost’)’>...</a>") #end #end ## ## ## #** * Displays the footer of the entry. * * @param entryDoc The xdocument of the blog post. Each post resides in its own document. * @param entryObj The xobject of the blog post, an instance of the <tt>Blog.BlogPostClass</tt> xclass. *### #macro(displayEntryFooter $entryDoc $entryObj) <div class="entry-footer"> #isPublished($entryObj $isPublished) #if($isPublished) $msg.get("xe.blog.code.postedby") ## #else $msg.get("xe.blog.code.createdby") ## #end <address class="author vcard">#userfn($entryDoc.creator)</address> ## #getEntryDate($entryDoc $entryObj $entryDate) at <abbr class="published" title="#formatdateISO($entryDate)">$xwiki.formatDate($entryDate, "MMM dd, yyyy HH:mm")</abbr>## #listCategories($entryObj)## ## Since the publish date and update date are not set at the exact same time, there could be a small difference that ## we assume cannot be more than 3 seconds. #if($entryDoc.date.time - $entryDate.time > 3000) | $msg.get("xe.blog.code.modifiedby") <address class="author vcard">#userfn($entryDoc.author)</address> ## at <abbr class="updated" title="#formatdateISO($entryDoc.date)">$xwiki.formatDate($entryDoc.date, "MMM dd, yyyy HH:mm")</abbr> ## #end | <a href="$entryDoc.getURL(’view’, ’#Comments’)">$entryDoc.comments.size() $msg.get("xe.blog.code.comments")</a> ## | <a href="$entryDoc.getURL(’view’)" rel="bookmark">$msg.get("xe.blog.code.permalink")</a> </div> ## entry-footer #end ## ## ## #** * List the categories an entry belongs to. Used in the footer. The categories are instances of <tt>Blog.CategoryClass</tt>. * * @param entryObj The xobject of the blog post, an instance of the <tt>Blog.BlogPostClass</tt> xclass. *### #macro(listCategories $entryObj) #if($entryObj.getxWikiClass().getName() == $blogPostClassname) #set($categories = $entryObj.getProperty(’category’).value) #set($first = true) #if($categories.size() > 0) #foreach($category in $categories) ## Do not indent #set($categoryDoc = $!xwiki.getDocument($category)) #if(!$categoryDoc.isNew() && $categoryDoc.getObject(${blogCategoryClassname})) #if($first) $msg.get("xe.blog.code.in") #set($first = false) #else, #end## if first <a rel="tag" href="$xwiki.getURL(${category})">$!xwiki.getDocument($category).getObject($blogCategoryClassname).getProperty(’name’).value</a>## #end## if isNew #end## foreach #end #end #end ## ## ## #** * Displays blog pagination links (older and newer entries). * * @param blogDoc the XDocument holding the blog definition object. *### #macro(displayNavigationLinks $blogDoc) <div class="clearfloats"></div> #getBlogDisplayType($blogDoc $displayType) #if($displayType == ’weekly’) <div class="pagingLinks"> #getRequestedWeek($weekDate) $weekDate.addWeeks(-1)## <span class="prevPage">*[« $msg.get("xe.blog.code.previousweek")>$doc.name?year=$weekDate.weekyear&week=$weekDate.weekOfWeekyear]*</span> #sep() $weekDate.addWeeks(2)## 2 because we already subtracted 1 above <span class=" nextPage">*[$msg.get("xe.blog.code.nextweek") »>$doc.name?year=$weekDate.weekyear&week=$weekDate.weekOfWeekyear]*</span> </div> #elseif($displayType == ’monthly’) <div class="pagingLinks"> #getRequestedMonth($monthDate) $monthDate.addMonths(-1)## <span class="prevPage">*[« $msg.get("xe.blog.code.previousmonth")>$doc.name?year=$monthDate.year&month=$monthDate.monthOfYear]*</span> #sep() $monthDate.addMonths(2)## 2 because we already subtracted 1 above <span class=" nextPage">*[$msg.get("xe.blog.code.nextmonth") »>$doc.name?year=$monthDate.year&month=$monthDate.monthOfYear]*</span> </div> #elseif($displayType == ’all’) #else ## Paginated #if(($totalPages > 1)) #set($queryString = "") #foreach($p in $request.getParameterNames()) #if($p != ’page’ && $p != ’ipp’) #foreach($v in $request.getParameterValues($p)) #set($queryString = "${queryString}&${p}=${v}") #end #end #end <div class="pagingLinks"> #if ($currentPageNumber < $totalPages) #set($currentPageNumber = $currentPageNumber + 1) #set($currentPageNumber = $currentPageNumber - 1) <span class="prevPage">*[« $msg.get("xe.blog.code.olderposts")>$doc.name?page=${currentPageNumber}&ipp=${itemsPerPage}$queryString]*</span> #end #if ($currentPageNumber > 1) #if ($currentPageNumber < $totalPages) #sep() #end #set($currentPageNumber = $currentPageNumber - 1) <span class="nextPage">*[$msg.get("xe.blog.code.newerposts") »>$doc.name?page=${currentPageNumber}&ipp=${itemsPerPage}$queryString]*</span> #set($currentPageNumber = $currentPageNumber + 1) #end <span class="clear"></span> </div> ## pagingLinks #end #end #end ## ## ## #** * Displays a message box with "publish" icon. * * @param message A text message concerning blog article publishing *### #macro(publishMessageBox $message) <div class="plainmessage publish-message">$message</div> #end #** * Displays a message box with "show/hide" icon. * * @param message A text message concerning blog article hiding *### #macro(hideMessageBox $message) <div class="plainmessage hide-message">$message</div> #end ## ## ## #** * Determine the requested week, for using in a weekly-indexed blog. The relevant request parameters are * <tt>year</tt> and <tt>week</tt>. By default, the current week is used. * * @param monthDate The resulting week, a JODATime MutableDateTime. *### #macro(getRequestedWeek $weekDate) #set($weekDate = $xwiki.jodatime.mutableDateTime) #if("$!{request.year}" != ’’) $weekDate.setYear($util.parseInt($request.year)) #end #if("$!{request.week}" != ’’) $weekDate.setWeekOfWeekyear($util.parseInt($request.week)) #end #end ## ## ## #** * Determine the requested month, for using in a monthly-indexed blog. The relevant request parameters are * <tt>year</tt> and <tt>month</tt>. By default, the current month is used. * * @param monthDate The resulting month, a JODATime MutableDateTime. *### #macro(getRequestedMonth $monthDate) #set($monthDate = $xwiki.jodatime.mutableDateTime) #if("$!{request.year}" != ’’) $monthDate.setYear($util.parseInt($request.year)) #end #if("$!{request.month}" != ’’) $monthDate.setMonthOfYear($util.parseInt($request.month)) #end #end ## ## ## #** * Retrieve a blog property (title, display type, etc). * * @param blogDoc The blog document. It should contain a <tt>Blog.BlogClass</tt> object. * @param propertyName The name of the property to be retrieved. One of the <tt>Blog.BlogClass</tt>’s properties. * @param defaultValue The default value to use in case the blog object does not define one. * @param propertyValue The resulting value. *### #macro(getBlogProperty $blogDoc $propertyName $defaultValue $propertyValue) #set($propertyValue = "$!{blogDoc.getObject(${blogClassname}).getProperty($propertyName).value}") #if($propertyValue == ’’) #set($propertyValue = $defaultValue) #end #end
Cannot make recursive include Cannot make recursive include Cannot make recursive include
Blog Categories
Cannot make recursive include
Blog Archive
No articles yet...
Search
Quick Links
Wiki Dashboard
Document Index
Blog
Sandbox
My Recent Modifications
dany
|
marco