collapse

* Simple Portal Archived Forum

This is an Archive Forum.

The content in this forum may be out-of-date or have been superseded by newer information, and links in forum pages to other sites may not work.
This forum contains archives for future reference.

Visit our thread at Simple Machines Forum for current support.

SMF 2.1 users: EhPortal is a ported version of Simple Portal specifically designed for the SMF 2.1 branch.
Please visit web-develop.ca to download EhPortal and for its support.

* User Info

 
 
Welcome, Guest. Please login or register.

* Who's Online

  • Dot Guests: 461
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.

* Shoutbox

Refresh History
  • Shoutbox is not for support!
  • {OCS}MasterSeal: Yup, Still adore SP
    April 21, 2019, 07:08:06 PM
  • {OCS}MasterSeal: STILL love SP :)
    November 24, 2018, 05:05:50 AM
  • ♦ Ninja ZX-10RR ♦: <3 aegersz
    September 13, 2018, 03:36:09 PM
  • aegersz: I STILL <3 LOVE SimplePortal
    September 13, 2018, 07:11:39 AM
  • aegersz: o LOVE you guys - Simple Portal rocks !
    May 09, 2018, 05:18:59 AM
  • Chen Zhen: our apologies for the site being down.. please read server issues topic
    March 22, 2018, 05:32:38 AM
  • {OCS}MasterSeal: LOL PLEASE forget I just posted that. I found the answer in my own dang post back in 2015. lol sorry!
    July 04, 2017, 10:47:55 PM
  • {OCS}MasterSeal: I know this SB isnt' for support, but I just have a general question. Who would I contact to find out where SP stores its block info? Is it DB driven or files? I searched the site but came up with nothing. probably my fault any insight is appreciated.
    July 04, 2017, 10:43:36 PM
  • ♦ Ninja ZX-10RR ♦: Excuse me but what does Simpleportal have to deal with that?
    February 05, 2017, 08:21:14 PM
  • WhiteEagle: of course IMHO that site appears to be dead :(
    February 04, 2017, 01:08:05 PM
  • WhiteEagle: If I can get that, then I'll use it for that site...
    February 04, 2017, 01:07:35 PM
  • WhiteEagle: decided to not use SMF for any projects, unless I can get a copy of the premium version of the fanfiction archive plugin
    February 04, 2017, 01:06:54 PM
  • expertdecisions: cloudflare
    January 28, 2017, 08:01:47 AM
  • aegersz: SM release 2.0.13 !
    January 12, 2017, 06:00:13 AM
  • raffo: Tks Emanuele, even if I didn't understand the fix :D
    November 07, 2016, 02:01:20 AM
  • emanuele: [link]
    November 01, 2016, 12:43:50 PM
  • emanuele: raffo: the English support board is a good place. ;)
    November 01, 2016, 12:43:38 PM
  • raffo: Where can I find the fix for the shoutbox?
    November 01, 2016, 05:06:09 AM
  • {OCS}MasterSeal: To the SP team, I make a point to come here and thank you as much as possible for your work.  so again, THANK YOU!
    October 28, 2016, 10:38:05 AM
  • emanuele: That's indeed funny, the limit is present only in the patch and not the full install.
    October 22, 2016, 06:14:58 PM

* Recent Posts

Adding Forums Button to Nav bar by jirapon
[August 01, 2019, 09:07:12 AM]


Re: Board Icons by ♦ Ninja ZX-10RR ♦
[July 30, 2019, 04:03:41 PM]


MOVED: Czech translation???? by ♦ Ninja ZX-10RR ♦
[July 30, 2019, 03:04:51 PM]


Board Icons by jirapon
[July 30, 2019, 07:28:44 AM]


Re: Thankyou Simpleportal, by ♦ Ninja ZX-10RR ♦
[July 29, 2019, 09:41:29 AM]

Blocks speak! Do you have an interest in getting more blocks - or even making your own? The Blocks Board is for you!

Author Topic: How to disable BBC tags in a block? And re-enable them afterwards?  (Read 5815 times)

0 Members and 1 Guest are viewing this topic.

Offline AngelinaBelle

  • Comrade
  • *
  • Posts: 4870
  • Gender: Female
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Having hunted through ModifyBBCSettings and parse_bbc, I thought I understood that the way to suppress BBC tags was to stuff them into $modSettings['disabledBBC'], then, later, set $modSettings['disabledBBC'] back to the way it started. 
 
But I'm not having much luck.
Within the block, I've attempted

 
echo 'disabled BBCcodes '$modSettings['disabledBBC'], '<br/>';
 
$supressTags = array('pdf','pdftest','flash');
 
$realdisabledbbc=$modSettings['disabledBBC'];
 
$temp=array();
 if (!empty(
$realdisabledbbc)) $temp=explode(','$realdisabledbbc);
 foreach (
$temp as $k => $tag)
  echo 
'$temp[',$k,'] '$tag'<br/>';
 foreach ( 
$supressTags as $k => $tag)
  if (! 
in_array($tag$tempTrue) ) $temp[]=$tag;
  
 foreach (
$temp as $k => $tag)
  echo 
'$temp[',$k,'] '$tag'<br/>';
 
$modSettings['disabledBBC'] = implode(',',$temp);
 
 echo 
'now disabled BBCcodes '$modSettings['disabledBBC'], '<br/>';

 
But the tags pdf and pdftest are not suppressed UNLESS I have unchecked them in the BBCcode admin panel.
 
Can anyone tell me what I am missing?
 
Thanks
« Last Edit: March 02, 2010, 04:42:39 PM by AngelinaBelle »
Please to keep this website running, if you like SimplePortal, make a
one-time subscription. Thank you for your support.

Have you tried the SimplePortal documentation?

Offline AngelinaBelle

  • Comrade
  • *
  • Posts: 4870
  • Gender: Female
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: How to disable BBC tags in a block?
« Reply #1 on: March 01, 2010, 10:41:06 AM »
So I've started hacking parse_bbc -- actually, I'm just filling it full of debugging echo statements.
 
I can see that, in general, $modSettings['disabledBBC'] is ignored because it is inside a block controlled by
[size=2]if (empty($bbc_codes) || $message === false)
[/
size]

 
So just shoving stuff into $modSettings['disabledBBC'] is clearly not going to work for me. So the statement at the top of the file
Quote
string parse_bbc(string message, bool smileys = true, string cache_id = '')
- this very hefty function parses bbc in message.
- only parses bbc tags which are not disabled in disabledBBC.
- also handles basic HTML, if enablePostHTML is on.
- caches the from/to replace regular expressions so as not to reload
them every time a string is parsed.
- only parses smileys if smileys is true.
- does nothing if the enableBBC setting is off.
- applies the fixLongWords magic if the setting is set to on.
- uses the cache_id as a unique identifier to facilitate any caching
it may do.
- returns the modified message.
Is clearly not true. It seems an extra call to parse_bbc with $message===False is required to stuff the contents of $modSettings['disabledBBC'] into static $disabled. It is really static $disabled that parse_bbc obeys.
 
I was stuck because I believed the documentation.
 
The correct solution is

 
echo 'disabled BBCcodes '$modSettings['disabledBBC'], '<br/>';
 
$supressTags = array('pdf','pdftest','flash');
 
$realdisabledbbc=$modSettings['disabledBBC'];
 
$temp=array();
 if (!empty(
$realdisabledbbc)) $temp=explode(','$realdisabledbbc);
 foreach (
$temp as $k => $tag)
  echo 
'$temp[',$k,'] '$tag'<br/>';
 foreach ( 
$supressTags as $k => $tag)
  if (! 
in_array($tag$tempTrue) ) $temp[]=$tag;
  
 
$modSettings['disabledBBC'] = implode(',',$temp);
 
parse_bbc(FALSE);

 
But that does not solve the problem of how to re-enable the tags after I'm done with the block!
« Last Edit: March 01, 2010, 10:44:53 AM by AngelinaBelle »
Please to keep this website running, if you like SimplePortal, make a
one-time subscription. Thank you for your support.

Have you tried the SimplePortal documentation?

Offline AngelinaBelle

  • Comrade
  • *
  • Posts: 4870
  • Gender: Female
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: How to disable BBC tags in a block? And re-enable them afterwards?
« Reply #2 on: March 01, 2010, 12:23:49 PM »
I feel awfully nervous about modifying parse_bbc.
 
But I can't see any way of removing tags from the disabled list after I'm done with the block.
 
If you call parse_bbc(FALSE), it updates its static $disabled by adding anything it finds in $modSettings['disabledBBC'], but does not remove anything. And since static $disabled is private to parse_bbc, there is no way to get to it outside of parse_bbc.
 
Here is my solution to re-enabling BBC tags at the end of the block
[size=2]  $modSettings['disabledBBC'] = $realdisabledbbc;
  
parse_bbc(FALSE);

[/
size]

 
And, in parse_BBC
Code: (find Subs.php) [Select]
  if (!empty($modSettings['disabledBBC']))
  {
   $temp = explode(',', strtolower($modSettings['disabledBBC']));
   foreach ($temp as $tag)
    $disabled[trim($tag)] = true;
  }
Code: (replace) [Select]
  if (!empty($modSettings['disabledBBC']))
  {
   $temp = explode(',', strtolower($modSettings['disabledBBC']));
   $disabled=array();
   foreach ($temp as $tag)
    $disabled[trim($tag)] = true;
  }
Please to keep this website running, if you like SimplePortal, make a
one-time subscription. Thank you for your support.

Have you tried the SimplePortal documentation?

Offline AngelinaBelle

  • Comrade
  • *
  • Posts: 4870
  • Gender: Female
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: How to disable BBC tags in a block? And re-enable them afterwards?
« Reply #3 on: March 02, 2010, 02:00:21 PM »
Actually, I was just told in http://www.smf-friends.org/index.php?topic=1300.msg27053#msg27053 that parse_bbc already has a mechanism for that.
 
So I think I'll stop fiddling with parse_bbc.
 
Here's the *real* solution to the problem:
Code: (function sp_articles in PortalBlocks.php) [Select]
$supressTags = array('pdf','pdftest','flash'); // add more tags to the list, if you want
 
 $parse_tags = array();
 $temp = parse_bbc(FALSE);
 foreach ($temp as $k => $code)
  if ( ! in_array($code['tag'],$supressTags) ) $parse_tags[]=$code['tag'];

and, further down in the same function,
Code: [Select]
   if (!empty($parameters['truncate']) && $func['strlen']($article['msg']['body']) > $parameters['truncate'] )
   {
     $article['msg']['body'] = sp_truncateText($article['msg']['body']);
     $articles[$k]['msg']['body'] =
      parse_bbc( $article['msg']['body'],
         $article['msg']['smileysEnabled'],
         $article['msg']['id'],
         $parse_tags
      ) . '<a href="'.$article['href'].'">...</a>';
   }
   else
    $articles[$k]['msg']['body'] = parse_bbc($article['msg']['body'], $article['msg']['smileysEnabled'],
          $article['msg']['id'], $parse_tags);

No modifications to parse_bbc required.
« Last Edit: March 02, 2010, 03:24:51 PM by AngelinaBelle »
Please to keep this website running, if you like SimplePortal, make a
one-time subscription. Thank you for your support.

Have you tried the SimplePortal documentation?

Offline [SiNaN]

  • Mr. SimplePortal
  • Developer
  • *
  • Posts: 6782
  • SMF Version: 2.0.15
  • SP Version: 2.3.7
Re: How to disable BBC tags in a block? And re-enable them afterwards?
« Reply #4 on: March 03, 2010, 08:43:50 AM »
Actually, I was just told in http://www.smf-friends.org/index.php?topic=1300.msg27053#msg27053 that parse_bbc already has a mechanism for that.

That functionality is a killer, unless you have SP installed. ;)
And slowly, you come to realize... It's all as it should be...

Offline AngelinaBelle

  • Comrade
  • *
  • Posts: 4870
  • Gender: Female
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: How to disable BBC tags in a block? And re-enable them afterwards?
« Reply #5 on: March 03, 2010, 09:53:32 AM »
That functionality is a killer, unless you have SP installed. ;)

What do you mean? That it is great, or that it causes poor performance?
Please to keep this website running, if you like SimplePortal, make a
one-time subscription. Thank you for your support.

Have you tried the SimplePortal documentation?

Offline [SiNaN]

  • Mr. SimplePortal
  • Developer
  • *
  • Posts: 6782
  • SMF Version: 2.0.15
  • SP Version: 2.3.7
Re: How to disable BBC tags in a block? And re-enable them afterwards?
« Reply #6 on: March 03, 2010, 11:30:44 AM »
Oh, right. I meant it is very poor on performance.
And slowly, you come to realize... It's all as it should be...

Offline AngelinaBelle

  • Comrade
  • *
  • Posts: 4870
  • Gender: Female
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: How to disable BBC tags in a block? And re-enable them afterwards?
« Reply #7 on: March 03, 2010, 12:44:20 PM »
So SP has improved the performance of that part of parse_bbc?
 
 
Please to keep this website running, if you like SimplePortal, make a
one-time subscription. Thank you for your support.

Have you tried the SimplePortal documentation?

Offline [SiNaN]

  • Mr. SimplePortal
  • Developer
  • *
  • Posts: 6782
  • SMF Version: 2.0.15
  • SP Version: 2.3.7
Re: How to disable BBC tags in a block? And re-enable them afterwards?
« Reply #8 on: March 03, 2010, 01:15:51 PM »
Yeah, it had to. It is used by shoutbox to limit the number of tags allowed. Without that fix, parsing a dozen of shouts made the forum unusable.
And slowly, you come to realize... It's all as it should be...

Offline AngelinaBelle

  • Comrade
  • *
  • Posts: 4870
  • Gender: Female
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: How to disable BBC tags in a block? And re-enable them afterwards?
« Reply #9 on: March 03, 2010, 02:11:41 PM »
OH! you are telling me that SP Adds the parse_tags parameter to parse_bbc?
I hadn't noticed. It looks like it is native to SMF2.0
 I, in my ignorance, had come up with another solution:  make parse_bbc obey $modSettings['disabledBBC'], so you can disable some BBC, parse the content, then re-enable the BBC.
 
I suppose the parse_tags solution performs better.
 
 
----------------------------------------
 
Anyway, I am thinking I probably should have posted my modified sp_articles block (http://simpleportal.net/index.php?board=39.0) in mods instead of in custom coding

 
 
 
« Last Edit: March 03, 2010, 02:13:46 PM by AngelinaBelle »
Please to keep this website running, if you like SimplePortal, make a
one-time subscription. Thank you for your support.

Have you tried the SimplePortal documentation?

Offline [SiNaN]

  • Mr. SimplePortal
  • Developer
  • *
  • Posts: 6782
  • SMF Version: 2.0.15
  • SP Version: 2.3.7
Re: How to disable BBC tags in a block? And re-enable them afterwards?
« Reply #10 on: March 03, 2010, 04:19:16 PM »
SP adds that functionality to 1.1 versions and fixes the performance issue on 2.0 versions.
And slowly, you come to realize... It's all as it should be...

Offline AngelinaBelle

  • Comrade
  • *
  • Posts: 4870
  • Gender: Female
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: How to disable BBC tags in a block? And re-enable them afterwards?
« Reply #11 on: March 03, 2010, 06:03:15 PM »
That's why we love the SimplePortal!
Please to keep this website running, if you like SimplePortal, make a
one-time subscription. Thank you for your support.

Have you tried the SimplePortal documentation?