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

add bbcode bar on contactform

File:
1 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);
Note: See TracChangeset for help on using the changeset viewer.