Changeset 20796
- Timestamp:
- Feb 17, 2013, 12:52:57 PM (11 years ago)
- Location:
- extensions/bbcode_bar
- Files:
-
- 3 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); -
extensions/bbcode_bar/main.inc.php
r20209 r20796 21 21 remove_event_handler('render_comment_content', 'render_comment_content'); 22 22 add_event_handler('render_comment_content', 'BBCodeParse'); 23 add_event_handler('render_contact_content', 'BBCodeParse'); 23 24 add_event_handler('loc_after_page_header', 'add_bbcode_bar'); 24 25 } … … 31 32 { 32 33 $prefilter = 'picture'; 34 $textarea_id = 'contentid'; 33 35 } 34 36 else if ( … … 38 40 { 39 41 $prefilter = 'comments_on_albums'; 42 $textarea_id = 'contentid'; 40 43 } 41 44 else if (isset($page['section']) and $page['section'] == 'guestbook') 42 45 { 43 46 $prefilter = 'index'; 47 $textarea_id = 'contentid'; 48 } 49 else if (isset($page['section']) and $page['section'] == 'contact') 50 { 51 $prefilter = 'index'; 52 $textarea_id = 'cf_content'; 44 53 } 45 54 46 55 if (isset($prefilter)) 47 56 { 48 set_bbcode_bar($prefilter );57 set_bbcode_bar($prefilter, $textarea_id); 49 58 } 50 59 } -
extensions/bbcode_bar/template/bbcode_bar.tpl
r15998 r20796 7 7 {counter start=0 print=false assign=bbc_counter} 8 8 9 {if isset($BBC_b)}{counter}{ldelim}name:'{'Bold : [b]bold[/b]'|@translate}', key:'B', openWith:'[b]', closeWith:'[/b]', className:'markItUpBold'},{/if}10 {if isset($BBC_i)}{counter}{ldelim}name:'{'Italic : [i]italic[/i]'|@translate}', key:'I', openWith:'[i]', closeWith:'[/i]', className:'markItUpItalic'},{/if}11 {if isset($BBC_u)}{counter}{ldelim}name:'{'Underline : [u]underline[/u]'|@translate}', key:'U', openWith:'[u]', closeWith:'[/u]', className:'markItUpUnderline'},{/if}12 {if isset($BBC_s)}{counter}{ldelim}name:'{'Striped : [s]striped[/s]'|@translate}', key:'S', openWith:'[s]', closeWith:'[/s]', className:'markItUpStroke'},{/if}9 {if $BBC.b}{counter}{ldelim}name:'{'Bold : [b]bold[/b]'|@translate}', key:'B', openWith:'[b]', closeWith:'[/b]', className:'markItUpBold'},{/if} 10 {if $BBC.i}{counter}{ldelim}name:'{'Italic : [i]italic[/i]'|@translate}', key:'I', openWith:'[i]', closeWith:'[/i]', className:'markItUpItalic'},{/if} 11 {if $BBC.u}{counter}{ldelim}name:'{'Underline : [u]underline[/u]'|@translate}', key:'U', openWith:'[u]', closeWith:'[/u]', className:'markItUpUnderline'},{/if} 12 {if $BBC.s}{counter}{ldelim}name:'{'Striped : [s]striped[/s]'|@translate}', key:'S', openWith:'[s]', closeWith:'[/s]', className:'markItUpStroke'},{/if} 13 13 14 {if (isset($BBC_p) OR isset($BBC_center) OR isset($BBC_right) OR isset($BBC_quote)) AND $bbc_counter>0}{counter start=0 print=false assign=bbc_counter}{ldelim}separator:'|'},{/if}14 {if $SEP[0]}{counter}{ldelim}separator:'|'},{/if} 15 15 16 {if isset($BBC_p)}{counter}{ldelim}name:'{'Paragraph : [p]Paragraph[/p]'|@translate}', openWith:'[p]', closeWith:'[/p]', className:'markItUpParagraph'},{/if}17 {if isset($BBC_center)}{counter}{ldelim}name:'{'Center : [center]center[/center]'|@translate}', openWith:'[center]', closeWith:'[/center]', className:'markItUpCenter'},{/if}18 {if isset($BBC_right)}{counter}{ldelim}name:'{'Right : [right]right[/right]'|@translate}', openWith:'[right]', closeWith:'[/right]', className:'markItUpRight'},{/if}19 {if isset($BBC_quote)}{counter}{ldelim}name:'{'Quote : [quote]quote[/quote]'|@translate}', openWith:'[quote]', closeWith:'[/quote]', className:'markItUpQuote'},{/if}16 {if $BBC.p}{counter}{ldelim}name:'{'Paragraph : [p]Paragraph[/p]'|@translate}', openWith:'[p]', closeWith:'[/p]', className:'markItUpParagraph'},{/if} 17 {if $BBC.center}{counter}{ldelim}name:'{'Center : [center]center[/center]'|@translate}', openWith:'[center]', closeWith:'[/center]', className:'markItUpCenter'},{/if} 18 {if $BBC.right}{counter}{ldelim}name:'{'Right : [right]right[/right]'|@translate}', openWith:'[right]', closeWith:'[/right]', className:'markItUpRight'},{/if} 19 {if $BBC.quote}{counter}{ldelim}name:'{'Quote : [quote]quote[/quote]'|@translate}', openWith:'[quote]', closeWith:'[/quote]', className:'markItUpQuote'},{/if} 20 20 21 {if (isset($BBC_ul) OR isset($BBC_ol) OR isset($BBC_li)) AND $bbc_counter>0}{counter start=0 print=false assign=bbc_counter}{ldelim}separator:'|'},{/if}21 {if $SEP[1]}{counter}{ldelim}separator:'|'},{/if} 22 22 23 {if isset($BBC_ul)}{counter}{ldelim}name:'{'Unordered list : [ul][li]element[/li][/ul]'|@translate}', openWith:'[ul]\n', closeWith:'\n[/ul]', className:'markItUpListUL'},{/if}24 {if isset($BBC_ol)}{counter}{ldelim}name:'{'Ordered list : [ol][li]element[/li][/ol]'|@translate}', openWith:'[ol]\n', closeWith:'\n[/ol]', className:'markItUpListOL'},{/if}25 {if isset($BBC_ul) OR isset($BBC_ol)}{counter}{ldelim}name:'{'List element : [li]element[/li]'|@translate}', openWith:'[li]', closeWith:'[/li]', className:'markItUpListLI'},{/if}23 {if $BBC.ul}{counter}{ldelim}name:'{'Unordered list : [ul][li]element[/li][/ul]'|@translate}', openWith:'[ul]\n', closeWith:'\n[/ul]', className:'markItUpListUL'},{/if} 24 {if $BBC.ol}{counter}{ldelim}name:'{'Ordered list : [ol][li]element[/li][/ol]'|@translate}', openWith:'[ol]\n', closeWith:'\n[/ol]', className:'markItUpListOL'},{/if} 25 {if $BBC.ul OR $BBC.ol}{counter}{ldelim}name:'{'List element : [li]element[/li]'|@translate}', openWith:'[li]', closeWith:'[/li]', className:'markItUpListLI'},{/if} 26 26 27 {if (isset($BBC_img) OR isset($BBC_url) OR isset($BBC_mail)) AND $bbc_counter>0}{counter start=0 print=false assign=bbc_counter}{ldelim}separator:'|' },{/if}27 {if $SEP[2]}{counter}{ldelim}separator:'|' },{/if} 28 28 29 {if isset($BBC_img)}{counter}{ldelim}name:'{'Picture : [img]picture[/img]'|@translate}', key:'P', replaceWith:'[img][![Url]!][/img]', className:'markItUpPicture'},{/if}30 {if isset($BBC_url)}{counter}{ldelim}name:'{'URL : [url=URL]Title[/url]'|@translate}', key:'L', openWith:'[url=[![Url]!]]', closeWith:'[/url]', className:'markItUpLink'},{/if}31 {if isset($BBC_email)}{counter}{ldelim}name:'{'E-mail : [email]Email[/email]'|@translate}', key:'M', replaceWith:'[email][![Mail]!][/email]', className:'markItUpMail'},{/if}29 {if $BBC.img}{counter}{ldelim}name:'{'Picture : [img]picture[/img]'|@translate}', key:'P', replaceWith:'[img][![Url]!][/img]', className:'markItUpPicture'},{/if} 30 {if $BBC.url}{counter}{ldelim}name:'{'URL : [url=URL]Title[/url]'|@translate}', key:'L', openWith:'[url=[![Url]!]]', closeWith:'[/url]', className:'markItUpLink'},{/if} 31 {if $BBC.email}{counter}{ldelim}name:'{'E-mail : [email]Email[/email]'|@translate}', key:'M', replaceWith:'[email][![Mail]!][/email]', className:'markItUpMail'},{/if} 32 32 33 {if (isset($BBC_size) OR isset($BBC_color) OR isset($BBC_smilies)) AND $bbc_counter>0}{counter start=0 print=false assign=bbc_counter}{ldelim}separator:'|'},{/if}33 {if $SEP[3]}{counter}{ldelim}separator:'|'},{/if} 34 34 35 {if isset($BBC_size)}{counter}35 {if $BBC.size}{counter} 36 36 {ldelim}name:'{'Font size : [size=X]text[/size]'|@translate}', className:'markItUpSize', 37 37 dropMenu :[ … … 44 44 }, 45 45 {/if} 46 {if isset($BBC_color)}{counter}46 {if $BBC.color}{counter} 47 47 {ldelim}name:'{'Font color : [color=color]text[/color]'|@translate}', className:'markItUpColors', openWith:'[color=[![Color]!]]', closeWith:'[/color]', 48 48 dropMenu: [ … … 65 65 66 66 jQuery(document).ready(function() {ldelim} 67 jQuery('#contentid').markItUp(BBCodeBar); 67 jQuery('#{$BBCODE_ID}').markItUp(BBCodeBar); 68 jQuery('.markItUpHeader>ul').css('width', {$bbc_counter}*22); 68 69 }); 69 70 {/footer_script}
Note: See TracChangeset
for help on using the changeset viewer.