# Changes for page Space Index

Last modified by superadmin on 2017/11/28 14:52

#### Export

#### Office Formats

Export as PDF Export as ODT Export as RTF

#### Other Formats

Export as HTML
From empty
To version 1.1
edited by superadmin
on 2017/11/28 14:52
Change comment: Install extension [org.xwiki.platform:xwiki-platform-index-ui/9.9]

## Summary

- Page properties (6 modified, 0 added, 0 removed)
- Objects (0 modified, 4 added, 0 removed)
  - XWiki.WikiMacroClass[0]
  - XWiki.WikiMacroParameterClass[0]
  - XWiki.WikiMacroParameterClass[1]
  - XWiki.WikiMacroParameterClass[2]

## Details

Page properties
  Title

    ... | ... | @@ -1,0 +1,1 @@
    | 1 | +$services.localization.render('platform.index.spaceIndex')

  Parent

    ... | ... | @@ -1,0 +1,1 @@
    | 1 | +Main.WebHome

  Author

    ... | ... | @@ -1,1 +1,1 @@
    1 |  | -XWiki.XWikiGuest
    | 1 | +xwiki:XWiki.superadmin

  Syntax

    ... | ... | @@ -1,1 +1,1 @@
    1 |  | -XWiki 2.1
    | 1 | +XWiki 2.0

  Hidden

    ... | ... | @@ -1,1 +1,1 @@
    1 |  | -false
    | 1 | +true

  Content

    ... | ... | @@ -1,0 +1,9 @@
    | 1 | +{{velocity}}
    | 2 | +#if("$!request.space" != "") #set($space=$request.space) #else #set($space = $doc.space) #end
    | 3 | +$services.localization.render('platform.index.spaceIndexDescription', [$space])
    | 4 | +## Since we display the space index, we do not display page titles and locations, but the old columns name and space
    | 5 | +## (old behavior consistent with this old macro)...
    | 6 | +
    | 7 | +{{documents space="$space.replaceAll('["~]', '~$0')" id="spaceindex" columns="doc.name, doc.space, doc.date, doc.author"/}}
    | 8 | +#set($docextras=[])
    | 9 | +{{/velocity}}

XWiki.WikiMacroClass[0]
  Macro code

    ... | ... | @@ -1,0 +1,56 @@
    | 1 | +{{velocity}}
    | 2 | + ## TODO: add a parameter to specify the style, list or livetable
    | 3 | + ## Get the number of documents to display
    | 4 | + #set ($limit = $xcontext.macro.params.get('count'))
    | 5 | + #if ("$!limit" == '')
    | 6 | + ## 100 documents displayed by default if no value is specified
    | 7 | + #set ($limit = '100')
    | 8 | + #end
    | 9 | + #set ($limit = $mathtool.toInteger($limit))
    | 10 | + ## Compute the XWQL portion related to sorting, based on the passed "sort" parameter
    | 11 | + ## Valid values are "creationDate", "modificationDate" and "docName"
    | 12 | + #set ($sort = $xcontext.macro.params.get('sort'))
    | 13 | + #if ("$sort" == 'docName')
    | 14 | + ## Sorting alphabetically
    | 15 | + #set ($sortQuery = 'doc.name asc')
    | 16 | + #elseif ("$sort" == 'modificationDate')
    | 17 | + ## Sorting by update date
    | 18 | + #set ($sortQuery = 'doc.contentUpdateDate desc')
    | 19 | + #else
    | 20 | + ## Sort by creation date by default
    | 21 | + #set ($sortQuery = 'doc.creationDate desc')
    | 22 | + #end
    | 23 | + ## Get the space to display the documents for
    | 24 | + #set ($spaceParam = $doc.space)
    | 25 | + #set ($spaceMacroParam = $xcontext.macro.params.get('space'))
    | 26 | + #if ("$!spaceMacroParam" != '')
    | 27 | + #set ($spaceParam = $spaceMacroParam)
    | 28 | + #end
    | 29 | + #set ($docNames = $services.query.hql("where doc.space=? order by $sortQuery").addFilter('currentlanguage').addFilter('hidden').setLimit($limit).bindValues([${spaceParam}]).execute())
    | 30 | + {{html}}
    | 31 | + #displayDocumentList($docNames false [])
    | 32 | + ## Note: we pass an empty blacklistedSpaces list since we are used as a space dashboard, not a global dashboard
    | 33 | + {{/html}}
    | 34 | +
    | 35 | + #if ($docNames.size() == $limit)
    | 36 | + #set ($docCount = $services.query.xwql('where doc.space = :space').bindValue('space', $spaceParam).addFilter('unique').count())
    | 37 | + #set ($remaining = $mathtool.sub($docCount, $limit))
    | 38 | + #if ($remaining > 0)
    | 39 | + (% class="documentListMore" %) (((
    | 40 | + // $services.localization.render('xe.dashboard.space.remainingDocumentsInSpace', [$remaining, $spaceParam])
    | 41 | + [[$services.localization.render('xe.dashboard.space.visitSpaceIndex')>>Main.SpaceIndex?space=${escapetool.url($spaceParam)}]] //
    | 42 | + )))
    | 43 | + #end
    | 44 | + #end
    | 45 | + ##
    | 46 | + ## Document creation.
    | 47 | + ##
    | 48 | + ## Only if the current user has edit rights.
    | 49 | + #if ($hasCreatePage)
    | 50 | + {{html}}
    | 51 | + <ul class="xlist">
    | 52 | + <li class="page create"><a href="$doc.getURL('create')">$services.localization.render('platform.index.spaceIndexDocumentListCreate')</a></li>
    | 53 | + </ul>
    | 54 | + {{/html}}
    | 55 | + #end
    | 56 | +{{/velocity}}

  Macro content type

    ... | ... | @@ -1,0 +1,1 @@
    | 1 | +No content

  Default category

    ... | ... | @@ -1,0 +1,1 @@
    | 1 | +Deprecated

  Macro description

    ... | ... | @@ -1,0 +1,1 @@
    | 1 | +Lists documents in a space.

  Macro id

    ... | ... | @@ -1,0 +1,1 @@
    | 1 | +spaceindex

  Macro name

    ... | ... | @@ -1,0 +1,1 @@
    | 1 | +Space Index

  Supports inline mode

    ... | ... | @@ -1,0 +1,1 @@
    | 1 | +No

  Macro visibility

    ... | ... | @@ -1,0 +1,1 @@
    | 1 | +Current Wiki

XWiki.WikiMacroParameterClass[0]
  Parameter default value

    ... | ... | @@ -1,0 +1,1 @@
    | 1 | +100

  Parameter description

    ... | ... | @@ -1,0 +1,1 @@
    | 1 | +The maximum number of documents to display. By default, up to 100 documents will be listed. If all documents should be displayed, pass 0.

  Parameter mandatory

    ... | ... | @@ -1,0 +1,1 @@
    | 1 | +No

  Parameter name

    ... | ... | @@ -1,0 +1,1 @@
    | 1 | +count

XWiki.WikiMacroParameterClass[1]
  Parameter description

    ... | ... | @@ -1,0 +1,1 @@
    | 1 | +The space to display the list of documents for. If missing, the current space will be used.

  Parameter mandatory

    ... | ... | @@ -1,0 +1,1 @@
    | 1 | +No

  Parameter name

    ... | ... | @@ -1,0 +1,1 @@
    | 1 | +space

XWiki.WikiMacroParameterClass[2]
  Parameter default value

    ... | ... | @@ -1,0 +1,1 @@
    | 1 | +creationDate

  Parameter description

    ... | ... | @@ -1,0 +1,5 @@
    | 1 | +Optional parameter to choose the sorting of the list of document.
    | 2 | +Value must be:
    | 3 | +- creationDate sort by creation date (default)
    | 4 | +- modificationDate sort by update date
    | 5 | +- or docName sort alphabetically

  Parameter mandatory

    ... | ... | @@ -1,0 +1,1 @@
    | 1 | +No

  Parameter name

    ... | ... | @@ -1,0 +1,1 @@
    | 1 | +sort