/**
  * Get a list of the profiles in the profiles folder
  * Profiles are named as "*.json".  Add additional info, too, like
  * date and number of visits in the file
  * @uses list_files
  * @return type 
  */
 private function _get_profiles()
 {
     $p3_profile_dir = P3_PROFILES_PATH;
     $files = list_files($p3_profile_dir);
     $files = array_filter($files, array(&$this, '_filter_json_files'));
     $ret = array();
     foreach ($files as $file) {
         $time = filemtime($file);
         $count = count(file($file));
         $key = basename($file);
         $name = substr($key, 0, -5);
         // strip off .json
         $ret[] = array('filename' => basename($file), 'name' => $this->_action_links($key, $name), 'date' => date('D, M jS', $time) . ' at ' . date('g:i a', $time), 'count' => number_format($count), 'filesize' => P3_Profiler_Plugin_Admin::readable_size(filesize($file)), '_filesize' => filesize($file), '_date' => $time, '_count' => $count);
     }
     return $ret;
 }
 /**
  * Dispatcher function.  All requests enter through here
  * and are routed based upon the p3_action request variable
  * @return void
  */
 public static function dispatcher()
 {
     // If there's a scan, create a viewer object
     if (!empty(self::$scan)) {
         try {
             self::$profile = new P3_Profiler_Reader(self::$scan);
         } catch (P3_Profiler_No_Data_Exception $e) {
             echo '<div class="error"><p>' . sprintf(__('No visits recorded during this profiling session.  Check the <a href="%s">help</a> page for more information', 'p3-profiler'), add_query_arg(array('p3_action' => 'help', 'current_scan' => null)) . '#q-circumvent-cache"') . '</p></div>';
             self::$scan = null;
             self::$profile = null;
             self::$action = 'list-scans';
         } catch (Exception $e) {
             echo '<div class="error"><p>' . __('Error reading scan', 'p3-profiler') . '</p></div>';
         }
     } else {
         self::$profile = null;
     }
     // Usability message
     if (!defined('WPP_PROFILING_STARTED')) {
         echo '<div class="updated usability-msg"><p>' . __('Click "Start Scan" to run a performance scan of your website.', 'p3-profiler') . '</p></div>';
     }
     // Load the list table, let it handle any bulk actions
     if (empty(self::$profile) && in_array(self::$action, array('list-scans', 'current-scan'))) {
         self::$scan_table = new P3_Profiler_Table();
         self::$scan_table->prepare_items();
     }
     // Load scripts & styles
     self::load_scripts();
     self::load_styles();
     // Show the page
     require_once P3_PATH . '/templates/template.php';
 }