Changeset 20796 for extensions/bbcode_bar/bbcode_bar.inc.php
- Timestamp:
- Feb 17, 2013, 12:52:57 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/bbcode_bar/bbcode_bar.inc.php
r15998 r20796 3 3 4 4 // add BBCodeBar to textarea 5 function set_bbcode_bar($prefilter='picture' )5 function set_bbcode_bar($prefilter='picture', $textarea_id='contentid') 6 6 { 7 7 global $template, $conf, $pwg_loaded_plugins, $page; … … 9 9 load_language('plugin.lang', dirname(__FILE__) . '/'); 10 10 $conf_bbcode_bar = unserialize($conf['bbcode_bar']); 11 11 12 12 13 // buttons 13 foreach(unserialize(BBcode_codes) as $key) 14 { 15 if ($conf_bbcode_bar[$key]) $template->assign('BBC_'.$key, true); 16 } 17 18 $template->assign('BBCODE_PATH', BBcode_PATH); 14 $tpl_codes = array(); 15 foreach (unserialize(BBcode_codes) as $key) 16 { 17 $tpl_codes[$key] = (bool)$conf_bbcode_bar[$key]; 18 } 19 $tpl_codes['smilies'] = isset($pwg_loaded_plugins['SmiliesSupport']); 20 21 22 // calculate separators between groups 23 $groups = array( 24 array('b','i','u','s'), 25 array('p','center','right','quote'), 26 array('ol','ul'), 27 array('img','url','email'), 28 array('size','color','smilies'), 29 ); 30 31 $tpl_groups = array(); 32 $count = 0; 33 for ($i=0; $i<count($groups)-1; $i++) 34 { 35 $separator = false; 36 foreach ($groups[$i] as $code) 37 { 38 if ($tpl_codes[$code]) $count++; 39 } 40 if ($count>0) 41 { 42 foreach ($groups[$i+1] as $code) 43 { 44 if ($tpl_codes[$code]) $separator = true; 45 } 46 } 47 if ($separator) 48 { 49 $tpl_groups[$i] = true; 50 $count = 0; 51 } 52 } 53 54 $template->assign(array( 55 'BBC' => $tpl_codes, 56 'SEP' => $tpl_groups, 57 'BBCODE_PATH' => BBcode_PATH, 58 'BBCODE_ID' => $textarea_id, 59 )); 60 19 61 $template->set_prefilter($prefilter, 'set_bbcode_bar_prefilter'); 20 62 … … 22 64 if (isset($pwg_loaded_plugins['SmiliesSupport'])) 23 65 { 24 $template->assign('BBC_smilies', true);25 66 set_smiliessupport($prefilter); 26 67 } … … 29 70 function set_bbcode_bar_prefilter($content, &$smarty) 30 71 { 31 $search = '#(<div id="guestbookAdd">|<div id="commentAdd"> )#';72 $search = '#(<div id="guestbookAdd">|<div id="commentAdd">|<div class="contact">)#'; 32 73 $replace = file_get_contents(BBcode_PATH.'/template/bbcode_bar.tpl').'$1'; 33 74 return preg_replace($search, $replace, $content);
Note: See TracChangeset
for help on using the changeset viewer.