JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
80c7c2dd660c05d355e02ff1365ac1d2da8f1404
[wfpl-cms.git] / admin_pages.html
1 <!DOCTYPE html>
2
3 <html>
4 <head>
5         <title><!--~$title show {~-->~$host~ Admin: <!--~listings once_if {~-->Manage pages<!--~}~--><!--~form {~--><!--~id {~-->Add a new page<!--~}~--><!--~id unset {~-->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 {~
65                                 {
66                                         thumb: "~image thumb_src jsdq~",
67                                         image: "~image image_src jsdq~",
68                                         image_width: ~image image_width~,
69                                         image_height: ~image image_height~,
70                                         sizes: "~sizes jsdq~",
71                                         caption: "~caption jsdq~"
72                                 }~ sep {~,~}~~}~
73                         ],
74                         next_id: 0,
75                         selected: [],
76                         editors: []
77                 };
78                 function cke_wfpl_images_thumb_click(plugin_id, element, image_id) {
79                         var thumbs = element.parentNode.children;
80                         var i, thumb;
81                         for (i = 0; i < thumbs.length; i++) {
82                                 thumb = thumbs[i];
83                                 if (thumb === element) {
84                                         if (thumb.className.substr(0, 9) !== 'selected ') {
85                                                 thumb.className = 'selected ' + thumb.className;
86                                         }
87                                 } else {
88                                         if (thumb.className.substr(0, 9) === 'selected ') {
89                                                 thumb.className = thumb.className.substr(9);
90                                         }
91                                 }
92                         }
93                         window.cke_wfpl_images.selected[plugin_id] = image_id;
94                 }
95                 function cke_wfpl_images_insert_click(plugin_id, align) {
96                         var selected = window.cke_wfpl_images.selected[plugin_id];
97                         var editor = window.cke_wfpl_images.editors[plugin_id];
98                         var image;
99                         var code, width, height, src, size, caption;
100                         if (selected == null) {
101                                 CKEDITOR.dialog.getCurrent().hide();
102                                 return;
103                         }
104                         image = window.cke_wfpl_images.images[selected];
105                         switch(align) {
106                                 case 'left':
107                                         code = '<span class="wfpl_ifl"'
108                                 break;
109                                 case 'right':
110                                         code = '<span class="wfpl_ifr"'
111                                 break;
112                                 case 'centered': case 'full':
113                                         code = '<div class="wfpl_ic"'
114                                 break;
115                         }
116                         size = image.sizes.replace(/^\s+|\s+$/g, '').split(/\s\+/)[0];
117                         width = image.image_width;
118                         height = image.image_height;
119                         src = image.image;
120                         caption = image.caption;
121                         if (caption == '') {
122                                 caption = '&nbsp;';
123                         }
124                         if (align != 'full') {
125                                 var wh = size.split('x');
126                                 wh[0] = parseInt(wh[0]);
127                                 wh[1] = parseInt(wh[1]);
128                                 if (width / height > wh[0] / wh[1]) {
129                                         height = Math.round(height * wh[0] / width);
130                                         width = wh[0];
131                                 } else {
132                                         width = Math.round(width * wh[1] / height);
133                                         height = wh[1];
134                                 }
135                                 size = '' + wh[0] + '-' + wh[1]; // dash instead of x
136                                 src = src.substr(0, src.length - 4) + '-' + size + src.substr(src.length - 4);
137                         }
138                         code += ' style="background-image: url(/' + src + ');';
139                         code += ' width: ' + width + 'px;';
140                         code += ' padding-top: ' + height + 'px;';
141                         code += '">' + caption;
142                         switch(align) {
143                                 case 'left': case 'right':
144                                         code += '</span>'
145                                 break;
146                                 case 'centered': case 'full':
147                                         code += '</div>'
148                                 break;
149                         }
150                         CKEDITOR.dialog.getCurrent().hide();
151                         CKEDITOR.currentInstance.insertElement(CKEDITOR.dom.element.createFromHtml(code));
152                 }
153                 CKEDITOR.plugins.add('wfpl_images', {
154                         init: function (editor) {
155                                 var plugin_id = window.cke_wfpl_images.editors.length;
156                                 window.cke_wfpl_images.editors.push(editor);
157                                 window.cke_wfpl_images.selected.push(window.cke_wfpl_images.images.length > 0 ? 0 : null);
158
159                                 editor.addCommand('wfpl_images', new CKEDITOR.dialogCommand('wfpl_images_dialog'));
160                                 editor.ui.addButton('wfpl_images', {
161                                         label: 'Insert Image',
162                                         command: 'wfpl_images',
163                                         toolbar: 'insert'
164                                 });
165                                 CKEDITOR.dialog.add('wfpl_images_dialog', function (api) {
166                                         return {
167                                                 title: 'Insert Image',
168                                                 minWidth: 700,
169                                                 minHeight: 350,
170                                                 contents: [
171                                                         {
172                                                                 expand: true,
173                                                                 padding: 0,
174                                                                 elements: [
175                                                                         {
176                                                                                 type: 'html',
177                                                                                 html: '<div class="cke_wfpl_images_dialog">'
178                                                                                         + '<h3>Step 1: Choose an image to insert:</h3>'
179                                                                                         + "<div class=\"cke_wfpl_thumbs\">~wfpl_images {~ <div class=\"~ first {~selected ~}~cke_wfpl_thumb\" onclick=\"return window.cke_wfpl_images_thumb_click("+plugin_id+", this, ~id~)\" style=\"background-image: url(~image thumb_src attr jsdq~)\">~caption empty {~~name html jsdq~~}~~caption nonempty {~~caption html jsdq~~}~</div>~}~</div>"
180                                                                                 + '<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>'
181                                                                                 + '</div>'
182                                                                         }
183                                                                 ]
184                                                         }
185                                                 ],
186                                                 buttons: [
187                                                         {
188                                                                 type: 'button',
189                                                                 label: 'Insert on Left',
190                                                                 className: 'cke_dialog_ui_button_ok',
191                                                                 onClick: function() {
192                                                                         cke_wfpl_images_insert_click(plugin_id, 'left');
193                                                                 }
194                                                         },
195                                                         {
196                                                                 type: 'button',
197                                                                 label: 'Insert Centered',
198                                                                 className: 'cke_dialog_ui_button_ok',
199                                                                 onClick: function() {
200                                                                         cke_wfpl_images_insert_click(plugin_id, 'centered');
201                                                                 }
202                                                         },
203                                                         {
204                                                                 type: 'button',
205                                                                 label: 'Insert on Right',
206                                                                 className: 'cke_dialog_ui_button_ok',
207                                                                 onClick: function() {
208                                                                         cke_wfpl_images_insert_click(plugin_id, 'right');
209                                                                 }
210                                                         },
211                                                         {
212                                                                 type: 'button',
213                                                                 label: 'Insert BIG',
214                                                                 className: 'cke_dialog_ui_button_ok',
215                                                                 onClick: function() {
216                                                                         cke_wfpl_images_insert_click(plugin_id, 'full');
217                                                                 }
218                                                         },
219                                                         CKEDITOR.dialog.cancelButton
220                                                 ]
221                                         };
222                                 });
223                         }
224                 });
225                 function make_wysiwyg(name) {
226                         CKEDITOR.replace(name, {
227                                 'contentsCss': 'style.css?m=~style.css mtime~',
228                                 'allowedContent': true,
229                                 bodyId: '~$basename~' + '_wysiwyg_' + name,
230                                 'stylesSet': [
231                                         { name: 'Paragraph', element: 'p'},
232                                         { name: 'Page Headline', element: 'h1'},
233                                         { name: 'Section Headline', element: 'h2'},
234                                         { name: 'Subsection Headline', element: 'h3'},
235                                         { name: 'Tagline (under headline)', element: 'h4', attributes: { class: 'tagline'}},
236                                         { name: 'Quote', element: 'p', attributes: { class: 'quote'}},
237                                         { name: 'Quote Author', element: 'p', attributes: { class: 'attrib'}},
238                                         { name: 'div (generic box)', element: 'div'}
239                                 ],
240                                 'uiColor': '#ccccff',
241                                 'removePlugins': 'forms,templates,smiley,pagebreak,save,newpage,preview,print',
242                                 'extraPlugins': 'wfpl_images',
243                                 'height': '300px',
244                                 'toolbar': [
245                                         ['Source'],
246                                         ['Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'SpellChecker', 'Scayt'],
247                                         ['Undo', 'Redo', '-', 'Find', 'Replace', '-', 'SelectAll', 'RemoveFormat'],
248                                         '/',
249                                         ['Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript'],
250                                         ['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', 'Blockquote'],
251                                         ['JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock'],
252                                         ['Link', 'Unlink', 'Anchor'],
253                                         ['wfpl_images', 'Table', 'HorizontalRule', 'SpecialChar', 'PageBreak'],
254                                         '/',
255                                         ['Styles', 'Font', 'FontSize'],
256                                         ['TextColor', 'BGColor'],
257                                         ['Maximize', 'ShowBlocks']
258                                 ]
259                         });
260                 }
261         </script>
262         <!--~}~-->
263
264 </head>
265
266 <body>
267 <!--~$body show {~-->
268
269         <!--~form {~-->
270                 <h1>~$host~ Admin Control Panel</h1>
271
272                 <h2><!--~id unset {~-->Add a new page<!--~}~--><!--~id {~-->Edit page "~title html~"<!--~}~--></h2>
273
274                 <form action="admin_pages" method="post"><!--~id {~--><div style="display: none"><input type="hidden" name="edit_id" value="~id attr~"></div><!--~}~-->
275
276                         <div class="caption">Title</div>
277                         <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>
278                         <div class="field"><input type="text" name="title" value="~title attr~" class="wide_field"></div>
279
280                         <div class="caption">Filename</div>
281                         <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>
282                         <div class="field"><input type="text" name="filename" value="~filename attr~"></div>
283
284                         <div class="caption">Show in navigation links</div>
285                         <div class="field_notes">(On the left of every page.)</div>
286                         <div class="field"><select name="navbar"><!--~navbar options~--></select></div>
287
288                         <div class="caption">Navigation Link Text</div>
289                         <div class="field_notes">(If you'd like this page to appear in the navigation with a shorter title.)</div>
290                         <div class="field"><input type="text" name="nav_title" value="~nav_title attr~"></div>
291
292                         <div class="caption">Page Contents</div>
293                         <div class="field_notes">
294                                 <ul class="first">
295                                         <li style="color: red; list-style: none">Please read these instructions in full:</li>
296                                         <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>
297                                         <li>If you're pasting from Microsoft Word, please use the "paste from word" button (looks like a clipboard with a "W").</li>
298                                         <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>
299                                         <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>
300                                 </ul>
301                         </div>
302                         <div class="field"><textarea class="html_editor" rows="20" cols="50" id="content" name="content">~content html~</textarea><script>make_wysiwyg('content');</script></div>
303
304                         <div class="caption">Description</div>
305                         <div class="field_notes">(Hidden description of this page, primarily for search engines.)</div>
306                         <div class="field"><textarea rows="9" cols="22" name="description">~description html~</textarea></div>
307
308                         <div class="caption">Keywords</div>
309                         <div class="field_notes">(Hidden words (up to 30) with commas between them for search engines)</div>
310                         <div class="field"><textarea rows="9" cols="22" name="keywords">~keywords html~</textarea></div>
311
312                         <div class="caption">&nbsp;</div>
313                         <div class="field"><input type="submit" name="save" value="Save"></div>
314
315                 </form>
316
317                 <div class="caption">&nbsp;</div>
318                 <div class="field"><a href="~filename nonempty {~~filename attr~~}~~filename empty {~admin_pages~id {~?id=~id~~}~~}~">Cancel</a></div>
319         <!--~}~-->
320
321         <!--~listings once {~-->
322                 <h1>~$host~ Admin Control Panel</h1>
323                 <h2>Manage Pages</h2>
324
325                 <!--~listings once_if {~-->
326                         <p><a href="admin_pages?new=1">[Add a new page]</a></p>
327
328                         <table cellspacing="0" cellpadding="4" border="0" summary="" class="evenodd">
329                                 <tr><th>Title</th><th>Filename</th><th>&nbsp;</th></tr>
330                                 <!--~listings {~-->
331                                 <tr>
332                                         <td class="listing"><a href="admin_pages?edit_id=~id~">~title html~<!--~title empty {~--><em>(untitled)</em><!--~}~--></a></td>
333                                         <td class="listing"><a href="admin_pages?edit_id=~id~">~filename html~<!--~filename empty {~--><em>(offline)</em><!--~}~--></a></td>
334                                         <td><a href="admin_pages?admin_pages_delete_id=~id~" onclick="return confirm('Permanently delete?')">[delete this page]</a></td>
335                                 </tr>
336                                 <!--~}~-->
337
338                         </table>
339                 <!--~}~-->
340                 <!--~listings once_else {~-->
341                         <p>No pages in database.</p>
342                 <!--~}~-->
343
344                 <p><a href="admin_pages?new=1">[Add a new page]</a></p>
345         <!--~}~-->
346 <!--~}~-->
347 </body>
348 </html>