Last modified by Administrator on 2009/09/17 10:33

Show last authors
1 {{include document="Blog.BlogParameters"/}}
2
3 {{velocity output="false"}}
4 ##
5 ##
6 ##
7 ## Import the blog skin and javascripts.
8 $!xwiki.ssx.use($blogStyleDocumentName)##
9 $!xwiki.jsx.use($blogScriptsDocumentName)##
10 ##
11 ##
12 ##
13 #**
14 * Prints a blog. This is the main macro used in the BlogSheet.
15 *
16 * @param blogDoc the XDocument holding the blog definition object.
17 *###
18 #macro(printBlog $blogDoc)
19 {{include document='Blog.CreatePost'/}}
20 #getBlogEntries($blogDoc $entries)
21 #displayBlog($entries 'index' true true)
22 #displayNavigationLinks($blogDoc)
23 #end
24 ##
25 ##
26 ##
27 #**
28 * Shows blog information. In view mode, the description is printed. In inline edit mode, allows changing
29 * blog settings: title, description, blog type (global or in-space), index display type (fixed size pagination, weekly
30 * index, monthly index, all entries).
31 *
32 * @param blogDoc The blog document. It should contain a <tt>Blog.BlogClass</tt> object.
33 *###
34 #macro(showBlogInfo $blogDoc)
35 #if($blogDoc.getObject($blogClassname))
36 #if($xcontext.action == 'inline')
37 #macro(displayProperty $blogDoc $propname)
38 <dt>#displayPropName($xwiki.getClass($blogClassname).get($propname)):</dt>
39 <dd>$blogDoc.display($propname)</dd>
40 #end
41 <dl>
42 #displayProperty($blogDoc 'title')
43 #displayProperty($blogDoc 'description')
44 #displayProperty($blogDoc 'blogType')
45 #displayProperty($blogDoc 'displayType')
46 #displayProperty($blogDoc 'itemsPerPage')
47 </dl>
48 #else
49 $blogDoc.display('description')
50 #end
51 #elseif($doc.fullName == $blogSheet)
52 = $msg.get('xe.blog.code.blogsheet') =
53 $msg.get('xe.blog.code.sheetexplanation')
54 #else
55 #warning($msg.get('xe.blog.code.notblog'))
56 #end
57 #end
58 ##
59 ##
60 ##
61 #**
62 * Retrieve the blog document, which usually is either <tt>&lt;Space&gt;.WebHome</tt> for whole-spaces blogs, or
63 * <tt>&lt;Space&gt;.Blog</tt> for in-space blogs. If none of these documents contains a blog object, then the first
64 * (alphabetically) document in the target space that contains one is returned. Finally, if no document in the current
65 * space contains a blog object, then <tt>Blog.WebHome</tt> is returned as the default blog.
66 *
67 * @param space A <tt>String</tt>, the name of the space where to search.
68 * @param blogDoc The resulting XDocument.
69 *###
70 #macro(getBlogDocument $space $blogDoc)
71 ## First, try the Space.WebHome, for a whole-space blog
72 #set($blogDoc = $xwiki.getDocument("${space}.WebHome"))
73 #if(!$blogDoc.getObject($blogClassname))
74 ## Second, try the Space.Blog document
75 #set($blogDoc = $xwiki.getDocument("${space}.Blog"))
76 #if(!$blogDoc.getObject($blogClassname))
77 ## Third, try searching for a blog document in the current space
78 #set($blogDocs = $xwiki.searchDocuments(", BaseObject obj where doc.space = ? and obj.name = doc.fullName and obj.className = '$blogClassname' order by doc.name", 1, 0, [${space}]))
79 #if($blogDocs.size() > 0)
80 #set($blogDoc = $xwiki.getDocument($blogDocs.get(0)))
81 #else
82 ## Last, fallback to Blog.WebHome, the default blog
83 #set($blogDoc = $xwiki.getDocument('Blog.WebHome'))
84 #end
85 #end
86 #end
87 #end
88 ##
89 ##
90 ##
91 #**
92 * Retrieve the blog title.
93 *
94 * @param blogDoc The blog document. It should contain a <tt>Blog.BlogClass<tt> object with the <tt>title</tt> property set.
95 * @param title The resulting title.
96 *###
97 #macro(getBlogTitle $blogDoc $title)
98 #getBlogProperty($blogDoc 'title' $!blogDoc.displayTitle $title)
99 #end
100 ##
101 ##
102 ##
103 #**
104 * Retrieve the blog description.
105 *
106 * @param blogDoc The blog document. It should contain a <tt>Blog.BlogClass</tt> object with the <tt>description</tt>
107 * property set.
108 * @param description The resulting description.
109 *###
110 #macro(getBlogDescription $blogDoc $description)
111 #getBlogProperty($blogDoc 'description' '' $description)
112 #end
113 ##
114 ##
115 ##
116 #**
117 * Retrieves a list of entries to be displayed. The entries are either part of the blog's space, or have the blog
118 * document set as a parent. The number and range of entries returned (from all those belonging to this blog) depends on
119 * the blog display type: paginated (fixed number of entries), weekly (all entries in a week), monthly (all entries in a
120 * month), or all.
121 *
122 * @param blogDoc The blog document. It should contain a <tt>Blog.BlogClass</tt> object.
123 * @param entries The resulting list of entries to display, a list of XDocument names.
124 *###
125 #macro(getBlogEntries $blogDoc $entries)
126 #getBlogEntriesBaseQuery($query)
127 #isBlogGlobal($blogDoc $isGlobal)
128 #if(!$isGlobal)
129 #set($query = "${query} and (doc.space = '${blogDoc.space}' or doc.parent = '${blogDoc.fullName}')")
130 #end
131 #getBlogDisplayType($blogDoc $displayType)
132 #if($displayType == 'weekly')
133 #getWeeklyBlogEntries($blogDoc $query $entries)
134 #elseif($displayType == 'monthly')
135 #getMonthlyBlogEntries($blogDoc $query $entries)
136 #elseif($displayType == 'all')
137 #getAllBlogEntries($blogDoc $query $entries)
138 #else
139 #getPagedBlogEntries($blogDoc $query $entries)
140 #end
141 #end
142 ##
143 ##
144 ##
145 #**
146 * Retrieves a list of entries to be displayed. The entries are taken from a "page" of the blog, a sequence of documents
147 * defined by the request parameters <tt>ipp</tt> (items per page) and <tt>page</tt> (the current page). Initially the
148 * first page is displayed, with the number of entries defined in the blog object in the <tt>itemsPerPage</tt> property
149 * (10 if not defined).
150 *
151 * @param blogDoc The blog document. It should contain a <tt>Blog.BlogClass</tt> object.
152 * @param query The base query for selecting entries. Apart from the base query that selects entries, it can further be
153 * refined to restrict to a given space, or to a given search criteria, etc.
154 * @param entries The resulting list of entries to display, a list of XDocument names.
155 *###
156 #macro(getPagedBlogEntries $blogDoc $query $entries)
157 #set($totalEntries = $xwiki.countDocuments(${query}))
158 #getBlogProperty($blogDoc 'itemsPerPage' '10' $defaultItemsPerPage)
159 #set($defaultItemsPerPage = $util.parseInt($defaultItemsPerPage))
160 ## This macro is defined in the default macros.vm library. It also sets $itemsPerPage and $startAt.
161 #preparePagedViewParams($totalEntries $defaultItemsPerPage)
162 #set($entries = $xwiki.searchDocuments("${query} order by publishDate.value desc", $itemsPerPage, $startAt))
163 #end
164 ##
165 ##
166 ##
167 #**
168 * Retrieves a list of entries to be displayed. The entries are taken from a week of the blog. The target week is
169 * defined by the request parameters <tt>week</tt> (the week number in the year, from 1 to 52) and <tt>year</tt> (4
170 * digit year). Initially the current week is displayed.
171 *
172 * @param blogDoc The blog document. It should contain a <tt>Blog.BlogClass</tt> object.
173 * @param query The base query for selecting entries. Apart from the base query that selects entries, it can further be
174 * refined to restrict to a given space, or to a given search criteria, etc.
175 * @param entries The resulting list of entries to display, a list of XDocument names.
176 *###
177 #macro(getWeeklyBlogEntries $blogDoc $query $entries)
178 #getRequestedWeek($weekDate)
179 #set($dateFormatter = $xwiki.jodatime.getDateTimeFormatterForPattern('yyyy-MM-dd'))
180 #set($minDay = $dateFormatter.print($weekDate.toMutableDateTime().weekOfWeekyear().roundFloor()))
181 #set($maxDay = $dateFormatter.print($weekDate.toMutableDateTime().weekOfWeekyear().roundCeiling()))
182 #set($query = "${query} and publishDate.value >= '$minDay' and publishDate.value < '$maxDay'")
183 #set($totalEntries = $xwiki.countDocuments(${query}))
184 #set($entries = $xwiki.searchDocuments("${query} order by publishDate.value desc"))
185 #end
186 ##
187 ##
188 ##
189 #**
190 * Retrieves a list of entries to be displayed. The entries are taken from a month of the blog. The target month is
191 * defined by the request parameters <tt>month</tt> (the month number, from 1 to 12) and <tt>year</tt> (4
192 * digit year). Initially the current month is displayed.
193 *
194 * @param blogDoc The blog document. It should contain a <tt>Blog.BlogClass</tt> object.
195 * @param query The base query for selecting entries. Apart from the base query that selects entries, it can further be
196 * refined to restrict to a given space, or to a given search criteria, etc.
197 * @param entries The resulting list of entries to display, a list of XDocument names.
198 *###
199 #macro(getMonthlyBlogEntries $blogDoc $query $entries)
200 #getRequestedMonth($monthDate)
201 #set($dateFormatter = $xwiki.jodatime.getDateTimeFormatterForPattern('yyyy-MM-dd'))
202 #set($minDay = $dateFormatter.print($monthDate.toMutableDateTime().monthOfYear().roundFloor()))
203 #set($maxDay = $dateFormatter.print($monthDate.toMutableDateTime().monthOfYear().roundCeiling()))
204 #set($query = "${query} and publishDate.value >= '$minDay' and publishDate.value < '$maxDay'")
205 #set($totalEntries = $xwiki.countDocuments(${query}))
206 #set($entries = $xwiki.searchDocuments("${query} order by publishDate.value desc"))
207 #end
208 ##
209 ##
210 ##
211 #**
212 * Retrieves a list of entries to be displayed. All entries belonging to the current blog are returned.
213 *
214 * @param blogDoc The blog document. It should contain a <tt>Blog.BlogClass</tt> object.
215 * @param query The base query for selecting entries. Apart from the base query that selects entries, it can further be
216 * refined to restrict to a given space, or to a given search criteria, etc.
217 * @param entries The resulting list of entries to display, a list of XDocument names.
218 *###
219 #macro(getAllBlogEntries $blogDoc $query $entries)
220 #set($totalEntries = $xwiki.countDocuments(${query}))
221 #set($entries = $xwiki.searchDocuments("${query} order by publishDate.value desc"))
222 #end
223 ##
224 ##
225 ##
226 #**
227 * Retrieves a list of entries to be displayed. Only (and all) unpublished entries are returned.
228 *
229 * @param blogDoc The blog document. It should contain a <tt>Blog.BlogClass</tt> object.
230 * @param query The base query for selecting entries. Apart from the base query that selects entries, it can further be
231 * refined to restrict to a given space, or to a given search criteria, etc.
232 * @param entries The resulting list of entries to display, a list of XDocument names.
233 *###
234 #macro(getUnpublishedBlogEntries $blogDoc $query $entries)
235 #set($query = "${query} and isPublished.value = 0")
236 #set($totalEntries = $xwiki.countDocuments(${query}))
237 #set($entries = $xwiki.searchDocuments("${query} order by publishDate.value desc"))
238 #end
239 ##
240 ##
241 ##
242 #**
243 * Retrieves a list of entries to be displayed. The entries are taken from all the wiki, and not from a specific blog.
244 *
245 * @param entries The resulting list of entries to display, a list of XDocument names.
246 *###
247 #macro(getGlobalBlogEntries $entries)
248 #getBlogEntriesBaseQuery($query)
249 #set($totalEntries = $xwiki.countDocuments(${query}))
250 #set($defaultItemsPerPage = 20)
251 ## This macro is defined in the default macros.vm library. It also sets $itemsPerPage and $startAt.
252 #preparePagedViewParams($totalEntries $defaultItemsPerPage)
253 #set($entries = $xwiki.searchDocuments("${query} order by publishDate.value desc", $itemsPerPage, $startAt))
254 #end
255 ##
256 ##
257 ##
258 #**
259 * Return the base query for selecting blog entries. It filters only visible entries, but does not bind to a specific
260 * blog, nor specify a range or an ordering criteria.
261 *
262 * @param query The basic query for selecting blog entries.
263 *###
264 #macro(getBlogEntriesBaseQuery $query)
265 #set ($query = ", BaseObject obj, IntegerProperty isPublished, IntegerProperty hidden, DateProperty publishDate
266 where doc.fullName <> '${blogPostTemplate}' and
267 obj.name = doc.fullName and obj.className = '${blogPostClassname}' and
268 publishDate.id.id = obj.id and publishDate.id.name = 'publishDate' and
269 isPublished.id.id = obj.id and isPublished.id.name = 'published' and
270 hidden.id.id = obj.id and hidden.id.name = 'hidden' and
271 (doc.creator = '$xcontext.user' or (isPublished.value = 1 and hidden.value = 0))")
272 #end
273 ##
274 ##
275 ##
276 #**
277 * Checks if the provided blog is global or in-space.
278 *
279 * @param blogDoc The blog document. It should contain a <tt>Blog.BlogClass</tt> object with the <tt>blogType</tt> property set.
280 * @param isGlobal The resulting boolean. If the blog object does not define anything, it is considered in-space.
281 *###
282 #macro(isBlogGlobal $blogDoc $isGlobal)
283 #set($isGlobal = false)
284 #getBlogProperty($blogDoc 'blogType' '' $discard)
285 #if($discard == 'global')
286 #set($isGlobal = true)
287 #end
288 #end
289 ##
290 ##
291 ##
292 #**
293 * Determines how is the blog index split into pages: paginated (fixed number of entries), weekly (all entries in a
294 * week), monthly (all entries in a month), or all.
295 *
296 * @param blogDoc The blog document. It should contain a <tt>Blog.BlogClass</tt> object with the <tt>displayType</tt>
297 * property set.
298 * @param displayType The resulting string. If the blog object does not define anything, it is considered paginated.
299 *###
300 #macro(getBlogDisplayType $blogDoc $displayType)
301 #getBlogProperty($blogDoc 'displayType' 'paginated' $displayType)
302 #end
303 ##
304 ##
305 ##
306 #**
307 * Displays a list of entries.
308 *
309 * @param entries The entries to display, a list of XDocument names.
310 * @param displaying What exactly is displayed: blog index, a single blog entry, a blog category, search results,
311 * unpublished entries, etc. This will be used as the classname(s) for the container div (hfeed). Currently
312 * used values: index, single, category, search, unpublished, hidden.
313 * @param onlyExtract If <tt>true</tt>, only display the extract of articles where available, otherwise display the full content.
314 * @param shouldDisplayTitles If <tt>true</tt>, display the blog title (blog posts shouldn't display the title when they're
315 * displayed alone on their page since it's the page title which is used in this case)
316 *###
317 #macro(displayBlog $entries $displaying $onlyExtract $shouldDisplayTitles)
318 #set($blogDay = '')
319 <div class="hfeed $!{displaying}">
320 <div class="blogDay">
321 #foreach ($entryDoc in $xwiki.wrapDocs($entries))
322 #getEntryObject($entryDoc $entryObj)
323 ## Although all entries should have one of the two objects, better check to be sure.
324 #if("$!{entryObj}" != '')
325 #getEntryDate($entryDoc $entryObj $entryDate)
326 ## Display a "calendar sheet" for each day. All entries posted on the same day share one such sheet.
327 #set($entryDateStr = $xwiki.formatDate($entryDate, 'yyyyMMMMdd'))
328 #if($blogDay != $entryDateStr)
329 #if($blogDay != '')
330 </div>
331 <div class="blogDay">
332 #end
333 #displayBlogDate($entryDate)
334 #set ($blogDay = $entryDateStr)
335 #end
336 ## Finally, display the entry.
337 #displayEntry($entryDoc $entryObj $onlyExtract $shouldDisplayTitles)
338 #end
339 #end
340 </div> ## blogDay
341 </div> ## hfeed
342 #end
343 ##
344 ##
345 ##
346 #**
347 * Get the entry object, either a new BlogPost or an old Article.
348 *
349 * @param entryDoc The xdocument of the blog post. Each post resides in its own document.
350 * @param entryObj The resulting xobject of the blog post.
351 *###
352 #macro(getEntryObject $entryDoc $entryObj)
353 #set($entryObj = '')
354 #set($entryObj = $entryDoc.getObject("${blogPostClassname}"))
355 #if("$!{entryObj}" == '')
356 #set($entryObj = $entryDoc.getObject("${oldArticleClassname}"))
357 #end
358 #end
359 ##
360 ##
361 ##
362 #**
363 * Gets the date associated with a blog entry. This is the publication date. For unpublished entries, initially this is
364 * the document creation date, but can be edited by the user.
365 *
366 * @param entryDoc The xdocument of the blog post. Each post resides in its own document.
367 * @param entryObj The xobject of the blog post, an instance of the <tt>Blog.BlogPostClass</tt> xclass.
368 * @param result The resulting date, an instance of <tt>java.util.Date</tt>.
369 *###
370 #macro(getEntryDate $entryDoc $entryObj $result)
371 #set($result = $entryObj.getProperty('publishDate').value)
372 #end
373 ##
374 ##
375 ##
376 #**
377 * Displays a date, nicely formatted as a calendar page.
378 *
379 * @param date The date to display, an instance of <tt>java.util.Date</tt>.
380 *###
381 #macro(displayBlogDate $date)
382 #set($year = $xwiki.formatDate($date, 'yyyy'))
383 ## 3 letter month name, like Jan, Dec.
384 #set($month = $xwiki.formatDate($date, 'MMM'))
385 ## Uncomment to get a full length month name, like January, December.
386 ## TODO: this could be defined somewhere in the blog style.
387 ## #set($month = $xwiki.formatDate($date, 'MMMM'))
388 #set($day = $xwiki.formatDate($date, 'dd'))
389 <h2 class="blogdate">## title="#formatdateISO($date)">
390 <span class="month">$month</span>
391 <span class="day">$day</span>
392 <span class="year">$year</span>
393 </h2>
394 #end
395 ##
396 ##
397 ##
398 #**
399 * Displays a blog article: management tools, header, content, footer.
400 *
401 * @param entryDoc The xdocument of the blog post. Each post resides in its own document.
402 * @param entryObj The xobject of the blog post, an instance of the <tt>Blog.BlogPostClass</tt> xclass.
403 * @param onlyExtract If <tt>true</tt>, try to display only a summary of the entry, instead of the full content.
404 * @param shouldDisplayTitle If <tt>true</tt>, display the blog title (blog posts shouldn't display the title
405 * when they're displayed alone on their page since it's the page title which is used in this case)
406 *###
407 #macro(displayEntry $entryDoc $entryObj $onlyExtract $shouldDisplayTitle)
408 ## Only articles with an explicit hidden setting or an explicit unpublished setting are hidden
409 #isPublished($entryObj $isPublished)
410 #isHidden($entryObj $isHidden)
411 #if($doc.fullName == $entryDoc.fullName)
412 <div class="hentry single-article">
413 #else
414 <div class="hentry#if(!$isPublished) unpublished-article#elseif($isHidden) hidden-article#end">
415 #end
416 #displayEntryTools($entryDoc $entryObj)
417 #if($shouldDisplayTitle)
418 #displayEntryTitle($entryDoc $entryObj)
419 #end
420 #if($doc.fullName == $entryDoc.fullName)
421 #if(!$isPublished)
422 #warning($msg.get('xe.blog.code.published'))
423 #elseif($isHidden)
424 #warning($msg.get('xe.blog.code.hidden'))
425 #end
426 #end
427 #displayEntryContent($entryDoc $entryObj $onlyExtract)
428 #displayEntryFooter($entryDoc $entryObj)
429 </div> ## hentry
430 #end
431 ##
432 ##
433 ##
434 #**
435 * Checks if the provided blog is published or not.
436 *
437 * @param entryObj The xobject of the blog post, an instance of the <tt>Blog.BlogPostClass</tt> xclass.
438 * @param isPublished The resulting boolean, true if the entry is considered published.
439 *###
440 #macro(isPublished $entryObj $isPublished)
441 ## This should work for both old articles, which don't have the 'published' property at all, and
442 ## are considered published by default, and new entries, that should have 1 if published.
443 #set($isPublished = ("$!{entryObj.getProperty('published').value}" != '0'))
444 #end
445 ##
446 ##
447 ##
448 #**
449 * Checks if the provided blog is hidden or not.
450 *
451 * @param entryObj The xobject of the blog post, an instance of the <tt>Blog.BlogPostClass<tt> xclass.
452 * @param isHiddel The resulting boolean, true if the entry is considered hidden.
453 *###
454 #macro(isHidden $entryObj $isHidden)
455 ## This should work for both old articles, which don't have the 'hidden' property at all, and
456 ## are considered visible by default, and new entries, that should have 1 if hidden.
457 #set($isHidden = ("$!{entryObj.getProperty('hidden').value}" == '1'))
458 #end
459 ##
460 ##
461 ##
462 #**
463 * Displays several "tools" for manipulating blog posts: hide/show, publish, edit.
464 *
465 * @param entryDoc The xdocument of the blog post. Each post resides in its own document.
466 * @param entryObj The xobject of the blog post, an instance of the <tt>Blog.BlogPostClass</tt> xclass.
467 *###
468 #macro(displayEntryTools $entryDoc $entryObj)
469 #if($xcontext.action == 'view')
470 {{html wiki="false"}}
471 <div class="blog-entry-toolbox">
472 #displayPublishButton($entryDoc $entryObj)
473 #displayHideShowButton($entryDoc $entryObj)
474 #displayEditButton($entryDoc $entryObj)
475 #displayDeleteButton($entryDoc $entryObj)
476 </div>
477 {{/html}}
478 #end
479 #end
480 ##
481 ##
482 ##
483 #**
484 * Displays the publish button to the entry <strong>creator</strong>, if the article is not published yet.
485 *
486 * @param entryDoc The xdocument of the blog post. Each post resides in its own document.
487 * @param entryObj The xobject of the blog post, an instance of the <tt>Blog.BlogPostClass</tt> xclass.
488 * @todo AJAX calls.
489 *###
490 #macro(displayPublishButton $entryDoc $entryObj)
491 #isPublished($entryObj $isPublished)
492 #if(!$isPublished && $entryDoc.creator == $xcontext.user && $xwiki.hasAccessLevel('edit', $xcontext.user, $entryDoc.fullName))
493 <a href="$blogPublisher.getURL('view', "entryName=${escapetool.url($entryDoc.fullName)}&amp;xredirect=${escapetool.url($thisURL)}")" title="${escapetool.xml($msg.get('xe.blog.code.notpublished'))}">#toolImage('page_white_world' 'publish ')</a>##
494 #end
495 #end
496 ##
497 ##
498 ##
499 #**
500 * Displays the hide or show button to the entry <strong>creator</strong>, if the article is already published.
501 *
502 * @param entryDoc The xdocument of the blog post. Each post resides in its own document.
503 * @param entryObj The xobject of the blog post, an instance of the <tt>Blog.BlogPostClass</tt> xclass.
504 *###
505 #macro(displayHideShowButton $entryDoc $entryObj)
506 #isPublished($entryObj $isPublished)
507 #isHidden($entryObj $isHidden)
508 ## Only published articles can be hidden. Unpublished articles are considered already hidden.
509 #if($isPublished && $entryDoc.creator == $xcontext.user && $xwiki.hasAccessLevel('edit', $xcontext.user, $entryDoc.fullName))
510 #if ($isHidden)
511 <a class="blog-tool-show" href="$entryDoc.getURL('save', "${entryObj.getxWikiClass().getName()}_${entryObj.number}_hidden=0&amp;comment=${escapetool.url($msg.get('xe.blog.code.madevisible'))}&amp;xredirect=${escapetool.url($thisURL)}&amp;form_token=$!{services.csrf.getToken()}")" title="${escapetool.xml($msg.get('xe.blog.code.makevisible'))}">#toolImage('lock_open', 'show ')</a>##
512 #else
513 <a class="blog-tool-hide" href="$entryDoc.getURL('save', "${entryObj.getxWikiClass().getName()}_${entryObj.number}_hidden=1&amp;comment=${escapetool.url($msg.get('xe.blog.code.hid'))}&amp;xredirect=${escapetool.url($thisURL)}&amp;form_token=$!{services.csrf.getToken()}")" title="${escapetool.xml($msg.get('xe.blog.code.hide'))}">#toolImage('lock' 'hide ')</a>##
514 #end
515 #end
516 #end
517 ##
518 ##
519 ##
520 #**
521 * Displays the edit button to those that can edit the article.
522 *
523 * @param entryDoc The xdocument of the blog post. Each post resides in its own document.
524 * @param entryObj The xobject of the blog post, an instance of the <tt>Blog.BlogPostClass</tt> xclass.
525 *###
526 #macro(displayEditButton $entryDoc $entryObj)
527 #if($xwiki.hasAccessLevel('edit', $xcontext.user, $entryDoc.fullName))
528 <a href="$entryDoc.getURL('inline')" title="${escapetool.xml($msg.get('xe.blog.code.editpost'))}">#toolImage('pencil' 'edit ')</a>##
529 #end
530 #end
531 ##
532 ##
533 ##
534 #**
535 * Displays the delete button to those that can edit the article.
536 *
537 * @param entryDoc The xdocument of the blog post. Each post resides in its own document.
538 * @param entryObj The xobject of the blog post, an instance of the <tt>Blog.BlogPostClass</tt> xclass.
539 * @todo AJAX calls.
540 *###
541 #macro(displayDeleteButton $entryDoc $entryObj)
542 #if($xwiki.hasAccessLevel('delete', $xcontext.user, $entryDoc.fullName))
543 <a href="$entryDoc.getURL('delete')" title="${escapetool.xml($msg.get('xe.blog.code.deletepost'))}">#toolImage('cross' 'delete ')</a>##
544 #end
545 #end
546 ##
547 ##
548 ##
549 #**
550 * Displays the title of the entry.
551 *
552 * @param entryDoc The xdocument of the blog post. Each post resides in its own document.
553 * @param entryObj The xobject of the blog post, an instance of the <tt>Blog.BlogPostClass</tt> xclass.
554 *###
555 #macro(displayEntryTitle $entryDoc $entryObj)
556 {{html wiki="false"}}
557 #if($doc.fullName == $entryDoc.fullName)
558 <h1 class="entry-title">$entryDoc.display('title', 'view', $entryObj)</h1>
559 #else
560 <h3 class="entry-title"><a href="$entryDoc.getURL()">$entryDoc.display('title', 'view', $entryObj)</a></h3>
561 #end
562 {{/html}}
563 #end
564 ##
565 ##
566 ##
567 #**
568 * Displays the body of the entry.
569 *
570 * @param entryDoc The xdocument of the blog post. Each post resides in its own document.
571 * @param entryObj The xobject of the blog post, an instance of the <tt>Blog.BlogPostClass</tt> xclass.
572 * @param onlyExtract If <tt>true</tt>, try to display only a summary of the entry, instead of the full content.
573 *###
574 #macro(displayEntryContent $entryDoc $entryObj $onlyExtract)
575 <div class="#if($onlyExtract)entry-summary#{else}entry-content#end">
576 #getEntryContent($entryDoc $entryObj $onlyExtract $entryContent)
577 {{html wiki="false"}}$entryDoc.getRenderedContent($entryContent, $entryDoc.getSyntax().toIdString()){{/html}}
578 </div> ## entry-content
579 #end
580 ##
581 ##
582 ##
583 #**
584 * Extracts the body of the entry that should be displayed. If <tt>onlyExtract</tt> is <tt>true</tt>, display the content
585 * of the <tt>extract</tt> field (if not empty).
586 *
587 * @param entryDoc The xdocument of the blog post. Each post resides in its own document.
588 * @param entryObj The xobject of the blog post, an instance of the <tt>Blog.BlogPostClass</tt> xclass.
589 * @param onlyExtract If <tt>true</tt>, try to display only a summary of the entry, instead of the full content.
590 * @param entryContent The resulting content.
591 *###
592 #macro(getEntryContent $entryDoc $entryObj $onlyExtract $entryContent)
593 #if($onlyExtract)
594 #set($entryContent = $entryObj.getProperty('extract').value)
595 #end
596 #if("$!entryContent" == '')
597 #set($entryContent = $entryObj.getProperty('content').value)
598 #* Disabled until the content can be cleanly cut.
599 * #if($onlyExtract && $content.length()>$maxchars)
600 * #set($i = $content.lastIndexOf(" ", $maxchars))
601 * #set($i = $i + 1)
602 * #set($content = "${content.substring(0,$i)} *[...>${entryDoc.fullName}]*")
603 * #end
604 ## *###
605 #else
606 #if($entryDoc.syntax == 'xwiki/1.0')
607 #set($entryContent = "${entryContent} <a href='${entryDoc.getURL()}' title='$msg.get('xe.blog.code.readpost')'>...</a>")
608 #else
609 #set($entryContent = "${entryContent} [[...>>${entryDoc}||title='$msg.get('xe.blog.code.readpost')']]")
610 #end
611 #end
612 #end
613 ##
614 ##
615 ##
616 #**
617 * Displays the footer of the entry.
618 *
619 * @param entryDoc The xdocument of the blog post. Each post resides in its own document.
620 * @param entryObj The xobject of the blog post, an instance of the <tt>Blog.BlogPostClass</tt> xclass.
621 *###
622 #macro(displayEntryFooter $entryDoc $entryObj)
623 {{html wiki="false"}}
624 <div class="entry-footer">
625 #isPublished($entryObj $isPublished)
626 #if($isPublished)
627 $msg.get('xe.blog.code.postedby') ##
628 #else
629 $msg.get('xe.blog.code.createdby') ##
630 #end
631 <address class="author vcard">#userfn($entryDoc.creator)</address> ##
632 #getEntryDate($entryDoc $entryObj $entryDate)
633 #listCategories($entryObj) ##
634 ## Since the publish date and update date are not set at the exact same time, there could be a small difference that
635 ## we assume cannot be more than 3 seconds.
636 <span class="separator">&#183;</span> <a href="$entryDoc.getURL('view')" rel="bookmark">$msg.get('xe.blog.code.permalink')</a> ##
637 <span class="separator">&#183;</span> <a href="$entryDoc.getURL('view', '#Comments')">$entryDoc.comments.size() $msg.get('xe.blog.code.comments')</a> ##
638 </div> ## entry-footer
639 {{/html}}
640 #end
641 ##
642 ##
643 ##
644 #**
645 * List the categories an entry belongs to. Used in the footer. The categories are instances of <tt>Blog.CategoryClass</tt>.
646 *
647 * @param entryObj The xobject of the blog post, an instance of the <tt>Blog.BlogPostClass</tt> xclass.
648 *###
649 #macro(listCategories $entryObj)
650 #if($entryObj.getxWikiClass().getName() == $blogPostClassname)
651 #set($categories = $entryObj.getProperty('category').value)
652 #set($first = true)
653 #if($categories.size() > 0)
654 #foreach($category in $categories)
655 ## Do not indent
656 #set($categoryDoc = $!xwiki.getDocument($category))
657 #if(!$categoryDoc.isNew() && $categoryDoc.getObject(${blogCategoryClassname}))
658 #if($first)
659 <span class="separator">&#183;</span> $msg.get('xe.blog.code.categories')
660 #set($first = false)
661 #else, #end## if first
662 <a rel="tag" href="$xwiki.getURL(${category})">$!{escapetool.xml($!xwiki.getDocument($category).getObject($blogCategoryClassname).getProperty('name').value)}</a>##
663 #end## if isNew
664 #end## foreach
665 #end
666 #end
667 #end
668 ##
669 ##
670 ##
671 #**
672 * Displays blog pagination links (older and newer entries).
673 *
674 * @param blogDoc the XDocument holding the blog definition object.
675 *###
676 #macro(displayNavigationLinks $blogDoc)
677 <div class="clearfloats"></div>
678 #getBlogDisplayType($blogDoc $displayType)
679 #if($displayType == 'weekly')
680 <div class="pagingLinks">
681 #getRequestedWeek($weekDate)
682 $weekDate.addWeeks(-1)##
683 (% class="prevPage" %)**[[&#171; $msg.get('xe.blog.code.previousweek')>>$doc.name?year=$weekDate.weekyear&week=$weekDate.weekOfWeekyear]]**(%%)
684 #sep()
685 $weekDate.addWeeks(2)## 2 because we already subtracted 1 above
686 (% class="nextPage" %)**[[$msg.get('xe.blog.code.nextweek') &#187;>>$doc.name?year=$weekDate.weekyear&week=$weekDate.weekOfWeekyear]]**(%%)
687 </div>
688 #elseif($displayType == 'monthly')
689 <div class="pagingLinks">
690 #getRequestedMonth($monthDate)
691 $monthDate.addMonths(-1)##
692 (% class="prevPage" %)**[[&#171; $msg.get('xe.blog.code.previousmonth')>>$doc.name?year=$monthDate.year&month=$monthDate.monthOfYear]]**(%%)
693 #sep()
694 $monthDate.addMonths(2)## 2 because we already subtracted 1 above
695 (% class="nextPage" %)**[[$msg.get('xe.blog.code.nextmonth') &#187;>>$doc.name?year=$monthDate.year&month=$monthDate.monthOfYear]]**(%%)
696 </div>
697 #elseif($displayType == 'all')
698 #else
699 ## Paginated
700 #if(($totalPages > 1))
701 #set($queryString = "")
702 #foreach($p in $request.getParameterNames())
703 #if($p != 'page' && $p != 'ipp')
704 #foreach($v in $request.getParameterValues($p))
705 #set($queryString = "${queryString}&amp;${p}=${v}")
706 #end
707 #end
708 #end
709 <div class="pagingLinks">
710 #if ($currentPageNumber < $totalPages)
711 #set($currentPageNumber = $currentPageNumber + 1)
712 (% class="prevPage" %)**[[&#171; $msg.get('xe.blog.code.olderposts')>>$doc.name?page=${currentPageNumber}&ipp=${itemsPerPage}$queryString]]**(%%)
713 #set($currentPageNumber = $currentPageNumber - 1)
714 #end
715 #if ($currentPageNumber > 1)
716 #if ($currentPageNumber < $totalPages)
717 #sep()
718 #end
719 #set($currentPageNumber = $currentPageNumber - 1)
720 (% class="nextPage" %)**[[$msg.get('xe.blog.code.newerposts') &#187;>>$doc.name?page=${currentPageNumber}&ipp=${itemsPerPage}$queryString]]**(%%)
721 #set($currentPageNumber = $currentPageNumber + 1)
722 #end
723 <span class="clear"></span>
724 </div> ## pagingLinks
725 #end
726 #end
727 #end
728 ##
729 ##
730 ##
731 #**
732 * Displays a message box with "publish" icon.
733 *
734 * @param message A text message concerning blog article publishing
735 *###
736 #macro(publishMessageBox $message)
737 <div class="plainmessage publish-message">$message</div>
738 #end
739 #**
740 * Displays a message box with "show/hide" icon.
741 *
742 * @param message A text message concerning blog article hiding
743 *###
744 #macro(hideMessageBox $message)
745 <div class="plainmessage hide-message">$message</div>
746 #end
747 ##
748 ##
749 ##
750 #**
751 * Determine the requested week, for using in a weekly-indexed blog. The relevant request parameters are
752 * <tt>year</tt> and <tt>week</tt>. By default, the current week is used.
753 *
754 * @param monthDate The resulting week, a JODATime MutableDateTime.
755 *###
756 #macro(getRequestedWeek $weekDate)
757 #set($weekDate = $xwiki.jodatime.mutableDateTime)
758 #if("$!{request.year}" != '')
759 $weekDate.setYear($util.parseInt($request.year))
760 #end
761 #if("$!{request.week}" != '')
762 $weekDate.setWeekOfWeekyear($util.parseInt($request.week))
763 #end
764 #end
765 ##
766 ##
767 ##
768 #**
769 * Determine the requested month, for using in a monthly-indexed blog. The relevant request parameters are
770 * <tt>year</tt> and <tt>month</tt>. By default, the current month is used.
771 *
772 * @param monthDate The resulting month, a JODATime MutableDateTime.
773 *###
774 #macro(getRequestedMonth $monthDate)
775 #set($monthDate = $xwiki.jodatime.mutableDateTime)
776 #if("$!{request.year}" != '')
777 $monthDate.setYear($util.parseInt($request.year))
778 #end
779 #if("$!{request.month}" != '')
780 $monthDate.setMonthOfYear($util.parseInt($request.month))
781 #end
782 #end
783 ##
784 ##
785 ##
786 #**
787 * Retrieve a blog property (title, display type, etc).
788 *
789 * @param blogDoc The blog document. It should contain a <tt>Blog.BlogClass</tt> object.
790 * @param propertyName The name of the property to be retrieved. One of the <tt>Blog.BlogClass</tt>'s properties.
791 * @param defaultValue The default value to use in case the blog object does not define one.
792 * @param propertyValue The resulting value.
793 *###
794 #macro(getBlogProperty $blogDoc $propertyName $defaultValue $propertyValue)
795 #set($propertyValue = "$!{blogDoc.getObject(${blogClassname}).getProperty($propertyName).value}")
796 #if($propertyValue == '')
797 #set($propertyValue = $defaultValue)
798 #end
799 #end
800 {{/velocity}}

Failed to execute the [velocity] macro. Cause: [The execution of the [velocity] script macro is not allowed in [totem:Blog.BlogParameters]. Check the rights of its last author or the parameters if it's rendered from another script.]. Click on this message for details.

Failed to execute the [velocity] macro. Cause: [The execution of the [velocity] script macro is not allowed in [totem:Blog.BlogCode]. Check the rights of its last author or the parameters if it's rendered from another script.]. Click on this message for details.

Failed to execute the [velocity] macro. Cause: [The execution of the [velocity] script macro is not allowed in [totem:Blog.RecentPostsPanel]. Check the rights of its last author or the parameters if it's rendered from another script.]. Click on this message for details.

Failed to execute the [velocity] macro. Cause: [The execution of the [velocity] script macro is not allowed in [totem:Blog.BlogParameters]. Check the rights of its last author or the parameters if it's rendered from another script.]. Click on this message for details.

Failed to execute the [velocity] macro. Cause: [The execution of the [velocity] script macro is not allowed in [totem:Blog.BlogCode]. Check the rights of its last author or the parameters if it's rendered from another script.]. Click on this message for details.

Failed to execute the [velocity] macro. Cause: [The execution of the [velocity] script macro is not allowed in [totem:Blog.UnpublishedPanel]. Check the rights of its last author or the parameters if it's rendered from another script.]. Click on this message for details.

Failed to execute the [velocity] macro. Cause: [The execution of the [velocity] script macro is not allowed in [totem:Blog.BlogParameters]. Check the rights of its last author or the parameters if it's rendered from another script.]. Click on this message for details.

Failed to execute the [velocity] macro. Cause: [The execution of the [velocity] script macro is not allowed in [totem:Blog.BlogCode]. Check the rights of its last author or the parameters if it's rendered from another script.]. Click on this message for details.

Failed to execute the [velocity] macro. Cause: [The execution of the [velocity] script macro is not allowed in [totem:Blog.CategoriesCode]. Check the rights of its last author or the parameters if it's rendered from another script.]. Click on this message for details.

Failed to execute the [velocity] macro. Cause: [The execution of the [velocity] script macro is not allowed in [totem:Blog.CategoriesPanel]. Check the rights of its last author or the parameters if it's rendered from another script.]. Click on this message for details.

Failed to execute the [velocity] macro. Cause: [The execution of the [velocity] script macro is not allowed in [totem:Blog.BlogParameters]. Check the rights of its last author or the parameters if it's rendered from another script.]. Click on this message for details.

Failed to execute the [velocity] macro. Cause: [The execution of the [velocity] script macro is not allowed in [totem:Blog.BlogCode]. Check the rights of its last author or the parameters if it's rendered from another script.]. Click on this message for details.

Failed to execute the [velocity] macro. Cause: [The execution of the [velocity] script macro is not allowed in [totem:Blog.ArchivePanel]. Check the rights of its last author or the parameters if it's rendered from another script.]. Click on this message for details.