diff -r be6c5fdd9203 -r 4ccdfeee9a11 plugins/admin/PageGroups.php --- a/plugins/admin/PageGroups.php Mon Dec 31 21:43:51 2007 -0500 +++ b/plugins/admin/PageGroups.php Thu Jan 03 00:53:33 2008 -0500 @@ -15,9 +15,12 @@ function page_Admin_PageGroups() { global $db, $session, $paths, $template, $plugins; // Common objects + global $lang; if ( $session->auth_level < USER_LEVEL_ADMIN || $session->user_level < USER_LEVEL_ADMIN ) { - echo '

Error: Not authenticated

It looks like your administration session is invalid or you are not authorized to access this administration page. Please re-authenticate to continue.

'; + $login_link = makeUrlNS('Special', 'Login/' . $paths->nslist['Special'] . 'Administration', 'level=' . USER_LEVEL_ADMIN, true); + echo '

' . $lang->get('adm_err_not_auth_title') . '

'; + echo '

' . $lang->get('adm_err_not_auth_body', array( 'login_link' => $login_link )) . '

'; return; } @@ -30,27 +33,27 @@ case true: if ( empty($_POST['pg_name']) || empty($_POST['group_type']) ) { - echo '
Please enter a name for the page group.
'; + echo '
' . $lang->get('acppg_err_need_name') . '
'; return; } if ( $_POST['group_type'] == PAGE_GRP_TAGGED && empty($_POST['member_tag']) ) { - echo '
Please enter a page tag.
'; + echo '
' . $lang->get('acppg_err_need_tag') . '
'; return; } if ( $_POST['group_type'] == PAGE_GRP_CATLINK && empty($_POST['member_cat']) ) { - echo '
Please create a category page before linking a page group to a category.
'; + echo '
' . $lang->get('acppg_err_need_cat') . '
'; return; } if ( $_POST['group_type'] == PAGE_GRP_NORMAL && empty($_POST['member_page_0']) ) { - echo '
Please specify at least one page to place in this group.
'; + echo '
' . $lang->get('acppg_err_need_page') . '
'; return; } if ( $_POST['group_type'] == PAGE_GRP_REGEX && empty($_POST['regex']) ) { - echo '
Please specify a regular expression to match page IDs against.
'; + echo '
' . $lang->get('acppg_err_need_regex') . '
'; 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 ) @@ -117,7 +120,7 @@ $db->_die(); break; } - echo '
The page group "' . htmlspecialchars($_POST['pg_name']) . '" has been created.
'; + echo '
' . $lang->get('acppg_msg_create_success', array('group_name' => htmlspecialchars($_POST['pg_name']))) . '
'; break; } // A little Javascript magic @@ -295,7 +298,7 @@ if ( $db->numrows() < 1 ) { - $catlist = 'There aren\'t any categories on this site.'; + $catlist = $lang->get('acppg_err_no_cats'); } else { @@ -316,14 +319,14 @@ echo '
- + '; // Name echo ''; @@ -349,16 +352,16 @@ echo ''; @@ -366,24 +369,19 @@ echo ''; echo ' - + '; echo '
Create page group' . $lang->get('acppg_th_create') . '
- Group name:
- This should be short, descriptive, and human-readable. + ' . $lang->get('acppg_field_group_name') . '
+ ' . $lang->get('acppg_field_group_name_hint') . '
@@ -333,14 +336,14 @@ // Group type echo '
- Group type: + ' . $lang->get('acppg_field_group_type') . '
- Static group of pages + ' . $lang->get('acppg_gtype_static') . ' - Group of commonly tagged pages + ' . $lang->get('acppg_gtype_tagged') . ' - Mirror a category + ' . $lang->get('acppg_gtype_catlink') . ' - Filter through a regular expression + ' . $lang->get('acppg_gtype_regex') . '
- Member pages:
- Click the "plus" button to add more fields. + ' . $lang->get('acppg_field_member_pages') . '
+ ' . $lang->get('acppg_field_member_pages_hint') . '
- Include pages with this tag: + ' . $lang->get('acppg_field_target_tag') . '
- 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.
+ ' . $lang->get('acppg_field_target_regex') . '
+ ' . $lang->get('acppg_field_target_regex_hint') . '
@@ -409,7 +407,7 @@ // Submit button echo '
@@ -427,18 +425,18 @@ if ( !empty($delete_id) ) { - echo '
'; - echo ''; - echo '
'; - echo ' '; - echo ' '; - echo ' '; - echo ' '; - echo '
Confirm deletion
Are you sure you want to delete this page group?
'; - echo ' '; - echo ' '; - echo '
'; - echo ''; + echo '
' . "\n"; + echo '' . "\n"; + echo '
' . "\n"; + echo ' ' . "\n"; + echo ' ' . "\n"; + echo ' ' . "\n"; + echo ' ' . "\n"; + echo '
' . $lang->get('acppg_th_delete_confirm') . '
' . $lang->get('acppg_msg_delete_confirm') . '
' . "\n"; + echo ' ' . "\n"; + echo ' ' . "\n"; + echo '
' . "\n"; + echo '' . "\n"; return; } @@ -471,7 +469,9 @@ $q = $db->sql_query('DELETE FROM '.table_prefix.'page_group_members WHERE pg_id=' . $delete_id . ';'); if ( !$q ) $db->_die(); - echo "
The group ".'"'.htmlspecialchars("$pg_name").'"'." has been deleted.
"; + + $del_msg = $lang->get('acppg_msg_delete_success', array('pg_name' => htmlspecialchars($pg_name))); + echo "
$del_msg
"; } else if ( isset($_POST['action']['edit']) && !isset($_POST['action']['noop']) ) { @@ -500,7 +500,7 @@ $page = $_POST['new_page']; if ( empty($page) ) { - $return = array('mode' => 'error', 'text' => 'Please enter a page title.'); + $return = array('mode' => 'error', 'text' => $lang->get('acppg_err_ajaxadd_need_title')); echo enano_json_encode($return); return; } @@ -534,7 +534,7 @@ } if ( $db->numrows() > 0 ) { - $return = array('mode' => 'error', 'text' => 'The page you are trying to add is already in this group.'); + $return = array('mode' => 'error', 'text' => $lang->get('acppg_err_ajaxadd_already_in')); echo enano_json_encode($return); return; } @@ -549,7 +549,7 @@ $title = "($namespace) " . get_page_title($paths->nslist[$namespace] . $page_id); - $return = array('mode' => 'info', 'text' => 'The page has been added to the specified group.', 'successful' => true, 'title' => $title, 'member_id' => $db->insert_id()); + $return = array('mode' => 'info', 'text' => $lang->get('acppg_ajaxadd_success'), 'successful' => true, 'title' => $title, 'member_id' => $db->insert_id()); echo enano_json_encode($return); return; @@ -565,7 +565,7 @@ $new_name = $_POST['pg_name']; if ( empty($new_name) ) { - echo '
Please enter a valid name for this group.
'; + echo '
' . $lang->get('acppg_err_save_need_name') . '
'; } else { @@ -581,7 +581,7 @@ if ( !$q ) $db->_die(); else - echo '
The group name was updated successfully.
'; + echo '
' . $lang->get('acppg_msg_save_name_updated') . '
'; } if ( $_POST['pg_type'] == PAGE_GRP_TAGGED ) { @@ -589,7 +589,7 @@ $target = sanitize_tag($target); if ( empty($target) ) { - echo '
Please enter a valid tag.
'; + echo '
' . $lang->get('acppg_err_save_need_tag') . '
'; } else { @@ -598,7 +598,7 @@ if ( !$q ) $db->_die(); else - echo '
The affecting tag was updated.
'; + echo '
' . $lang->get('acppg_msg_save_tag_updated') . '
'; } } else if ( $_POST['pg_type'] == PAGE_GRP_REGEX ) @@ -606,7 +606,7 @@ $target = $_POST['pg_target']; if ( empty($target) ) { - echo '
Please enter an expression to match against..
'; + echo '
' . $lang->get('acppg_err_save_need_regex') . '
'; } else { @@ -615,7 +615,7 @@ if ( !$q ) $db->_die(); else - echo '
The expression to match against was updated.
'; + echo '
' . $lang->get('acppg_msg_save_regex_updated') . '
'; } } else if ( $_POST['pg_type'] == PAGE_GRP_CATLINK ) @@ -623,7 +623,7 @@ $target = $_POST['pg_target']; if ( empty($target) ) { - echo '
No category ID specified on POST URI.
'; + echo '
' . $lang->get('acppg_err_save_bad_category') . '
'; } else { @@ -632,7 +632,7 @@ if ( !$q ) $db->_die(); else - echo '
The affecting category was updated.
'; + echo '
' . $lang->get('acppg_msg_save_cat_updated') . '
'; } } } @@ -667,7 +667,7 @@ $subquery = ( count($good) > 0 ) ? 'pg_member_id=' . implode(' OR pg_member_id=', $good) : "'foo'='bar'"; if ( $subquery == "'foo'='bar'" ) { - echo '
No pages were selected for deletion, and thus none were deleted.
'; + echo '
' . $lang->get('acppg_err_save_no_pages') . '
'; } else { @@ -676,7 +676,7 @@ { $db->_die(); } - echo '
The requested page group members have been deleted.
'; + echo '
' . $lang->get('acppg_msg_save_pages_deleted') . '
'; } } @@ -700,12 +700,12 @@ echo '
- + '; // Group name echo ' - + '; @@ -725,7 +725,7 @@ // You have guessed correct. // *Sits in chair for 10 minutes listening to the radio in an effort to put off writing the code you see below* - echo ''; + echo ''; echo '
Editing page group: ' . htmlspecialchars($row['pg_name']) . '' . $lang->get('acppg_th_editing_group') . ' ' . htmlspecialchars($row['pg_name']) . '
Group name:' . $lang->get('acppg_field_group_name') . '
'; echo ''; echo '
'; @@ -733,7 +733,7 @@ echo '
- + '; $q = $db->sql_query('SELECT m.pg_member_id,m.page_id,m.namespace FROM '.table_prefix.'page_group_members AS m @@ -744,11 +744,11 @@ if ( !$q ) $db->_die(); - $delim = ceil( $db->numrows() / 2 ); + $delim = ceil( $db->numrows($q) / 2 ); if ( $delim < 5 ) { $delim = 0xFFFFFFFE; - // stupid hack + // stupid hack. I'm XSSing my own code. $colspan = '2" id="pg_edit_tackon2me'; } else @@ -756,10 +756,10 @@ $colspan = "1"; } - echo ''; - echo ''; + echo ''; // More javascript magic! ?> @@ -781,7 +781,10 @@ { var input = document.getElementById('inptext_pg_add_member'); input.onkeyup = function(e) { ajaxPageNameComplete(this); }; - input.onkeypress = function(e) { if ( e.keyCode == 13 ) { setTimeout('__pg_edit_ajaxadd(document.getElementById(\'' + this.id + '\'));', 500); } }; + } addOnloadHook(__ol_pg_edit_setup); var __pg_edit_objcache = false; @@ -869,7 +872,7 @@ case PAGE_GRP_TAGGED: echo ''; + echo ''; } else { echo ''; } @@ -950,10 +945,10 @@ { // This needs to be outside of the form. echo '
Remove pages from this group' . $lang->get('acppg_th_remove_selected') . '
Remove pages:'; + echo '
' . $lang->get('acppg_field_remove') . ''; $i = 0; - while ( $row = $db->fetchrow() ) + while ( $row = $db->fetchrow($q) ) { $i++; if ( $i == $delim ) @@ -771,7 +771,7 @@ } echo '
- Include pages with this tag: + ' . $lang->get('acppg_field_target_tag') . ' @@ -879,13 +882,8 @@ 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.
+ ' . $lang->get('acppg_field_target_regex') . '
+ ' . $lang->get('acppg_field_target_regex_hint') . '
@@ -916,11 +914,8 @@ echo '
- Include pages that are in this category:
- Reminder: Enano does not automatically place any access controls on the category. If you - don\'t want users to be able to freely add and remove pages from the category (assuming Wiki Mode is enabled - for the category) then you need to enable protection on the category using the button on the more options menu. - + ' . $lang->get('acppg_field_target_category') . '
+ ' . $lang->get('acppg_field_target_category_hint2') . '
' . $catlist . ' @@ -932,13 +927,13 @@ if ( $ajax_page_add ) { - echo '
- - + +
'; - echo ''; + echo ''; echo ''; // Add pages AJAX form - echo ''; + echo ''; echo ''; echo '
On-the-fly tools
' . $lang->get('acppg_th_onthefly') . '
Add page:
You can add multiple pages by entering part of a page title, and it will be auto-completed. Press Enter to quickly add the page. This only works if you a really up-to-date browser.
' . $lang->get('acppg_field_add_page') . '
' . $lang->get('acppg_field_add_page_hint') . '
'; } @@ -971,8 +966,8 @@ } // No action defined - show default menu - echo '

Manage page groups

'; - echo '

Enano\'s page grouping system allows you to build sets of pages that can be controlled by a single ACL rule. This makes managing features such as a members-only section of your site a lot easier. If you don\'t use the ACL system, you probably don\'t need to use page groups.

'; + echo '

' . $lang->get('acppg_heading_main') . '

'; + echo '

' . $lang->get('acppg_hint_intro') . '

'; $q = $db->sql_query('SELECT pg_id, pg_type, pg_name, pg_target FROM '.table_prefix.'page_groups;'); if ( !$q ) @@ -983,13 +978,13 @@ echo '
- - - - + + + + '; - if ( $row = $db->fetchrow() ) + if ( $row = $db->fetchrow($q) ) { do { @@ -998,53 +993,51 @@ switch ( $row['pg_type'] ) { case PAGE_GRP_CATLINK: - $type = 'Link to category'; + $type = $lang->get('acppg_gtype_catlink'); break; case PAGE_GRP_TAGGED: - $type = 'Set of tagged pages'; + $type = $lang->get('acppg_gtype_tagged'); break; case PAGE_GRP_NORMAL: - $type = 'Static set of pages'; + $type = $lang->get('acppg_gtype_static'); break; case PAGE_GRP_REGEX: - $type = 'Regular expression match'; + $type = $lang->get('acppg_gtype_regex'); break; } $target = ''; if ( $row['pg_type'] == PAGE_GRP_TAGGED ) { - $target = 'Tag: ' . htmlspecialchars($row['pg_target']); + $target = $lang->get('acppg_lbl_tag') . ' ' . htmlspecialchars($row['pg_target']); } else if ( $row['pg_type'] == PAGE_GRP_CATLINK ) { - $target = 'Category: ' . htmlspecialchars(get_page_title($paths->nslist['Category'] . sanitize_page_id($row['pg_target']))); + $target = $lang->get('acppg_lbl_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']) . ''; + $target = $lang->get('acppg_lbl_regex') . ' ' . htmlspecialchars($row['pg_target']) . ''; } - $btn_edit = ''; - $btn_del = ''; - // stupid jEdit bug/hack - $quot = '"'; + $btn_edit = ''; + $btn_del = ''; echo " - - - - - + + + + + "; } - while ( $row = $db->fetchrow() ); + while ( $row = $db->fetchrow($q) ); } else { - echo ' '; + echo ' '; } echo ' ';
Group nameTypeTargetActions' . $lang->get('acppg_col_group_name') . '' . $lang->get('acppg_col_type') . '' . $lang->get('acppg_col_target') . '' . $lang->get('acppg_col_actions') . '
$name$type$target$btn_edit$btn_del$name$type$target$btn_edit$btn_del
No page groups defined.
' . $lang->get('acppg_msg_no_groups') . '
- +