diff -r d8156d18ac58 -r 97ae8e9d5e29 plugins/admin/PageGroups.php
--- a/plugins/admin/PageGroups.php Thu Sep 27 15:55:37 2007 -0400
+++ b/plugins/admin/PageGroups.php Sat Nov 03 07:43:35 2007 -0400
@@ -48,7 +48,12 @@
echo '
Please specify at least one page to place in this group.
';
return;
}
- if ( $_POST['group_type'] != PAGE_GRP_TAGGED && $_POST['group_type'] != PAGE_GRP_CATLINK && $_POST['group_type'] != PAGE_GRP_NORMAL )
+ if ( $_POST['group_type'] == PAGE_GRP_REGEX && empty($_POST['regex']) )
+ {
+ echo 'Please specify a regular expression to match page IDs against.
';
+ return;
+ }
+ 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 )
{
echo '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.
';
return;
@@ -103,6 +108,14 @@
if ( !$q )
$db->_die();
break;
+ case PAGE_GRP_REGEX:
+ $name = $db->escape($_POST['pg_name']);
+ $regex = $db->escape($_POST['regex']);
+ $sql = 'INSERT INTO '.table_prefix.'page_groups(pg_type,pg_name,pg_target) VALUES(' . PAGE_GRP_REGEX . ', \'' . $name . '\', \'' . $regex . '\');';
+ $q = $db->sql_query($sql);
+ if ( !$q )
+ $db->_die();
+ break;
}
echo 'The page group "' . htmlspecialchars($_POST['pg_name']) . '" has been created.
';
break;
@@ -115,6 +128,7 @@
var pg_normal = ;
var pg_tagged = ;
var pg_catlink = ;
+ var pg_regex = ;
var selection = false;
// Get selection
for ( var i = 0; i < selector.childNodes.length; i++ )
@@ -135,7 +149,7 @@
return true;
}
selection = parseInt(selection);
- if ( selection != pg_normal && selection != pg_tagged && selection != pg_catlink )
+ if ( selection != pg_normal && selection != pg_tagged && selection != pg_catlink && selection != pg_regex )
{
alert('Invalid field value');
return true;
@@ -156,6 +170,10 @@
document.getElementById('pg_create_title_normal').style.display = 'inline';
document.getElementById('pg_create_normal_1').style.display = 'block';
document.getElementById('pg_create_normal_2').style.display = 'block';
+
+ document.getElementById('pg_create_title_regex').style.display = 'none';
+ document.getElementById('pg_create_regex_1').style.display = 'none';
+ document.getElementById('pg_create_regex_2').style.display = 'none';
}
else if ( selection == pg_catlink )
{
@@ -170,6 +188,10 @@
document.getElementById('pg_create_title_normal').style.display = 'none';
document.getElementById('pg_create_normal_1').style.display = 'none';
document.getElementById('pg_create_normal_2').style.display = 'none';
+
+ document.getElementById('pg_create_title_regex').style.display = 'none';
+ document.getElementById('pg_create_regex_1').style.display = 'none';
+ document.getElementById('pg_create_regex_2').style.display = 'none';
}
else if ( selection == pg_tagged )
{
@@ -184,6 +206,28 @@
document.getElementById('pg_create_title_normal').style.display = 'none';
document.getElementById('pg_create_normal_1').style.display = 'none';
document.getElementById('pg_create_normal_2').style.display = 'none';
+
+ document.getElementById('pg_create_title_regex').style.display = 'none';
+ document.getElementById('pg_create_regex_1').style.display = 'none';
+ document.getElementById('pg_create_regex_2').style.display = 'none';
+ }
+ else if ( selection == pg_regex )
+ {
+ document.getElementById('pg_create_title_catlink').style.display = 'none';
+ document.getElementById('pg_create_catlink_1').style.display = 'none';
+ document.getElementById('pg_create_catlink_2').style.display = 'none';
+
+ document.getElementById('pg_create_title_tagged').style.display = 'none';
+ document.getElementById('pg_create_tagged_1').style.display = 'none';
+ document.getElementById('pg_create_tagged_2').style.display = 'none';
+
+ document.getElementById('pg_create_title_normal').style.display = 'none';
+ document.getElementById('pg_create_normal_1').style.display = 'none';
+ document.getElementById('pg_create_normal_2').style.display = 'none';
+
+ document.getElementById('pg_create_title_regex').style.display = 'inline';
+ document.getElementById('pg_create_regex_1').style.display = 'block';
+ document.getElementById('pg_create_regex_2').style.display = 'block';
}
}
@@ -199,6 +243,10 @@
document.getElementById('pg_create_tagged_1').style.display = 'none';
document.getElementById('pg_create_tagged_2').style.display = 'none';
+ document.getElementById('pg_create_title_regex').style.display = 'none';
+ document.getElementById('pg_create_regex_1').style.display = 'none';
+ document.getElementById('pg_create_regex_2').style.display = 'none';
+
document.getElementById('pg_create_title_normal').style.display = 'inline';
document.getElementById('pg_create_normal_1').style.display = 'block';
document.getElementById('pg_create_normal_2').style.display = 'block';
@@ -292,6 +340,7 @@
+ Regular expression:
+
Be sure to include the starting and ending delimiters and any flags you might need.
+ These pages might help: Pattern modifiers •
+ Pattern syntax
+ Examples: /^(Special|Admin):/i • /^Image:([0-9]+)$/
+ Developers, remember that this will be matched against the full page identifier string. This means that /^About_Enano$/
+ will NOT match the page Special:About_Enano.
';
echo '
@@ -341,6 +401,9 @@
' . $catlist . '
+
+
+
';
@@ -539,6 +602,23 @@
echo '
The affecting tag was updated.
';
}
}
+ else if ( $_POST['pg_type'] == PAGE_GRP_REGEX )
+ {
+ $target = $_POST['pg_target'];
+ if ( empty($target) )
+ {
+ echo '
Please enter an expression to match against..
';
+ }
+ else
+ {
+ $target = $db->escape($target);
+ $q = $db->sql_query('UPDATE '.table_prefix.'page_groups SET pg_target=\'' . $target . '\' WHERE pg_id=' . $edit_id . ';');
+ if ( !$q )
+ $db->_die();
+ else
+ echo '
The expression to match against was updated.
';
+ }
+ }
else if ( $_POST['pg_type'] == PAGE_GRP_CATLINK )
{
$target = $_POST['pg_target'];
@@ -797,6 +877,22 @@
';
break;
+ case PAGE_GRP_REGEX:
+ echo '
+
+ Regular expression to use:
+ Be sure to include the starting and ending delimiters and any flags you might need.
+ These pages might help: Pattern modifiers •
+ Pattern syntax
+ Examples: /^(Special|Admin):/i • /^Image:([0-9]+)$/
+ Developers, remember that this will be matched against the full page identifier string. This means that /^About_Enano$/
+ will NOT match the page Special:About_Enano.
+
+
+
+
+ ';
+ break;
case PAGE_GRP_CATLINK:
// Build category list
@@ -911,6 +1007,9 @@
case PAGE_GRP_NORMAL:
$type = 'Static set of pages';
break;
+ case PAGE_GRP_REGEX:
+ $type = 'Regular expression match';
+ break;
}
$target = '';
if ( $row['pg_type'] == PAGE_GRP_TAGGED )
@@ -921,6 +1020,10 @@
{
$target = 'Category: ' . htmlspecialchars(get_page_title($paths->nslist['Category'] . sanitize_page_id($row['pg_target'])));
}
+ else if ( $row['pg_type'] == PAGE_GRP_REGEX )
+ {
+ $target = 'Expression:
' . htmlspecialchars($row['pg_target']) . ' ';
+ }
$btn_edit = '
';
$btn_del = '
';
// stupid jEdit bug/hack