Changes for page Supervisors

From version 109.1
edited by Andrea Omicini
on 03/07/2023 18:41
Change comment: There is no comment for this version
To version 69.2
edited by Andrea Omicini
on 08/11/2021 13:41
Change comment: Update document after refactoring.

Summary

Details

Page properties
Title
... ... @@ -1,1 +1,1 @@
1 -#if($request.tag)$services.localization.render('supervisor').toLowerCase() : #if($request.tag.contains('XWiki.'))$xwiki.getUserName($request.tag,false)#else$request.tag#end#else$services.localization.render('supervisors')#end
1 +Tag Cloud
Parent
... ... @@ -1,1 +1,1 @@
1 -Theses.Clouds.WebHome
1 +Theses.WebHome
Default language
... ... @@ -1,0 +1,1 @@
1 +en
Content
... ... @@ -1,99 +1,43 @@
1 -{{velocity}}
2 -{{html clean="false" wiki="true"}}
3 -#template('apice_macros.vm')
4 -#objectspace()
5 -##
6 -#### tag parameter possibly brings name to be used as tag
1 +{{include reference = "MacroSheet" /}}{{velocity}}
7 7  #if( !$request.tag )
8 -## no tag parameter --> just the cloud
9 -## set query
10 - #set( $query = ", BaseObject as objThesis, LargeStringProperty as propSupervisors, StringProperty as propStatus, DateProperty as propEnddate
11 - where objThesis.name = doc.fullName and objThesis.className = '${objectSpace}.Class' and objThesis.name <> '${objectSpace}.Template' and propSupervisors.id.id = objThesis.id and propStatus.id.id = objThesis.id and propEnddate.id.id = objThesis.id and propSupervisors.name = 'supervisors' and propSupervisors.value <> '' and propStatus.name = 'status' and lower(propStatus.value) = 'completed' and propEnddate.name = 'end' order by propEnddate.value desc" )
12 -## execute query
13 - #set( $itemFound = $xwiki.searchDocuments($query) )
14 - #set( $itemFoundNo = $itemFound.size() )
15 -## name-item map
16 - #set( $nameMap = {} )
17 -## START EACH ITEM IN MAP
18 - #foreach( $item in $itemFound )
19 -## set $doc & $obj
20 - #set( $itemDoc = $xwiki.getDocument($item) )
21 - #set( $nameList = $itemDoc.getValue("supervisors").split(",") )
22 -## set user-item map
23 - #foreach( $name in $nameList )
24 -#### build name lists
25 - #if( $nameMap.keySet().contains($name) )
26 -## nameMap already contains current name
27 -## add $item to nameMap for current name
28 - #set( $discard = $nameMap[$name].add($item) )
29 - #elseif( !$oneUser || $oneUser && $name != $userName )
30 -## nameMap does not contain name or selected user
31 -## add name / selected user to nameMap
32 - #set( $nameMap[$name] = [] )
33 - ## adding $item to nameMap for $name
34 - #set( $discard = $nameMap[$name].add($item) )
35 - #end
3 +## no tag specified in the query
4 +>**Tag Cloud** / {{stringEngIta eng="Theses" ita="Tesi" /}}
5 +
6 +#set( $from = ", BaseObject as obj0" )
7 +#set( $where = " obj0.name = doc.fullName and obj0.className = 'Theses.ThesisClass' and obj0.name <> 'Theses.ThesisClassTemplate' and obj0.name <> 'Theses.ThesisTemplate' " )
8 +#set( $tagCount = $xwiki.tag.getTagCountForQuery($from, $where) )
9 +(% style='text-align: center' %)(((
10 +#foreach( $thesisTag in $tagCount.keySet() )
11 + #set( $thesisCount = $tagCount.get($thesisTag) )
12 + #if( $thesisCount > 20 ) #set ( $tagSize = "140%" )
13 + #elseif( $thesisCount > 10 ) #set ( $tagSize = "130%" )
14 + #elseif( $thesisCount > 5 ) #set ( $tagSize = "120%" )
15 + #elseif( $thesisCount > 3 ) #set ( $tagSize = "110%" )
16 + #elseif( $thesisCount == 3 ) #set ( $tagSize = "105%" )
17 + #elseif( $thesisCount == 2 ) #set ( $tagSize = "100%" )
18 + #else#set ($tagSize = "90%" )
36 36   #end
37 -#### END / feed name list from each item
38 - #end
39 -## END EACH ITEM IN MAP
40 -## final values: $nameMap
41 - #set( $nameFoundNo = $nameMap.keySet().size() )
42 -### CLOUD PAGE / START
43 -<div class="mainheader">
44 - $services.localization.render('theses').toLowerCase()
45 -</div>
46 -<div style='text-align: center'>
47 - #foreach( $name in $nameMap.keySet() )
48 - #set( $nameItemNo = $nameMap[$name].size() )
49 - #if( $nameItemNo > 40 )#set( $tagSize = "140%" )
50 - #elseif( $nameItemNo > 30 )#set( $tagSize = "135%" )
51 - #elseif( $nameItemNo > 20 )#set( $tagSize = "130%" )
52 - #elseif( $nameItemNo > 10 )#set( $tagSize = "125%" )
53 - #elseif( $nameItemNo > 5 )#set( $tagSize = "120%" )
54 - #elseif( $nameItemNo > 3 )#set( $tagSize = "110%" )
55 - #elseif( $nameItemNo == 3 )#set( $tagSize = "105%" )
56 - #elseif( $nameItemNo == 2 )#set( $tagSize = "100%" )
57 - #else#set( $tagSize = "90%" )
58 - #end
59 - #set( $urlEscapedName = $escapetool.url($name) )
60 -<span style='font-size:$tagSize; white-space: nowrap'>&ensp;[[#if( $name.startsWith("XWiki.") )$xwiki.getUserName($name,false)#else$name#end>>$doc||queryString="tag=$urlEscapedName"]]</span><sub class='textprimary' style="font-size: .75em">$nameItemNo</sub>&ensp;
61 - #end
62 -</div>
63 -## cloud bottom
64 -<div class="menuqualifier" style="text-align: right">
65 -[ $nameFoundNo #if( $nameFoundNo == 1 )$services.localization.render('supervisor').toLowerCase()#{else}$services.localization.render('supervisors').toLowerCase()#end / $itemFoundNo #if( $itemFoundNo == 1 )$services.localization.render('thesis').toLowerCase()#{else}$services.localization.render('theses').toLowerCase()#end ]
66 -</div>
67 -### CLOUD PAGE / END
20 + #set( $urlEscapedTag = $escapetool.url($thesisTag) )
21 + #set( $htmlEscapedTag = $escapetool.xml($thesisTag) )
22 +(% style='font-size:$tagSize' %) [[$thesisTag>>Theses.Tags||queryString="tag=$urlEscapedTag"]] (%%)#end
23 +)))
68 68  #else
69 -## yes tag parameter --> the item list
70 -##
71 -#### TAG PAGE / START
72 - #set( $query = ", BaseObject as objThesis, LargeStringProperty as propSupervisors, StringProperty as propStatus, DateProperty as propEnddate
73 - where objThesis.name = doc.fullName and objThesis.className = '${objectSpace}.Class' and objThesis.name <> '${objectSpace}.Template' and propSupervisors.id.id = objThesis.id and propStatus.id.id = objThesis.id and propEnddate.id.id = objThesis.id and propSupervisors.name = 'supervisors' and propSupervisors.value like '%$request.tag%' and propStatus.name = 'status' and lower(propStatus.value) = 'completed' and propEnddate.name = 'end' order by propEnddate.value desc" )
74 -## execute query
75 - #set( $itemFound = $xwiki.searchDocuments($query) )
76 - #set( $itemNo = $itemFound.size() )
77 -## subtitle
78 -<div class="mainheader">
79 - $itemNo
80 - #if( $itemNo > 1)
81 - $services.localization.render('theses').toLowerCase()
82 - #else
83 - $services.localization.render('thesis').toLowerCase()
84 - #end
85 -</div>
86 -## thesis list
87 - #template('apice_thesis_macros.vm')
88 - #foreach( $item in $itemFound )
89 -<div>
90 -[[image:icon:book]] #thesislinked($item)
91 -</div>
92 - #end
93 -## thesis list bottom
94 -<div class="menuqualifier" style="text-align: right">
95 -[ [[{{stringEngIta eng="supervisor cloud" ita="nuvola relatori" /}}>>$doc.name]] / $services.localization.render('theses').toLowerCase() ]
96 -</div>
25 +## one tag specified in the query
26 +>Tag “**$request.tag**” / {{stringEngIta eng = "Theses" ita = "Tesi" /}}
27 +
28 +#set( $from = ", BaseObject as obj0, DBStringListProperty as prop0 join prop0.list item, BaseObject as obj1, DateProperty as prop1, StringProperty as prop2" )
29 +#set( $where = "obj0.className = 'XWiki.TagClass' and obj0.name = doc.fullName and obj0.id = prop0.id.id and prop0.id.name = 'tags' and lower(item) = lower('$request.tag') and obj1.name = doc.fullName and obj1.className = 'Theses.ThesisClass' and obj1.name <> 'Theses.ThesisClassTemplate' and obj1.name <> 'Theses.ThesisTemplate' and prop1.id.id = obj1.id and prop2.id.id = obj1.id and prop1.name = 'endDate' and prop2.name = 'status' and lower(prop2.value) <> 'out-of-date' order by prop1.value desc" )
30 +#set( $sql = $from + " where " + $where )
31 +#set( $thesisFound = $xwiki.searchDocuments($sql) )
32 +## show tag
33 +(((
34 +#foreach( $thesis in $thesisFound)
35 + #set($thesisDoc = $xwiki.getDocument($thesis) )
36 +* {{thesis}}$thesisDoc{{/thesis}}
97 97  #end
98 -{{/html}}
99 -{{/velocity}}{{pageDisplay sort="objectservice"/}}
38 +)))
39 +
40 +(% style='font-style:oblique;font-size:smaller;text-align:right;color:gray' %)((([ [[tag cloud>>Tags]] / {{stringEngIta eng = "theses" ita = "tesi"/}} ])))(%%)
41 +
42 +#end
43 +{{/velocity}}