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 /> |
909 $type = 'Set of tagged pages'; |
972 $type = 'Set of tagged pages'; |
910 break; |
973 break; |
911 case PAGE_GRP_NORMAL: |
974 case PAGE_GRP_NORMAL: |
912 $type = 'Static set of pages'; |
975 $type = 'Static set of pages'; |
913 break; |
976 break; |
|
977 case PAGE_GRP_REGEX: |
|
978 $type = 'Regular expression match'; |
|
979 break; |
914 } |
980 } |
915 $target = ''; |
981 $target = ''; |
916 if ( $row['pg_type'] == PAGE_GRP_TAGGED ) |
982 if ( $row['pg_type'] == PAGE_GRP_TAGGED ) |
917 { |
983 { |
918 $target = 'Tag: ' . htmlspecialchars($row['pg_target']); |
984 $target = 'Tag: ' . htmlspecialchars($row['pg_target']); |
919 } |
985 } |
920 else if ( $row['pg_type'] == PAGE_GRP_CATLINK ) |
986 else if ( $row['pg_type'] == PAGE_GRP_CATLINK ) |
921 { |
987 { |
922 $target = 'Category: ' . htmlspecialchars(get_page_title($paths->nslist['Category'] . sanitize_page_id($row['pg_target']))); |
988 $target = 'Category: ' . htmlspecialchars(get_page_title($paths->nslist['Category'] . sanitize_page_id($row['pg_target']))); |
|
989 } |
|
990 else if ( $row['pg_type'] == PAGE_GRP_REGEX ) |
|
991 { |
|
992 $target = 'Expression: <tt>' . htmlspecialchars($row['pg_target']) . '</tt>'; |
923 } |
993 } |
924 $btn_edit = '<input type="submit" name="action[edit][' . $row['pg_id'] . ']" value="Edit" />'; |
994 $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" />'; |
995 $btn_del = '<input type="submit" name="action[del][' . $row['pg_id'] . ']" value="Delete" />'; |
926 // stupid jEdit bug/hack |
996 // stupid jEdit bug/hack |
927 $quot = '"'; |
997 $quot = '"'; |