Kawai Wiki

Rev

Rev 60 | Rev 65 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
12 soliveira 1
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2
<%@taglib prefix="mtw" uri="http://www.mentaframework.org/tags-mtw/"%>
26 soliveira 3
<%@ taglib uri="/WEB-INF/tld/taglib.tld" prefix="k" %>
12 soliveira 4
 
5
<html>
6
<head>
7
 
8
<title>Mentawai Web Framework</title>
9
 
10
<style type="text/css" media="all">
31 soliveira 11
@import url("<mtw:contextPath/>/GenerateCSS.getCSS.css");
12 soliveira 12
</style>
13
 
14
<meta http-equiv="imagetoolbar" content="no" />
15
<meta http-equiv="imagetoolbar" content="false" />
16
 
17
<link rel="shortcut icon" type="image/x-icon" href="favicon.ico" />
18
<link rel="icon" type="image/gif" href="/favicon.gif" />
31 soliveira 19
<link rel="stylesheet" href="<mtw:contextPath/>/GenerateCSS.getPrintCSS.css" type="text/css" media="print" />
12 soliveira 20
 
21
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
22
<meta name="author" content="Sergio Oliveira Junior" />
23
<meta name="email" content="sergio.oliveira.jr@gmail.com" />
24
 
25
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css" />
26
<script type="text/javascript" src="jquery/jquery-1.6.4.min.js"></script>
27
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
28
 
29
<script language="JavaScript">
30
 
31
        $(document).ready(function() {
33 soliveira 32
 
33
        	<mtw:if test="showForm" value="login">
39 soliveira 34
				showLoginDialog();
35
			</mtw:if>
36
 
37
			<mtw:if test="showForm" value="add">
38
				showCreateNewPageDialog();
33 soliveira 39
			</mtw:if>
35 soliveira 40
 
41
			$('#loginDialog').keyup(function(e) {
42
    			if (e.keyCode == 13) {
43
        			$('#loginForm').submit();
44
    			}
45
			});
46
 
33 soliveira 47
 
12 soliveira 48
        });
49
 
28 soliveira 50
        function prepareEditPageDialog(myDialog, theTitle) {
12 soliveira 51
 
52
            options = {
53
                autoOpen: false,
54
                width: 800,
55
                modal: true,
56
                title: theTitle,
57
                buttons: [
58
                          {
59
                                text: "Save",
28 soliveira 60
                                click: function() { $('#editPageForm').submit(); }
12 soliveira 61
                          },
62
                          {
63
                                text: "Cancel",
64
                                click: function() { $(this).dialog("close"); }
65
                          }
66
                      ]
67
           };
68
 
69
          myDialog.dialog(options);
70
 
71
          return myDialog;
72
        }
49 soliveira 73
 
74
        function prepareListAllPagesDialog(myDialog) {
75
 
76
            options = {
77
                autoOpen: false,
78
                width: 800,
53 soliveira 79
                height: 450,
49 soliveira 80
                modal: true,
81
                title: 'Pages:',
82
                buttons: [
83
                          {
55 soliveira 84
                                text: "FrontPage",
56 soliveira 85
                                click: function() { $('#listAllPagesForm').attr('action', '<mtw:contextPath/>/Page.setFrontPage.mtw'); $('#listAllPagesForm').submit(); }
49 soliveira 86
                          },
87
                          {
55 soliveira 88
                                text: "Delete",
57 soliveira 89
                                click: function() { $('#listAllPagesForm').attr('action', '<mtw:contextPath/>/Page.delete.mtw'); $('#listAllPagesForm').submit(); }
55 soliveira 90
                          },
91
                          {
49 soliveira 92
                                text: "Close",
93
                                click: function() { $(this).dialog("close"); }
94
                          }
95
                      ]
96
           };
97
 
98
          myDialog.dialog(options);
99
 
100
          return myDialog;
101
        }
102
 
33 soliveira 103
 
41 soliveira 104
        function showEditPageDialog(pageName, lang) {
12 soliveira 105
 
41 soliveira 106
            $.getJSON('<mtw:contextPath />/Page.get.mtw?name=' + pageName + '&lang=' + lang, function(data) {
18 soliveira 107
 
28 soliveira 108
                $('#editPageTextArea').val(data.page.body);
109
                $('#editPageName').val(data.page.name);
41 soliveira 110
                $('#editPageLang').val(data.page.lang);
12 soliveira 111
 
28 soliveira 112
                myDialog = $('#editPageDialog');
113
                myDialog = prepareEditPageDialog(myDialog, 'Editing <i><font color="darkblue">' + pageName + "</font></i> in <i>" + data.page.language + "<i>...");
12 soliveira 114
                myDialog.dialog('open');
115
            });
116
 
117
            return false;
118
        }
63 soliveira 119
 
120
       	function showEditPreviewDialog(pageName, lang) {
49 soliveira 121
 
63 soliveira 122
            $.getJSON('<mtw:contextPath />/Page.getPreview.mtw?name=' + pageName + '&lang=' + lang, function(data) {
123
 
124
           		$('#createNewPageName').val(data.page.name);
125
        		$('#createNewPageTitle').val(data.page.title);
126
        		$('#createNewPageLanguage').val(data.page.languageId);
127
        		$('#createNewPageTextArea').val(data.page.body);
128
        		$('#createNewPageNameError').text('');
129
        		$('#createNewPageTitleError').text('');
130
        		$('#createNewPageLanguageError').text('');
131
        		$('#createNewPageBodyError').text('');
132
 
133
				showCreateNewPageDialog();
134
            });
135
 
136
            return false;
137
        }
138
 
49 soliveira 139
        function showListAllPagesDialog() {
140
 
141
            $.getJSON('<mtw:contextPath />/Page.list.mtw', function(data) {
142
 
143
                tableData = '';
144
                tableData += '<tr>';
55 soliveira 145
                tableData += '<th>&nbsp;</th>';
49 soliveira 146
                tableData += '<th>Name</th>';
147
                tableData += '<th>Language</th>';
148
                tableData += '<th>Created By</th>';
149
                tableData += '<th>Modified By</th>';
150
                tableData += '<th>&nbsp;</th>';
151
                tableData += '</tr>';
152
 
153
                $.each(data.pages, function(i,page) {
55 soliveira 154
 
155
                	pageName = page.name;
49 soliveira 156
 
157
                    modifiedBy = '';
158
                    if (page.modifiedById > 0) {
159
                        modifiedBy = page.modifiedBy.username;
160
                    }
161
 
162
                    if (page.systemPage == true) {
55 soliveira 163
                        pageName = '*' + pageName;
49 soliveira 164
                    }
165
 
166
                    if (page.frontPage == true) {
55 soliveira 167
                        pageName = '[' + pageName + ']';
49 soliveira 168
                    }
52 soliveira 169
 
170
                    modifiedOnTitle = '';
171
                    if (page.formattedModifiedOn != null) {
172
                    	modifiedOnTitle = ' title="' + page.formattedModifiedOn + '"';
173
                    }
174
 
175
                    createdOnTitle = '';
176
                    if (page.formattedCreatedOn != null) {
177
                    	createdOnTitle = ' title="' + page.formattedCreatedOn + '"';
178
                    }
53 soliveira 179
 
55 soliveira 180
                    radioCell = '&nbsp;';
53 soliveira 181
                    viewCell = '&nbsp;';
55 soliveira 182
                    if (page.CSS == false && page.systemPage == false) {
58 soliveira 183
                    	viewCell = '<a tabindex="-1" href="<mtw:contextPath/>/Page.mtw?name=' + page.name + '&lang=' + page.lang + '"><img src="<mtw:contextPath/>/images/view.png" /></a>';
55 soliveira 184
                    	if (page.frontPage == false) {
58 soliveira 185
                    		radioCell = '<input tabindex="-1" type="radio" name="pageId" id="pageId" value="' + page.id + '" />';
55 soliveira 186
                    	}
53 soliveira 187
                    }
54 soliveira 188
 
189
                    nameTitle = '';
190
                    if (page.title != null && page.title != '') {
191
                    	nameTitle = ' title="' + page.title + '"';
192
                    }
49 soliveira 193
 
194
                    tableData += '<tr>';
55 soliveira 195
                    tableData += '<td>' + radioCell + '</td>';
196
                    tableData += '<td' + nameTitle + '>' + pageName + '</td>';
49 soliveira 197
                    tableData += '<td align="center">' + page.language + '</td>';
52 soliveira 198
                    tableData += '<td align="center"' + createdOnTitle + '>' + page.createdBy.username + '</td>';
199
                    tableData += '<td align="center"' + modifiedOnTitle + '>' + modifiedBy + '</td>';
53 soliveira 200
                    tableData += '<td align="center">' + viewCell + '</td>';
49 soliveira 201
                    tableData += '</tr>';
202
                });
203
 
204
                $('#listAllPagesTable').html(tableData);
205
 
206
                myDialog = $('#listAllPagesDialog');
207
                myDialog = prepareListAllPagesDialog(myDialog);
208
                myDialog.dialog('open');
58 soliveira 209
                $('.ui-dialog :button').blur();
49 soliveira 210
             });
211
 
212
            return false;
213
        }
33 soliveira 214
 
36 soliveira 215
       	function showCreateNewPageDialog() {
216
 
42 soliveira 217
            $('#createNewPageFormName').val('<mtw:out value="bodyColumn.name" />');
218
            $('#createNewPageFormLang').val('<mtw:out value="bodyColumn.lang" />');
219
 
36 soliveira 220
            myDialog = $('#createNewPageDialog');
221
            myDialog = prepareCreateNewPageDialog(myDialog);
222
            myDialog.dialog('open');
223
 
224
            return false;
225
        }
226
 
227
        function prepareCreateNewPageDialog(myDialog) {
228
 
229
            options = {
38 soliveira 230
            	close: function() { clearCreateNewPageForm(); },
36 soliveira 231
                autoOpen: false,
232
                width: 800,
233
                modal: true,
234
                title: "Create New Page:",
235
                buttons: [
236
                          {
38 soliveira 237
                                text: "Create",
238
                                click: function() { $('#createNewPageForm').submit(); }
36 soliveira 239
                          },
240
                          {
60 soliveira 241
                              text: "Preview",
242
                              click: function() { $('#createNewPageFormPreview').val('true'); $('#createNewPageForm').submit(); }
243
                          },
244
                          {
36 soliveira 245
                                text: "Cancel",
37 soliveira 246
                                click: function() {  $(this).dialog("close"); }
36 soliveira 247
                          }
248
                      ]
249
           };
250
 
251
          myDialog.dialog(options);
252
 
253
          return myDialog;
254
        }
255
 
33 soliveira 256
 
257
        function showLoginDialog() {
12 soliveira 258
 
42 soliveira 259
            $('#loginFormName').val('<mtw:out value="bodyColumn.name" />');
260
            $('#loginFormLang').val('<mtw:out value="bodyColumn.lang" />');
261
 
33 soliveira 262
            myDialog = $('#loginDialog');
263
            myDialog = prepareLoginDialog(myDialog);
264
            myDialog.dialog('open');
265
 
266
            return false;
267
        }
268
 
35 soliveira 269
        function clearLoginForm() {
270
        	$('#loginUsername').val('');
271
        	$('#loginPassword').val('');
272
        	$('#loginUsernameError').text('');
273
        	$('#loginPasswordError').text('');
36 soliveira 274
        }
33 soliveira 275
 
36 soliveira 276
        function clearCreateNewPageForm() {
277
        	$('#createNewPageName').val('');
278
        	$('#createNewPageTitle').val('');
279
        	$('#createNewPageLanguage').val('');
280
        	$('#createNewPageTextArea').val('');
39 soliveira 281
        	$('#createNewPageNameError').text('');
282
        	$('#createNewPageTitleError').text('');
283
        	$('#createNewPageLanguageError').text('');
284
        	$('#createNewPageBodyError').text('');
36 soliveira 285
        }
286
 
33 soliveira 287
      	function prepareLoginDialog(myDialog) {
288
 
289
            options = {
35 soliveira 290
            	close: function() { clearLoginForm(); },
33 soliveira 291
                autoOpen: false,
292
                width: 290,
293
                modal: true,
294
                title: "Login:",
295
                buttons: [
296
                          {
297
                                text: "Login",
298
                                click: function() { $('#loginForm').submit(); }
299
                          },
300
                          {
301
                                text: "Cancel",
37 soliveira 302
                                click: function() {  $(this).dialog("close"); }
33 soliveira 303
                          }
304
                      ]
305
           };
306
 
307
          myDialog.dialog(options);
308
 
309
          return myDialog;
310
        }
37 soliveira 311
 
312
      	function prepareConfirmDialog(myDialog) {
33 soliveira 313
 
37 soliveira 314
            options = {
315
                autoOpen: false,
316
                width: 300,
317
                modal: true,
318
                title: "Confirmation:",
319
                buttons: [
320
                          {
321
                                text: "Yes",
322
                                click: function() { $(this).dialog("close"); }
323
                          },
324
                          {
325
                                text: "No",
326
                                click: function() {  $(this).dialog("close"); }
327
                          }
328
                      ]
329
           };
330
 
331
          myDialog.dialog(options);
332
 
333
          return myDialog;
334
        }
335
 
336
         function showConfirmDialog() {
337
 
338
            myDialog = $('#confirmDialog');
339
            myDialog = prepareConfirmDialog(myDialog);
340
            myDialog.dialog('open');
341
 
342
            return false;
343
        }
344
 
12 soliveira 345
    </script>
346
 
347
</head>
348
 
349
<body class="composite">
350
 
351
<!-- For Testing -->
352
<div id="dialog" title="Dialog Title" style="display: none;">I'm in a dialog</div>
353
 
37 soliveira 354
<!-- Close Confirm -->
355
<div id="confirmDialog" style="display: none;">
356
	<span id="confirmMessage">The confirmation message goes here.</span>
357
</div>
358
 
33 soliveira 359
<!-- For Editing Pages -->
28 soliveira 360
<div id="editPageDialog" style="display: none;">
41 soliveira 361
<form id="editPageForm" action="<mtw:contextPath />/Page.edit.mtw" method="post">
28 soliveira 362
<input type="hidden" name="name" id ="editPageName" value="" />
41 soliveira 363
<input type="hidden" name="lang" id="editPageLang" value="" />
12 soliveira 364
<table>
365
    <tr>
366
        <td>&nbsp;</td>
367
    </tr>
28 soliveira 368
    <mtw:outError field="html">
12 soliveira 369
        <tr>
370
            <td colspan="2"><span class="Negative" style="font-weight: bold;"><mtw:out /></span></td>
371
        </tr>
372
    </mtw:outError>
373
    <tr>
28 soliveira 374
        <td colspan="2"><mtw:textarea id="editPageTextArea" name="body" style="width: 100%; height: 465px;" /></td>
12 soliveira 375
    </tr>
376
</table>
377
</form>
378
</div>
379
 
33 soliveira 380
<!-- For Login -->
381
<div id="loginDialog" style="display: none;">
382
		<form action="<mtw:contextPath />/Login.mtw" method="post" id="loginForm">
42 soliveira 383
            <input type="hidden" name="name" value="" id="loginFormName" />
384
            <input type="hidden" name="lang" value="" id="loginFormLang" />
33 soliveira 385
			<table>
386
				<tr>
387
					<td>
388
						Username:
389
					</td>
390
					<td>
35 soliveira 391
						<mtw:input id="loginUsername" name="username" size="20" maxlength="20" />
392
						<span id="loginUsernameError">
33 soliveira 393
						<mtw:outError field="username">
394
							<font color="red">
395
								<b><mtw:out /></b>
396
							</font>
397
						</mtw:outError>
35 soliveira 398
						</span>
33 soliveira 399
					</td>
400
				</tr>
401
				<tr>
402
					<td>
403
						Password:
404
					</td>
405
					<td>
35 soliveira 406
						<mtw:input id="loginPassword" name="password" type="password" size="20" maxlength="20" />
407
						<span id="loginPasswordError">
33 soliveira 408
						<mtw:outError field="password">
409
							<font color="red">
410
								<b><mtw:out /></b>
411
							</font>
412
						</mtw:outError>
35 soliveira 413
						</span>
33 soliveira 414
					</td>
415
				</tr>
416
			</table>
417
		</form>
418
</div>
419
 
49 soliveira 420
<!-- For displaying all pages -->
421
<div id="listAllPagesDialog" style="display: none;">
56 soliveira 422
    <form action="#" method="post" id="listAllPagesForm">
53 soliveira 423
    <table id="listAllPagesTable">
49 soliveira 424
    </table>
56 soliveira 425
    </form>
49 soliveira 426
</div>
427
 
36 soliveira 428
<!-- Create New Page -->
429
<div id="createNewPageDialog" style="display: none;">
430
		<form action="<mtw:contextPath />/Page.add.mtw" method="post" id="createNewPageForm">
42 soliveira 431
            <input type="hidden" name="name" value="" id="createNewPageFormName" />
432
            <input type="hidden" name="lang" value="" id="createNewPageFormLang" />
60 soliveira 433
            <input type="hidden" name="isPreview" value="false" id="createNewPageFormPreview" />
36 soliveira 434
			<table>
435
				<tr>
436
					<td>
437
						Name:
438
					</td>
439
					<td>
39 soliveira 440
						<mtw:input id="createNewPageName" name="newPage.name" size="40" maxlength="30" />
36 soliveira 441
						<span id="createNewPageNameError">
39 soliveira 442
						<mtw:outError field="newPage.name">
36 soliveira 443
							<font color="red">
444
								<b><mtw:out /></b>
445
							</font>
446
						</mtw:outError>
447
						</span>
448
					</td>
449
				</tr>
450
				<tr>
451
					<td>
452
						Title:
453
					</td>
454
					<td>
39 soliveira 455
						<mtw:input id="createNewPageTitle" name="newPage.title" size="40" maxlength="60" />
36 soliveira 456
						<span id="createNewPageTitleError">
39 soliveira 457
						<mtw:outError field="newPage.title">
36 soliveira 458
							<font color="red">
459
								<b><mtw:out /></b>
460
							</font>
461
						</mtw:outError>
462
						</span>
463
					</td>
464
				</tr>
465
				<tr>
466
					<td>
467
						Language:
468
					</td>
469
					<td>
39 soliveira 470
						<mtw:select name="newPage.languageId" list="languages" id="createNewPageLanguage" emptyField="true" />
36 soliveira 471
						<span id="createNewPageLanguageError">
39 soliveira 472
						<mtw:outError field="newPage.languageId">
36 soliveira 473
							<font color="red">
474
								<b><mtw:out /></b>
475
							</font>
476
						</mtw:outError>
477
						</span>
478
					</td>
479
				</tr>
480
				<tr>
39 soliveira 481
        			<td colspan="2">
482
        				<mtw:textarea id="createNewPageTextArea" name="newPage.body" style="width: 100%; height: 465px;" />
483
        				<span id="createNewPageBodyError">
484
						<mtw:outError field="newPage.body">
485
							<font color="red">
486
								<b><mtw:out /></b>
487
							</font>
488
						</mtw:outError>
489
						</span>
490
        			</td>
36 soliveira 491
    			</tr>
492
			</table>
493
		</form>
494
</div>
33 soliveira 495
 
36 soliveira 496
 
12 soliveira 497
<div>
498
<table border="0">
499
    <tr>
39 soliveira 500
        <td><a href="<mtw:contextPath/>"><img src="images/logos/logo.png" border="0"></img></a></td>
22 soliveira 501
        <td align="right" valign="bottom">
502
            <mtw:isLogged negate="true">
33 soliveira 503
                <a href="#" onclick="return showLoginDialog();">Login</a>
22 soliveira 504
            </mtw:isLogged>
505
            <mtw:isLogged>
36 soliveira 506
                <a href="#" onclick="return showCreateNewPageDialog();">Create New Page</a> |
49 soliveira 507
                <a href="#" onclick="return showListAllPagesDialog();">List Pages</a> |
44 soliveira 508
                <mtw:hasAuthorization groups="admin">
41 soliveira 509
                <a href="#" onclick="return showEditPageDialog('CSS', 'en');" title="<k:editTooltip name="css" />">Edit CSS</a> |
44 soliveira 510
                </mtw:hasAuthorization>
22 soliveira 511
                <a href="<mtw:contextPath/>/Logout.mtw">Logout</a> (<mtw:out value="sessionUser.username" />)
512
            </mtw:isLogged>
513
            &nbsp;
39 soliveira 514
            <mtw:isLocale value="pt">
515
	            <a href="<mtw:urlWithLoc loc="pt" />"><img src="images/brazil.gif" border="0" width="20" height="13" style="border: 3px solid #ccc;" /></a>
516
    	        <a href="<mtw:urlWithLoc loc="en" />"><img src="images/usa.gif" width="20" height="13" border="0" style="border: 3px solid #fff;" /></a>
517
            </mtw:isLocale>
518
            <mtw:isLocale value="en">
519
            	<a href="<mtw:urlWithLoc loc="pt" />"><img src="images/brazil.gif" border="0" width="20" height="13" style="border: 3px solid #fff;" /></a>
520
            	<a href="<mtw:urlWithLoc loc="en" />"><img src="images/usa.gif" width="20" height="13" border="0" style="border: 3px solid #ccc;" /></a>
521
            </mtw:isLocale>
22 soliveira 522
            &nbsp;&nbsp;&nbsp;
523
        </td>
12 soliveira 524
    </tr>
525
</table>
526
</div>
527
 
528
<hr />
529
 
530
<div id="leftColumn"><mtw:isLogged>
44 soliveira 531
    <mtw:hasAuthorization groups="admin">
41 soliveira 532
        <div style="text-align: right; padding-right: 14px; padding-top: 6px;"><a href="#" onclick="return showEditPageDialog('LeftColumn', '<mtw:out value="leftColumn.language.locale" />');" title="<k:editTooltip name="leftColumn" />">Edit</a></div>
12 soliveira 533
    </mtw:hasAuthorization>
534
</mtw:isLogged>
20 soliveira 535
<div id="navcolumn">
536
    <div>
22 soliveira 537
    <mtw:out value="leftColumn.body" />
20 soliveira 538
    </div>
539
<br />
12 soliveira 540
</div>
541
 
542
</div>
543
 
544
<div id="bodyColumn">
28 soliveira 545
    <mtw:hasAuthorization groups="admin, editor">
63 soliveira 546
 
547
    <mtw:if test="bodyColumn.preview" value="true">
548
    <div style="text-align: left; padding-left: 14px;"><a href="#" onclick="return showEditPreviewDialog('<mtw:out value="bodyColumn.name" />', '<mtw:out value="bodyColumn.language.locale" />');" title="<k:editTooltip name="bodyColumn" />">This is a Preview</a></div>
549
    </mtw:if>
550
 
551
    <mtw:if test="bodyColumn.preview" value="false">
41 soliveira 552
    <div style="text-align: right; padding-right: 14px;"><a href="#" onclick="return showEditPageDialog('<mtw:out value="bodyColumn.name" />', '<mtw:out value="bodyColumn.language.locale" />');" title="<k:editTooltip name="bodyColumn" />">Edit</a></div>
63 soliveira 553
    </mtw:if>
554
 
28 soliveira 555
    </mtw:hasAuthorization>
24 soliveira 556
    <mtw:out value="bodyColumn.body" />
12 soliveira 557
</div>
558
 
559
<div class="clear">
560
<hr />
561
</div>
562
 
563
<div id="footer">
63 soliveira 564
<div class="xright">Copyright (c) 2011</div>
12 soliveira 565
<div class="clear">
566
<hr />
567
</div>
568
</div>
569
 
570
</body>
571
</html>