/** * Fetch and decorates the history stats using the specified parameters * * @param array $aParams Query parameters * @param string $link Optional link for the leftmost column content */ function prepare(&$aParams, $link = '') { parent::prepare($aParams); // Set the span requirements // Disable this for now, since these queries can be very slow // $this->oHistory->getSpan($this, $aParams); // Get the historical stats $aStats = $this->getHistory($aParams, $link); if ($this->noStatsAvailable) { $this->aStatsData = array(); return; } if ($this->disablePager) { $use_pager = false; } elseif ($this->statsBreakdown == 'week') { $per_page = 4; $use_pager = count($stats) > $per_page; } elseif ($this->aGlobalPrefs['period_preset'] == 'this_month' || $this->aGlobalPrefs['period_preset'] == 'last_month') { // Do not use pager when showing last or current month $use_pager = false; } elseif ($this->statsBreakdown == 'hour' || $this->statsBreakdown == 'dow') { $use_pager = false; } else { $per_page = 15; $use_pager = count($stats) > $per_page; } if ($use_pager) { $params = array('itemData' => $stats, 'perPage' => htmlspecialchars(MAX_getStoredValue('setPerPage', $per_page)), 'delta' => 8, 'append' => true, 'clearIfVoid' => false, 'urlVar' => 'page', 'useSessions' => false, 'mode' => 'Jumping'); if ($params['perPage'] % $per_page || $params['perPage'] > $per_page * 4) { // Reset the perPage and the request parameters when not matching the available values $params['perPage'] = $per_page; $_REQUEST['setPerPage'] = $per_page; } $pager =& Pager::factory($params); $this->aStatsData = $pager->getPageData(); $this->pagerLinks = $pager->getLinks(); $this->pagerLinks = $this->pagerLinks['all']; $this->pagerSelect = preg_replace('/(<select.*?)(>)/i', '$1 onchange="this.form.submit()"$2', $pager->getPerPageSelectBox($per_page, $per_page * 4, $per_page)); } else { $this->aStatsData = $aStats; $this->pagerLinks = false; $this->pagerSelect = false; } $this->aPagePrefs['setPerPage'] = $params['perPage']; // Format the rows appropriately for output $this->oHistory->formatRows($this->aStatsData, $this); }