You are here

function monolog_profile_page in Monolog 6

Same name and namespace in other branches
  1. 7 monolog.admin.inc \monolog_profile_page()

Page callback; Displayes all profile pages.

1 string reference to 'monolog_profile_page'
monolog_menu in ./monolog.module
Implements hook_menu().

File

./monolog.admin.inc, line 168
Administrative settings for the Monolog module.

Code

function monolog_profile_page() {
  $build = array();
  $build['description'] = array(
    '#markup' => t('<p>A <strong>profile</strong> is a collection of handlers that process the record.</p><p>Common examples of handlers are a <em>syslog handler</em> that routes records to the syslog and a <em>stream wrapper handler</em> that writes records to files and other streams.</p>'),
  );
  $header = array(
    'profile' => t('Profile'),
    'handlers' => t('Handlers'),
    'operations' => t('Operations'),
  );
  $rows = array();
  $profiles = monolog_profile_load_all();
  foreach ($profiles as $name => $profile) {
    $base_path = 'admin/config/development/monolog/profile/' . $name;

    // @todo Make a theme function.
    $label = check_plain($profile->options['label']);
    $machine_name = '<small>' . t('(Machine name: @name)', array(
      '@name' => $profile->name,
    )) . '</small>';
    $row = array(
      'profile' => $label . ' ' . $machine_name,
      'handlers' => join(', ', array_map('check_plain', monolog_get_profile_handlers($profile))),
    );
    if (empty($row['handlers'])) {
      $row['handlers'] = '<em>No handlers</em>';
    }
    $in_db = $profile->export_type & EXPORT_IN_DATABASE;
    $in_code = $profile->export_type & EXPORT_IN_CODE;
    $operations = array();
    $operations[] = array(
      'title' => t('Edit'),
      'href' => $base_path,
    );
    $operations[] = array(
      'title' => t('Export'),
      'href' => $base_path . '/export',
    );
    if ($profile->export_type & EXPORT_IN_DATABASE) {
      $operations[] = array(
        'title' => $profile->export_type & EXPORT_IN_CODE ? t('Revert') : t('Delete'),
        'href' => $base_path . '/delete',
      );
    }
    $row['operations'] = array(
      'data' => array(
        '#theme' => 'links__node_operations',
        '#links' => $operations,
        '#attributes' => array(
          'class' => array(
            'links',
            'inline',
          ),
        ),
      ),
    );
    $rows[] = $row;
  }
  $build['profiles'] = array(
    '#theme' => 'table',
    '#caption' => t('Logging Profiles'),
    '#empty' => t('There are no logging channels. Add one by clicking the "Add channel" link above.'),
    '#header' => $header,
    '#rows' => $rows,
  );
  return $build;
}