Changes for page Per Sort
From version 32.1
edited by Andrea Omicini
on 03/07/2023 00:24
on 03/07/2023 00:24
Change comment:
There is no comment for this version
To version 29.4
edited by Andrea Omicini
on 22/06/2023 16:39
on 22/06/2023 16:39
Change comment:
There is no comment for this version
Summary
-
Page properties (1 modified, 0 added, 0 removed)
Details
- Page properties
-
- Content
-
... ... @@ -1,9 +1,18 @@ 1 1 {{velocity}} 2 -{{html clean="false" wiki="true"}} 3 -#template('apice_boolean.vm') 4 -## BIBTEX / START 2 +{{html wiki="true" clean="false"}} 3 +## GET PARAMETERS / START 4 +## inline display 5 +#set( $inlinePar = $request.inline.trim().toLowerCase() ) 5 5 ## show BibTeX 6 6 #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 7 7 ## default: false 8 8 #set( $showBibtex = false ) 9 9 ## check $bibtexPar ... ... @@ -10,11 +10,9 @@ 10 10 #if( $bibtexPar != "" && $trueStringList.contains($bibtexPar.toLowerCase()) ) 11 11 #set( $showBibtex = true ) 12 12 #end 13 -## BIBTEX / END 22 +## HANDLE BIBTEX / END 14 14 ## 15 -## INLINE / START 16 -## inline display 17 -#set( $inlinePar = $request.inline.trim().toLowerCase() ) 24 +## HANDLE INLINE / START 18 18 ## default: true 19 19 #set( $showInline = true ) 20 20 ## check $inlinePar ... ... @@ -21,12 +21,13 @@ 21 21 #if( $inlinePar != "" && $falseStringList.contains($inlinePar) ) 22 22 #set( $showInline = false ) 23 23 #end 24 -## INLINE / END 25 -#template('apice_publications.vm') 26 -#template('apice_user_param.vm') 27 -## SORT / START 31 +## HANDLE INLINE / END 32 +## 33 +## HANDLE SORT / START 28 28 ## $sortList gets the list of sorts to be shown 29 29 ## $oneSort true if just one sort to be shown 36 +#template('apice_publications.vm') 37 +## default: all sorts 30 30 #set( $sortList = $publicationSorts ) 31 31 #set( $oneSort = false ) 32 32 ## ... ... @@ -43,9 +43,61 @@ 43 43 #end 44 44 #end 45 45 ## INVARIANT: $oneSort and $sortList are correctly and coherently initialised 46 -## SORT / END 54 +## HANDLE SORT / END 47 47 ## 48 -## DATA STRUCTURES / START 56 +## HANDLE WHO / START 57 +#template('apice_macros.vm') 58 +#isuserspace() 59 +#if( $isUserSpace ) 60 + #userspace() 61 +## from a personal page 62 + #set( $apiceUser = true ) 63 + #set( $oneUser = true ) 64 +#elseif( $userNamePar ) 65 +## from the URL, "user=$userNamePar" parameter 66 + #if( $userNamePar.contains('XWiki.') ) 67 + #set( $userName = "$userNamePar" ) 68 + #else 69 + #set( $userName = "XWiki.$userNamePar" ) 70 + #end 71 + #if( !$xwiki.exists( $userName ) ) 72 + #if( $services.localization.currentLocale == 'it' ) 73 +{{warning}}L'utente “$userNamePar” non esiste{{/warning}} 74 + #else 75 +{{warning}}User “$userNamePar” does not exist{{/warning}} 76 + #end 77 + #stop 78 + #end 79 + #set( $apiceUser = true ) 80 + #set( $oneUser = true) 81 + #set( $userdoc = $xwiki.getDocument($userName) ) 82 + #set( $userFirstName = $userdoc.display("first_name") ) 83 + #set( $userLastName = $userdoc.display("last_name") ) 84 +#elseif( $firstNamePar && $lastNamePar ) 85 +## from the URL, "name=Firstname&surname=Lastname" parameter 86 + #set( $apiceUser = false ) 87 + #set( $oneUser = true ) 88 + #set( $userFirstName = $firstNamePar ) 89 + #set( $userLastName = $lastNamePar ) 90 +#else 91 + #set( $apiceUser = false ) 92 + #set( $oneUser = false ) 93 + #set( $userFirstName = "" ) 94 + #set( $userLastName = "" ) 95 +#end 96 +#if( $oneUser ) 97 + #if( $apiceUser ) 98 + #set( $userString = "%$userName%" ) 99 + #else 100 + #set( $userString = "%$userFirstName $userLastName%" ) 101 + #end 102 +#else 103 + #set( $userString = "%%" ) 104 +#end 105 +## HANDLE WHO / END 106 +## 107 +### query to structures 108 +## map & counter initialisation 49 49 #set( $itemMap = {} ) 50 50 #set( $itemNo = 0 ) 51 51 ## cycle over sorts ... ... @@ -52,7 +52,7 @@ 52 52 #foreach( $sort in $sortList ) 53 53 ## set query 54 54 #set( $query = ", BaseObject as obj, StringProperty as propStatus, DateProperty as propYear, #if( $oneUser ) LargeStringProperty as propAuthor, LargeStringProperty as propEditor, #end StringProperty as propSort #if( !$hasEdit ), StringProperty as propAccess #end 55 - where obj.name = doc.fullName and obj.className = '${objectSpace}.Class' and obj.name <> '${objectPool}.Template' and propStatus.id.id = obj.id and propYear.id.id = obj.id and propSort.id.id = obj.id and propStatus.name = 'status' and propYear.name = 'year' #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 lower(propStatus.value) = 'published' and propSort.name = 'sort' and lower(propSort.value) = '$sort' #if( !$hasEdit ) and propAccess.id.id = obj.id and propAccess.name = 'access' and propAccess.value <> 'hidden' #end order by propYear.value desc" ) 115 + where obj.name = doc.fullName and obj.className = '${objectSpace}.${objectClass}' and obj.name <> '${objectPool}.${objectTemplate}' and propStatus.id.id = obj.id and propYear.id.id = obj.id and propSort.id.id = obj.id and propStatus.name = 'status' and propYear.name = 'year' #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 lower(propStatus.value) = 'published' and propSort.name = 'sort' and lower(propSort.value) = '$sort' #if( !$hasEdit ) and propAccess.id.id = obj.id and propAccess.name = 'access' and propAccess.value <> 'hidden' #end order by propYear.value desc" ) 56 56 ## execute query 57 57 #set( $itemFound = $xwiki.searchDocuments($query) ) 58 58 ## set counters ... ... @@ -62,9 +62,8 @@ 62 62 #set( $itemNo = $itemNo + $itemSortNo ) 63 63 #end 64 64 #end 65 -## DATA STRUCTURES / END 66 66 ## 67 -## DISPLAY/ START126 +### output results 68 68 ## page subtitle 69 69 <div style="display: flex"> 70 70 <div class="mainheader"> ... ... @@ -71,9 +71,9 @@ 71 71 $itemNo 72 72 #if( $oneSort ) 73 73 #if( $itemNo == 1 ) 74 - $services.localization.render("${objectSpace}.Class_sort_${sortList[0]}").toLowerCase() 133 + $services.localization.render("${objectSpace}.${objectClass}_sort_${sortList[0]}").toLowerCase() 75 75 #else 76 - $services.localization.render("${objectSpace}.Class_sort_${sortList[0]}_plural").toLowerCase() 135 + $services.localization.render("${objectSpace}.${objectClass}_sort_${sortList[0]}_plural").toLowerCase() 77 77 #end 78 78 #else 79 79 #if( $itemNo == 1 ) ... ... @@ -108,7 +108,7 @@ 108 108 #if( !$foreach.first ) 109 109  •  110 110 #end 111 - [[$services.localization.render("${objectSpace}.Class_sort_${sort}_short_plural").toLowerCase()>>||anchor="$sort"]] 170 + [[$services.localization.render("${objectSpace}.${objectClass}_sort_${sort}_short_plural").toLowerCase()>>||anchor="$sort"]] 112 112 #end 113 113 </div> 114 114 #end ... ... @@ -119,7 +119,7 @@ 119 119 ## sort top / start 120 120 <div class="mainselectseparator"> 121 121 <a class="mainselectseparatorlink" id="$sort" href=$xwiki.getURL($doc,"view","sort=$sort#if( $apiceUser )&user=$userName#elseif( $oneUser )&name=$userFirstName&surname=$userLastName#end")> 122 - $services.localization.render("${objectSpace}.Class_sort_${sort}_plural").toLowerCase() 181 + $services.localization.render("${objectSpace}.${objectClass}_sort_${sort}_plural").toLowerCase() 123 123 </a> 124 124 </div> 125 125 ## sort top / end ... ... @@ -155,10 +155,9 @@ 155 155 ## sort bottom / start 156 156 <div #if( $foreach.last )id="bottom"#end class="mainselectbottom"> 157 157 #set( $itemSortNo = $itemMap[$sort].size() ) 158 -$itemSortNo #if( $itemSortNo == 1 )$services.localization.render("${objectSpace}.Class_sort_${sort}").toLowerCase()#{else}$services.localization.render("${objectSpace}.Class_sort_${sort}_plural").toLowerCase()#end • #anchorlinks()217 +$itemSortNo #if( $itemSortNo == 1 )$services.localization.render("${objectSpace}.${objectClass}_sort_${sort}").toLowerCase()#{else}$services.localization.render("${objectSpace}.${objectClass}_sort_${sort}_plural").toLowerCase()#end • [[{{stringEngIta eng='top' ita='in cima'/}}>>||anchor="top"]] • [[{{stringEngIta eng='index' ita='indice'/}}>>||anchor="index"]] • [[{{stringEngIta eng='bottom' ita='in fondo'/}}>>||anchor="bottom"]] 159 159 </div> 160 160 ## sort bottom / end 161 161 #end 162 -## DISPLAY / END 163 163 {{/html}} 164 164 {{/velocity}}{{pageDisplay sort="objectservice"/}}