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)
-   -   Editpost preview (https://vborg.vbsupport.ru/showthread.php?t=9569)

Mas*Mind 02-22-2001 10:00 PM

This is what the hack does: It let's you preview a message when you're editing it, you can only preview when you're posting or replying the way it is now:

It works on my testserver, but I've not tested on a 'live' forum, but it seems to be working allright...

Instructions

1 Backup your editpost.php file!!! and open the original one...

Then:

after:

PHP Code:

if (!isset($action) or $action=="") {
  
$action="editpost";


insert:

PHP Code:

if($preview AND $action="updatepost")
    
$action "editpost"

after:

PHP Code:

if ($action=="editpost") {

  
// draw nav bar
  
$navbar=makenavbar($threadinfo[threadid],"thread",1); 

insert:

PHP Code:

  if($preview)
  { 
$parseurl=iif($parseurl=="yes",1,0);
      
$email=iif($email=="yes",1,0);
      
$allowsmilie=iif($disablesmilies=="yes",0,1);
      
$signature=iif($signature=="yes",1,0);
    
    
$previewmessage=$message;
    
    if (
$parseurl) {
      
$previewmessage $postinfo[message]=parseurl($previewmessage);
      }
    
    
$previewpost=1;
    
$previewmessage=bbcodeparse($previewmessage,$foruminfo[forumid],$allowsmilie);
    
$postinfo[message]=$message;    

    if (
$signature) {
      
$previewmessage.=bbcodeparse("\n__________________\n$bbuserinfo[signature]",0,$allowsmilies);
    }

    eval(
"\$postpreview=\"".gettemplate("editpost_postpreview")."\";");

    
$parseurlchecked=iif($parseurl,"checked","");
    
$postinfo[allowsmilie] = $allowsmilie;
    
$postinfo[showsignature] = $signature;
    
$postinfo[iconid] = $iconid;
    
$postinfo[title] = $title;
    
$previewchecked=0;
  }
  else{
       
$postinfo[message]=htmlspecialchars($postinfo[pagetext]);
    
$parseurlchecked="CHECKED";
  } 

Replace:

PHP Code:

 $postinfo[message]=htmlspecialchars($postinfo[pagetext]); 

with:

PHP Code:

//$postinfo[message]=htmlspecialchars($postinfo[pagetext]); 

replace:

PHP Code:

   if ($checkid=$DB_site->query_first("SELECT subscribethreadid FROM subscribethread WHERE userid='$userinfo[userid]' AND threadid=$threadinfo[threadid]")) {
    
$emailchecked="CHECKED";
  } else {
    
$emailchecked="";
  } 

with:

PHP Code:

   if(!$preview)
      
$email=$DB_site->query_first("SELECT subscribethreadid FROM subscribethread WHERE userid=$userinfo[userid] AND threadid=$threadinfo[threadid]");
  
$emailchecked=iif($email,"CHECKED",""); 

Make a new template called 'editpost_postpreview' with the following content:

Code:

<table width=100% border=0 cellspacing=1 cellpadding=4>
<TR bgcolor="#6c6081">
<TD valign=middle><smallfont color="#afa3c5"><B>Post Preview:</B></smallfont></TD>
</TR>

<tr bgcolor="#DEDEDE">
<td><normalfont>$previewmessage</normalfont></td>
</tr>
</table>

<br>

then edit your 'editpost' template:

insert the '$postpreview' variable at the appropiate place (look into the 'newthread' template for an example)

and replace:

Code:

<INPUT TYPE="Submit" NAME="SUBMIT" ACCESSKEY="S" VALUE="Submit Now">
with:

Code:

<INPUT TYPE="Submit" NAME="preview" ACCESSKEY="P" VALUE="Preview">
<INPUT TYPE="Submit" NAME="SUBMIT" ACCESSKEY="S" VALUE="Submit Now">

All done! Enjoy :)

02-23-2001 09:03 PM

I'll be working on the pm-preview btw

02-24-2001 06:05 PM

No-one's interested?

02-24-2001 07:55 PM

Sure i will use them both, I just wasn't doing much with hacks yet until 2.0 is released. I didn't want a beta 3 to come out and have to re-hack a bunch of stuff.

It would be great if you wrote a upgrade script that you ran and it automatically fixed the things, that way you could just update the script for each beta released.

ThomasP 07-11-2001 06:01 AM

Hi there,

hopefully didn't overlook something in between,
but I definetely would appreciate to use that hack!

Does it work for 2.0.1?
Did you have a solution meantime for PM Preview - I know there's a hack, just interested if you worked on it, too.

Thanks,
-Tom

Minimazz 01-20-2002 01:19 PM

Yes Mas*Mind, I am very interrested in that hack !

I run v 2.2.1 is your hack fixed for that version ?

any update since your former post ?

waiting for news, see you

Shenlong 01-20-2002 02:28 PM

great hack Mas*Mind

Stretchr 01-26-2002 12:50 AM

Thanks Mas*Mind! I really missed having the ability to preview my edited posts, especially when I'm using vB code. I keep finding myself using HTML instead and then I have to go in again and edit. This is a really good idea!

LuBi 02-06-2002 09:15 PM

Does this work on 2.2.2?

bitbender 02-07-2002 12:47 AM

Sweet Work!

T?Pau 02-07-2002 10:12 PM

I have installed it, but ist doesn?t work correct. :(
I can have a first preview and it works, but if I try to preview again, it posts the message. Any ideas?

JJR512 02-12-2002 05:10 AM

Three comments about this hack:

1. You do not need a separate template (editpost_postpreview). The contents of the existing template, newpost_postpreview, are almost exactly the same, but are a bit more polished in terms of HTML coding (including being the standard vBulletin table-within-a-table which I guess gives you the border or whatever). Plus, using the existing template saves space (even if only a tiny amount) in the database. (I tested that doing this works, and can confirm that it does indeed work properly to use the existing template. All you have to do is first of all, not create the new template, or delete it if you already did, then in editpost.php, change the part you added that says "editpost_postpreview" so that it says "newpost_postpreview".)

2. Whenever making a vBulletin .php file use a template it didn't use before, you should add it to the "$templateused" section at the top of the file. I'm told this saves a database query. You should do this regardless of what you do about my #1 above.

3. When you click the button to edit a post, then you click the Preview button, the edit is submitted and saved to the database. This means that whatever changes you made are saved before you tell it to save them! This is not the desired behavior of the Preview function. If you want to "preview" something, that means you want to see what it looks like, before you commit to it, right? Well, the mere act of previewing something now means you've committed the changes! This is not good.

Mas*Mind 02-12-2002 10:32 AM

sorry guys, this was a beta for 2.01 if I'm correct. I've never tested it fully and never really released it fully (don't know why it says v2.2.2 before the title)

currently there's no change for me to work on this, so if a fellow hacker wants to do it: great :)

Mystics 02-12-2002 10:48 AM

I have fixed this long time ago, sorry I haven't posted it :p
It works perfect for vB2.2.x!

@JJR512
We had the same thoughts, I also have just used the newpost_postpreview Template.

I have attached the fixed version.

FWC 02-12-2002 04:56 PM

Quote:

Originally posted by Mystics
I have fixed this long time ago, sorry I haven't posted it :p
It works perfect for vB2.2.x!

This works great. Thanks, Mystics! :up:

JJR512 02-12-2002 05:11 PM

Yep, works fine now! :)

Lucky 02-12-2002 08:14 PM

Works great on 2.2.2.

Thanks.

Jawelin 02-13-2002 11:08 AM

Quote:

Originally posted by Mystics
I have fixed this long time ago, sorry I haven't posted it :p
It works perfect for vB2.2.x!

@JJR512
We had the same thoughts, I also have just used the newpost_postpreview Template.

I have attached the fixed version.

Thanks a lot, Mystics !! Great upgrade.
I installed perfectly without any problem.

Just a couple of little things:
1) When an admin (me, for instance...) is previewing after edit an other user's post, the signature showed in preview mode is mine, instead of the user's one. When saved, everything works fine, as usual.
2) Html style question: how can I make the 'save changes' button selected by default as it was before adding a button just before ? I tried with 'tabindex' but ... :(

Thanks a lot.
Bye

DWZ 04-23-2002 09:35 AM

Quote:

Originally posted by Mystics
I have fixed this long time ago, sorry I haven't posted it :p
It works perfect for vB2.2.x!

@JJR512
We had the same thoughts, I also have just used the newpost_postpreview Template.

I have attached the fixed version.

I just tried to install this hack on 2.2.5 but, I cant find the code
Code:

<INPUT TYPE="Submit" NAME="SUBMIT" ACCESSKEY="S" VALUE="Submit Now">
in the editpost template... Has it been changed to somthing else?

I found this:
Code:

<input type="submit" class="bginput" name="submit" accesskey="s" value="Save Changes" tabindex="3">
I dont know if thats it or not, so yeah...

Thanks :)

Alan (DWZ)

Mystics 04-23-2002 01:29 PM

Quote:

Originally posted by DWZ
I found this:
Code:

<input type="submit" class="bginput" name="submit" accesskey="s" value="Save Changes" tabindex="3">
I dont know if thats it or not, so yeah...

Yes, that's the right code.

webForum 06-13-2002 03:26 PM

I'm using Mystics version on my forum and it stopped working after upgrading to v2.2.6. It seems to execute template 'standardredirect' in some way beacuse it's redirect to the post again after 1sec.

Please, can someone verify if this is working with v2.2.6.

Mystics 06-13-2002 03:50 PM

Quote:

Originally posted by webForum
Please, can someone verify if this is working with v2.2.6.
It's working perfect with 2.2.6 :)

I think, you have forgotten this step:
Code:

Search for
-----------------------------------------------------------
if ($HTTP_POST_VARS['action']=="updatepost") {
-----------------------------------------------------------

REPLACE it with
-----------------------------------------------------------
if ($action=="updatepost") {
-----------------------------------------------------------

Mystics

webForum 06-13-2002 04:03 PM

Yes, you're correct. I actually leaved it out since I thought both more or less did the same thing.

Many thanks Mystics :)

xamu 06-19-2002 06:39 PM

So really,
Code:

<input type="submit" class="bginput" name="submit" accesskey="s" value="Save Changes" tabindex="3">
Should be replaced with
Code:

<input type="submit" class="bginput" name="submit" accesskey="s" value="Save Changes" tabindex="3">
<INPUT TYPE="Submit" class="bginput" NAME="preview" ACCESSKEY="P" VALUE="Preview">

Otherwise the Preview button will not be the same size. :cool:

Probably wouldn't hurt to change the tabindex= numbers for Preview, Save Changes & Reset Message.

Boofo 03-31-2003 02:19 AM

For anyone still using this hack, I have fixed the problem with the signature showing for the original poster instead of the person editing the post.

Change:

PHP Code:

    if ($signature && $bbuserinfo[signature]) {
      
$previewmessage.=bbcodeparse("\n__________________\n$bbuserinfo[signature]",0,$allowsmilies);
    } 

To:

PHP Code:

    if ($signature) {
    
$userinfo=$DB_site->query_first("
    SELECT signature
      FROM user
     WHERE userid='
$postinfo[userid]'");
      
$post[username]=$postinfo[username];
      
$post['signature'] = bbcodeparse($userinfo['signature'],0,$allowsmilie);
      eval(
"\$post[signature] = \"".gettemplate("postbit_signature")."\";");
      
$previewmessage.=$post['signature'];
    } 

It does add one query, but this is the only way to fix it AFAIK. ;)

msimplay 05-11-2003 01:11 AM

works great on vbulletin 2.3 its a wonder why it isnt there as standard

padblaz 05-23-2003 06:45 AM

very useful hack
thanks for it :)

Kriek 08-10-2003 12:05 PM

Flawless via 2.3.0

/me clicks install

Aaron1 02-01-2004 09:24 AM

Very cool, i installed it, the only problem what i have is that the preview of the changes of the post looks good, but in the form the changes aren't there anymore. So i need to edit it again whenever i preview the edit post.

Anyone knows what could have caused that? Very ackward! :ermm:

Ps: I am still running my faitfulll vb 2.2.7

ngx 01-28-2005 03:31 PM

Quote:

Originally Posted by Mystics
It's working perfect with 2.2.6 :)

I think, you have forgotten this step:
Code:

Search for
-----------------------------------------------------------
if ($HTTP_POST_VARS['action']=="updatepost") {
-----------------------------------------------------------

REPLACE it with
-----------------------------------------------------------
if ($action=="updatepost") {
-----------------------------------------------------------

Mystics

Installed nicely into 2.3.5 Thanks.

Just posting here to point out that that part of code isnt actually in the first post instructions :( So I missed it twice until I came further into the thread. just an FYI


All times are GMT. The time now is 06:11 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.02341 seconds
  • Memory Usage 1,849KB
  • 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
  • (10)bbcode_code_printable
  • (10)bbcode_php_printable
  • (6)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (30)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
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete