Changes for page Per Status

From version 90.1
edited by Andrea Omicini
on 22/06/2023 13:01
Change comment: There is no comment for this version
To version 99.1
edited by Andrea Omicini
on 03/07/2023 00:26
Change comment: There is no comment for this version

Summary

Details

Page properties
Content
... ... @@ -1,18 +1,9 @@
1 1  {{velocity}}
2 -{{html wiki="true" clean="false"}}
3 -## GET PARAMETERS / START
4 -## inline display
5 -#set( $inlinePar = $request.inline.trim().toLowerCase() )
2 +{{html clean="false" wiki="true"}}
3 +#template('apice_boolean.vm')
4 +## BIBTEX / START
6 6  ## show BibTeX
7 7  #set( $bibtexPar = $request.bibtex.trim().toLowerCase() )
8 -## who
9 -#set( $userNamePar = $request.user.trim() )
10 -#set( $firstNamePar = $request.name.trim() )
11 -#set( $lastNamePar = $request.surname.trim() )
12 -## GET PARAMETERS / END
13 -##
14 -#template('apice_boolean.vm')
15 -## HANDLE BIBTEX / START
16 16  ## default: false
17 17  #set( $showBibtex = false )
18 18  ## check $bibtexPar
... ... @@ -19,9 +19,11 @@
19 19  #if( $bibtexPar != "" && $trueStringList.contains($bibtexPar.toLowerCase()) )
20 20   #set( $showBibtex = true )
21 21  #end
22 -## HANDLE BIBTEX / END
13 +## BIBTEX / END
23 23  ##
24 -## HANDLE INLINE / START
15 +## INLINE / START
16 +## inline display
17 +#set( $inlinePar = $request.inline.trim().toLowerCase() )
25 25  ## default: true
26 26  #set( $showInline = true )
27 27  ## check $inlinePar
... ... @@ -28,13 +28,15 @@
28 28  #if( $inlinePar != "" && $falseStringList.contains($inlinePar) )
29 29   #set( $showInline = false )
30 30  #end
31 -## HANDLE INLINE / END
32 -##
33 -## HANDLE STATUS / START
24 +## INLINE / END
34 34  #template('apice_publications.vm')
26 +#template('apice_user_param.vm')
27 +##
28 +## STATUS / START
35 35  ## $oneStatus false gets a list of statuses, true just one
36 36  #set( $oneStatus = false )
37 37  #set( $showRejected = false )
32 +#set( $showPublished = false )
38 38  ## $statusList gets the list of statuses to be shown
39 39  #set( $statusList = $publicationStatuses )
40 40  ##
... ... @@ -42,85 +42,42 @@
42 42  #if( $statusPar.toLowerCase() == "all" )
43 43  ## 'all' value gets all unpublished papers including "Rejected" ones
44 44   #set( $showRejected = true )
45 -#else
46 - #if( $publicationStatuses.contains($statusPar) )
47 - ## 'status' parameter is an admissible publication status value
48 - #set( $oneStatus = true )
49 - #set( $statusList = [$statusPar] )
50 - #end
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] )
51 51  #end
52 52  ##
53 -## HANDLE STATUS / END
54 -## HANDLE WHO / START
55 -#template('apice_macros.vm')
56 -#isuserspace()
57 -#if( $isUserSpace )
58 - #userspace()
59 -## from a personal page
60 - #set( $apiceUser = true )
61 - #set( $oneUser = true )
62 -#elseif( $userNamePar )
63 -## from the URL, "user=$userNamePar" parameter
64 - #if( $userNamePar.contains('XWiki.') )
65 - #set( $userName = "$userNamePar" )
66 - #else
67 - #set( $userName = "XWiki.$userNamePar" )
68 - #end
69 - #if( !$xwiki.exists( $userName ) )
70 - #if( $services.localization.currentLocale == 'it' )
71 -{{warning}}L'utente “$userNamePar” non esiste{{/warning}}
72 - #else
73 -{{warning}}User “$userNamePar” does not exist{{/warning}}
74 - #end
75 - #stop
76 - #end
77 - #set( $apiceUser = true )
78 - #set( $oneUser = true)
79 - #set( $userdoc = $xwiki.getDocument($userName) )
80 - #set( $userFirstName = $userdoc.display("first_name") )
81 - #set( $userLastName = $userdoc.display("last_name") )
82 -#elseif( $firstNamePar && $lastNamePar )
83 -## from the URL, "name=Firstname&surname=Lastname" parameter
84 - #set( $apiceUser = false )
85 - #set( $oneUser = true )
86 - #set( $userFirstName = $firstNamePar )
87 - #set( $userLastName = $lastNamePar )
88 -#else
89 - #set( $apiceUser = false )
90 - #set( $oneUser = false )
91 - #set( $userFirstName = "" )
92 - #set( $userLastName = "" )
93 -#end
94 -#if( $oneUser )
95 - #if( $apiceUser )
96 - #set( $userString = "%$userName%" )
97 - #else
98 - #set( $userString = "%$userFirstName $userLastName%" )
99 - #end
100 -#else
101 - #set( $userString = "%%" )
102 -#end
103 -## HANDLE WHO / END
54 +## STATUS / END
104 104  ##
105 -### query to structures
106 -## map & counter initialisation
56 +## DATA STRUCTURES / START
107 107  #set( $itemMap = {} )
108 108  #set( $itemNo = 0 )
109 109  ## cycle over statuses
110 110  #foreach( $status in $statusList )
111 - #set( $query = ", BaseObject as obj, #if( $oneUser ) LargeStringProperty as propAuthor, LargeStringProperty as propEditor, #end StringProperty as propStatus #if( !$hasEdit ), StringProperty as propAccess #end
112 - 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" )
113 - #set( $itemFound = $xwiki.searchDocuments($query) )
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 = '${objectSpace}.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) )
114 114  ## set counters
115 - #set( $itemStatusNo = $itemFound.size() )
116 - #if( $itemStatusNo > 0 )
117 - #set( $itemMap[$status] = $itemFound )
118 - #set( $itemNo = $itemNo + $itemStatusNo )
66 + #set( $itemStatusNo = $itemFound.size() )
67 + #if( $itemStatusNo > 0 )
68 + #set( $itemMap[$status] = $itemFound )
69 + #set( $itemNo = $itemNo + $itemStatusNo )
70 + #end
119 119   #end
120 120  #end
121 -$itemStatusNo
73 +## DATA STRUCTURES / END
122 122  ##
123 -## output results
75 +## DISPLAY / START
124 124  ## page subtitle
125 125  <div style="display: flex">
126 126   <div class="mainheader">
... ... @@ -127,14 +127,26 @@
127 127  $itemNo
128 128  #if( $oneStatus )
129 129   #if( $itemNo == 1 )
130 - $services.localization.render("${objectSpace}.${objectClass}_status_${statusList[0]}").toLowerCase()
82 + $services.localization.render('work').toLowerCase()
83 + <span class="textsecondary">&ensp;/&ensp;</span>
84 + $services.localization.render("${objectSpace}.Class_status_${statusList[0]}").toLowerCase()
131 131   #else
132 -$services.localization.render("${objectSpace}.${objectClass}_status_${statusList[0]}_plural").toLowerCase() #end
86 + $services.localization.render('works').toLowerCase()
87 + <span class="textsecondary">&ensp;/&ensp;</span>
88 + $services.localization.render("${objectSpace}.Class_status_${statusList[0]}_plural").toLowerCase() #end
133 133  #else
134 134   #if( $itemNo == 1 )
135 - $services.localization.render('yetunpublished_singular').toLowerCase()
91 + #if( $showPublished )
92 + $services.localization.render('work').toLowerCase()
93 + #else
94 + $services.localization.render('yetunpublished_singular').toLowerCase()
95 + #end
136 136   #else
137 - $services.localization.render('yetunpublished').toLowerCase()
97 + #if( $showPublished )
98 + $services.localization.render('works').toLowerCase()
99 + #else
100 + $services.localization.render('yetunpublished').toLowerCase()
101 + #end
138 138   #end
139 139  #end
140 140  #if( $oneUser )
... ... @@ -144,9 +144,11 @@
144 144   </div>
145 145   <div style="flex-grow: 1">
146 146   </div>
147 - <div">
111 + <div>
148 148   <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 )
149 149   <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
150 150   </div>
151 151  </div>
152 152  ## stop if no pubs are found
... ... @@ -163,7 +163,7 @@
163 163   #if( !$foreach.first )
164 164   &ensp;&bull;&ensp;
165 165   #end
166 - [[$services.localization.render("${objectSpace}.${objectClass}_status_${status}_short_plural").toLowerCase()>>||anchor="$status"]]
132 + [[$services.localization.render("${objectSpace}.Class_status_${status}_short_plural").toLowerCase()>>||anchor="$status"]]
167 167   #end
168 168  </div>
169 169  #end
... ... @@ -174,7 +174,7 @@
174 174  ## status top / start
175 175  <div class="mainselectseparator">
176 176   <a class="mainselectseparatorlink" id="$status" href=$xwiki.getURL($doc,"view","status=$status#if( $apiceUser )&user=$userName#elseif( $oneUser )&name=$userFirstName&surname=$userLastName#end")>
177 - $services.localization.render("${objectSpace}.${objectClass}_status_${status}_plural").toLowerCase()
143 + $services.localization.render("${objectSpace}.Class_status_${status}_plural").toLowerCase()
178 178   </a>
179 179  </div>
180 180  ## status top / end
... ... @@ -184,12 +184,11 @@
184 184   #if( $showInline && !$showBibtex )
185 185   <ul>
186 186   #foreach( $item in $itemMap[$status] )
187 - <li>#publinked($item)</li>
188 -## <li>#pubperstatus($item)</li>
153 + <li>#pubperstatus($item)</li>
189 189   #end
190 190   </ul>
191 191   #else
192 - #foreach( $item in $itemMap[$sort] )
157 + #foreach( $item in $itemMap[$status] )
193 193   #if( $showBibtex)
194 194   #if( $showInline )
195 195   ((({{{ $xwiki.getDocument($item).getValue('bibtex') }}})))
... ... @@ -200,7 +200,7 @@
200 200   <div style="border-style:hidden hidden hidden hidden; font-size:smaller; line-height: 1.25em; margin-bottom: .5em">
201 201   #pubauthed($item)<br/>
202 202   #pubtitle($item)<br/>
203 - <span class="textsecondary">(#pubstatus($item))</span> {{pubVenue linked="false"}}$item{{/pubVenue}}
168 + <span class="textsecondary">(#pubsort($item))</span> {{pubVenue linked="false"}}$item{{/pubVenue}}
204 204   </div>
205 205   #end
206 206   #end
... ... @@ -211,9 +211,10 @@
211 211  ## status bottom / start
212 212  <div #if( $foreach.last )id="bottom"#end class="mainselectbottom">
213 213   #set( $itemStatusNo = $itemMap[$status].size() )
214 -$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"]]
179 +$itemStatusNo #if( $itemStatusNo == 1 )$services.localization.render("${objectSpace}.Class_status_${status}").toLowerCase()#{else}$services.localization.render("${objectSpace}.Class_status_${status}_plural").toLowerCase()#end &bull; #anchorlinks()
215 215  </div>
216 216  ## status bottom / end
217 217  #end
183 +## DISPLAY / END
218 218  {{/html}}
219 219  {{/velocity}}{{pageDisplay sort="objectservice"/}}