vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 2.x Full Releases (https://vborg.vbsupport.ru/forumdisplay.php?f=4)
-   -   WYSIWYG New thread/Reply (https://vborg.vbsupport.ru/showthread.php?t=40130)

Velocd 06-25-2002 05:21 PM

as requested...

Add-On: Allow users to choose which posting engine to use via UserCp Options
A nice addition by Velocd


This will help users whose browser does not support the WYSIWYG editor, such as Mozilla 1.0 (stated by GameCrash earlier in this thread). Also, everything is about user preference so its good to give your members an option. ;)

Very easy to install, shouldn't take long at all. Although, if you currently have the WYSIWYG editor installed you will have to do a few things on your own.


--------------------------------------------------------------
Install Procedure:
--------------------------------------------------------------

1. Run the following query in PhpMyAdmin:
Code:

alter table user
add enablewysiwyg smallint(5) UNSIGNED not null default '0';

2. In member.php, find the following:
PHP Code:

    $showsignaturesnotchecked="checked";


Directly below it add:
PHP Code:

if ($bbuserinfo[enablewysiwyg]) {
     
$enablewysiwygchecked="checked";
     
$enablewysiwygnotchecked="";
  } else {
     
$enablewysiwygchecked="";
     
$enablewysiwygnotchecked="checked";
  } 

Now find:
PHP Code:

$options=iif($showsignatures=="yes",1,0); 

Below it add:
PHP Code:

$enablewysiwyg=iif($enablewysiwyg=="yes",1,0); 

Last but no least, find:
PHP Code:

$DB_site->query("UPDATE user
                     SET "
.$updatestyles."adminemail='$adminemail',enablewysiwyg='$enablewysiwyg',allowrate='$allowrate',
                        showemail='
$showemail',invisible='$invisible',cookieuser='$cookieuser',
                        maxposts='"
.addslashes($umaxposts)."',daysprune='".addslashes($prunedays)."',
                        timezoneoffset='"
.addslashes($timezoneoffset)."',emailnotification='$emailnotification',
                        startofweek='"
.addslashes($startofweek)."',options='$options',receivepm='$receivepm',
                        emailonpm='
$emailonpm',pmpopup='$pmpopup',usergroupid='$bbuserinfo[usergroupid]',
                        nosessionhash='
$nosessionhash'
                   WHERE userid='
$bbuserinfo[userid]'"); 

And see in that code on the 2nd line where I have:
PHP Code:

enablewysiwyg='$enablewysiwyg'

You wanna add that too ;)
After your finish that, save member.php


3. Open newthread.php, and find the following:
PHP Code:

eval("dooutput(\"".gettemplate("newthread")."\");"); 

Replace it with this code:
PHP Code:

$threadengine $DB_site->query_first("SELECT enablewysiwyg FROM user WHERE userid='$bbuserinfo[userid]'");

  if(
$threadengine[enablewysiwyg]){ eval("dooutput(\"".gettemplate("newthread_wysiwyg")."\");");

  } else { eval(
"dooutput(\"".gettemplate("newthread")."\");"); } 

4. Open newreply.php, and find the following:
PHP Code:

eval("dooutput(\"".gettemplate("newreply")."\");"); 

Replace it with this code:
PHP Code:

$replyengine $DB_site->query_first("SELECT enablewysiwyg FROM user WHERE userid='$bbuserinfo[userid]'");

  if(
$replyengine[enablewysiwyg] == 1) { eval("dooutput(\"".gettemplate("newreply_wysiwyg")."\");");

  } else { eval(
"dooutput(\"".gettemplate("newreply")."\");"); } 

5. The same thing still needs to be done with the private.php and editpost.php, only problem is that their templates have not yet been implemented with the WYSIWYG system, so we will have to wait awhile...

6. Go into your admin/functions.php, find the following:
PHP Code:

global $vbcodemode,$vbcode_smilies

Replace it with:
PHP Code:

global $DB_site,$vbcodemode,$vbcode_smilies

Now find:
PHP Code:

eval ("\$vbcode_buttons = \"".gettemplate("vbcode_buttons")."\";"); 

Place above it on a new line the following:
PHP Code:

$vbcodetype $DB_site->query_first("SELECT enablewysiwyg FROM user WHERE userid='$bbuserinfo[userid]'");
    if(
$vbcodetype[enablewysiwyg]) { $vbcodetype "vbcode2.js"; } else { $vbcodetype "vbcode.js"; } 

7.. Now to create new templates! In your Admin Cp, create the following template with its content:

newreply_wysiwyg:
newreply.txt that was provided in the hack zip needs to be in this template.

newthread_wysiwyg:
newthread.txt that was provided in the hack zip needs to be in this template.


8. Now you need to revert the templates, or change back to what you originally had, newthread and newreply.


9. Now to modify a couple templates, and then we're finished. In vbcode_buttons find the following:
Code:

<script language="Javascript" src="vbcode.js"></script>
Replace it with:
Code:

<script language="Javascript" src="$vbcodetype"></script>

10. In the template modifyoptions, find the following:
Code:

<input type="radio" name="pmpopup" $pmpopupnotchecked value="no"> no
        </normalfont></td>
</tr>
<!-- *** -->

And just below it place:
Code:

<tr>
<td bgcolor="#1D6AA0" colspan="2"><normalfont color="#EEEEFF"><b>New Thread, Reply & Personal Messaging Engine</b></normalfont></td>
</tr>
<tr>
        <td bgcolor="#1C5780"><normalfont><b>Use the WYSIWYG enhanced HTML engine? *IS IN BETA*</b></normalfont><br>
        <smallfont>Selecting yes will enable the new WYSIWYG posting engine, which does not require the use of some VBcode tags and has a typing interface similar to that of Microsoft Word.  <br><b><u>Note:</u> May be incompatible with some internet browsers.</b><br><b><u>Note2:</u> To use such VBcodes as the [img] tag, you must first initialize <i>enhanced mode</i> on the posting screen.  Then simply type in the tags and close them as you would normally do.</b>
</smallfont></td>
        <td bgcolor="#1C5780"><normalfont>
                <input type="radio" name="enablewysiwyg" value="yes" $enablewysiwygchecked> yes
                <input type="radio" name="enablewysiwyg" value="no" $enablewysiwygnotchecked> no
        </normalfont></td>
</tr>

When the WYSIWYG is out of beta, meaning fixed of bugs, you should probably reomve the *IS IN BETA* from the chunk above.

--------------------------------------------------------------

Well thats it! If I missed anything or there are problems be sure to let me know, but I'm fairly sure I got everything down.

;)


UPDATE:

To reduce the ues of extra queries, its always good to add the custom templates to the $templatesused = "" list.

1. In newthread.php, find:
PHP Code:

$templatesused "newpost_postpreview, 

Replace it with this:
PHP Code:

$templatesused "newpost_postpreview, newthread_wysiwyg, 

2. In newreply.php, find:
PHP Code:

$templatesused "quotereply, 

Replace it with this:
PHP Code:

$templatesused "quotereply, newreply_wysiwyg, 


eiSecure 06-25-2002 05:28 PM

whoohoo! We've finished the HTML -> BBCode conversion code!:)

I will test it out to see how it works, and, if velocd lets me, I'll release everything as a complete package. (With credit given, of course.:))

:bunny:

Velocd 06-25-2002 05:34 PM

Sounds like an excellent idea ^_^

eiSecure 06-25-2002 05:47 PM

Velocd, just wondering...

...any chance you can make your addon autodetect if the user is using IE5.5 or above?

For example, if the user is using IE5.5, then WYSIWYG will automatically be default, but if the user is on Netscape/Mozilla, it will autodefault to regular mode, and not let them switch, because it won't be possible.

Paul 06-25-2002 06:33 PM

Quote:

Originally posted by eiSecure
Everything is working, except for the HTML to BBCode conversion.
Hah. That's the biggest part. Allowing HTML is like leaving your car keys in the ignition, the doors unlocked, and installing a big flashing neon sign on the roof of your car that blinks "STEAL ME" in bright pink.

;D

Velocd 06-25-2002 07:06 PM

Quote:

Originally posted by eiSecure
Velocd, just wondering...

...any chance you can make your addon autodetect if the user is using IE5.5 or above?

For example, if the user is using IE5.5, then WYSIWYG will automatically be default, but if the user is on Netscape/Mozilla, it will autodefault to regular mode, and not let them switch, because it won't be possible.

I have no idea how to do that, sorry eiSecure..:(
I'm sure it requires some javascript which I don't have much knowledge in..

eiSecure 06-25-2002 07:06 PM

It's all fixed now.

It has almost no bugs now, and the only problem is compatibility.:)

Superman53142 06-25-2002 07:08 PM

Quote:

Originally posted by LoveShack


Hah. That's the biggest part. Allowing HTML is like leaving your car keys in the ignition, the doors unlocked, and installing a big flashing neon sign on the roof of your car that blinks "STEAL ME" in bright pink.

;D

It's done. We finished this afternoon. It will be officially released tomorrow. Don't ask me why :p

Superman53142 06-25-2002 07:09 PM

Quote:

Originally posted by Velocd


I have no idea how to do that, sorry eiSecure..:(
I'm sure it requires some javascript which I don't have much knowledge in..

I'll take a look at it after I get a snack. I'm pretty sure PHP grabs all the user variables when the user requests a page. Should be in there somewhere.

Admin 06-26-2002 04:31 AM

Can I close this thread now that there's a new one?

Speak now or forever hold your peace. :)


All times are GMT. The time now is 06:37 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.02146 seconds
  • Memory Usage 1,794KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (5)bbcode_code_printable
  • (18)bbcode_php_printable
  • (4)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (3)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete