You are here

function xbbcode_settings_handlers in Extensible BBCode 6

Same name and namespace in other branches
  1. 8 xbbcode.admin.inc \xbbcode_settings_handlers()
  2. 5 xbbcode-settings.php \xbbcode_settings_handlers()
  3. 7 xbbcode.admin.inc \xbbcode_settings_handlers()
1 string reference to 'xbbcode_settings_handlers'
xbbcode_menu in ./xbbcode.module

File

./xbbcode.admin.inc, line 202

Code

function xbbcode_settings_handlers() {

  /* check for format-specific settings */
  $res = db_query("SELECT DISTINCT format, name FROM {filter_formats} NATURAL JOIN {filters} f WHERE f.module = 'xbbcode'");
  while ($row = db_fetch_array($res)) {
    $formats[$row['format']] = array(
      'name' => $row['name'],
      'specific' => FALSE,
    );
  }
  $res = db_query("SELECT DISTINCT format FROM {xbbcode_handlers}");
  while ($row = db_fetch_array($res)) {
    $formats[$row['format']]['specific'] = TRUE;
  }
  $global = array();
  $specific = array();
  foreach ($formats as $format => $set) {
    if (!isset($set['name'])) {
      continue;
    }
    if ($set['specific']) {
      $specific[] = $set['name'];
    }
    else {
      $global[] = $set['name'];
    }
  }
  $form = array(
    'global' => array(),
    'tags' => array(),
    '#tree' => TRUE,
  );
  $form['global'] = array(
    '#weight' => -1,
    '#value' => t('You are changing the global settings.'),
  );
  if (!empty($global)) {
    $form['global']['#value'] .= ' ' . t('The following formats are affected by the global settings:') . '<ul><li>' . implode('</li><li>', $global) . '</li></ul>';
  }
  if (!empty($specified)) {
    $form['global']['#value'] .= ' ' . t('The following formats have specific settings and will not be affected:') . '<ul><li>' . implode('</li><li>', $specified) . '</li></ul>';
  }
  $xbbcode = xbbcode_settings_handlers_form();
  foreach ($xbbcode as $id => $element) {
    $form[$id] = $element;
  }
  $form['submit'] = array(
    '#type' => 'submit',
    '#name' => 'op',
    '#value' => t('Save changes'),
  );
  return $form;
}