Changes for page Per Year
From version 12.5
edited by Andrea Omicini
on 22/06/2021 01:17
on 22/06/2021 01:17
Change comment:
There is no comment for this version
To version 70.1
edited by Andrea Omicini
on 29/10/2021 15:21
on 29/10/2021 15:21
Change comment:
There is no comment for this version
Summary
-
Page properties (2 modified, 0 added, 0 removed)
Details
- Page properties
-
- Title
-
... ... @@ -1,0 +1,1 @@ 1 +#if($xcontext.language=='it')Tesi per anno#{else}Theses per Year#end - Content
-
... ... @@ -1,199 +1,163 @@ 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( $c ontactdoc= $xwiki.getDocument($contactName))47 - set( $contactFirstName = $contactdoc.display("first_name") )48 - #set( $ contactLastName= $contactdoc.display("last_name"))24 + #if( $lastYear <= $firstYear ) 25 + #set( $oneYear = true ) 26 + #set( $selectedYear = $firstYear ) 27 + #else 28 + #set( $yearList = [$lastYear..$firstYear] ) 49 49 #end 50 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 31 +$oneYear 32 +$selectedYear 33 +$firstYear 34 +$lastYear 35 +$yearList 36 +#stop 77 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 - 84 -> {{stringEngIta eng="as a supervisor" ita="come relatore"/}} 85 - 38 +STOP 39 +##check velocity variable, takes precedence 40 +#if( $thesisStatus && $thesisStatus != '' && $allThesisStatuses.contains($thesisStatus.trim().toLowerCase()) ) 41 + #set( $oneStatus = true ) 42 + #set( $selectedStatus = $thesisStatus.trim().toLowerCase() ) 86 86 #end 87 - #if( $cosupervisor ) 88 -> #stringEnIt("as a co-supervisor","come correlatore") // // 89 - #end 90 - #if( $contact ) 91 -> #stringEnIt("as a contact","come contatto") // // 92 - #end 93 - #else 94 - #if( $supervisorLastName != "" ) 95 -> #stringEnIt("supervised by","con relatore") $supervisorFirstName $supervisorLastName 96 - #end 97 - #if( $cosupervisorLastName != "" ) 98 -> #stringEnIt("co-supervised by","con correlatore") $cosupervisorFirstName $cosupervisorLastName 99 - #end 100 - #if( $contactLastName != "" ) 101 -> #stringEnIt("with contact","con contatto") $contactFirstName $contactLastName 102 - #end 103 - #end 104 -#end 105 -## 106 -## hypothesis: $thesisStatus set, default "Completed" 107 -## to do: get from parameter 108 -#if ($thesisStatus == "Available") 109 - #set ($orderingDateFieldName = "availabilityDate") 110 -#elseif ($thesisStatus == "Ongoing") 111 - #set ($orderingDateFieldName = "startDate") 44 +## set ordering field 45 +#if( $selectedStatus == "available" ) 46 + #set( $orderingDateFieldName = "availabilityDate" ) 47 +#elseif( $selectedStatus == "ongoing" ) 48 + #set( $orderingDateFieldName = "startDate" ) 112 112 #else 113 - #set($thesisStatus= "Completed")114 - #set 50 +## default for no selected status, too 51 + #set( $orderingDateFieldName = "endDate" ) 115 115 #end 116 -## 117 -#if ( $cosupervisor ) 118 - #set ( $roleSelectedFieldName = "coSupervisors" ) 119 -#elseif ( $contact ) 120 - #set ( $roleSelectedFieldName = "contact" ) 121 -#else 122 - #set ( $roleSelectedFieldName = "supervisor" ) 123 -#end 53 +## invariant: $oneStatus set, $selectedStatus & $orderingDateFieldName set accordingly 54 +### END STATUS 124 124 ## 125 -#if ($userSelected) 126 - #if ( $roleSelected ) 127 - #set ($sql = ", BaseObject as obj, StringProperty as prop, LargeStringProperty as prop1, DateProperty as prop2 128 - where obj.name=doc.fullName and 129 - obj.className='Theses.ThesisClass' and 130 - obj.name<>'Theses.ThesisClassTemplate' and 131 - prop.id.id=obj.id and 132 - prop1.id.id=obj.id and 133 - prop2.id.id=obj.id and 134 - prop.name='status' and 135 - prop.value='$thesisStatus' and 136 - prop1.name='$roleSelectedFieldName' and 137 - prop2.name='$orderingDateFieldName' and 138 - prop1.value like '%$userName%' 139 - order by prop2.value desc") 56 +### START USER & ROLE 57 +#set( $userNamePar = $request.user.trim() ) 58 +## default values 59 +#set( $oneUser = false ) 60 +#set( $oneRole = false ) 61 +#set( $userFirstName = "" ) 62 +#set( $userLastName = "" ) 63 +#if( $userName || $userNamePar ) 64 +## a user is specified for all roles 65 + #if( !$userName ) 66 + #set( $selectedUser = "XWiki.$userNamePar" ) 140 140 #else 141 - #set ($sql = ", BaseObject as obj, StringProperty as prop, LargeStringProperty as prop1, LargeStringProperty as prop2, LargeStringProperty as prop3, DateProperty as prop4 142 - where obj.name=doc.fullName and 143 - obj.className='Theses.ThesisClass' and 144 - obj.name<>'Theses.ThesisClassTemplate' and 145 - prop.id.id=obj.id and 146 - prop1.id.id=obj.id and 147 - prop2.id.id=obj.id and 148 - prop3.id.id=obj.id and 149 - prop4.id.id=obj.id and 150 - prop.name='status' and 151 - prop.value = '$thesisStatus' and 152 - prop1.name='supervisor' and 153 - prop2.name='coSupervisors' and 154 - prop3.name='contact' and 155 - prop4.name='$orderingDateFieldName' and 156 - ( prop1.value like '%$userName%' or 157 - prop2.value like '%$userName%' or 158 - prop3.value like '%$userName%') 159 - order by prop4.value desc") 68 + #set( $selectedUser = $userName ) 160 160 #end 161 -#elseif ( $roleSelected ) 162 - #set ($sql = ", BaseObject as obj, StringProperty as prop, LargeStringProperty as prop1, LargeStringProperty as prop2, LargeStringProperty as prop3, DateProperty as prop4 163 - where obj.name=doc.fullName and 164 - obj.className='Theses.ThesisClass' and 165 - obj.name<>'Theses.ThesisClassTemplate' and 166 - prop.id.id=obj.id and 167 - prop1.id.id=obj.id and 168 - prop2.id.id=obj.id and 169 - prop3.id.id=obj.id and 170 - prop4.id.id=obj.id and 171 - prop.name='status' and 172 - prop.value = '$thesisStatus' and 173 - prop1.name='supervisor' and 174 - prop2.name='coSupervisors' and 175 - prop3.name='contact' and 176 - prop4.name='$orderingDateFieldName' and 177 - prop1.value like '%$supervisorName%' and 178 - prop2.value like '%$cosupervisorName%' and 179 - prop3.value like '%$contactName%' 180 - order by prop4.value desc") 181 -#else 182 - #set ($sql = ", BaseObject as obj, StringProperty as prop, DateProperty as prop1 183 - where obj.name=doc.fullName and 184 - obj.className='Theses.ThesisClass' and 185 - obj.name<>'Theses.ThesisClassTemplate' and 186 - prop.id.id=obj.id and 187 - prop1.id.id=obj.id and 188 - prop.name='status' and 189 - prop.value = '$thesisStatus' and 190 - prop1.name='$orderingDateFieldName' 191 - order by prop1.value desc") 70 + #if( $xwiki.exists($selectedUser) ) 71 + #set( $oneUser = true ) 72 + #set( $userdoc = $xwiki.getDocument($selectedUser) ) 73 + #set( $userFirstName = $userdoc.display("first_name") ) 74 + #set( $userLastName = $userdoc.display("last_name") ) 75 + #else 76 +{{warning}} $selectedUser is not an {{apice/}} user{{/warning}} 77 + #stop 78 + #end 79 +##user selected and existing user page 80 + #set( $rolePar = $request.role.trim().toLowerCase() ) 81 + #set( $selectedRole = '' ) 82 + #if( $rolePar != '' && $allThesisRoles.contains($rolePar) ) 83 + #set( $oneRole = true ) 84 + #set( $selectedRole = $rolePar ) 85 + #end 192 192 #end 193 -#set($thesisFound = $xwiki.searchDocuments($sql)) 87 +## $oneUser and $oneRole set properly, other related variables set accordingly 88 +## $oneRole has meaning only if $oneUser 89 +## if $oneUser, $oneRole false means one user for all roles 90 +## if $oneUser, $oneRole true means one specific role for one user selected 91 +## if $oneUser is false, $oneRole means nothing -- so all users, all roles / just status 194 194 ## 195 -#foreach ($thesis in $thesisFound)#set($thesisDoc = $xwiki.getDocument($thesis)) 196 -* #thesisTitleLink($thesis)#if( $thesisDoc.getValue("studentUserName") != "" || $thesisDoc.getValue("studentName") != "" ) //(#thesisAuthorLink($thesis)#if( $thesisDoc.display("endDate") != "" ), #thesisYear($thesis)#end)//#end 93 +## title 94 +>#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'/}} 95 +## index 96 +#if( !$oneStatus ) 97 +(% 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))) 98 +#elseif( $oneUser && !$oneRole ) 99 +(% 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))) 100 +#end{{id name='index'/}} 101 +## search theses 102 +#set( $thesisNo = 0 ) 103 +#foreach( $status in $allThesisStatuses ) 104 + #if( !$oneStatus || $selectedStatus == $status ) 105 + #set( $thesisStatusNo = 0 ) 106 + #if( !$oneStatus ) 107 +(% 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}} 108 + #end 109 +## some selected status or all statuses / now $status 110 + #if( $oneUser ) 111 +## some user selected 112 + #foreach( $role in $allThesisRoles ) 113 + #set( $thesisStatusRoleNo = 0 ) 114 + #if( !$oneRole || $selectedRole == $role ) 115 + #if( $role == "contact" ) 116 + #set( $selectedRoleFieldName = "contacts" ) 117 + #elseif( $role == "cosupervisor" ) 118 + #set( $selectedRoleFieldName = "cosupervisors" ) 119 + #else 120 + #set( $selectedRoleFieldName = "supervisors" ) 121 + #end 122 +## some selected role or all roles / now $role 123 + #set ($sql = ", BaseObject as obj, StringProperty as prop0, LargeStringProperty as prop1, DateProperty as prop2 124 + 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" ) 125 + #set( $thesisFound = $xwiki.searchDocuments($sql) ) 126 + #set( $thesisFoundNo = $thesisFound.size() ) 127 + #set( $thesisStatusRoleNo = $thesisStatusRoleNo + $thesisFoundNo ) 128 + #if( $thesisFoundNo > 0 && !$oneRole ) 129 +(% 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}} 130 + #end 131 + #foreach( $thesis in $thesisFound ) 132 + #set($thesisDoc = $xwiki.getDocument($thesis)) 133 + #set($thesisObj = $thesisDoc.getObject('Theses.ThesisClass')) 134 +* [[$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 197 197 136 + #end 137 + #if( $thesisFoundNo > 0 && !$oneRole ) 138 +(% 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"]] 139 + #end 140 + #end 141 + #set( $thesisStatusNo = $thesisStatusNo + $thesisStatusRoleNo ) 142 + #end 143 +## no user selected, no role selected 144 + #else 145 + #set ($sql = ", BaseObject as obj, StringProperty as prop0, DateProperty as prop1 146 + 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" ) 147 + #set( $thesisFound = $xwiki.searchDocuments($sql) ) 148 + #set( $thesisFoundNo = $thesisFound.size() ) 149 + #set( $thesisStatusNo = $thesisStatusNo + $thesisFoundNo ) 150 + #foreach( $thesis in $thesisFound ) 151 + #set($thesisDoc = $xwiki.getDocument($thesis)) 152 + #set($thesisObj = $thesisDoc.getObject('Theses.ThesisClass')) 153 +* [[$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 154 + 155 + #end 156 + #end 157 + #if( !$oneStatus ) 158 +(% 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"]] 159 + #end 160 + #end 198 198 #end 162 +{{id name='bottom'/}} 199 199 {{/velocity}}