Login
Username

Password



Not a member yet?
Click here to register.

Forgotten your password?
Request a new one here.
Navigation
Latest Addons
Cookiebar Panel 11
AD Gallery 68
SyntaxHighlighte... 51
Newsletters v4.03 115
Facebook Like Box 135
Newsletters v4.02 61
Metro 173
Facebook Connect 174
Shoutbox Panel 131
Redactor for PHP... 107
MI Floating Side... 109
Facebook Login/R... 156
Avatar Studio v2.03 180
Relationship Sta... 98
Sexual Orientati... 116
Popular Addons
iTheme2 5810
Arise 5808
User Control v1.23 4625
Event Calendar 4060
Photowidget panel 3889
Radio-Theme red2... 3360
Highslide Gallery 3315
CSS/JavaScript D... 3234
Facebook Connect... 2992
Dynamic Menu 2896
Slideshow Lightb... 2729
L-AMANT 2662
Enigma 2637
2Dark 2608
Black 2580
View Thread
Official Home of PHP-Fusion » General Addon and Modification Support » Panels and Infusions
Who is here? 1 guest(s)
 Print Thread
parseubb() question
skpacman
I was wondering if there was a way to parse all bbcodes excluding a single one instead of listing all of the ones to parse.

The article at Next doesn't cover it completely.

My code is:

Download source  Code
$description = nl2br(parseubb(parsesmileys($snippet['description']), "b|i|u|url|left|center|justify|right|code|quote|olist|ulist|color|size|hide|fpnotice|fieldset"));





But I'm wondering if there's a way to exclude bbcodes from parse instead of listing the ones to include.

Is this possible or am I forced to do it the long way?
 
http://www.php-fusion.us
Tyler
I think it is the one's you wish to include... You could store the list in a variable... you'd have to do it at least once but if its something you repeat or often use its nice.
 
skpacman
Thanks for your suggestion Mittens Returns.

I found a solution. My overall goal for this was to remove the GeSHi bbcode but leave all else because it conflicted with some of my other code.

I used a custom function and a few variables and tricks later, I have exactly what I wanted :D see below

Download source  Code
function remove_element($arr, $val){
foreach ($arr as $key => $value){
if ($arr[$key] == $val){
unset($arr[$key]);
}
}
return $arr = array_values($arr);
}

$bbcode_cache = remove_element($bbcode_cache, 'geshi');

$csp_bb = implode('|', $bbcode_cache);

echo $csp_bb;




Bascially what the function does is search the $bbcode_cache array set by php-fusion's bbcode_include.php for the value 'geshi' then unsets that key, implodes it into a string, and returns it as a variable you can plug into the parseubb

so then my parseubb code is severely simplified to:

Download source  Code
$description = nl2br(parseubb(parsesmileys($snippet['description']), $csp_bb));





Again, thanks for your reply, it made me realize that a custom function would be required to do what I wanted. I was just hoping for a simpler solution built into the parseubb function.
 
http://www.php-fusion.us
Tyler
good job. found your answer and did it yourself. there's nothing wrong with what you did and there isn't anything special about this other than one less function to call. its the core parseubb function changed. to use it call parseubb($text, false, $list_to_avoid)

the list must be separated by | as the include. if you stick with what you have its cool. if you do use it, overwrite parseubb function in maincore.php
Tyler attached the following file:
parseubb_modified.zip [497Bytes / 71 Downloads]
 
skpacman
Thanks again. I'm trying to make this portable though (an infusion I'm building) so I don't want people to have to edit the maincore just to get this working.

I think I'll stick with my solution. I like your modification though, I'll keep it in mind.

Merged on Mar 21 2012 at 10:59:13:
Yet another case of "Seek and ye shall find."

I found an even easier way to do it without modifying core files and no need for special functions.

Download source  Code
if (!$bbcode_cache) { cache_bbcode(); }
if (in_array("geshi", $bbcode_cache)){
$csp_bb = implode('|', $bbcode_cache);
$csp_bb = str_replace("|geshi", "", $csp_bb);
} else {
$csp_bb = implode('|', $bbcode_cache);
}




then just use $csp_bb (or whatever you want to name it) as your pipe " | " separated list

For your own purposes, you can replace "geshi" with any kind of bbcode name you want. This is useful if you want to show all available bbcodes excluding a single one. It could also be expanded to get rid if several others just by removing the if in_array and doing multiple str_replace calls.
Edited by skpacman on 21-03-2012 17:59
 
http://www.php-fusion.us
Tyler
That's nice. I guess if this was implemented in fusion core as I did you wouldn't need any extra coding at all.

BTW: What exactly are you working on?
 
skpacman
Mittens Returns wrote:
BTW: What exactly are you working on?


I'm making an infusion by special request from Lenoox (on my site)

Details on my forum.

The infusion is nearly complete and will be released as soon as I'm done correcting a few errors and updating the security and version of geshi i'm using.
 
http://www.php-fusion.us
Jump to Forum:
Similar Threads
Thread Forum Replies Last Post
Cookie question Suspected Bugs and Errors 17 14-05-2013 03:39
dumb question about file pages Content Administration 6 09-04-2013 05:16
News parseubb Content Administration 3 10-02-2013 18:52
Registration Security Question Security Issues & Announcements 10 25-01-2013 16:12
FIXED maincore 7.02.05 trimlink function bug (trapezoid with question mark) Suspected Bugs and Errors 2 21-01-2013 02:14
Official Home of PHP-Fusion uses cookies. Some may already have been set. Read more about our Cookies here.
Please click the button I Consent Cookies to hide this bar and accept our cookies. If you continue to use the site with no action taken, we'll assume that you consent our cookies anyway.
Cookiebar Panel byVenue