Changeset 20796


Ignore:
Timestamp:
Feb 17, 2013, 12:52:57 PM (7 years ago)
Author:
mistic100
Message:

add bbcode bar on contactform

Location:
extensions/bbcode_bar
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • extensions/bbcode_bar/bbcode_bar.inc.php

    r15998 r20796  
    33
    44// add BBCodeBar to textarea
    5 function set_bbcode_bar($prefilter='picture')
     5function set_bbcode_bar($prefilter='picture', $textarea_id='contentid')
    66{
    77  global $template, $conf, $pwg_loaded_plugins, $page;
     
    99  load_language('plugin.lang', dirname(__FILE__) . '/');
    1010  $conf_bbcode_bar = unserialize($conf['bbcode_bar']);
    11 
     11 
     12 
    1213  // 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 
    1961  $template->set_prefilter($prefilter, 'set_bbcode_bar_prefilter');   
    2062
     
    2264  if (isset($pwg_loaded_plugins['SmiliesSupport']))
    2365  {
    24     $template->assign('BBC_smilies', true);
    2566    set_smiliessupport($prefilter);
    2667  } 
     
    2970function set_bbcode_bar_prefilter($content, &$smarty)
    3071{
    31   $search = '#(<div id="guestbookAdd">|<div id="commentAdd">)#';
     72  $search = '#(<div id="guestbookAdd">|<div id="commentAdd">|<div class="contact">)#';
    3273  $replace = file_get_contents(BBcode_PATH.'/template/bbcode_bar.tpl').'$1';
    3374  return preg_replace($search, $replace, $content);
  • extensions/bbcode_bar/main.inc.php

    r20209 r20796  
    2121  remove_event_handler('render_comment_content', 'render_comment_content');
    2222  add_event_handler('render_comment_content', 'BBCodeParse');
     23  add_event_handler('render_contact_content', 'BBCodeParse');
    2324  add_event_handler('loc_after_page_header', 'add_bbcode_bar');
    2425}
     
    3132  {
    3233    $prefilter = 'picture';
     34    $textarea_id = 'contentid';
    3335  }
    3436  else if (
     
    3840  {
    3941    $prefilter = 'comments_on_albums';
     42    $textarea_id = 'contentid';
    4043  }
    4144  else if (isset($page['section']) and $page['section'] == 'guestbook')
    4245  {
    4346    $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';
    4453  }
    4554 
    4655  if (isset($prefilter))
    4756  {
    48     set_bbcode_bar($prefilter);
     57    set_bbcode_bar($prefilter, $textarea_id);
    4958  }
    5059}
  • extensions/bbcode_bar/template/bbcode_bar.tpl

    r15998 r20796  
    77    {counter start=0 print=false assign=bbc_counter}
    88   
    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}
    1313   
    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}
    1515   
    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}
    2020   
    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}
    2222   
    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}
    2626   
    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}
    2828   
    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}
    3232   
    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}
    3434   
    35     {if isset($BBC_size)}{counter}
     35    {if $BBC.size}{counter}
    3636    {ldelim}name:'{'Font size : [size=X]text[/size]'|@translate}', className:'markItUpSize',
    3737      dropMenu :[
     
    4444    },
    4545    {/if}
    46     {if isset($BBC_color)}{counter}
     46    {if $BBC.color}{counter}
    4747    {ldelim}name:'{'Font color : [color=color]text[/color]'|@translate}', className:'markItUpColors', openWith:'[color=[![Color]!]]', closeWith:'[/color]',
    4848      dropMenu: [
     
    6565
    6666jQuery(document).ready(function() {ldelim}
    67   jQuery('#contentid').markItUp(BBCodeBar);
     67  jQuery('#{$BBCODE_ID}').markItUp(BBCodeBar);
     68  jQuery('.markItUpHeader>ul').css('width', {$bbc_counter}*22);
    6869});
    6970{/footer_script}
Note: See TracChangeset for help on using the changeset viewer.