Kawai Wiki

Rev

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