Go Back   vb.org Archive > Community Discussions > Modification Requests/Questions (Unpaid)

Reply
 
Thread Tools Display Modes
  #1  
Old 02-05-2012, 03:00 AM
Kybyrian Kybyrian is offline
 
Join Date: Oct 2011
Posts: 23
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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.
Reply With Quote
  #2  
Old 02-05-2012, 03:03 AM
Simon Lloyd's Avatar
Simon Lloyd Simon Lloyd is offline
 
Join Date: Aug 2008
Location: Manchester
Posts: 3,481
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Do you mean in each post?
Reply With Quote
  #3  
Old 02-05-2012, 03:33 AM
Kybyrian Kybyrian is offline
 
Join Date: Oct 2011
Posts: 23
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #4  
Old 02-05-2012, 03:53 AM
Simon Lloyd's Avatar
Simon Lloyd Simon Lloyd is offline
 
Join Date: Aug 2008
Location: Manchester
Posts: 3,481
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
  #5  
Old 02-05-2012, 08:37 AM
Kybyrian Kybyrian is offline
 
Join Date: Oct 2011
Posts: 23
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #6  
Old 02-05-2012, 05:57 PM
Simon Lloyd's Avatar
Simon Lloyd Simon Lloyd is offline
 
Join Date: Aug 2008
Location: Manchester
Posts: 3,481
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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?
Reply With Quote
  #7  
Old 02-05-2012, 07:31 PM
Kybyrian Kybyrian is offline
 
Join Date: Oct 2011
Posts: 23
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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']); 
Reply With Quote
  #8  
Old 02-05-2012, 07:33 PM
Simon Lloyd's Avatar
Simon Lloyd Simon Lloyd is offline
 
Join Date: Aug 2008
Location: Manchester
Posts: 3,481
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Ah yes, i remember that now "$1", glad i got you started
Reply With Quote
  #9  
Old 02-19-2013, 05:55 AM
Zakalway Zakalway is offline
 
Join Date: Nov 2012
Posts: 20
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #10  
Old 04-05-2015, 02:27 PM
itsRahul itsRahul is offline
 
Join Date: Oct 2011
Posts: 29
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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']); 
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 05:02 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.04733 seconds
  • Memory Usage 2,260KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (6)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • 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
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete