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
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.
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?
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:
$plugins->add_hook('parse_message_start', 'my_wonderful_hack');
function my_wonderful_hack(&$m) {
global $parser;
if(!is_object($parser)) return $m;
if(empty($parser->mycode_cache)) {
$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
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.
If you don't mind editing files, take a look at inc/class_parser.php, in particular, this part:
PHP Code:
if($this->options['allow_mycode'])
{
$message = $this->parse_mycode($message, $this->options);
}
if($this->options['highlight'])
{
$message = $this->highlight_message($message, $this->options['highlight']);
}
$message = $plugins->run_hooks("parse_message", $message);
|
(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:
if($this->options['allow_mycode'])
{
$message = $this->parse_mycode($message, $this->options);
}
if($this->options['highlight'])
{
$message = $this->highlight_message($message, $this->options['highlight']);
}
$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.
(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?
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.
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.