mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 06:08:52 +00:00
[ticket/12273] Move $extension to constructor so the path is always set
PHPBB3-12273
This commit is contained in:
parent
2d5bae555d
commit
7f90ff70ac
3 changed files with 30 additions and 38 deletions
|
@ -61,8 +61,8 @@ switch ($action)
|
||||||
echo '__FORCETOC__' . "\n";
|
echo '__FORCETOC__' . "\n";
|
||||||
|
|
||||||
case 'php':
|
case 'php':
|
||||||
$exporter = new \phpbb\event\php_exporter($phpbb_root_path);
|
$exporter = new \phpbb\event\php_exporter($phpbb_root_path, $extension);
|
||||||
$exporter->crawl_phpbb_directory_php($extension);
|
$exporter->crawl_phpbb_directory_php();
|
||||||
echo $exporter->export_events_for_wiki();
|
echo $exporter->export_events_for_wiki();
|
||||||
|
|
||||||
if ($action === 'php')
|
if ($action === 'php')
|
||||||
|
@ -73,8 +73,8 @@ switch ($action)
|
||||||
// no break;
|
// no break;
|
||||||
|
|
||||||
case 'styles':
|
case 'styles':
|
||||||
$exporter = new \phpbb\event\md_exporter($phpbb_root_path);
|
$exporter = new \phpbb\event\md_exporter($phpbb_root_path, $extension);
|
||||||
$exporter->crawl_phpbb_directory_styles('docs/events.md', $extension);
|
$exporter->crawl_phpbb_directory_styles('docs/events.md');
|
||||||
echo $exporter->export_events_for_wiki();
|
echo $exporter->export_events_for_wiki();
|
||||||
|
|
||||||
if ($action === 'styles')
|
if ($action === 'styles')
|
||||||
|
@ -85,8 +85,8 @@ switch ($action)
|
||||||
// no break;
|
// no break;
|
||||||
|
|
||||||
case 'adm':
|
case 'adm':
|
||||||
$exporter = new \phpbb\event\md_exporter($phpbb_root_path);
|
$exporter = new \phpbb\event\md_exporter($phpbb_root_path, $extension);
|
||||||
$exporter->crawl_phpbb_directory_adm('docs/events.md', $extension);
|
$exporter->crawl_phpbb_directory_adm('docs/events.md');
|
||||||
echo $exporter->export_events_for_wiki();
|
echo $exporter->export_events_for_wiki();
|
||||||
|
|
||||||
if ($action === 'all')
|
if ($action === 'all')
|
||||||
|
|
|
@ -34,10 +34,17 @@ class md_exporter
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $phpbb_root_path
|
* @param string $phpbb_root_path
|
||||||
|
* @param mixed $extension String 'vendor/ext' to filter, null for phpBB core
|
||||||
*/
|
*/
|
||||||
public function __construct($phpbb_root_path)
|
public function __construct($phpbb_root_path, $extension = null)
|
||||||
{
|
{
|
||||||
$this->root_path = $phpbb_root_path;
|
$this->root_path = $phpbb_root_path;
|
||||||
|
$this->path = $this->root_path;
|
||||||
|
if ($extension)
|
||||||
|
{
|
||||||
|
$this->path .= 'ext/' . $extension . '/';
|
||||||
|
}
|
||||||
|
|
||||||
$this->events = array();
|
$this->events = array();
|
||||||
$this->events_by_file = array();
|
$this->events_by_file = array();
|
||||||
$this->filter = $this->current_event = '';
|
$this->filter = $this->current_event = '';
|
||||||
|
@ -55,19 +62,12 @@ class md_exporter
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $md_file Relative from phpBB root
|
* @param string $md_file Relative from phpBB root
|
||||||
* @param mixed $extension String 'vendor/ext' to filter, null for phpBB core
|
|
||||||
* @return int Number of events found
|
* @return int Number of events found
|
||||||
* @throws \LogicException
|
* @throws \LogicException
|
||||||
*/
|
*/
|
||||||
public function crawl_phpbb_directory_adm($md_file, $extension = null)
|
public function crawl_phpbb_directory_adm($md_file)
|
||||||
{
|
{
|
||||||
$this->path = $this->root_path;
|
$this->crawl_eventsmd($md_file, 'adm');
|
||||||
if ($extension)
|
|
||||||
{
|
|
||||||
$this->path .= 'ext/' . $extension . '/';
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->crawl_eventsmd($this->path . $md_file, 'adm', $extension);
|
|
||||||
|
|
||||||
$file_list = $this->get_recursive_file_list($this->path . 'adm/style/');
|
$file_list = $this->get_recursive_file_list($this->path . 'adm/style/');
|
||||||
foreach ($file_list as $file)
|
foreach ($file_list as $file)
|
||||||
|
@ -81,19 +81,12 @@ class md_exporter
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $md_file Relative from phpBB root
|
* @param string $md_file Relative from phpBB root
|
||||||
* @param mixed $extension String 'vendor/ext' to filter, null for phpBB core
|
|
||||||
* @return int Number of events found
|
* @return int Number of events found
|
||||||
* @throws \LogicException
|
* @throws \LogicException
|
||||||
*/
|
*/
|
||||||
public function crawl_phpbb_directory_styles($md_file, $extension = null)
|
public function crawl_phpbb_directory_styles($md_file)
|
||||||
{
|
{
|
||||||
$this->path = $this->root_path;
|
$this->crawl_eventsmd($md_file, 'styles');
|
||||||
if ($extension)
|
|
||||||
{
|
|
||||||
$this->path .= 'ext/' . $extension . '/';
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->crawl_eventsmd($this->path . $md_file, 'styles', $extension);
|
|
||||||
|
|
||||||
$styles = array('prosilver', 'subsilver2');
|
$styles = array('prosilver', 'subsilver2');
|
||||||
foreach ($styles as $style)
|
foreach ($styles as $style)
|
||||||
|
@ -115,18 +108,17 @@ class md_exporter
|
||||||
/**
|
/**
|
||||||
* @param string $md_file Relative from phpBB root
|
* @param string $md_file Relative from phpBB root
|
||||||
* @param string $filter Should be 'styles' or 'adm'
|
* @param string $filter Should be 'styles' or 'adm'
|
||||||
* @param mixed $extension String 'vendor/ext' to filter, null for phpBB core
|
|
||||||
* @return int Number of events found
|
* @return int Number of events found
|
||||||
* @throws \LogicException
|
* @throws \LogicException
|
||||||
*/
|
*/
|
||||||
public function crawl_eventsmd($md_file, $filter, $extension = null)
|
public function crawl_eventsmd($md_file, $filter)
|
||||||
{
|
{
|
||||||
if (!file_exists($md_file))
|
if (!file_exists($this->path . $md_file))
|
||||||
{
|
{
|
||||||
throw new \LogicException("The event docs file '{$md_file}' could not be found");
|
throw new \LogicException("The event docs file '{$md_file}' could not be found");
|
||||||
}
|
}
|
||||||
|
|
||||||
$file_content = file_get_contents($md_file);
|
$file_content = file_get_contents($this->path . $md_file);
|
||||||
$this->filter = $filter;
|
$this->filter = $filter;
|
||||||
|
|
||||||
$events = explode("\n\n", $file_content);
|
$events = explode("\n\n", $file_content);
|
||||||
|
|
|
@ -40,14 +40,21 @@ class php_exporter
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $phpbb_root_path
|
* @param string $phpbb_root_path
|
||||||
|
* @param mixed $extension String 'vendor/ext' to filter, null for phpBB core
|
||||||
*/
|
*/
|
||||||
public function __construct($phpbb_root_path)
|
public function __construct($phpbb_root_path, $extension = null)
|
||||||
{
|
{
|
||||||
$this->root_path = $phpbb_root_path;
|
$this->root_path = $phpbb_root_path;
|
||||||
$this->path = $phpbb_root_path;
|
$this->path = $phpbb_root_path;
|
||||||
$this->events = $this->file_lines = array();
|
$this->events = $this->file_lines = array();
|
||||||
$this->current_file = $this->current_event = '';
|
$this->current_file = $this->current_event = '';
|
||||||
$this->current_event_line = 0;
|
$this->current_event_line = 0;
|
||||||
|
|
||||||
|
$this->path = $this->root_path;
|
||||||
|
if ($extension)
|
||||||
|
{
|
||||||
|
$this->path .= 'ext/' . $extension . '/';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -86,17 +93,10 @@ class php_exporter
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Crawl the phpBB/ directory for php events
|
* Crawl the phpBB/ directory for php events
|
||||||
* @param mixed $extension String 'vendor/ext' to filter, null for phpBB core
|
|
||||||
* @return int The number of events found
|
* @return int The number of events found
|
||||||
*/
|
*/
|
||||||
public function crawl_phpbb_directory_php($extension = null)
|
public function crawl_phpbb_directory_php()
|
||||||
{
|
{
|
||||||
$this->path = $this->root_path;
|
|
||||||
if ($extension)
|
|
||||||
{
|
|
||||||
$this->path .= 'ext/' . $extension . '/';
|
|
||||||
}
|
|
||||||
|
|
||||||
$files = $this->get_recursive_file_list();
|
$files = $this->get_recursive_file_list();
|
||||||
$this->events = array();
|
$this->events = array();
|
||||||
foreach ($files as $file)
|
foreach ($files as $file)
|
||||||
|
|
Loading…
Add table
Reference in a new issue