Changes for page Per Status
From version 69.1
edited by Andrea Omicini
on 31/12/2022 02:24
on 31/12/2022 02:24
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 (1 modified, 0 added, 0 removed)
Details
- Page properties
-
- Content
-
... ... @@ -9,7 +9,7 @@ 9 9 #set( $firstNamePar = $request.name.trim() ) 10 10 #set( $lastNamePar = $request.surname.trim() ) 11 11 ## which status 12 -#set($statusPar = $request.status.trim()) 12 +#set( $statusPar = $request.status.trim() ) 13 13 ## 14 14 #### handle who 15 15 #if( $userName ) ... ... @@ -61,7 +61,7 @@ 61 61 #set( $userString = "%$userFirstName $userLastName%" ) 62 62 #end 63 63 #else 64 - #set( $userString = "" ) 64 + #set( $userString = "%%" ) 65 65 #end 66 66 ## 67 67 #### handle status ... ... @@ -68,48 +68,51 @@ 68 68 ## $oneStatus false gets a list of statuses, true just one 69 69 #set( $oneStatus = false ) 70 70 ## $statusList gets the list of statuses to be shown 71 +#set( $statusList = [] ) 71 71 ## default: all unpublished papers except Rejected ones 72 -#set( $ statusList= $statusRangeUnpublished )73 +#set( $discard = $statusList.addAll($unpublishedStatuses) ) 73 73 #if( $statusPar.toLowerCase() == "all" ) 74 74 ## 'all' value gets all unpublished papers including "Rejected" ones 75 - #set($ statusList= $statusRangeUnpublishedFull)76 + #set( $discard = $statusList.add("rejected") ) 76 76 #else 77 - #if( $ statusRangeFull.contains($statusPar) )78 + #if( $allStatusesPlus.contains($statusPar) ) 78 78 ## 'status' parameter is an admissible publication status value 79 - #set($oneStatus = true) 80 - #set($statusList = [$statusPar]) 80 + #set( $oneStatus = true ) 81 + #set( $statusList = [$statusPar] ) 81 81 #end 82 82 #end 84 +$statusList 83 83 ## 84 -{{id name="top"/}} 85 -#if( $oneUser )#if( $oneStatus ) 86 ->**{{pubStatus uppercase='true' plural='true'}}$statusPar{{/pubStatus}}** / $userFirstName $userLastName 87 -#else 88 ->**{{pubStatus uppercase='true' plural='true'}}unpublished{{/pubStatus}}** / $userFirstName $userLastName 89 -#end#elseif($oneStatus) 90 ->{{pubStatus uppercase='true' plural='true'}}$statusPar{{/pubStatus}} 91 -#else 92 ->{{pubStatus uppercase='true' plural='true'}}unpublished{{/pubStatus}} 93 -#end 94 -## 95 -#if( !$oneStatus ) 96 -(% 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))) 97 -#end 98 -## 86 +## query to structures 87 +#set( $pubMap = {} ) 88 +#set( $pubNo = 0 ) 99 99 #foreach( $status in $statusList ) 100 100 #set( $from = ", BaseObject as obj, LargeStringProperty as prop0, LargeStringProperty as prop1, StringProperty as prop2" ) 101 101 #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'" ) 102 102 #set( $sql = $from + " where " + $where ) 103 103 #set( $pubFound = $xwiki.searchDocuments($sql) ) 104 - #set($pubStatusNo = $pubFound.size())94 +$pubFound.size() 105 105 #if( $pubStatusNo > 0 ) 106 - #if( !$oneStatus ) 107 -(% 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"/}} 108 - #end 109 - #foreach( $pub in $pubFound )#if( $xwiki.exists($pub) )#set( $pubDoc = $xwiki.getDocument($pub) )#if( $pubDoc.getObject("${objectSpace}.${objectClass}") )## handling visibility at show time 110 -|{{pub inline='false' linked='title'}}$pub{{/pub}} 111 - #end#end#end 112 -(% 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"]] 96 + #set( $pubMap[$status] = $pubFound ) 97 + #set( $pubNo = $pubNo + $pubStatusNo ) 113 113 #end 114 114 #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 + 115 115 {{/velocity}}