You are here

function quotes_blocks_settings in Quotes 7

Same name and namespace in other branches
  1. 6 quotes.admin.inc \quotes_blocks_settings()

Displays a list of currently-defined quote blocks.

1 string reference to 'quotes_blocks_settings'
quotes_menu in ./quotes.module
Implements hook_menu().

File

./quotes.admin.inc, line 289
The quotes module allows users to maintain a list of quotes that can be displayed in any number of administrator-defined quote blocks.

Code

function quotes_blocks_settings($form, $form_state) {
  $header = array(
    t('Name'),
    t('Filters'),
    t('Operations'),
    '',
  );
  $rows = array();
  $result = db_select('quotes_blocks', 'qb')
    ->extend('PagerDefault')
    ->extend('TableSort')
    ->fields('qb')
    ->limit(20)
    ->orderByHeader($header)
    ->execute();
  foreach ($result as $qblock) {
    $filters = array();
    if ($qblock->nid_filter) {
      $filters[] = t('node');
    }
    if ($qblock->rid_filter) {
      $filters[] = t('role');
    }
    if ($qblock->uid_filter) {
      $filters[] = t('user');
    }
    if ($qblock->tid_filter) {
      $filters[] = t('term');
    }
    $rows[] = array(
      // Cells.
      t($qblock->name),
      implode(', ', count($filters) ? $filters : array(
        t('none'),
      )),
      l(t('configure block'), "admin/structure/block/manage/quotes/{$qblock->bid}/configure"),
      l(t('delete block'), "admin/config/quotes/delete/{$qblock->bid}"),
    );
  }
  $form = array();
  $form['quotes_blocks_table'] = array(
    '#theme' => 'table',
    '#header' => $header,
    '#rows' => $rows,
    '#empty' => t('No quotes blocks created.'),
  );
  $form['name'] = array(
    '#type' => 'textfield',
    '#size' => 32,
    '#default_value' => NULL,
    '#maxlength' => 64,
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Add block'),
  );
  $form['quotes_blocks_table'] = array(
    '#theme' => 'table',
    '#header' => $header,
    '#rows' => $rows,
    '#empty' => t('No quotes blocks created.'),
  );
  $form['quotes_blocks_pager'] = array(
    '#theme' => 'pager',
  );
  return $form;
}