Completed Info Maker section. Moved sections to own files
Jeremy D

Jeremy D commited on 2011-12-30 15:24:16
Showing 8 changed files, with 402 additions and 331 deletions.

... ...
@@ -0,0 +1,171 @@
1
+<?php
2
+/*
3
+ * SMF Package Manager Generator
4
+ * Author: SleePy (JeremyD)
5
+ * Repository: https://github.com/jdarwood007/smf_package_maker
6
+ * License: BSD 3 Clause; See license.txt
7
+*/
8
+if (!defined('PacManGen')) { exit('[' . basename(__FILE__) . '] Direct access restricted');}
9
+
10
+/*
11
+ * The package-info section
12
+*/
13
+function info_section()
14
+{
15
+	global $text;
16
+
17
+	echo '
18
+			<fieldset id="basic_info">
19
+				<legend>
20
+					', $text['basic_info_header'], '
21
+					<a href="#" id="collapse_basic">[', $text['button_collapse'], ']</a>
22
+					<a href="#" id="restore_basic" style="display: none;">[', $text['button_expand'], ']</a>
23
+				</legend>
24
+				<dl class="info">
25
+					<dt>', $text['basic_your_name'], ':</dt>
26
+					<dd><input id="basic_info_name" /></dd>
27
+
28
+					<dt>', $text['basic_mod_name'], ':</dt>
29
+					<dd><input id="basic_info_mod" /></dd>
30
+
31
+					<dd>', $text['basic_mod_version'], ':</dt>
32
+					<dd><input id="basic_info_version" /></dd>
33
+
34
+					<dd>', $text['basic_mod_type'], ':</dt>
35
+					<dd><select id="basic_info_type">
36
+						<option value="modification">Modification</option>
37
+						<option value="avatar">Avatars</option>
38
+						<option value="smiley">Smileys</option>
39
+						<option value="language">Language</option>
40
+						<option value="other">Other</option>
41
+					</select>
42
+					</dd>
43
+
44
+				</dl>
45
+			</fieldset>
46
+			<fieldset id="details_info">
47
+				<legend>
48
+					', $text['details_header'], '
49
+					<a href="#" id="collapse_details">[', $text['button_collapse'], ']</a>
50
+					<a href="#" id="restore_details" style="display: none;">[', $text['button_expand'], ']</a>
51
+				</legend>
52
+				<dl class="info">
53
+					<dt>', $text['details_num_actions'], ':</dt>
54
+					<dd><input disabled="disabled" id="detail_actions" /></dd>
55
+
56
+					<dt>', $text['details_num_instructions'], ':&nbsp;&nbsp;</dt>
57
+					<dd><input disabled="disabled" id="detail_instructs" /></dd>
58
+				</dl>
59
+			</fieldset>
60
+
61
+			<br clear="all" />
62
+			<hr />
63
+			<form id="action_container">
64
+			</form>
65
+			<input type="button" id="add_action" value="', $text['button_add_action'], '" />
66
+			<input type="button" id="show_preview" value="', $text['button_preview'], '" />
67
+			<input type="button" id="download_file" value="', $text['button_download'], '" onclick="download_file_', ($use_php ? 'generate' : 'data'), '()" />
68
+			<br />
69
+			<fieldset id="preview_container" style="display: none;" class="edits" >
70
+				<legend>', $text['preview_header'], '</legend>
71
+				<textarea id="preview" cols="150" rows="25"></textarea>
72
+			</fieldset>
73
+				<br />';
74
+
75
+}
76
+
77
+/*
78
+ * This is the mod templates near the end of the page
79
+*/
80
+function info_templates()
81
+{
82
+	global $text;
83
+
84
+	echo '
85
+<!-- This is the container for a new action -->
86
+<!-- Do not remove any id attribute.  This makes the magic work! -->
87
+<div id="action_template" style="display: none;">
88
+			<fieldset id="action-#ACTIONINDEX#" class="edits">
89
+				<input type="hidden" id="action-#ACTIONINDEX#-delete" value="0" />
90
+				<legend>
91
+					<span class="alignright">
92
+						<a href="#" class="delete_action" data-action="#ACTIONINDEX#">[', $text['button_delete'], ']</a>
93
+						<a href="#" class="restore_action" data-action="#ACTIONINDEX#" style="display: none;">[', $text['button_restore'], ']</a>
94
+						&nbsp;&mdash;&nbsp;
95
+						<a href="#" class="collapse_action" data-action="#ACTIONINDEX#">[', $text['button_collapse'], ']</a>
96
+						<a href="#" class="expand_action" data-action="#ACTIONINDEX#" style="display: none;">[', $text['button_expand'], ']</a>
97
+						</span>
98
+					', sprintf($text['action_header'], '#ACTIONINDEX#'), '
99
+				</legend>
100
+
101
+				', $text['type_of_action'], ':
102
+				<select id="action-#ACTIONINDEX#-type">
103
+					<option value="install">', $text['type_of_action_install'], '</option>
104
+					<option value="uninstall">', $text['type_of_action_uninstall'], '</option>
105
+					<option value="upgrade">', $text['type_of_action_upgrade'], '</option>
106
+				</select>
107
+
108
+				<span class="pad">', $text['action_smf_versions'], ':
109
+					<input type="text" id="action-#ACTIONINDEX#-smf_versions" size="60" value="SMF 2.0 RC5, SMF 2.0-2.0.99" />
110
+				</span>
111
+
112
+				<div id="action-#ACTIONINDEX#-instruct_container">
113
+				<hr />
114
+				</div>
115
+				<input type="button" class="add_instruct" data-action="#ACTIONINDEX#" value="', $text['button_add_instruct'], '" />
116
+			</fieldset>
117
+			<hr />
118
+</div>
119
+
120
+<!-- This is the container for a new edit -->
121
+<!-- Do not remove any id attribute.  This makes the magic work! -->
122
+<div id="instruct_template" style="display: none;">
123
+				<fieldset id="action-#ACTIONINDEX#-instruct-#INSTRUCTINDEX#" class="edit">
124
+					<input type="hidden" id="action-#ACTIONINDEX#-instruct-#INSTRUCTINDEX#-delete" value="0" />
125
+					<legend>
126
+						<span class="alignright">
127
+							<a href="#" class="delete_change" data-action="#ACTIONINDEX#" data-instruct="#INSTRUCTINDEX#">[', $text['button_delete'], ']</a>
128
+							<a href="#" class="restore_change" data-action="#ACTIONINDEX#" data-instruct="#INSTRUCTINDEX#" style="display: none;">[', $text['button_restore'], ']</a>
129
+							&nbsp;&mdash;&nbsp;
130
+							<a href="#" class="collapse_change" data-action="#ACTIONINDEX#" data-instruct="#INSTRUCTINDEX#">[', $text['button_collapse'], ']</a>
131
+							<a href="#" class="expand_change" data-action="#ACTIONINDEX#" data-instruct="#INSTRUCTINDEX#" style="display: none;">[', $text['button_expand'], ']</a>
132
+						</span>
133
+						', sprintf($text['instruct_header'], '#ACTIONINDEX#', '#INSTRUCTINDEX#'), '
134
+					</legend>
135
+
136
+					<dl class="edits">
137
+						<dt>', $text['instruct_action'], ':</dt>
138
+						<dd><select class="instruct_action" id="action-#ACTIONINDEX#-instruct-#INSTRUCTINDEX#-action" data-action="#ACTIONINDEX#" data-instruct="#INSTRUCTINDEX#">
139
+							<option value="modification">', $text['instruct_action_modification'], '</option>
140
+							<option value="code">', $text['instruct_action_code'], '</option>
141
+							<option value="database">', $text['instruct_action_database'], '</option>
142
+							<option value="create-dir">', $text['instruct_action_create_dir'], '</option>
143
+							<option value="create-file">', $text['instruct_action_create_file'], '</option>
144
+							<option value="require-dir">', $text['instruct_action_require_dir'], '</option>
145
+							<option value="require-file">', $text['instruct_action_require_file'], '</option>
146
+							<option value="move-dir">', $text['instruct_action_move_dir'], '</option>
147
+							<option value="move-file">', $text['instruct_action_move_file'], '</option>
148
+							<option value="remove-dir">', $text['instruct_action_delete_dir'], '</option>
149
+							<option value="remove-file">', $text['instruct_action_delete_file'] , '</option>
150
+							<option value="readme">', $text['instruct_action_readme'], '</option>
151
+						<select></dd>
152
+
153
+						<dt class="reverse">', $text['action_reverse'], ':</dt>
154
+						<dd class="reverse"><input type="checkbox" id="action-#ACTIONINDEX#-instruct-#INSTRUCTINDEX#-reverse"></dd>
155
+
156
+						<dt class="source">', $text['action_source'], '</dt>
157
+						<dd class="source"><input id="action-#ACTIONINDEX#-instruct-#INSTRUCTINDEX#-source" type="text" /></dd>
158
+
159
+						<dt class="destination">', $text['action_destination'], '</dt>
160
+						<dd class="destination"><input id="action-#ACTIONINDEX#-instruct-#INSTRUCTINDEX#-destination" type="text" /></dd>
161
+
162
+						<dt class="inline">', $text['action_inline'], ':</dt>
163
+						<dd class="inline"><input type="checkbox" id="action-#ACTIONINDEX#-instruct-#INSTRUCTINDEX#-inline" data-action="#ACTIONINDEX#" data-instruct="#INSTRUCTINDEX#" class="inline_check"></dd>
164
+
165
+						<dt class="code_block">', $text['action_code_block'], ':</dt>
166
+						<dd class="code_block"><textarea id="action-#ACTIONINDEX#-instruct-#INSTRUCTINDEX#-block" cols="75" rows="7"></textarea></dd>
167
+					</dl>
168
+				</fieldset>
169
+				<br />
170
+</div>';
171
+}
... ...
@@ -0,0 +1,161 @@
1
+<?php
2
+/*
3
+ * SMF Package Manager Generator
4
+ * Author: SleePy (JeremyD)
5
+ * Repository: https://github.com/jdarwood007/smf_package_maker
6
+ * License: BSD 3 Clause; See license.txt
7
+*/
8
+if (!defined('PacManGen')) { exit('[' . basename(__FILE__) . '] Direct access restricted');}
9
+
10
+/*
11
+ * This is the mod section code.
12
+*/
13
+function mod_section()
14
+{
15
+	global $text;
16
+
17
+	echo '
18
+			<fieldset id="basic_info">
19
+				<legend>
20
+					', $text['basic_info_header'], '
21
+					<a href="#" id="collapse_basic">[', $text['button_collapse'], ']</a>
22
+					<a href="#" id="restore_basic" style="display: none;">[', $text['button_expand'], ']</a>
23
+				</legend>
24
+				<dl class="info">
25
+					<dt>', $text['basic_your_name'], ':</dt>
26
+					<dd><input id="basic_info_name" /></dd>
27
+
28
+					<dt>', $text['basic_mod_name'], ':</dt>
29
+					<dd><input id="basic_info_mod" /></dd>
30
+
31
+					<dd>', $text['basic_mod_version'], ':</dt>
32
+					<dd><input id="basic_info_version" /></dd>
33
+
34
+				</dl>
35
+			</fieldset>
36
+			<fieldset id="details_info">
37
+				<legend>
38
+					', $text['details_header'], '
39
+					<a href="#" id="collapse_details">[', $text['button_collapse'], ']</a>
40
+					<a href="#" id="restore_details" style="display: none;">[', $text['button_expand'], ']</a>
41
+				</legend>
42
+				<dl class="info">
43
+					<dt>', $text['details_num_files'], ':</dt>
44
+					<dd><input disabled="disabled" id="detail_files" /></dd>
45
+
46
+					<dt>', $text['details_num_edits'], ':</dt>
47
+					<dd><input disabled="disabled" id="detail_edits" /></dd>
48
+
49
+					<dd>', $text['details_num_lines'], ':</dt>
50
+					<dd><input disabled="disabled" id="detail_lines" /></dd>
51
+				</dl>
52
+			</fieldset>
53
+
54
+			<br clear="all" />
55
+			<hr />
56
+			<form id="file_container"></form>
57
+			<input type="button" id="add_file" value="', $text['button_add_file'], '" />
58
+			<input type="button" id="show_preview" value="', $text['button_preview'], '" />
59
+			<input type="button" id="download_file" value="', $text['button_download'], '" onclick="download_file_', ($use_php ? 'generate' : 'data'), '()" />
60
+			<br />
61
+			<fieldset id="preview_container" style="display: none;" class="edits" >
62
+				<legend>', $text['preview_header'], '</legend>
63
+				<textarea id="preview" cols="150" rows="25"></textarea>
64
+			</fieldset>
65
+				<br />';
66
+}
67
+
68
+/*
69
+ * This is the mod templates near the end of the page
70
+*/
71
+function mod_templates()
72
+{
73
+	global $text;
74
+
75
+	echo '
76
+<!-- This is the container for a new file -->
77
+<!-- Do not remove any id attribute.  This makes the magic work! -->
78
+<div id="file_template" style="display: none;">
79
+			<fieldset id="file-#FILEINDEX#" class="edits">
80
+				<input type="hidden" id="file-#FILEINDEX#-delete" value="0" />
81
+				<legend>
82
+					<span class="alignright">
83
+						<a href="#" class="delete_file" data-file="#FILEINDEX#">[', $text['button_delete'], ']</a>
84
+						<a href="#" class="restore_file" data-file="#FILEINDEX#" style="display: none;">[', $text['button_restore'], ']</a>
85
+						&nbsp;&mdash;&nbsp;
86
+						<a href="#" class="collapse_file" data-file="#FILEINDEX#">[', $text['button_collapse'], ']</a>
87
+						<a href="#" class="expand_file" data-file="#FILEINDEX#" style="display: none;">[', $text['button_expand'], ']</a>
88
+						</span>
89
+					', sprintf($text['file_header'], '#FILEINDEX#'), '
90
+				</legend>
91
+
92
+				', $text['file_to_edit'], ':
93
+				<select id="file-#FILEINDEX#-file_type">
94
+					<option value="$boarddir">$boarddir</option>
95
+					<option value="$sourcedir">$sourcedir</option>
96
+					<option value="$themedir">$themedir</option>
97
+					<option value="$languagedir">$languagedir</option>
98
+				</select>
99
+				<input type="text" id="file-#FILEINDEX#-file_name" size="30" value="index.php" />
100
+
101
+				<span class="pad">', $text['file_not_found'], ':
102
+					<select id="file-#FILEINDEX#-file_fail">
103
+						<option value="fatal">', $text['file_not_found_fatal'], '</option>
104
+						<option value="ignore">', $text['file_not_found_ignore'], '</option>
105
+						<option value="skip">', $text['file_not_found_skip'], '</option>
106
+					</select>
107
+				</span>
108
+
109
+				<div id="file-#FILEINDEX#-edit_container">
110
+				<hr />
111
+				</div>
112
+				<input type="button" class="add_edit" data-file="#FILEINDEX#" value="', $text['button_add_edit'], '" />
113
+			</fieldset>
114
+			<hr />
115
+</div>
116
+
117
+<!-- This is the container for a new edit -->
118
+<!-- Do not remove any id attribute.  This makes the magic work! -->
119
+<div id="edit_template" style="display: none;">
120
+				<fieldset id="file-#FILEINDEX#-edit-#EDITINDEX#" class="edit">
121
+					<input type="hidden" id="file-#FILEINDEX#-edit-#EDITINDEX#-delete" value="0" />
122
+					<legend>
123
+						<span class="alignright">
124
+							<a href="#" class="delete_change" data-file="#FILEINDEX#" data-edit="#EDITINDEX#">[', $text['button_delete'], ']</a>
125
+							<a href="#" class="restore_change" data-file="#FILEINDEX#" data-edit="#EDITINDEX#" style="display: none;">[', $text['button_restore'], ']</a>
126
+							&nbsp;&mdash;&nbsp;
127
+							<a href="#" class="collapse_change" data-file="#FILEINDEX#" data-edit="#EDITINDEX#">[', $text['button_collapse'], ']</a>
128
+							<a href="#" class="expand_change" data-file="#FILEINDEX#" data-edit="#EDITINDEX#" style="display: none;">[', $text['button_expand'], ']</a>
129
+						</span>
130
+						', sprintf($text['edit_header'], '#FILEINDEX#', '#EDITINDEX#'), '
131
+					</legend>
132
+
133
+					<dl class="edits">
134
+						<dt>', $text['edit_action'], ':</dt>
135
+						<dd><select id="file-#FILEINDEX#-edit-#EDITINDEX#-action" onchange="update_counter()">
136
+							<option value="replace">', $text['edit_action_replace'], '</option>
137
+							<option value="before">', $text['edit_action_before'], '</option>
138
+							<option value="after">', $text['edit_action_after'], '</option>
139
+							<option value="end">', $text['edit_action_end'], '</option>
140
+						<select></dd>
141
+
142
+						<dt>', $text['edit_errors'], ':</dt>
143
+						<dd><select id="file-#FILEINDEX#-edit-#EDITINDEX#-error">
144
+							<option value="fatal">', $text['edit_errors_fail'], '</option>
145
+							<option value="ignore">', $text['edit_errors_ignore'], '</option>
146
+							<option value="required">', $text['edit_errors_required'], '</option>
147
+						</select></dd>
148
+
149
+						<dt>', $text['edit_ignore_whitespace'], '</dt>
150
+						<dd><input id="file-#FILEINDEX#-edit-#EDITINDEX#-whitespace" type="checkbox" /></dd>
151
+
152
+						<dt>', $text['edit_search_for'], ':</dt>
153
+						<dd><textarea id="file-#FILEINDEX#-edit-#EDITINDEX#-search" class="search_for" cols="75" rows="7" onchange="update_counter()">// Locate</textarea></dd>
154
+
155
+						<dt>', $text['edit_replace_with'], ':</dt>
156
+						<dd><textarea id="file-#FILEINDEX#-edit-#EDITINDEX#-replace" class="replace_with" cols="75" rows="7" onchange="update_counter()">/* Replace */</textarea></dd>
157
+					</dl>
158
+				</fieldset>
159
+				<br />
160
+</div>';
161
+}
... ...
@@ -1,13 +1,29 @@
1
+/*
2
+ * SMF Package Manager Generator
3
+ * Author: SleePy (JeremyD)
4
+ * Repository: https://github.com/jdarwood007/smf_package_maker
5
+ * License: BSD 3 Clause; See license.txt
6
+*/
7
+
8
+/* This gets things going once the document has loaded, also makes sure JQuery is here. */
1 9
 $(document).ready(function(){
10
+	/* Start off some counting */
2 11
 	action_count = 1;
3 12
 	instruct_count =new Array();
4 13
 	instruct_count[action_count] = 1;
5 14
 
15
+	/* Kick things off by creating a new action. */
6 16
 	create_new_action();
7 17
 
18
+	/* Give our buttons some actions. */
8 19
 	$('#add_action').click(create_new_action);
9
-
10 20
 	$('#show_preview').click(show_instruct_preview);
21
+
22
+	/* The details and basic buttons. */
23
+	$('#collapse_basic').click(function(){$('#basic_info .info').hide(); $('#collapse_basic').hide(); $('#restore_basic').show();});
24
+	$('#restore_basic').click(function(){$('#basic_info .info').show(); $('#restore_basic').hide(); $('#collapse_basic').show();});
25
+	$('#collapse_details').click(function(){$('#details_info .info').hide(); $('#collapse_details').hide(); $('#restore_details').show();});
26
+	$('#restore_details').click(function(){$('#details_info .info').show(); $('#restore_details').hide(); $('#collapse_details').show();});
11 27
 });
12 28
 
13 29
 /* Handles adding actions */
... ...
@@ -48,9 +64,11 @@ function create_new_instruct()
48 64
 	$('#action-' + action_index + '-instruct_container .delete_change').click(delete_instruct);
49 65
 	$('#action-' + action_index + '-instruct_container .restore_change').click(restore_instruct);
50 66
 
51
-	$('#action-' + action_index + '-instruct_container .instruct_action').change(instruct_change);
67
+	$('#action-' + action_index + '-instruct-' + instruct_count[action_index] + '-action').change(instruct_change);
52 68
 	$('#action-' + action_index + '-instruct-' + instruct_count[action_index] + '-action').change();
53 69
 
70
+	$('#action-' + action_index + '-instruct-' + instruct_count[action_index] + '-inline').change(instruct_inline);
71
+
54 72
 	instruct_count[action_index]++;
55 73
 
56 74
 	update_counter();
... ...
@@ -59,9 +77,6 @@ function create_new_instruct()
59 77
 /* Handles a change in the instruction */
60 78
 function instruct_change()
61 79
 {
62
-/*	action_index = $(selected).attr('data-action');
63
-	instruct_index = $(selected).attr('data-instruct');
64
-	this_act = $(selected).val();*/
65 80
 	action_index = $(this).attr('data-action');
66 81
 	instruct_index = $(this).attr('data-instruct');
67 82
 	this_act = $(this).val();
... ...
@@ -101,9 +116,6 @@ function instruct_change()
101 116
 
102 117
 		$('#action-' + action_index + '-instruct-' + instruct_index + ' .source').show();
103 118
 		$('#action-' + action_index + '-instruct-' + instruct_index + ' .inline').show();
104
-
105
-		/* Set our inline option */
106
-		instruct_inline($('#action-' + action_index + '-instruct-' + instruct_index + '-inline'));
107 119
 	}
108 120
 	else
109 121
 	{
... ...
@@ -114,11 +126,11 @@ function instruct_change()
114 126
 }
115 127
 
116 128
 /* Handles clicking the inline button */
117
-function instruct_inline(selected)
129
+function instruct_inline()
118 130
 {
119
-	action_index = $(selected).attr('data-action');
120
-	instruct_index = $(selected).attr('data-instruct');
121
-	is_inline = $(selected).is(':checked');
131
+	action_index = $(this).attr('data-action');
132
+	instruct_index = $(this).attr('data-instruct');
133
+	is_inline = $(this).is(':checked');
122 134
 
123 135
 	if (is_inline)
124 136
 	{
... ...
@@ -324,17 +336,12 @@ function show_instruct_preview()
324 336
 
325 337
 				if (instruct_inline && $.inArray(instruct_action, ["code", "database", "readme"]) > -1)
326 338
 				{
327
-					preview += ' inline="true"';
328
-				}
329
-
330
-				if (instruct_inline && $.inArray(instruct_action, ["code", "database", "readme"]) > -1)
331
-				{
332
-					preview += '>' + instruct_block + "\n" + '\
339
+					preview += ' inline="true">' + "\n" + instruct_block + "\n" + '\
333 340
 		</' + instruct_action + '>';
334 341
 				}
335 342
 				else
336 343
 				{
337
-					preview += " />\n";
344
+					preview += '>' + instruct_source + '</' + instruct_action + ">\n";
338 345
 				}
339 346
 			}
340 347
 			else if ($.inArray(instruct_action, ["create-dir", "create-file", "remove-dir", "remove-file"]) > -1)
... ...
@@ -1,13 +1,30 @@
1
+/*
2
+ * SMF Package Manager Generator
3
+ * Author: SleePy (JeremyD)
4
+ * Repository: https://github.com/jdarwood007/smf_package_maker
5
+ * License: BSD 3 Clause; See license.txt
6
+*/
7
+
8
+/* This gets things going once the document has loaded, also makes sure JQuery is here. */
1 9
 $(document).ready(function(){
10
+	/* Start off some counting */
2 11
 	file_count = 1;
3 12
 	edit_count =new Array();
4 13
 	edit_count[file_count] = 1;
5 14
 
15
+	/* Kick things off by creating a file. */
6 16
 	create_new_file();
7 17
 
8 18
 	$('#add_file').click(create_new_file);
9 19
 
20
+	/* Give our buttons some actions. */
10 21
 	$('#show_preview').click(show_edit_preview);
22
+
23
+	/* The details and basic buttons. */
24
+	$('#collapse_basic').click(function(){$('#basic_info .info').hide(); $('#collapse_basic').hide(); $('#restore_basic').show();});
25
+	$('#restore_basic').click(function(){$('#basic_info .info').show(); $('#restore_basic').hide(); $('#collapse_basic').show();});
26
+	$('#collapse_details').click(function(){$('#details_info .info').hide(); $('#collapse_details').hide(); $('#restore_details').show();});
27
+	$('#restore_details').click(function(){$('#details_info .info').show(); $('#restore_details').hide(); $('#collapse_details').show();});
11 28
 });
12 29
 
13 30
 /* Handles adding files */
... ...
@@ -5,6 +5,8 @@
5 5
  * Repository: https://github.com/jdarwood007/smf_package_maker
6 6
  * License: BSD 3 Clause; See license.txt
7 7
 */
8
+define('PacManGen', true);
9
+
8 10
 require_once(dirname(__FILE__) . '/settings.php');
9 11
 
10 12
 // Only invoke the download when it is enabled and we are going to try to do it.
... ...
@@ -5,8 +5,7 @@
5 5
  * Repository: https://github.com/jdarwood007/smf_package_maker
6 6
  * License: BSD 3 Clause; See license.txt
7 7
 */
8
-require_once(dirname(__FILE__) . '/settings.php');
9
-require_once(dirname(__FILE__) . '/language/' . $language . '.php');
8
+define('PacManGen', true);
10 9
 
11 10
 // Default our action.
12 11
 if (!isset($_GET['action']) || !in_array($_GET['action'], array('mod', 'info')))
... ...
@@ -14,6 +13,11 @@ if (!isset($_GET['action']) || !in_array($_GET['action'], array('mod', 'info')))
14 13
 else
15 14
 	$action = $_GET['action'];
16 15
 
16
+// Load up some files.
17
+require_once(dirname(__FILE__) . '/settings.php');
18
+require_once(dirname(__FILE__) . '/_' . $action . 'maker.php');
19
+require_once(dirname(__FILE__) . '/language/' . $language . '.php');
20
+
17 21
 echo '
18 22
 <!DOCTYPE html><!-- HTML 5 -->
19 23
 <html dir="ltr" lang="', $locale, '">
... ...
@@ -51,12 +55,9 @@ echo '
51 55
 	<div id="container">
52 56
 		<div id="wrap" class="action_', $action, '">';
53 57
 
54
-if ($action == 'mod')
55
-	mod_section();
56
-elseif ($action == 'info')
57
-	info_section();
58
-else
59
-	index_section();
58
+// Call up the right section.
59
+$function = $action . '_section';
60
+$function();
60 61
 
61 62
 echo '
62 63
 		</div>
... ...
@@ -69,315 +70,14 @@ echo '
69 70
 	</div>
70 71
 </div>';
71 72
 
72
-if ($action == 'mod')
73
-	mod_templates();
74
-elseif ($action == 'info')
75
-	info_templates();
73
+// Bring in the correct templates.
74
+$function = $action . '_templates';
75
+$function();
76 76
 
77 77
 echo '
78 78
 </body>
79 79
 </html>';
80 80
 
81
-/*
82
- * This is the mod section code.
83
-*/
84
-function mod_section()
85
-{
86
-	global $text;
87
-
88
-	echo '
89
-			<fieldset id="basic_info">
90
-				<legend>', $text['basic_info_header'], ' <span id="collapse_basic">^</span></legend>
91
-				<dl class="info">
92
-					<dt>', $text['basic_your_name'], ':</dt>
93
-					<dd><input id="basic_info_name" /></dd>
94
-
95
-					<dt>', $text['basic_mod_name'], ':</dt>
96
-					<dd><input id="basic_info_mod" /></dd>
97
-
98
-					<dd>', $text['basic_mod_version'], ':</dt>
99
-					<dd><input id="basic_info_version" /></dd>
100
-
101
-				</dl>
102
-			</fieldset>
103
-			<fieldset id="details_info">
104
-				<legend>', $text['details_header'], ' <span id="collapse_basic">^</span></legend>
105
-				<dl class="info">
106
-					<dt>', $text['details_num_files'], ':</dt>
107
-					<dd><input disabled="disabled" id="detail_files" /></dd>
108
-
109
-					<dt>', $text['details_num_edits'], ':</dt>
110
-					<dd><input disabled="disabled" id="detail_edits" /></dd>
111
-
112
-					<dd>', $text['details_num_lines'], ':</dt>
113
-					<dd><input disabled="disabled" id="detail_lines" /></dd>
114
-				</dl>
115
-			</fieldset>
116
-
117
-			<br clear="all" />
118
-			<hr />
119
-			<form id="file_container"></form>
120
-			<input type="button" id="add_file" value="', $text['button_add_file'], '" />
121
-			<input type="button" id="show_preview" value="', $text['button_preview'], '" />
122
-			<input type="button" id="download_file" value="', $text['button_download'], '" onclick="download_file_', ($use_php ? 'generate' : 'data'), '()" />
123
-			<br />
124
-			<fieldset id="preview_container" style="display: none;" class="edits" >
125
-				<legend>', $text['preview_header'], '</legend>
126
-				<textarea id="preview" cols="150" rows="25"></textarea>
127
-			</fieldset>
128
-				<br />';
129
-}
130
-
131
-/*
132
- * This is the mod templates near the end of the page
133
-*/
134
-function mod_templates()
135
-{
136
-	global $text;
137
-
138
-	echo '
139
-<!-- This is the container for a new file -->
140
-<!-- Do not remove any id attribute.  This makes the magic work! -->
141
-<div id="file_template" style="display: none;">
142
-			<fieldset id="file-#FILEINDEX#" class="edits">
143
-				<input type="hidden" id="file-#FILEINDEX#-delete" value="0" />
144
-				<legend>
145
-					<span class="alignright">
146
-						<a href="#" class="delete_file" data-file="#FILEINDEX#">[', $text['button_delete'], ']</a>
147
-						<a href="#" class="restore_file" data-file="#FILEINDEX#" style="display: none;">[', $text['button_restore'], ']</a>
148
-						&nbsp;&mdash;&nbsp;
149
-						<a href="#" class="collapse_file" data-file="#FILEINDEX#">[', $text['button_collapse'], ']</a>
150
-						<a href="#" class="expand_file" data-file="#FILEINDEX#" style="display: none;">[', $text['button_expand'], ']</a>
151
-						</span>
152
-					', sprintf($text['file_header'], '#FILEINDEX#'), '
153
-				</legend>
154
-
155
-				', $text['file_to_edit'], ':
156
-				<select id="file-#FILEINDEX#-file_type">
157
-					<option value="$boarddir">$boarddir</option>
158
-					<option value="$sourcedir">$sourcedir</option>
159
-					<option value="$themedir">$themedir</option>
160
-					<option value="$languagedir">$languagedir</option>
161
-				</select>
162
-				<input type="text" id="file-#FILEINDEX#-file_name" size="30" value="index.php" />
163
-
164
-				<span class="pad">', $text['file_not_found'], ':
165
-					<select id="file-#FILEINDEX#-file_fail">
166
-						<option value="fatal">', $text['file_not_found_fatal'], '</option>
167
-						<option value="ignore">', $text['file_not_found_ignore'], '</option>
168
-						<option value="skip">', $text['file_not_found_skip'], '</option>
169
-					</select>
170
-				</span>
171
-
172
-				<div id="file-#FILEINDEX#-edit_container">
173
-				<hr />
174
-				</div>
175
-				<input type="button" class="add_edit" data-file="#FILEINDEX#" value="', $text['button_add_edit'], '" />
176
-			</fieldset>
177
-			<hr />
178
-</div>
179
-
180
-<!-- This is the container for a new edit -->
181
-<!-- Do not remove any id attribute.  This makes the magic work! -->
182
-<div id="edit_template" style="display: none;">
183
-				<fieldset id="file-#FILEINDEX#-edit-#EDITINDEX#" class="edit">
184
-					<input type="hidden" id="file-#FILEINDEX#-edit-#EDITINDEX#-delete" value="0" />
185
-					<legend>
186
-						<span class="alignright">
187
-							<a href="#" class="delete_change" data-file="#FILEINDEX#" data-edit="#EDITINDEX#">[', $text['button_delete'], ']</a>
188
-							<a href="#" class="restore_change" data-file="#FILEINDEX#" data-edit="#EDITINDEX#" style="display: none;">[', $text['button_restore'], ']</a>
189
-							&nbsp;&mdash;&nbsp;
190
-							<a href="#" class="collapse_change" data-file="#FILEINDEX#" data-edit="#EDITINDEX#">[', $text['button_collapse'], ']</a>
191
-							<a href="#" class="expand_change" data-file="#FILEINDEX#" data-edit="#EDITINDEX#" style="display: none;">[', $text['button_expand'], ']</a>
192
-						</span>
193
-						', sprintf($text['edit_header'], '#FILEINDEX#', '#EDITINDEX#'), '
194
-					</legend>
195
-
196
-					<dl class="edits">
197
-						<dt>', $text['edit_action'], ':</dt>
198
-						<dd><select id="file-#FILEINDEX#-edit-#EDITINDEX#-action" onchange="update_counter()">
199
-							<option value="replace">', $text['edit_action_replace'], '</option>
200
-							<option value="before">', $text['edit_action_before'], '</option>
201
-							<option value="after">', $text['edit_action_after'], '</option>
202
-							<option value="end">', $text['edit_action_end'], '</option>
203
-						<select></dd>
204
-
205
-						<dt>', $text['edit_errors'], ':</dt>
206
-						<dd><select id="file-#FILEINDEX#-edit-#EDITINDEX#-error">
207
-							<option value="fatal">', $text['edit_errors_fail'], '</option>
208
-							<option value="ignore">', $text['edit_errors_ignore'], '</option>
209
-							<option value="required">', $text['edit_errors_required'], '</option>
210
-						</select></dd>
211
-
212
-						<dt>', $text['edit_ignore_whitespace'], '</dt>
213
-						<dd><input id="file-#FILEINDEX#-edit-#EDITINDEX#-whitespace" type="checkbox" /></dd>
214
-
215
-						<dt>', $text['edit_search_for'], ':</dt>
216
-						<dd><textarea id="file-#FILEINDEX#-edit-#EDITINDEX#-search" class="search_for" cols="75" rows="7" onchange="update_counter()">// Locate</textarea></dd>
217
-
218
-						<dt>', $text['edit_replace_with'], ':</dt>
219
-						<dd><textarea id="file-#FILEINDEX#-edit-#EDITINDEX#-replace" class="replace_with" cols="75" rows="7" onchange="update_counter()">/* Replace */</textarea></dd>
220
-					</dl>
221
-				</fieldset>
222
-				<br />
223
-</div>';
224
-}
225
-
226
-/*
227
- * The package-info section
228
-*/
229
-function info_section()
230
-{
231
-	global $text;
232
-
233
-	echo '
234
-			<fieldset id="basic_info">
235
-				<legend>', $text['basic_info_header'], ' <span id="collapse_basic">^</span></legend>
236
-				<dl class="info">
237
-					<dt>', $text['basic_your_name'], ':</dt>
238
-					<dd><input id="basic_info_name" /></dd>
239
-
240
-					<dt>', $text['basic_mod_name'], ':</dt>
241
-					<dd><input id="basic_info_mod" /></dd>
242
-
243
-					<dd>', $text['basic_mod_version'], ':</dt>
244
-					<dd><input id="basic_info_version" /></dd>
245
-
246
-					<dd>', $text['basic_mod_type'], ':</dt>
247
-					<dd><select name="basic_info_type">
248
-						<option value="modification">Modification</option>
249
-						<option value="avatar">Avatars</option>
250
-						<option value="smiley">Smileys</option>
251
-						<option value="language">Language</option>
252
-						<option value="other">Other</option>
253
-					</select>
254
-					</dd>
255
-
256
-				</dl>
257
-			</fieldset>
258
-			<fieldset id="details_info">
259
-				<legend>', $text['details_header'], ' <span id="collapse_basic">^</span></legend>
260
-				<dl class="info">
261
-					<dt>', $text['details_num_actions'], ':</dt>
262
-					<dd><input disabled="disabled" id="detail_actions" /></dd>
263
-
264
-					<dt>', $text['details_num_instructions'], ':&nbsp;&nbsp;</dt>
265
-					<dd><input disabled="disabled" id="detail_instructs" /></dd>
266
-				</dl>
267
-			</fieldset>
268
-
269
-			<br clear="all" />
270
-			<hr />
271
-			<form id="action_container">
272
-			</form>
273
-			<input type="button" id="add_action" value="', $text['button_add_action'], '" />
274
-			<input type="button" id="show_preview" value="', $text['button_preview'], '" />
275
-			<input type="button" id="download_file" value="', $text['button_download'], '" onclick="download_file_', ($use_php ? 'generate' : 'data'), '()" />
276
-			<br />
277
-			<fieldset id="preview_container" style="display: none;" class="edits" >
278
-				<legend>', $text['preview_header'], '</legend>
279
-				<textarea id="preview" cols="150" rows="25"></textarea>
280
-			</fieldset>
281
-				<br />';
282
-
283
-}
284
-
285
-/*
286
- * This is the mod templates near the end of the page
287
-*/
288
-function info_templates()
289
-{
290
-	global $text;
291
-
292
-	echo '
293
-<!-- This is the container for a new action -->
294
-<!-- Do not remove any id attribute.  This makes the magic work! -->
295
-<div id="action_template" style="display: none;">
296
-			<fieldset id="action-#ACTIONINDEX#" class="edits">
297
-				<input type="hidden" id="action-#ACTIONINDEX#-delete" value="0" />
298
-				<legend>
299
-					<span class="alignright">
300
-						<a href="#" class="delete_action" data-action="#ACTIONINDEX#">[', $text['button_delete'], ']</a>
301
-						<a href="#" class="restore_action" data-action="#ACTIONINDEX#" style="display: none;">[', $text['button_restore'], ']</a>
302
-						&nbsp;&mdash;&nbsp;
303
-						<a href="#" class="collapse_action" data-action="#ACTIONINDEX#">[', $text['button_collapse'], ']</a>
304
-						<a href="#" class="expand_action" data-action="#ACTIONINDEX#" style="display: none;">[', $text['button_expand'], ']</a>
305
-						</span>
306
-					', sprintf($text['action_header'], '#ACTIONINDEX#'), '
307
-				</legend>
308
-
309
-				', $text['type_of_action'], ':
310
-				<select id="action-#ACTIONINDEX#-type">
311
-					<option value="install">', $text['type_of_action_install'], '</option>
312
-					<option value="uninstall">', $text['type_of_action_uninstall'], '</option>
313
-					<option value="upgrade">', $text['type_of_action_upgrade'], '</option>
314
-				</select>
315
-
316
-				<span class="pad">', $text['action_smf_versions'], ':
317
-					<input type="text" id="action-#ACTIONINDEX#-smf_versions" size="60" value="SMF 2.0 RC5, SMF 2.0-2.0.99" />
318
-				</span>
319
-
320
-				<div id="action-#ACTIONINDEX#-instruct_container">
321
-				<hr />
322
-				</div>
323
-				<input type="button" class="add_instruct" data-action="#ACTIONINDEX#" value="', $text['button_add_instruct'], '" />
324
-			</fieldset>
325
-			<hr />
326
-</div>
327
-
328
-<!-- This is the container for a new edit -->
329
-<!-- Do not remove any id attribute.  This makes the magic work! -->
330
-<div id="instruct_template" style="display: none;">
331
-				<fieldset id="action-#ACTIONINDEX#-instruct-#INSTRUCTINDEX#" class="edit">
332
-					<input type="hidden" id="action-#ACTIONINDEX#-instruct-#INSTRUCTINDEX#-delete" value="0" />
333
-					<legend>
334
-						<span class="alignright">
335
-							<a href="#" class="delete_change" data-action="#ACTIONINDEX#" data-instruct="#INSTRUCTINDEX#">[', $text['button_delete'], ']</a>
336
-							<a href="#" class="restore_change" data-action="#ACTIONINDEX#" data-instruct="#INSTRUCTINDEX#" style="display: none;">[', $text['button_restore'], ']</a>
337
-							&nbsp;&mdash;&nbsp;
338
-							<a href="#" class="collapse_change" data-action="#ACTIONINDEX#" data-instruct="#INSTRUCTINDEX#">[', $text['button_collapse'], ']</a>
339
-							<a href="#" class="expand_change" data-action="#ACTIONINDEX#" data-instruct="#INSTRUCTINDEX#" style="display: none;">[', $text['button_expand'], ']</a>
340
-						</span>
341
-						', sprintf($text['instruct_header'], '#ACTIONINDEX#', '#INSTRUCTINDEX#'), '
342
-					</legend>
343
-
344
-					<dl class="edits">
345
-						<dt>', $text['instruct_action'], ':</dt>
346
-						<dd><select class="instruct_action" id="action-#ACTIONINDEX#-instruct-#INSTRUCTINDEX#-action" data-action="#ACTIONINDEX#" data-instruct="#INSTRUCTINDEX#">
347
-							<option value="modification">', $text['instruct_action_modification'], '</option>
348
-							<option value="code">', $text['instruct_action_code'], '</option>
349
-							<option value="database">', $text['instruct_action_database'], '</option>
350
-							<option value="create-dir">', $text['instruct_action_create_dir'], '</option>
351
-							<option value="create-file">', $text['instruct_action_create_file'], '</option>
352
-							<option value="require-dir">', $text['instruct_action_require_dir'], '</option>
353
-							<option value="require-file">', $text['instruct_action_require_file'], '</option>
354
-							<option value="move-dir">', $text['instruct_action_move_dir'], '</option>
355
-							<option value="move-file">', $text['instruct_action_move_file'], '</option>
356
-							<option value="remove-dir">', $text['instruct_action_delete_dir'], '</option>
357
-							<option value="remove-file">', $text['instruct_action_delete_file'] , '</option>
358
-							<option value="readme">', $text['instruct_action_readme'], '</option>
359
-						<select></dd>
360
-
361
-						<dt class="reverse">', $text['action_reverse'], ':</dt>
362
-						<dd class="reverse"><input type="checkbox" id="action-#ACTIONINDEX#-instruct-#INSTRUCTINDEX#-reverse"></dd>
363
-
364
-						<dt class="source">', $text['action_source'], '</dt>
365
-						<dd class="source"><input id="action-#ACTIONINDEX#-instruct-#INSTRUCTINDEX#-source" type="text" /></dd>
366
-
367
-						<dt class="destination">', $text['action_destination'], '</dt>
368
-						<dd class="destination"><input id="action-#ACTIONINDEX#-instruct-#INSTRUCTINDEX#-destination" type="text" /></dd>
369
-
370
-						<dt class="inline">', $text['action_inline'], ':</dt>
371
-						<dd class="inline"><input type="checkbox" id="action-#ACTIONINDEX#-instruct-#INSTRUCTINDEX#-inline" onchange="instruct_inline(this)" data-action="#ACTIONINDEX#" data-instruct="#INSTRUCTINDEX#"></dd>
372
-
373
-						<dt class="code_block">', $text['action_code_block'], ':</dt>
374
-						<dd class="code_block"><textarea id="action-#ACTIONINDEX#-instruct-#INSTRUCTINDEX#-block" cols="75" rows="7"></textarea></dd>
375
-					</dl>
376
-				</fieldset>
377
-				<br />
378
-</div>';
379
-}
380
-
381 81
 /*
382 82
  * The index section
383 83
 */
... ...
@@ -394,3 +94,9 @@ function index_section()
394 94
 			<li>', $text['index_compress'], '</li>
395 95
 		</ol>';
396 96
 }
97
+
98
+/*
99
+ * The index template
100
+ * Just a voodoo function.
101
+*/
102
+function index_templates() {}
... ...
@@ -1,4 +1,10 @@
1 1
 <?php
2
+/*
3
+ * SMF Package Manager Generator
4
+ * Author: SleePy (JeremyD)
5
+ * Repository: https://github.com/jdarwood007/smf_package_maker
6
+ * License: BSD 3 Clause; See license.txt
7
+*/
2 8
 
3 9
 // The locale 
4 10
 $locale = 'en-US';
... ...
@@ -5,6 +5,7 @@
5 5
  * Repository: https://github.com/jdarwood007/smf_package_maker
6 6
  * License: BSD 3 Clause; See license.txt
7 7
 */
8
+if (!defined('PacManGen')) { exit('[' . basename(__FILE__) . '] Direct access restricted');}
8 9
 
9 10
 // Assets URL location.
10 11
 $assets = '/PacManGen/assets';
11 12