You are here

function add_to_head_overview in Add To Head 7

Same name and namespace in other branches
  1. 6 add_to_head.admin.inc \add_to_head_overview()

Overview page - provides a list of existing add to head profiles

1 string reference to 'add_to_head_overview'
add_to_head_menu in ./add_to_head.module
Implements hook_menu().

File

./add_to_head.admin.inc, line 12
This file contains all the admin-related callbacks

Code

function add_to_head_overview() {

  // Fetch the list of profiles saved to the DB.
  $settings = variable_get('add_to_head_profiles', array());

  // Allow other modules to alter them.
  drupal_alter(basename(__FILE__, '.admin.inc') . '_profiles', $settings);

  // Set the titles in the header.
  $header = array(
    t('Title'),
    t('Paths'),
    t('Visibility'),
    t('Scope'),
    t('Ops'),
  );

  // List each profile on the overview page.
  $rows = array();
  foreach ($settings as $delta => $settings) {

    // Show all possible operations on the profile.
    if (in_array($settings, variable_get('add_to_head_profiles', array()))) {

      // This profile is in the DB. It can be modified through the Web UI.
      $ops = implode(' | ', array(
        l(t('Edit'), 'admin/config/development/add-to-head/' . $delta),
        l(t('Delete'), 'admin/config/development/add-to-head/' . $delta . '/delete'),
      ));
    }
    else {

      // The profile is in code only. It cannot be edited from here so show a message.
      $ops = t('None (in code)');
    }

    // Fill the current row with profile data.
    $rows[] = array(
      check_plain($settings['name']),
      nl2br(check_plain($settings['paths'])),
      $settings['path_visibility'] == 0 ? t('Exclude') : t('Include'),
      drupal_ucfirst($settings['scope']),
      $ops,
    );
  }
  if (!empty($rows)) {
    $rows[] = array(
      array(
        'colspan' => count($header),
        'data' => l(t('Add another profile'), 'admin/config/development/add-to-head/add'),
      ),
    );
  }
  return array(
    '#theme' => 'table',
    '#header' => $header,
    '#rows' => $rows,
    '#empty' => t('No profiles configured yet. !link', array(
      '!link' => l(t('Add one now'), 'admin/config/development/add-to-head/add'),
    )),
  );
}