mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-27 21:58:52 +00:00
[ticket/11924] Add script to export events.md with wiki markup
PHPBB3-11924
This commit is contained in:
parent
5f788e40d8
commit
9cf634e517
1 changed files with 102 additions and 0 deletions
102
phpBB/develop/export_events_for_wiki.php
Normal file
102
phpBB/develop/export_events_for_wiki.php
Normal file
|
@ -0,0 +1,102 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* @copyright (c) 2012 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
define('IN_PHPBB', 1);
|
||||
define('ANONYMOUS', 1);
|
||||
$phpEx = substr(strrchr(__FILE__, '.'), 1);
|
||||
$phpbb_root_path = __DIR__.'/../';
|
||||
|
||||
include($phpbb_root_path . 'common.'.$phpEx);
|
||||
|
||||
function usage()
|
||||
{
|
||||
echo "Usage: export_events_for_wiki.php COMMAND\n";
|
||||
echo "\n";
|
||||
echo "acp:\n";
|
||||
echo " Export all events for files in the acp style.\n";
|
||||
echo "\n";
|
||||
echo "styles:\n";
|
||||
echo " Export all events for files in the prosilver and subsilver2 styles.\n";
|
||||
exit(2);
|
||||
}
|
||||
|
||||
function export_from_eventsmd($filter)
|
||||
{
|
||||
global $phpbb_root_path;
|
||||
$file_content = file_get_contents($phpbb_root_path . 'docs/events.md');
|
||||
|
||||
$events = explode("\n\n", $file_content);
|
||||
foreach ($events as $event)
|
||||
{
|
||||
// Last row of the file
|
||||
if (strpos($event, "\n===\n") === false) continue;
|
||||
|
||||
list($event_name, $details) = explode("\n===\n", $event);
|
||||
|
||||
if ($filter == 'acp' && strpos($event_name, 'acp_') !== 0) continue;
|
||||
if ($filter == 'styles' && strpos($event_name, 'acp_') === 0) continue;
|
||||
|
||||
list($file_details, $explanition) = explode("\n* Purpose: ", $details);
|
||||
|
||||
echo "|- id=\"{$event_name}\"\n";
|
||||
echo "| [[#{$event_name}|{$event_name}]] || ";
|
||||
|
||||
if (strpos($file_details, "* Locations:\n + ") === 0)
|
||||
{
|
||||
$file_details = substr($file_details, strlen("* Locations:\n + "));
|
||||
$files = explode("\n + ", $file_details);
|
||||
$prosilver = $subsilver2 = array();
|
||||
foreach ($files as $file)
|
||||
{
|
||||
if (strpos($file, 'styles/prosilver/template/') === 0)
|
||||
{
|
||||
$prosilver[] = substr($file, strlen('styles/prosilver/template/'));
|
||||
}
|
||||
if (strpos($file, 'styles/subsilver2/template/') === 0)
|
||||
{
|
||||
$subsilver2[] = substr($file, strlen('styles/subsilver2/template/'));
|
||||
}
|
||||
}
|
||||
echo implode(', ', $prosilver) . ' || ' . implode(', ', $subsilver2);
|
||||
}
|
||||
else if ($filter == 'acp')
|
||||
{
|
||||
echo substr($file_details, strlen("* Location: adm/style/"));
|
||||
}
|
||||
echo " || 3.1.0-a1 || " . str_replace("\n", ' ', $explanition) . "\n";
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function validate_argument_count($count)
|
||||
{
|
||||
global $argv;
|
||||
|
||||
if (count($argv) <= $count)
|
||||
{
|
||||
usage();
|
||||
}
|
||||
}
|
||||
|
||||
validate_argument_count(1);
|
||||
|
||||
$action = $argv[1];
|
||||
|
||||
switch ($action)
|
||||
{
|
||||
case 'acp':
|
||||
export_from_eventsmd('acp');
|
||||
break;
|
||||
|
||||
case 'styles':
|
||||
export_from_eventsmd('styles');
|
||||
break;
|
||||
|
||||
default:
|
||||
usage();
|
||||
}
|
Loading…
Add table
Reference in a new issue