mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-08 04:18:52 +00:00
Merge branch 'prep-release-3.3.6' into 3.3.x
This commit is contained in:
commit
6a6d83c674
3 changed files with 215 additions and 0 deletions
126
phpBB/develop/export_events_for_bbcode.php
Normal file
126
phpBB/develop/export_events_for_bbcode.php
Normal file
|
@ -0,0 +1,126 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* This file is part of the phpBB Forum Software package.
|
||||||
|
*
|
||||||
|
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||||
|
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||||
|
*
|
||||||
|
* For full copyright and license information, please see
|
||||||
|
* the docs/CREDITS.txt file.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (php_sapi_name() != 'cli')
|
||||||
|
{
|
||||||
|
die("This program must be run from the command line.\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
$phpEx = substr(strrchr(__FILE__, '.'), 1);
|
||||||
|
$phpbb_root_path = __DIR__ . '/../';
|
||||||
|
define('IN_PHPBB', true);
|
||||||
|
|
||||||
|
function usage()
|
||||||
|
{
|
||||||
|
echo "Usage: export_events_for_bbcode.php COMMAND [VERSION] [EXTENSION]\n";
|
||||||
|
echo "\n";
|
||||||
|
echo "COMMAND:\n";
|
||||||
|
echo " diff:\n";
|
||||||
|
echo " Generate the Event Diff for the release highlights\n";
|
||||||
|
echo "\n";
|
||||||
|
echo " php:\n";
|
||||||
|
echo " Generate the PHP event section of Event_List\n";
|
||||||
|
echo "\n";
|
||||||
|
echo " adm:\n";
|
||||||
|
echo " Generate the ACP Template event section of Event_List\n";
|
||||||
|
echo "\n";
|
||||||
|
echo " styles:\n";
|
||||||
|
echo " Generate the Styles Template event section of Event_List\n";
|
||||||
|
echo "\n";
|
||||||
|
echo "VERSION (diff only):\n";
|
||||||
|
echo " Filter events (minimum version)\n";
|
||||||
|
echo "\n";
|
||||||
|
echo "EXTENSION (Optional):\n";
|
||||||
|
echo " If not given, only core events will be exported.\n";
|
||||||
|
echo " Otherwise only events from the extension will be exported.\n";
|
||||||
|
echo "\n";
|
||||||
|
exit(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
function validate_argument_count($arguments, $count)
|
||||||
|
{
|
||||||
|
if ($arguments <= $count)
|
||||||
|
{
|
||||||
|
usage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
validate_argument_count($argc, 1);
|
||||||
|
|
||||||
|
$action = $argv[1];
|
||||||
|
$extension = isset($argv[2]) ? $argv[2] : null;
|
||||||
|
$min_version = null;
|
||||||
|
require __DIR__ . '/../phpbb/event/php_exporter.' . $phpEx;
|
||||||
|
require __DIR__ . '/../phpbb/event/md_exporter.' . $phpEx;
|
||||||
|
require __DIR__ . '/../phpbb/event/rst_exporter.' . $phpEx;
|
||||||
|
require __DIR__ . '/../includes/functions.' . $phpEx;
|
||||||
|
require __DIR__ . '/../phpbb/event/recursive_event_filter_iterator.' . $phpEx;
|
||||||
|
require __DIR__ . '/../phpbb/recursive_dot_prefix_filter_iterator.' . $phpEx;
|
||||||
|
|
||||||
|
switch ($action)
|
||||||
|
{
|
||||||
|
|
||||||
|
case 'diff':
|
||||||
|
echo "[size=200]Event changes[/size]\n\n";
|
||||||
|
$min_version = $extension;
|
||||||
|
$extension = isset($argv[3]) ? $argv[3] : null;
|
||||||
|
|
||||||
|
case 'php':
|
||||||
|
$exporter = new \phpbb\event\php_exporter($phpbb_root_path, $extension, $min_version);
|
||||||
|
$exporter->crawl_phpbb_directory_php();
|
||||||
|
echo $exporter->export_events_for_bbcode($action);
|
||||||
|
|
||||||
|
if ($action === 'php')
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
echo "\n\n";
|
||||||
|
// no break;
|
||||||
|
|
||||||
|
case 'styles':
|
||||||
|
$exporter = new \phpbb\event\md_exporter($phpbb_root_path, $extension, $min_version);
|
||||||
|
if ($min_version && $action === 'diff')
|
||||||
|
{
|
||||||
|
$exporter->crawl_eventsmd('docs/events.md', 'styles');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$exporter->crawl_phpbb_directory_styles('docs/events.md');
|
||||||
|
}
|
||||||
|
echo $exporter->export_events_for_bbcode($action);
|
||||||
|
|
||||||
|
if ($action === 'styles')
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
echo "\n\n";
|
||||||
|
// no break;
|
||||||
|
|
||||||
|
case 'adm':
|
||||||
|
$exporter = new \phpbb\event\md_exporter($phpbb_root_path, $extension, $min_version);
|
||||||
|
if ($min_version && $action === 'diff')
|
||||||
|
{
|
||||||
|
$exporter->crawl_eventsmd('docs/events.md', 'adm');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$exporter->crawl_phpbb_directory_adm('docs/events.md');
|
||||||
|
}
|
||||||
|
echo $exporter->export_events_for_bbcode($action);
|
||||||
|
|
||||||
|
echo "\n";
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
usage();
|
||||||
|
}
|
|
@ -364,6 +364,64 @@ class md_exporter
|
||||||
return $rst_exporter->get_rst_output();
|
return $rst_exporter->get_rst_output();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Format the md events as BBCode list
|
||||||
|
*
|
||||||
|
* @param string $action
|
||||||
|
* @return string Events BBCode
|
||||||
|
*/
|
||||||
|
public function export_events_for_bbcode(string $action = ''): string
|
||||||
|
{
|
||||||
|
if ($this->filter === 'adm')
|
||||||
|
{
|
||||||
|
if ($action === 'diff')
|
||||||
|
{
|
||||||
|
$bbcode_text = "[size=150]ACP Template Events[/size]\n";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$bbcode_text = "[size=200]ACP Template Events[/size]\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ($action === 'diff')
|
||||||
|
{
|
||||||
|
$bbcode_text = "[size=150]Template Events[/size]\n";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$bbcode_text = "[size=200]Template Events[/size]\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!count($this->events))
|
||||||
|
{
|
||||||
|
return $bbcode_text . "[list][*][i]None[/i][/list]\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($this->events as $event_name => $event)
|
||||||
|
{
|
||||||
|
$bbcode_text .= "[list]\n";
|
||||||
|
$bbcode_text .= "[*][b]{$event_name}[/b]\n";
|
||||||
|
|
||||||
|
if ($this->filter === 'adm')
|
||||||
|
{
|
||||||
|
$bbcode_text .= "Placement: " . implode(', ', $event['files']['adm']) . "\n";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$bbcode_text .= "Prosilver Placement: " . implode(', ', $event['files']['prosilver']) . "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
$bbcode_text .= "Added in Release: {$event['since']}\n";
|
||||||
|
$bbcode_text .= "Explanation: {$event['description']}\n";
|
||||||
|
$bbcode_text .= "[/list]\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
return $bbcode_text;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validates a template event name
|
* Validates a template event name
|
||||||
*
|
*
|
||||||
|
|
|
@ -207,6 +207,37 @@ class php_exporter
|
||||||
return $rst_exporter->get_rst_output();
|
return $rst_exporter->get_rst_output();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Format the PHP events as a BBCode list
|
||||||
|
*
|
||||||
|
* @param string $action
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function export_events_for_bbcode(string $action = ''): string
|
||||||
|
{
|
||||||
|
if ($action === 'diff')
|
||||||
|
{
|
||||||
|
$bbcode_text = '[size=150]PHP Events[/size]' . "\n";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$bbcode_text = '[size=200]PHP Events[/size]' . "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($this->events as $event)
|
||||||
|
{
|
||||||
|
$bbcode_text .= "[list]\n";
|
||||||
|
$bbcode_text .= "[*][b]{$event['event']}[/b]\n";
|
||||||
|
$bbcode_text .= "Placement: {$event['file']}\n";
|
||||||
|
$bbcode_text .= 'Arguments: ' . implode(', ', $event['arguments']) . "\n";
|
||||||
|
$bbcode_text .= "Added in Release: {$event['since']}\n";
|
||||||
|
$bbcode_text .= "Explanation: {$event['description']}\n";
|
||||||
|
$bbcode_text .= "[/list]\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
return $bbcode_text;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $file
|
* @param string $file
|
||||||
* @return int Number of events found in this file
|
* @return int Number of events found in this file
|
||||||
|
|
Loading…
Add table
Reference in a new issue