From bdad879508d7d3d36119d0d106682c213ff61f35 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 2 May 2015 14:32:14 +0200 Subject: [PATCH] [ticket/13807] Allow filtering template events PHPBB3-13807 --- phpBB/phpbb/event/md_exporter.php | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/phpBB/phpbb/event/md_exporter.php b/phpBB/phpbb/event/md_exporter.php index f7021875f3..d5de56525a 100644 --- a/phpBB/phpbb/event/md_exporter.php +++ b/phpBB/phpbb/event/md_exporter.php @@ -24,6 +24,12 @@ class md_exporter /** @var string phpBB Root Path */ protected $root_path; + /** @var string The minimum version for the events to return */ + protected $min_version; + + /** @var string The maximum version for the events to return */ + protected $max_version; + /** @var string */ protected $filter; @@ -36,8 +42,10 @@ class md_exporter /** * @param string $phpbb_root_path * @param mixed $extension String 'vendor/ext' to filter, null for phpBB core + * @param string $min_version + * @param string $max_version */ - public function __construct($phpbb_root_path, $extension = null) + public function __construct($phpbb_root_path, $extension = null, $min_version = null, $max_version = null) { $this->root_path = $phpbb_root_path; $this->path = $this->root_path; @@ -49,6 +57,8 @@ class md_exporter $this->events = array(); $this->events_by_file = array(); $this->filter = $this->current_event = ''; + $this->min_version = $min_version; + $this->max_version = $max_version; } /** @@ -152,6 +162,11 @@ class md_exporter $files = $this->validate_file_list($file_details); $since = $this->validate_since($since); + if (!$this->version_is_filtered($since)) + { + continue; + } + $this->events[$event_name] = array( 'event' => $this->current_event, 'files' => $files, @@ -163,6 +178,17 @@ class md_exporter return sizeof($this->events); } + /** + * The version to check + * + * @param string $version + */ + protected function version_is_filtered($version) + { + return (!$this->min_version || phpbb_version_compare($this->min_version, $version, '<=')) + && (!$this->max_version || phpbb_version_compare($this->max_version, $version, '>=')); + } + /** * Format the php events as a wiki table * @return string Number of events found