'lib', ); static $page_view_options = Array( 'lib' => 'By Library', 'date' => 'By Age', ); var $params; // Normalised URL parameters var $pull_requests; var $last_updated; var $page_url_path; // URL path for this page var $page_view; // Grouped by library, or sorted by age. function __construct($params) { $json_data = json_decode( file_get_contents(BOOST_DATA_DIR.'/pull-requests.json')); $this->pull_requests = $json_data->pull_requests; $this->last_updated = $json_data->last_updated; $this->page_url_path = preg_replace('![#?].*!', '', $_SERVER['REQUEST_URI']); $this->params = array(); foreach (self::$param_defaults as $key => $default) { // Note: Using default for empty values as well as missing values. $this->params[$key] = strtolower(trim( BoostWebsite::array_get($params, $key))) ?: $default; } $this->page_view = $this->params['page_view']; if (!array_key_exists($this->page_view, self::$page_view_options)) { BoostWeb::throw_http_error(400, 'Invalid view type', "Invalid view type: {$this->page_view}"); } } function display() { echo '
Last updated ', $this->time_ago($this->last_updated), "
\n"; switch ($this->page_view) { case 'lib': $this->by_library(); break; case 'date': $this->by_date(); break; default: echo "Invalid page_view."; } } function by_library() { foreach ($this->pull_requests as $name => $repo_requests) { $repo_count = count($repo_requests); echo "{$repo_count} open request", ($repo_count != 1 ? 's' : ''), ":
\n"; foreach ($repo_requests as $pull) { $this->pull_request_item($pull); } } } function by_date() { $pull_requests = Array(); foreach ($this->pull_requests as $name => $repo_requests) { foreach ($repo_requests as $pull) { $pull->name = $name; $pull_requests[] = $pull; } } usort($pull_requests, function($x, $y) { return strtotime($x->created_at) - strtotime($y->created_at); }); echo '