source: trunk/skins/lemill/widget_chapter.pt @ 3098

Revision 3098, 17.5 KB checked in by jukka, 9 years ago (diff)

Fixed bugs found from error_log, mostly to do about strange pieces.

Line 
1<html xmlns="http://www.w3.org/1999/xhtml"
2      xmlns:tal="http://xml.zope.org/namespaces/tal"
3      xmlns:metal="http://xml.zope.org/namespaces/metal"
4      xmlns:i18n="http://xml.zope.org/namespaces/i18n"
5      i18n:domain="lemill">
6  <head><title></title></head>
7  <body>
8
9<!-- Main view macro -->
10
11<metal:view_macro define-macro="view" tal:define="value accessor"> 
12    <tal:chapters repeat="chapter value">           
13        <tal:defs tal:define="text chapter/text;
14            type chapter/type;
15            index repeat/chapter/index;">
16            <metal:view_block use-macro="python:path('here/widget_chapter/macros/view_'+type)" />
17        </tal:defs>
18    </tal:chapters>
19</metal:view_macro>
20
21<!-- view macros, called from Main view macro and these can be used by other widgets too -->
22
23<metal:view_text_block define-macro="view_text_block">
24<div tal:replace="structure text" />
25</metal:view_text_block>
26
27<metal:view_media_piece define-macro="view_media_piece">
28<tal:piece_defs define="piece python:field.getObjectByUID(context, chapter.get('uid',''));
29    piece_url piece/absolute_url | nothing;
30    piece_type piece/getPiece_type | nothing;
31    macro_mapping python:{'image':'here/piece_macros/macros/image',
32        'audio':'here/macros_audioplayer/macros/audioplayer',
33        'flash':'here/piece_macros/macros/swf_macro',
34        'flv-video':'here/macros_flowplayer/macros/flowplayer_chapter_view',
35        'kml':'here/piece_macros/macros/kml_macro',
36        'video':'here/macros_flowplayer/macros/flowplayer_chapter_view'}">   
37        <tal:we_got_piece condition="python:piece and not piece.isDeleted()">
38            <metal:view use-macro="python:path(macro_mapping.get(piece_type,'here/piece_macros/macros/download_only'))" />
39        </tal:we_got_piece>
40</tal:piece_defs>
41</metal:view_media_piece>
42
43<metal:view_embed_block define-macro="view_embed_block">
44<div class="embed_content" tal:define="oembed python:field.isOEmbedChapter(chapter)">
45<tal:oembed condition="oembed">
46<a href="" tal:attributes="href chapter/embed" class="oembed" content="chapter/embed">Embedded content</a>
47</tal:oembed>
48<tal:old_embed condition="not:oembed" replace="structure chapter/embed | python:''" /></div>
49</metal:view_embed_block>
50
51<!-- Main edit macro -->
52
53<metal:define define-macro="edit">
54 <metal:use use-macro="field_macro | here/field/macros/edit">
55  <metal:fill fill-slot="widget_body">
56   <metal:chapter_editor_block define-macro="chapter_editor">
57  <tal:define define="edit_chapter request/chapter_edited | python:0;
58              edit_chapter python: int(edit_chapter);
59              translation translation | python:0;
60              chapter_count python:len(value);
61              edit_chapter python: test(edit_chapter&lt;chapter_count, edit_chapter, chapter_count-1);           
62              cleaned_chapters here/getBodyText;
63              macro_mapping python:{'text_block':'here/widget_chapter/macros/%s_text_block',
64                'guidelines':'here/widget_exercise/macros/%s_guidelines',
65                'media_piece':'here/widget_chapter/macros/%s_media_piece',
66                'embed_block':'here/widget_chapter/macros/%s_embed_block',
67                'choice':'here/widget_exercise/macros/%s_choice',
68                'multiple_choices':'here/widget_exercise/macros/%s_multiple_choices',
69                'poll':'here/widget_exercise/macros/%s_poll',
70                'fill_in_the_blanks':'here/widget_exercise/macros/%s_fill_in_the_blanks',
71                'open_ended':'here/widget_exercise/macros/%s_open_ended',
72                'exercise':'here/widget_exercise/macros/%s_exercise'};
73              chapter_names field/getChapterNames;">
74    <input type="hidden" name="chapter_count" id="chapter_count" value="1" tal:attributes="value chapter_count"/>
75    <input type="hidden" name="chapter_edited" id="chapter_edited" value="0" tal:attributes="value edit_chapter"/>
76    <input type="hidden" name="chapter_last_edited" id="chapter_last_edited" value="0" tal:attributes="value edit_chapter"/>
77    <input type="hidden" name="chapter_type" id="chapter_type" tal:attributes="value python:value[edit_chapter]['type']"/>
78   <div class="sortable">
79   <tal:chapters repeat="chapter value">
80    <tal:definitions define="index repeat/chapter/index;
81      text chapter/text;
82      type chapter/type;
83      cleaned_chapter python:cleaned_chapters[index];
84       ">       
85     <a name="#" tal:attributes="name index"></a>
86     <div class="sortable_row">       
87     <fieldset class="edit_box">   
88       <metal:legend define-macro="legendbuttons">
89            <div class="handle">
90                <img src="images/pattern.png" tal:attributes="src string:${portal_url}/images/pattern.png" alt="" width="18" height="10" style="padding-top:4px;padding-left:4px" />
91                <input class="editChapter "
92                    type="submit"
93                    name="editChapter"
94                    value="Edit" i18n:domain="plone"
95                    tal:condition="python:index!=edit_chapter"
96                    i18n:attributes="value label_edit;"
97                    tal:attributes="tabindex tabindex/next;
98                    onClick python:'''javascript:document.getElementById('chapter_edited').value=%s''' %  index"/>                   
99                <input class="saveChapter"
100                    tabindex=""
101                    type="submit"
102                    name="saveChapter"
103                    value="Save" i18n:domain="plone"
104                    tal:condition="python:index==edit_chapter"
105                    i18n:attributes="value label_save;"
106                    tal:attributes="tabindex tabindex/next;"
107                    onClick="$('chapter_edited').val('-1')"/>
108                <span tal:content="python:chapter_names[type]" i18n:translate="" class="discreet">text chapter</span>
109
110                <input class="right deleteButton"
111                    type="button"
112                    name="deleteButton"
113                    value="Delete" i18n:domain="plone"
114                    i18n:attributes="value;"
115                    tal:attributes="tabindex tabindex/next;"
116                    onClick="deleteChapter(this);" />
117                <input type="button"
118                    name="undeleteButton"
119                    class="right undeleteButton"
120                    value="Undelete"
121                    i18n:attributes="value;"
122                    tal:attributes="tabindex tabindex/next;"
123                    style="display:none"
124                    onClick="undeleteChapter(this);"/>
125                <input type="hidden"
126                    tal:attributes="id string:chapter_deleted_$index; name string:chapter_deleted_$index"
127                    class="deletionkeeper"
128                    value="0" />
129                <input type="hidden"
130                    class="orderkeeper"
131                    tal:attributes="name string:chapter_order_$index; id string:chapter_order_$index; value index" />       
132            </div>
133        </metal:legend>
134        <tal:view_mode condition="python:index!=edit_chapter">
135           <div class="inner_box">
136            <metal:block use-macro="python:path(macro_mapping[type] % 'edit_view')" />
137           </div>             
138        </tal:view_mode>
139      <tal:edit_mode condition="python:index==edit_chapter">
140           <a name="edit"></a>
141           <metal:block use-macro="python:path(macro_mapping[type] % 'edit')" />               
142      </tal:edit_mode>
143     </fieldset>
144     </div>
145     </tal:definitions>
146   </tal:chapters>
147   </div>
148   </tal:define>
149   </metal:chapter_editor_block>
150   <tal:buttons>
151       <input class="context"
152           tabindex=""
153           type="submit"
154           name="add_media_piece"
155           value="Add media piece"
156           i18n:attributes="value label_add_media_piece;"
157           tal:attributes="tabindex tabindex/next"
158           />               
159       <input class="context"
160           tabindex=""
161           type="submit"
162           name="add_text_block"
163           value="Add text block"
164           i18n:attributes="value label_add_textarea;"
165           tal:attributes="tabindex tabindex/next"
166           />
167       <input class="context"
168           tabindex=""
169           type="submit"
170           name="add_embed_block"
171           value="Add an embedded section"
172           i18n:attributes="value label_add_embed_block;"
173           tal:attributes="tabindex tabindex/next"
174           />
175   </tal:buttons>
176 </metal:fill>
177</metal:use>
178</metal:define>
179
180
181<!-- edit/view macros,  called from Main edit macros if chapter is not the one that is edited -->
182
183<metal:edit_view_text_block define-macro="edit_view_text_block">
184<div tal:replace="structure cleaned_chapter/text" />
185</metal:edit_view_text_block>
186
187<tal:edit_view_media_piece metal:define-macro="edit_view_media_piece">    
188    <tal:defs define="piece python:field.getObjectByUID(context, chapter['uid']);
189        deleted piece/isDeleted | python:True;
190        piece_url piece/absolute_url | nothing;
191        piece_type piece/getPiece_type | nothing;
192        macro_mapping python:{'image':'here/piece_macros/macros/image',
193            'audio':'here/macros_audioplayer/macros/audioplayer',
194            'flash':'here/piece_macros/macros/swf_macro',
195            'flv-video':'here/macros_flowplayer/macros/flowplayer_chapter_area_edit',
196            'kml':'here/piece_macros/macros/kml_macro'}">   
197        <tal:we_got_piece condition="python:piece and not piece.isDeleted()">
198            <metal:view use-macro="python:path(macro_mapping.get(piece_type,'here/piece_macros/macros/download_only'))" />
199        </tal:we_got_piece>
200    </tal:defs>
201</tal:edit_view_media_piece>
202
203<metal:edit_view_embed_block define-macro="edit_view_embed_block">
204<div class="embed_content" tal:define="oembed python:field.isOEmbedChapter(chapter)">
205<tal:oembed condition="oembed">
206<a href="" tal:attributes="href chapter/embed" class="oembed" content="chapter/embed">Embedded content</a>
207</tal:oembed>
208<tal:old_embed condition="not:oembed" replace="structure chapter/embed | python:''" /></div>
209</metal:edit_view_embed_block>
210
211<!-- edit macros, called from Main edit macro for chapter that is open to editing -->
212
213<metal:original_text define-macro="original_text">
214<label i18n:translate="label_original_field">Original<span i18n:name="field" >:</span></label>
215<div class="text_to_translate">
216   <span tal:replace="structure chapter/translation_source"/>           
217</div>
218</metal:original_text>
219
220
221<tal:edit_text_block metal:define-macro="edit_text_block">    
222<div class="translatedText" tal:condition="translation"><metal:tra use-macro="here/widget_chapter/macros/original_text" /></div>
223<tal:def define="inputvalue text;
224    fieldName python:'chapter_textarea';
225    inputname fieldName;
226    height python:'260px';
227    rows python:18">     
228        <metal:block metal:use-macro="here/wysiwyg_support/macros/wysiwygEditorBox" />
229</tal:def>
230</tal:edit_text_block>
231
232<tal:edit_embed_block metal:define-macro="edit_embed_block">
233<div class="editorPaddings" tal:define="oembed python:field.isOEmbedChapter(chapter) or not chapter['embed']"> 
234<div class="formHelp" i18n:translate="embed_field_help">Enter address for embedded content here. (for example http://www.youtube.com/watch?v=... )</div>      
235<p>
236<input type="text" style="width:60%" id="embed_field" name="embed_field" tal:attributes="value python:test(oembed, chapter['embed'], '')" />
237<input type="button" value="Test embedding" i18n:attributes="value python:Test embedding" onclick="$('#embed_test').oembed($('#embed_field').val());$('#old_embed').html('');" /></p>
238<div id="embed_test">
239<a href="" tal:attributes="href chapter/embed" class="oembed" tal:condition="oembed" tal:content="chapter/embed">Embedded content</a></div>    
240<tal:old_embed condition="not:oembed">
241<div id="old_embed" tal:content="structure chapter/embed" />
242<br/>
243<div class="formHelp" i18n:translate="embed_field_old_value_help">For safety reason we don't allow direct embed codes anymore. The embed code for this resource was:</div>      
244
245<textarea readonly="1" rows="6" style="width:95%" id="embed_field_old" name="embed_field_old" tal:content="chapter/embed | python:''"></textarea>    
246<div class="formHelp" i18n:translate="embed_field_old_value_help_2">If you want to update this embedded content, please use the webpage address (not the embed code) of the resource.</div>
247</tal:old_embed></div>
248</tal:edit_embed_block>
249
250<metal:edit_media_piece define-macro="edit_media_piece">
251    <tal:def_search_type tal:define="piece_type python:'All'; piece_edit python:True">
252        <metal:block metal:use-macro="here/widget_chapter/macros/piece_chooser" />   
253    </tal:def_search_type>
254</metal:edit_media_piece>
255
256<metal:define define-macro="piece_chooser">
257  <tal:defines define="piece_uid chapter/uid;
258                        piece python: field.getObjectByUID(context, piece_uid);
259                        piece_url piece/absolute_url | nothing;
260                        deleted piece/isDeleted | python:True;
261                        isImage piece/isImage | python:0;
262                        isAudio piece/isAudio | python:0;
263                        isFLVVideo piece/isFLVVideo | python:0;
264                        coverImage piece/getCoverImage | nothing;">
265    <div id="piece-edit-box" tal:attributes="style python:test(piece_url, 'background-image:url(%s/image_large)' % piece_url, 'background-image:none')">
266    <div style="display:inline-block">
267        <div style="height:20px" class="visualClear">&nbsp;</div>
268        <div id="piece-edit-controls" tal:attributes="class python:test(piece and isImage, 'contrast','')"><tal:block tal:condition="python: piece_type=='image'" i18n:translate="label_upload_image_file">Upload image file</tal:block>
269        <tal:block tal:condition="python: piece_type=='audio'" i18n:translate="label_upload_audio">Upload audio file</tal:block>
270        <tal:block tal:condition="python: piece_type not in ['audio','image']" i18n:translate="label_upload_a_file">Upload a file</tal:block>...
271        <input type="hidden" value="0" name="piece_uid" id="piece_uid" tal:attributes="value piece_uid | nothing;"  />
272        <input type="hidden" value="" name="piece_type" id="piece_type" tal:attributes="value piece_type | string:image;" />
273        <input id="file"  type="file" value="" name="file" />
274        <input id="uploadFile"  type="submit"  name="uploadFile" value="Upload file" i18n:attributes="value label_upload_file;" /></div>
275        <div style="height:20px" class="visualClear">&nbsp;</div>
276    </div>
277    <div id="piece-view-controls"  style="display:inline-block">
278        <div id="piece-media-box">
279         <div style="display:inline-block;vertical-align:middle;">
280          <tal:not_image condition="python:piece and not isImage">
281            <a href="" tal:attributes="href piece_url">                       
282            <tal:coverimage condition="coverImage" replace="structure coverImage" />
283            <img tal:condition="python: isAudio and not coverImage" src="images/default_soundclip.png" />
284            <img tal:condition="python: not (isAudio or coverImage)" src="images/default_movieclip.png" />
285            </a>
286          </tal:not_image>
287         </div>
288        <div style="display:inline-block;vertical-align:middle;" tal:condition="python: isAudio and not deleted">
289         <metal:block metal:use-macro="here/macros_audioplayer/macros/audioplayer" />
290        </div>
291        </div>
292    </div>
293    <div id="tab_spacer" style="height:300px" tal:attributes="class python:test(not piece, 'hidden', '')">&nbsp;</div>
294    <div>
295    <div class="tab" id="tab_search" tal:attributes="class python:test(not piece, 'tab selected_tab', 'tab')" i18n:translate="label_or_search_from_pieces" onclick="clickedTab(this,'tab_sheet_search')">... or search from media pieces</div>
296    <div class="tab" id="tab_pieces" i18n:translate="label_browse_your_media" onclick="clickedTab(this,'tab_sheet_pieces')">browse your media</div>
297    <div class="tab" id="tab_collections" i18n:translate="label_browse_from_your_collections" onclick="clickedTab(this,'tab_sheet_collections')">browse from your collections</div>
298
299    <div class="tab_sheet" id="tab_sheet_search" tal:attributes="class python:test(not piece, 'tab_sheet selected_tab_sheet', 'tab_sheet')">
300    <p>
301    <input id="piece-search"
302            type="text"
303            value=""
304            name="piece-search"
305            onkeypress="if(event.keyCode==13) { document.getElementById('piece-searchbutton').onclick(); return false; }" />
306    <input id="piece-searchbutton"
307            type="button"
308            value="Search"
309            name="piece-searchbutton"
310            i18n:attributes="value label_search;" i18n:domain="plone"
311            onclick="search_for_pieces(this, event);"/>
312    </p>
313     <div class="tab_sheet_results">
314        <b class="message" style="display:none;">Query result message</b>
315        <div style="height:20px" class="visualClear">&nbsp;</div>
316        <div class="piece_chooser" style="display:none">Results go here</div>                                       
317    </div>
318    </div>
319   
320    <div class="tab_sheet" id="tab_sheet_pieces">
321     <div class="tab_sheet_results">
322        <b class="message" style="display:none;">Query result message</b>
323        <div style="height:20px" class="visualClear">&nbsp;</div>
324        <div class="piece_chooser" style="display:none"></div>                                       
325    </div>
326   </div>
327   <div class="tab_sheet" id="tab_sheet_collections">
328     <div class="tab_sheet_results">
329        <b class="message" style="display:none;">Query result message</b>
330        <div style="height:20px" class="visualClear">&nbsp;</div>
331        <div class="piece_chooser" style="display:none"></div>                                       
332    </div>
333  </div>
334
335    </div>
336    </div>
337
338     </tal:defines>
339</metal:define>
340
341  </body>
342</html>
Note: See TracBrowser for help on using the repository browser.