You are here

function insert_block_filter in Insert Block 6

Same name and namespace in other branches
  1. 5 insert_block.module \insert_block_filter()

Implementation of hook_filter().

File

./insert_block.module, line 46
Insert blocks into the body of a node

Code

function insert_block_filter($op, $delta = 0, $format = -1, $text = '') {

  // The "list" operation provides the module an opportunity to declare both how
  // many filters it defines and a human-readable name for each filter. Note that
  // the returned name should be passed through t() for translation.
  if ($op == 'list') {
    return array(
      0 => t('insert block filter'),
    );
  }

  // go ahead and set this up for multiple filters, though I doubt we'll use it
  switch ($delta) {
    case 0:
      switch ($op) {
        case 'description':
          return t('Inserts the contents of a block into a node using [block:module=delta] tags.');
        case 'prepare':
          return $text;
        case 'process':
          return _insert_block_substitute_tags($text, $format);
        case 'no cache':
          return TRUE;
        case 'settings':
          $form['insert_block'] = array(
            '#type' => 'fieldset',
            '#title' => t('Insert Block filter'),
            '#collapsible' => TRUE,
          );
          $form['insert_block']["insert_block_check_roles_{$format}"] = array(
            '#type' => 'checkbox',
            '#title' => t('Check the roles assigned by the Block module'),
            '#default_value' => variable_get("insert_block_check_roles_{$format}", 0),
            '#description' => t('Without this checked, anyone can see inserted blocks.'),
          );
          return $form;
      }
      break;
  }
}