Changes for page Per Status

From version 86.5
edited by Andrea Omicini
on 18/03/2023 09:41
Change comment: There is no comment for this version
To version 101.2
edited by Andrea Omicini
on 11/07/2023 17:07
Change comment: There is no comment for this version

Summary

Details

Page properties
Title
... ... @@ -1,0 +1,1 @@
1 +$services.localization.render('perstatus')
Content
... ... @@ -1,124 +1,185 @@
1 -= {{italiano}}Per stato{{/italiano}}{{english}}Per Status{{/english}} =
2 -
3 -{{include reference="Publications.Environment" excludeFirstHeading="true"/}}{{velocity}}
4 -## a Publications page
5 -#set( $publicationMenu = true )
6 -#### get parameters
7 -## who
8 -#set( $userNamePar = $request.user.trim() )
9 -#set( $firstNamePar = $request.name.trim() )
10 -#set( $lastNamePar = $request.surname.trim() )
11 -## which status
12 -#set( $statusPar = $request.status.trim() )
1 +{{velocity}}
2 +{{html clean="false" wiki="true"}}
3 +#template('apice_macros.vm')
4 +#setobjectspace("Publications")
5 +## BIBTEX / START
6 +## show BibTeX
7 +#set( $bibtexPar = $request.bibtex.trim().toLowerCase() )
8 +## default: false
9 +#set( $showBibtex = false )
10 +## check $bibtexPar
11 +#if( $bibtexPar != "" && $trueStringList.contains($bibtexPar.toLowerCase()) )
12 + #set( $showBibtex = true )
13 +#end
14 +## BIBTEX / END
13 13  ##
14 -#### handle who
15 -#if( $userName )
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 )
23 - #set( $userdoc = $xwiki.getDocument($userName) )
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") )
45 -#elseif( $firstNamePar && $lastNamePar )
46 -## from the URL, "name=Firstname&surname=Lastname" parameter
47 - #set( $apiceUser = false )
48 - #set( $oneUser = true )
49 - #set( $userFirstName = $firstNamePar )
50 - #set( $userLastName = $lastNamePar )
51 -#else
52 - #set( $apiceUser = false )
53 - #set( $oneUser = false )
54 - #set( $userFirstName = "" )
55 - #set( $userLastName = "" )
16 +## INLINE / START
17 +## inline display
18 +#set( $inlinePar = $request.inline.trim().toLowerCase() )
19 +## default: true
20 +#set( $showInline = true )
21 +## check $inlinePar
22 +#if( $inlinePar != "" && $falseStringList.contains($inlinePar) )
23 + #set( $showInline = false )
56 56  #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
25 +## INLINE / END
26 +#template('apice_user_param.vm')
66 66  ##
67 -#### handle status
28 +## STATUS / START
68 68  ## $oneStatus false gets a list of statuses, true just one
69 69  #set( $oneStatus = false )
31 +#set( $showRejected = false )
32 +#set( $showPublished = false )
70 70  ## $statusList gets the list of statuses to be shown
71 -#set( $statusList = [] )
72 -## default: all unpublished papers except Rejected ones
73 -#set( $discard = $statusList.addAll($unpublishedStatuses) )
34 +#set( $statusList = $publicationStatuses )
35 +##
36 +#set( $statusPar = $request.status.trim() )
74 74  #if( $statusPar.toLowerCase() == "all" )
75 75  ## 'all' value gets all unpublished papers including "Rejected" ones
76 - #set( $discard = $statusList.add("rejected") )
77 -#else
78 - #if( $allStatusesPlus.contains($statusPar) )
79 - ## 'status' parameter is an admissible publication status value
80 - #set( $oneStatus = true )
81 - #set( $statusList = [$statusPar] )
82 - #end
39 + #set( $showRejected = true )
40 +#elseif( $statusPar.toLowerCase() == "published" )
41 + #set( $oneStatus = true )
42 + #set( $statusList = ["published"] )
43 + #set( $showPublished = true )
44 +#elseif( $statusPar.toLowerCase() == "rejected" )
45 + #set( $oneStatus = true )
46 + #set( $statusList = ["rejected"] )
47 + #set( $showRejected = true )
48 +#elseif( $publicationStatuses.contains($statusPar) )
49 +## 'status' parameter is an admissible publication status value
50 + #set( $oneStatus = true )
51 + #set( $statusList = [$statusPar] )
83 83  #end
84 84  ##
85 -## query to structures
86 -#set( $pubMap = {} )
87 -#set( $pubNo = 0 )
54 +## STATUS / END
55 +##
56 +## DATA STRUCTURES / START
57 +#set( $itemMap = {} )
58 +#set( $itemNo = 0 )
59 +## cycle over statuses
88 88  #foreach( $status in $statusList )
89 - #set( $from = ", BaseObject as obj, LargeStringProperty as prop0, LargeStringProperty as prop1, StringProperty as prop2, StringProperty as prop3" )
90 - #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 prop3.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' and prop3.name = 'access'#if( !$hasEdit ) and prop3.value <> 'hidden'#end" )
91 - #set( $sql = $from + " where " + $where )
92 - #set( $pubFound = $xwiki.searchDocuments($sql) )
93 - #set( $pubStatusNo = $pubFound.size() )
94 - #if( $pubStatusNo > 0 )
95 - #set( $pubMap[$status] = $pubFound )
96 - #set( $pubNo = $pubNo + $pubStatusNo )
61 + #if( $status != "published" && $status != "rejected" || $status == "published" && $showPublished || $status == "rejected" && $showRejected )
62 + #set( $query = ", BaseObject as obj, #if( $oneUser ) LargeStringProperty as propAuthor, LargeStringProperty as propEditor, #end StringProperty as propStatus #if( !$hasEdit ), StringProperty as propAccess #end
63 + where obj.name = doc.fullName and obj.className = '${mainSpace}.Class' and obj.name <> '${objectPool}.Template' #if( $oneUser ) and propAuthor.id.id = obj.id and propEditor.id.id = obj.id and propAuthor.name = 'author' and propEditor.name = 'editor' and ( propAuthor.value like '$userString' or ( propAuthor.value = '' and propEditor.value like '$userString' ) ) #end and propStatus.id.id = obj.id and propStatus.name = 'status' and propStatus.value = '$status' #if( !$hasEdit ) and propAccess.id.id = obj.id and propAccess.name = 'access' and propAccess.value <> 'hidden' #end" )
64 + #set( $itemFound = $xwiki.searchDocuments($query) )
65 +## set counters
66 + #set( $itemStatusNo = $itemFound.size() )
67 + #if( $itemStatusNo > 0 )
68 + #set( $itemMap[$status] = $itemFound )
69 + #set( $itemNo = $itemNo + $itemStatusNo )
70 + #end
97 97   #end
98 98  #end
99 -## output results
73 +## DATA STRUCTURES / END
74 +##
75 +## DISPLAY / START
100 100  ## page subtitle
101 -{{id name="top"/}}
102 ->(%%)$pubNo #if( $pubNo == 1 ){{stringEngIta eng="$objectEngSingular.toLowerCase()" ita="$objectItaSingular.toLowerCase()"/}}#{else}{{stringEngIta eng="$objectEngPlural.toLowerCase()" ita="$objectItaPlural.toLowerCase()"/}}#{end} / #if( $oneStatus ){{pubStatus uppercase='false' plural='true'}}$statusPar{{/pubStatus}}#{else}{{pubStatus uppercase='false' plural='true'}}unpublished{{/pubStatus}}#{end}#if( $oneUser ) / $userFirstName $userLastName#{end}(%%)
77 +<div style="display: flex">
78 + <div class="mainheader">
79 +$itemNo
80 +#if( $oneStatus )
81 + #if( $itemNo == 1 )
82 + $services.localization.render('work').toLowerCase()
83 + <span class="textsecondary">&ensp;/&ensp;</span>
84 + $services.localization.render("${mainSpace}.Class_status_${statusList[0]}").toLowerCase()
85 + #else
86 + $services.localization.render('works').toLowerCase()
87 + <span class="textsecondary">&ensp;/&ensp;</span>
88 + $services.localization.render("${mainSpace}.Class_status_${statusList[0]}_plural").toLowerCase() #end
89 +#else
90 + #if( $itemNo == 1 )
91 + #if( $showPublished )
92 + $services.localization.render('work').toLowerCase()
93 + #else
94 + $services.localization.render('yetunpublished_singular').toLowerCase()
95 + #end
96 + #else
97 + #if( $showPublished )
98 + $services.localization.render('works').toLowerCase()
99 + #else
100 + $services.localization.render('yetunpublished').toLowerCase()
101 + #end
102 + #end
103 +#end
104 +#if( $oneUser )
105 + <span class="textsecondary">&ensp;/&ensp;</span>
106 + $userFirstName $userLastName
107 +#end
108 + </div>
109 + <div style="flex-grow: 1">
110 + </div>
111 + <div>
112 + <a class="basebutton" style="padding: .5em" href='$doc.getURL("view","bibtex=$showBibtex&inline=#if( $showInline )false#{else}true#end#if( $oneStatus )&status=${statusList[0]}#end#if( $apiceUser )&user=$userName#elseif( $oneUser )&name=$userFirstName&surname=$userLastName#end")'>#if( $showBibtex )#if( $showInline )formatted#{else}plain#end#else#if( $showInline )long#{else}short#end#end</a>
113 +#if( $showPublished )
114 + <a class="basebutton" style="padding: .5em" href='$doc.getURL("view","inline=$showInline&bibtex=#if( $showBibtex )false#{else}true#end#if( $oneStatus )&status=${statusList[0]}#end#if( $apiceUser )&user=$userName#elseif( $oneUser )&name=$userFirstName&surname=$userLastName#end")'>#if( $showBibtex )text#{else}bib#end</a>
115 +#end
116 + </div>
117 +</div>
103 103  ## stop if no pubs are found
104 -#if( $pubNo == 0 || $pubMap.keySet().size() == 0 )
119 +#if( $itemNo == 0 || $itemMap.keySet().size() == 0 )
105 105  ## redundant double check
106 106   #stop
107 107  #end
108 108  ## some pubs found
109 109  ## page index
110 -#if( $pubMap.keySet().size() > 1 )
125 +#if( $itemMap.keySet().size() > 1 )
111 111  ## found more than one status
112 -{{id name="index"/}}
113 -(% 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'}}$status{{/pubStatus}}>>||anchor="$status"]]#end)))
127 +<div class="mainselectbar" id="index">
128 + #foreach( $status in $itemMap.keySet() )
129 + #if( !$foreach.first )
130 + &ensp;&bull;&ensp;
131 + #end
132 + [[$services.localization.render("${mainSpace}.Class_status_${status}_short_plural").toLowerCase()>>||anchor="$status"]]
133 + #end
134 +</div>
114 114  #end
115 -## pubs displayed per year
116 -#foreach( $status in $pubMap.keySet() )
117 -(% style="border-style:solid hidden hidden solid; border-color:$theme.borderColor; text-align:left; font-style:oblique" %)|{{id name='$status'/}}[[{{pubStatus uppercase='false' plural='true'}}$status{{/pubStatus}}>>$doc.name||queryString='status=$status#if( $oneUser )#if( $apiceUser )&user=$userName#{else}&name=$userFirstName&surname=$userLastName#end#end']]
118 - #foreach( $pub in $pubMap[$status] )
119 -(% style="border-style:hidden hidden hidden hidden" %)|{{pub inline='false' linked='title'}}$pub{{/pub}}
136 +##
137 +#template('apice_publication_macros.vm')
138 +##
139 +#foreach( $status in $itemMap.keySet() )
140 +## status top / start
141 +<div class="mainselectseparator">
142 + <a class="mainselectseparatorlink" id="$status" href=$xwiki.getURL($doc,"view","status=$status&bibtex=$showBibtex&inline=$showInline#if( $apiceUser )&user=$userName#elseif( $oneUser )&name=$userFirstName&surname=$userLastName#end")>
143 + $services.localization.render("${mainSpace}.Class_status_${status}_plural").toLowerCase()
144 + </a>
145 +</div>
146 +## status top / end
147 +##
148 +## status display / start
149 +<div>
150 + #if( $showInline && !$showBibtex )
151 + <ul>
152 + #foreach( $item in $itemMap[$status] )
153 + <li>#pubperstatus($item)</li>
154 + #end
155 + </ul>
156 + #else
157 + #foreach( $item in $itemMap[$status] )
158 + #if( $showBibtex)
159 + #if( $showInline )
160 + ((({{{ $xwiki.getDocument($item).getValue('bibtex') }}})))
161 + #else
162 + ((({{code language="bibtex"}}$xwiki.getDocument($item).getValue('bibtex'){{/code}})))
163 + #end
164 + #else
165 + <div style="border-style: hidden hidden hidden hidden; font-size: smaller; line-height: 1.25em; margin: .75em 0 .75em 0">
166 + <div style="margin: 0 0 0 0">#pubauthed($item)</div>
167 + <div style="margin: 0 0 0 0">#pubtitle($item)</div>
168 + <div style="margin: 0 0 0 0"><span class="textsecondary">(#pubsort($item))</span> {{pubVenue linked="false"}}$item{{/pubVenue}}</div>
169 + </div>
170 + #end
171 + #end
120 120   #end
121 - #set( $pubStatusNo = $pubMap[$status].size() )
122 -(% style="border-style:hidden solid solid hidden; border-color:$theme.borderColor; text-align:right; font-style:oblique; font-size:smaller" %)|($pubStatusNo #if( $pubStatusNo == 1 ){{stringEngIta eng='publication' ita='pubblicazione'/}} {{pubStatus uppercase='false' plural='false'}}$status{{/pubStatus}}#{else}{{stringEngIta eng='publications' ita='pubblicazioni'/}} {{pubStatus uppercase='false' plural='true'}}$status{{/pubStatus}}#end) [[[{{stringEngIta eng='top' ita='in cima'/}}]>>||anchor="top"]] [[[{{stringEngIta eng='bottom' ita='in fondo'/}}]>>||anchor="bottom"]]
173 +</div>
174 +## status display / end
175 +##
176 +## status bottom / start
177 +<div #if( $foreach.last )id="bottom"#end class="mainselectbottom">
178 + #set( $itemStatusNo = $itemMap[$status].size() )
179 +$itemStatusNo #if( $itemStatusNo == 1 )$services.localization.render("${mainSpace}.Class_status_${status}").toLowerCase()#{else}$services.localization.render("${mainSpace}.Class_status_${status}_plural").toLowerCase()#end &bull; #anchorlinks()
180 +</div>
181 +## status bottom / end
123 123  #end
124 -{{/velocity}}
183 +## DISPLAY / END
184 +{{/html}}
185 +{{/velocity}}{{pageDisplay sort="objectservice"/}}