Changes for page Per Status
From version 63.1
edited by Andrea Omicini
on 16/10/2021 01:00
on 16/10/2021 01:00
Change comment:
There is no comment for this version
To version 77.1
edited by Andrea Omicini
on 03/01/2023 00:07
on 03/01/2023 00:07
Change comment:
There is no comment for this version
Summary
-
Page properties (3 modified, 0 added, 0 removed)
Details
- Page properties
-
- Title
-
... ... @@ -1,1 +1,0 @@ 1 -Per Status - Default language
-
... ... @@ -1,1 +1,0 @@ 1 -en - Content
-
... ... @@ -1,85 +1,118 @@ 1 -{{include reference="Publications.Environment"/}}{{include reference="Environment"/}}{{velocity}} 1 += {{italiano}}Per stato{{/italiano}}{{english}}Per Status{{/english}} = 2 + 3 +{{include reference="Publications.Environment" excludeFirstHeading="true"/}}{{velocity}} 4 +## a Publications page 2 2 #set( $publicationMenu = true ) 3 3 #### get parameters 4 4 ## who 5 -#set( $userNamePar = $ context.getRequest().getParameter("user") )6 -#set( $firstNamePar = $ context.getRequest().getParameter("name") )7 -#set( $lastNamePar = $ context.getRequest().getParameter("surname") )8 +#set( $userNamePar = $request.user.trim() ) 9 +#set( $firstNamePar = $request.name.trim() ) 10 +#set( $lastNamePar = $request.surname.trim() ) 8 8 ## which status 9 -#set($statusPar = $ context.getRequest().getParameter("status"))12 +#set( $statusPar = $request.status.trim() ) 10 10 ## 11 11 #### handle who 12 12 #if( $userName ) 13 -## from a personal page, "XWiki.PersonalSpace" $userName form 14 - #set( $oneAuthor = true ) 16 +## from a personal page, "XWiki.$userName" $userName form 17 + #if( !$xwiki.exists( $userName ) ) 18 +{{warning}}User $userName does not exist{{/warning}} 19 + #stop 20 + #end 21 + #set( $apiceUser = true ) 22 + #set( $oneUser = true ) 15 15 #set( $userdoc = $xwiki.getDocument($userName) ) 16 - #set( $authorFirstName = $userdoc.display("first_name") ) 17 - #set( $authorLastName = $userdoc.display("last_name") ) 18 -#elseif( $userNamePar ) 19 -## from the URL, "user=PersonalSpace" parameter 20 - #set( $oneAuthor = true) 21 - #set( $userdoc = $xwiki.getDocument("XWiki.$userNamePar") ) 22 - #set( $authorFirstName = $userdoc.display("first_name") ) 23 - #set( $authorLastName = $userdoc.display("last_name") ) 24 + #set( $userFirstName = $userdoc.display("first_name") ) 25 + #set( $userLastName = $userdoc.display("last_name") ) 26 +#elseif( $userNamePar ) ## from the URL, "user=$userNamePar" parameter 27 + #if( $userNamePar.contains('XWiki.') ) 28 + #set( $userName = "$userNamePar" ) 29 + #else 30 + #set( $userName = "XWiki.$userNamePar" ) 31 + #end 32 + #if( !$xwiki.exists( $userName ) ) 33 + #if( $services.localization.currentLocale == 'it' ) 34 +{{warning}}L'utente “$userNamePar” non esiste{{/warning}} 35 + #else 36 +{{warning}}User “$userNamePar” does not exist{{/warning}} 37 + #end 38 + #stop 39 + #end 40 + #set( $apiceUser = true ) 41 + #set( $oneUser = true) 42 + #set( $userdoc = $xwiki.getDocument($userName) ) 43 + #set( $userFirstName = $userdoc.display("first_name") ) 44 + #set( $userLastName = $userdoc.display("last_name") ) 24 24 #elseif( $firstNamePar && $lastNamePar ) 25 25 ## from the URL, "name=Firstname&surname=Lastname" parameter 26 - #set( $oneAuthor = true ) 27 - #set( $authorFirstName = $firstNamePar ) 28 - #set( $authorLastName = $lastNamePar ) 47 + #set( $apiceUser = false ) 48 + #set( $oneUser = true ) 49 + #set( $userFirstName = $firstNamePar ) 50 + #set( $userLastName = $lastNamePar ) 29 29 #else 30 - #set( $oneAuthor = false ) 31 - #set( $authorFirstName = "" ) 32 - #set( $authorLastName = "" ) 52 + #set( $apiceUser = false ) 53 + #set( $oneUser = false ) 54 + #set( $userFirstName = "" ) 55 + #set( $userLastName = "" ) 33 33 #end 57 +#if( $oneUser ) 58 + #if( $apiceUser ) 59 + #set( $userString = "%$userName%" ) 60 + #else 61 + #set( $userString = "%$userFirstName $userLastName%" ) 62 + #end 63 +#else 64 + #set( $userString = "%%" ) 65 +#end 34 34 ## 35 35 #### handle status 36 36 ## $oneStatus false gets a list of statuses, true just one 37 37 #set( $oneStatus = false ) 38 38 ## $statusList gets the list of statuses to be shown 71 +#set( $statusList = [] ) 39 39 ## default: all unpublished papers except Rejected ones 40 -#set( $ statusList= $statusRangeUnpublished )73 +#set( $discard = $statusList.addAll($unpublishedStatuses) ) 41 41 #if( $statusPar.toLowerCase() == "all" ) 42 42 ## 'all' value gets all unpublished papers including "Rejected" ones 43 - #set($ statusList= $statusRangeUnpublishedFull)76 + #set( $discard = $statusList.add("rejected") ) 44 44 #else 45 - #if( $ statusRangeFull.contains($statusPar) )78 + #if( $allStatusesPlus.contains($statusPar) ) 46 46 ## 'status' parameter is an admissible publication status value 47 - #set($oneStatus = true) 48 - #set($statusList = [$statusPar]) 80 + #set( $oneStatus = true ) 81 + #set( $statusList = [$statusPar] ) 49 49 #end 50 50 #end 84 +$statusList 51 51 ## 52 -{{id name="top"/}} 53 -#if( $oneAuthor )#if( $oneStatus ) 54 ->**{{pubStatus uppercase='true' plural='true'}}$statusPar{{/pubStatus}}** / $authorFirstName $authorLastName 55 -#else 56 ->**{{pubStatus uppercase='true' plural='true'}}unpublished{{/pubStatus}}** / $authorFirstName $authorLastName 57 -#end#elseif($oneStatus) 58 ->{{pubStatus uppercase='true' plural='true'}}$statusPar{{/pubStatus}} 59 -#else 60 ->{{pubStatus uppercase='true' plural='true'}}unpublished{{/pubStatus}} 61 -#end 62 -## 63 -#if( !$oneStatus ) 64 -(% style="font-size: smaller; padding:1em 1.5em 0.25em 1.5em; background-color:#if( $xwikiTheme =='dark') #3A3F44 #else whitesmoke #end" %)(((#foreach( $status in $statusList )#if( $velocityCount > 1 ) | #end[[{{pubStatus}}$status{{/pubStatus}}>>||anchor=$status]]#end))) 65 -#end 66 -## 86 +## query to structures 87 +#set( $pubMap = {} ) 88 +#set( $pubNo = 0 ) 67 67 #foreach( $status in $statusList ) 68 - #set( $from = ", BaseObject as obj, LargeStringProperty as prop0, StringProperty as prop1" ) 69 - #set( $where = "obj.name=doc.fullName and obj.className=' Publications.PublicationClass' and obj.name<>'Publications.PublicationClassTemplate' and prop0.id.id=obj.id and prop1.id.id=obj.id and prop0.name='author' and (prop0.value like '%$authorFirstName$authorLastName%'orprop0.value like '%$authorLastName, $authorFirstName%') and prop1.name = 'status' and prop1.value = '$status'" )90 + #set( $from = ", BaseObject as obj, LargeStringProperty as prop0, LargeStringProperty as prop1, StringProperty as prop2" ) 91 + #set( $where = "obj.name = doc.fullName and obj.className = '${objectSpace}.${objectClass}' and obj.name <> '${objectSpace}.${objectTemplate}' and prop0.id.id = obj.id and prop1.id.id = obj.id and prop2.id.id = obj.id and prop0.name = 'author' and prop1.name = 'editor' and ( prop0.value like '$userString' or ( prop0.value = '' and prop1.value like '$userString' ) ) and prop2.name = 'status' and prop2.value = '$status'" ) 70 70 #set( $sql = $from + " where " + $where ) 71 71 #set( $pubFound = $xwiki.searchDocuments($sql) ) 72 - #set($pubStatusNo = $pubFound.size())94 +$pubFound.size() 73 73 #if( $pubStatusNo > 0 ) 74 - #if( !$oneStatus ) 75 -(% style="border-style:solid hidden hidden solid; border-color:silver; text-align:left; font-style:oblique" %)|{{id name='$sort'/}}{{pubStatus plural='true' uppercase='true'}}$status{{/pubStatus}}{{id name="$status"/}} 76 - #end 77 - #foreach( $pub in $pubFound ) 78 -|(% style='color:#if( $xwikiTheme == 'dark' ) silver #else dimgray #end; display:block; line-height:1.25em; margin-top:0; margin-bottom:0em'%){{pubAutheditors eds='true'}}$pub{{/pubAutheditors}} 79 -{{pubTitle}}$pub{{/pubTitle}} 80 -{{pubVenue}}$pub{{/pubVenue}}(%%) 81 - #end 82 -(% style="#if( !$oneStatus )border-style:hidden solid solid hidden;#end border-color:silver; text-align:right; font-style:oblique; font-weight:normal; font-size:smaller; color:gray" %)|($pubStatusNo #if( $pubStatusNo > 1 ){{pubStatus plural='true'}}$status{{/pubStatus}}#else{{pubStatus plural='false'}}$status{{/pubStatus}}#end) [[[top]>>||anchor="top"]] 96 + #set( $pubMap[$status] = $pubFound ) 97 + #set( $pubNo = $pubNo + $pubStatusNo ) 83 83 #end 84 84 #end 100 +## output results 101 +## page subtitle 102 +{{id name="top"/}} 103 +>(%%)$pubNo #if( $pubNo == 1 ){{stringEngIta eng="$objectEngSingular.toLowerCase()" ita="$objectItaSingular.toLowerCase()"/}}#{else}{{stringEngIta eng="$objectEngPlural.toLowerCase()" ita="$objectItaPlural.toLowerCase()"/}}#{end} / #if( $oneStatus ){{pubStatus uppercase='true' plural='true'}}$statusPar{{/pubStatus}}#{else}{{pubStatus uppercase='true' plural='true'}}unpublished{{/pubStatus}}#{end}#if( $oneUser ) / $userFirstName $userLastName#{end}(%%) 104 +## stop if no pubs are found 105 +#if( $pubNo == 0 || $pubMap.keySet().size() == 0 ) 106 +## redundant double check 107 + #stop 108 +#end 109 +## some pubs found 110 +## page index 111 +#if( $pubMap.keySet().size() > 1 ) 112 +## found more than one status 113 +{{id name="index"/}} 114 +(% style="font-size:smaller; text-align:right; padding:1em 1.5em 0.25em 1.5em; background-color:$theme.highlightColor" %)(((#foreach( $status in $pubMap.keySet() )#if( !$foreach.first ) | #end[[${pubStatus uppercase='false' plural='true'}}$statusPar{{/pubStatus}}>>||anchor="$status"]]#end))) 115 +#end 116 + 117 + 85 85 {{/velocity}}