Kawai Wiki

Rev

Rev 155 | Rev 163 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@taglib prefix="mtw" uri="http://www.mentaframework.org/tags-mtw/"%>
<%@ taglib uri="/WEB-INF/tld/taglib.tld" prefix="k" %>

<html>
<head>

<title><mtw:out  value="bodyColumn.title" /></title>

<style type="text/css" media="all">
@import url("<mtw:contextPath/>/Page.getCSS.mtw?file=main.css");
</style>

<meta http-equiv="imagetoolbar" content="no" />
<meta http-equiv="imagetoolbar" content="false" />

<link rel="shortcut icon" type="image/x-icon" href="<mtw:contextPath />/images/kawai.ico" />
<link rel="icon" type="image/gif" href="<mtw:contextPath />/images/kawai.gif" />
<link rel="stylesheet" href="<mtw:contextPath/>/Page.getPrintCSS.mtw?file=print.css" type="text/css" media="print" />

<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<meta name="author" content="Sergio Oliveira Junior" />
<meta name="email" content="sergio.oliveira.jr@gmail.com" />

<link href="<mtw:contextPath/>/css/jquery-ui-1.8.16.custom.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="jquery/jquery-1.6.4.min.js"></script>
<script src="<mtw:contextPath/>/js/jquery-ui-1.8.16.custom.min.js"></script>

<link href="<mtw:contextPath />/uploadify/uploadify.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="<mtw:contextPath />/uploadify/swfobject.js"></script>
<script type="text/javascript" src="<mtw:contextPath />/uploadify/jquery.uploadify.v2.1.4.min.js"></script>

<!-- Include required JS files -->
<script type="text/javascript" src="<mtw:contextPath/>/sh/js/shCore.js"></script>
 
<!--
    At least one brush, here we choose JS. You need to include a brush for every 
    language you want to highlight
-->
<script type="text/javascript" src="<mtw:contextPath/>/sh/js/shBrushJava.js"></script>
 
<!-- Include *at least* the core style and default theme -->
<link href="<mtw:contextPath/>/sh/css/shCore.css" rel="stylesheet" type="text/css" />
<link href="<mtw:contextPath/>/sh/css/shThemeDefault.css" rel="stylesheet" type="text/css" />
 
<!-- Finally, to actually run the highlighter, you need to include this JS on your page -->
<script type="text/javascript">
     SyntaxHighlighter.all();
</script>

<!--  User JavaScript -->
<script type="text/javascript">

<mtw:out value="js.body" />

</script>


<script language="JavaScript">
    
        $(document).ready(function() {
        
                <mtw:if test="showForm" value="login">
                                showLoginDialog();
                        </mtw:if>

            <mtw:if test="showForm" value="addNewUser">
                showAddNewUserDialog(false);
            </mtw:if>
                        
                        <mtw:if test="showForm" value="add">
                                showCreateNewPageDialog();
                        </mtw:if>

            <mtw:outMessage>
                alert('<mtw:out />');
            </mtw:outMessage>

                        $('#loginDialog').keyup(function(e) {
                        if (e.keyCode == 13) {
                                $('#loginForm').submit();
                        }
                        });
                        
                        $('#file_upload').uploadify({
                                'uploader'  : '<mtw:contextPath />/uploadify/uploadify.swf',
                                'script'    : '<mtw:contextPath />/File.upload.mtw;jsessionid=<%= session.getId() %>',
                                'cancelImg' : '<mtw:contextPath />/uploadify/cancel.png',
                                'folder'    : '<mtw:contextPath />/uploads',
                                'scriptData': { 'JSESSIONID': '<%= session.getId() %>'},
                                'auto'      : true,
                                'multi'     : true,
                                'onComplete'  : function(event, ID, fileObj, response, data) {

                                        var resp = eval('(' + response + ')');
                
                                        if (resp.status == 'success') {
                                                $('#uploadResults').append('<tr><td style="color: blue;">' + resp.msg + '</td></tr>');
                                        } else if (resp.status == 'error') {
                                                $('#uploadResults').append('<tr><td style="color: red;">' + resp.msg + '</td></tr>');                                   
                                        }
                                }
                        });

            // ajax add new user:

                
            $('#usernameLoading').hide();
    
            $('#addNewUserUsername').blur( function() {
    
                $('#usernameMessage').hide();
    
                if ($('#addNewUserUsername').val().trim() != '') {

                    $('#usernameLoading').show();
    
                    $.post("<mtw:contextPath />/User.check.mtw", {
                        username : $('#addNewUserUsername').val()
                    }, function(response) {
                        $('#usernameMessage').fadeOut();
                        setTimeout("usernameResult('"
                                + escape(response) + "')", 400);
                    });
                }
    
                return false;
            });

        });
        
        function prepareEditPageDialog(myDialog, theTitle) {

            options = {
                autoOpen: false,
                width: 1000,
                modal: true,
                title: theTitle,
                buttons: [
                          {
                                text: "Save",
                                click: function() { $('#editPageForm').submit(); }
                          },
                          {
                                text: "Preview",
                                click: function() { $('#editPagePreview').val('true'); $('#editPageForm').submit(); }
                          },                          
                          {
                                text: "Cancel",
                                click: function() { $(this).dialog("close"); }
                          }
                      ]
           };

          myDialog.dialog(options);

          return myDialog;
        }

        function prepareShowPageDialog(myDialog, theTitle) {

            options = {
                autoOpen: false,
                width: 800,
                modal: true,
                title: theTitle,
                buttons: [
                          {
                                text: "Back",
                                click: function() { $(this).dialog("close"); }
                          },
                          {
                                text: "Close",
                                click: function() { $(this).dialog("close"); $('#listLastRevisionsDialog').dialog('close'); $('#listRevisionsDialog').dialog('close'); $('#listAllPagesDialog').dialog('close'); }
                          }
                      ]
           };

          myDialog.dialog(options);

          return myDialog;
        }
        
                function prepareFileListDialog(myDialog) {

            options = {
                autoOpen: false,
                width: 400,
                height: 300,
                modal: true,
                title: "Files uploaded:",
                buttons: [
                          {
                                text: "Close",
                                click: function() { $(this).dialog("close"); }
                          }
                      ]
           };

          myDialog.dialog(options);

          return myDialog;
        }        
                

        function prepareListAllPagesDialog(myDialog, showEdit) {

            listAllPagesButtons = [
                      {
                            text: "Close",
                            click: function() { $(this).dialog("close"); }
                      }];

            if (showEdit) {
                listAllPagesButtons = [
                          {
                                text: "FrontPage",
                                click: function() { $('#listAllPagesForm').attr('action', '<mtw:contextPath/>/Page.setFrontPage.mtw'); $('#listAllPagesForm').submit(); }
                          },
                          {
                                text: "Delete",
                                click: function() { $('#listAllPagesForm').attr('action', '<mtw:contextPath/>/Page.delete.mtw'); $('#listAllPagesForm').submit(); }
                          },
                          {
                                text: "Close",
                                click: function() { $(this).dialog("close"); }
                          }];
            }

            options = {
                autoOpen: false,
                width: 800,
                height: 450,
                modal: true,
                title: 'Pages:',
                buttons: listAllPagesButtons
           };

          myDialog.dialog(options);

          return myDialog;
        }

        function prepareListRevisionsDialog(myDialog, name, lang, showBackButton) {
        
                theButtons = [
                          {
                                text: "Back",
                                click: function() { $(this).dialog("close"); }
                          },
                          {
                                text: "Close",
                                click: function() { $(this).dialog("close"); $('#listAllPagesDialog').dialog('close'); }
                          }
                      ];
                      
                        if (!showBackButton) {
                        
                theButtons = [
                          {
                                text: "Close",
                                click: function() { $(this).dialog("close"); $('#listAllPagesDialog').dialog('close'); }
                          }
                      ];
                        }                      
            

            options = {
                autoOpen: false,
                width: 800,
                height: 450,
                modal: true,
                title: 'Revisions for ' + name + ' in ' + lang,
                buttons: theButtons
           };

          myDialog.dialog(options);

          return myDialog;
        }
        
        function prepareListLastRevisionsDialog(myDialog, language) {
        
                theButtons = [
                          {
                                text: "Close",
                                click: function() { $(this).dialog("close"); }
                          }
                      ];

            options = {
                autoOpen: false,
                width: 800,
                height: 450,
                modal: true,
                title: 'Latest revisions in ' + language,
                buttons: theButtons
           };

          myDialog.dialog(options);

          return myDialog;
        }
        
        
        function prepareFileUploadDialog(myDialog) {
        
            options = {
                autoOpen: false,
                width: 400,
                height: 300,
                modal: true,
                title: 'Uploading files...',
                buttons: [
                          {
                                text: "Close",
                                click: function() { $(this).dialog("close"); }
                          }
                      ]
           };

          myDialog.dialog(options);

          return myDialog;
        }        
        
        function showEditPageDialog(pageName, lang) {

            $.getJSON('<mtw:contextPath />/Page.get.mtw?name=' + pageName + '&lang=' + lang, function(data) {

                if (data.page.systemPage) {
                        $('.editPageTitleCell').hide();
                } else {
                        $('.editPageTitleCell').show();
                        $('#editPageTitle').val(data.page.title);
                }
                
                if (data.page.new) {
                        $('#editPageCommentCell').hide();
                } else {
                        $('#editPageCommentCell').show();
                        if (data.page.preview) {
                                $('#editPageComment').val(data.page.comment);
                        }
                }
                
                $('#editPageTextArea').val(data.page.body);
                $('#editPageName').val(data.page.name);
                $('#editPageLang').val(data.page.lang);

                myDialog = $('#editPageDialog');
                myDialog = prepareEditPageDialog(myDialog, 'Editing <i><font color="darkblue">' + pageName + "</font></i> in <i>" + data.page.language.name + "<i>...");
                myDialog.dialog('open');
            });
            
            return false;
        }
        
        function showFileListDialog() {

            $.getJSON('<mtw:contextPath />/File.listFiles.mtw', function(data) {

                                $('#fileListTable').html('');
            
                if (data.files.length == 0) {
                        $('#fileListTable').html('<tr><td align="center">No files uploaded yet!</td></tr>');
                } else {
                        $.each(data.files, function(i,file) {
                                                $('#fileListTable').append('<tr><td>' + file + '</td></tr>');                                                                           
                        });
                }

                myDialog = $('#fileListDialog');
                myDialog = prepareFileListDialog(myDialog);
                myDialog.dialog('open');
            });
            
            return false;
        }        

        function showShowPageDialog(pageName, lang, revision) {

            $.getJSON('<mtw:contextPath />/Page.get.mtw?name=' + pageName + '&lang=' + lang + '&revision=' + revision, function(data) {
            
                if (data.page.systemPage) {
                    $('.showPageTitleCell').hide();
                } else {
                    $('.showPageTitleCell').show();
                    $('#showPageTitle').val(data.page.title);
                }
                $('#showPageTextArea').val(data.page.body);

                theTitle = 'Showing <i><font color="darkblue">' + pageName + "</font></i> in <i>" + data.page.language.name + "<i>...";
                if (revision > 0) {
                    theTitle += ' (Revision #' + revision + ')';
                }

                myDialog = $('#showPageDialog');
                myDialog = prepareShowPageDialog(myDialog, theTitle);
                myDialog.dialog('open');
            });
            
            return false;
        }

        
        function showEditPreviewDialog(pageName, lang) {

            $.getJSON('<mtw:contextPath />/Page.getPreview.mtw?name=' + pageName + '&lang=' + lang, function(data) {

                if (data.page.systemPage) {
                        $('.editPageTitleCell').hide();
                } else {
                        $('.editPageTitleCell').show();
                        $('#editPageTitle').val(data.page.title);
                }
                
                if (data.page.new) {
                        $('#editPageCommentCell').hide();
                } else {
                        $('#editPageCommentCell').show();
                        if (data.page.preview) {
                                $('#editPageComment').val(data.page.comment);
                        }
                }
                
                
                $('#editPageTextArea').val(data.page.body);
                $('#editPageName').val(data.page.name);
                $('#editPageLang').val(data.page.lang);

                myDialog = $('#editPageDialog');
                myDialog = prepareEditPageDialog(myDialog, 'Editing <i><font color="darkblue">' + pageName + "</font></i> in <i>" + data.page.language.name + "<i>...");
                myDialog.dialog('open');
            });
            
            return false;
        }
        
        
        function showEditPreviewNewPageDialog(pageName, lang) {

            $.getJSON('<mtw:contextPath />/Page.getPreview.mtw?name=' + pageName + '&lang=' + lang, function(data) {
            
                        $('#createNewPageName').val(data.page.name);
                        $('#createNewPageTitle').val(data.page.title);
                        $('#createNewPageLanguage').val(data.page.languageId);
                        $('#createNewPageTextArea').val(data.page.body);
                        $('#createNewPageNameError').text('');
                        $('#createNewPageTitleError').text('');
                        $('#createNewPageLanguageError').text('');
                        $('#createNewPageBodyError').text('');
            
                                showCreateNewPageDialog();

                                $('#createPageLanguageCell').hide();
            });
            
            return false;
        }
        
        function showListAllPagesDialog(isAdmin) {

            $.getJSON('<mtw:contextPath />/Page.list.mtw', function(data) {

                tableData = '';
                tableData += '<tr>';
                if (isAdmin) tableData += '<th>&nbsp;</th>';
                tableData += '<th>Name</th>';
                tableData += '<th>Language</th>';
                tableData += '<th>Created By</th>';
                tableData += '<th>Modified By</th>';
                tableData += '<th>&nbsp;</th>';
                tableData += '<th>&nbsp;</th>';
                tableData += '<th>&nbsp;</th>';
                tableData += '</tr>';

                $.each(data.pages, function(i,page) {
                
                        pageName = page.name;

                    modifiedBy = '';
                    if (page.modifiedById > 0) {
                        modifiedBy = page.modifiedBy.username;
                    }

                    if (page.systemPage == true) {
                        pageName = '*' + pageName;
                    }

                    if (page.frontPage == true) {
                        pageName = '[' + pageName + ']';
                    }
                    
                    modifiedOnTitle = '';
                    if (page.formattedModifiedOn != null) {
                        modifiedOnTitle = ' title="' + page.formattedModifiedOn + '"';
                    }
                    
                    createdOnTitle = '';
                    if (page.formattedCreatedOn != null) {
                        createdOnTitle = ' title="' + page.formattedCreatedOn + '"';
                    }
                    
                    radioCell = '&nbsp;';
                    viewCell = '&nbsp;';
                    if (page.CSS == false && page.systemPage == false) {
                        viewCell = '<a title="View Page" tabindex="-1" href="<mtw:contextPath/>/Page.mtw?name=' + page.name + '&lang=' + page.lang + '"><img src="<mtw:contextPath/>/images/preview.png" border="0" /></a> ';
                        if (page.frontPage == false) {
                                radioCell = '<input tabindex="-1" type="radio" name="pageId" id="pageId" value="' + page.id + '" />';
                        }
                    }

                    viewRevisionsCell = '<a title="View Revisions" class="revisionLink" tabindex="-1" href="#" onclick="return showListRevisionsDialog(\'' + page.name + '\',\'' + page.lang + '\',\'' + page.language.name + '\', true);"><img src="<mtw:contextPath/>/images/folder.png" height="24" height="20" border="0" /></a>';
                    
                    nameTitle = '';
                    if (page.title != null && page.title != '') {
                        nameTitle = ' title="' + page.title + '"';
                    }

                    tableData += '<tr>';
                    if (isAdmin) tableData += '<td>' + radioCell + '</td>';
                    tableData += '<td' + nameTitle + '>' + pageName + '</td>';
                    tableData += '<td align="center">' + page.language.name + '</td>';
                    tableData += '<td align="center"' + createdOnTitle + '>' + page.createdBy.username + '</td>';
                    tableData += '<td align="center"' + modifiedOnTitle + '>' + modifiedBy + '</td>';
                    tableData += '<td align="center">' + viewCell + '</td>';
                    tableData += '<td align="center"><a tabindex="-1" title="View Html" href="#" onclick="return showShowPageDialog(\'' + page.name + '\',\'' + page.lang + '\', -1);"><img src="<mtw:contextPath/>/images/view.png" border="0" /></a></td>';
                    tableData += '<td align="center">' + viewRevisionsCell + '</td>';
                    tableData += '</tr>';
                });

                $('#listAllPagesTable').html(tableData);

                myDialogDiv = $('#listAllPagesDialog');
                myDialog = prepareListAllPagesDialog(myDialogDiv, isAdmin);
                myDialog.dialog('open');
                $('.ui-dialog :button').blur();
             });
            
            return false;
        }

        function showListRevisionsDialog(name, lang, language, showBackButton) {

            $.getJSON('<mtw:contextPath />/Page.getRevisions.mtw?name=' + name + '&lang=' + lang, function(data) {

                tableData = '';
                tableData += '<tr>';
                tableData += '<th>Revision</th>';
                tableData += '<th>Author</th>';
                tableData += '<th>Date</th>';
                
                if (data.isSystemPage == false) {
                    tableData += '<th>&nbsp;</th>';
                }
                tableData += '<th>&nbsp;</th>';
                tableData += '</tr>';

                $.each(data.revisions, function(i,revision) {
                
                        titleForComment = '';
                        if (revision.comment != null && revision.comment != '') {
                                titleForComment = ' title="' + revision.comment + '"';
                        }

                    tableData += '<tr>';
                    tableData += '<td' + titleForComment + '>' + revision.revision + '</td>';
                    tableData += '<td align="center">' + revision.user.username + '</td>';
                    tableData += '<td align="center">' + revision.formattedCreatedOn + '</td>';

                    if (data.isSystemPage == false) {
                        tableData += '<td align="center"><a title="View Page" tabindex="-1" href="<mtw:contextPath/>/Page.mtw?name=' + revision.name + '&lang=' + revision.lang + '&revision=' + revision.revision +'"><img src="<mtw:contextPath/>/images/preview.png" border="0" /></a></td>';
                    }
                    
                    tableData += '<td align="center"><a tabindex="-1" title="View Html" href="#" onclick="return showShowPageDialog(\'' + revision.name + '\',\'' + revision.lang + '\',' + revision.revision + ');"><img src="<mtw:contextPath/>/images/view.png" border="0" /></a></td>';

                    tableData += '</tr>';
                });

                $('#listRevisionsTable').html(tableData);
                myDialog = $('#listRevisionsDialog');
                myDialog = prepareListRevisionsDialog(myDialog, name, language, showBackButton);
                myDialog.dialog('open');
                $('.ui-dialog :button').blur();
             });
            
            return false;
        }
        
        function showListLastRevisionsDialog(lang, language, isLogged) {

            $.getJSON('<mtw:contextPath />/Page.getLastRevisions.mtw?lang=' + lang, function(data) {

                tableData = '';
                tableData += '<tr>';
                tableData += '<th>Page</th>';
                tableData += '<th>Revision</th>';
                tableData += '<th>Author</th>';
                tableData += '<th>Date</th>';
                tableData += '<th>Comment</th>';
                tableData += '<th>&nbsp;</th>';

                if (isLogged) {
                    tableData += '<th>&nbsp;</th>';
                }
                
                tableData += '</tr>';

                $.each(data.revisions, function(i,revision) {
                
                    tableData += '<tr>';
                    
                    pageName = revision.name;
                    
                    if (revision.frontPage) {
                        pageName = '[' + pageName + ']';
                    } else if (revision.systemPage) {
                        pageName = '*' + pageName;
                    }

                    nameTitle = '';
                    if (revision.title != null && revision.title != '') {
                        nameTitle = ' title="' + revision.title + '"';
                    }
                    
                    tableData += '<td' + nameTitle + ' align="center">' + pageName + '</td>';
                    tableData += '<td align="center">' + revision.revision + '</td>';
                    tableData += '<td align="center">' + revision.user.username + '</td>';
                    tableData += '<td align="center">' + revision.formattedCreatedOn + '</td>';
                    tableData += '<td align="left">' + revision.comment + '</td>';

                                        if (!revision.systemPage) {
                        tableData += '<td align="center"><a title="View Page" tabindex="-1" href="<mtw:contextPath/>/Page.mtw?name=' + revision.name + '&lang=' + revision.lang + '&revision=' + revision.revision +'"><img src="<mtw:contextPath/>/images/preview.png" border="0" /></a></td>';
                    } else {
                        tableData += '<td>&nbsp;</td>';
                    }

                    if (isLogged) {
                        tableData += '<td align="center"><a tabindex="-1" title="View Html" href="#" onclick="return showShowPageDialog(\'' + revision.name + '\',\'' + revision.lang + '\',' + revision.revision + ');"><img src="<mtw:contextPath/>/images/view.png" border="0" /></a></td>';
                    }
                    
                    tableData += '</tr>';
                });

                $('#listLastRevisionsTable').html(tableData);
                myDialog = $('#listLastRevisionsDialog');
                myDialog = prepareListLastRevisionsDialog(myDialog, language);
                myDialog.dialog('open');
                $('.ui-dialog :button').blur();
             });
            
            return false;
        }


        function showCreateNewPageDialog() {

            $('#createNewPageFormName').val('<mtw:out value="bodyColumn.name" />');
            $('#createNewPageFormLang').val('<mtw:out value="bodyColumn.lang" />');
            $('#createPageLanguageCell').show();

            myDialog = $('#createNewPageDialog');
            myDialog = prepareCreateNewPageDialog(myDialog);
            myDialog.dialog('open');
            
            return false;
        }
        
        function prepareCreateNewPageDialog(myDialog) {

            options = {
                close: function() { clearCreateNewPageForm(); },
                autoOpen: false,
                width: 800,
                modal: true,
                title: "Create New Page:",
                buttons: [
                          {
                                text: "Create",
                                click: function() { $('#createNewPageForm').submit(); }
                          },
                          {
                              text: "Preview",
                              click: function() { $('#createNewPageFormPreview').val('true'); $('#createNewPageForm').submit(); }
                          },
                          {
                                text: "Cancel",
                                click: function() {  $(this).dialog("close"); }
                          }
                      ]
           };

          myDialog.dialog(options);

          return myDialog;
        }
        
        function showFileUploadDialog() {
                        
                        $('#uploadResults').html('');
        
                myDialog = $('#fileUploadDialog');
                myDialog = prepareFileUploadDialog(myDialog);
                myDialog.dialog('open');
        }
        
    
        function showLoginDialog() {

            $('#loginFormName').val('<mtw:out value="bodyColumn.name" />');
            $('#loginFormLang').val('<mtw:out value="bodyColumn.lang" />');

            myDialog = $('#loginDialog');
            myDialog = prepareLoginDialog(myDialog);
            myDialog.dialog('open');

            return false;
        }

        function showAddNewUserDialog(hideUsernameMessage) {

            myDialog = $('#addNewUserDialog');
            myDialog = prepareAddNewUserDialog(myDialog, hideUsernameMessage);
            myDialog.dialog('open');

            return false;
        }
        
        function clearLoginForm() {
                $('#loginUsername').val('');
                $('#loginPassword').val('');
                $('#loginUsernameError').text('');
                $('#loginPasswordError').text('');
        }

        function clearAddNewUserForm() {
                $('#addNewUserUsername').val('');
                $('#addNewUserPassword').val('');
                $('#addNewUserPassconf').val('');
                $('#addNewUserGroup').val('');
                $('#usernameMessage').text('');
                $('#addNewUserPasswordError').text('');
                $('#addNewUserPassconfError').text('');
                $('#addNewUserGroupError').text('');
        }
        
        function clearCreateNewPageForm() {
                $('#createNewPageName').val('');
                $('#createNewPageTitle').val('');
                $('#createNewPageLanguage').val('');
                $('#createNewPageTextArea').val('');
                $('#createNewPageNameError').text('');
                $('#createNewPageTitleError').text('');
                $('#createNewPageLanguageError').text('');
                $('#createNewPageBodyError').text('');
        }
        
        function prepareLoginDialog(myDialog) {

            options = {
                close: function() { clearLoginForm(); },
                autoOpen: false,
                width: 290,
                modal: true,
                title: "Login:",
                buttons: [
                          {
                                text: "Login",
                                click: function() { $('#loginForm').submit(); }
                          },
                          {
                                text: "Cancel",
                                click: function() {  $(this).dialog("close"); }
                          }
                      ]
           };

          myDialog.dialog(options);

          return myDialog;
        }

        function prepareAddNewUserDialog(myDialog, hideUsernameMessage) {

                $('#usernameLoading').hide();
            if (hideUsernameMessage) $('#usernameMessage').text('');

            options = {
                close: function() { clearAddNewUserForm(); },
                autoOpen: false,
                width: 550,
                modal: true,
                title: "Add New User:",
                buttons: [
                          {
                                text: "Add",
                                click: function() { $('#addNewUserForm').submit(); }
                          },
                          {
                                text: "Cancel",
                                click: function() {  $(this).dialog("close"); }
                          }
                      ]
           };

          myDialog.dialog(options);

          return myDialog;
        }
        
        function prepareConfirmDialog(myDialog) {

            options = {
                autoOpen: false,
                width: 300,
                modal: true,
                title: "Confirmation:",
                buttons: [
                          {
                                text: "Yes",
                                click: function() { $(this).dialog("close"); }
                          },
                          {
                                text: "No",
                                click: function() {  $(this).dialog("close"); }
                          }
                      ]
           };

          myDialog.dialog(options);

          return myDialog;
        }
        
         function showConfirmDialog() {

            myDialog = $('#confirmDialog');
            myDialog = prepareConfirmDialog(myDialog);
            myDialog.dialog('open');

            return false;
        }
        
        function usernameResult(response) {
        
                $('#usernameLoading').hide();
        
                var res = unescape(response);
        
                if (res == "error") {
        
                    $('#usernameMessage')
                            .html(
                                    '<font color="red"><b>Error!</b></font>');
                    $('#usernameMessage').fadeIn();
        
                } else if (res == "success") {
        
                    $('#usernameMessage').html(
                            '<img src="<mtw:contextPath />/images/chk.gif" />');
                    $('#usernameMessage').fadeIn();
        
                } else if (res == "already") {
        
                    $('#usernameMessage')
                            .html(
                                    '<font color="red"><b>Username already exists!</b></font>');
                    $('#usernameMessage').fadeIn();
                }
            }
        </script>

</head>

<body class="composite">

<!--  For adding username -->
<div id="addNewUserDialog" style="display: none;">
        <form action="<mtw:contextPath />/User.add.mtw" method="post" id="addNewUserForm">
            <table>
                <tr>
                    <td width="10%">
                        Username:
                    </td>
                    <td>
                        <mtw:input name="username" id="addNewUserUsername" size="20" maxlength="30" />
                        <span id="usernameLoading">
                            <img src="<mtw:contextPath />/images/loading.gif" />
                        </span>
                        <span id="usernameMessage">
                            <mtw:outError field="username">
                                <font color="red">
                                    <b><mtw:out /></b>
                                </font>
                            </mtw:outError>
                        </span>
                    </td>
                </tr>
                <tr>
                    <td>
                        Password:
                    </td>
                    <td>
                        <mtw:input name="password" type="password" size="20" maxlength="20" id="addNewUserPassword" /> 
                        <span id="addNewUserPasswordError">
                            <mtw:outError field="password">
                                <font color="red">
                                    <b><mtw:out /></b>
                                </font>
                        </mtw:outError>
                        </span>
                    </td>
                </tr>
                <tr>
                    <td>
                        Confirm:
                    </td>
                    <td>
                        <mtw:input name="passconf" type="password" size="20" maxlength="20" id="addNewUserPassconf" /> 
                        <span id="addNewUserPassconfError">
                            <mtw:outError field="passconf">
                                <font color="red">
                                <b><mtw:out /></b>
                            </font>
                        </mtw:outError>
                        </span>
                    </td>
                </tr>
                <tr>
                    <td>
                        Group:
                    </td>
                    <td>
                        <mtw:select name="groupId" list="groups" emptyField="true" id="addNewUserGroup" />
                        <span id="addNewUserGroupError">
                        <mtw:outError field="groupId">
                            <font color="red">
                                <b><mtw:out /></b>
                            </font>
                        </mtw:outError>
                        </span>
                    </td>
                </tr>
            </table>
        </form>
</div>

<!-- For Testing -->
<div id="dialog" title="Dialog Title" style="display: none;">I'm in a dialog</div>

<!-- Close Confirm -->
<div id="confirmDialog" style="display: none;">
        <span id="confirmMessage">The confirmation message goes here.</span>
</div>

<!-- For file upload -->
<div id="fileUploadDialog" style="display: none;">
<br/>
<input id="file_upload" name="file_upload" type="file" />
<table cellspacing="2" cellpadding="5" id="uploadResults" style="margin-top: 10px;">
</table>
</div>

<!-- For files listing -->
<div id="fileListDialog" style="display: none;">
<table cellspacing="2" cellpadding="5" id="fileListTable" style="margin-top: 10px;">
</table>
</div>

<!-- For Editing Pages -->
<div id="editPageDialog" style="display: none;">
<form id="editPageForm" action="<mtw:contextPath />/Page.edit.mtw" method="post">
<input type="hidden" name="name" id ="editPageName" value="" />
<input type="hidden" name="lang" id="editPageLang" value="" />
<input type="hidden" name="isPreview" id="editPagePreview" value="false" />
<table border="0">
    <tr>
        <td>&nbsp;</td>
    </tr>
                <tr class="editPageTitleCell">
                    <td>
                        Title:&nbsp;&nbsp;&nbsp;&nbsp;
                        <mtw:input id="editPageTitle" name="title" size="40" maxlength="60" />
                        <span id="editPageTitleError">
                        <mtw:outError field="title">
                            <font color="red">
                                <b><mtw:out /></b>
                            </font>
                        </mtw:outError>
                        </span>
                    </td>
                </tr>
                <tr class="editPageTitleCell"><td colspan="2">&nbsp;</td></tr>
    <tr>
        <td><mtw:textarea id="editPageTextArea" name="body" style="width: 100%; height: 465px;" />
        <span id="editPageTextAreaError">
                        <mtw:outError field="body">
                            <font color="red">
                                <b><mtw:out /></b>
                            </font>
                        </mtw:outError>
                        </span>
        
        </td>
    </tr>
    
    <tr id="editPageCommentCell">
                    <td width="20%">
                        Edit comment: (<i>optional</i>) &nbsp;&nbsp;&nbsp;&nbsp;
                        <mtw:input id="editPageComment" name="comment" size="40" maxlength="60" />
                        <span id="editPageCommentError">
                        <mtw:outError field="comment">
                            <font color="red">
                                <b><mtw:out /></b>
                            </font>
                        </mtw:outError>
                        </span>
                    </td>
                </tr>
    
</table>
</form>
</div>

<!-- For Showing Page Html -->
<div id="showPageDialog" style="display: none;">
<form id="showPageForm">
<table>
    <tr>
        <td>&nbsp;</td>
    </tr>
                <tr class="showPageTitleCell">
                    <td>
                        Title:
                    </td>
                    <td>
                        <mtw:input id="showPageTitle" name="title" size="40" maxlength="60" extra="readonly=readonly" />
                    </td>
                </tr>
                <tr class="showPageTitleCell"><td>&nbsp;</td></tr>
    <tr>
        <td colspan="2">
        <mtw:textarea id="showPageTextArea" name="body" style="width: 100%; height: 465px;" extra="readonly=readonly" />
        </td>
    </tr>
</table>
</form>
</div>


<!-- For Login -->
<div id="loginDialog" style="display: none;">
                <form action="<mtw:contextPath />/Login.mtw" method="post" id="loginForm">
            <input type="hidden" name="name" value="" id="loginFormName" />
            <input type="hidden" name="lang" value="" id="loginFormLang" />
                        <table>
                                <tr>
                                        <td>
                                                Username:
                                        </td>
                                        <td>
                                                <mtw:input id="loginUsername" name="username" size="20" maxlength="20" />
                                                <span id="loginUsernameError">
                                                <mtw:outError field="username">
                                                        <font color="red">
                                                                <b><mtw:out /></b>
                                                        </font>
                                                </mtw:outError>
                                                </span>
                                        </td>
                                </tr>
                                <tr>
                                        <td>
                                                Password:
                                        </td>
                                        <td>
                                                <mtw:input id="loginPassword" name="password" type="password" size="20" maxlength="20" />
                                                <span id="loginPasswordError"> 
                                                <mtw:outError field="password">
                                                        <font color="red">
                                                                <b><mtw:out /></b>
                                                        </font>
                                                </mtw:outError>
                                                </span>
                                        </td>
                                </tr>
                        </table>
                </form>
</div>

<!-- For displaying all pages -->
<div id="listAllPagesDialog" style="display: none;">
    <form action="#" method="post" id="listAllPagesForm">
    <table id="listAllPagesTable">
    </table>
    </form>
</div>


<!-- For displaying revisions -->
<div id="listRevisionsDialog" style="display: none;">
    <table class="revisionsTable" id="listRevisionsTable">
    </table>
</div>

<!-- For displaying last revisions -->
<div id="listLastRevisionsDialog" style="display: none;">
    <table class="revisionsTable" id="listLastRevisionsTable">
    </table>
</div>


<!-- Create New Page -->
<div id="createNewPageDialog" style="display: none;">
                <form action="<mtw:contextPath />/Page.add.mtw" method="post" id="createNewPageForm">
            <input type="hidden" name="name" value="" id="createNewPageFormName" />
            <input type="hidden" name="lang" value="" id="createNewPageFormLang" />
            <input type="hidden" name="isPreview" value="false" id="createNewPageFormPreview" />
                        <table>
                                <tr>
                                        <td>
                                                Name:
                                        </td>
                                        <td>
                                                <mtw:input id="createNewPageName" name="newPage.name" size="40" maxlength="30" />
                                                <span id="createNewPageNameError">
                                                <mtw:outError field="newPage.name">
                                                        <font color="red">
                                                                <b><mtw:out /></b>
                                                        </font>
                                                </mtw:outError>
                                                </span>
                                        </td>
                                </tr>
                                <tr>
                                        <td>
                                                Title:
                                        </td>
                                        <td>
                                                <mtw:input id="createNewPageTitle" name="newPage.title" size="40" maxlength="60" />
                                                <span id="createNewPageTitleError">
                                                <mtw:outError field="newPage.title">
                                                        <font color="red">
                                                                <b><mtw:out /></b>
                                                        </font>
                                                </mtw:outError>
                                                </span>
                                        </td>
                                </tr>
                                <tr id="createPageLanguageCell">
                                        <td>
                                                Language:
                                        </td>
                                        <td>
                                                <mtw:select name="newPage.languageId" list="languages" id="createNewPageLanguage" emptyField="true" />
                                                <span id="createNewPageLanguageError">
                                                <mtw:outError field="newPage.languageId">
                                                        <font color="red">
                                                                <b><mtw:out /></b>
                                                        </font>
                                                </mtw:outError>
                                                </span>
                                        </td>
                                </tr>
                                <tr>
                                <td colspan="2">
                                        <mtw:textarea id="createNewPageTextArea" name="newPage.body" style="width: 100%; height: 465px;" />
                                        <span id="createNewPageBodyError">
                                                <mtw:outError field="newPage.body">
                                                        <font color="red">
                                                                <b><mtw:out /></b>
                                                        </font>
                                                </mtw:outError>
                                                </span>
                                </td>
                        </tr>
                        </table>
                </form>
</div>


<div>
<table border="0">
    <tr>
        <td>

        <k:kcode name="logo" />        
        <mtw:hasAuthorization groups="admin">
        
        <mtw:if test="logo.preview" value="false">
        <br/>&nbsp;&nbsp;&nbsp;&nbsp;<a href="#" style="font-size: 8px;" onclick="return showEditPageDialog('logo', '<mtw:out value="logo.lang" />');" title="<k:editTooltip name="logo" />">Edit Logo</a>
        </mtw:if>
        
        <mtw:if test="logo.preview" value="true">
        <br/>&nbsp;&nbsp;&nbsp;&nbsp;
        <span style="font-size: 10px; font-weight: bold;">Preview</span><span style="font-size: 8px;">&nbsp;&nbsp;-&nbsp;</span>
        <a style="font-size: 8px;" href="<mtw:contextPath/>/Page.savePreview.mtw?name=<mtw:out value="logo.name" />&lang=<mtw:out value="logo.language.locale" />">Save</a>&nbsp;
        <a style="font-size: 8px;" href="#" onclick="return showEditPreviewDialog('<mtw:out value="logo.name" />', '<mtw:out value="logo.language.locale" />');" title="<k:editTooltip name="logo" />">Edit</a>&nbsp;
        <a style="font-size: 8px;" href="<mtw:contextPath/>/Page.discardPreview.mtw?name=<mtw:out value="logo.name" />&lang=<mtw:out value="logo.language.locale" />">Discard</a>
        </mtw:if>
        
        </mtw:hasAuthorization>
        
        </td>
        <td align="right" valign="bottom">
            <mtw:isLogged negate="true">
                <a href="#" onclick="return showListLastRevisionsDialog('<mtw:out value="bodyColumn.language.locale" />', '<mtw:out value="bodyColumn.language" />', false);">Last Updates</a> |
                <a href="#" onclick="return showLoginDialog();">Login</a>
            </mtw:isLogged>
            <mtw:isLogged>
                <a href="#" onclick="return showCreateNewPageDialog();">Create New Page</a> |
                <a href="#" onclick="return showAddNewUserDialog(true);">Add New User</a> |
                <a href="#" onclick="return showListAllPagesDialog(<mtw:out value="sessionUser.admin" />);">List Pages</a> |
                
                <mtw:hasAuthorization groups="admin, editor">
                
                <mtw:if test="css.preview" value="true">
                <b>CSS</b> - 
                <a href="<mtw:contextPath/>/Page.savePreview.mtw?name=<mtw:out value="css.name" />&lang=<mtw:out value="css.language.locale" />">Save</a>&nbsp;
                <a href="#" onclick="return showEditPreviewDialog('<mtw:out value="css.name" />', '<mtw:out value="css.language.locale" />');" title="<k:editTooltip name="css" />">Edit</a>&nbsp;
                <a href="<mtw:contextPath/>/Page.discardPreview.mtw?name=<mtw:out value="css.name" />&lang=<mtw:out value="css.language.locale" />">Discard</a> |
                </mtw:if>
                
                <mtw:if test="css.preview" value="false">
                <a href="#" onclick="return showEditPageDialog('CSS', 'en');" title="<k:editTooltip name="css" />">Edit CSS</a> |
                </mtw:if>
                
                </mtw:hasAuthorization>
                
                <mtw:hasAuthorization groups="admin, editor">
                
                <mtw:if test="js.preview" value="true">
                <b>JavaScript</b> - 
                <a href="<mtw:contextPath/>/Page.savePreview.mtw?name=<mtw:out value="js.name" />&lang=<mtw:out value="js.language.locale" />">Save</a>&nbsp;
                <a href="#" onclick="return showEditPreviewDialog('<mtw:out value="js.name" />', '<mtw:out value="js.language.locale" />');" title="<k:editTooltip name="js" />">Edit</a>&nbsp;
                <a href="<mtw:contextPath/>/Page.discardPreview.mtw?name=<mtw:out value="js.name" />&lang=<mtw:out value="js.language.locale" />">Discard</a> |
                </mtw:if>
                
                <mtw:if test="js.preview" value="false">
                <a href="#" onclick="return showEditPageDialog('JavaScript', 'en');" title="<k:editTooltip name="js" />">Edit JavaScript</a> |
                </mtw:if>
                
                </mtw:hasAuthorization>
                
                <mtw:hasAuthorization groups="admin, editor">
                
                <a href="#" onclick="return showFileUploadDialog();">Upload Files</a> |
                <a href="#" onclick="return showFileListDialog();">List Files</a> |
                <a href="#" onclick="return showListLastRevisionsDialog('<mtw:out value="bodyColumn.language.locale" />', '<mtw:out value="bodyColumn.language" />', true);">Last Updates</a> |
                
                </mtw:hasAuthorization>
                
                
                <a href="<mtw:contextPath/>/Logout.mtw">Logout</a> (<mtw:out value="sessionUser.username" />)
            </mtw:isLogged>
            &nbsp;
            <%--
            <mtw:isLocale value="pt">
                    <a href="<mtw:urlWithLoc loc="pt" tagsToExclude="revision" />"><img src="images/brazil.gif" border="0" width="20" height="13" style="border: 3px solid #ccc;" /></a>
                <a href="<mtw:urlWithLoc loc="en" tagsToExclude="revision" />"><img src="images/usa.gif" width="20" height="13" border="0" style="border: 3px solid #fff;" /></a>
            </mtw:isLocale>
            <mtw:isLocale value="en">
                <a href="<mtw:urlWithLoc loc="pt" tagsToExclude="revision" />"><img src="images/brazil.gif" border="0" width="20" height="13" style="border: 3px solid #fff;" /></a>
                <a href="<mtw:urlWithLoc loc="en" tagsToExclude="revision" />"><img src="images/usa.gif" width="20" height="13" border="0" style="border: 3px solid #ccc;" /></a>
            </mtw:isLocale>
            --%>
            <k:listFlags />
            &nbsp;&nbsp;&nbsp;
        </td>
    </tr>
</table>
</div>

<hr />

<div id="leftColumn"><mtw:isLogged>
    <mtw:hasAuthorization groups="admin, editor">
    
        <mtw:if test="leftColumn.preview" value="true">
        <div style="text-align: left; padding-left: 8px; padding-top: 6px;">
            <b>Preview</b>
            &nbsp;-&nbsp;
            <a href="<mtw:contextPath/>/Page.savePreview.mtw?name=<mtw:out value="leftColumn.name" />&lang=<mtw:out value="leftColumn.language.locale" />">Save</a>&nbsp;&nbsp;
            <a href="#" onclick="return showEditPreviewDialog('<mtw:out value="leftColumn.name" />', '<mtw:out value="leftColumn.language.locale" />');" title="<k:editTooltip name="leftColumn" />">Edit</a>&nbsp;&nbsp;
            <a href="<mtw:contextPath/>/Page.discardPreview.mtw?name=<mtw:out value="leftColumn.name" />&lang=<mtw:out value="leftColumn.language.locale" />">Discard</a>
        </div>
        </mtw:if>

        <mtw:if test="leftColumn.preview" value="false">
        <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>
        &nbsp;&nbsp;
        <a href="#" onclick="return showListRevisionsDialog('LeftColumn','<mtw:out value="leftColumn.language.locale" />','<mtw:out value="leftColumn.language" />', false);">Revisions</a>
        </div>
        </mtw:if>
    
        
    </mtw:hasAuthorization>
</mtw:isLogged>
<div id="navcolumn">
    <div>
    <k:kcode name="leftColumn" />
    </div>
<br />
</div>

</div>

<div id="bodyColumn">
    <mtw:hasAuthorization groups="admin, editor">

    <mtw:if test="bodyColumn.preview" value="true">

        <mtw:if test="bodyColumn.new" value="true">
                        <div style="text-align: left; padding-left: 4px;">
                        <b>This is a Preview</b>
                        &nbsp;-&nbsp;
            <a href="<mtw:contextPath/>/Page.savePreview.mtw?name=<mtw:out value="bodyColumn.name" />&lang=<mtw:out value="bodyColumn.language.locale" />">Save</a>&nbsp;&nbsp;
            <a href="#" onclick="return showEditPreviewNewPageDialog('<mtw:out value="bodyColumn.name" />', '<mtw:out value="bodyColumn.language.locale" />');" title="<k:editTooltip name="bodyColumn" />">Edit</a>&nbsp;&nbsp;
                        <a href="<mtw:contextPath/>/Page.discardPreview.mtw?name=<mtw:out value="bodyColumn.name" />&lang=<mtw:out value="bodyColumn.language.locale" />">Discard</a>
                        </div>    
        </mtw:if>
        <mtw:if test="bodyColumn.new" value="false">
            <div style="text-align: left; padding-left: 4px;">
            <b>This is a Preview</b>
            &nbsp;-&nbsp;
            <a href="<mtw:contextPath/>/Page.savePreview.mtw?name=<mtw:out value="bodyColumn.name" />&lang=<mtw:out value="bodyColumn.language.locale" />">Save</a>&nbsp;&nbsp;
            <a href="#" onclick="return showEditPreviewDialog('<mtw:out value="bodyColumn.name" />', '<mtw:out value="bodyColumn.language.locale" />');" title="<k:editTooltip name="bodyColumn" />">Edit</a>&nbsp;&nbsp;
            <a href="<mtw:contextPath/>/Page.discardPreview.mtw?name=<mtw:out value="bodyColumn.name" />&lang=<mtw:out value="bodyColumn.language.locale" />">Discard</a>
                        </div>          
        </mtw:if>
    
    </mtw:if>

    <mtw:if test="bodyColumn.preview" value="false">
        <mtw:if test="bodyColumn.revision" value="true">
            <div style="text-align: left; padding-left: 4px;"><span title="<k:editTooltip name="bodyColumn" />"><b>Revision #<mtw:out value="bodyColumn.revisionNumber" /></b></span></div>
        </mtw:if>
    
        <mtw:if test="bodyColumn.revision" value="false">
            <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>
            &nbsp;&nbsp;
            <a href="#" onclick="return showListRevisionsDialog('<mtw:out value="bodyColumn.name" />','<mtw:out value="bodyColumn.language.locale" />','<mtw:out value="bodyColumn.language" />', false);">Revisions</a>
            </div>
        </mtw:if>
    </mtw:if>

    </mtw:hasAuthorization>
    <k:kcode name="bodyColumn" />
</div>

<div class="clear">
<hr />
</div>
<br/><br/><br/>
<div id="footer">
<div><center>Copyright (c) 2011 - Powered by <a href="http://kawai.mentaframework.org" target="_blank"><b>Kawai</b></a></center></div>
<div class="clear">
<hr />
</div>
</div>

</body>
</html>