1 | <?python |
---|
2 | from xml.sax.saxutils import escape |
---|
3 | import milk_server.lib.constants as constants |
---|
4 | def et2string(x): |
---|
5 | #use this to strip namespaces for children within text elements |
---|
6 | cb=x.tag.find('}') |
---|
7 | if cb!=-1: |
---|
8 | x.tag=x.tag[cb+1:] |
---|
9 | txt=(x.text or '') |
---|
10 | s='<%s>%s'%(x.tag,txt) |
---|
11 | # recurse through tree, if necessary |
---|
12 | for a in x: |
---|
13 | s+=et2string(a) |
---|
14 | s+='</%s>%s'%(x.tag,(x.tail or '')) |
---|
15 | return s |
---|
16 | ?> |
---|
17 | |
---|
18 | <html xmlns="http://www.w3.org/1999/xhtml" xmlns:py="http://genshi.edgewall.org/" |
---|
19 | py:strip=""> |
---|
20 | |
---|
21 | <span py:def="Text(elem)" py:strip=""> |
---|
22 | <!--! Note that we have to expect the possibility of xhtml in these elements and we won't |
---|
23 | want the parent attributes, or the namespaces --> |
---|
24 | <span py:if="elem is not None" py:strip=""> |
---|
25 | <span py:if="hasattr(elem, 'text')" py:strip=""> |
---|
26 | ${elem.text.strip()} |
---|
27 | </span> |
---|
28 | <!--! output any child elements --> |
---|
29 | <span py:with="s = ''" py:strip=""> |
---|
30 | <?python |
---|
31 | for a in elem: |
---|
32 | s+=et2string(a) |
---|
33 | ?> |
---|
34 | <span py:if="s" py:strip=""> |
---|
35 | ${Markup(s).strip()} |
---|
36 | </span> |
---|
37 | </span> |
---|
38 | </span> |
---|
39 | </span> |
---|
40 | |
---|
41 | |
---|
42 | <span py:def="expandHideSection(div1,div2,icon)"> |
---|
43 | <a href="javascript:;" title="Show/Hide details" |
---|
44 | onclick="swapLayers('$div1', '$div2'); return false;"> |
---|
45 | <img src="$icon" alt="Toggle expand/contract" class="helpicon"/></a> |
---|
46 | |
---|
47 | |
---|
48 | </span> |
---|
49 | |
---|
50 | |
---|
51 | |
---|
52 | <div class="metadataSection" py:def="TextArea(name, value, editLink, helpText, title=None, noEscapeVal=False)"> |
---|
53 | <?python |
---|
54 | divID = name + 'Div' |
---|
55 | edID = divID+'ed' |
---|
56 | helpID = divID + '_help' |
---|
57 | |
---|
58 | # adjust non-editable data to cope with newlines |
---|
59 | nonEditVal = "" |
---|
60 | if not noEscapeVal: |
---|
61 | value = escape(value) |
---|
62 | if value: |
---|
63 | nonEditVal = value.replace('\n', '<br />') |
---|
64 | nonEditVal = nonEditVal.replace('\r', '<br />') |
---|
65 | if not title: |
---|
66 | title = name |
---|
67 | ?> |
---|
68 | <table py:if="value or editLink"> |
---|
69 | <tr><td class="linehead"> |
---|
70 | <table> |
---|
71 | <tr><td>${title}<span py:if="editLink" py:replace="helpIcon(helpID, 'tr')"/></td> |
---|
72 | <span py:if="editLink" py:strip=""> |
---|
73 | <td align="right"> |
---|
74 | <span class="txtBlktog"> |
---|
75 | <a href="javascript:;" title="Toggle Form" |
---|
76 | onclick="swapLayers('$divID', '$edID'); return false;"> |
---|
77 | Add/Edit</a> |
---|
78 | </span> |
---|
79 | </td> |
---|
80 | </span> |
---|
81 | </tr> |
---|
82 | <tr id="$helpID" class="hidden" > |
---|
83 | <td class="helptxt" colspan="2">$helpText</td> |
---|
84 | </tr> |
---|
85 | </table> |
---|
86 | </td></tr> |
---|
87 | <tr><td> |
---|
88 | <div id = "$divID"> |
---|
89 | ${Markup(nonEditVal or 'No data specified at present')} |
---|
90 | </div> |
---|
91 | </td></tr> |
---|
92 | <tr py:if="editLink"><td> |
---|
93 | <div id="$edID" class="hidden"> |
---|
94 | <form action="${editLink}" method="post"> |
---|
95 | <table> |
---|
96 | <tr><td> |
---|
97 | ${Markup(h.text_area(name, value or '', class_="fullWidth", rows="9"))} |
---|
98 | </td></tr> |
---|
99 | <tr><td> |
---|
100 | ${Markup(h.submit('Update', **{'onclick': 'Div_show("loading");'}))} |
---|
101 | </td></tr> |
---|
102 | </table> |
---|
103 | </form> |
---|
104 | </div> |
---|
105 | </td></tr> |
---|
106 | </table> |
---|
107 | </div> |
---|
108 | |
---|
109 | |
---|
110 | <!--! hyperlinked image --> |
---|
111 | <span py:def="linkimage(linkref,imageref,alttext)"> |
---|
112 | <a href="$linkref"><image src="$imageref" alt="$alttext" title="$alttext"/></a> |
---|
113 | </span> |
---|
114 | |
---|
115 | <!--! Help Icons --> |
---|
116 | <span py:def="helpIcon(value, elementType = 'div')"> |
---|
117 | <span> |
---|
118 | <a href="javascript:;" title="Toggle help" onclick="toggleDiv(1,'$value','shown','hidden','$elementType'); return false;"> |
---|
119 | <img src="$g.helpIcon" alt="Toggle help" class="helpicon"/></a> |
---|
120 | </span> |
---|
121 | </span> |
---|
122 | |
---|
123 | <!-- *********************************************************************************** --> |
---|
124 | |
---|
125 | <!-- ! Icons for vocab assisted text search --> |
---|
126 | <span py:def="vocSrchIcon(value, elementType = 'div')"> |
---|
127 | <span> |
---|
128 | <input type="button" alt="Vocabulary assisted text search" value="Vocab text search" onclick="toggleDiv(1,'$value','shown','hidden','$elementType'); return false;"/> |
---|
129 | </span> |
---|
130 | </span> |
---|
131 | |
---|
132 | <!-- ! Icons for free text search --> |
---|
133 | <span py:def="txtSrchIcon(value, elementType = 'div')"> |
---|
134 | <span> |
---|
135 | <input type="button" alt="Click to perfom a Free text search" value="Free text search" onclick="toggleDiv(1,'$value','shown','hidden','$elementType'); return false;"/> |
---|
136 | </span> |
---|
137 | </span> |
---|
138 | |
---|
139 | |
---|
140 | |
---|
141 | |
---|
142 | <!-- *********************************************************************************** --> |
---|
143 | |
---|
144 | <div py:def="EditTextFieldRow(title, name, value, isEditable, type, width='auto', colspan='1')" py:strip=""> |
---|
145 | <tr> |
---|
146 | <td class="cellhead" width="10%">${title}:</td> |
---|
147 | <div py:replace="EditTextField(name, value, isEditable, type, width='$width', colspan='$colspan')"/> |
---|
148 | </tr> |
---|
149 | </div> |
---|
150 | |
---|
151 | |
---|
152 | <div py:def="EditTextField(name, value, isEditable, type, width='auto', colspan='1')" py:strip=""> |
---|
153 | <td py:if="isEditable" class="column" width="$width" colspan="$colspan"> |
---|
154 | <span py:if="type == constants.TEXT_FIELD" py:strip=""> |
---|
155 | ${Markup(h.text_field(name, value, class_="fullWidth"))} |
---|
156 | </span> |
---|
157 | <span py:if="type == constants.TEXT_AREA" py:strip=""> |
---|
158 | ${Markup(h.text_area(name, value, class_="fullWidth", rows="4"))} |
---|
159 | </span> |
---|
160 | </td> |
---|
161 | <td py:if="not isEditable" class="column" width="$width" colspan="$colspan"> |
---|
162 | ${Markup(value)} |
---|
163 | </td> |
---|
164 | </div> |
---|
165 | |
---|
166 | </html> |
---|