<
From version < 17.1 >
edited by Vincent Massol
on 2017/03/01
To version < 18.1
edited by Thomas Mortagne
on 2020/01/28
Change comment: Install extension [org.xwiki.contrib.blog:application-blog-ui/9.10.4]

Summary

Details

Page properties
Title
... ... @@ -1,1 +1,1 @@
1 -$services.localization.render('xe.blog.manageCategories.title')
1 +$services.localization.render('blog.manageCategories.title')
Author
... ... @@ -1,1 +1,1 @@
1 -XWiki.VincentMassol
1 +XWiki.ThomasMortagne
Content
... ... @@ -15,23 +15,27 @@
15 15  #elseif("$!request.xaction" == 'rename')
16 16   #set ($newFullName = "$!{request.newCategoryName}")
17 17   #if($newFullName.trim().equals(''))
18 - #blog__actionResponseError(400, 'xe.blog.manageCategories.create.error.emptyName', [])
18 + #blog__actionResponseError(400, 'blog.manageCategories.create.error.emptyName', [])
19 19   #elseif(!$xwiki.exists($request.category))
20 - #blog__actionResponseError(404, 'xe.blog.manageCategories.create.error.notExists', [])
20 + #blog__actionResponseError(404, 'blog.manageCategories.create.error.notExists', [])
21 21   #elseif($xwiki.exists($newFullName))
22 - #blog__actionResponseError(409, 'xe.blog.manageCategories.create.error.alreadyExists', [$newFullName, $xwiki.getURL($newFullName)])
22 + #blog__actionResponseError(409, 'blog.manageCategories.create.error.alreadyExists', [$newFullName, $xwiki.getURL($newFullName)])
23 23   #elseif(!$xwiki.hasAccessLevel('edit', $xcontext.user, $newFullName))
24 - #blog__actionResponseError(403, 'xe.blog.manageCategories.create.error.targetNotWritable', [$newFullName])
24 + #blog__actionResponseError(403, 'blog.manageCategories.create.error.targetNotWritable', [$newFullName])
25 25   #else
26 26   #renameCategory($request.category, $newFullName)
27 27   #end
28 28  #elseif("$!request.xaction" == 'create')
29 29   #set($title = "$!{request.newCategoryName}")
30 - #set($name = "${doc.space}.${title}")
30 + #set ($escapedTitle = $title.replaceAll('\.', '\\.')) ## Escape categories with dots
31 + #set($name = "${doc.space}.${escapedTitle}")
32 + #if ("$!request.newCategoryParent" != '')
33 + #set ($name = "${xwiki.getDocument($request.newCategoryParent).space}.${escapedTitle}")
34 + #end
31 31   #if ($title.trim().equals(''))
32 - #blog__actionResponseError(400, 'xe.blog.manageCategories.create.error.emptyName', [])
36 + #blog__actionResponseError(400, 'blog.manageCategories.create.error.emptyName', [])
33 33   #elseif (!$xwiki.getDocument($name).isNew())
34 - #blog__actionResponseError(409, 'xe.blog.manageCategories.create.error.alreadyExists', [])
38 + #blog__actionResponseError(409, 'blog.manageCategories.create.error.alreadyExists', [])
35 35   #else
36 36   #if($request.ajax)
37 37   #set($redirectParams = {
... ... @@ -65,14 +65,29 @@
65 65  #####################################################
66 66  ## Action execution done
67 67  #####################################################
72 +#set($categoriesLocation = $defaultBlogSpace)
73 +#if ("$!request.root" != '')
74 + #set ($categoriesLocation = $xwiki.getDocument($request.root).space)
75 +#elseif ("$!request.categoriesSpace" != '')
76 + #set ($categoriesLocation = $request.categoriesSpace)
77 +#elseif ("$!request.categoryParent" != '')
78 + #set ($categoriesLocation = $xwiki.getDocument($request.categoryParent).space)
79 + #set ($defaultCategoryParent = $request.categoryParent)
80 +#elseif ("$!request.category" != '')
81 + #set ($categoriesLocation = $xwiki.getDocument($request.category).space)
82 +#end
83 +#if ("$!categoriesLocation" != $defaultBlogSpace && "$!defaultCategoryParent" != '')
84 + #set($defaultCategoryParent = "${categoriesLocation}.WebHome")
85 +#end
86 +
68 68  #if ("$!request.display" == 'list')
69 69   #set($displayType = "$!{request.listType}")
70 70   #if($displayType == '')
71 71   #set($displayType = 'editable')
72 72   #end
73 - #displayCategoryManagementTree('' $displayType)
92 + #displayCategoryManagementTree($categoriesLocation $displayType)
74 74  #elseif ("$!request.display" == 'addForm')
75 - #getCategoriesHierarchy('' $tree)
94 + #getCategoriesHierarchy($categoriesLocation $tree)
76 76   #addCategoryForm()
77 77  #elseif ("$!request.display" == 'renameForm')
78 78   #renameCategoryForm()
... ... @@ -81,7 +81,7 @@
81 81  $xwiki.ssx.use('Blog.ManageCategories')##
82 82  $xwiki.jsx.use('Blog.ManageCategories', {'minify':false})##
83 83  ##
84 -#displayCategoryManagementTree('' 'editable')
103 +#displayCategoryManagementTree($defaultBlogSpace 'editable')
85 85  #end
86 86  {{/html}}
87 87  {{/velocity}}
XWiki.JavaScriptExtension[0]
Code
... ... @@ -65,7 +65,7 @@
65 65   onCreate : function () {
66 66   // ignore "cascade" clicks
67 67   parent.disabled = true;
68 - parent.notification = new XWiki.widgets.Notification("$escapetool.javascript($services.localization.render('xe.blog.manageCategories.js.fetchingForm'))", "inprogress");
68 + parent.notification = new XWiki.widgets.Notification("$escapetool.javascript($services.localization.render('blog.manageCategories.js.fetchingForm'))", "inprogress");
69 69   },
70 70   onSuccess : function (response) {
71 71   var container = new Element("div");
... ... @@ -75,7 +75,7 @@
75 75   this.insertRenameForm(item, parent._x_rename_form);
76 76   }.bind(this),
77 77   onFailure : function (response) {
78 - new XWiki.widgets.Notification(response.responseText || "$escapetool.javascript($services.localization.render('xe.blog.manageCategories.js.error.noServer'))", "error");
78 + new XWiki.widgets.Notification(response.responseText || "$escapetool.javascript($services.localization.render('blog.manageCategories.js.error.noServer'))", "error");
79 79   },
80 80   // 0 is returned for network failures, except on IE where a strange large number (12031) is returned.
81 81   on0 : function(response) {
... ... @@ -113,7 +113,7 @@
113 113   onCreate : function () {
114 114   // ignore "cascade" clicks
115 115   form.disable();
116 - form.notification = new XWiki.widgets.Notification("$escapetool.javascript($services.localization.render('xe.blog.manageCategories.js.rename.inProgress'))", "inprogress");
116 + form.notification = new XWiki.widgets.Notification("$escapetool.javascript($services.localization.render('blog.manageCategories.js.rename.inProgress'))", "inprogress");
117 117   },
118 118   onSuccess : function (response) {
119 119   $$(".blog-categories-list").first().replace(response.responseText);
... ... @@ -121,7 +121,7 @@
121 121   form.reset();
122 122   }.bind(this),
123 123   onFailure : function (response) {
124 - new XWiki.widgets.Notification(response.responseText || "$escapetool.javascript($services.localization.render('xe.blog.manageCategories.js.error.noServer'))", "error");
124 + new XWiki.widgets.Notification(response.responseText || "$escapetool.javascript($services.localization.render('blog.manageCategories.js.error.noServer'))", "error");
125 125   },
126 126   onComplete : function () {
127 127   form.enable();
... ... @@ -128,13 +128,13 @@
128 128   form.notification.hide();
129 129   },
130 130   on403 : function(response) {
131 - new XWiki.widgets.Notification("$escapetool.javascript($services.localization.render('xe.blog.manageCategories.js.rename.error.403'))", "error");
131 + new XWiki.widgets.Notification("$escapetool.javascript($services.localization.render('blog.manageCategories.js.rename.error.403'))", "error");
132 132   },
133 133   on404 : function(response) {
134 - new XWiki.widgets.Notification("$escapetool.javascript($services.localization.render('xe.blog.manageCategories.js.rename.error.404'))", "error");
134 + new XWiki.widgets.Notification("$escapetool.javascript($services.localization.render('blog.manageCategories.js.rename.error.404'))", "error");
135 135   },
136 136   on409 : function(response) {
137 - new XWiki.widgets.Notification("$escapetool.javascript($services.localization.render('xe.blog.manageCategories.js.rename.error.409'))", "error");
137 + new XWiki.widgets.Notification("$escapetool.javascript($services.localization.render('blog.manageCategories.js.rename.error.409'))", "error");
138 138   },
139 139   // 0 is returned for network failures, except on IE where a strange large number (12031) is returned.
140 140   on0 : function(response) {
... ... @@ -197,6 +197,14 @@
197 197   if(entryObjNb && entryObjNb != '') {
198 198   ajaxParams['entryObjNb'] = entryObjNb;
199 199   }
200 + var categoriesSpace = urlParams.categoriesSpace;
201 + if(categoriesSpace && categoriesSpace != '') {
202 + ajaxParams['categoriesSpace'] = categoriesSpace;
203 + }
204 + var categoryParent = urlParams.parentCategory;
205 + if(categoryParent && categoryParent != '') {
206 + ajaxParams['categoryParent'] = categoryParent;
207 + }
200 200   if (!parent._x_add_form) {
201 201   if (!parent.disabled) {
202 202   new Ajax.Request(
... ... @@ -206,7 +206,7 @@
206 206   onCreate : function () {
207 207   // ignore "cascade" clicks
208 208   parent.disabled = true;
209 - parent.notification = new XWiki.widgets.Notification("$escapetool.javascript($services.localization.render('xe.blog.manageCategories.js.fetchingForm'))", "inprogress");
217 + parent.notification = new XWiki.widgets.Notification("$escapetool.javascript($services.localization.render('blog.manageCategories.js.fetchingForm'))", "inprogress");
210 210   },
211 211   onSuccess : function (response) {
212 212   var container = new Element("div");
... ... @@ -216,7 +216,7 @@
216 216   this.insertAddForm(item, parent._x_add_form);
217 217   }.bind(this),
218 218   onFailure : function (response) {
219 - new XWiki.widgets.Notification(response.responseText || "$escapetool.javascript($services.localization.render('xe.blog.manageCategories.js.error.noServer'))", "error");
227 + new XWiki.widgets.Notification(response.responseText || "$escapetool.javascript($services.localization.render('blog.manageCategories.js.error.noServer'))", "error");
220 220   },
221 221   // 0 is returned for network failures, except on IE where a strange large number (12031) is returned.
222 222   on0 : function(response) {
... ... @@ -274,7 +274,7 @@
274 274   onCreate : function () {
275 275   // ignore "cascade" clicks
276 276   form.disable();
277 - form.notification = new XWiki.widgets.Notification("$escapetool.javascript($services.localization.render('xe.blog.manageCategories.js.add.inProgress'))", "inprogress");
285 + form.notification = new XWiki.widgets.Notification("$escapetool.javascript($services.localization.render('blog.manageCategories.js.add.inProgress'))", "inprogress");
278 278   },
279 279   onSuccess : function (response) {
280 280   /* var reference = form._x_item.up('.blog-category-level');
... ... @@ -304,7 +304,7 @@
304 304   });
305 305   }.bind(this),
306 306   onFailure : function (response) {
307 - new XWiki.widgets.Notification(response.responseText || "$escapetool.javascript($services.localization.render('xe.blog.manageCategories.js.error.noServer'))", "error");
315 + new XWiki.widgets.Notification(response.responseText || "$escapetool.javascript($services.localization.render('blog.manageCategories.js.error.noServer'))", "error");
308 308   },
309 309   onComplete : function () {
310 310   form.enable();
... ... @@ -311,13 +311,13 @@
311 311   form.notification.hide();
312 312   },
313 313   on401 : function(response) {
314 - new XWiki.widgets.Notification("$escapetool.javascript($services.localization.render('xe.blog.manageCategories.js.add.error.401'))", "error");
322 + new XWiki.widgets.Notification("$escapetool.javascript($services.localization.render('blog.manageCategories.js.add.error.401'))", "error");
315 315   },
316 316   on403 : function(response) {
317 - new XWiki.widgets.Notification("$escapetool.javascript($services.localization.render('xe.blog.manageCategories.js.add.error.403'))", "error");
325 + new XWiki.widgets.Notification("$escapetool.javascript($services.localization.render('blog.manageCategories.js.add.error.403'))", "error");
318 318   },
319 319   on409 : function(response) {
320 - new XWiki.widgets.Notification("$escapetool.javascript($services.localization.render('xe.blog.manageCategories.js.add.error.409'))", "error");
328 + new XWiki.widgets.Notification("$escapetool.javascript($services.localization.render('blog.manageCategories.js.add.error.409'))", "error");
321 321   },
322 322   // 0 is returned for network failures, except on IE where a strange large number (12031) is returned.
323 323   on0 : function(response) {
... ... @@ -376,10 +376,10 @@
376 376   },
377 377   /* Interaction parameters */
378 378   {
379 - confirmationText: "$escapetool.javascript($services.localization.render('xe.blog.manageCategories.js.delete.confirm'))",
380 - progressMessageText : "$escapetool.javascript($services.localization.render('xe.blog.manageCategories.js.delete.inProgress'))",
381 - successMessageText : "$escapetool.javascript($services.localization.render('xe.blog.manageCategories.js.delete.done'))",
382 - failureMessageText : "$escapetool.javascript($services.localization.render('xe.blog.manageCategories.js.delete.failed'))"
387 + confirmationText: "$escapetool.javascript($services.localization.render('blog.manageCategories.js.delete.confirm'))",
388 + progressMessageText : "$escapetool.javascript($services.localization.render('blog.manageCategories.js.delete.inProgress'))",
389 + successMessageText : "$escapetool.javascript($services.localization.render('blog.manageCategories.js.delete.done'))",
390 + failureMessageText : "$escapetool.javascript($services.localization.render('blog.manageCategories.js.delete.failed'))"
383 383   }
384 384   );
385 385   }
... ... @@ -391,11 +391,13 @@
391 391  document.observe('xwiki:dom:loaded', function() {
392 392   new XWiki.blog.Categories();
393 393   $$(".blog-categories-list.subcategories").each(function(item) {
394 - var toggler = new Element("a", {style : "display: block; cursor: pointer; float: right; font-style: italic;"}).update("show »");
402 + var downIcon = '<span class="glyphicon glyphicon-chevron-down" aria-hidden="true"></span>';
403 + var upIcon = '<span class="glyphicon glyphicon-chevron-up" aria-hidden="true"></span>'
404 + var toggler = new Element('a', {'class' : 'subcat-toggle-link'}).update(downIcon);
395 395   var list = item.down("div", 1);
396 396   toggler.observe("click", function() {
397 397   list.toggle();
398 - toggler.update(list.visible() ? hide" : "show »");
408 + toggler.update(list.visible() ? upIcon : downIcon);
399 399   });
400 400   item.down("strong").insert({after : toggler});
401 401   item.down("strong").insert({after : "&nbsp;&nbsp;"});
XWiki.StyleSheetExtension[0]
Code
... ... @@ -78,3 +78,20 @@
78 78   margin-right: 3px;
79 79   width: 16em;
80 80  }
81 +.cat-posts-count {
82 + display: inline-block;
83 + float: left;
84 + margin-top: 0px;
85 + padding-bottom: 20px;
86 +}
87 +.subcat-toggle-link {
88 + cursor: pointer;
89 + display: block;
90 + float: left;
91 + font-style: italic;
92 + padding-left: 5px;
93 + padding-top: 5px;
94 +}
95 +.blog-categories-list.subcategories.cat-count{
96 + padding-top: 0;
97 +}

Get Connected