vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Check Titles - automatically correct (https://vborg.vbsupport.ru/showthread.php?t=255588)

symptome 12-20-2010 12:19 PM

Check Titles - automatically correct
 
I've got the problem, that many people use titles with plenty of !!!!!?????-Signs.
I always edit those titles to delete those signs.
Another typical faults is, that after a comma there is no space.

Isn't there a possibility that creation of a thread corrects those things in titles automatically?

Thanks!

BirdOPrey5 12-20-2010 03:38 PM

I put together a quick plugin that will tell a user to fix a mistake (not fix it for them) if they enter more than one ! or ? or a combination of ?! in a row...

So:
This! Is! OK!
But
This is NOT OK!!!

Also it should stop commas with no space after them...

Good:
this is a good, comma usage!
Bad:
this will not,be allowed!

Go to your Admin CP -> Plugin Manager -> Add a New Plugin

Product: vBulletin
Hook: newthread_post_start
Title: Thread Title Punctuation Check
Code"
PHP Code:

$checktitle $vbulletin->GPC['subject'];
$regpat "/[\w \(\)\[\]<>]+,[\w\(\)\[\]<>]/";

   if ( 
strpos($checktitle"!!") OR strpos($checktitle"??") OR strpos($checktitle"?!") OR strpos($checktitle"!?") OR preg_match ($regpat$checktitle) )
   {  
      
standard_error("Please fix the punctuation in the thread title. Excessive ! and ? are not allowed and commas must be properly spaced. <input type=\"button\" id=\"backbutton\" class=\"button\" value=\"Go Back\" title=\"\" tabindex=\"1\" onclick=\"{ history.back(1);}\">");
   } 

Set ACTIVE to YES
and SAVE.

symptome 12-20-2010 05:37 PM

Simply brillant!
Thanks a lot!

I believe, I will add some more ;)
Like the 2 or 3 usual smileys ...
Or "..."

symptome 12-22-2010 04:09 AM

Or would it be possible to write the above to be executed automatically without showing any error to the member?

BirdOPrey5 12-22-2010 04:25 AM

Not that I can do... you might find someone else willing and able.

kh99 12-22-2010 01:07 PM

Something like this might work for you:

PHP Code:

static $pattern = array('/!+/''/\?+/''/(!\?|\?!)[\?!]+/''/,(\S)/');
static 
$replacement = array('!''?''\\1'', \\1');

$vbulletin->GPC['subject'] = preg_replace($pattern$replacement$vbulletin->GPC['subject']); 

(This allows ?! or !?, but you could change it to disallow that if you want).


All times are GMT. The time now is 03:37 PM.

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.00948 seconds
  • Memory Usage 1,725KB
  • 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
  • (2)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (6)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