Changes for page Per Year

From version 12.3
edited by Andrea Omicini
on 22/06/2021 01:15
Change comment: There is no comment for this version
To version 69.1
edited by Andrea Omicini
on 29/10/2021 15:18
Change comment: There is no comment for this version

Summary

Details

Page properties
Title
... ... @@ -1,0 +1,1 @@
1 +#if($xcontext.language=='it')Tesi per anno#{else}Theses per Year#end
Content
... ... @@ -1,197 +1,161 @@
1 -{{include document="Main.MacroSheet"/}}{{include document="Theses.MacroSheet"/}}{{velocity filter="none"}}#### get parameters
2 -## who
3 -#set( $userNamePar = $context.getRequest().getParameter("user") )
4 -#set( $supervisorNamePar = $context.getRequest().getParameter("supervisor") )
5 -#set( $cosupervisorNamePar = $context.getRequest().getParameter("cosupervisor") )
6 -#set( $contactNamePar = $context.getRequest().getParameter("contact") )
7 -#### set default values
8 -#set( $userSelected = false )
9 -#set( $roleSelected = false )
10 -#set( $userFirstName = "" )
11 -#set( $userLastName = "" )
12 -#set( $supervisorName = "" )
13 -#set( $supervisorFirstName = "" )
14 -#set( $supervisorLastName = "" )
15 -#set( $cosupervisorName = "" )
16 -#set( $cosupervisorFirstName = "" )
17 -#set( $cosupervisorLastName = "" )
18 -#set( $contactName = "" )
19 -#set( $contactFirstName = "" )
20 -#set( $contactLastName = "" )
21 -##
22 -#### handle who & roles
23 -##
24 -#if ( $userName || $userNamePar ) ## a user is specified for all roles
25 - #set( $userSelected = true )
26 - #if ( !$userName )#set( $userName = "XWiki.$userNamePar" )#end
27 - #set( $userdoc = $xwiki.getDocument($userName) )
28 - #set( $userFirstName = $userdoc.display("first_name") )
29 - #set( $userLastName = $userdoc.display("last_name") )
30 -#elseif ( $supervisorNamePar || $cosupervisorNamePar || $contactNamePar )
31 - #set( $roleSelected = true )
32 - #if ( $supervisorNamePar )
33 - #set( $supervisorName = "XWiki.$supervisorNamePar" )
34 - #set( $supervisordoc = $xwiki.getDocument($supervisorName) )
35 - #set( $supervisorFirstName = $supervisordoc.display("first_name") )
36 - #set( $supervisorLastName = $supervisordoc.display("last_name") )
1 +{{include reference="Theses.Environment"/}}{{include reference="Environment"/}}{{velocity}}
2 +#set( $thesisMenu = true )
3 +#set( $oneYear = false )
4 +### START YEAR
5 +## year parameter
6 +#set( $yearPar = $mathtool.toInteger("$!$request.year") )
7 +#set( $fromPar = $mathtool.toInteger("$!$request.from") )
8 +#set( $toPar = $mathtool.toInteger("$!$request.to") )
9 +#set( $firstYear = $firstYearTh )
10 +#set( $lastYear = $lastYearTh )
11 +#set( $yearList = [$lastYear..$firstYear] )
12 +#if( $yearPar != '' )
13 + #set( $oneYear = true )
14 + #set( $selectedYear = $yearPar )
15 +#else
16 + #if( $fromPar != '' && $yearList.contains($fromPar) )
17 + #set( $firstYear = $fromPar )
18 + #set( $yearList = [$lastYear..$firstYear] )
37 37   #end
38 - #if ( $cosupervisorNamePar )
39 - #set( $cosupervisorName = "XWiki.$cosupervisorNamePar" )
40 - #set( $cosupervisordoc = $xwiki.getDocument($cosupervisorName) )
41 - #set( $cosupervisorFirstName = $cosupervisordoc.display("first_name") )
42 - #set( $cosupervisorLastName = $cosupervisordoc.display("last_name") )
20 + #if( $toPar != '' && $yearList.contains($toPar) )
21 + #set( $lastYear = $toPar )
22 + #set( $yearList = [$lastYear..$firstYear] )
43 43   #end
44 - #if ( $contactNamePar )
45 - #set( $contactName = "XWiki.$contactNamePar" )
46 - #set( $contactdoc = $xwiki.getDocument($contactName) )
47 - #set( $contactFirstName = $contactdoc.display("first_name") )
48 - #set( $contactLastName = $contactdoc.display("last_name") )
49 - #end
50 -#end
51 -#if( $supervisor )
52 - #set( $roleSelected = true )
53 - #set( $supervisorName = $userName )
54 - #set( $supervisordoc = $xwiki.getDocument($supervisorName) )
55 - #set( $supervisorFirstName = $supervisordoc.display("first_name") )
56 - #set( $supervisorLastName = $supervisordoc.display("last_name") )
57 -#end
58 -#if( $cosupervisor )
59 - #set( $roleSelected = true )
60 - #set( $cosupervisorName = $userName )
61 - #set( $cosupervisordoc = $xwiki.getDocument($cosupervisorName) )
62 - #set( $cosupervisorFirstName = $cosupervisordoc.display("first_name") )
63 - #set( $cosupervisorLastName = $cosupervisordoc.display("last_name") )
64 -#end
65 -#if( $contact )
66 - #set( $roleSelected = true )
67 - #set( $contactName = $userName )
68 - #set( $contactdoc = $xwiki.getDocument($contactName) )
69 - #set( $contactFirstName = $contactdoc.display("first_name") )
70 - #set( $contactLastName = $contactdoc.display("last_name") )
71 -#end
72 -##
73 -## $userSelected true means one user for all roles
74 -## $userSelected true and $roleSelected true for one user with one specific role
75 -## if $userSelected false and $roleSelected true mean at least one role with an assigned user
76 -## both false means all theses
77 -
78 -== #if( $userSelected )$userFirstName $userLastName / #end#stringEnIt("Theses ","Tesi")#if( $thesisStatus ) / #ThesisStatusesString($thesisStatus)#end ==
79 -
80 -#if( $roleSelected )
81 - #if( $userSelected )
82 - #if( $supervisor )
83 -> #stringEnIt("as a supervisor","come relatore") // //
84 - #end
85 - #if( $cosupervisor )
86 -> #stringEnIt("as a co-supervisor","come correlatore") // //
87 - #end
88 - #if( $contact )
89 -> #stringEnIt("as a contact","come contatto") // //
90 - #end
24 + #if( $lastYear <= $firstYear )
25 + #set( $oneYear = true )
26 + #set( $selectedYear = $firstYear )
91 91   #else
92 - #if( $supervisorLastName != "" )
93 -> #stringEnIt("supervised by","con relatore") $supervisorFirstName $supervisorLastName
94 - #end
95 - #if( $cosupervisorLastName != "" )
96 -> #stringEnIt("co-supervised by","con correlatore") $cosupervisorFirstName $cosupervisorLastName
97 - #end
98 - #if( $contactLastName != "" )
99 -> #stringEnIt("with contact","con contatto") $contactFirstName $contactLastName
100 - #end
28 + #set( $yearList = [$lastYear..$firstYear] )
101 101   #end
102 102  #end
103 -##
104 -## hypothesis: $thesisStatus set, default "Completed"
105 -## to do: get from parameter
106 -#if ($thesisStatus == "Available")
107 - #set ($orderingDateFieldName = "availabilityDate")
108 -#elseif ($thesisStatus == "Ongoing")
109 - #set ($orderingDateFieldName = "startDate")
110 -#else
111 - #set ($thesisStatus = "Completed")
112 - #set ($orderingDateFieldName = "endDate")
31 +$oneYear
32 +$selectedYear
33 +$firstYear
34 +$lastYear
35 +$yearList
36 +#stop
37 +##check velocity variable, takes precedence
38 +#if( $thesisStatus && $thesisStatus != '' && $allThesisStatuses.contains($thesisStatus.trim().toLowerCase()) )
39 + #set( $oneStatus = true )
40 + #set( $selectedStatus = $thesisStatus.trim().toLowerCase() )
113 113  #end
114 -##
115 -#if ( $cosupervisor )
116 - #set ( $roleSelectedFieldName = "coSupervisors" )
117 -#elseif ( $contact )
118 - #set ( $roleSelectedFieldName = "contact" )
42 +## set ordering field
43 +#if( $selectedStatus == "available" )
44 + #set( $orderingDateFieldName = "availabilityDate" )
45 +#elseif( $selectedStatus == "ongoing" )
46 + #set( $orderingDateFieldName = "startDate" )
119 119  #else
120 - #set ( $roleSelectedFieldName = "supervisor" )
48 +## default for no selected status, too
49 + #set( $orderingDateFieldName = "endDate" )
121 121  #end
51 +## invariant: $oneStatus set, $selectedStatus & $orderingDateFieldName set accordingly
52 +### END STATUS
122 122  ##
123 -#if ($userSelected)
124 - #if ( $roleSelected )
125 - #set ($sql = ", BaseObject as obj, StringProperty as prop, LargeStringProperty as prop1, DateProperty as prop2
126 - where obj.name=doc.fullName and
127 - obj.className='Theses.ThesisClass' and
128 - obj.name<>'Theses.ThesisClassTemplate' and
129 - prop.id.id=obj.id and
130 - prop1.id.id=obj.id and
131 - prop2.id.id=obj.id and
132 - prop.name='status' and
133 - prop.value='$thesisStatus' and
134 - prop1.name='$roleSelectedFieldName' and
135 - prop2.name='$orderingDateFieldName' and
136 - prop1.value like '%$userName%'
137 - order by prop2.value desc")
54 +### START USER & ROLE
55 +#set( $userNamePar = $request.user.trim() )
56 +## default values
57 +#set( $oneUser = false )
58 +#set( $oneRole = false )
59 +#set( $userFirstName = "" )
60 +#set( $userLastName = "" )
61 +#if( $userName || $userNamePar )
62 +## a user is specified for all roles
63 + #if( !$userName )
64 + #set( $selectedUser = "XWiki.$userNamePar" )
138 138   #else
139 - #set ($sql = ", BaseObject as obj, StringProperty as prop, LargeStringProperty as prop1, LargeStringProperty as prop2, LargeStringProperty as prop3, DateProperty as prop4
140 - where obj.name=doc.fullName and
141 - obj.className='Theses.ThesisClass' and
142 - obj.name<>'Theses.ThesisClassTemplate' and
143 - prop.id.id=obj.id and
144 - prop1.id.id=obj.id and
145 - prop2.id.id=obj.id and
146 - prop3.id.id=obj.id and
147 - prop4.id.id=obj.id and
148 - prop.name='status' and
149 - prop.value = '$thesisStatus' and
150 - prop1.name='supervisor' and
151 - prop2.name='coSupervisors' and
152 - prop3.name='contact' and
153 - prop4.name='$orderingDateFieldName' and
154 - ( prop1.value like '%$userName%' or
155 - prop2.value like '%$userName%' or
156 - prop3.value like '%$userName%')
157 - order by prop4.value desc")
66 + #set( $selectedUser = $userName )
158 158   #end
159 -#elseif ( $roleSelected )
160 - #set ($sql = ", BaseObject as obj, StringProperty as prop, LargeStringProperty as prop1, LargeStringProperty as prop2, LargeStringProperty as prop3, DateProperty as prop4
161 - where obj.name=doc.fullName and
162 - obj.className='Theses.ThesisClass' and
163 - obj.name<>'Theses.ThesisClassTemplate' and
164 - prop.id.id=obj.id and
165 - prop1.id.id=obj.id and
166 - prop2.id.id=obj.id and
167 - prop3.id.id=obj.id and
168 - prop4.id.id=obj.id and
169 - prop.name='status' and
170 - prop.value = '$thesisStatus' and
171 - prop1.name='supervisor' and
172 - prop2.name='coSupervisors' and
173 - prop3.name='contact' and
174 - prop4.name='$orderingDateFieldName' and
175 - prop1.value like '%$supervisorName%' and
176 - prop2.value like '%$cosupervisorName%' and
177 - prop3.value like '%$contactName%'
178 - order by prop4.value desc")
179 -#else
180 - #set ($sql = ", BaseObject as obj, StringProperty as prop, DateProperty as prop1
181 - where obj.name=doc.fullName and
182 - obj.className='Theses.ThesisClass' and
183 - obj.name<>'Theses.ThesisClassTemplate' and
184 - prop.id.id=obj.id and
185 - prop1.id.id=obj.id and
186 - prop.name='status' and
187 - prop.value = '$thesisStatus' and
188 - prop1.name='$orderingDateFieldName'
189 - order by prop1.value desc")
68 + #if( $xwiki.exists($selectedUser) )
69 + #set( $oneUser = true )
70 + #set( $userdoc = $xwiki.getDocument($selectedUser) )
71 + #set( $userFirstName = $userdoc.display("first_name") )
72 + #set( $userLastName = $userdoc.display("last_name") )
73 + #else
74 +{{warning}} $selectedUser is not an {{apice/}} user{{/warning}}
75 + #stop
76 + #end
77 +##user selected and existing user page
78 + #set( $rolePar = $request.role.trim().toLowerCase() )
79 + #set( $selectedRole = '' )
80 + #if( $rolePar != '' && $allThesisRoles.contains($rolePar) )
81 + #set( $oneRole = true )
82 + #set( $selectedRole = $rolePar )
83 + #end
190 190  #end
191 -#set($thesisFound = $xwiki.searchDocuments($sql))
85 +## $oneUser and $oneRole set properly, other related variables set accordingly
86 +## $oneRole has meaning only if $oneUser
87 +## if $oneUser, $oneRole false means one user for all roles
88 +## if $oneUser, $oneRole true means one specific role for one user selected
89 +## if $oneUser is false, $oneRole means nothing -- so all users, all roles / just status
192 192  ##
193 -#foreach ($thesis in $thesisFound)#set($thesisDoc = $xwiki.getDocument($thesis))
194 -* #thesisTitleLink($thesis)#if( $thesisDoc.getValue("studentUserName") != "" || $thesisDoc.getValue("studentName") != "" ) //(#thesisAuthorLink($thesis)#if( $thesisDoc.display("endDate") != "" ), #thesisYear($thesis)#end)//#end
91 +## title
92 +>#if( $oneStatus ){{thesisStatus plural='yes' uppercase='yes'}}$selectedStatus{{/thesisStatus}}#else{{stringEngIta eng="Theses" ita="Tesi"/}}#end#if( $oneUser ) / $userFirstName **$userLastName**#end#if( $oneRole ) / {{thesisRole short='yes'}}$selectedRole{{/thesisRole}}#end{{id name='top'/}}
93 +## index
94 +#if( !$oneStatus )
95 +(% style="font-size: smaller; padding:1em 1.5em 0.25em 1.5em; background-color:$theme.highlightColor" %)(((#foreach( $status in $allThesisStatuses )#if ($velocityCount > 1) | #end[[{{thesisStatus plural="true" uppercase="false"}}$status{{/thesisStatus}}>>||anchor="$status"]]#end)))
96 +#elseif( $oneUser && !$oneRole )
97 +(% style="font-size: smaller; padding:1em 1.5em 0.25em 1.5em; background-color:$theme.highlightColor" %)(((#foreach( $role in $allThesisRoles )#if ($velocityCount > 1) | #end [[{{thesisRole}}$role{{/thesisRole}}>>||anchor="$role"]]#end)))
98 +#end{{id name='index'/}}
99 +## search theses
100 +#set( $thesisNo = 0 )
101 +#foreach( $status in $allThesisStatuses )
102 + #if( !$oneStatus || $selectedStatus == $status )
103 + #set( $thesisStatusNo = 0 )
104 + #if( !$oneStatus )
105 +(% style="border-style:solid hidden hidden solid; border-color:$theme.borderColor; text-align:left; font-style:oblique" %)|{{id name='$status'/}}{{thesisStatus plural='true' uppercase='true' short='true'}}$status{{/thesisStatus}}
106 + #end
107 +## some selected status or all statuses / now $status
108 + #if( $oneUser )
109 +## some user selected
110 + #foreach( $role in $allThesisRoles )
111 + #set( $thesisStatusRoleNo = 0 )
112 + #if( !$oneRole || $selectedRole == $role )
113 + #if( $role == "contact" )
114 + #set( $selectedRoleFieldName = "contacts" )
115 + #elseif( $role == "cosupervisor" )
116 + #set( $selectedRoleFieldName = "cosupervisors" )
117 + #else
118 + #set( $selectedRoleFieldName = "supervisors" )
119 + #end
120 +## some selected role or all roles / now $role
121 + #set ($sql = ", BaseObject as obj, StringProperty as prop0, LargeStringProperty as prop1, DateProperty as prop2
122 + where obj.name = doc.fullName and obj.className = 'Theses.ThesisClass' and obj.name <> 'Theses.ThesisClassTemplate' and obj.name <> 'Theses.ThesisTemplate' and prop0.id.id = obj.id and prop1.id.id = obj.id and prop2.id.id = obj.id and prop0.name = 'status' and prop1.name = '$selectedRoleFieldName' and prop2.name = '$orderingDateFieldName' and lower(prop0.value) = '$status' and prop1.value like '%$selectedUser%' order by prop2.value desc" )
123 + #set( $thesisFound = $xwiki.searchDocuments($sql) )
124 + #set( $thesisFoundNo = $thesisFound.size() )
125 + #set( $thesisStatusRoleNo = $thesisStatusRoleNo + $thesisFoundNo )
126 + #if( $thesisFoundNo > 0 && !$oneRole )
127 +(% style="border-style:#if( $oneStatus )solid hidden hidden solid#{else}hidden hidden hidden dotted#end; border-color:$theme.borderColor; text-align:left; font-style:oblique; font-size:smaller" %)|#if( $oneStatus ){{id name='$role'/}}#else{{id name='$status-$role'/}}#end{{thesisRole plural='no' uppercase='yes' short='yes'}}$role{{/thesisRole}}
128 + #end
129 + #foreach( $thesis in $thesisFound )
130 + #set($thesisDoc = $xwiki.getDocument($thesis))
131 + #set($thesisObj = $thesisDoc.getObject('Theses.ThesisClass'))
132 +* [[$thesisObj.title>>$thesisDoc]]#if( $thesisObj.endDate != "" ) //($thesisObj.endDate)//#end#if( $thesisDoc.getValue('studentUserName') != "" ) [[$xwiki.getUserName($thesisDoc.getValue('studentUserName'), false)>>$thesisDoc.getValue('studentUserName')]]#elseif( $thesisObj.studentFirstName != "" && $thesisObj.studentLastName != "" ) $thesisObj.studentFirstName $thesisObj.studentLastName#end
195 195  
134 + #end
135 + #if( $thesisFoundNo > 0 && !$oneRole )
136 +(% style="border-style:#if( $oneStatus )hidden solid solid hidden#{else}hidden dotted hidden hidden#end; border-color:$theme.borderColor; text-align:right; font-style:oblique; font-weight:normal; font-size:smaller; color:$theme.textSecondaryColor" %)|#if( $oneStatus ){{id name='$role-bottom'/}}#else{{id name='$role-$status-bottom'/}}#end($thesisStatusRoleNo #if( $thesisStatusRoleNo == 1 ){{thesisStatus plural='no' uppercase='no' short='no'}}$status{{/thesisStatus}}#else{{thesisStatus plural='yes' uppercase='no' short='no'}}$status{{/thesisStatus}}#end {{stringEngIta eng='as' ita='come'/}} {{thesisRole short='yes'}}$role{{/thesisRole}}) [[[{{stringEngIta eng='top' ita='in cima'/}}]>>||anchor="top"]] [[[{{stringEngIta eng='bottom' ita='in fondo'/}}]>>||anchor="bottom"]]
137 + #end
138 + #end
139 + #set( $thesisStatusNo = $thesisStatusNo + $thesisStatusRoleNo )
140 + #end
141 +## no user selected, no role selected
142 + #else
143 + #set ($sql = ", BaseObject as obj, StringProperty as prop0, DateProperty as prop1
144 + where obj.name = doc.fullName and obj.className = 'Theses.ThesisClass' and obj.name <> 'Theses.ThesisClassTemplate' and obj.name <> 'Theses.ThesisTemplate' and prop0.id.id = obj.id and prop1.id.id = obj.id and prop0.name = 'status' and prop1.name = '$orderingDateFieldName' and lower(prop0.value) = '$status' order by prop1.value desc" )
145 + #set( $thesisFound = $xwiki.searchDocuments($sql) )
146 + #set( $thesisFoundNo = $thesisFound.size() )
147 + #set( $thesisStatusNo = $thesisStatusNo + $thesisFoundNo )
148 + #foreach( $thesis in $thesisFound )
149 + #set($thesisDoc = $xwiki.getDocument($thesis))
150 + #set($thesisObj = $thesisDoc.getObject('Theses.ThesisClass'))
151 +* [[$thesisObj.title>>$thesisDoc]]#if( $thesisObj.endDate != "" ) //($thesisObj.endDate)//#end#if( $thesisDoc.getValue('studentUserName') != "" ) [[$xwiki.getUserName($thesisDoc.getValue('studentUserName'), false)>>$thesisDoc.getValue('studentUserName')]]#elseif( $thesisObj.studentFirstName != "" && $thesisObj.studentLastName != "" ) $thesisObj.studentFirstName $thesisObj.studentLastName#end
152 +
153 + #end
154 + #end
155 + #if( !$oneStatus )
156 +(% style="border-style:hidden solid solid hidden; border-color:$theme.borderColor; text-align:right; font-style:oblique; font-weight:normal; font-size:smaller; color:$theme.textSecondaryColor" %)|($thesisStatusNo #if($thesisStatusNo == 1){{thesisStatus plural='false' uppercase='false' short='no'}}$status{{/thesisStatus}}#else{{thesisStatus plural='true' uppercase='false' short='no'}}$status{{/thesisStatus}}#end{{id name='$status-bottom'/}}) [[[{{stringEngIta eng='top' ita='in cima'/}}]>>||anchor="top"]] [[[{{stringEngIta eng='bottom' ita='in fondo'/}}]>>||anchor="bottom"]]
157 + #end
158 + #end
196 196  #end
160 +{{id name='bottom'/}}
197 197  {{/velocity}}