Code source wiki de homeopathsSheet

Version 3.46 par Jip-jan Alunkel le mars 09, 04:32

Afficher les derniers auteurs
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 ## The classProperties Map has to be in the order of how you want the form elements to appear in the form.
51 #set($certify = $theDocObj.getProperty("certification").value)
52 #set($cert=$numbertool.toNumber($certify).intValue())
53 $cert
54 #set($classProperties = {
55 '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.'}},
56 'editAddress': {'type': 'checkbox', 'opener': 1, 'classless': 1, 'checked': 0},
57 '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.'}},
58 'pmStreet': {'type': 'text', 'disabled': 1},
59 'pmHousenumber': {'type': 'text', 'disabled': 1},
60 'pmPostcode': {'type': 'text', 'disabled': 1},
61 'pmCity': {'type': 'text', 'disabled': 1},
62 'pmCounty': {'type': 'text', 'disabled': 1},
63 'pmState': {'type': 'text', 'disabled': 1},
64 'pmCountry': {'type': 'text', 'disabled': 1},
65 'certification': {'type': 'checkbox', 'opener': 1, 'checked': $cert},
66 'certificationFrom': {'type': 'text', 'parent': 'certification'}
67 })
68 #foreach($property in $classProperties.keySet())
69 #if($theDocObj.getProperty($property))
70 <p class="property">
71 #if($theDocObj.getProperty($property).value != "" && $property != "pmHousenumber") ## Difference with added housenumber because of the streetaddress layout.
72 #if($property == "pmStreet")
73 <span class="property-name">$services.localization.render("homeopaths.classproperty.address")</span> <span class="property-value">$doc.display($property) $doc.display("pmHousenumber")</span>
74 #elseif($property == "practiceName") ## Difference, should receive the title from the page.
75 <span class="property-name">$services.localization.render("homeopaths.classproperty.${property}")</span> <span class="property-value">$doc.getTitle()</span>
76 #else ## Normal situation.
77 <span class="property-name">$services.localization.render("homeopaths.classproperty.${property}")</span> <span class="property-value">$doc.display($property)</span>
78 #end
79 </p>
80 #end
81 #end
82 #end
83
84 #if($hasRight)
85 <p class="buttons text-align-right">
86 <a class="btn btn-secondary" title="Edit" data-toggle="modal" data-target="#detailsModal" role="button" rel="nofollow">
87 <span class="btn-label">Edit details</span>
88 </a>
89 </p>
90 #end
91 </div>
92 #if($hasRight)
93 #set($form_start = {
94 "id": "homeopaths_form",
95 "product": "homeopath details",
96 "method": "post",
97 "url": "",
98 "use_captcha": "false"
99 })
100 #set($submit = {
101 "id" : "edit_details",
102 "button-text" : "Save changes",
103 "clean": "true",
104 "help-block" : ""
105 })
106 #set($form_end = {
107 "use_captcha": "false"
108 })
109 <div class="modal fade" id="detailsModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
110 <div class="modal-dialog modal-dialog-centered" role="document">
111 <div class="modal-content">
112 #createFormStart($form_start)
113 <div class="modal-header">
114 <h3 class="modal-title">Details</h3>
115 <button type="button" class="close" data-dismiss="modal" aria-label="Close">
116 <span aria-hidden="true">&times;</span>
117 </button>
118 </div>
119 <div class="modal-body">
120 <fieldset class="fieldset">
121 <address>
122 $doc.getTitle()<br />
123 #set($addressArray = ['pmStreet','pmHousenumber','pmPostcode','pmCity','pmState','pmCounty','pmCountry'])
124 #set($x = {})
125 #foreach($datapart in $addressArray)
126 #if($theDocObj.getProperty($datapart))
127 #set($datapart4Publish = $theDocObj.getProperty($datapart).value)
128 #if($datapart == 'pmCountry')
129 #set($datapart4Publish = $datapart4Publish.toUpperCase())
130 #end
131 #set($discard = $x.put("$datapart", $datapart4Publish))
132 #end
133 #end
134 $x['pmStreet'] $x['pmHousenumber']<br />
135 $x['pmPostcode'] $x['pmCity']<br />
136 $x['pmCounty'] $x['pmState']<br />
137 $x['pmCountry']
138 </address>
139 </fieldset>
140 #set($lastChild = "")
141 #foreach($propertyName in $classProperties.keySet())
142 #set($item = $classProperties["$propertyName"])
143 #if($item.containsKey("disabled"))
144 #else
145 #set($propertyType = $item.type)
146 #set($propertyChecked = $item.checked)
147 #set($propertyOpener = $item.opener)
148 #set($propertyParent = $item.parent)
149 #set($extraAttributes = $item.extraAttributes)
150 #set($label = $services.localization.render("homeopaths.classproperty.${propertyName}"))
151 #if($propertyType == "checkbox" || $propertyType == "radio")
152 #set($value = "1")
153 #elseif($theDocObj.getProperty($propertyName) || $propertyType == "address") ## 'address' is not a property in the current class
154 #set($value = $theDocObj.getProperty($propertyName).value)
155 #end
156 #if(!$value)
157 #set($value = "")
158 #end
159 #if($item.containsKey("classless"))
160 #set($newElem = {
161 "id" : "$propertyName",
162 "type" : $propertyType,
163 "required" : "false",
164 "label" : "$label",
165 "value" : "$value"
166 })
167 #else
168 #set($newElem = {
169 "id" : "$propertyName",
170 "type" : $propertyType,
171 "required" : "false",
172 "label" : "$label",
173 "data-create-xobj" : "true",
174 "data-xobj-classname" : $theClass,
175 "data-xobj-fieldname" : "$propertyName",
176 "value" : "$value"
177 })
178 #end
179 #if($extraAttributes.keySet().size() > 0)
180 #set($attrMap = $extraAttributes)
181 #foreach($attr in $attrMap.keySet())
182 #set($discard = $newElem.put("$attr", $attrMap[$attr]))
183 #end
184 #end
185 #if($propertyChecked == '1')
186 hello1
187 #set($discard = $newElem.put("data-checked", "true"))
188 #else
189 hello0
190 #set($discard = $newElem.put("data-checked", "false"))
191 #end
192 #if($propertyOpener)
193 #set($discard = $newElem.put("data-opener", "true"))
194 #end
195 #if($propertyParent)
196 #set($lastChild = "$key")
197 #elseif($lastChild != "")
198 #set($lastChild = "")
199 #createExpandEnd()
200 #end
201 #createFormElement($newElem)
202 #if($propertyOpener)
203 #createExpandStart($newElem $value)
204 #end
205 #end
206 #end
207 </div>
208 <div class="modal-footer">
209 <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
210 #createSubmit($submit)
211 </div>
212 #createFormEnd($form_end)
213 </div>
214 </div>
215 </div>
216 #end
217 #else
218 This page can not be viewed in inline mode.
219 #end
220
221 #macro(createElementObjects $properties)
222 #foreach($item in $properties.keySet())
223 #set($label = $services.localization.render("homeopaths.classproperty.${item}"))
224 #if($theDocObj.getProperty($item))
225 #set($value = $theDocObj.getProperty($item).value)
226 #set($newElem = {
227 "id" : "$item",
228 "type" : $classProperties[$item].type,
229 "required" : "false",
230 "label" : "$label",
231 "data-create-xobj" : "true",
232 "data-xobj-classname" : $theClass,
233 "data-xobj-fieldname" : "$item",
234 "value" : "$value"
235 })
236 #if($classProperties[$item].opener == 1)
237 #set($discard = $newElem.put("data-opener", "true"))
238 #end
239 #if($classProperties[$item].extraAttributes)
240 #set($attrMap = $classProperties[$item].extraAttributes)
241 #foreach($attr in $attrMap.keySet())
242 #set($discard = $newElem.put("$attr", $attrMap[$attr]))
243 #end
244 #end
245 #set($thisObj["$item"] = $newElem)
246 #end
247 #end
248 #end
249
250 {{/html}}
251 {{/velocity}}