Someone Posted January 19, 2013 Share Posted January 19, 2013 (edited) When I first started making the youtube link parser, I had this issue. It suddenly worked, thought it was magic. Turns out I had made changes to the core engine files doh. To be specific I had moved lines 1385 and 1386 (libs/common.php) to after the Pretty Message hook has ran, and renamed the variables to match up. RunHook("pretty_message.php", "sourceText"); $sourceText = preg_replace_callback('/(^|[^' . "'" . '])(http(|s):\/\/[a-zA-Z0-9\/\-\+:\.\?=_\&\#\;\%\,]*(\.jpg|\.jpeg|\.gif|\.png))($|[^' . "'" . '])/', "PrettyMessageImageReplace", $sourceText); $sourceText = preg_replace_callback('/(^|\s|\>)(http[s]{0,1}:\/\/[a-zA-Z0-9\/\-\+:\.\?=_\&\#\;\%\,]{1,30})([a-zA-Z0-9\/\-\+:\.\?=_\&\#\;\%\,]*)/', "PrettyMessageLinkReplace", $sourceText); Its not fair that the engine calls first dips on changing links and images :p Edited January 19, 2013 by Someone Quote Link to comment Share on other sites More sharing options...
a_bertrand Posted January 19, 2013 Share Posted January 19, 2013 Mmm prioritize the order of an hook is not something currently in. I will have to think about it. Quote Link to comment Share on other sites More sharing options...
Someone Posted January 19, 2013 Author Share Posted January 19, 2013 I am not really requesting priority of hooks, although that could perhaps be useful. I just request that the hook is ran before the hard coded reg expression. Quote Link to comment Share on other sites More sharing options...
a_bertrand Posted January 19, 2013 Share Posted January 19, 2013 Ok will change than in the engine. Shall be in, in the next release. Quote Link to comment Share on other sites More sharing options...
Someone Posted January 19, 2013 Author Share Posted January 19, 2013 Sweet, thanks, hope it doesn't crash anything serious :rolleyes: Haha, I have tested some links, and they still work fine this way around. Nobody has pointed out that my module dont work with raw youtube links, so no time pressure from me on this. Quote Link to comment Share on other sites More sharing options...
gmoore Posted January 19, 2013 Share Posted January 19, 2013 I haven't found a youtube use for it yet but I thought it was a great idea. Especially in the future to let players link in 'how to' play type videos. Greg Quote Link to comment Share on other sites More sharing options...
Djkanna Posted January 19, 2013 Share Posted January 19, 2013 I haven't found a youtube use for it yet but I thought it was a great idea. Especially in the future to let players link in 'how to' play type videos. Greg It's also handy in profile signatures, for 'profile music' related to their character. Joan Jett - I love playing with fire, for this little rebel. (on that note who ever removed my Mr Rebel user title here, is a bar-steward.) Quote Link to comment Share on other sites More sharing options...
Someone Posted January 19, 2013 Author Share Posted January 19, 2013 I haven't found a youtube use for it yet but I thought it was a great idea. Especially in the future to let players link in 'how to' play type videos. Greg Users like to place videos on their profile, forum posts, messages to each other etc. You got me thinking, videos should perhaps not be in _all_ places where pretty message is used. Might add a setting for that. The change is needed for just about any change to urls or images, because the hard coded parsing will change it before you can through the hook. Quote Link to comment Share on other sites More sharing options...
a_bertrand Posted January 19, 2013 Share Posted January 19, 2013 well the pretty message hook could provide a "where" parameter and tell you where it's used, and then you decide to act or not. Quote Link to comment Share on other sites More sharing options...
Someone Posted January 19, 2013 Author Share Posted January 19, 2013 (edited) well the pretty message hook could provide a "where" parameter and tell you where it's used, and then you decide to act or not. ^That sounds like viable solution. Tested using this in prettymessage.php This detected the correct module in profile, messages and forum. But pretty sure it will fail in some cases. Like if you have two pretty messages boxes on one page, and want something only available in one. $callers = debug_backtrace(); echo $callers[4]['args'][0]; /* echo '<pre>'; print_r($callers); echo '</pre>'; */ Edited January 19, 2013 by Someone Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.