Webmaster общности: Predpriemach.com | SearchEngines.bg

    WYSIWYG едитор за phpBB форум

    Автор: SandPrince

    От доста врме търсих този мод – WYSIWYG едитор – и най накрая го намерих!!!!
    Това е един доста полезен редактор за форум който се използва при отговор или пускане на тема! Има много функции и предполагам че ще е чудесен мод за вашите форуми! До тук с празните приказки и да започнем с обяснението на урока!

    Преди да започнем с урока обаче трябва да изтеглите този архив:
    СВАЛИ АРХИВА С НЕОБХОДИМИТЕ ФАЙЛОВЕ!!!!

    ## Ниво на трудност: (Лесно)
    ## Време за изпълнение: 10 минути
    ## Файлове за редакция: extension.inc,
    ## privmsg.php,
    ## posting.php,
    ## search.php,
    ## viewtopic.php
    ## includes/topic_review.php
    ## templates/subSilver/overall_header.tpl
    ## templates/subSilver/posting_body.tpl
    ##
    ## Добавени файлове : set_default_editor.php,
    ## templates/subSilver/posting_body_ie.tpl
    ##
    ## Добавени папки: richedit

    Първото нещо което трябва да направите е да си качите всички файлове. В архива има папка
    phpBB. Влизате в нея и в основната директория на форума качвате папката richedit,както и файла set_default_editor.php . после файловете от папката Templates ги качвате във вашия теплейт – за този урок използваме темплейта SubSilver.

    #-----[ ОТВОРЕТЕ ]------------------------------------------
    #
    extension.inc
    
    #
    #-----[ НАМЕРЕТЕ ]------------------------------------------
    #
    $starttime = 0;
    
    #
    #-----[ СЛЕД ТОВА ДОБАВЕТЕ ]------------------------------------------
    #
    //---------------------------------------------------------------------------------------------------------
    //EDITOR - Replace text inside [EDITOR= .... EDITOR] to HTML code
    function get_hoteditor($res="",$replace_quote=""){
    preg_match_all("/\{EDITOR=(.*?) EDITOR\}/si",$res,$matches);
    $get_code = $matches[1][0];
    if($get_code !=""){
    $res=str_replace("$get_code","{HOTEDITOR_TMP}",$res);
    $get_code=str_replace("&","&",$get_code);
    $get_code=str_replace("<","<",$get_code);
    $get_code=str_replace(">",">",$get_code);
    $get_code=str_replace("[<]","<",$get_code);
    $get_code=str_replace("[>]",">",$get_code);
    $get_code=str_replace("[<]","<",$get_code);
    $get_code=str_replace("[>]",">",$get_code);
    $get_code=str_replace("<br />","",$get_code);
    if($replace_quote==1) {
    $get_code=str_replace(""","\"",$get_code);
    }
    $get_code=str_replace(" "," ",$get_code);
    
    // Clear all onClick onMouseOver onMouseOut onMouseDown onMouseUp onMouseMove onBlur cursor
    // position absolute visibility visible z-index
    
    // Example <span onClick=alert('BOOOO')>Click here</span>
    // will be replaced to <span =alert('BOOOO')>Click here</span>
    // in this way your board won't mess up. Hope this will help.
    
    $match_count = preg_match_all("/<(.*?)>/si", $get_code, $matches_code);
    
    for ($i = 0; $i < $match_count; $i++){
    $get_code1 = $matches_code[1][$i];
    $get_code2 = $matches_code[1][$i];
    $get_code2 = preg_replace("/onclick/si", "", $get_code2);
    $get_code2 = preg_replace("/onmouseover/si", "", $get_code2);
    $get_code2 = preg_replace("/onmouseout/si", "", $get_code2);
    $get_code2 = preg_replace("/onmousedown/si", "", $get_code2);
    $get_code2 = preg_replace("/onmouseup/si", "", $get_code2);
    $get_code2 = preg_replace("/onmousemove/si", "", $get_code2);
    $get_code2 = preg_replace("/onblur/si", "", $get_code2);
    $get_code2 = preg_replace("/cursor/si", "", $get_code2);
    $get_code2 = preg_replace("/position/si", "", $get_code2);
    $get_code2 = preg_replace("/absolute/si", "", $get_code2);
    $get_code2 = preg_replace("/visibility/si", "", $get_code2);
    $get_code2 = preg_replace("/visible/si", "", $get_code2);
    $get_code2 = preg_replace("/z-index/si", "", $get_code2);
    $get_code2 = preg_replace("/script/si", "", $get_code2);
    $get_code =str_replace($get_code1,$get_code2,$get_code);
    }
    $get_code=str_replace("\r\n",' ',$get_code);
    $get_code=str_replace("\n",' ',$get_code);
    
    $res=str_replace("{HOTEDITOR_TMP}","$get_code",$res);
    $res=str_replace("{EDITOR=","",$res);
    $res=str_replace("EDITOR}","",$res);
    }
    else{
    if($_COOKIE[cookie_editor]=="on"){
    $res=str_replace("\r\n",'<br>',$res);
    $res=str_replace("\n",'<br>',$res);
    }
    $res=str_replace("{EDITOR= EDITOR}","",$res);
    }
    return $res;
    }
    //EDITOR END HERE
    
    #
    #-----[ ОТВОРЕТЕ ]------------------------------------------
    #
    posting.php
    
    #
    #-----[ НАМЕРЕТЕ ]------------------------------------------
    # ~ line number 722
    $preview_message = str_replace("\n", '<br />', $preview_message);
    
    #
    #-----[ СЛЕД ТОВА ДОБАВЕТЕ ]------------------------------------------
    #
    
    //EDITOR
    $preview_message = get_hoteditor($preview_message,1);
    
    #
    #-----[ НАМЕРЕТЕ ]------------------------------------------
    # ~ line number 820
    $message = '[quote="' . $quote_username . '"]' . $message . '[/quote]';
    
    #
    #-----[ ЗАМЕСТЕТЕ С ]------------------------------------------
    #
    $message = '[quote="' . $quote_username . '"]' . $message . '[/quote]';
    $message=str_replace("\"",""",$message);
    
    #
    #-----[ НАМЕРЕТЕ ]------------------------------------------
    # ~ line number 978
    $template->set_filenames(array(
    'body' => 'posting_body.tpl',
    'pollbody' => 'posting_poll_body.tpl',
    'reviewbody' => 'posting_topic_review.tpl')
    );
    
    #
    #-----[ ЗАМЕСТЕТЕ С ]------------------------------------------
    #
    //EDITOR START HERE
    $richedit = $_POST[richedit];
    $ua = $_SERVER[HTTP_USER_AGENT];
    $cookie_editor =$_COOKIE[cookie_editor];
    if($cookie_editor=="on" || $cookie_editor==""){
    $richedit="1";
    }
    else{
    $richedit="0";
    }
    
    if($richedit == "1" && !(strpos($ua,"Windows")===false) && !(strpos($ua,"MSIE")===false) || $richedit == "1" && !(strpos($ua,"Opera/9")===false) || $richedit == "1" && !(strpos($ua,"Gecko")===false) && (strpos($ua,"Safari")===false)){ //if true
    $display_editor_option = "<span class=gen>\n";
    $display_editor_option .= "<input type=radio value=1 checked name=richedit onClick='set_cookie(\"on\")'><font size=1>Click here to set Rich Text Editor as your default (Note: New Popup window will be openned. Please turn off the Popup Blocker program)</font><br>\n";
    $display_editor_option .= "<input type=radio value=0 name=richedit onClick='set_cookie(\"off\")'><font size=1>Click here to set normal Text Area as your default (Note: New Popup window will be openned. Please turn off the Popup Blocker program)</font>\n";
    $display_editor_option .= "</span>\n";
    $display_editor_option .= "<script language=javascript>\n";
    $display_editor_option .= "function set_cookie(data){\n";
    $display_editor_option .= "window.open('set_default_editor.php?editor=' + data, 'hoteditor', 'height=300,width=300,status=no,toolbar=no,menubar=no,location=no,scrollbars=no');\n";
    $display_editor_option .= "}\n";
    $display_editor_option .= "</script>\n";
    
    $template->set_filenames(array(
    'body' => 'posting_body_ie.tpl',
    'pollbody' => 'posting_poll_body.tpl',
    'reviewbody' => 'posting_topic_review.tpl')
    );
    }
    else{
    $display_editor_option = "<span class=gen>\n";
    $display_editor_option .= "<input type=radio value=1 name=richedit onClick='set_cookie(\"on\")'><font size=1>Click here to set Rich Text Editor as your default (Note: New Popup window will be openned. Please turn off the Popup Blocker program)</font><br>\n";
    $display_editor_option .= "<input type=radio value=0 checked name=richedit onClick='set_cookie(\"off\")'><font size=1>Click here to set normal Text Area as your default (Note: New Popup window will be openned. Please turn off the Popup Blocker program)</font>\n";
    $display_editor_option .= "</span>\n";
    $display_editor_option .= "<script language=javascript>\n";
    $display_editor_option .= "function set_cookie(data){\n";
    $display_editor_option .= "window.open('set_default_editor.php?editor=' + data, 'hoteditor', 'height=300,width=300,status=no,toolbar=no,menubar=no,location=no,scrollbars=no')\n";
    $display_editor_option .= "}\n";
    $display_editor_option .= "</script>\n";
    
    $template->set_filenames(array(
    'body' => 'posting_body.tpl',
    'pollbody' => 'posting_poll_body.tpl',
    'reviewbody' => 'posting_topic_review.tpl')
    );
    }
    //EDITOR END HERE
    
    #
    #-----[ НАМЕРЕТЕ ]------------------------------------------
    # ~ line number 1041
    $template->assign_block_vars('switch_not_privmsg', array());
    
    #
    #-----[ СЛЕД ТОВА ДОБАВЕТЕ ]------------------------------------------
    #
    
    //EDITOR
    $message = get_hoteditor($message,0);
    
    #
    #-----[ НАМЕРЕТЕ ]------------------------------------------
    # ~ line number 1050
    'USERNAME' => $username,
    
    #
    #-----[ СЛЕД ТОВА ДОБАВЕТЕ ]------------------------------------------
    #
    //EDITOR
    'DISPLAY_EDITOR_OPTION' => $display_editor_option,
    
    #
    #-----[ ОТВОРЕТЕ ]------------------------------------------
    #
    privmsg.php
    
    #
    #-----[ НАМЕРЕТЕ ]------------------------------------------
    # ~ line number 613
    $private_message = str_replace("\n", '<br />', $private_message);
    
    #
    #-----[ СЛЕД ТОВА ДОБАВЕТЕ ]------------------------------------------
    #
    
    //EDITOR
    $private_message = get_hoteditor($private_message,1);
    
    #
    #-----[ НАМЕРЕТЕ ]------------------------------------------
    # ~ line number 1626
    $preview_message = str_replace("\n", '<br />', $preview_message);
    
    #
    #-----[ СЛЕД ТОВА ДОБАВЕТЕ ]------------------------------------------
    #
    
    //EDITOR
    $preview_message = get_hoteditor($preview_message,1);
    
    #
    #-----[ НАМЕРЕТЕ ]------------------------------------------
    # ~ line number 1682
    $template->set_filenames(array(
    'body' => 'posting_body.tpl')
    );
    
    #
    #-----[ ЗАМЕСТЕТЕ С ]------------------------------------------
    #
    
    //EDITOR START HERE
    $richedit = $_POST[richedit];
    $ua = $_SERVER[HTTP_USER_AGENT];
    $cookie_editor =$_COOKIE[cookie_editor];
    if($cookie_editor=="on" || $cookie_editor==""){
    $richedit="1";
    }
    else{
    $richedit="0";
    }
    
    if($richedit == "1" && !(strpos($ua,"Windows")===false) && !(strpos($ua,"MSIE")===false) || $richedit == "1" && !(strpos($ua,"Opera/9")===false) || $richedit == "1" && !(strpos($ua,"Gecko")===false) && (strpos($ua,"Safari")===false)){ //if true
    $display_editor_option = "<span class=gen>\n";
    $display_editor_option .= "<input type=radio value=1 checked name=richedit onClick='set_cookie(\"on\")'><font size=1>Click here to set Rich Text Editor as your default (Note: New Popup window will be openned. Please turn off the Popup Blocker program)</font><br>\n";
    $display_editor_option .= "<input type=radio value=0 name=richedit onClick='set_cookie(\"off\")'><font size=1>Click here to set normal Text Area as your default (Note: New Popup window will be openned. Please turn off the Popup Blocker program)</font>\n";
    $display_editor_option .= "</span>\n";
    $display_editor_option .= "<script language=javascript>\n";
    $display_editor_option .= "function set_cookie(data){\n";
    $display_editor_option .= "window.open('set_default_editor.php?editor=' + data, 'hoteditor', 'height=300,width=300,status=no,toolbar=no,menubar=no,location=no,scrollbars=no');\n";
    $display_editor_option .= "}\n";
    $display_editor_option .= "</script>\n";
    
    $template->set_filenames(array(
    'body' => 'posting_body_ie.tpl')
    );
    }
    else{
    $display_editor_option = "<span class=gen>\n";
    $display_editor_option .= "<input type=radio value=1 name=richedit onClick='set_cookie(\"on\")'><font size=1>Click here to set Rich Text Editor as your default (Note: New Popup window will be openned. Please turn off the Popup Blocker program)</font><br>\n";
    $display_editor_option .= "<input type=radio value=0 checked name=richedit onClick='set_cookie(\"off\")'><font size=1>Click here to set normal Text Area as your default (Note: New Popup window will be openned. Please turn off the Popup Blocker program)</font>\n";
    $display_editor_option .= "</span>\n";
    $display_editor_option .= "<script language=javascript>\n";
    $display_editor_option .= "function set_cookie(data){\n";
    $display_editor_option .= "window.open('set_default_editor.php?editor=' + data, 'hoteditor', 'height=300,width=300,status=no,toolbar=no,menubar=no,location=no,scrollbars=no')\n";
    $display_editor_option .= "}\n";
    $display_editor_option .= "</script>\n";
    
    $template->set_filenames(array(
    'body' => 'posting_body.tpl')
    );
    }
    //EDITOR END HERE
    
    #
    #-----[ НАМЕРЕТЕ ]------------------------------------------
    # ~ line number 1808
    generate_smilies('inline', PAGE_PRIVMSGS);
    
    #
    #-----[ СЛЕД ТОВА ДОБАВЕТЕ ]------------------------------------------
    #
    
    //EDITOR
    $privmsg_message = get_hoteditor($privmsg_message,0);
    
    #
    #-----[ НАМЕРЕТЕ ]------------------------------------------
    # ~ line number 1814
    'SUBJECT' => $privmsg_subject,
    
    #
    #-----[ СЛЕД ТОВА ДОБАВЕТЕ ]------------------------------------------
    #
    //EDITOR
    'DISPLAY_EDITOR_OPTION' => $display_editor_option,
    
    #
    #-----[ ОТВОРЕТЕ ]------------------------------------------
    #
    search.php
    
    #
    #-----[ НАМЕРЕТЕ ]------------------------------------------
    # ~ line number 891
    $message = ( strlen($message) > $return_chars ) ? substr($message, 0, $return_chars) . ' ...' : $message;
    
    #
    #-----[ ЗАМЕСТЕТЕ С ]------------------------------------------
    #
    //EDITOR
    //$message = ( strlen($message) > $return_chars ) ? substr($message, 0, $return_chars) . ' ...' : $message;
    
    #
    #-----[ НАМЕРЕТЕ ]------------------------------------------
    # ~ line number 1043
    $template->assign_block_vars("searchresults", array(
    
    #
    #-----[ ПРЕДИ ТОВА ДОБАВЕТЕ ]------------------------------------------
    #
    
    //EDITOR
    $message = get_hoteditor($message,1);
    
    #
    #-----[ ОТВОРЕТЕ ]------------------------------------------
    #
    viewtopic.php
    
    #
    #-----[ НАМЕРЕТЕ ]------------------------------------------
    # ~ line number 1156
    $row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2'];
    
    #
    #-----[ СЛЕД ТОВА ДОБАВЕТЕ ]------------------------------------------
    #
    //EDITOR
    $message = get_hoteditor($message,1);
    
    #
    #-----[ ОТОВОРЕТЕ ]------------------------------------------
    #
    includes/topic_review.php
    
    #
    #-----[ НАМЕРЕТЕ ]------------------------------------------
    # ~ line number 188
    $row_class = ( !($i % 2) ) ? $theme['td_class1'] : $theme['td_class2'];
    
    #
    #-----[ СЛЕД ТОВА ДОБАВЕТЕ ]------------------------------------------
    #
    //EDITOR
    $message = get_hoteditor($message,1);
    
    #
    #-----[ ОТВОРЕТЕ ]------------------------------------------
    #
    templates/subSilver/overall_header.tpl
    
    #
    #-----[ НАМЕРЕТЕ ]------------------------------------------
    # ~ line number 35
    font,th,td,p { font-family: {T_FONTFACE1} }
    
    #
    #-----[ ЗАМЕСТЕТЕ С ]------------------------------------------
    #
    /* //EDITOR - TAKE OUT TEXT font */
    th,td,p { font-family: {T_FONTFACE1} }
    
    #
    #-----[ НАМЕРЕТЕ ]------------------------------------------
    # ~ line number 147
    .postbody { font-size : {T_FONTSIZE3}px; line-height: 18px}
    
    #
    #-----[ ЗАМЕСТЕТЕ С ]------------------------------------------
    #
    /* //EDITOR - REPLACE 18px TO 24px*/
    .postbody { font-size : {T_FONTSIZE3}px; line-height: 24px}
    
    #
    #-----[ ОТОВРЕТЕ ]------------------------------------------
    #
    templates/subSilver/posting_body.tpl
    
    #
    #-----[ НАМЕРЕТЕ ]------------------------------------------
    # ~ line number 75
    function checkForm() {
    
    #
    #-----[ СЛЕД ТОВА ДОБАВЕТЕ ]------------------------------------------
    #
    //EDITOR START HERE
    var MESS_EDITOR = document.post.message.value;
    MESS_EDITOR = MESS_EDITOR.replace(/\{EDITOR/ig,"{EDITOR");
    MESS_EDITOR = MESS_EDITOR.replace(/EDITOR\}/ig,"EDITOR}");
    document.post.message.value= MESS_EDITOR;
    //EDITOR END HERE
    
    #
    #-----[ НАМЕРЕТЕ ]------------------------------------------
    # ~ line number 403
    </textarea>
    
    #
    #-----[ СЛЕД ТОВА ДОБАВЕТЕ ]------------------------------------------
    #
    <!-- //EDITOR HERE -->
    {DISPLAY_EDITOR_OPTION}
    <!-- //EDITOR HERE -->
    
    
    #
    #-----[ СЪХРАНЕТЕ/ЗАТВОРЕТЕ ВСИЧКИ ФАЙЛОВЕ ]------------------------------------------

    Това е!

    Оставете коментар