You are here

function xmlsitemap_add_form_entity_summary in XML sitemap 7.2

Same name and namespace in other branches
  1. 8 xmlsitemap.module \xmlsitemap_add_form_entity_summary()
  2. 6.2 xmlsitemap.admin.inc \xmlsitemap_add_form_entity_summary()
  3. 2.x xmlsitemap.module \xmlsitemap_add_form_entity_summary()

Add a table summary for an entity and its bundles.

1 call to xmlsitemap_add_form_entity_summary()
xmlsitemap_settings_form in ./xmlsitemap.admin.inc
Form builder; Administration settings form.

File

./xmlsitemap.admin.inc, line 562
Administrative page callbacks for the xmlsitemap module.

Code

function xmlsitemap_add_form_entity_summary(&$form, $entity, array $entity_info) {
  $priorities = xmlsitemap_get_priority_options(NULL, FALSE);
  $statuses = xmlsitemap_get_status_options(NULL);
  $rows = array();
  $totals = array(
    'total' => 0,
    'indexed' => 0,
    'visible' => 0,
  );
  foreach ($entity_info['bundles'] as $bundle => $bundle_info) {

    // Fetch current per-bundle link total and indexed counts.
    $status = xmlsitemap_get_link_type_indexed_status($entity, $bundle);
    $totals['total'] += $status['total'];
    $totals['indexed'] += $status['indexed'];
    $totals['visible'] += $status['visible'];
    $row = array();
    if (drupal_valid_path("admin/config/search/xmlsitemap/settings/{$entity}/{$bundle}")) {
      $edit_link = xmlsitemap_get_operation_link("admin/config/search/xmlsitemap/settings/{$entity}/{$bundle}", array(
        'title' => $bundle_info['label'],
        'modal' => TRUE,
      ));
      $row[] = l($edit_link['title'], $edit_link['href'], $edit_link);
    }
    else {

      // Bundle labels are assumed to be un-escaped input.
      $row[] = check_plain($bundle_info['label']);
    }
    $row[] = $statuses[$bundle_info['xmlsitemap']['status'] ? 1 : 0];
    $row[] = $priorities[number_format($bundle_info['xmlsitemap']['priority'], 1)];
    $row[] = $status['total'];
    $row[] = $status['indexed'];
    $row[] = $status['visible'];
    $rows[] = $row;
  }
  if ($rows) {
    $header = array(
      isset($entity_info['bundle label']) ? $entity_info['bundle label'] : '',
      t('Inclusion'),
      t('Priority'),
      t('Available'),
      t('Indexed'),
      t('Visible'),
    );
    $rows[] = array(
      array(
        'data' => t('Totals'),
        'colspan' => 3,
        'header' => TRUE,
      ),
      array(
        'data' => $totals['total'],
        'header' => TRUE,
      ),
      array(
        'data' => $totals['indexed'],
        'header' => TRUE,
      ),
      array(
        'data' => $totals['visible'],
        'header' => TRUE,
      ),
    );
    $form['summary'] = array(
      '#theme' => 'table',
      '#header' => $header,
      '#rows' => $rows,
    );
  }
}