aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/develop/export_events_for_wiki.php
blob: 2096e9c858be9ce292ac2c221bda84d07a5a283f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<?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__ . '/../';

function usage()
{
	echo "Usage: export_events_for_wiki.php COMMAND [EXTENSION]\n";
	echo "\n";
	echo "COMMAND:\n";
	echo "    all:\n";
	echo "        Generate the complete wikipage for https://wiki.phpbb.com/Event_List\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 "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;
require __DIR__ . '/../phpbb/event/php_exporter.' . $phpEx;
require __DIR__ . '/../phpbb/event/md_exporter.' . $phpEx;
require __DIR__ . '/../phpbb/event/recursive_event_filter_iterator.' . $phpEx;
require __DIR__ . '/../phpbb/recursive_dot_prefix_filter_iterator.' . $phpEx;

switch ($action)
{
	case 'all':
		echo '__FORCETOC__' . "\n";

	case 'php':
		$exporter = new \phpbb\event\php_exporter($phpbb_root_path, $extension);
		$exporter->crawl_phpbb_directory_php();
		echo $exporter->export_events_for_wiki();

		if ($action === 'php')
		{
			break;
		}
		echo "\n";
		// no break;

	case 'styles':
		$exporter = new \phpbb\event\md_exporter($phpbb_root_path, $extension);
		$exporter->crawl_phpbb_directory_styles('docs/events.md');
		echo $exporter->export_events_for_wiki();

		if ($action === 'styles')
		{
			break;
		}
		echo "\n";
		// no break;

	case 'adm':
		$exporter = new \phpbb\event\md_exporter($phpbb_root_path, $extension);
		$exporter->crawl_phpbb_directory_adm('docs/events.md');
		echo $exporter->export_events_for_wiki();

		if ($action === 'all')
		{
			echo "\n" . '[[Category:Events and Listeners]]' . "\n";
		}
	break;

	default:
		usage();
}