You are here

function _sbp_paths_list_page in Search by Page 7

Same name and namespace in other branches
  1. 6 sbp_paths.module \_sbp_paths_list_page()

Page callback for path listings page.

Builds a page that lists existing paths to index, with links to edit, delete, and add new.

1 string reference to '_sbp_paths_list_page'
sbp_paths_menu in ./sbp_paths.module
Implements hook_menu().

File

./sbp_paths.module, line 267
Module file for Search by Page Paths, a sub-module for Search by Page.

Code

function _sbp_paths_list_page($environment) {
  $output = '';
  $environment = intval($environment);

  // Overview
  $output .= '<p>' . t('This page allows you to define pages on your site to be indexed by the Search by Page module in this environment.') . '</p>' . "\n";

  // Link to add a new path
  $basepath = 'admin/config/search/search_by_page/edit/' . $environment . '/paths/';
  $output .= '<p>' . l(t('Add new path'), $basepath . 'add') . '</p>' . "\n";

  // List existing paths in a table, with edit/delete links
  // and use a pager
  $query = db_select('sbpp_path', 'p')
    ->extend('PagerDefault');
  $query
    ->addField('p', 'pid');
  $query
    ->addField('p', 'page_path');
  $query
    ->addField('p', 'title');
  $query
    ->condition('environment', $environment)
    ->limit(50)
    ->orderBy('page_path');
  $result = $query
    ->execute()
    ->fetchAll();
  $headers = array(
    t('Path'),
    t('Title'),
    array(
      'data' => t('Operations'),
      'colspan' => 2,
    ),
  );
  $rows = array();
  foreach ($result as $data) {
    $rows[] = array(
      check_plain($data->page_path),
      check_plain($data->title),
      l(t('edit'), $basepath . 'edit/' . $data->pid),
      l(t('delete'), $basepath . 'delete/' . $data->pid),
    );
  }
  $output .= theme('table', array(
    'header' => $headers,
    'rows' => $rows,
  ));
  $output .= theme('pager', array(
    'tags' => NULL,
  ));
  return $output;
}