You are here

function _search_by_page_status_details in Search by Page 7

Same name and namespace in other branches
  1. 8 search_by_page.module \_search_by_page_status_details()
  2. 6 search_by_page.module \_search_by_page_status_details()

Generates a detailed status listing for the Search status page.

Return value

Renderable array of search status.

1 call to _search_by_page_status_details()
search_by_page_search_admin in ./search_by_page.module
Implements hook_search_admin().

File

./search_by_page.module, line 1883
Main module file for Drupal module Search by Page.

Code

function _search_by_page_status_details() {
  _search_by_page_rebuild_all_paths();

  // Query to find number of un-indexed items by environment and module.
  $dbr = db_query('SELECT COUNT(*) as nonindexed, p.environment, p.from_module FROM {sbp_path} p WHERE p.last_index_time = 0 GROUP BY p.environment, p.from_module')
    ->fetchAll();

  // Make this into a table.
  $stuff = array();
  $module_list = array();
  foreach ($dbr as $item) {
    if ($item->nonindexed) {
      $stuff[$item->environment][$item->from_module] = $item->nonindexed;
      $module_list[$item->from_module] = 1;
    }
  }
  if (!count($stuff)) {
    return array(
      '#type' => 'markup',
      '#markup' => '<p>' . t('Search by Page is fully indexed.') . '</p>',
    );
  }
  $module_list = array_keys($module_list);
  sort($module_list);
  array_unshift($module_list, t('Core'));
  $rows = array();
  foreach ($stuff as $envid => $lst) {
    $row = array();
    $row[] = search_by_page_setting_get('environment_name', $envid, t('new'));
    foreach ($module_list as $module) {
      $row[] = isset($lst[$module]) ? $lst[$module] : '';
    }
    $rows[] = $row;
  }
  $core = node_search_status();
  if (!empty($core['remaining'])) {
    $corerow = array(
      t('Core content search'),
      $core['remaining'],
    );
    for ($i = count($corerow); $i < count($row); $i++) {
      $corerow[] = '';
    }
    $rows[] = $corerow;
  }

  // Re-purpose module list as table header and make this into a table.
  array_unshift($module_list, t('Environment'));
  return array(
    '#type' => 'markup',
    '#markup' => theme('table', array(
      'header' => $module_list,
      'rows' => $rows,
      'caption' => t('Count of un-indexed items by environment and module'),
    )),
  );
}