You are here

function performance_sources_switcher in Performance Logging and Monitoring 6

Same name and namespace in other branches
  1. 7 performance.module \performance_sources_switcher()

Helper function to output sources switcher on summary page. Made this function easily expandable to add additional souces. Just add one to the sources array and you're done.

Parameters

source currently enabled source as string:

1 call to performance_sources_switcher()
performance_view_summary in ./performance.module

File

./performance.module, line 1096
Logs detailed and/or summary page generation time and memory consumption for page requests. Copyright Khalid Baheyeldin 2008 of http://2bits.com

Code

function performance_sources_switcher($source) {
  $sources = array();
  foreach (performance_data_stores() as $store => $data) {
    if ($data['#enabled']) {
      $sources[$store] = $data['#name'];
    }
  }
  $current = $sources[$source];
  unset($sources[$source]);

  // Build the switcher. Note that we do not keep the paging/filter settings as
  // this will probably just cause confusion.
  $switch = '';
  if (count($sources) >= 1) {
    $switch = array();
    foreach ($sources as $src => $txt) {
      $switch[] = l($txt, 'admin/reports/performance-logging', array(
        'query' => array(
          'source' => $src,
        ),
      ));
    }
    $switch = ' (switch to ' . implode(' | ', $switch) . ')';
  }
  return '<br/><strong>' . t('Data source') . ':</strong> ' . $current . $switch;
}