modify the image editor page to use new style markup
[bse.git] / site / templates / admin / article_img.tmpl
1 <:.set article_type = cfg.entry("level names", article.level, "Article") -:>
2 <:.define image_move:>
3 <:-.if images.size > 1 -:>
4 <:.set up_url = loop.is_first ? ""
5   : cfg.admin_url2("add", "moveimgup", 
6                    { id: article.id,
7                      imageid: image.id,
8                      _t: "img",
9                      _csrfp: request.get_csrf_token("admin_move_image")
10                    }) -:>
11 <:.set down_url = loop.is_last ? ""
12   : cfg.admin_url2("add", "moveimgdown", 
13                    { id: article.id,
14                      imageid: image.id,
15                      _t: "img",
16                      _csrfp: request.get_csrf_token("admin_move_image")
17                    }) -:>
18 <:.call "make_arrows", down_url:down_url, up_url: up_url -:>
19 <:-.end if -:>
20 <:.end define:>
21 <:.wrap "admin/base.tmpl", title:"Image Wizard", js:"admin_edit.js" :>
22 <h1><:.if article.id == -1:>Global<:.else:><:= article_type :><:.end if:> Image Wizard</h1>
23
24 <:.call "messages":>
25
26 <p>| <a href="<:= cfg.admin_url("menu") :>">Admin menu</a> | 
27 <:.if article.generator =~ /Product/ :>
28   <a href="<:= cfg.admin_url("add", { id: article.id }) :>">Edit product</a> |
29   <a href="<:= cfg.admin_url("shopadmin") :>">Manage catalogs</a> |
30 <:.elsif article.id == cfg.entry("articles", "shop", 3) -:>
31   <a href="/cgi-bin/admin/add.pl?id=<:article id:>">Edit shop</a> |
32 <:.elsif article.id == -1 -:>
33   <a href="/cgi-bin/admin/add.pl?id=<:article id:>">Edit sections</a> |
34 <:.else -:>
35 <a href="/cgi-bin/admin/add.pl?id=<:article id:>"><:.if article.generator =~ /Catalog/:>Edit catalog<:.else:>Edit article<:.end if:></a> |
36 <:.end if :>
37
38 <:.if thumbs -:>
39   <a href="<:= cfg.admin_url("add", {id:article.id, "_t": "img", f_showfull:1}) :>">Full size images</a> |
40 <:.else -:>
41   <:.if can_thumbs -:>
42   <a href="<:= cfg.admin_url("add", {id:article.id, _t: "img"}):>">With Thumbnails</a> |
43   <:.end if :>
44 <:.end if:>
45 </p>
46 <:.if request.user_can("edit_images_add", article) -:>
47 <h2>Add new image</h2>
48
49 <form method="post" action="<:script:>" enctype="multipart/form-data" name="add">
50
51 <input type="hidden" name="level" value="<:= article.level :>" />
52 <input type="hidden" name="id" value="<:= article.id :>" />
53 <input type="hidden" name="parentid" value="<:= article.parentid :>" />
54 <input type="hidden" name="_t" value="img" />
55 <:csrfp admin_add_image hidden:>
56         <table>
57           <tr> 
58             <th>Image file to add:</th>
59             <td> 
60               <input type="file" name="image" /> 
61             </td>
62             <td class="help"><:help image file:> <:.call "error_img", field: "image":></td>
63           </tr>
64           <tr> 
65             <th>Alt text for image:</th>
66             <td> 
67               <input type="text" name="altIn" value="<:.call "old", field:"altIn":>" />
68             </td>
69             <td class="help"><:help image alt:> <:.call "error_img", field: "altIn":></td>
70           </tr>
71           <tr> 
72             <th>URL for image:</th>
73             <td> 
74               <input type="text" name="url" value="<:.call "old", field: "url":>" />
75             </td>
76             <td class="help"><:help image url:> <:.call "error_img", field: "url":></td>
77           </tr>
78           <tr> 
79             <th>Identifier for image:</th>
80             <td> 
81               <input type="text" name="name" value="<:.call "old", field: "name":>" />
82             </td>
83             <td class="help"><:help image name:> <:.call "error_img", field: "name":></td>
84           </tr>
85   <tr>
86     <th>Tags</th>
87     <td>
88       <input type="hidden" name="_save_tags" value="1" />
89       <div id="tags">
90       <:- .set tags = [ cgi.param("tags") ] :>
91       <:- .if tags.size == 0 :>
92         <:% tags.push("") :>
93       <:- .end if :>
94       <:.for tag in tags :>
95         <div class="tag"><input type="text" name="tags" value="<:= tag :>" /><:.call "error_img_n", field:"tags", index:loop.index :></div>
96       <:.end for:>
97       </div>
98     </td>
99     <td class="help"><:help edit tags:></td>
100   </tr>
101           <tr> 
102             <th>Storage:</th>
103             <td> 
104 <select name="storage">
105 <option value="">(Auto)</option>
106 <:iterator begin image_stores:>
107 <option value="<:image_store name:>"><:image_store description:></option>
108 <:iterator end image_stores:>
109 </select>
110             </td>
111             <td class="help"><:help image storage:> <:error_img storage:></td>
112           </tr>
113           <tr> 
114             <td  colspan="3" class="buttons"> 
115               <input type="submit" name="addimg" value="Add Image" />
116             </td>
117           </tr>
118         </table>
119 </form>
120 <:.end if -:>
121
122 <:.set images = [ article.images ] -:>
123 <:.set can_save = request.user_can("edit_images_save", article) -:>
124 <:.set can_delete = request.user_can("edit_images_delete", article) -:>
125 <:.set delete_token = request.get_csrf_token("admin_remove_image") -:>
126
127 <form method="post" action="<:= cfg.admin_url("add") :>" enctype="multipart/form-data" name="manage">
128 <input type="hidden" name="level" value="<:= article.level :>" />
129 <input type="hidden" name="id" value="<:= article.id :>" />
130 <input type="hidden" name="parentid" value="<:= article.parentid :>" />
131 <input type="hidden" name="_t" value="img" />
132 <:csrfp admin_save_images hidden:>
133   <h2>Manage images</h2>
134         <table class="editform images">
135 <:.if images.size:><:.if article.id != -1
136   and cfg.entry("basic", "auto_images", 1)-:>
137 <tr> 
138             <th colspan="5">First Image Position</th>
139           </tr>
140                   <tr> 
141             <td colspan="5"> 
142 <input type="radio" name="imagePos" value="tl" <:= article.imagePos eq "tl" ? "checked " : "":>/>Top Left &nbsp;
143 <input type="radio" name="imagePos" value="tr" <:= article.imagePos eq "tr" ? "checked " : "":>/>Top Right &nbsp;
144 <input type="radio" name="imagePos" value="bl" <:= article.imagePos eq "bl" ? "checked " : "":>/>Bottom Left &nbsp;
145 <input type="radio" name="imagePos" value="br" <:= article.imagePos eq "br" ? "checked " : "":>/>Bottom Right
146 <input type="radio" name="imagePos" value="xx" <:= article.imagePos eq "xx" ? "checked " : "":>/>Don't automatically insert images
147
148 <:help image position:>
149
150             </td>
151           </tr>
152 <:-.end if:>
153 <:.if thumbs:>
154           <tr> 
155             <th>Image</th>
156             <th colspan="2"> &nbsp;</th>
157             <th class="col_modify"> Modify</th>
158             <th class="col_move"> Move</th>
159           </tr>
160 <:.for image in images:>
161         <tr>
162           <td rowspan="5" class="col_thumbnail"><a href="#" onclick="window.open('<:= image.src:>', 'fullimage', 'width=<:= 20 + image.width:>,height=<:= 30 + image.height:>,location=no,status=no,menubar=no,scrollbars=yes'); return false;"><:= image.thumb("geo", "editor") |raw:></a></td>
163             <th>Alt text:</th>
164             <td class="col_field"> 
165               <:.if can_save:><input type="text" name="alt<:= image.id:>" value="<:.call "old", field:"alt" _ image.id, default: image.alt :>" size="32" /><:.else:><:= image.alt :><:.end if:>
166             </td>
167             <td class="col_modify" rowspan="5"> 
168 <:.if can_delete -:>
169   <b><a href="<:= cfg.admin_url("add", { id:article.id, "removeimg_" _ image.id:1, _t:"img", _csrfp: delete_token}):>" onClick="return window.confirm('Are you sure you want to delete this Image')">Delete</a></b>
170 <:-.end if:>
171 <:.if can_save -:>
172 <a href="<:= cfg.admin_url2("add", "edit_image", { id:article.id, image_id:image. id}):>">Edit</a>
173 <:-.end if-:>
174 </td>
175             <td class="col_move" rowspan="5">
176 <:.call "image_move":></td>
177           </tr>
178           <tr>        
179             <th>URL:</th>
180             <td class="col_field"> 
181               <:.if can_save :><input type="text" name="url<:= image.id :>" value="<:.call "old", field:"url" _ image.id, default:image.url :>" size="32" /><:.else:><:= image.url :><:.end if:>
182             </td>
183           </tr>
184           <tr>
185             <th>Identifier:</th>
186             <td class="col_field"> 
187               <:.if can_save :><input type="text" name="name<:= image.id:>" value="<:.call "old", field: "name" _ image.id, default: image.name :>" size="32" /> <:.call "error_img", field: "name" _ image.id :><:.else:><:= image.name :><:.end if:>
188             </td>
189         </tr>
190           <tr>
191             <th>Image file:</th>
192             <td class="col_field"> 
193               <:.if can_save :><input type="file" name="image<:= image.id:>" size="32" /> <:.call "error_img", field: "image" _ image.id:><:.else:><:= image.displayName :><:.end if:>
194             </td>
195         </tr>
196           <tr>
197             <th>Stored:</th>
198             <td class="col_field"> 
199               <:.if can_save -:>
200 <:.set stores = [ image_stores() ] -:>
201 <:.set oldstore = cgi.param("storage").defined
202        ? cgi.param("storage") : image.storage -:>
203
204 <select name="storage<:= image.id:>">
205 <option value="">(Auto)</option>
206 <:.for store in stores :>
207 <option value="<:= store.name:>"<:= oldstore eq store.name ? " selected" : "" :>><:= store.description:></option>
208 <:.end for -:>
209 </select><:.call "error_img", field: "storage" _ image.id:><:.else:><:= image.storage :><:.end if:>
210             </td>
211         </tr>
212 <:.end for:>          
213 <:.else :>
214           <tr> 
215             <th colspan="5">Image</th>
216           </tr>
217           <:.for image in images :> 
218           <tr> 
219             <td class="col_image" colspan="5"><:= image.inline("align", "center") |raw:></td>
220           </tr>
221           <tr> 
222             <th> Alt Text</th>
223             <th class="col_url"> URL</th>
224             <th> Identifier</th>
225             <th class="col_modify"> Modify</th>
226                         <th class="col_move"> Move</th>
227           </tr>
228           <tr> 
229             <td> 
230               <:.if can_save:><input type="text" name="alt<:= image.id:>" value="<:.call "old", field: "alt" _ image.id, default: image.alt:>" size="32" /><:.else:><:= image.alt :><:.end if:>
231             </td>
232             <td class="col_url"> 
233               <:.if can_save:><input type="text" name="url<:=image.id:>" value="<:.call "old", field: "url" _ image.id, default: image.url :>" size="32" /><:.else:><:= image.url :><:.end if:>
234             </td>
235             <td class="col_identifier"> 
236               <:.if can_save:><input type="text" name="name<:= image.id:>" value="<:.call "old", field: "name" _ image.id, default: image.name:>" size="32" /> <:.call "error_img", field: "name" _ image.id :><:.else:><:= image.name :><:.end if:>
237             </td>
238             <td class="col_modify"> 
239               <:.if can_save:><b><a href="<:= cfg.admin_url("add", { id:article.id, "removeimg_" _ image.id:1, _t:"img", _csrfp: delete_token}):>" onClick="return window.confirm('Are you sure you want to delete this Image')">Delete</a></b><:.end if:></td>
240             <td class="col_move"><:.call "image_move":></td>
241           </tr>
242           <:.if !loop.is_last :> 
243           <tr> 
244             <td colspan="5">&nbsp;</td>
245           </tr>
246           <:.end if:>
247           <: .end for :> 
248 <:.end if:>
249 <:.if can_save:>
250           <tr> 
251             <td colspan="5" class="buttons"> 
252               <input type="submit" name="process" value="Save changes" />
253             </td>
254           </tr>
255 <:.end if:>
256 <:.else-:>
257   <tr><td colspan="5" align="center" bgcolor="#FFFFFF">
258   <:-= article.id == -1 ? "There are no global images"
259                         : "No images are attached to this article" :></td>
260           </tr><:.end if:>
261         </table>
262
263 </form>