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

📄 htmlarea.php

📁 很棒的在线教学系统
💻 PHP
📖 第 1 页 / 共 5 页
字号:
<?php    include("../../../config.php");    require_once($CFG->dirroot.'/lib/languages.php');    $id            = optional_param('id', SITEID, PARAM_INT);    $httpsrequired = optional_param('httpsrequired', 0, PARAM_BOOL); //flag indicating editor on page with required https    require_course_login($id);    $lastmodified = filemtime("htmlarea.php");    $lifetime = 1800;    // Commenting this out since it's creating problems    // where solution seem to be hard to find...    // http://moodle.org/mod/forum/discuss.php?d=34376    //if ( function_exists('ob_gzhandler') ) {    //    ob_start("ob_gzhandler");    //}    header("Content-type: application/x-javascript; charset: utf-8");  // Correct MIME type    header("Last-Modified: " . gmdate("D, d M Y H:i:s", $lastmodified) . " GMT");    header("Expires: " . gmdate("D, d M Y H:i:s", time() + $lifetime) . " GMT");    header("Cache-control: max_age = $lifetime");    header("Pragma: ");    $lang = current_language();    if (empty($lang)) {        $lang = "en";    }    if ($httpsrequired) {        // this is an ugly hack to allow partial operation of editor on pages that require https when loginhttps enabled        // please note that some popups still show nonsecurre items and fullscreen may not function properly in IE        $url = preg_replace('|https?://[^/]+|', '', $CFG->wwwroot).'/lib/editor/htmlarea/';    } else {        $url = $CFG->wwwroot.'/lib/editor/htmlarea/';    }    $strheading = get_string("heading", "editor");    $strnormal = get_string("normal", "editor");    $straddress = get_string("address", "editor");    $strpreformatted = get_string("preformatted", "editor");    $strlang = get_string('lang', 'editor');    $strmulti = get_string('multi', 'editor');?>// htmlArea v3.0 - Copyright (c) 2002, 2003 interactivetools.com, inc.// This copyright notice MUST stay intact for use (see license.txt).//// Portions (c) dynarch.com, 2003-2004//// A free WYSIWYG editor replacement for <textarea> fields.// For full source code and docs, visit http://www.interactivetools.com///// Version 3.0 developed by Mihai Bazon.//   http://dynarch.com/mishoo//// $Id: htmlarea.php,v 1.24.2.5 2008/07/10 04:11:34 scyrma Exp $if (typeof _editor_url == "string") {    // Leave exactly one backslash at the end of _editor_url    _editor_url = _editor_url.replace(/\x2f*$/, '/');} else {    //alert("WARNING: _editor_url is not set!  You should set this variable to the editor files path; it should preferably be an absolute path, like in '/htmlarea', but it can be relative if you prefer.  Further we will try to load the editor files correctly but we'll probably fail.");    _editor_url = '<?php echo $url; ?>';// we need relative path to site root for editor in pages wit hrequired https}// make sure we have a languageif (typeof _editor_lang == "string") {    _editor_lang = "en"; // should always be english in moodle.} else {    _editor_lang = "en";}// Creates a new HTMLArea object.  Tries to replace the textarea with the given// ID with it.function HTMLArea(textarea, config) {    if (HTMLArea.checkSupportedBrowser()) {        if (typeof config == "undefined") {            this.config = new HTMLArea.Config();        } else {            this.config = config;        }        this._htmlArea = null;        this._textArea = textarea;        this._editMode = "wysiwyg";        this.plugins = {};        this._timerToolbar = null;        this._timerUndo = null;        this._undoQueue = new Array(this.config.undoSteps);        this._undoPos = -1;        this._customUndo = true;        this._mdoc = document; // cache the document, we need it in plugins        this.doctype = '';        this.dropdowns = [];   // Array of select elements in the toolbar    }};// load some scripts(function() {    var scripts = HTMLArea._scripts = [ _editor_url + "htmlarea.js",                        _editor_url + "dialog.js",                        _editor_url + "popupwin.js" ];    var head = document.getElementsByTagName("head")[0];    // start from 1, htmlarea.js is already loaded    for (var i = 1; i < scripts.length; ++i) {        var script = document.createElement("script");        script.src = scripts[i];        head.appendChild(script);    }})();// cache some regexpsHTMLArea.RE_tagName = /(<\/|<)\s*([^ \t\n>]+)/ig;HTMLArea.RE_doctype = /(<!doctype((.|\n)*?)>)\n?/i;HTMLArea.RE_head    = /<head>((.|\n)*?)<\/head>/i;HTMLArea.RE_body    = /<body>((.|\n)*?)<\/body>/i;HTMLArea.RE_blocktag = /^(h1|h2|h3|h4|h5|h6|p|address|pre)$/i;HTMLArea.RE_junktag = /^\/($|\/)/;// Hopefully a complete list of tags that MSIEs parser will consider// as possible content tags. Retrieved from// http://www.echoecho.com/htmlreference.htmHTMLArea.RE_msietag  = /^\/?(a|abbr|acronym|address|applet|area|b|base|basefont|bdo|bgsound|big|blink|blockquote|body|br|button|caption|center|cite|code|col|colgroup|comment|dd|del|dfn|dir|div|dl|dt|em|embed|fieldset|font|form|frame|frameset|h1|h2|h3|h4|h5|h6|head|hr|html|i|iframe|ilayer|img|input|ins|isindex|kbd|keygen|label|layer|legend|li|link|map|marquee|menu|meta|multicol|nobr|noembed|noframes|nolayer|noscript|object|ol|optgroup|option|p|param|plaintext|pre|q|s|samp|script|select|server|small|spacer|span|strike|strong|style|sub|sup|table|tbody|td|textarea|tfoot|th|thead|title|tr|tt|u|ul|var)$/iHTMLArea.Config = function () {    this.version = "3.0";    this.width = "auto";    this.height = "auto";    // enable creation of a status bar?    this.statusBar = true;    // maximum size of the undo queue    this.undoSteps = 20;    // the time interval at which undo samples are taken    this.undoTimeout = 500; // 1/2 sec.    // the next parameter specifies whether the toolbar should be included    // in the size or not.    this.sizeIncludesToolbar = true;    // if true then HTMLArea will retrieve the full HTML, starting with the    // <HTML> tag.    this.fullPage = false;    // style included in the iframe document    this.pageStyle = "body { background-color: #fff; font-family: 'Times New Roman', Times; } \n .lang { background-color: #dee; }";    // set to true if you want Word code to be cleaned upon Paste    this.killWordOnPaste = true;    // BaseURL included in the iframe document    this.baseURL = document.baseURI || document.URL;    if (this.baseURL && this.baseURL.match(/(.*)\/([^\/]+)/))        this.baseURL = RegExp.$1 + "/";    // URL-s    this.imgURL = "images/";    this.popupURL = "popups/";    this.toolbar = [        [ "fontname", "space",          "fontsize", "space",          "formatblock", "space",          "language", "space",          "bold", "italic", "underline", "strikethrough", "separator",          "subscript", "superscript", "separator",          "clean", "separator", "undo", "redo" ],        [ "justifyleft", "justifycenter", "justifyright", "justifyfull", "separator",          "lefttoright", "righttoleft", "separator",          "insertorderedlist", "insertunorderedlist", "outdent", "indent", "separator",          "forecolor", "hilitecolor", "separator",          "inserthorizontalrule", "createanchor", "createlink", "unlink", "nolink", "separator",          "insertimage", "inserttable",          "insertsmile", "insertchar", "search_replace",          <?php if (!empty($CFG->aspellpath) && file_exists($CFG->aspellpath) && !empty($CFG->editorspelling)) {              echo '"separator","spellcheck",';            } ?>          "separator", "htmlmode", "separator", "popupeditor"]    ];    this.fontname = {        "Arial":       'arial,helvetica,sans-serif',        "Courier New":     'courier new,courier,monospace',        "Georgia":     'georgia,times new roman,times,serif',        "Tahoma":      'tahoma,arial,helvetica,sans-serif',        "Times New Roman": 'times new roman,times,serif',        "Verdana":     'verdana,arial,helvetica,sans-serif',        "Impact":           'impact',        "WingDings":       'wingdings'    };    this.fontsize = {        "1 (8 pt)":  "1",        "2 (10 pt)": "2",        "3 (12 pt)": "3",        "4 (14 pt)": "4",        "5 (18 pt)": "5",        "6 (24 pt)": "6",        "7 (36 pt)": "7"    };    this.formatblock = {        "":"",        "<?php echo $strheading ?> 1": "h1",        "<?php echo $strheading ?> 2": "h2",        "<?php echo $strheading ?> 3": "h3",        "<?php echo $strheading ?> 4": "h4",        "<?php echo $strheading ?> 5": "h5",        "<?php echo $strheading ?> 6": "h6",        "<?php echo $strnormal ?>": "p",        "<?php echo $straddress ?>": "address",        "<?php echo $strpreformatted ?>": "pre"    };    this.language = {        "<?php echo $strlang; ?>":"",        <?php        $strlangarray = '';        foreach ($LANGUAGES as $key => $name) {            $key = str_replace('_', '-', $key);            $strlangarray .= '"'.$key.'": "'.$key.'",';        }        $strlangarray .= '"'.$strmulti.'": "multi",';        foreach ($LANGUAGES as $key => $name) {            $key = str_replace('_', '-', $key);            $strlangarray .= '"'.$key.' ": "'.$key.'_ML",';        }        $strlangarray = substr($strlangarray, 0, -1);        echo $strlangarray;        ?>    };    this.customSelects = {};    function cut_copy_paste(e, cmd, obj) {        e.execCommand(cmd);    };    this.btnList = {        bold: [ "Bold", "ed_format_bold.gif", false, function(e) {e.execCommand("bold");} ],        italic: [ "Italic", "ed_format_italic.gif", false, function(e) {e.execCommand("italic");} ],        underline: [ "Underline", "ed_format_underline.gif", false, function(e) {e.execCommand("underline");} ],        strikethrough: [ "Strikethrough", "ed_format_strike.gif", false, function(e) {e.execCommand("strikethrough");} ],        subscript: [ "Subscript", "ed_format_sub.gif", false, function(e) {e.execCommand("subscript");} ],        superscript: [ "Superscript", "ed_format_sup.gif", false, function(e) {e.execCommand("superscript");} ],        justifyleft: [ "Justify Left", "ed_align_left.gif", false, function(e) {e.execCommand("justifyleft");} ],        justifycenter: [ "Justify Center", "ed_align_center.gif", false, function(e) {e.execCommand("justifycenter");} ],        justifyright: [ "Justify Right", "ed_align_right.gif", false, function(e) {e.execCommand("justifyright");} ],        justifyfull: [ "Justify Full", "ed_align_justify.gif", false, function(e) {e.execCommand("justifyfull");} ],        insertorderedlist: [ "Ordered List", "ed_list_num.gif", false, function(e) {e.execCommand("insertorderedlist");} ],        insertunorderedlist: [ "Bulleted List", "ed_list_bullet.gif", false, function(e) {e.execCommand("insertunorderedlist");} ],        outdent: [ "Decrease Indent", "ed_indent_less.gif", false, function(e) {e.execCommand("outdent");} ],        indent: [ "Increase Indent", "ed_indent_more.gif", false, function(e) {e.execCommand("indent");} ],        forecolor: [ "Font Color", "ed_color_fg.gif", false, function(e) {e.execCommand("forecolor");} ],        hilitecolor: [ "Background Color", "ed_color_bg.gif", false, function(e) {e.execCommand("hilitecolor");} ],        inserthorizontalrule: [ "Horizontal Rule", "ed_hr.gif", false, function(e) {e.execCommand("inserthorizontalrule");} ],        createanchor: [ "Create anchor", "ed_anchor.gif", false, function(e) {e.execCommand("createanchor", true);} ],        createlink: [ "Insert Web Link", "ed_link.gif", false, function(e) {e.execCommand("createlink", true);} ],        unlink: [ "Remove Link", "ed_unlink.gif", false, function(e) {e.execCommand("unlink");} ],        nolink: [ "No link", "ed_nolink.gif", false, function(e) {e.execCommand("nolink");} ],        insertimage: [ "Insert/Modify Image", "ed_image.gif", false, function(e) {e.execCommand("insertimage");} ],        inserttable: [ "Insert Table", "insert_table.gif", false, function(e) {e.execCommand("inserttable");} ],        htmlmode: [ "Toggle HTML Source", "ed_html.gif", true, function(e) {e.execCommand("htmlmode");} ],        popupeditor: [ "Enlarge Editor", "fullscreen_maximize.gif", true, function(e) {e.execCommand("popupeditor");} ],        about: [ "About this editor", "ed_about.gif", true, function(e) {e.execCommand("about");} ],        showhelp: [ "Help using editor", "ed_help.gif", true, function(e) {e.execCommand("showhelp");} ],        undo: [ "Undoes your last action", "ed_undo.gif", false, function(e) {e.execCommand("undo");} ],        redo: [ "Redoes your last action", "ed_redo.gif", false, function(e) {e.execCommand("redo");} ],        clean: [ "Clean Word HTML", "ed_wordclean.gif", false, function(e) {e.execCommand("killword"); }],        lefttoright: [ "Direction left to right", "ed_left_to_right.gif", false, function(e) {e.execCommand("lefttoright");} ],        righttoleft: [ "Direction right to left", "ed_right_to_left.gif", false, function(e) {e.execCommand("righttoleft");} ],        <?php if (!empty($CFG->aspellpath) && file_exists($CFG->aspellpath) && !empty($CFG->editorspelling)) {            echo 'spellcheck: ["Spell-check", "spell-check.gif", false, spellClickHandler ],'."\n";        }?>        insertsmile: ["Insert Smiley", "em.icon.smile.gif", false, function(e) {e.execCommand("insertsmile");} ],        insertchar: [ "Insert Char", "icon_ins_char.gif", false, function(e) {e.execCommand("insertchar");} ],        search_replace: [ "Search and replace", "ed_replace.gif", false, function(e) {e.execCommand("searchandreplace");} ]    };    // initialize tooltips from the I18N module and generate correct image path    for (var i in this.btnList) {        var btn = this.btnList[i];        btn[1] = _editor_url + this.imgURL + btn[1];        if (typeof HTMLArea.I18N.tooltips[i] != "undefined") {            btn[0] = HTMLArea.I18N.tooltips[i];        }    }};HTMLArea.Config.prototype.registerButton = function(id, tooltip, image, textMode, action, context) {    var the_id;    if (typeof id == "string") {        the_id = id;    } else if (typeof id == "object") {        the_id = id.id;    } else {        alert("ERROR [HTMLArea.Config::registerButton]:\ninvalid arguments");        return false;    }    // check for existing id    if (typeof this.customSelects[the_id] != "undefined") {        // alert("WARNING [HTMLArea.Config::registerDropdown]:\nA dropdown with the same ID already exists.");    }    if (typeof this.btnList[the_id] != "undefined") {        // alert("WARNING [HTMLArea.Config::registerDropdown]:\nA button with the same ID already exists.");    }    switch (typeof id) {        case "string": this.btnList[id] = [ tooltip, image, textMode, action, context ]; break;        case "object": this.btnList[id.id] = [ id.tooltip, id.image, id.textMode, id.action, id.context ]; break;    }};HTMLArea.Config.prototype.registerDropdown = function(object) {    // check for existing id    if (typeof this.customSelects[object.id] != "undefined") {        // alert("WARNING [HTMLArea.Config::registerDropdown]:\nA dropdown with the same ID already exists.");    }    if (typeof this.btnList[object.id] != "undefined") {        // alert("WARNING [HTMLArea.Config::registerDropdown]:\nA button with the same ID already exists.");    }    this.customSelects[object.id] = object;};HTMLArea.Config.prototype.hideSomeButtons = function(remove) {    var toolbar = this.toolbar;    for (var i in toolbar) {        var line = toolbar[i];        for (var j = line.length; --j >= 0; ) {            if (remove.indexOf(" " + line[j] + " ") >= 0) {                var len = 1;                if (/separator|space/.test(line[j + 1])) {                    len = 2;                }                line.splice(j, len);            }        }    }};/** Helper function: replace all TEXTAREA-s in the document with HTMLArea-s. */HTMLArea.replaceAll = function(config) {

⌨️ 快捷键说明

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