PHP version to ueditor image online governance column to increase the image deletion function

Source: Internet
Author: User
PHP version to ueditor image Online management column to increase the image deletion function

1. Locate the Uedior/dialogs/image/image.js file and add the code for the modified section:

/** * tab-click Processing event * @param tabheads * @param tabbodys * @param obj*/function ClickHandler (tabheads, Tabbodys, obj) {//he    Ad style change for (var k = 0, len = tabheads.length; k < Len; k++) {tabheads[k].classname = "";    } obj.classname = "Focus";    Body explicit var tabsrc = Obj.getattribute ("tabsrc"); for (var j = 0, length = tabbodys.length; j < length; J + +) {var body = Tabbodys[j], id = body.getattr        Ibute ("id");        Body.onclick = function () {this.style.zoom = 1;        };        if (id! = tabsrc) {body.style.zIndex = 1;            } else {body.style.zIndex = 200;                When switching to a local image upload, hide the mask with the iframe if (id = = "local") {Toggleflash (true);                MaskIframe.style.display = "None";                Handles determining the state of the button if (selectedimagecount) {dialog.buttons[0].setdisabled (true);      }} else {Toggleflash (false);          MaskIframe.style.display = "";            Dialog.buttons[0].setdisabled (FALSE);            } var list = g ("ImageList");            List.style.display = "None";                When switching to picture management, AJAX requests the background picture list if (id = = "Imgmanager") {list.style.display = ""; The stale commit request has been initialized obsolete no more if (!list.children.length) {ajax.request (Editor.options.imageManagerU RL, {timeout:100000, action: "Get", Onsuccess:func                            tion (XHR) {//Remove space var tmp = Utils.trim (Xhr.responsetext), Imageurls =!tmp?                            []: Tmp.split ("Ue_separate_ue"), length = Imageurls.length; G ("ImageList"). InnerHTML =!length?                            "+ Lang.nouploadimage:" "; for (var k = 0,ci; ci = imageurls[k++];) {                                //add start=============================== var div = document.createelement ("div");                                var img = document.createelement ("img");                                var del = document.createelement ("img");                                var p = document.createelement ("P");                                Div.appendchild (IMG);                                Div.appendchild (P);                                P.appendchild (DEL);                                Div.style.display = "None";                                Img.style.height = "100px";                                Img.style.width = "100px";                                Del.setattribute ("src", "images/del.png");                                P.style.margintop = " -104px";                                P.style.marginleft = "90px";                                G ("ImageList"). AppendChild (Div);                          Img.onclick = function () {          Changeselected (this);                                }; Del.onclick = function () {var me = this, src = me.g                                    Etattribute ("Alt", 2);                                    var pic = me.parentnode.parentnode.childnodes[0]; if (!confirm ("Delete operation is not recoverable, are you sure you want to delete this picture?")                                    ")) return;                                        Ajax.request (EDITOR.OPTIONS.IMAGEMANAGERURL, {action: "Del", FileName:src.substr (Src.lastindexof ("/") + 1), onsuccess:functi                                            On (XHR) {me.parentNode.parentNode.removeChild (pic);                                        Me.parentNode.removeChild (Me);                                      }, Onerror:function (XHR) {      Alert ("The server failed to delete the picture, please try again!")                                        ");                                }                                    });                                };                                    ADD end================================ img.onload = function () {                                    This.parentNode.style.display = "";                                    var w = this.width, h = this.height;                                    Scale (this, 100, 120, 80);                                    This.title = lang.toggleselect + W + "X" + H;                                This.onload = null;                                }; Img.setattribute (K < 35?)                                "src": "lazy_src", Editor.options.imageManagerPath + ci.replace (/\s+|\s+/ig, ""));                                Img.setattribute ("title", Editor.options.imageManagerPath + ci.replace (/\s+|\s+/ig, "")); Img.setattribute ("WIdth "," 100px ");                                Img.setattribute ("height", "100px");                                    Del.onload = function () {//set the style This.style = "border:0" when loading the Del picture;                                This.onload = null;                                };                            Del.setattribute ("alt", Editor.options.imageManagerPath + ci.replace (/\s+|\s+/ig, "")); }}, Onerror:function () {g ("ImageList"). Innerht                        ML = Lang.imageloaderror;                }                    });            }} if (id = = "Imgsearch") {Selecttxt (g ("Imgsearchtxt"));            } if (id = = "remote") {$focus (g ("url")); }        }    }}

Locate the uedior/php/imagemanager.php file and add the following:

if ($action = = "Del") {    $fileName = $_post[' FileName '];    foreach ($paths as $path) {        $str 1 = DelFiles ($fileName, $path);        break;    }} function DelFiles ($fileName, $path, & $files = Array ()) {    if (!is_dir ($path)) return null;    $handle = Opendir ($path);    while (false!== ($file = Readdir ($handle))) {        if ($file! = '. ' && $file! = ') {            $path 2 = $path. ' /'. $file;            if (Is_dir ($path 2)) {                DelFiles ($fileName, $path 2, $files);            } else {                if (Preg_match ("/\." ( gif|jpeg|jpg|png|bmp) $/i ", $file)) {                    $path 3 = Str_replace ('.. /.. /', '/static/', $path 2);                    $FILEIMG = basename ($path 3);                    if ($fileImg = = $fileName) {                        $is _del = unlink ($path 2);}}}}}    





  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.