How can I stop Syntext Highighting in MyBB with a mod
mrgtb Offline
Junior Member
**
Posts: 10
Joined: Jan 2011
Post: #1
How can I stop Syntext Highighting in MyBB with a mod
I've finished my mod now and testing shows it works perfect apart from one thing that I was aware of from the very start. A problem with "Search Highlighting" in MyBB that adds the colour span tag to all ed2k links added by the mod if a keyword in the links shown matches a search made. It messes things up, so want to try and stop Syntext Highlighting happening with the ed2k links displayed.

Is there anyway to stop this happening with link displayed by a plug-in (the ed2k links).

You can see the mod in action here:
Link: http://www.mrgtb.com/thread-291.html

But now look what happens to that same page if you look at it  (via a search result) below:

Link: http://www.mrgtb.com/thread-291.html?highlight=cookbook
(This post was last modified: 01-17-2011 12:46 PM by mrgtb.)
01-17-2011 12:38 PM
Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #2
RE: How can I stop Syntext Highighting in MyBB with a mod
If it's a MyCode, it shouldn't have this.
If it's a plugin, it may be affected.  If you have to implement it as a plugin, you may wish to try to reverse the effects of the highlight, or completely disable it.  An alternative method may be to try to insert your regular expression into the MyCode cache so that it's somewhat treated like a custom MyCode.

My Blog
01-17-2011 01:00 PM
Find all posts by this user Quote this message in a reply
mrgtb Offline
Junior Member
**
Posts: 10
Joined: Jan 2011
Post: #3
RE: How can I stop Syntext Highighting in MyBB with a mod
Sorry, but I don't really follow you. I've attached the plug-in itself below so you can take a look at it yourself and see what you think about the syntax highlighting problem..

I forgot to mention above also. I spotted another slight issue with the mod last night too. "Word Wrapping" in MyBB causes issues if you have it switched on using a low setting for breaking characters that are 80 long with no spaces. Most ed2k links are pretty long in general with no spaces so get broken and no longer work if word wrapping is in effect.

I did increase the setting to 110 from from 80 and that helped. But I wanted to ask is there a way to use Word Wrapping still, but disable it with the ed2k links posted by the mod so it doesn't break them?


Attached File(s)
.zip  ed2klinks.zip (Size: 1.35 KB / Downloads: 423)
(This post was last modified: 01-18-2011 12:43 AM by mrgtb.)
01-18-2011 12:17 AM
Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #4
RE: How can I stop Syntext Highighting in MyBB with a mod
So, it's a plugin, so it'll be affected by the highlight problem.  MyCodes are parsed before the highlight occurs, but plugins run after (in fact, you're hooking right at the end, so it's affected by everything that goes on earlier).
There's not really a nice solution - all the ones I can think of are rather "hacky".

EDIT: you should really take a look at inc/class_parser.php
One of the suggestions I made above is to hack the MyCode cache, eg:

PHP Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
$plugins->add_hook('parse_message_start', 'my_wonderful_hack');
function my_wonderful_hack(&$m) {
 // ugly to assume $parser is the object being dealt with, but I don't see much other choice here
 global $parser;
 if(!is_object($parser)) return $m;
 if(empty($parser->mycode_cache)) {
  // unfortunately, $parser->cache_mycode is private, so we work around this through a dummy message parse
  $parser->parse_mycode('');
  if(empty($parser->mycode_cache)) return $m;
 }
 $mcc =& $parser->mycode_cache['standard'];
 if(!isset($mcc['find']['ed2k'])) {
  $mcc['find']['ed2k'] = "#ed2k://\|file\|(.*?)\|([0-9]+)\|(.*?)\|/#e";
  $mcc['replace']['ed2k'] = "parse_ed2k_stuff('$1')";
 }
 return $m;
}

Above is just an idea - you'll need to modify it to suit your needs.

As for wordwrap, it's a weakness in MyBB itself unfortunately: http://community.mybb.com/thread-43152.html


My Blog
(This post was last modified: 01-18-2011 09:19 AM by ZiNgA BuRgA.)
01-18-2011 08:57 AM
Find all posts by this user Quote this message in a reply
mrgtb Offline
Junior Member
**
Posts: 10
Joined: Jan 2011
Post: #5
RE: How can I stop Syntext Highighting in MyBB with a mod
Thanks for the help, I can see there really is no easy solution to these two issues then. I mean, it was possible to not allow searching of the forum board that displayed ed2k links on it to avoid the search highlighting issue. But then that's really wasn't the answer and was just a work-around instead.

I wasn't really bothered though about it being a plug-in, if the issues could have been solved by hard-coded it all into php files instead. That would have been fine by me, as I have no intentions of upgrading past the MyBB 1.6.1 version that I'm using anyway, some files have already had some hard-code changes made already for some other features used there.
01-18-2011 02:55 PM
Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #6
RE: How can I stop Syntext Highighting in MyBB with a mod
If you don't mind editing files, take a look at inc/class_parser.php, in particular, this part:

PHP Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
		// Replace MyCode if requested.
		if($this->options['allow_mycode'])
		{
			$message = $this->parse_mycode($message, $this->options);
		}
		
		// Parse Highlights
		if($this->options['highlight'])
		{
			$message = $this->highlight_message($message, $this->options['highlight']);
		}

		// Run plugin hooks
		$message = $plugins->run_hooks("parse_message", $message);


My Blog
01-18-2011 03:39 PM
Find all posts by this user Quote this message in a reply
mrgtb Offline
Junior Member
**
Posts: 10
Joined: Jan 2011
Post: #7
RE: How can I stop Syntext Highighting in MyBB with a mod
(01-18-2011 03:39 PM)ZiNgA BuRgA Wrote:  If you don't mind editing files, take a look at inc/class_parser.php, in particular, this part:

PHP Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
		// Replace MyCode if requested.
		if($this->options['allow_mycode'])
		{
			$message = $this->parse_mycode($message, $this->options);
		}
		
		// Parse Highlights
		if($this->options['highlight'])
		{
			$message = $this->highlight_message($message, $this->options['highlight']);
		}

		// Run plugin hooks
		$message = $plugins->run_hooks("parse_message", $message);


I'm not sure what you want me to do with that file, in editing it?

I've attached my class_parser.php file below. Any chance you can do the edits to that file you think need doing manually. Then I can install the mod, over-right the php file with your edited one and test it.


Attached File(s)
.php  class_parser.php (Size: 34.84 KB / Downloads: 422)
(This post was last modified: 01-23-2011 05:22 AM by mrgtb.)
01-23-2011 05:21 AM
Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #8
RE: How can I stop Syntext Highighting in MyBB with a mod
(01-23-2011 05:21 AM)mrgtb Wrote:  I'm not sure what you want me to do with that file, in editing it?
I'm assuming you have enough PHP knowledge to understand what's going on in that file, or at least, that segment.
Sorry, I don't do modification requests.

What part are you having difficulty understanding?

My Blog
01-23-2011 10:37 AM
Find all posts by this user Quote this message in a reply
mrgtb Offline
Junior Member
**
Posts: 10
Joined: Jan 2011
Post: #9
RE: How can I stop Syntext Highighting in MyBB with a mod
I don't get what your talking about me changing or editing in that PHP file. But if you don't help with code modifications, it doesn't matter. I originally posted about this on MyBB and somebody recommended I visit your site and ask you for help with it.

I'm not that good with PHP, No! Which is why I really don't understand what your getting at that needs doing.
(This post was last modified: 01-23-2011 11:02 AM by mrgtb.)
01-23-2011 10:40 AM
Find all posts by this user Quote this message in a reply
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #10
RE: How can I stop Syntext Highighting in MyBB with a mod
Maybe try asking on MyBB again pointing back to this thread.  There's probably someone who can do this via a code edit over there I'd think.

Hope that helps.

My Blog
01-23-2011 05:58 PM
Find all posts by this user Quote this message in a reply

« Next Oldest | Next Newest »

 Standard Tools
Forum Jump: