vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Modification Requests/Questions (Unpaid) (https://vborg.vbsupport.ru/forumdisplay.php?f=112)
-   -   Greentext (https://vborg.vbsupport.ru/showthread.php?t=278071)

Kybyrian 02-05-2012 03:00 AM

Greentext
 
Thought it would be pretty cool after hearing out a couple requests, but I have no real idea how to go about doing it. Cutting to the chase, greentext *chan style.

Text after a ">" at the beginning of a line would turn all the text after it until a line break green.

>exactly like
this

I understand BBCode could do a job like this pretty simply, but we were looking for something automatic.

Would appreciate any help on this.

Simon Lloyd 02-05-2012 03:03 AM

Do you mean in each post?

Kybyrian 02-05-2012 03:33 AM

Quote:

Originally Posted by Simon Lloyd
Do you mean in each post?

Yeah, this would happen any time somebody makes a post with > at the beginning of a line.

Simon Lloyd 02-05-2012 03:53 AM

I'm no expert but i think you'll need to create a plugin maybe using the hook postdata_save and use some kind of replace function or maybe regex to match any line that starts with >

So the replace function COULD look like this
PHP Code:

$textstr_ireplace'>*' '<span style="font-color:green;">'/>*/'</span>'$text); 

--------------- Added [DATE]1328418603[/DATE] at [TIME]1328418603[/TIME] ---------------

Or maybe in PCRE format
PHP Code:

$string='>*'
$string preg_replace('/>*/i''<span style="font-color:green;">'/>*/'</span>'$string); 

I'm a real novice when it comes to REGEX so maybe this will get someone's attention and they'll be able to tweak it for you :)

Kybyrian 02-05-2012 08:37 AM

I managed to get this, stemming somewhat off of yours and hitting up regex and using the hook location postbit_display_complete.

PHP Code:

$pattern htmlspecialchars('/>.*/');
$replacement '<span style="color:green">text</span>';
$this->post['message'] = preg_replace($pattern$replacement$this->post['message']); 

This replaces anything after > on one line with the green word "text".

It seems I can perfectly call the text, but I cannot change its color. If I try to input "<span style=\"color:green\">$pattern</span>"; or any such thing in, it simply returns />.*/ instead of the actual text that regex defines. This occurs even when I place the regex itself in the span tags.

Simon Lloyd 02-05-2012 05:57 PM

Thats beacue in your REGEX (and im no expert!) you are replacing > with '<span style="color:green">text</span>' and not '<span style="color:green">/>*/</span>'

What i mean to say you need to replace >* (so > and wildcard) with >* but wrapped in the span, as it is your replacing it with the word "text" in green :)

Have you tried:
PHP Code:

$replacement '<span style="color:green">$pattern</span>'

or some variation with or without more single quotes?

Kybyrian 02-05-2012 07:31 PM

Yeah, I've actually tried that. It wasn't returning the text in the regex. I went a different route and got a working code. Thanks for you help, though, it gave me my starting point. :)

PHP Code:

$pattern htmlspecialchars('/(>.*)/');
$replacement '<span style="color:#789922">$1</span>';
$this->post['message'] = preg_replace($pattern$replacement$this->post['message']); 


Simon Lloyd 02-05-2012 07:33 PM

Ah yes, i remember that now "$1", glad i got you started :)

Zakalway 02-19-2013 05:55 AM

This works great, except it shows up as regular plain text when quoted.

Any way to make it appear as green text in quotes?

Never mind; it shows up fine in quotes. It just doesn't show up in reply previews.

itsRahul 04-05-2015 02:27 PM

sorry for the bump, but this does not seem to be working when I added a plugin to postbit_display_complete. is there something that needs to be changed to make it applicable to vb5?

it just doesn't modify the post at all

PHP Code:

$pattern htmlspecialchars('/(>.*)/');
$replacement '<span style="color:#789922">$1</span>';
$this->post['message'] = preg_replace($pattern$replacement$this->post['message']); 



All times are GMT. The time now is 07:05 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.01037 seconds
  • Memory Usage 1,747KB
  • 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
  • (6)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)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