Afficher les derniers auteurs
1 {{velocity output="false"}}
2 #set ($LONG_MAX_VALUE = $mathtool.pow(2,63))
3 #set ($licensorId = 'com.xwiki.licensing:application-licensing-licensor-api')
4 #set ($licensingConfigDoc = $xwiki.getDocument('Licenses.Code.LicensingConfig'))
5 #set ($storeBuyURL = $licensingConfigDoc.storeBuyURL)
6 #set ($storeAccessURL = $licensingConfigDoc.storeAccessURL)
7 #set ($ownerObj = $licensingConfigDoc.getObject('Licenses.Code.LicensingOwnerClass'))
8 #set ($userCount = $services.licensing.licensor.userCount)
9
10 #macro (getPaidExtensions)
11 #set ($paidExtensionsByNamespace = $services.extension.installed.getBackwardDependencies($licensorId))
12 ## CollectionsTool is deprecated since 12.1RC1.
13 #if ($collectiontool)
14 #set ($paidExtensions = $collectiontool.set)
15 #else
16 #set ($paidExtensions = $collectionstool.set)
17 #end
18 #foreach ($paidExtensionsOnNamespace in $paidExtensionsByNamespace.values())
19 #set ($discard = $paidExtensions.addAll($paidExtensionsOnNamespace))
20 #end
21 #end
22
23 #macro (getVisiblePaidExtensions)
24 #getPaidExtensions
25 ## CollectionsTool is deprecated since 12.1RC1.
26 #if ($collectiontool)
27 #set ($visiblePaidExtensions = $collectiontool.set)
28 #else
29 #set ($visiblePaidExtensions = $collectionstool.set)
30 #end
31 #foreach ($paidExtension in $paidExtensions)
32 ## Filter out the paid extensions that are dependencies of other paid extensions (because the license of a paid
33 ## extension should cover its paid dependencies).
34 #isRequiredBy($paidExtension $paidExtensions)
35 #if (!$isRequiredBy)
36 #set ($discard = $visiblePaidExtensions.add($paidExtension))
37 #end
38 #end
39 #end
40
41 #macro (isRequiredBy $installedExtension $extensions)
42 #set ($isRequiredBy = false)
43 ## CollectionsTool is deprecated since 12.1RC1.
44 #if ($collectiontool)
45 #set ($backwardDependencies = $collectiontool.queue)
46 #else
47 #set ($backwardDependencies = $collectionstool.queue)
48 #end
49 #addBackwardDependencies($installedExtension $backwardDependencies)
50 ## We can't iterate the queue while modifying it and we can't write a "while" loop in Velocity so we're forced to
51 ## rely on a range loop (limiting the number of backward dependencies that we analyze).
52 #foreach ($i in [0..1000])
53 #set ($backwardDependency = $backwardDependencies.poll())
54 #if ($backwardDependency)
55 #if ($extensions.contains($backwardDependency))
56 #set ($isRequiredBy = true)
57 #break
58 #else
59 #addBackwardDependencies($backwardDependency $backwardDependencies)
60 #end
61 #else
62 #break
63 #end
64 #end
65 #end
66
67 #macro (addBackwardDependencies $installedExtension $backwardDependencies)
68 ## CollectionsTool is deprecated since 12.1RC1.
69 #if ($collectiontool)
70 #set ($backwardDependenciesSet = $collectiontool.set)
71 #else
72 #set ($backwardDependenciesSet = $collectionstool.set)
73 #end
74 #set ($discard = $backwardDependenciesSet.addAll($backwardDependencies))
75 #set ($backwardDependenciesByNamespace = $services.extension.installed.getBackwardDependencies($installedExtension.id))
76 #foreach ($backwardDependenciesOnNamespace in $backwardDependenciesByNamespace.values())
77 #foreach ($backwardDependency in $backwardDependenciesOnNamespace)
78 #if ($backwardDependenciesSet.add($backwardDependency))
79 #set ($discard = $backwardDependencies.add($backwardDependency))
80 #end
81 #end
82 #end
83 #end
84
85 #macro (getLicensesAdminSectionURL)
86 ## We target the main wiki explicitly because licenses are managed globally.
87 #if ($xwiki.exists($services.model.createDocumentReference($xcontext.mainWikiName, 'XWiki', 'ConfigurableClass')))
88 $xwiki.getURL($services.model.createDocumentReference($xcontext.mainWikiName, 'XWiki', 'XWikiPreferences'),
89 'admin', 'editor=globaladmin&section=Licenses')##
90 #else
91 ## Fall-back in case the Administration Application is not installed.
92 $xwiki.getURL($services.model.createDocumentReference($xcontext.mainWikiName, 'Licenses', 'WebHome'))##
93 #end
94 #end
95
96 #macro (getMissingLicenseMessage $extensionName)
97 $services.localization.render('licensor.missingLicense', [$services.localization.render($extensionName), '[[',
98 ">>path:#getLicensesAdminSectionURL]]"])
99 #end
100
101 #macro (getMissingLicenseMessageHTML $extensionName)
102 $services.localization.render('licensor.missingLicense', [$services.localization.render($extensionName),
103 "<a href='#getLicensesAdminSectionURL'>", '</a>'])
104 #end
105
106 #macro (getInstanceIdFormField)
107 <dt>
108 <label for="instanceId">$services.localization.render('licensor.ownerDetails.instanceId.label')</label>
109 <span class="xHint">$services.localization.render('licensor.ownerDetails.instanceId.hint')</span>
110 </dt>
111 <dd>
112 #getInstanceIdInput(false)
113 </dd>
114 #end
115
116 #macro (getInstanceIdInput $hidden)
117 #set ($type = 'text')
118 #if ($hidden)
119 #set ($type = 'hidden')
120 #end
121 <input type="$type" name="instanceId" id="instanceId" value="${services.instance.getInstanceId()}" readonly />
122 #end
123
124 #macro (getOwnerFormFields)
125 #foreach ($prop in $ownerObj.properties)
126 <dt>
127 <label for="${prop.name}">$services.localization.render("licensor.ownerDetails.${prop.name}.label")</label>
128 #set ($hintTranslationKey = "licensor.ownerDetails.${prop.name}.hint")
129 #set ($hint = $services.localization.render($hintTranslationKey))
130 #if ($hint != $hintTranslationKey)
131 <span class="xHint">$!escapetool.xml($hint)</span>
132 #end
133 </dt>
134 #set ($inputType = 'text')
135 #if ($prop.name == 'email')
136 #set ($inputType = 'email')
137 #end
138 <dd><input type="$inputType" name="${prop.name}" id="${prop.name}" value="$!{prop.value}" /></dd>
139 #end
140 #end
141
142 #macro (displayOwnerDetailsForm)
143 {{html clean=false}}
144 <form id="ownerDetails" target="_blank" class="xform half" action="${storeBuyURL}" method="post">
145 <fieldset class="header">
146 <legend>$services.localization.render('licensor.ownerDetails.heading')</legend>
147 <p>$services.localization.render('licensor.ownerDetails.hint')</p>
148 <input type="hidden" name="form_token" value="$!escapetool.xml($services.csrf.token)" />
149 <dl>
150 #getOwnerFormFields
151 #getInstanceIdFormField
152 </dl>
153 </fieldset>
154 </form>
155 {{/html}}
156 #end
157
158 #macro (licenseButton $licenseType $cssClass $key $jsonData)
159 #set ($jsonData.licenseType = $licenseType)
160 #set ($label = $services.localization.render("licensor.${key}License.label"))
161 <button class="btn btn-$cssClass licenseButton licenseButton-$escapetool.xml($key)"
162 data-button="$escapetool.xml($jsontool.serialize($jsonData))">$label</button>
163 #end
164
165 #macro (moreActionsButton $extensionId)
166 #set ($licensingConfigDoc = $xwiki.getDocument('Licenses.Code.LicensingConfig'))
167 #set ($autoUpgradesObj = $licensingConfigDoc.getObject('Licenses.Code.AutomaticUpgradesClass'))
168 #set ($isAutoUpgrade = $autoUpgradesObj.getValue('allowlist').contains($extensionId))
169 <div class="btn-group">
170 <a class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-expanded="false"
171 title="$services.localization.render("licensor.moreActions")" role="button">
172 <span class="fa fa-ellipsis-v"></span>
173 </a>
174 <ul class="dropdown-menu dropdown-left">
175 <li class="dropdown-header">
176 <form target="_blank" class="xform half">
177 <input type="hidden" name="form_token" value="$!escapetool.xml($services.csrf.token)" />
178 <input type="hidden" name="extensionId" value="$extensionId" />
179 <input type="checkbox" name="autoUpgrade" #if ($isAutoUpgrade) checked #end />
180 <label for="autoUpgrade">
181 $services.localization.render("licensor.moreActions.autoUpgrade.allow")
182 </label>
183 </form>
184 </li>
185 </ul>
186 </div>
187 #end
188
189 #macro (getLicenseActions $license $extension $actions)
190 ## Use the JSON format in order to be parsable in JavaScript.
191 #set ($jsonData = {
192 'featureId': $extension.id.id,
193 'extensionVersion': $extension.id.version.toString(),
194 'userCount': $userCount
195 })
196 #if (!$license || $license.expirationDate == 0)
197 ## No license available.
198 #set ($discard = $actions.add("#licenseButton('PAID' 'success' 'paid' $jsonData)"))
199 #set ($discard = $actions.add("#licenseButton('TRIAL' 'primary' 'trial' $jsonData)"))
200 #elseif ($license.type == 'FREE')
201 #set ($discard = $actions.add("#licenseButton('PAID' 'success' 'paid' $jsonData)"))
202 #elseif ($license.type == 'TRIAL')
203 #set ($discard = $actions.add("#licenseButton('PAID' 'success' 'paid' $jsonData)"))
204 #set ($discard = $actions.add("#licenseButton('TRIAL' 'primary' 'extendTrial' $jsonData)"))
205 #elseif ($license.type == 'PAID')
206 #set ($discard = $actions.add("#licenseButton('PAID' 'success' 'extendPaid' $jsonData)"))
207 #end
208 #set ($discard = $actions.add("#moreActionsButton($jsonData.featureId)"))
209 #end
210
211 #macro (licenseActions $license $extension)
212 #set ($actions = [])
213 #getLicenseActions($license $extension $actions)
214 <div class="licenseActions">
215 $stringtool.join($actions, '')
216 </div>
217 #end
218 {{/velocity}}
This wiki is licensed under a Creative Commons 2.0 license
XWiki 13.10 - Documentation - Conditions