View Single Post
  #102  
Old 06-25-2002, 06:21 PM
Velocd's Avatar
Velocd Velocd is offline
 
Join Date: Mar 2002
Location: CA University
Posts: 1,696
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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, 
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01399 seconds
  • Memory Usage 1,862KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (5)bbcode_code
  • (18)bbcode_php
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.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_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • 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
  • showpost_complete