Wiki-Quellcode von NavigationConfigurationSheet
Zeige letzte Bearbeiter
| author | version | line-number | content |
|---|---|---|---|
| 1 | {{velocity output="false"}} | ||
| 2 | #macro (displayView $configDoc $configObj) | ||
| 3 | #foreach ($propertyName in $configObj.propertyNames) | ||
| 4 | ; $configDoc.displayPrettyName($propertyName) | ||
| 5 | (% class="xHint" %)$services.localization.render("PanelsCode.NavigationConfigurationClass_${propertyName}.hint")(%%) | ||
| 6 | : $configDoc.display($propertyName) | ||
| 7 | #end | ||
| 8 | #end | ||
| 9 | |||
| 10 | #macro (displayEdit $configObj) | ||
| 11 | #set ($discard = $xwiki.ssx.use('PanelsCode.NavigationConfigurationSheet')) | ||
| 12 | #set ($discard = $xwiki.jsx.use('PanelsCode.NavigationConfigurationSheet')) | ||
| 13 | {{html clean="false"}} | ||
| 14 | <div class="hidden"> | ||
| 15 | <input type="hidden" name="xhidden" value="1" /> | ||
| 16 | <input type="hidden" name="objectPolicy" value="updateOrCreate" /> | ||
| 17 | #set ($wikiPreferences = $xwiki.getDocument('XWiki.XWikiPreferences')) | ||
| 18 | #set ($pinnedChildPagesObject = $wikiPreferences.getObject('XWiki.PinnedChildPagesClass')) | ||
| 19 | #set ($pinnedTopLevelPages = $wikiPreferences.getValue('pinnedChildPages', $pinnedChildPagesObject)) | ||
| 20 | #if (!$pinnedTopLevelPages) | ||
| 21 | #set ($pinnedTopLevelPages = []) | ||
| 22 | #end | ||
| 23 | <input type="hidden" name="pinnedTopLevelPages" value="$escapetool.xml($jsontool.serialize($pinnedTopLevelPages))" /> | ||
| 24 | </div> | ||
| 25 | {{/html}} | ||
| 26 | (% class="row" %)((( | ||
| 27 | (% class="col-sm-6" %)((( | ||
| 28 | #displayNavigationPanel | ||
| 29 | {{info}}{{translation key="index.tree.pinnedChildPages.topLevelHint" /}}{{/info}} | ||
| 30 | ))) | ||
| 31 | (% class="col-sm-6" %)((( | ||
| 32 | #displayExcludedPages($configObj) | ||
| 33 | ))) | ||
| 34 | ))) | ||
| 35 | #end | ||
| 36 | |||
| 37 | #macro (displayNavigationPanel) | ||
| 38 | #set ($navigationPanel = $xwiki.getDocument('Panels.Navigation')) | ||
| 39 | $navigationPanel.display('content', 'view').replace('data-dragAndDrop = "false"', 'data-dragAndDrop = "true"' | ||
| 40 | ).replace('class = "xtree"', 'class = "xtree jstree-no-links jstree-xwiki-large"') | ||
| 41 | #end | ||
| 42 | |||
| 43 | #macro (displayExcludedPages $configObj) | ||
| 44 | {{html clean="false"}} | ||
| 45 | <div class="panel panel-info"> | ||
| 46 | <div class="panel-heading"> | ||
| 47 | <div class="panel-title"> | ||
| 48 | $escapetool.xml($services.localization.render('platform.panels.navigation.configuration.excludedPages')) | ||
| 49 | </div> | ||
| 50 | </div> | ||
| 51 | <div class="panel-body"> | ||
| 52 | <p class="xHint"> | ||
| 53 | $escapetool.xml($services.localization.render('platform.panels.navigation.configuration.excludedPages.hint')) | ||
| 54 | </p> | ||
| 55 | #set ($inclusions = {}) | ||
| 56 | #foreach ($inclusion in $configObj.getValue('inclusions')) | ||
| 57 | #set ($discard = $inclusions.put($services.model.resolveDocument($inclusion), $inclusion)) | ||
| 58 | #end | ||
| 59 | #set ($defaultDocumentName = $services.model.getEntityReference('DOCUMENT', 'default').name) | ||
| 60 | #topLevelExtensionPagesFilter($configObj $inclusions) | ||
| 61 | #topLevelApplicationPagesFilter($configObj $inclusions) | ||
| 62 | <div class="exclusion-filter otherPages"> | ||
| 63 | <p class="exclusion-filter-label"> | ||
| 64 | $escapetool.xml($services.localization.render('platform.panels.navigation.configuration.otherPages')) | ||
| 65 | </p> | ||
| 66 | <ul class="exclusion-filter-pages"> | ||
| 67 | #foreach ($exclusion in $configObj.getValue('exclusions')) | ||
| 68 | #set ($documentReference = $services.model.resolveDocument($exclusion)) | ||
| 69 | #set ($excludedDoc = $xwiki.getDocument($documentReference)) | ||
| 70 | <li class="page" data-reference="$escapetool.xml($services.model.serialize($documentReference, 'default'))"> | ||
| 71 | <a href="$excludedDoc.getURL()">$escapetool.xml($excludedDoc.plainTitle)</a> | ||
| 72 | <input type="hidden" name="PanelsCode.NavigationConfigurationClass_0_exclusions" | ||
| 73 | value="$escapetool.xml($exclusion)" /> | ||
| 74 | </li>## | ||
| 75 | #end | ||
| 76 | <li class="empty"> | ||
| 77 | $escapetool.xml($services.localization.render('platform.panels.navigation.configuration.excludedPages.empty')) | ||
| 78 | <input type="hidden" name="PanelsCode.NavigationConfigurationClass_0_exclusions" value="" /> | ||
| 79 | </li> | ||
| 80 | </ul> | ||
| 81 | </div> | ||
| 82 | </div> | ||
| 83 | </div> | ||
| 84 | {{/html}} | ||
| 85 | #end | ||
| 86 | |||
| 87 | #macro (topLevelExtensionPagesFilter $configObj $inclusions) | ||
| 88 | <div class="exclusion-filter exclusion-filter-dynamic topLevelExtensionPages"> | ||
| 89 | #exclusionFilterToggle($configObj 'excludeTopLevelExtensionPages') | ||
| 90 | <ul class="exclusion-filter-pages#if (!$isFilterActive) hidden#end"> | ||
| 91 | #set ($query = $services.query.hql('select space.name from XWikiSpace space where space.parent is null')) | ||
| 92 | #set ($discard = $query.addFilter('hidden/space')) | ||
| 93 | #foreach ($result in $query.execute()) | ||
| 94 | #set ($documentReference = $services.model.createDocumentReference($NULL, $result, $defaultDocumentName)) | ||
| 95 | #set ($installedExtensions = $services.extension.xar.getInstalledExtensions($documentReference)) | ||
| 96 | #if ($installedExtensions && $installedExtensions.size() > 0 | ||
| 97 | && !$services.extension.xar.isEditAllowed($documentReference)) | ||
| 98 | #exclusionFilterPage($documentReference $inclusions) | ||
| 99 | #end | ||
| 100 | #end | ||
| 101 | #exclusionFilterEmpty | ||
| 102 | </ul> | ||
| 103 | </div> | ||
| 104 | #end | ||
| 105 | |||
| 106 | #macro (topLevelApplicationPagesFilter $configObj $inclusions) | ||
| 107 | <div class="exclusion-filter exclusion-filter-dynamic topLevelApplicationPages"> | ||
| 108 | #exclusionFilterToggle($configObj 'excludeTopLevelApplicationPages') | ||
| 109 | <ul class="exclusion-filter-pages#if (!$isFilterActive) hidden#end"> | ||
| 110 | #set ($statement = 'select space.name ' | ||
| 111 | + 'from XWikiSpace as space, Document as doc, doc.object(AppWithinMinutes.LiveTableClass) as app ' | ||
| 112 | + 'where space.parent is null and doc.space = space.reference') | ||
| 113 | #set ($query = $services.query.xwql($statement).addFilter('hidden/space')) | ||
| 114 | #foreach ($result in $query.execute()) | ||
| 115 | #set ($documentReference = $services.model.createDocumentReference($NULL, $result, $defaultDocumentName)) | ||
| 116 | ## Don't list application pages that come from installed extensions because we have another filter for this. | ||
| 117 | #set ($installedExtensions = $services.extension.xar.getInstalledExtensions($documentReference)) | ||
| 118 | #if (!$installedExtensions || $installedExtensions.isEmpty()) | ||
| 119 | #exclusionFilterPage($documentReference $inclusions) | ||
| 120 | #end | ||
| 121 | #end | ||
| 122 | #exclusionFilterEmpty | ||
| 123 | </ul> | ||
| 124 | </div> | ||
| 125 | #end | ||
| 126 | |||
| 127 | #macro (exclusionFilterToggle $configObj $filterName) | ||
| 128 | #set ($isFilterActive = $configObj.getValue($filterName) == 1) | ||
| 129 | <p class="exclusion-filter-label"> | ||
| 130 | <label title="$escapetool.xml($services.localization.render("PanelsCode.NavigationConfigurationClass_${filterName}.hint"))"> | ||
| 131 | <input type="checkbox" name="PanelsCode.NavigationConfigurationClass_0_$filterName" | ||
| 132 | value="1"#if ($isFilterActive) checked="checked"#end /> | ||
| 133 | <input type="hidden" name="PanelsCode.NavigationConfigurationClass_0_$filterName" value="0" /> | ||
| 134 | #set ($suffix = $stringtool.uncapitalize($stringtool.removeStart($filterName, 'exclude'))) | ||
| 135 | $escapetool.xml($services.localization.render("platform.panels.navigation.configuration.$suffix")) | ||
| 136 | </label> | ||
| 137 | </p> | ||
| 138 | #end | ||
| 139 | |||
| 140 | #macro (exclusionFilterPage $documentReference $inclusions) | ||
| 141 | #set ($excludedDoc = $xwiki.getDocument($documentReference)) | ||
| 142 | #set ($included = $inclusions.containsKey($documentReference)) | ||
| 143 | <li class="page#if ($included) included#end" | ||
| 144 | data-reference="$escapetool.xml($services.model.serialize($documentReference, 'default'))"> | ||
| 145 | <a href="$excludedDoc.getURL()">$escapetool.xml($excludedDoc.plainTitle)</a> | ||
| 146 | #if ($included) | ||
| 147 | <input type="hidden" name="PanelsCode.NavigationConfigurationClass_0_inclusions" | ||
| 148 | value="$escapetool.xml($inclusions.get($documentReference))" /> | ||
| 149 | #end | ||
| 150 | </li>## | ||
| 151 | #end | ||
| 152 | |||
| 153 | #macro (exclusionFilterEmpty) | ||
| 154 | <li class="empty"> | ||
| 155 | $escapetool.xml($services.localization.render('platform.panels.navigation.configuration.excludedPages.empty')) | ||
| 156 | <input type="hidden" name="PanelsCode.NavigationConfigurationClass_0_inclusions" value="" /> | ||
| 157 | </li> | ||
| 158 | #end | ||
| 159 | {{/velocity}} | ||
| 160 | |||
| 161 | {{velocity}} | ||
| 162 | #set ($configDoc = $doc) | ||
| 163 | #if ($doc.fullName == 'XWiki.XWikiPreferences') | ||
| 164 | #set ($configDoc = $xwiki.getDocument('PanelsCode.NavigationConfiguration')) | ||
| 165 | #end | ||
| 166 | #set ($configObj = $configDoc.getObject('PanelsCode.NavigationConfigurationClass', true)) | ||
| 167 | (% class="xform navigationPanelConfiguration" %)((( | ||
| 168 | #if ($xcontext.action != 'edit' && $xcontext.action != 'admin') | ||
| 169 | #displayView($configDoc $configObj) | ||
| 170 | #else | ||
| 171 | #displayEdit($configObj) | ||
| 172 | #end | ||
| 173 | ))) | ||
| 174 | {{/velocity}} |