You are here

function dynamic_banner_admin_page in Dynamic Banner 7.2

Same name and namespace in other branches
  1. 6 includes/callbacks.inc \dynamic_banner_admin_page()
  2. 7 includes/callbacks.inc \dynamic_banner_admin_page()
  3. 8.x dynamic_banner.module \dynamic_banner_admin_page()

Return a listing of all defined URL aliases. When filter key passed, perform a standard search on the given key, And return the list of matching URL aliases.

1 string reference to 'dynamic_banner_admin_page'
dynamic_banner_menu in ./dynamic_banner.module
Implements hook_menu(). it is key to note here access arguments is referring to permissions

File

./dynamic_banner.module, line 315
Distributed under GNU GPL version 3

Code

function dynamic_banner_admin_page() {

  // Grab the filter if the user set one.
  $filter = dynamic_banner_build_filter_query();
  $output['dynamic_banner_admin_filter_form'] = drupal_get_form('dynamic_banner_admin_filter_form');
  $header = array(
    array(
      'data' => t('Banner Path'),
      'field' => 'd.path',
      'sort' => 'asc',
    ),
    array(
      'data' => t('Image Path'),
    ),
    array(
      'data' => t('Text'),
      'field' => 'd.text',
    ),
    array(
      'data' => t('Anchor Link'),
      'field' => 'd.link',
    ),
    array(
      'data' => t('Display Mode'),
      'field' => 'd.mode',
    ),
    array(
      'data' => t('Operations'),
      'colspan' => '2',
    ),
  );

  // Load all data fields and attach pager and sorter.
  $query = db_select('dynamic_banner', 'd')
    ->extend('PagerDefault')
    ->extend('TableSort');
  $query
    ->fields('d')
    ->limit(20)
    ->orderByHeader($header);

  // Find if the filter has returned a where clause and add it in before executing
  if (!empty($filter)) {
    $query
      ->where($filter);
  }
  $result = $query
    ->execute();

  // Start constructing the individual rows (with XSS protection).
  $rows = array();
  foreach ($result as $data) {
    $image = dynamic_banner_image_handler($data->imgurl, $data->imgfid);
    $rows[] = array(
      'data' => array(
        $data->path,
        $image,
        filter_xss($data->text),
        filter_xss($data->link),
        $data->mode,
        l(t('edit'), 'admin/structure/banners/edit/' . $data->dbid),
        l(t('delete'), 'admin/structure/banners/delete/' . $data->dbid),
      ),
    );
  }
  $output['dynamic_banner_table'] = array(
    '#theme' => 'table',
    '#header' => $header,
    '#rows' => $rows,
    '#empty' => t('No Banners Found.'),
  );

  // Adds the pager buttons to the bottom of the table.
  $output['dynamic_banner_pager'] = array(
    '#theme' => 'pager',
  );
  return $output;
}