-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathops-spacelist-by-label
112 lines (107 loc) · 4.02 KB
/
ops-spacelist-by-label
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
## @param Header:title=Table Header|type=string|required=true|desc=The title for table results.
## @param Label:title=Space Category|type=string|required=true|desc=Categories you want to list spaces from, comma separated, for performance reason please put the less used category first.
## @param DisplayPages:title=Display Pages|type=boolean|required=true|default=false|Desc=Display Space Pages
## @param DisplayArchivedSpaces:title=Display Archived Spaces|type=boolean|required=true|default=false|Desc=Display Archived Spaces
#set( $myList = $paramLabel.split(","))
#set($myArray = [])
#foreach ( $cat in $myList )
#set( $tmp = $myArray.add($cat) )
#end
#set( $mainCategory = $myArray.get(0))
## try to get space category
#set ( $spaceLabel = $action.labelManager.getLabel( "team:${mainCategory}" ) )
## check if space category exists
#if ( $!spaceLabel )
## try to get spaces by category
#set ( $spaces = $action.labelManager.getSpacesWithLabel( $spaceLabel ) )
<table class="confluenceTable tablesorter tablesorter-default" style="width:90%; margin-left:5%">
<theader>
<tr>
<th class="confluenceTh">${paramHeader} ${paramLabel}</th>
</tr>
</theader>
<tbody>
#foreach ( $space in $spaces )
#set ($firstloop = true)
#set ($spaceMatch = false)
#set ($firstlookup = true)
#set ($curSpaceLabels = $action.labelManager.getTeamLabelsForSpace($space.key))
#foreach ($label in $myList)
#set( $find = false)
#foreach ( $curSpaceLabel in $curSpaceLabels )
#if ($curSpaceLabel == $label)
#set( $find = true )
#end
#end
#if ($find == false)
#set ($spaceMatch = false)
#elseif ($firstlookup == true)
#set ($spaceMatch = true)
#end
#set ($firstlookup = false)
#end
## check if current user can view space and if all labels founded
#if ( $spaceMatch == true and $permissionHelper.canView($action.remoteUser, $space) and (!$space.isArchived() or $paramDisplayArchivedSpaces == true))
<tr>
#if ($paramDisplayPages == false)
<td class="confluenceTd">
<span class="icon icon-space"> </span><span><a href="$!space.urlPath">$!space.name</a></span>
</td>
<td class="confluenceTd">
<a href="/display/$!space.key">
<div title="View Space">
<a class="icon icon-space" href="/display/$!space.key">Espace</a>
</div>
</a>
#else
<td class="confluenceTd">
#set ( $toppages = $pageManager.getTopLevelPages($space) )
#foreach ($toppage in $toppages)
<span class="icon icon-space"> </span>
<a href="/display/$!space.key">$toppage.getDisplayTitle()</a>
#if ($firstloop == true)
<ul>
#end
#set ($firstloop = false)
#if ($toppage.hasChildren())
#set ($children = $toppage.getSortedChildren())
#foreach ($childpage in $children)
#if( $childpage.hasChildren() )
#set ($subchildren = $childpage.getSortedChildren())
<li onclick="jQuery(this).find('ul').slideToggle('slow');" style="list-style-type:circle; cursor:pointer">
#else
<li>
#end
<span class="icon icon-page"> </span>
<a href="/display/$!space.key/$!childpage.getDisplayTitle()">$childpage.getDisplayTitle()</a>
#if( $childpage.hasChildren() )
<ul style="display: none">
#foreach ($subchildpage in $subchildren)
<li>
<span class="icon icon-page"> </span>
<a href="/display/$!space.key/$!subchildpage.getDisplayTitle()">$subchildpage.getDisplayTitle()</a>
</li>
#end
</ul>
#end
</li>
#end
#end
#end
</ul>
#end
</td>
</tr>
#end
#end
</tbody>
</table>
#else
<div class="aui-message warning">
<p class="title">
<span class="aui-icon icon-warning">Warning</span>
<strong>No spaces in these categories</strong>
</p>
<p>Couldn't find space categories <strong>$paramLabel</strong>!</p>
</div>
#end