⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 editor.jsp

📁 cms是开源的框架
💻 JSP
📖 第 1 页 / 共 2 页
字号:
<%@ page import="
	org.opencms.editors.htmlarea.*,
	org.opencms.workplace.*,
	org.opencms.workplace.editors.*,
	org.opencms.workplace.help.*,
	org.opencms.jsp.*,
	org.opencms.main.*,
	java.util.*"
%><%
	
CmsJspActionElement cms = new CmsJspActionElement(pageContext, request, response);
CmsHtmlAreaEditor wp = new CmsHtmlAreaEditor(cms);
CmsEditorDisplayOptions options = wp.getEditorDisplayOptions();
Properties displayOptions = options.getDisplayOptions(cms);

int buttonStyle = wp.getSettings().getUserSettings().getEditorButtonStyle();

boolean showTableOptions = options.showElement("option.table", displayOptions);

//////////////////// start of switch statement 
	
switch (wp.getAction()) {

case CmsEditor.ACTION_SHOW_ERRORMESSAGE:
//////////////////// ACTION: display the common error dialog
	
	// do nothing here, only prevents editor content from being displayed!
	
break;
case CmsEditor.ACTION_PREVIEW:
//////////////////// ACTION: preview the page

	wp.actionPreview();

break;
case CmsEditor.ACTION_EXIT:
//////////////////// ACTION: exit the editor

	wp.actionExit();

break;
case CmsEditor.ACTION_SAVEEXIT:
//////////////////// ACTION: save the modified content and exit the editor

	wp.actionSave();
	wp.actionExit();

break;
case CmsEditor.ACTION_SAVE:
//////////////////// ACTION: save the modified content

	wp.actionSave();

case CmsDialog.ACTION_DEFAULT:
case CmsEditor.ACTION_SHOW:
default:
//////////////////// ACTION: show editor frame (default)

	// escape the content parameter to display it in the form
	wp.escapeParams();

%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=<%= wp.getEncoding() %>">
<title>(<%= wp.getSettings().getUser().getName() %>) - <%= wp.getParamResource() %></title>

<link rel=stylesheet type="text/css" href="<%= wp.getStyleUri("workplace.css") %>">

<script type="text/javascript" src="<%= wp.getEditorResourceUri() %>htmlarea-ocms.js"></script>
<script type="text/javascript">
// the content as escaped string
var __content = "<%= wp.getParamContent() %>";

// OpenCms workplace path
var workplacePath="<%= cms.link("/system/workplace/") %>";

// dialog windows
var dialogElementWindow = null;
var dialogPropertyWindow = null;

// display settings (disable style inputs for popups in HTMLArea, does not work properly!)
// var USE_LINKSTYLEINPUTS = <%= options.showElement("linkstyleinputs", displayOptions) %>;
USE_LINKSTYLEINPUTS = false;

// OpenCms context prefix, required for page editor because no link replacement is done here
var linkEditorPrefix = "<%= org.opencms.main.OpenCms.getSystemInfo().getOpenCmsContext() %>";

// inits the editors contents
function initContent() {
    document.EDITOR.edit1.value = decodeURIComponent(__content);
}

// saves the editors contents
function saveContent() {
    document.EDITOR.content.value = encodeURIComponent(getActiveEditor().getHTML());
}

//action on button click 
function buttonAction(para) {
	var _form = document.EDITOR;
	_form.action.value = "";
    switch (para) {
    case 1:
        // reload the editor
    	saveContent();
        _form.action.value = "<%= CmsEditor.EDITOR_SHOW %>";
        _form.target = "_self";
        _form.submit();
        break;
    case 2:
        // preview selected 
    	saveContent();
        _form.action.value = "<%= CmsEditor.EDITOR_PREVIEW %>";
        _form.target = "PREVIEW";
        _form.submit();
        break;
    case 3:
        // change element
    	saveContent();
        _form.action.value = "<%= CmsEditor.EDITOR_CHANGE_ELEMENT %>";
        _form.target = "_self";
        _form.submit();
        break;
    case 4:
        // open elements window
    	saveContent();
        dialogElementWindow = window.open("about:blank","DIALOGELEMENT","width=320,height=250,left=0,top=0,resizable=yes,scrollbars=no,location=no,menubar=no,toolbar=no,status=no,dependent=yes");
        document.ELEMENTS.submit();
        dialogElementWindow.focus();
        break;      
    case 5:
        // open properties window
    	saveContent();
        dialogPropertyWindow = window.open("about:blank","DIALOGPROPERTY","width=600,height=280,left=0,top=0,resizable=yes,scrollbars=yes,location=no,menubar=no,toolbar=no,status=no,dependent=yes");
        document.PROPERTIES.submit();
        dialogPropertyWindow.focus();
        break;
    case 6:
    	// exit without saving 
    	saveContent();
        _form.action.value = "<%= CmsEditor.EDITOR_EXIT %>";
        _form.target = "_top";
        _form.submit();
        break;
    case 7:
    	// save and exit
    	saveContent();
        _form.action.value = "<%= CmsEditor.EDITOR_SAVEEXIT %>";
        _form.target = "_top";
        _form.submit();
        break;
    case 8:
    	// save
    	saveContent();
        _form.action.value = "<%= CmsEditor.EDITOR_SAVE %>";
        _form.target = "_self";
        _form.submit();
        break;
    case 9:
    	// save and reload top editor frame
    	saveContent();
        _form.action.value = "<%= CmsEditor.EDITOR_SAVEACTION %>";
        _form.target = "_top";
        _form.submit();
        break;
    case 10:
    	// open the special character dialog popup
    	dialogCharWindow = window.open("dialogs/specialchars.jsp", "characters", "width=450, height=300, resizable=no, scrollbars=no, location=no, menubar=no, toolbar=no,dependent=yes, top=300, left=250");
    	break;
     case 11:
    	// open the anchor dialog popup
    	openAnchorDialog("<%= wp.key(org.opencms.workplace.editors.Messages.ERR_EDITOR_MESSAGE_NOSELECTION_0) %>");
    	break;
    	case 12:
    	// open the link dialog popup
    	openLinkDialog("<%= wp.key(org.opencms.workplace.editors.Messages.ERR_EDITOR_MESSAGE_NOSELECTION_0) %>");
    	break;
    	case 13:
        // clear document
        saveContent();
		_form.action.value = "<%= CmsEditor.EDITOR_CLEANUP %>";
		_form.target = "_self";
		_form.submit();
        break;		
    case 30:
		openOnlineHelp("/system/modules/org.opencms.editors.htmlarea/locales/<%= wp.getLocale() %>/help/index.html");
		break;		
    }
}

function deleteEditorContent(elementName, language) {
    if (elementName == document.EDITOR.<%= CmsDefaultPageEditor.PARAM_ELEMENTNAME %>.value && language == document.EDITOR.<%= CmsEditor.PARAM_ELEMENTLANGUAGE %>.value) {
        document.EDITOR.edit1.value = "";
    }
}

function changeElement(elementName, language) {
    if (elementName != document.EDITOR.<%= CmsDefaultPageEditor.PARAM_ELEMENTNAME %>.value && language == document.EDITOR.<%= CmsEditor.PARAM_ELEMENTLANGUAGE %>.value) {
        document.EDITOR.<%= CmsDefaultPageEditor.PARAM_ELEMENTNAME %>.value = elementName;
        buttonAction(3);   
    } else {
        buttonAction(1);
    }
}

function opensmallwin(url, name, w, h) {
    encodedurl = encodeURI(url);
    smallwindow = window.open(encodedurl, name, 'toolbar=no,location=no,directories=no,status=no,menubar=0,scrollbars=yes,resizable=yes,top=150,left=660,width='+w+',height='+h);
    if (smallwindow != null) {
        if (smallwindow.opener == null) {
            smallwindow.opener = self;
        }
    }
    return smallwindow;
}
  
// action for closing the window
function closeDialog() {
    if (dialogElementWindow) {
        window.dialogElementWindow.close();
    }
    if (dialogPropertyWindow) {
        window.dialogPropertyWindow.close();
    }
    if (dialogCharWindow) {
    	window.dialogCharWindow.close();
    }
    if (dialogAnchorWindow) {
    	window.dialogAnchorWindow.close();
    }
    if (document.EDITOR.<%= CmsDialog.PARAM_ACTION %>.value == "null" || document.EDITOR.<%= CmsDialog.PARAM_ACTION %>.value == "") {
        top.closeframe.closePage("<%= wp.getParamTempfile() %>", "<%= wp.getParamResource() %>");
    }        
}

// action when closing a popup window
function popupCloseAction(closeObj) {
	if (closeObj.refreshOpener && closeObj.refreshOpener == true) {
		buttonAction(1);
	} else if (closeObj.elemName) {
		changeElement(closeObj.elemName, closeObj.elemLocale);
	}
}

// confirm exit dialog
function confirmExit() {
	if (confirm("<%= wp.key(org.opencms.workplace.editors.Messages.GUI_EDITOR_MESSAGE_EXIT_0) %>")) {
		buttonAction(6);
	}
}
</script>

<script type="text/javascript">
   _editor_url = "<%= CmsWorkplace.getSkinUri() + "editors/htmlarea/" %>";
   _editor_lang = "<%= CmsHtmlAreaWidget.getHtmlAreaLocale(cms.getCmsObject(), wp.getLocale()) %>";
</script>

<script type="text/javascript" src="<%= CmsWorkplace.getSkinUri() + "editors/htmlarea/" %>htmlarea.js"></script>

<script type="text/javascript">

// load the HTMLArea plugin files
<%
	if (showTableOptions) {
	    // load HTML area plugin
		%>HTMLArea.loadPlugin("TableOperations");<%
	}
%>

HTMLArea.loadPlugin("ContextMenu");
// HTMLArea.loadPlugin("CSS");

function initEditor() {
	// initialize the editor content

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -