Código fuente wiki de homeopathsSheet

Versión 3.281 por Jip-jan Alunkel el marzo 16, 13:35

Mostrar los últimos autores
1 {{include reference="assets.pagemaker.macros"/}}
2
3 {{velocity}}
4 #set($discard = $services.localization.use('document', 'assets.global.translations'))
5 #set($discard = $services.localization.use('document', 'assets.pagemaker.translations'))
6 #set($discard = $xwiki.ssx.use('assets.pagemaker.WebHome', {'minify': false}))
7 #set($discard = $xwiki.jsx.use('assets.pagemaker.WebHome', {'minify': false, 'language': $context.language, 'myParameter': 'value'}))
8 ## Set the variable for the current subject which then can be used for translation keys, CSS classses and XClass determination.
9 ## The $subject is equal to the leading space of the current page that uses this sheet.
10 #set($subject = $doc.getFullName().split('\.')[0])
11 ## Find the correct class name. This is if the class name starts with the name of the top parent space (referenced here by $subject).
12 ## Specify a class name below to override this.
13 #set($theClass = "")
14 #set($docObjects = $doc.getxWikiObjects())
15 #foreach($docObjectKey in $docObjects.keySet())
16 #if($docObjectKey.indexOf($subject) == 0)
17 #if($theClass == "")
18 #set($theClass = $docObjectKey)
19 #end
20 #end
21 #end
22 #set($theDocObj = $doc.getObject($theClass, true))
23 #set($hasRight = !$isGuest && ($theDocObj.getProperty('doc_owner').value == $context.getUser() || $hasAdmin))
24 ## ADDRESS: Prepare object to provide hidden values to the address input. The keys are equal to the class property names.
25 ## The entries will be filled by the class property values.
26 #set($xa = {'pmLatlong': '','pmCountry': '','pmState': '','pmCounty': '','pmPostcode': '','pmCity': '','pmStreet': '','pmHousenumber': ''})
27 #foreach($item in $xa.keySet())
28 #if($theDocObj.getProperty("$item").value)
29 #set($xa["$item"] = $theDocObj.getProperty("$item").value)
30 #end
31 #end
32 ## The classProperties Map has to be in the order of how you want the form elements to appear in the form.
33 ## 'opener': 1 --> Input functions as an interface control element, it 'opens' an additional block of form inputs. Only for select, input or radio inputs.
34 ## 'classless': 1 --> Input is not bound to any XClass or XClass property.
35 ## 'disabled': 1 --> Will not show up in the form at all.
36 ## 'extraAttributes': {"disabled": "disabled"} --> Will show up in the form as a disabled input.
37 #set($classProperties = {
38 'editAddress': {'type': 'checkbox', 'opener': 1, 'classless': 1, 'extraAttributes': {"data-checked": "false"}},
39 'pmAddress': {'type': 'address', 'parent': 'editAddress', "help-block": 1, 'extraAttributes': {"pmLatlong": "$xa['pmLatlong']", "pmCountry": "$xa['pmCountry']", "pmState": "$xa['pmState']", "pmCounty": "$xa['pmCounty']", "pmPostcode": "$xa['pmPostcode']", "pmCity": "$xa['pmCity']", "pmStreet": "$xa['pmStreet']", "pmHousenumber": "$xa['pmHousenumber']", "data-auto-first-capital": "true", "data-query-type": "address", "data-query-reference": "", "data-query-list-type": "suggest-select", "data-query-list-header": "$services.localization.render('pagemaker.line.suggest_select_list')", "data-query-list-contents": "value/key", "data-query-list-editable": "false", "data-create-xobj": "true", "data-xobj-classname": "homeopaths.Code.homeopathsClass"}},
40 'practiceName': {'type': 'text', 'disabled': 0, "help-block": 1, 'extraAttributes': {"disabled": "disabled"}},
41 'pmStreet': {'type': 'text', 'disabled': 1},
42 'pmHousenumber': {'type': 'text', 'disabled': 1},
43 'pmPostcode': {'type': 'text', 'disabled': 1},
44 'pmCity': {'type': 'text', 'disabled': 1},
45 'pmCounty': {'type': 'text', 'disabled': 1},
46 'pmState': {'type': 'text', 'disabled': 1},
47 'pmCountry': {'type': 'text', 'disabled': 1},
48 'nrOfHomeopaths': {'type': 'number'},
49 'certification': {'type': 'checkbox', 'opener': 1},
50 'certificationFrom': {'type': 'text', 'parent': 'certification'}
51 })
52 $doc.getTranslatedDocument().getContent()
53
54 {{html wiki="true" clean="false"}}
55 ## Manual disabling of the create button in the 'Document actions' menu.
56 #if(!$isGuest)<p><script>var pmMenuCreate = "disable";</script></p>#end
57 ## Show the 'Edit content' button for the admin and the author only.
58 #if($hasRight)
59 <p class="buttons text-align-right">
60 <a class="btn btn-primary" title="Edit" href="$doc.getURL('edit','editor=wysiwyg')" role="button" rel="nofollow">
61 <span class="btn-label">$services.localization.render("editcontent")</span>
62 </a>
63 </p>
64 #end
65 <div class="clearfix"></div>
66 ## Show properties from the classProperties Map.
67 #if($xcontext.action == "view")
68 <h2 class="inline-data-summary">$services.localization.render("${subject}.inlineDataSummary.sheet_properties")</h2>
69 <div id="${subject}" class="sheet_properties inline-data-summary">
70 ## Show the address
71 #createAddress($theClass 1)
72 ## Set the XClass properties which you would like to be displayed.
73 #set($properties = ['nrOfHomeopaths','certification','certificationFrom'])
74 ## Show the above chosen properties
75 #foreach($property in $properties)
76 #set($hide = 0)
77 ## All form elements that are hidden in the form should also be hidden in the page.
78 #if($classProperties["$property"].containsKey('parent'))
79 #set($parentKey = $classProperties["$property"].parent)
80 #if((($classProperties["$parentKey"].type == "checkbox" || $classProperties["$parentKey"].type == "radio") && $theDocObj.getProperty($parentKey).value == 0) || !$theDocObj.getProperty($parentKey).value)
81 #set($hide = 1)
82 #end
83 #end
84 #if($hide == 0)
85 <p class="property">
86 ## Show value only if there is a value to show, otherwise set to 'unknown'.
87 <span class="property-name">$services.localization.render("${subject}.classproperty.${property}.label")</span>#if($theDocObj.getProperty($property).value && $theDocObj.getProperty($property).value != "") <span class="property-value">$doc.display($property)</span>#else <span class="property-value ghost">$services.localization.render("resource.unknown.label")</span>#end
88 </p>
89 #end
90 #end
91 ## Show the 'Edit details' button for the admin and the author only.
92 #if($hasRight)
93 <p class="buttons text-align-right">
94 <a class="btn btn-secondary" title="$services.localization.render("web.history.changes.details")" data-toggle="modal" data-target="#detailsModal" role="button" rel="nofollow">
95 <span class="btn-label">$services.localization.render("web.history.changes.details")</span>
96 </a>
97 </p>
98 #end
99 </div>
100 ## Show the properties edit form in a modal.
101 #if($hasRight)
102 #set($form_start = {
103 "id": "${subject}_form",
104 "product": $services.localization.render("${subject}.pmProduct"),
105 "method": "post",
106 "url": "",
107 "use_captcha": "false"
108 })
109 #set($submit = {
110 "id" : "edit_details",
111 "button-text" : $services.localization.render("notifications.watch.modal.savechanges"),
112 "clean": "true",
113 "help-block" : ""
114 })
115 #set($form_end = {
116 "use_captcha": "false"
117 })
118 $form_start.product
119 <div class="modal fade" id="detailsModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
120 <div class="modal-dialog modal-dialog-centered" role="document">
121 <div class="modal-content">
122 #createFormStart($form_start)
123 <div class="modal-header">
124 <h3 class="modal-title">$services.localization.render("web.history.changes.details")</h3>
125 <button type="button" class="close" data-dismiss="modal" title="$services.localization.render("modal.close")" aria-label="$services.localization.render("modal.close")">
126 <span aria-hidden="true">&times;</span>
127 </button>
128 </div>
129 <div class="modal-body">
130 #createAddress($theClass 1)
131 #set($lastChild = "")
132 #foreach($propertyName in $classProperties.keySet())
133 #set($value = "")
134 #set($item = $classProperties["$propertyName"])
135 #if(!$item.containsKey("disabled") || $item["disabled"] == 0)
136 #if(!$item.extraAttributes)
137 #set($item.extraAttributes = {})
138 #end
139 #set($translatedProperties = {})
140 #set($checkBool = ["false","true"])
141 #set($hasClassObj = !$item.containsKey("classless") && $theDocObj.getProperty($propertyName))
142 #if($item.type == "checkbox" || $item.type == "radio")
143 #if($hasClassObj)
144 #set($item.extraAttributes["data-checked"] = "$checkBool[$theDocObj.getProperty($propertyName).value]")
145 #else
146 #if(!$item.extraAttributes.containsKey("data-checked"))
147 #set($item.extraAttributes["data-checked"] = "$checkBool[0]")
148 #end
149 #end
150 #set($value = "1")
151 #else
152 #if($hasClassObj)
153 #if($theDocObj.getProperty($propertyName).value)
154 #set($value = $theDocObj.getProperty($propertyName).value)
155 #end
156 #end
157 #end
158 #if($item.type != "checkbox" && $item.type != "radio" && (!$item.containsKey("disabled") || $item["disabled"] == 0))
159 #set($translatedProperties = {
160 'aria_label': 'data-aria-label',
161 'placeholder': 'placeholder'
162 })
163 #end
164 #set($translatedProperties['label'] = 'label')
165 #if($item['help-block'] == 1)
166 #set($translatedProperties['help_block'] = 'help-block')
167 #end
168 #foreach($key in $translatedProperties.keySet())
169 #set($item.extraAttributes["$translatedProperties[$key]"] = $services.localization.render("${subject}.classproperty.${propertyName}.${key}"))
170 #end
171 #if($item.containsKey("classless"))
172 #set($newElem = {
173 "id" : "$propertyName",
174 "type" : $item.type,
175 "required" : "false",
176 "label" : "$label",
177 "value" : "$value"
178 })
179 #else
180 #set($newElem = {
181 "id" : "$propertyName",
182 "type" : $item.type,
183 "required" : "false",
184 "label" : "$label",
185 "data-create-xobj" : "true",
186 "data-xobj-classname" : $theClass,
187 "data-xobj-fieldname" : "$propertyName",
188 "value" : "$value"
189 })
190 #end
191 #if($item.extraAttributes.keySet().size() > 0)
192 #foreach($attr in $item.extraAttributes.keySet())
193 #set($discard = $newElem.put("$attr", $item.extraAttributes[$attr]))
194 #end
195 #end
196 #if($item.opener)
197 #set($discard = $newElem.put("data-opener", "true"))
198 #end
199 #if($item.parent)
200 #set($lastChild = "$key")
201 #elseif($lastChild != "")
202 #set($lastChild = "")
203 #createExpandEnd()
204 #end
205 #createFormElement($newElem)
206 #if($item.opener)
207 #createExpandStart($newElem $value)
208 #end
209 #end
210 #end
211 </div>
212 <div class="modal-footer">
213 <button type="button" class="btn btn-secondary" title="$services.localization.render("modal.close")" data-dismiss="modal">$services.localization.render("modal.close")</button>
214 #createSubmit($submit)
215 </div>
216 #createFormEnd($form_end)
217 </div>
218 </div>
219 </div>
220 #end
221 #elseif($xcontext.action == 'edit' && ($request.get('editor') == 'inline' || $request.get('section')))
222 <p>$services.localization.render("global.line.inline_noedit")</p>
223 <ul>
224 <li>[[$services.localization.render("global.line.edit_in_full")>>path:$doc.getURL('edit','editor=wysiwyg')]]</li>
225 <li>[[$services.localization.render("core.viewers.comments.preview.button.back")>>$doc.fullName]]</li>
226 </ul>
227 #end
228 #macro(createAddress $className $withLabel)
229 #set($docObj = $doc.getObject($className))
230 #set($addressArray = ['pmStreet','pmHousenumber','pmPostcode','pmCity','pmState','pmCounty','pmCountry'])
231 #set($x = {})
232 #foreach($datapart in $addressArray)
233 #if($docObj.getProperty($datapart))
234 #set($datapart4Publish = $docObj.getProperty($datapart).value)
235 #if($datapart == 'pmCountry')
236 #set($datapart4Publish = $datapart4Publish.toUpperCase())
237 #end
238 #set($discard = $x.put("$datapart", $datapart4Publish))
239 #end
240 #end
241 <div class="formElement">
242 #if($withLabel)
243 <label>$services.localization.render("${subject}.classproperty.pmAddress.label")</label>
244 #end
245 <address>
246 $doc.getTitle()<br />
247 $x['pmStreet'] $x['pmHousenumber']<br />
248 $x['pmPostcode'] $x['pmCity']<br />
249 $x['pmCounty'] $x['pmState']<br />
250 $x['pmCountry']
251 </address>
252 </div>
253 #end
254 {{/html}}
255 {{/velocity}}