JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
593b5c0128fa3fbbc9cd7ab63175376195199fca
[wfpl-cms.git] / admin_pages.html
1 <!DOCTYPE html>
2
3 <html>
4 <head>
5         <title><!--~$title show {~-->~$host~ Admin: <!--~listing {~-->Manage Pages<!--~}~--><!--~form {~--><!--~id unset {~-->Add a new page<!--~}~--><!--~id {~-->Edit page "~title html~"<!--~}~--><!--~}~--><!--~}~--></title>
6         <!--~$head {~-->
7         <script src="inc/ckeditor/ckeditor.js?t=F0RD"></script>
8         <style>
9                 /* icon in cke buttons */
10                 .cke_button_icon.cke_button__wfpl_images_icon {
11                         background-image: url(/inc/ckeditor/plugins/icons.png?t=F0RD);
12                         background-position: 0 -936px;
13                 }
14                 .cke_wfpl_images_dialog * {
15                         white-space: normal !important;
16                 }
17                 .cke_wfpl_images_dialog h3 {
18                         margin-top: 10px;
19                         font-weight: bold;
20                         font-size: 18px;
21                 }
22                 .cke_wfpl_images_dialog strong {
23                         color: inherit;
24                 }
25                 .cke_wfpl_images_dialog p {
26                         font-size: 12px;
27                         line-height: 16px;
28                 }
29                 .cke_wfpl_images_dialog * + p {
30                         padding-top: 5px;
31                 }
32                 .cke_wfpl_images_dialog * a {
33                         text-decoration: underline;
34                         color: blue;
35                 }
36                 .cke_wfpl_images_dialog .cke_wfpl_thumbs {
37                         height: 270px;
38                         overflow-y: scroll;
39                 }
40                 .cke_wfpl_thumbs .cke_wfpl_thumb {
41                         width: 50px;
42                         height: 50px;
43                         padding: 10px;
44                         color: transparent;
45                         font-size: 10px;
46                         font-weight: bold;
47                         display: inline-block;
48                         overflow: hidden;
49                         text-align: center;
50                         background-position: 50% 50%;
51                         background-repeat: no-repeat;
52                         background-color: transparent;
53                         border: 2px solid white;
54                 }
55                 .cke_wfpl_thumbs .cke_wfpl_thumb:hover, .cke_wfpl_thumbs .cke_wfpl_thumb.selected {
56                         color: white;
57                         text-shadow: 1px 1px 2px #000;
58                         box-shadow: 1px 1px 6px #444;
59                         border: 2px solid #444;
60                 }
61         </style>
62         <script>
63                 window.cke_wfpl_images = {
64                         images: ~wfpl_images_json~,
65                         full_width: ~wfpl_image_width_full~,
66                         small_width: ~wfpl_image_width_small~,
67                         thumb_width: ~wfpl_image_width_thumb~,
68                         next_id: 0,
69                         selected: [],
70                         editors: []
71                 };
72                 var enc_html = function(str) {
73                         return str.replace(/[<>&]/g, function(i) { return '&#' + i.charCodeAt(0) + ';'; });
74                 };
75                 function cke_wfpl_images_thumb_click(plugin_id, element, image_id) {
76                         var thumbs = element.parentNode.children;
77                         var i, thumb;
78                         for (i = 0; i < thumbs.length; i++) {
79                                 thumb = thumbs[i];
80                                 if (thumb === element) {
81                                         if (thumb.className.substr(0, 9) !== 'selected ') {
82                                                 thumb.className = 'selected ' + thumb.className;
83                                         }
84                                 } else {
85                                         if (thumb.className.substr(0, 9) === 'selected ') {
86                                                 thumb.className = thumb.className.substr(9);
87                                         }
88                                 }
89                         }
90                         window.cke_wfpl_images.selected[plugin_id] = image_id;
91                 }
92                 function cke_wfpl_images_insert_click(plugin_id, align) {
93                         var selected = window.cke_wfpl_images.selected[plugin_id];
94                         var editor = window.cke_wfpl_images.editors[plugin_id];
95                         var image;
96                         var code, src, caption;
97                         if (selected == null) {
98                                 CKEDITOR.dialog.getCurrent().hide();
99                                 return;
100                         }
101                         image = window.cke_wfpl_images.images[selected];
102                         switch(align) {
103                                 case 'left':
104                                         code = '<div class="wfpl_li">'
105                                 break;
106                                 case 'centered':
107                                         code = '<div class="wfpl_ci">'
108                                 break;
109                                 case 'right':
110                                         code = '<div class="wfpl_ri">'
111                                 break;
112                                 case 'full':
113                                         code = '<div class="wfpl_fi">'
114                                 break;
115                         }
116                         code += '<div class="wfpl_i"'
117                         src =
118                                 image.src.substr(0, image.src.length - 4)
119                                 + 'w'
120                                 + window.cke_wfpl_images[align == 'full' ? 'full_width' : 'small_width']
121                                 + image.src.substr(image.src.length - 4);
122                         if (image.caption == '') {
123                                 caption = '&nbsp;';
124                         } else {
125                                 caption = enc_html(image.caption);
126                         }
127                         code += ' style="background-image: url(/' + src + ');';
128                         code += ' padding-top: ' + image.aspect;
129                         code += '">&nbsp</div>' + caption;
130                         code += '</div>'
131                         CKEDITOR.dialog.getCurrent().hide();
132                         CKEDITOR.currentInstance.insertElement(CKEDITOR.dom.element.createFromHtml(code));
133                 }
134                 CKEDITOR.plugins.add('wfpl_images', {
135                         init: function (editor) {
136                                 var plugin_id = window.cke_wfpl_images.editors.length;
137                                 window.cke_wfpl_images.editors.push(editor);
138                                 window.cke_wfpl_images.selected.push(window.cke_wfpl_images.images.length > 0 ? 0 : null);
139
140                                 editor.addCommand('wfpl_images', new CKEDITOR.dialogCommand('wfpl_images_dialog'));
141                                 editor.ui.addButton('wfpl_images', {
142                                         label: 'Insert Image',
143                                         command: 'wfpl_images',
144                                         toolbar: 'insert'
145                                 });
146                                 CKEDITOR.dialog.add('wfpl_images_dialog', function (api) {
147                                         var i, im, selected, thumbs;
148                                         selected = 'selected ';
149                                         thumbs = '<div class="cke_wfpl_thumbs">'
150                                         for (i in window.cke_wfpl_images.images) {
151                                                 im = window.cke_wfpl_images.images[i];
152                                                 thumbs += '<div class="'+selected+'cke_wfpl_thumb" onclick="return window.cke_wfpl_images_thumb_click('+plugin_id+', this, '+im.id+')" style="background-image: url('+im.src.substr(0, im.src.length - 4) + 'w' + window.cke_wfpl_images.thumb_width + im.src.substr(im.src.length - 4) + ')">'+ enc_html(im.name.length > 0 ? im.name : im.caption) + '</div>';
153                                                 selected = '';
154                                         }
155                                         thumbs += '</div>'
156                                         return {
157                                                 title: 'Insert Image',
158                                                 minWidth: 700,
159                                                 minHeight: 350,
160                                                 contents: [
161                                                         {
162                                                                 expand: true,
163                                                                 padding: 0,
164                                                                 elements: [
165                                                                         {
166                                                                                 type: 'html',
167                                                                                 html: '<div class="cke_wfpl_images_dialog">'
168                                                                                         + '<h3>Step 1: Choose an image to insert:</h3>'
169                                                                                         + thumbs
170                                                                                 + '<p>If you\'d like to insert an image not shown above, you can <a href="admin_images?new=1" target="_blank">upload it here</a>. Sorry, it won\'t appear here until you reload this editor page (hit Save below, then "edit this page" again.)</p>'
171                                                                                 + '</div>'
172                                                                         }
173                                                                 ]
174                                                         }
175                                                 ],
176                                                 buttons: [
177                                                         {
178                                                                 type: 'button',
179                                                                 label: 'Insert on Left',
180                                                                 className: 'cke_dialog_ui_button_ok',
181                                                                 onClick: function() {
182                                                                         cke_wfpl_images_insert_click(plugin_id, 'left');
183                                                                 }
184                                                         },
185                                                         {
186                                                                 type: 'button',
187                                                                 label: 'Insert Centered',
188                                                                 className: 'cke_dialog_ui_button_ok',
189                                                                 onClick: function() {
190                                                                         cke_wfpl_images_insert_click(plugin_id, 'centered');
191                                                                 }
192                                                         },
193                                                         {
194                                                                 type: 'button',
195                                                                 label: 'Insert on Right',
196                                                                 className: 'cke_dialog_ui_button_ok',
197                                                                 onClick: function() {
198                                                                         cke_wfpl_images_insert_click(plugin_id, 'right');
199                                                                 }
200                                                         },
201                                                         {
202                                                                 type: 'button',
203                                                                 label: 'Insert BIG',
204                                                                 className: 'cke_dialog_ui_button_ok',
205                                                                 onClick: function() {
206                                                                         cke_wfpl_images_insert_click(plugin_id, 'full');
207                                                                 }
208                                                         },
209                                                         CKEDITOR.dialog.cancelButton
210                                                 ]
211                                         };
212                                 });
213                         }
214                 });
215                 function make_wysiwyg(name) {
216                         CKEDITOR.replace(name, {
217                                 'contentsCss': 'css.css?m=~css.css mtime~',
218                                 'allowedContent': true,
219                                 bodyId: '~$basename~' + '_wysiwyg_' + name,
220                                 'stylesSet': [
221                                         { name: 'Paragraph', element: 'p'},
222                                         { name: 'Page Headline', element: 'h1'},
223                                         { name: 'Section Headline', element: 'h2'},
224                                         { name: 'Subsection Headline', element: 'h3'},
225                                         { name: 'Tagline (under headline)', element: 'h4', attributes: { class: 'tagline'}},
226                                         { name: 'Quote', element: 'p', attributes: { class: 'quote'}},
227                                         { name: 'Quote Author', element: 'p', attributes: { class: 'attrib'}},
228                                         { name: 'div (generic box)', element: 'div'}
229                                 ],
230                                 'uiColor': '#ccccff',
231                                 'removePlugins': 'forms,templates,smiley,pagebreak,save,newpage,preview,print',
232                                 'extraPlugins': 'wfpl_images',
233                                 'height': '300px',
234                                 'toolbar': [
235                                         ['Source'],
236                                         ['Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'SpellChecker', 'Scayt'],
237                                         ['Undo', 'Redo', '-', 'Find', 'Replace', '-', 'SelectAll', 'RemoveFormat'],
238                                         '/',
239                                         ['Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript'],
240                                         ['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', 'Blockquote'],
241                                         ['JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock'],
242                                         ['Link', 'Unlink', 'Anchor'],
243                                         ['wfpl_images', 'Table', 'HorizontalRule', 'SpecialChar', 'PageBreak'],
244                                         '/',
245                                         ['Styles', 'Font', 'FontSize'],
246                                         ['TextColor', 'BGColor'],
247                                         ['Maximize', 'ShowBlocks']
248                                 ]
249                         });
250                 }
251         </script>
252         <!--~}~-->
253
254 </head>
255
256 <body>
257 <!--~$body show {~-->
258
259         <!--~form {~-->
260                 <h1>~$host~ Admin Control Panel</h1>
261
262                 <h2><!--~id unset {~-->Add a new page<!--~}~--><!--~id {~-->Edit page "~title html~"<!--~}~--></h2>
263
264                 <form action="admin_pages" method="post"><!--~id {~--><div style="display: none"><input type="hidden" name="edit_id" value="~id attr~"></div><!--~}~-->
265
266                         <div class="caption">Title</div>
267                         <div class="field_notes">(This appears at the top of the page, in the window title-bar (by the close button) and as the headline/link of search engine results.)</div>
268                         <div class="field"><input type="text" name="title" value="~title attr~" class="wide_field"></div>
269
270                         <div class="caption">Filename</div>
271                         <div class="field_notes">(<!--~editing {~-->Careful: if you change this, be sure to update all links to this page<!--~}~--><!--~editing unset {~-->Please use only a-z, 0-9 and _ (underscore) in your filename. Please, no capitals, punctuation or spaces.<!--~}~-->)</div>
272                         <div class="field"><input type="text" name="filename" value="~filename attr~"></div>
273
274                         <div class="caption">Show in site-wide navigation links (optional)</div>
275                         <div class="field"><select name="navbar"><!--~navbar options~--></select></div>
276
277                         <div class="caption">Navigation Link Text</div>
278                         <div class="field_notes">(If you'd like this page to appear in the navigation with a shorter title.)</div>
279                         <div class="field"><input type="text" name="nav_title" value="~nav_title attr~"></div>
280
281                         <div class="caption">Page Contents</div>
282                         <div class="field_notes">
283                                 <ul class="first">
284                                         <li style="color: red; list-style: none">Please read these instructions in full:</li>
285                                         <li>If you don't see an editor below (with buttons in it) then please try this page in <a href="http://getfirefox.com">Mozilla FireFox</a> or <a href="http://www.google.com/chrome/">Google Chrome</a>.</li>
286                                         <li>If you're pasting from Microsoft Word, please use the "paste from word" button (looks like a clipboard with a "W").</li>
287                                         <li>To make a link, type the text to be clicked, select it, click the "Link" button (looks like a short chain) and paste the web address (where the link should point to) into the "URL" field. Exception: If you're making a link to another page on this site, please remove the "http://~$host~/" from the beginning of the "URL" field and set the "Protocol" to &lt;other&gt;.</li>
288                                         <li>To insert an image: place the cursor at the beginning of a line and click the "insert image" button in the editor. Note that you will only be able to insert images that you have already uploaded on the <a href="admin_images" target="_blank">manage images</a> page.</li>
289                                 </ul>
290                         </div>
291                         <div class="field"><textarea class="html_editor" rows="20" cols="50" id="content" name="content">~content html~</textarea><script>make_wysiwyg('content');</script></div>
292
293                         <!--
294                         <div class="caption">Description</div>
295                         <div class="field_notes">(Hidden description of this page, primarily for search engines.)</div>
296                         <div class="field"><textarea rows="9" cols="22" name="description">~description html~</textarea></div>
297
298                         <div class="caption">Keywords</div>
299                         <div class="field_notes">(Hidden words (up to 30) with commas between them for search engines)</div>
300                         <div class="field"><textarea rows="9" cols="22" name="keywords">~keywords html~</textarea></div>
301                         -->
302
303                         <div class="caption">&nbsp;</div>
304                         <div class="field"><input type="submit" name="save" value="Save"></div>
305
306                 </form>
307
308                 <div class="caption">&nbsp;</div>
309                 <div class="field"><a href="~filename nonempty {~~filename attr~~}~~filename empty {~admin_pages~id {~?id=~id~~}~~}~">Cancel</a></div>
310         <!--~}~-->
311
312         <!--~listing {~-->
313                 <h1>~$host~ Admin Control Panel</h1>
314                 <h2>Manage Pages</h2>
315
316                 <!--~rows once_if {~-->
317                         <p><a href="admin_pages?new=1">[Add a new page]</a></p>
318
319                         <table cellspacing="0" cellpadding="4" border="0" summary="" class="evenodd">
320                                 <tr>
321                                         <th><a href="?sort=~sorting-by-filename~filename">Filename</a></th>
322                                         <th><a href="?sort=~sorting-by-title~title">Title</a></th>
323                                         <th>&nbsp;</th>
324                                 </tr><!--~rows {~-->
325                                 <tr>
326                                         <td class="listing"><a href="admin_pages?edit_id=~id~">~filename html~<!--~filename empty {~--><em>(offline)</em><!--~}~--></a></td>
327                                         <td class="listing"><a href="admin_pages?edit_id=~id~">~title html~<!--~title empty {~--><em>(untitled)</em><!--~}~--></a></td>
328                                         <td><a href="admin_pages?admin_pages_delete_id=~id~" onclick="return confirm('Permanently delete?')">[delete]</a></td>
329                                 </tr><!--~}~-->
330
331                         </table>
332                 <!--~}~-->
333                 <!--~rows once_else {~-->
334                         <p>No pages in database.</p>
335                 <!--~}~-->
336
337                 <p><a href="admin_pages?new=1">[Add a new page]</a></p>
338         <!--~}~-->
339 <!--~}~-->
340 </body>
341 </html>