Changes for page Per Status

From version 86.1
edited by Andrea Omicini
on 03/01/2023 00:19
Change comment: There is no comment for this version
To version 93.1
edited by Andrea Omicini
on 22/06/2023 13:33
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,29 +1,73 @@
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
1 +{{velocity}}
2 +{{html wiki="true" clean="false"}}
3 +## GET PARAMETERS / START
4 +## inline display
5 +#set( $inlinePar = $request.inline.trim().toLowerCase() )
6 +## show BibTeX
7 +#set( $bibtexPar = $request.bibtex.trim().toLowerCase() )
7 7  ## who
8 8  #set( $userNamePar = $request.user.trim() )
9 9  #set( $firstNamePar = $request.name.trim() )
10 10  #set( $lastNamePar = $request.surname.trim() )
11 -## which status
12 +## GET PARAMETERS / END
13 +##
14 +#template('apice_boolean.vm')
15 +## HANDLE BIBTEX / START
16 +## default: false
17 +#set( $showBibtex = false )
18 +## check $bibtexPar
19 +#if( $bibtexPar != "" && $trueStringList.contains($bibtexPar.toLowerCase()) )
20 + #set( $showBibtex = true )
21 +#end
22 +## HANDLE BIBTEX / END
23 +##
24 +## HANDLE INLINE / START
25 +## default: true
26 +#set( $showInline = true )
27 +## check $inlinePar
28 +#if( $inlinePar != "" && $falseStringList.contains($inlinePar) )
29 + #set( $showInline = false )
30 +#end
31 +## HANDLE INLINE / END
32 +##
33 +## HANDLE STATUS / START
34 +#template('apice_publications.vm')
35 +## $oneStatus false gets a list of statuses, true just one
36 +#set( $oneStatus = false )
37 +#set( $showRejected = false )
38 +#set( $showPublished = false )
39 +## $statusList gets the list of statuses to be shown
40 +#set( $statusList = $publicationStatuses )
41 +##
12 12  #set( $statusPar = $request.status.trim() )
43 +#if( $statusPar.toLowerCase() == "all" )
44 +## 'all' value gets all unpublished papers including "Rejected" ones
45 + #set( $showRejected = true )
46 +#elseif( $statusPar.toLowerCase() == "published" )
47 + #set( $oneStatus = true )
48 + #set( $statusList = ["published"] )
49 + #set( $showPublished = true )
50 +#elseif( $statusPar.toLowerCase() == "rejected" )
51 + #set( $oneStatus = true )
52 + #set( $statusList = ["rejected"] )
53 + #set( $showRejected = true )
54 +#elseif( $publicationStatuses.contains($statusPar) )
55 +## 'status' parameter is an admissible publication status value
56 + #set( $oneStatus = true )
57 + #set( $statusList = [$statusPar] )
58 +#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
60 +## HANDLE STATUS / END
61 +## HANDLE WHO / START
62 +#template('apice_macros.vm')
63 +#isuserspace()
64 +#if( $isUserSpace )
65 + #userspace()
66 +## from a personal page
21 21   #set( $apiceUser = true )
22 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
69 +#elseif( $userNamePar )
70 +## from the URL, "user=$userNamePar" parameter
27 27   #if( $userNamePar.contains('XWiki.') )
28 28   #set( $userName = "$userNamePar" )
29 29   #else
... ... @@ -63,62 +63,133 @@
63 63  #else
64 64   #set( $userString = "%%" )
65 65  #end
110 +## HANDLE WHO / END
66 66  ##
67 -#### handle status
68 -## $oneStatus false gets a list of statuses, true just one
69 -#set( $oneStatus = false )
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) )
74 -#if( $statusPar.toLowerCase() == "all" )
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
83 -#end
84 -##
85 -## query to structures
86 -#set( $pubMap = {} )
87 -#set( $pubNo = 0 )
112 +### query to structures
113 +## map & counter initialisation
114 +#set( $itemMap = {} )
115 +#set( $itemNo = 0 )
116 +## cycle over statuses
88 88  #foreach( $status in $statusList )
89 - #set( $from = ", BaseObject as obj, LargeStringProperty as prop0, LargeStringProperty as prop1, StringProperty as prop2" )
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 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'" )
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 )
118 + #if( $status != "published" && $status != "rejected" || $status == "published" && $showPublished || $status == "rejected" && $showRejected )
119 + #set( $query = ", BaseObject as obj, #if( $oneUser ) LargeStringProperty as propAuthor, LargeStringProperty as propEditor, #end StringProperty as propStatus #if( !$hasEdit ), StringProperty as propAccess #end
120 + where obj.name = doc.fullName and obj.className = '${objectSpace}.${objectClass}' and obj.name <> '${objectPool}.${objectTemplate}' #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" )
121 + #set( $itemFound = $xwiki.searchDocuments($query) )
122 +## set counters
123 + #set( $itemStatusNo = $itemFound.size() )
124 + #if( $itemStatusNo > 0 )
125 + #set( $itemMap[$status] = $itemFound )
126 + #set( $itemNo = $itemNo + $itemStatusNo )
127 + #end
97 97   #end
98 98  #end
130 +##
99 99  ## output results
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}(%%)
133 +<div style="display: flex">
134 + <div class="mainheader">
135 +$itemNo
136 +#if( $oneStatus )
137 + #if( $itemNo == 1 )
138 + $services.localization.render('work').toLowerCase()
139 + <span class="textsecondary">&ensp;/&ensp;</span>
140 + $services.localization.render("${objectSpace}.${objectClass}_status_${statusList[0]}").toLowerCase()
141 + #else
142 + $services.localization.render('works').toLowerCase()
143 + <span class="textsecondary">&ensp;/&ensp;</span>
144 + $services.localization.render("${objectSpace}.${objectClass}_status_${statusList[0]}_plural").toLowerCase() #end
145 +#else
146 + #if( $itemNo == 1 )
147 + #if( $showPublished )
148 + $services.localization.render('work').toLowerCase()
149 + #else
150 + $services.localization.render('yetunpublished_singular').toLowerCase()
151 + #end
152 + #else
153 + #if( $showPublished )
154 + $services.localization.render('works').toLowerCase()
155 + #else
156 + $services.localization.render('yetunpublished').toLowerCase()
157 + #end
158 + #end
159 +#end
160 +#if( $oneUser )
161 + <span class="textsecondary">&ensp;/&ensp;</span>
162 + $userFirstName $userLastName
163 +#end
164 + </div>
165 + <div style="flex-grow: 1">
166 + </div>
167 + <div">
168 + <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>
169 + <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>
170 + </div>
171 +</div>
103 103  ## stop if no pubs are found
104 -#if( $pubNo == 0 || $pubMap.keySet().size() == 0 )
173 +#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 )
179 +#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)))
181 +<div class="mainselectbar" id="index">
182 + #foreach( $status in $itemMap.keySet() )
183 + #if( !$foreach.first )
184 + &ensp;&bull;&ensp;
185 + #end
186 + [[$services.localization.render("${objectSpace}.${objectClass}_status_${status}_short_plural").toLowerCase()>>||anchor="$status"]]
187 + #end
188 +</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}}
190 +##
191 +#template('apice_publication_macros.vm')
192 +##
193 +#foreach( $status in $itemMap.keySet() )
194 +## status top / start
195 +<div class="mainselectseparator">
196 + <a class="mainselectseparatorlink" id="$status" href=$xwiki.getURL($doc,"view","status=$status#if( $apiceUser )&user=$userName#elseif( $oneUser )&name=$userFirstName&surname=$userLastName#end")>
197 + $services.localization.render("${objectSpace}.${objectClass}_status_${status}_plural").toLowerCase()
198 + </a>
199 +</div>
200 +## status top / end
201 +##
202 +## status display / start
203 +<div>
204 + #if( $showInline && !$showBibtex )
205 + <ul>
206 + #foreach( $item in $itemMap[$status] )
207 + <li>#publinked($item)</li>
208 +## <li>#pubperstatus($item)</li>
209 + #end
210 + </ul>
211 + #else
212 + #foreach( $item in $itemMap[$sort] )
213 + #if( $showBibtex)
214 + #if( $showInline )
215 + ((({{{ $xwiki.getDocument($item).getValue('bibtex') }}})))
216 + #else
217 + ((({{code language="bibtex"}}$xwiki.getDocument($item).getValue('bibtex'){{/code}})))
218 + #end
219 + #else
220 + <div style="border-style:hidden hidden hidden hidden; font-size:smaller; line-height: 1.25em; margin-bottom: .5em">
221 + #pubauthed($item)<br/>
222 + #pubtitle($item)<br/>
223 + <span class="textsecondary">(#pubstatus($item))</span> {{pubVenue linked="false"}}$item{{/pubVenue}}
224 + </div>
225 + #end
226 + #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"]]
228 +</div>
229 +## status display / end
230 +##
231 +## status bottom / start
232 +<div #if( $foreach.last )id="bottom"#end class="mainselectbottom">
233 + #set( $itemStatusNo = $itemMap[$status].size() )
234 +$itemStatusNo #if( $itemStatusNo == 1 )$services.localization.render("${objectSpace}.${objectClass}_status_${status}").toLowerCase()#{else}$services.localization.render("${objectSpace}.${objectClass}_status_${status}_plural").toLowerCase()#end &bull; [[{{stringEngIta eng='top' ita='in cima'/}}>>||anchor="top"]] &bull; [[{{stringEngIta eng='index' ita='indice'/}}>>||anchor="index"]] &bull; [[{{stringEngIta eng='bottom' ita='in fondo'/}}>>||anchor="bottom"]]
235 +</div>
236 +## status bottom / end
123 123  #end
124 -{{/velocity}}
238 +{{/html}}
239 +{{/velocity}}{{pageDisplay sort="objectservice"/}}