Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > vBulletin 3.7 > vBulletin 3.7 Add-ons
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Adding EditArea for Template & Plugin Editing Details »»
Adding EditArea for Template & Plugin Editing
Version: 0.1, by sweede sweede is offline
Developer Last Online: Jun 2014 Show Printable Version Email this Page

Category: Administrative and Maintenance Tools - Version: 3.7.0 Beta 2 Rating:
Released: 12-18-2007 Last Update: Never Installs: 24
Code Changes Additional Files  
No support by the author.

This isnt a Plugin or Mod, but a collection of code changes to allow the use of Edit Area to edit vbulletin templates and in the plugin code editor areas.

http://cdolivet.net/editarea/

Quote:
Edit area
Here is EditArea, a free javascript editor for source code. (That is no way a WYSIWYG editor).
This editor is designed to edit souce code files in a textarea. The main goal is to allow text formatting, search and replace and real-time syntax highlight (for small text).
Download the zip file from the website above and unpack the zip file. Upload the edit_area folder into your /clientscript/ directory in your vbb installation. (See additional instructions at the bottom). You should now have a /clientscript/edit_area folder with files such as edit_area.css , edit_area.js and so on in it. Be sure that you also uploaded the images, langs, plugs and reg_syntax folders.


This requires changes to two files, one of them being optional.

The first file to edit is the includes/adminfunctions.php file
Using the UNMODIFIED 3.7.0 beta 2 version (Unsure of actual locations of the code in 3.6.8 and ealier versions, but the edits are basicly the same)

The first edit is adding the javascript to the page.
Open up the file includes/adminfunctions.php and look for the first
Code:
<script type=\"text/javascript\">
It should be around line 295.

Before that line, add
Code:
<script language=\"Javascript\" type=\"text/javascript\" src=\"../clientscript/edit_area/edit_area_full.js\"></script>
*Read http://cdolivet.net/editarea/editarea/docs/include.html for advanced options.

Now, we will look for the function print_textarea_row which starts around line 894

This is where the majority of the code changes are.

Comment out line 915 (add // infront of the line)
Code:
$resizer = "<div class=\"smallfont\"><a href=\"#\" $ie_reflow_css onclick=\"return resize_textarea(1, '{$vbulletin->textarea_id}')\">$vbphrase[increase_size]</a> <a href=\"#\" $ie_reflow_css onclick=\"return resize_textarea(-1, '{$vbulletin->textarea_id}')\">$vbphrase[decrease_size]</a></div>";
And then add the following code after the line you just commented out.
Code:
    if (!$doeditbutton OR strpos($name,'[') !== false)
    {
        $javascript_source = '';
    } else {
        $javascript_source = '
            <script language="Javascript" type="text/javascript">
                // initialisation
                editAreaLoader.init({
                    id: "'.$vbulletin->textarea_id.'"
                    ,language: "en"
                    ,syntax: "html"
                    ,start_highlight: true	
                    ,font_size: "8"
                    ,font_family: "verdana, monospace"
                    ,allow_resize: "both"
                    ,allow_toggle: true
                    ,replace_tab_by_spaces: 4
                    ,min_height: 350
                    ,syntax_selection_allow: "css,html,js,php,xml"
                    ,toolbar: " search, go_to_line,fullscreen, |, undo, redo, |, select_font,|, syntax_selection, |, change_smooth_selection, highlight, reset_highlight, |, help"
                });	
            </script>
        ';
    }
Please read up on http://cdolivet.net/editarea/editare...iguration.html to adjust some of the settings to your new editor interface

The last change in this file is a few lines down from the code you just pasted. Should be line 943.

Add
Code:
 $javascript_source.
to the begining of the following line
Code:
"<div id=\"ctrl_$name\"><textarea name=\"$name\" id=\"{$vbulletin->textarea_id}\"" . iif($textareaclass, " class=\"$textareaclass\"") . " rows=\"$rows\" cols=\"$cols\" wrap=\"virtual\" dir=\"$direction\" tabindex=\"1\"" . iif($vbulletin->debug, " title=\"name=&quot;$name&quot;\"") . ">" . iif($htmlise, htmlspecialchars_uni($value), $value) . "</textarea>$resizer</div>",
It should look like
Code:
 $javascript_source . "<div id=\"ctrl_$name\"> ...
Save and close this file!

Right now, the template editor usable and with a full screen option built into it, you shouldnt need a reason to use the Large Edit Box option. However, those changes are also quite easy to do so i will add those.

Open up the file admincp/textarea.php

On line 48,
HTML Code:
opener.document.getElementsByName('<?php echo $vbulletin->GPC['name']; ?>')[0].value = textarea.value;
Change too
HTML Code:
opener.document.getElementsByName('<?php echo $vbulletin->GPC['name']; ?>')[0].value = editAreaLoader.getValue("popuptextarea");
Before the closing </head> tag, add
HTML Code:
<script language="Javascript" type="text/javascript" src="/clientscript/edit_area/edit_area_full.js"></script>
*Read http://cdolivet.net/editarea/editarea/docs/include.html for advanced options.

Replace the existing <body> tag (the entire line) with the following
HTML Code:
<body onload="self.focus(); editAreaLoader.setValue('popuptextarea', opener.editAreaLoader.getValue('<?php echo $vbulletin->GPC['name']; ?>'));" style="margin:0px">
<script language="Javascript" type="text/javascript">
    // initialisation
    editAreaLoader.init({
        id: "popuptextarea"
        ,language: "en"
        ,syntax: "html"	
        ,start_highlight: true	
        ,font_size: "8"
        ,font_family: "verdana, monospace"
        ,allow_resize: "both"
        ,allow_toggle: true
        ,replace_tab_by_spaces: 4
        ,syntax_selection_allow: "css,html,js,php,xml"
        ,toolbar: " search, go_to_line, fullscreen, |, undo, redo, |, select_font,|, syntax_selection, |, change_smooth_selection, highlight, reset_highlight, |, help"
    });	
</script>
And you're done.


Some screenshots of the result..

**Note:
For whatever reason, you cannot save text from the Large Edit Box into the main window IF you have the Edit Area editor enabled! you MUST uncheck the Toggle Editor checkbox before clicking the Large Edit Box button. If you fail to do that, you may or may not save your changes and you may loose the textarea data all together.

For whatever reasons, while
Code:
editAreaLoader.setValue('popuptextarea', 
opener.editAreaLoader.getValue('<?php echo $vbulletin->GPC['name']; ?>'))
works, the reverse
Code:
opener.editAreaLoader.setValue('<?php echo $vbulletin->GPC['name']; ?>',
editAreaLoader.getValue('popuptextarea'));
does not, if anyone knows the secret to getting this to work, please post here!

---------------------------------------
**Addition
In the adminfunctions.php file, the line that we added that says
HTML Code:
  ,syntax: "html"
change to
HTML Code:
 ,syntax: "'.$syntax_type.'"
Before the line that reads
HTML Code:
if (!$doeditbutton OR strpos($name,'[') !== false)
add

HTML Code:
switch ($name) {
    case "installcode":
        $syntax_type = "php";
        break;
    case "uninstallcode":
        $syntax_type = "php";
        break;
    case "phpcode":
        $syntax_type = "php";
        break;
    case "template":
        $syntax_type = "html";
        break;
    default:
        $syntax_type = "html";
}
Anything in the template editor will default to HTML syntax, anything in the plugin section will default to PHP syntax and anywhere else, HTML syntax.

you can also add other lines here that could disable the javascript editor from showing, one example is adding
HTML Code:
    case "searchstring":
        $doeditbutton = false;
        break;
before the default: line and this would disable the EditArea box. An alternative to searching and replacing text in many of the files.

you can also prevent the Large Area Button from being displayed by adding
HTML Code:
$openwindowbutton = '<div style="width: 150px">&nbsp;</div>';
in whatever case statements you would like (i have it in the install/uninstall, phpcode and template editors along with the default selection).

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #12  
Old 12-21-2007, 10:08 AM
Triky's Avatar
Triky Triky is offline
 
Join Date: Mar 2007
Location: [Italy]
Posts: 728
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Is there a search function?
Reply With Quote
  #13  
Old 12-21-2007, 02:26 PM
Snake's Avatar
Snake Snake is offline
 
Join Date: Mar 2005
Location: Cleveland, OH
Posts: 3,832
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Nice release!
Reply With Quote
  #14  
Old 12-21-2007, 07:07 PM
sweede's Avatar
sweede sweede is offline
 
Join Date: Jan 2007
Posts: 391
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Triky View Post
Is there a search function?
See my 3rd post.
Reply With Quote
  #15  
Old 12-26-2007, 03:41 PM
hocphp hocphp is offline
 
Join Date: Nov 2007
Posts: 28
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

i will install . thank
Reply With Quote
  #16  
Old 12-28-2007, 05:51 PM
Wayne Luke's Avatar
Wayne Luke Wayne Luke is offline
Senior Member
 
Join Date: Jan 2002
Location: Southern California
Posts: 1,694
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by sweede View Post
Click the binacular icon, if you're using IE though that stupid "scripted window" warning pops up and either refreshes your page or blows the world up or something like that. i hate that popup warning.
It can be turned off in the options. I do not get prompts for this. I can't remember which option does it though.
Reply With Quote
  #17  
Old 12-29-2007, 02:51 PM
gothicuser's Avatar
gothicuser gothicuser is offline
 
Join Date: Apr 2004
Location: Kernow, Nr. UK
Posts: 468
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

This walks on water, great and thanks.

One (major) problem for me is that it only fully works in M$ IE thingy
In FF it just displays the normal small edit box, and clicking on the 'Large Edit' opens the window and displays "False" (and nothing else) at the top of the window.

In Safari I get the full editor in the small window but again get the "False" in the large edit box.

p.s. I use FF on Linux and Safari on my Mac (where I do all my work)
Reply With Quote
  #18  
Old 12-29-2007, 03:08 PM
sweede's Avatar
sweede sweede is offline
 
Join Date: Jan 2007
Posts: 391
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by gothicuser View Post
This walks on water, great and thanks.

One (major) problem for me is that it only fully works in M$ IE thingy
In FF it just displays the normal small edit box, and clicking on the 'Large Edit' opens the window and displays "False" (and nothing else) at the top of the window.

In Safari I get the full editor in the small window but again get the "False" in the large edit box.

p.s. I use FF on Linux and Safari on my Mac (where I do all my work)
Ya, the interaction between the normal in window (or parent) text area and when you click on the large edit box is a mess. It doesnt seem to want to communicate between the parent window (opener) and the new window both directions, I can only get it to work one way on IE.

I gave up on using the large edit box all together and used the fullscreen option in the normal parent window.
Reply With Quote
  #19  
Old 12-29-2007, 03:55 PM
gothicuser's Avatar
gothicuser gothicuser is offline
 
Join Date: Apr 2004
Location: Kernow, Nr. UK
Posts: 468
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Oops. found that the Scriptblocker addon in FF was on steroids and over enthusiastically thought the editor was not nice. All working nicely (bar the Large Edit) But yes, full page will suffice
Reply With Quote
  #20  
Old 12-29-2007, 05:25 PM
KURTZ KURTZ is offline
 
Join Date: Nov 2006
Location: Italy
Posts: 2,257
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

i think that this isn't ad add-on but a templates edit ...
Reply With Quote
  #21  
Old 12-29-2007, 05:34 PM
sweede's Avatar
sweede sweede is offline
 
Join Date: Jan 2007
Posts: 391
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by KURTZ View Post
i think that this isn't ad add-on but a templates edit ...
It's a code modification, no templates are edited.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 06:50 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.06870 seconds
  • Memory Usage 2,341KB
  • Queries Executed 25 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (9)bbcode_code
  • (10)bbcode_html
  • (5)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (11)post_thanks_box
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (11)postbit_onlinestatus
  • (11)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete