Wiki source code of Editor’s Index
Last modified by Andrea Omicini on 2020/10/12 15:49
Show last authors
author | version | line-number | content |
---|---|---|---|
1 | #includeMacros("Main.MacroSheet") | ||
2 | #includeMacros("Publications.MacroSheet") | ||
3 | |||
4 | #### get parameters | ||
5 | ## who | ||
6 | #set( $userNamePar = $context.getRequest().getParameter("user") ) | ||
7 | #set( $firstNamePar = $context.getRequest().getParameter("name") ) | ||
8 | #set( $lastNamePar = $context.getRequest().getParameter("surname") ) | ||
9 | |||
10 | #### handle who | ||
11 | #if ( $userName ) | ||
12 | ## from a personal page, "XWiki.PersonalSpace" $userName form | ||
13 | #set( $oneEditor = true ) | ||
14 | #set( $userdoc = $xwiki.getDocument($userName) ) | ||
15 | #set( $editorFirstName = $userdoc.display("first_name") ) | ||
16 | #set( $editorLastName = $userdoc.display("last_name") ) | ||
17 | #elseif ( $userNamePar ) | ||
18 | ## from the URL, "user=PersonalSpace" parameter | ||
19 | #set( $oneEditor = true) | ||
20 | #set( $userdoc = $xwiki.getDocument("XWiki.$userNamePar") ) | ||
21 | #set( $editorFirstName = $userdoc.display("first_name") ) | ||
22 | #set( $editorLastName = $userdoc.display("last_name") ) | ||
23 | #elseif ( $firstNamePar && $lastNamePar ) | ||
24 | ## from the URL, "name=Firstname&surname=Lastname" parameter | ||
25 | #set( $oneEditor = true ) | ||
26 | #set( $editorFirstName = $firstNamePar ) | ||
27 | #set( $editorLastName = $lastNamePar ) | ||
28 | #else | ||
29 | #set( $oneEditor = false ) | ||
30 | #set( $editorFirstName = "" ) | ||
31 | #set( $editorLastName = "" ) | ||
32 | #end | ||
33 | |||
34 | <a name="top"> </a> | ||
35 | |||
36 | #if($oneEditor) | ||
37 | 1 $editorFirstName $editorLastName Co-Editors Index | ||
38 | #else | ||
39 | 1 Editor's Index | ||
40 | #end | ||
41 | |||
42 | #set ($sql = ", BaseObject as obj, StringProperty as prop, StringProperty as prop1, LargeStringProperty as prop2 | ||
43 | where | ||
44 | obj.name=doc.fullName and | ||
45 | obj.className='Publications.PublicationClass' and | ||
46 | obj.name<>'Publications.PublicationClassTemplate' and | ||
47 | prop.id.id=obj.id and | ||
48 | prop1.id.id=obj.id and | ||
49 | prop2.id.id=obj.id and | ||
50 | prop1.name='status' and | ||
51 | prop1.value='Published' and | ||
52 | prop2.name='author' and | ||
53 | prop2.value='' and | ||
54 | prop.name='editor' and | ||
55 | (prop.value like '%$editorFirstName $editorLastName%' or | ||
56 | prop.value like '%$editorLastName, $editorFirstName%') | ||
57 | ") | ||
58 | |||
59 | #set($editMap = $util.getHashMap()) | ||
60 | #set($editArrayList = $util.getArrayList()) | ||
61 | #set($letterMap = $util.getHashMap()) | ||
62 | #set($editedPubs=0) | ||
63 | #foreach ($pub in $xwiki.searchDocuments($sql)) | ||
64 | #set($pubDoc=$xwiki.getDocument($pub)) | ||
65 | #set($pubObj=$pubDoc.getObject("Publications.PublicationClass")) | ||
66 | #if ( $pubObj.editor != "" ) | ||
67 | #set($editedPubs=$editedPubs+1) | ||
68 | #set($editList=$pubObj.getProperty("editor").value.split(" (and|AND) ")) | ||
69 | #foreach ($untrimmedEdit in $editList) | ||
70 | #set($edit = $untrimmedEdit.trim()) | ||
71 | #### build the editor list | ||
72 | #if (!$editArrayList.contains($edit)) | ||
73 | #set($noprintvar = $editArrayList.add($edit)) | ||
74 | #end | ||
75 | #### build the editor hash table | ||
76 | #if (!$editMap.get($edit)) | ||
77 | $!editMap.put($edit, $util.getArrayList()) | ||
78 | #end | ||
79 | #set($noprintvar = $editMap.get($edit).add($pub)) | ||
80 | #### build the per-letter hash tables | ||
81 | #set($firstLetter = $edit.substring(0,1).toUpperCase()) | ||
82 | #if (!$letterMap.get($firstLetter)) | ||
83 | $!letterMap.put($firstLetter, true) | ||
84 | #end | ||
85 | #end | ||
86 | #end | ||
87 | #end | ||
88 | |||
89 | #set($editorNo=$editArrayList.size()) | ||
90 | The following page indexes #if($oneEditor) $editorFirstName $editorLastName's #end edited publications in the #apice() space ~~by editor~~. | ||
91 | Currently, the #apice() space contains $editedPubs #if($oneEditor) $editorFirstName $editorLastName's edited #end publications by *$editorNo* #if($oneEditor)co-editors. #else editors. #end | ||
92 | |||
93 | #set($sortedEditorList=$xwiki.sort($editArrayList)) | ||
94 | |||
95 | ---- | ||
96 | <div> | ||
97 | #foreach ($firstLetter in ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]) | ||
98 | #if ($velocityCount > 1) | #end | ||
99 | #if ($letterMap.get($firstLetter)) | ||
100 | <a href="#$firstLetter">$firstLetter</a> | ||
101 | #else | ||
102 | $firstLetter | ||
103 | #end | ||
104 | #end | ||
105 | </div> | ||
106 | ---- | ||
107 | <table width="100%"> | ||
108 | #foreach ($edit in $sortedEditorList) | ||
109 | #if ($edit.contains(",")) | ||
110 | #set ($editstring = $edit.split(",")) | ||
111 | #set ($editlastname = $editstring.get(0).trim()) | ||
112 | #set ($editfirstname = $editstring.get(1).trim()) | ||
113 | #end | ||
114 | #set($firstLetter = $edit.substring(0,1).toUpperCase()) | ||
115 | #if ($letterMap.get($firstLetter)) | ||
116 | #set($noprintvar = $letterMap.put($firstLetter,false)) | ||
117 | <tr><th align="left" ><a name="$firstLetter"> $firstLetter </a></th><th align="right"><a href="#top">{pre}[{/pre}top{pre}]{/pre}</a></th></tr> | ||
118 | #end | ||
119 | #set($editPubList = $editMap.get($edit)) | ||
120 | #set($sortedEditPubList = $xwiki.sort($editPubList)) | ||
121 | <tr valign="top"><td>#if ($editlastname != "") [ <b>$editlastname</b>, $editfirstname | Publications.VolumesPerYear?surname=$editlastname&name=$editfirstname] #else $edit #end</td><td><td>#foreach ($pubedit in $sortedEditPubList) #if ($velocityCount > 1) <br/> #end [$xwiki.getDocument($pubedit).display('title')>$pubedit] #end</td></tr> | ||
122 | #end | ||
123 | </table> |