Changes for page Per Status

From version 66.4
edited by Andrea Omicini
on 25/02/2022 11:42
Change comment: There is no comment for this version
To version 70.1
edited by Andrea Omicini
on 02/01/2023 16:28
Change comment: There is no comment for this version

Summary

Details

Page properties
Title
... ... @@ -1,1 +1,0 @@
1 -#if($xcontext.language=="it")Pubblicazioni per stato#{else}Publications per Status#end
Default language
... ... @@ -1,1 +1,0 @@
1 -en
Content
... ... @@ -1,59 +1,92 @@
1 -{{include reference="Publications.Environment" excludeFirstHeading="true"/}}{{include reference="Environment" excludeFirstHeading="true"/}}{{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
51 51  ##
52 52  {{id name="top"/}}
53 -#if( $oneAuthor )#if( $oneStatus )
54 ->**{{pubStatus uppercase='true' plural='true'}}$statusPar{{/pubStatus}}** / $authorFirstName $authorLastName
86 +#if( $oneUser )#if( $oneStatus )
87 +>**{{pubStatus uppercase='true' plural='true'}}$statusPar{{/pubStatus}}** / $userFirstName $userLastName
55 55  #else
56 ->**{{pubStatus uppercase='true' plural='true'}}unpublished{{/pubStatus}}** / $authorFirstName $authorLastName
89 +>**{{pubStatus uppercase='true' plural='true'}}unpublished{{/pubStatus}}** / $userFirstName $userLastName
57 57  #end#elseif($oneStatus)
58 58  >{{pubStatus uppercase='true' plural='true'}}$statusPar{{/pubStatus}}
59 59  #else
... ... @@ -61,12 +61,12 @@
61 61  #end
62 62  ##
63 63  #if( !$oneStatus )
64 -(% style="font-size: smaller; padding:1em 1.5em 0.25em 1.5em; background-color:$theme.highlightColor" %)(((#foreach( $status in $statusList )#if( $velocityCount > 1 ) | #end[[{{pubStatus}}$status{{/pubStatus}}>>||anchor=$status]]#end)))
97 +(% style="font-size: smaller; padding:1em 1.5em 0.25em 1.5em; background-color:$theme.highlightColor" %)(((#foreach( $status in $statusList )#if( $foreach.index > 0 ) | #end[[{{pubStatus}}$status{{/pubStatus}}>>||anchor=$status]]#end)))
65 65  #end
66 66  ##
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%' or prop0.value like '%$authorLastName, $authorFirstName%') and prop1.name = 'status' and prop1.value = '$status'" )
101 + #set( $from = ", BaseObject as obj, LargeStringProperty as prop0, LargeStringProperty as prop1, StringProperty as prop2" )
102 + #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 72   #set( $pubStatusNo = $pubFound.size() )
... ... @@ -74,11 +74,8 @@
74 74   #if( !$oneStatus )
75 75  (% style="border-style:solid hidden hidden solid; border-color:$theme.borderColor; text-align:left; font-style:oblique" %)|{{id name='$sort'/}}{{pubStatus plural='true' uppercase='true'}}$status{{/pubStatus}}{{id name="$status"/}}
76 76   #end
77 - #foreach( $pub in $pubFound )#if( $xwiki.exists($pub) )#set( $pubDoc = $xwiki.getDocument($pub) )#if( $pubDoc.getObject('Publications.PublicationClass') )## handling visibility at show time
78 -##|(% style='color:$theme.textColor; 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 -|{{pub inline=false linked=true}}$pub{{/pub}}
110 + #foreach( $pub in $pubFound )#if( $xwiki.exists($pub) )#set( $pubDoc = $xwiki.getDocument($pub) )#if( $pubDoc.getObject("${objectSpace}.${objectClass}") )## handling visibility at show time
111 +|{{pub inline='false' linked='title'}}$pub{{/pub}}
82 82   #end#end#end
83 83  (% style="#if( !$oneStatus )border-style:hidden solid solid hidden;#end border-color:$theme.borderColor; 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"]]
84 84   #end