diff options
author | Ludovic Arnaud <ludovic_arnaud@users.sourceforge.net> | 2003-08-10 18:30:27 +0000 |
---|---|---|
committer | Ludovic Arnaud <ludovic_arnaud@users.sourceforge.net> | 2003-08-10 18:30:27 +0000 |
commit | b11ed262ac862f7ec8b8d96b53f65d1d1df7477e (patch) | |
tree | 775fa5f2dae43974d1c8689b9c451b0bd3b4a6dd /phpBB/includes/bbcode.php | |
parent | 214ea917e562949f11c3d3e7a1135ba6b546d559 (diff) | |
download | forums-b11ed262ac862f7ec8b8d96b53f65d1d1df7477e.tar forums-b11ed262ac862f7ec8b8d96b53f65d1d1df7477e.tar.gz forums-b11ed262ac862f7ec8b8d96b53f65d1d1df7477e.tar.bz2 forums-b11ed262ac862f7ec8b8d96b53f65d1d1df7477e.tar.xz forums-b11ed262ac862f7ec8b8d96b53f65d1d1df7477e.zip |
Primary / secondary style bbcode implementation. Not thoroughly tested yet but my test board still functions so I guess it works ;)
git-svn-id: file:///svn/phpbb/trunk@4363 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/includes/bbcode.php')
-rw-r--r-- | phpBB/includes/bbcode.php | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/phpBB/includes/bbcode.php b/phpBB/includes/bbcode.php index c40167549c..b7567f2c88 100644 --- a/phpBB/includes/bbcode.php +++ b/phpBB/includes/bbcode.php @@ -26,6 +26,9 @@ class bbcode var $bbcode_cache = array(); var $bbcode_template = array(); + var $template_bitfield = 0; + var $template_filename = ''; + function bbcode($bitfield = 0) { if ($bitfield) @@ -55,7 +58,7 @@ class bbcode { $this->bbcode_cache_init(); } - +//echo'<pre>';print_r($this); $str = array('search' => array(), 'replace' => array()); $preg = array('search' => array(), 'replace' => array()); @@ -96,10 +99,26 @@ class bbcode // function bbcode_cache_init() { - global $user; + if (empty($this->template_filename)) + { + global $user, $phpbb_root_path; - $sql = ''; + $style = 'primary'; + if (!empty($user->theme['secondary'])) + { + $merged_bitfield = $user->theme['primary']['bbcode_bitfield'] | $user->theme['secondary']['bbcode_bitfield']; + if ($this->bbcode_bitfield & $merged_bitfield) + { + $style = (file_exists($phpbb_root_path . 'styles/templates/' . $user->theme['primary']['template_path'] . '/bbcode.html')) ? 'primary' : 'secondary'; + } + } + + $this->template_bitfield = $user->theme[$style]['bbcode_bitfield']; + $this->template_filename = $phpbb_root_path . 'styles/templates/' . $user->theme[$style]['template_path'] . '/bbcode.html'; + } + + $sql = ''; $bbcode_ids = array(); $bitlen = strlen(decbin($this->bbcode_bitfield)); @@ -257,8 +276,6 @@ class bbcode function bbcode_tpl($tpl_name, $bbcode_id = -1) { - global $template, $user; - if (empty($bbcode_hardtpl)) { static $bbcode_hardtpl = array( @@ -276,7 +293,7 @@ class bbcode ); } - if ($bbcode_id != -1 && !($user->theme['primary']['bbcode_bitfield'] & (1 << $bbcode_id))) + if ($bbcode_id != -1 && !($this->template_bitfield & (1 << $bbcode_id))) { return $bbcode_hardtpl[$tpl_name]; } @@ -291,7 +308,7 @@ class bbcode { trigger_error('Could not load bbcode template'); } - $tpl = fread($fp, filesize($tpl_filename)); + $tpl = fread($fp, filesize($this->template_filename)); @fclose($fp); // replace \ with \\ and then ' with \'. |