Wiki-Quellcode von homeopathsSheet

Version 3.36 von Jip-jan Alunkel am März 09, 03:55

Zeige letzte Bearbeiter
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($theDoc = $xwiki.getDocument("${doc.fullName}").getTranslatedDocument())
9 #set($isInline = $xcontext.action == 'edit' && $request.get('editor') == 'inline')
10 #set($theClass = "homeopaths.Code.homeopathsClass")
11 ## Create object (important for sheet binding, do not remove)
12 #set($theDocObj = $doc.getObject($theClass, true))
13 #set($hasRight = !$isGuest && ($theDocObj.getProperty('user').value == $context.getUser() || $hasAdmin))
14 $theDoc.getContent()
15 {{html wiki="true" clean="false"}}
16 #if(!$isGuest)
17 <script>
18 var pagemakerOffspring = "disable";
19 </script>
20 #end
21 #if($hasRight)
22 <p class="buttons text-align-right">
23 <a class="btn btn-primary" title="Edit" href="$doc.getURL("edit")?editor=wysiwyg" role="button" rel="nofollow">
24 <span class="fa fa-pencil"></span>
25 <span class="btn-label">Edit content</span>
26 </a>
27 </p>
28 #end
29 #set($spaceReference = $services.model.resolveDocument('', 'default', $doc.documentReference.lastSpaceReference).parent)
30 #set($spaceTitle = $spaceReference.getName())
31 <div class="clearfix"></div>
32 #if($xcontext.action == "view")
33 <div id="${spaceTitle}" class="box sheet_properties">
34 <h2>Details</h2>
35 #set($xa = {
36 'pmLatlong': '',
37 'pmCountry': '',
38 'pmState': '',
39 'pmCounty': '',
40 'pmPostcode': '',
41 'pmCity': '',
42 'pmStreet': '',
43 'pmHousenumber': ''
44 })
45 #foreach($item in $xa.keySet())
46 #if($theDocObj.getProperty("$item"))
47 #set($xa["$item"] = $theDocObj.getProperty("$item").value)
48 #end
49 #end
50
51 ## The classProperties Map has to be in the order of how you want the form elements to appear in the form.
52 #set($classProperties = {
53 'practiceName': {'type': 'text', 'extraAttributes': {"disabled": "disabled", "help-block" : 'The name of your practice is the title of this page. If you want to change it, you should edit the content of this page.'}},
54 'editAddress': {'type': 'checkbox', 'opener': 1, 'classless': 1, 'checked': 0},
55 'pmAddress': {'type': 'address', 'parent': 'editAddress', 'extraAttributes': {"aria-label": "Input and select the address of your practice", "placeholder": "$services.localization.render('homeopaths.multiword.address.placeholder')", "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", "help-block" : 'Input street and number, then select the address of your practice.'}},
56 'pmStreet': {'type': 'text', 'disabled': 1},
57 'pmHousenumber': {'type': 'text', 'disabled': 1},
58 'pmPostcode': {'type': 'text', 'disabled': 1},
59 'pmCity': {'type': 'text', 'disabled': 1},
60 'pmCounty': {'type': 'text', 'disabled': 1},
61 'pmState': {'type': 'text', 'disabled': 1},
62 'pmCountry': {'type': 'text', 'disabled': 1},
63 'certification': {'type': 'checkbox', 'opener': 1},
64 'certificationFrom': {'type': 'text', 'parent': 'certification'}
65 })
66 #foreach($property in $classProperties.keySet())
67 #if($theDocObj.getProperty($property))
68 <p class="property">
69 #if($theDocObj.getProperty($property).value != "" && $property != "pmHousenumber") ## Difference with added housenumber because of the streetaddress layout.
70 #if($property == "pmStreet")
71 <span class="property-name">$services.localization.render("homeopaths.classproperty.address")</span> <span class="property-value">$doc.display($property) $doc.display("pmHousenumber")</span>
72 #elseif($property == "practiceName") ## Difference, should receive the title from the page.
73 <span class="property-name">$services.localization.render("homeopaths.classproperty.${property}")</span> <span class="property-value">$doc.getTitle()</span>
74 #else ## Normal situation.
75 <span class="property-name">$services.localization.render("homeopaths.classproperty.${property}")</span> <span class="property-value">$doc.display($property)</span>
76 #end
77 </p>
78 #end
79 #end
80 #end
81
82 #if($hasRight)
83 <p class="buttons text-align-right">
84 <a class="btn btn-secondary" title="Edit" data-toggle="modal" data-target="#detailsModal" role="button" rel="nofollow">
85 <span class="btn-label">Edit details</span>
86 </a>
87 </p>
88 #end
89 </div>
90 #if($hasRight)
91 #set($form_start = {
92 "id": "homeopaths_form",
93 "product": "homeopath details",
94 "method": "post",
95 "url": "",
96 "use_captcha": "false"
97 })
98 #set($submit = {
99 "id" : "edit_details",
100 "button-text" : "Save changes",
101 "clean": "true",
102 "help-block" : ""
103 })
104 #set($form_end = {
105 "use_captcha": "false"
106 })
107 <div class="modal fade" id="detailsModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
108 <div class="modal-dialog modal-dialog-centered" role="document">
109 <div class="modal-content">
110 #createFormStart($form_start)
111 <div class="modal-header">
112 <h3 class="modal-title">Details</h3>
113 <button type="button" class="close" data-dismiss="modal" aria-label="Close">
114 <span aria-hidden="true">&times;</span>
115 </button>
116 </div>
117 <div class="modal-body">
118 <fieldset class="fieldset">
119 <address>
120 $doc.getTitle()<br />
121 #set($addressArray = ['pmStreet','pmHousenumber','pmPostcode','pmCity','pmState','pmCounty','pmCountry'])
122 #set($x = {})
123 #foreach($datapart in $addressArray)
124 #if($theDocObj.getProperty($datapart))
125 #set($datapart4Publish = $theDocObj.getProperty($datapart).value)
126 #if($datapart == 'pmCountry')
127 #set($datapart4Publish = $datapart4Publish.toUpperCase())
128 #end
129 #set($discard = $x.put("$datapart", $datapart4Publish))
130 #end
131 #end
132 $x['pmStreet'] $x['pmHousenumber']<br />
133 $x['pmPostcode'] $x['pmCity']<br />
134 $x['pmCounty'] $x['pmState']<br />
135 $x['pmCountry']
136 </address>
137 </fieldset>
138 #set($lastChild = "")
139 #foreach($propertyName in $classProperties.keySet())
140 #set($item = $classProperties["$propertyName"])
141 #if($item.containsKey("disabled"))
142 #else
143 #set($propertyType = $item.type)
144 #set($propertyChecked = $item.checked)
145 #set($propertyOpener = $item.opener)
146 #set($propertyParent = $item.parent)
147 #set($extraAttributes = $item.extraAttributes)
148 #set($label = $services.localization.render("homeopaths.classproperty.${propertyName}"))
149 #if($propertyType == "checkbox" || $propertyType == "radio")
150 #set($value = "1")
151 #elseif($theDocObj.getProperty($propertyName) || $propertyType == "address") ## 'address' is not a property in the current class
152 #set($value = $theDocObj.getProperty($propertyName).value)
153 #end
154 #if(!$value)
155 #set($value = "")
156 #end
157 #if($item.containsKey("classless"))
158 #set($newElem = {
159 "id" : "$propertyName",
160 "type" : $propertyType,
161 "required" : "false",
162 "label" : "$label",
163 "value" : "$value"
164 })
165 #else
166 #set($newElem = {
167 "id" : "$propertyName",
168 "type" : $propertyType,
169 "required" : "false",
170 "label" : "$label",
171 "data-create-xobj" : "true",
172 "data-xobj-classname" : $theClass,
173 "data-xobj-fieldname" : "$propertyName",
174 "value" : "$value"
175 })
176 #end
177 #if($extraAttributes.keySet().size() > 0)
178 #set($attrMap = $extraAttributes)
179 #foreach($attr in $attrMap.keySet())
180 #set($discard = $newElem.put("$attr", $attrMap[$attr]))
181 #end
182 #end
183 #if($propertyChecked)
184 #set($discard = $newElem.put("data-checked", "false"))
185 #end
186 #if($propertyOpener)
187 #set($discard = $newElem.put("data-opener", "true"))
188 #end
189 #if($propertyParent)
190 #set($lastChild = "$key")
191 #elseif($lastChild != "")
192 #set($lastChild = "")
193 #createExpandEnd()
194 #end
195 #createFormElement($newElem)
196 #if($propertyOpener)
197 #createExpandStart($newElem $value)
198 #end
199 #end
200 #end
201 </div>
202 <div class="modal-footer">
203 <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
204 #createSubmit($submit)
205 </div>
206 #createFormEnd($form_end)
207 </div>
208 </div>
209 </div>
210 #end
211 #else
212 This page can not be viewed in inline mode.
213 #end
214
215 #macro(createElementObjects $properties)
216 #foreach($item in $properties.keySet())
217 #set($label = $services.localization.render("homeopaths.classproperty.${item}"))
218 #if($theDocObj.getProperty($item))
219 #set($value = $theDocObj.getProperty($item).value)
220 #set($newElem = {
221 "id" : "$item",
222 "type" : $classProperties[$item].type,
223 "required" : "false",
224 "label" : "$label",
225 "data-create-xobj" : "true",
226 "data-xobj-classname" : $theClass,
227 "data-xobj-fieldname" : "$item",
228 "value" : "$value"
229 })
230 #if($classProperties[$item].opener == 1)
231 #set($discard = $newElem.put("data-opener", "true"))
232 #end
233 #if($classProperties[$item].extraAttributes)
234 #set($attrMap = $classProperties[$item].extraAttributes)
235 #foreach($attr in $attrMap.keySet())
236 #set($discard = $newElem.put("$attr", $attrMap[$attr]))
237 #end
238 #end
239 #set($thisObj["$item"] = $newElem)
240 #end
241 #end
242 #end
243
244 {{/html}}
245 {{/velocity}}