46 if ( $_POST['group_type'] == PAGE_GRP_NORMAL && empty($_POST['member_page_0']) ) |
46 if ( $_POST['group_type'] == PAGE_GRP_NORMAL && empty($_POST['member_page_0']) ) |
47 { |
47 { |
48 echo '<div class="error-box">Please specify at least one page to place in this group.</div>'; |
48 echo '<div class="error-box">Please specify at least one page to place in this group.</div>'; |
49 return; |
49 return; |
50 } |
50 } |
51 if ( $_POST['group_type'] != PAGE_GRP_TAGGED && $_POST['group_type'] != PAGE_GRP_CATLINK && $_POST['group_type'] != PAGE_GRP_NORMAL ) |
51 if ( $_POST['group_type'] == PAGE_GRP_REGEX && empty($_POST['regex']) ) |
|
52 { |
|
53 echo '<div class="error-box">Please specify a regular expression to match page IDs against.</div>'; |
|
54 return; |
|
55 } |
|
56 if ( $_POST['group_type'] != PAGE_GRP_TAGGED && $_POST['group_type'] != PAGE_GRP_CATLINK && $_POST['group_type'] != PAGE_GRP_NORMAL && $_POST['group_type'] != PAGE_GRP_REGEX ) |
52 { |
57 { |
53 echo '<div class="error-box">Umm, you sent an invalid group type. I\'d put a real error message here but this will only be shown if you try to hack the system.</div>'; |
58 echo '<div class="error-box">Umm, you sent an invalid group type. I\'d put a real error message here but this will only be shown if you try to hack the system.</div>'; |
54 return; |
59 return; |
55 } |
60 } |
56 // All checks passed, create the group |
61 // All checks passed, create the group |
101 $sql = 'INSERT INTO '.table_prefix.'page_group_members(pg_id,page_id,namespace) VALUES' . implode(',', $arr_sql) . ';'; |
106 $sql = 'INSERT INTO '.table_prefix.'page_group_members(pg_id,page_id,namespace) VALUES' . implode(',', $arr_sql) . ';'; |
102 $q = $db->sql_query($sql); |
107 $q = $db->sql_query($sql); |
103 if ( !$q ) |
108 if ( !$q ) |
104 $db->_die(); |
109 $db->_die(); |
105 break; |
110 break; |
|
111 case PAGE_GRP_REGEX: |
|
112 $name = $db->escape($_POST['pg_name']); |
|
113 $regex = $db->escape($_POST['regex']); |
|
114 $sql = 'INSERT INTO '.table_prefix.'page_groups(pg_type,pg_name,pg_target) VALUES(' . PAGE_GRP_REGEX . ', \'' . $name . '\', \'' . $regex . '\');'; |
|
115 $q = $db->sql_query($sql); |
|
116 if ( !$q ) |
|
117 $db->_die(); |
|
118 break; |
106 } |
119 } |
107 echo '<div class="info-box">The page group "' . htmlspecialchars($_POST['pg_name']) . '" has been created.</div>'; |
120 echo '<div class="info-box">The page group "' . htmlspecialchars($_POST['pg_name']) . '" has been created.</div>'; |
108 break; |
121 break; |
109 } |
122 } |
110 // A little Javascript magic |
123 // A little Javascript magic |
113 function pg_create_typeset(selector) |
126 function pg_create_typeset(selector) |
114 { |
127 { |
115 var pg_normal = <?php echo PAGE_GRP_NORMAL; ?>; |
128 var pg_normal = <?php echo PAGE_GRP_NORMAL; ?>; |
116 var pg_tagged = <?php echo PAGE_GRP_TAGGED; ?>; |
129 var pg_tagged = <?php echo PAGE_GRP_TAGGED; ?>; |
117 var pg_catlink = <?php echo PAGE_GRP_CATLINK; ?>; |
130 var pg_catlink = <?php echo PAGE_GRP_CATLINK; ?>; |
|
131 var pg_regex = <?php echo PAGE_GRP_REGEX; ?>; |
118 var selection = false; |
132 var selection = false; |
119 // Get selection |
133 // Get selection |
120 for ( var i = 0; i < selector.childNodes.length; i++ ) |
134 for ( var i = 0; i < selector.childNodes.length; i++ ) |
121 { |
135 { |
122 var child = selector.childNodes[i]; |
136 var child = selector.childNodes[i]; |
154 document.getElementById('pg_create_tagged_2').style.display = 'none'; |
168 document.getElementById('pg_create_tagged_2').style.display = 'none'; |
155 |
169 |
156 document.getElementById('pg_create_title_normal').style.display = 'inline'; |
170 document.getElementById('pg_create_title_normal').style.display = 'inline'; |
157 document.getElementById('pg_create_normal_1').style.display = 'block'; |
171 document.getElementById('pg_create_normal_1').style.display = 'block'; |
158 document.getElementById('pg_create_normal_2').style.display = 'block'; |
172 document.getElementById('pg_create_normal_2').style.display = 'block'; |
|
173 |
|
174 document.getElementById('pg_create_title_regex').style.display = 'none'; |
|
175 document.getElementById('pg_create_regex_1').style.display = 'none'; |
|
176 document.getElementById('pg_create_regex_2').style.display = 'none'; |
159 } |
177 } |
160 else if ( selection == pg_catlink ) |
178 else if ( selection == pg_catlink ) |
161 { |
179 { |
162 document.getElementById('pg_create_title_catlink').style.display = 'inline'; |
180 document.getElementById('pg_create_title_catlink').style.display = 'inline'; |
163 document.getElementById('pg_create_catlink_1').style.display = 'block'; |
181 document.getElementById('pg_create_catlink_1').style.display = 'block'; |
168 document.getElementById('pg_create_tagged_2').style.display = 'none'; |
186 document.getElementById('pg_create_tagged_2').style.display = 'none'; |
169 |
187 |
170 document.getElementById('pg_create_title_normal').style.display = 'none'; |
188 document.getElementById('pg_create_title_normal').style.display = 'none'; |
171 document.getElementById('pg_create_normal_1').style.display = 'none'; |
189 document.getElementById('pg_create_normal_1').style.display = 'none'; |
172 document.getElementById('pg_create_normal_2').style.display = 'none'; |
190 document.getElementById('pg_create_normal_2').style.display = 'none'; |
|
191 |
|
192 document.getElementById('pg_create_title_regex').style.display = 'none'; |
|
193 document.getElementById('pg_create_regex_1').style.display = 'none'; |
|
194 document.getElementById('pg_create_regex_2').style.display = 'none'; |
173 } |
195 } |
174 else if ( selection == pg_tagged ) |
196 else if ( selection == pg_tagged ) |
175 { |
197 { |
176 document.getElementById('pg_create_title_catlink').style.display = 'none'; |
198 document.getElementById('pg_create_title_catlink').style.display = 'none'; |
177 document.getElementById('pg_create_catlink_1').style.display = 'none'; |
199 document.getElementById('pg_create_catlink_1').style.display = 'none'; |
182 document.getElementById('pg_create_tagged_2').style.display = 'block'; |
204 document.getElementById('pg_create_tagged_2').style.display = 'block'; |
183 |
205 |
184 document.getElementById('pg_create_title_normal').style.display = 'none'; |
206 document.getElementById('pg_create_title_normal').style.display = 'none'; |
185 document.getElementById('pg_create_normal_1').style.display = 'none'; |
207 document.getElementById('pg_create_normal_1').style.display = 'none'; |
186 document.getElementById('pg_create_normal_2').style.display = 'none'; |
208 document.getElementById('pg_create_normal_2').style.display = 'none'; |
|
209 |
|
210 document.getElementById('pg_create_title_regex').style.display = 'none'; |
|
211 document.getElementById('pg_create_regex_1').style.display = 'none'; |
|
212 document.getElementById('pg_create_regex_2').style.display = 'none'; |
|
213 } |
|
214 else if ( selection == pg_regex ) |
|
215 { |
|
216 document.getElementById('pg_create_title_catlink').style.display = 'none'; |
|
217 document.getElementById('pg_create_catlink_1').style.display = 'none'; |
|
218 document.getElementById('pg_create_catlink_2').style.display = 'none'; |
|
219 |
|
220 document.getElementById('pg_create_title_tagged').style.display = 'none'; |
|
221 document.getElementById('pg_create_tagged_1').style.display = 'none'; |
|
222 document.getElementById('pg_create_tagged_2').style.display = 'none'; |
|
223 |
|
224 document.getElementById('pg_create_title_normal').style.display = 'none'; |
|
225 document.getElementById('pg_create_normal_1').style.display = 'none'; |
|
226 document.getElementById('pg_create_normal_2').style.display = 'none'; |
|
227 |
|
228 document.getElementById('pg_create_title_regex').style.display = 'inline'; |
|
229 document.getElementById('pg_create_regex_1').style.display = 'block'; |
|
230 document.getElementById('pg_create_regex_2').style.display = 'block'; |
187 } |
231 } |
188 |
232 |
189 } |
233 } |
190 |
234 |
191 // Set to pg_normal on page load |
235 // Set to pg_normal on page load |
196 document.getElementById('pg_create_catlink_2').style.display = 'none'; |
240 document.getElementById('pg_create_catlink_2').style.display = 'none'; |
197 |
241 |
198 document.getElementById('pg_create_title_tagged').style.display = 'none'; |
242 document.getElementById('pg_create_title_tagged').style.display = 'none'; |
199 document.getElementById('pg_create_tagged_1').style.display = 'none'; |
243 document.getElementById('pg_create_tagged_1').style.display = 'none'; |
200 document.getElementById('pg_create_tagged_2').style.display = 'none'; |
244 document.getElementById('pg_create_tagged_2').style.display = 'none'; |
|
245 |
|
246 document.getElementById('pg_create_title_regex').style.display = 'none'; |
|
247 document.getElementById('pg_create_regex_1').style.display = 'none'; |
|
248 document.getElementById('pg_create_regex_2').style.display = 'none'; |
201 |
249 |
202 document.getElementById('pg_create_title_normal').style.display = 'inline'; |
250 document.getElementById('pg_create_title_normal').style.display = 'inline'; |
203 document.getElementById('pg_create_normal_1').style.display = 'block'; |
251 document.getElementById('pg_create_normal_1').style.display = 'block'; |
204 document.getElementById('pg_create_normal_2').style.display = 'block'; |
252 document.getElementById('pg_create_normal_2').style.display = 'block'; |
205 } |
253 } |
290 <td class="row1"> |
338 <td class="row1"> |
291 <select name="group_type" onchange="pg_create_typeset(this);"> |
339 <select name="group_type" onchange="pg_create_typeset(this);"> |
292 <option value="' . PAGE_GRP_NORMAL . '" selected="selected">Static group of pages</option> |
340 <option value="' . PAGE_GRP_NORMAL . '" selected="selected">Static group of pages</option> |
293 <option value="' . PAGE_GRP_TAGGED . '">Group of pages with one tag</option> |
341 <option value="' . PAGE_GRP_TAGGED . '">Group of pages with one tag</option> |
294 <option value="' . PAGE_GRP_CATLINK . '">Link to category</option> |
342 <option value="' . PAGE_GRP_CATLINK . '">Link to category</option> |
|
343 <option value="' . PAGE_GRP_REGEX . '">Perl-compatible regular expression (advanced)</option> |
295 </select> |
344 </select> |
296 </td> |
345 </td> |
297 </tr>'; |
346 </tr>'; |
298 |
347 |
299 // Titles |
348 // Titles |
322 <small>Pages in subcategories are <u>not</u> included, however subcategory pages themselves are.</small> |
374 <small>Pages in subcategories are <u>not</u> included, however subcategory pages themselves are.</small> |
323 </div> |
375 </div> |
324 <div id="pg_create_tagged_1"> |
376 <div id="pg_create_tagged_1"> |
325 Include pages with this tag: |
377 Include pages with this tag: |
326 </div> |
378 </div> |
|
379 <div id="pg_create_regex_1"> |
|
380 Regular expression:<br /> |
|
381 <small>Be sure to include the starting and ending delimiters and any flags you might need.<br /> |
|
382 These pages might help: <a href="http://us.php.net/manual/en/reference.pcre.pattern.modifiers.php">Pattern modifiers</a> • |
|
383 <a href="http://us.php.net/manual/en/reference.pcre.pattern.syntax.php">Pattern syntax</a><br /> |
|
384 Examples: <tt>/^(Special|Admin):/i</tt> • <tt>/^Image:([0-9]+)$/</tt><br /> |
|
385 Developers, remember that this will be matched against the full page identifier string. This means that <tt>/^About_Enano$/</tt> |
|
386 will NOT match the page Special:About_Enano.</small> |
327 </td>'; |
387 </td>'; |
328 |
388 |
329 echo ' <td class="row1"> |
389 echo ' <td class="row1"> |
330 <div id="pg_create_normal_2" /> |
390 <div id="pg_create_normal_2" /> |
331 <input type="text" style="margin-top: 3px;" name="member_page_0" id="pg_create_member_0" onkeyup="return ajaxPageNameComplete(this);" size="30" /><br /> |
391 <input type="text" style="margin-top: 3px;" name="member_page_0" id="pg_create_member_0" onkeyup="return ajaxPageNameComplete(this);" size="30" /><br /> |
535 $q = $db->sql_query('UPDATE '.table_prefix.'page_groups SET pg_target=\'' . $target . '\' WHERE pg_id=' . $edit_id . ';'); |
598 $q = $db->sql_query('UPDATE '.table_prefix.'page_groups SET pg_target=\'' . $target . '\' WHERE pg_id=' . $edit_id . ';'); |
536 if ( !$q ) |
599 if ( !$q ) |
537 $db->_die(); |
600 $db->_die(); |
538 else |
601 else |
539 echo '<div class="info-box">The affecting tag was updated.</div>'; |
602 echo '<div class="info-box">The affecting tag was updated.</div>'; |
|
603 } |
|
604 } |
|
605 else if ( $_POST['pg_type'] == PAGE_GRP_REGEX ) |
|
606 { |
|
607 $target = $_POST['pg_target']; |
|
608 if ( empty($target) ) |
|
609 { |
|
610 echo '<div class="error-box">Please enter an expression to match against..</div>'; |
|
611 } |
|
612 else |
|
613 { |
|
614 $target = $db->escape($target); |
|
615 $q = $db->sql_query('UPDATE '.table_prefix.'page_groups SET pg_target=\'' . $target . '\' WHERE pg_id=' . $edit_id . ';'); |
|
616 if ( !$q ) |
|
617 $db->_die(); |
|
618 else |
|
619 echo '<div class="info-box">The expression to match against was updated.</div>'; |
540 } |
620 } |
541 } |
621 } |
542 else if ( $_POST['pg_type'] == PAGE_GRP_CATLINK ) |
622 else if ( $_POST['pg_type'] == PAGE_GRP_CATLINK ) |
543 { |
623 { |
544 $target = $_POST['pg_target']; |
624 $target = $_POST['pg_target']; |
795 <td class="row1"> |
875 <td class="row1"> |
796 <input type="text" name="pg_target" value="' . htmlspecialchars($row['pg_target']) . '" size="30" /> |
876 <input type="text" name="pg_target" value="' . htmlspecialchars($row['pg_target']) . '" size="30" /> |
797 </td> |
877 </td> |
798 </tr>'; |
878 </tr>'; |
799 break; |
879 break; |
|
880 case PAGE_GRP_REGEX: |
|
881 echo '<tr> |
|
882 <td class="row2"> |
|
883 Regular expression to use:<br /> |
|
884 <small>Be sure to include the starting and ending delimiters and any flags you might need.<br /> |
|
885 These pages might help: <a href="http://us.php.net/manual/en/reference.pcre.pattern.modifiers.php">Pattern modifiers</a> • |
|
886 <a href="http://us.php.net/manual/en/reference.pcre.pattern.syntax.php">Pattern syntax</a><br /> |
|
887 Examples: <tt>/^(Special|Admin):/i</tt> • <tt>/^Image:([0-9]+)$/</tt><br /> |
|
888 Developers, remember that this will be matched against the full page identifier string. This means that <tt>/^About_Enano$/</tt> |
|
889 will NOT match the page Special:About_Enano.</small> |
|
890 </td> |
|
891 <td class="row1"> |
|
892 <input type="text" name="pg_target" value="' . htmlspecialchars($row['pg_target']) . '" size="30" /> |
|
893 </td> |
|
894 </tr>'; |
|
895 break; |
800 case PAGE_GRP_CATLINK: |
896 case PAGE_GRP_CATLINK: |
801 |
897 |
802 // Build category list |
898 // Build category list |
803 $q = $db->sql_query('SELECT name,urlname FROM '.table_prefix.'pages WHERE namespace=\'Category\';'); |
899 $q = $db->sql_query('SELECT name,urlname FROM '.table_prefix.'pages WHERE namespace=\'Category\';'); |
804 if ( !$q ) |
900 if ( !$q ) |
909 $type = 'Set of tagged pages'; |
1005 $type = 'Set of tagged pages'; |
910 break; |
1006 break; |
911 case PAGE_GRP_NORMAL: |
1007 case PAGE_GRP_NORMAL: |
912 $type = 'Static set of pages'; |
1008 $type = 'Static set of pages'; |
913 break; |
1009 break; |
|
1010 case PAGE_GRP_REGEX: |
|
1011 $type = 'Regular expression match'; |
|
1012 break; |
914 } |
1013 } |
915 $target = ''; |
1014 $target = ''; |
916 if ( $row['pg_type'] == PAGE_GRP_TAGGED ) |
1015 if ( $row['pg_type'] == PAGE_GRP_TAGGED ) |
917 { |
1016 { |
918 $target = 'Tag: ' . htmlspecialchars($row['pg_target']); |
1017 $target = 'Tag: ' . htmlspecialchars($row['pg_target']); |
919 } |
1018 } |
920 else if ( $row['pg_type'] == PAGE_GRP_CATLINK ) |
1019 else if ( $row['pg_type'] == PAGE_GRP_CATLINK ) |
921 { |
1020 { |
922 $target = 'Category: ' . htmlspecialchars(get_page_title($paths->nslist['Category'] . sanitize_page_id($row['pg_target']))); |
1021 $target = 'Category: ' . htmlspecialchars(get_page_title($paths->nslist['Category'] . sanitize_page_id($row['pg_target']))); |
|
1022 } |
|
1023 else if ( $row['pg_type'] == PAGE_GRP_REGEX ) |
|
1024 { |
|
1025 $target = 'Expression: <tt>' . htmlspecialchars($row['pg_target']) . '</tt>'; |
923 } |
1026 } |
924 $btn_edit = '<input type="submit" name="action[edit][' . $row['pg_id'] . ']" value="Edit" />'; |
1027 $btn_edit = '<input type="submit" name="action[edit][' . $row['pg_id'] . ']" value="Edit" />'; |
925 $btn_del = '<input type="submit" name="action[del][' . $row['pg_id'] . ']" value="Delete" />'; |
1028 $btn_del = '<input type="submit" name="action[del][' . $row['pg_id'] . ']" value="Delete" />'; |
926 // stupid jEdit bug/hack |
1029 // stupid jEdit bug/hack |
927 $quot = '"'; |
1030 $quot = '"'; |