Kawai Wiki

Rev

Rev 53 | Rev 55 | 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
                          {
84
                                text: "Update",
85
                                click: function() { $('#editPageForm').submit(); }
86
                          },
87
                          {
88
                                text: "Close",
89
                                click: function() { $(this).dialog("close"); }
90
                          }
91
                      ]
92
           };
93
 
94
          myDialog.dialog(options);
95
 
96
          return myDialog;
97
        }
98
 
33 soliveira 99
 
41 soliveira 100
        function showEditPageDialog(pageName, lang) {
12 soliveira 101
 
41 soliveira 102
            $.getJSON('<mtw:contextPath />/Page.get.mtw?name=' + pageName + '&lang=' + lang, function(data) {
18 soliveira 103
 
28 soliveira 104
                $('#editPageTextArea').val(data.page.body);
105
                $('#editPageName').val(data.page.name);
41 soliveira 106
                $('#editPageLang').val(data.page.lang);
12 soliveira 107
 
28 soliveira 108
                myDialog = $('#editPageDialog');
109
                myDialog = prepareEditPageDialog(myDialog, 'Editing <i><font color="darkblue">' + pageName + "</font></i> in <i>" + data.page.language + "<i>...");
12 soliveira 110
                myDialog.dialog('open');
111
            });
112
 
113
            return false;
114
        }
49 soliveira 115
 
116
        function showListAllPagesDialog() {
117
 
118
            $.getJSON('<mtw:contextPath />/Page.list.mtw', function(data) {
119
 
120
                tableData = '';
121
                tableData += '<tr>';
122
                tableData += '<th>Name</th>';
123
                tableData += '<th>Language</th>';
124
                tableData += '<th>Front Page</th>';
125
                tableData += '<th>System Page</th>';
126
                tableData += '<th>Created By</th>';
127
                tableData += '<th>Modified By</th>';
128
                tableData += '<th>&nbsp;</th>';
129
                tableData += '</tr>';
130
 
131
                $.each(data.pages, function(i,page) {
132
 
133
                    modifiedBy = '';
134
                    if (page.modifiedById > 0) {
135
                        modifiedBy = page.modifiedBy.username;
136
                    }
137
 
138
                    systemPage = '';
139
                    if (page.systemPage == true) {
140
                        systemPage = 'X';
141
                    }
142
 
143
                    frontPage = '';
144
                    if (page.frontPage == true) {
145
                        frontPage = 'X';
146
                    }
52 soliveira 147
 
148
                    modifiedOnTitle = '';
149
                    if (page.formattedModifiedOn != null) {
150
                    	modifiedOnTitle = ' title="' + page.formattedModifiedOn + '"';
151
                    }
152
 
153
                    createdOnTitle = '';
154
                    if (page.formattedCreatedOn != null) {
155
                    	createdOnTitle = ' title="' + page.formattedCreatedOn + '"';
156
                    }
53 soliveira 157
 
158
                    viewCell = '&nbsp;';
159
                    if (page.CSS == false) {
160
                    	viewCell = '<a href="<mtw:contextPath/>/Page.mtw?name=' + page.name + '&lang=' + page.lang + '">View</a>';
161
                    }
54 soliveira 162
 
163
                    nameTitle = '';
164
                    if (page.title != null && page.title != '') {
165
                    	nameTitle = ' title="' + page.title + '"';
166
                    }
49 soliveira 167
 
168
                    tableData += '<tr>';
54 soliveira 169
                    tableData += '<td' + nameTitle + '>' + page.name + '</td>';
49 soliveira 170
                    tableData += '<td align="center">' + page.language + '</td>';
171
                    tableData += '<td align="center">' + frontPage + '</td>';
172
                    tableData += '<td align="center">' + systemPage + '</td>';
52 soliveira 173
                    tableData += '<td align="center"' + createdOnTitle + '>' + page.createdBy.username + '</td>';
174
                    tableData += '<td align="center"' + modifiedOnTitle + '>' + modifiedBy + '</td>';
53 soliveira 175
                    tableData += '<td align="center">' + viewCell + '</td>';
49 soliveira 176
                    tableData += '</tr>';
177
                });
178
 
179
                $('#listAllPagesTable').html(tableData);
180
 
181
                myDialog = $('#listAllPagesDialog');
182
                myDialog = prepareListAllPagesDialog(myDialog);
183
                myDialog.dialog('open');
184
             });
185
 
186
            return false;
187
        }
33 soliveira 188
 
36 soliveira 189
       	function showCreateNewPageDialog() {
190
 
42 soliveira 191
            $('#createNewPageFormName').val('<mtw:out value="bodyColumn.name" />');
192
            $('#createNewPageFormLang').val('<mtw:out value="bodyColumn.lang" />');
193
 
36 soliveira 194
            myDialog = $('#createNewPageDialog');
195
            myDialog = prepareCreateNewPageDialog(myDialog);
196
            myDialog.dialog('open');
197
 
198
            return false;
199
        }
200
 
201
        function prepareCreateNewPageDialog(myDialog) {
202
 
203
            options = {
38 soliveira 204
            	close: function() { clearCreateNewPageForm(); },
36 soliveira 205
                autoOpen: false,
206
                width: 800,
207
                modal: true,
208
                title: "Create New Page:",
209
                buttons: [
210
                          {
38 soliveira 211
                                text: "Create",
212
                                click: function() { $('#createNewPageForm').submit(); }
36 soliveira 213
                          },
214
                          {
215
                                text: "Cancel",
37 soliveira 216
                                click: function() {  $(this).dialog("close"); }
36 soliveira 217
                          }
218
                      ]
219
           };
220
 
221
          myDialog.dialog(options);
222
 
223
          return myDialog;
224
        }
225
 
33 soliveira 226
 
227
        function showLoginDialog() {
12 soliveira 228
 
42 soliveira 229
            $('#loginFormName').val('<mtw:out value="bodyColumn.name" />');
230
            $('#loginFormLang').val('<mtw:out value="bodyColumn.lang" />');
231
 
33 soliveira 232
            myDialog = $('#loginDialog');
233
            myDialog = prepareLoginDialog(myDialog);
234
            myDialog.dialog('open');
235
 
236
            return false;
237
        }
238
 
35 soliveira 239
        function clearLoginForm() {
240
        	$('#loginUsername').val('');
241
        	$('#loginPassword').val('');
242
        	$('#loginUsernameError').text('');
243
        	$('#loginPasswordError').text('');
36 soliveira 244
        }
33 soliveira 245
 
36 soliveira 246
        function clearCreateNewPageForm() {
247
        	$('#createNewPageName').val('');
248
        	$('#createNewPageTitle').val('');
249
        	$('#createNewPageLanguage').val('');
250
        	$('#createNewPageTextArea').val('');
39 soliveira 251
        	$('#createNewPageNameError').text('');
252
        	$('#createNewPageTitleError').text('');
253
        	$('#createNewPageLanguageError').text('');
254
        	$('#createNewPageBodyError').text('');
36 soliveira 255
        }
256
 
33 soliveira 257
      	function prepareLoginDialog(myDialog) {
258
 
259
            options = {
35 soliveira 260
            	close: function() { clearLoginForm(); },
33 soliveira 261
                autoOpen: false,
262
                width: 290,
263
                modal: true,
264
                title: "Login:",
265
                buttons: [
266
                          {
267
                                text: "Login",
268
                                click: function() { $('#loginForm').submit(); }
269
                          },
270
                          {
271
                                text: "Cancel",
37 soliveira 272
                                click: function() {  $(this).dialog("close"); }
33 soliveira 273
                          }
274
                      ]
275
           };
276
 
277
          myDialog.dialog(options);
278
 
279
          return myDialog;
280
        }
37 soliveira 281
 
282
      	function prepareConfirmDialog(myDialog) {
33 soliveira 283
 
37 soliveira 284
            options = {
285
                autoOpen: false,
286
                width: 300,
287
                modal: true,
288
                title: "Confirmation:",
289
                buttons: [
290
                          {
291
                                text: "Yes",
292
                                click: function() { $(this).dialog("close"); }
293
                          },
294
                          {
295
                                text: "No",
296
                                click: function() {  $(this).dialog("close"); }
297
                          }
298
                      ]
299
           };
300
 
301
          myDialog.dialog(options);
302
 
303
          return myDialog;
304
        }
305
 
306
         function showConfirmDialog() {
307
 
308
            myDialog = $('#confirmDialog');
309
            myDialog = prepareConfirmDialog(myDialog);
310
            myDialog.dialog('open');
311
 
312
            return false;
313
        }
314
 
12 soliveira 315
    </script>
316
 
317
</head>
318
 
319
<body class="composite">
320
 
321
<!-- For Testing -->
322
<div id="dialog" title="Dialog Title" style="display: none;">I'm in a dialog</div>
323
 
37 soliveira 324
<!-- Close Confirm -->
325
<div id="confirmDialog" style="display: none;">
326
	<span id="confirmMessage">The confirmation message goes here.</span>
327
</div>
328
 
33 soliveira 329
<!-- For Editing Pages -->
28 soliveira 330
<div id="editPageDialog" style="display: none;">
41 soliveira 331
<form id="editPageForm" action="<mtw:contextPath />/Page.edit.mtw" method="post">
28 soliveira 332
<input type="hidden" name="name" id ="editPageName" value="" />
41 soliveira 333
<input type="hidden" name="lang" id="editPageLang" value="" />
12 soliveira 334
<table>
335
    <tr>
336
        <td>&nbsp;</td>
337
    </tr>
28 soliveira 338
    <mtw:outError field="html">
12 soliveira 339
        <tr>
340
            <td colspan="2"><span class="Negative" style="font-weight: bold;"><mtw:out /></span></td>
341
        </tr>
342
    </mtw:outError>
343
    <tr>
28 soliveira 344
        <td colspan="2"><mtw:textarea id="editPageTextArea" name="body" style="width: 100%; height: 465px;" /></td>
12 soliveira 345
    </tr>
346
</table>
347
</form>
348
</div>
349
 
33 soliveira 350
<!-- For Login -->
351
<div id="loginDialog" style="display: none;">
352
		<form action="<mtw:contextPath />/Login.mtw" method="post" id="loginForm">
42 soliveira 353
            <input type="hidden" name="name" value="" id="loginFormName" />
354
            <input type="hidden" name="lang" value="" id="loginFormLang" />
33 soliveira 355
			<table>
356
				<tr>
357
					<td>
358
						Username:
359
					</td>
360
					<td>
35 soliveira 361
						<mtw:input id="loginUsername" name="username" size="20" maxlength="20" />
362
						<span id="loginUsernameError">
33 soliveira 363
						<mtw:outError field="username">
364
							<font color="red">
365
								<b><mtw:out /></b>
366
							</font>
367
						</mtw:outError>
35 soliveira 368
						</span>
33 soliveira 369
					</td>
370
				</tr>
371
				<tr>
372
					<td>
373
						Password:
374
					</td>
375
					<td>
35 soliveira 376
						<mtw:input id="loginPassword" name="password" type="password" size="20" maxlength="20" />
377
						<span id="loginPasswordError">
33 soliveira 378
						<mtw:outError field="password">
379
							<font color="red">
380
								<b><mtw:out /></b>
381
							</font>
382
						</mtw:outError>
35 soliveira 383
						</span>
33 soliveira 384
					</td>
385
				</tr>
386
			</table>
387
		</form>
388
</div>
389
 
49 soliveira 390
<!-- For displaying all pages -->
391
<div id="listAllPagesDialog" style="display: none;">
53 soliveira 392
    <table id="listAllPagesTable">
49 soliveira 393
    </table>
394
</div>
395
 
36 soliveira 396
<!-- Create New Page -->
397
<div id="createNewPageDialog" style="display: none;">
398
		<form action="<mtw:contextPath />/Page.add.mtw" method="post" id="createNewPageForm">
42 soliveira 399
            <input type="hidden" name="name" value="" id="createNewPageFormName" />
400
            <input type="hidden" name="lang" value="" id="createNewPageFormLang" />
36 soliveira 401
			<table>
402
				<tr>
403
					<td>
404
						Name:
405
					</td>
406
					<td>
39 soliveira 407
						<mtw:input id="createNewPageName" name="newPage.name" size="40" maxlength="30" />
36 soliveira 408
						<span id="createNewPageNameError">
39 soliveira 409
						<mtw:outError field="newPage.name">
36 soliveira 410
							<font color="red">
411
								<b><mtw:out /></b>
412
							</font>
413
						</mtw:outError>
414
						</span>
415
					</td>
416
				</tr>
417
				<tr>
418
					<td>
419
						Title:
420
					</td>
421
					<td>
39 soliveira 422
						<mtw:input id="createNewPageTitle" name="newPage.title" size="40" maxlength="60" />
36 soliveira 423
						<span id="createNewPageTitleError">
39 soliveira 424
						<mtw:outError field="newPage.title">
36 soliveira 425
							<font color="red">
426
								<b><mtw:out /></b>
427
							</font>
428
						</mtw:outError>
429
						</span>
430
					</td>
431
				</tr>
432
				<tr>
433
					<td>
434
						Language:
435
					</td>
436
					<td>
39 soliveira 437
						<mtw:select name="newPage.languageId" list="languages" id="createNewPageLanguage" emptyField="true" />
36 soliveira 438
						<span id="createNewPageLanguageError">
39 soliveira 439
						<mtw:outError field="newPage.languageId">
36 soliveira 440
							<font color="red">
441
								<b><mtw:out /></b>
442
							</font>
443
						</mtw:outError>
444
						</span>
445
					</td>
446
				</tr>
447
				<tr>
39 soliveira 448
        			<td colspan="2">
449
        				<mtw:textarea id="createNewPageTextArea" name="newPage.body" style="width: 100%; height: 465px;" />
450
        				<span id="createNewPageBodyError">
451
						<mtw:outError field="newPage.body">
452
							<font color="red">
453
								<b><mtw:out /></b>
454
							</font>
455
						</mtw:outError>
456
						</span>
457
        			</td>
36 soliveira 458
    			</tr>
459
			</table>
460
		</form>
461
</div>
33 soliveira 462
 
36 soliveira 463
 
12 soliveira 464
<div>
465
<table border="0">
466
    <tr>
39 soliveira 467
        <td><a href="<mtw:contextPath/>"><img src="images/logos/logo.png" border="0"></img></a></td>
22 soliveira 468
        <td align="right" valign="bottom">
469
            <mtw:isLogged negate="true">
33 soliveira 470
                <a href="#" onclick="return showLoginDialog();">Login</a>
22 soliveira 471
            </mtw:isLogged>
472
            <mtw:isLogged>
36 soliveira 473
                <a href="#" onclick="return showCreateNewPageDialog();">Create New Page</a> |
49 soliveira 474
                <a href="#" onclick="return showListAllPagesDialog();">List Pages</a> |
44 soliveira 475
                <mtw:hasAuthorization groups="admin">
41 soliveira 476
                <a href="#" onclick="return showEditPageDialog('CSS', 'en');" title="<k:editTooltip name="css" />">Edit CSS</a> |
44 soliveira 477
                </mtw:hasAuthorization>
22 soliveira 478
                <a href="<mtw:contextPath/>/Logout.mtw">Logout</a> (<mtw:out value="sessionUser.username" />)
479
            </mtw:isLogged>
480
            &nbsp;
39 soliveira 481
            <mtw:isLocale value="pt">
482
	            <a href="<mtw:urlWithLoc loc="pt" />"><img src="images/brazil.gif" border="0" width="20" height="13" style="border: 3px solid #ccc;" /></a>
483
    	        <a href="<mtw:urlWithLoc loc="en" />"><img src="images/usa.gif" width="20" height="13" border="0" style="border: 3px solid #fff;" /></a>
484
            </mtw:isLocale>
485
            <mtw:isLocale value="en">
486
            	<a href="<mtw:urlWithLoc loc="pt" />"><img src="images/brazil.gif" border="0" width="20" height="13" style="border: 3px solid #fff;" /></a>
487
            	<a href="<mtw:urlWithLoc loc="en" />"><img src="images/usa.gif" width="20" height="13" border="0" style="border: 3px solid #ccc;" /></a>
488
            </mtw:isLocale>
22 soliveira 489
            &nbsp;&nbsp;&nbsp;
490
        </td>
12 soliveira 491
    </tr>
492
</table>
493
</div>
494
 
495
<hr />
496
 
497
<div id="leftColumn"><mtw:isLogged>
44 soliveira 498
    <mtw:hasAuthorization groups="admin">
41 soliveira 499
        <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 500
    </mtw:hasAuthorization>
501
</mtw:isLogged>
20 soliveira 502
<div id="navcolumn">
503
    <div>
22 soliveira 504
    <mtw:out value="leftColumn.body" />
20 soliveira 505
    </div>
506
<br />
12 soliveira 507
</div>
508
 
509
</div>
510
 
511
<div id="bodyColumn">
28 soliveira 512
    <mtw:hasAuthorization groups="admin, editor">
41 soliveira 513
    <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>
28 soliveira 514
    </mtw:hasAuthorization>
24 soliveira 515
    <mtw:out value="bodyColumn.body" />
12 soliveira 516
</div>
517
 
518
<div class="clear">
519
<hr />
520
</div>
521
 
522
<div id="footer">
39 soliveira 523
<div class="xright">Copyright � 2011</div>
12 soliveira 524
<div class="clear">
525
<hr />
526
</div>
527
</div>
528
 
529
</body>
530
</html>