diff -r de56132c008d -r bdac73ed481e plugins/admin/PageEditor.php
--- a/plugins/admin/PageEditor.php Sun Mar 28 21:49:26 2010 -0400
+++ b/plugins/admin/PageEditor.php Sun Mar 28 23:10:46 2010 -0400
@@ -15,162 +15,162 @@
function page_Admin_PageEditor()
{
- global $db, $session, $paths, $template, $plugins; // Common objects
- global $lang;
- if ( $session->auth_level < USER_LEVEL_ADMIN || $session->user_level < USER_LEVEL_ADMIN )
- {
- $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;
- }
-
- echo '' . $lang->get('acped_heading_main') . '
';
- $show_select = true;
-
- if ( isset($_REQUEST['action']) || isset($_REQUEST['source']) )
- {
- if ( isset($_REQUEST['action']) )
- {
- $act =& $_REQUEST['action'];
- $act = strtolower($act);
- }
- else if ( isset($_REQUEST['source']) && $_REQUEST['source'] == 'ajax' )
- {
- $act = 'select';
- }
- switch ( $act )
- {
- case 'save':
- case 'select':
- // First step is to determine the page ID and namespace
-
- if ( isset($_REQUEST['pid_search']) )
- {
- list($page_id, $namespace) = RenderMan::strToPageID($_REQUEST['page_id']);
- $name = $db->escape(dirtify_page_id($page_id));
- $page_id = $db->escape(sanitize_page_id($page_id));
- $namespace = $db->escape($namespace);
- $name = strtolower($name);
- $page_id = strtolower($page_id);
- $sql = "SELECT * FROM " . table_prefix . "pages WHERE ( " . ENANO_SQLFUNC_LOWERCASE . "(urlname) LIKE '%$page_id%' OR " . ENANO_SQLFUNC_LOWERCASE . "(name) LIKE '%$name%' ) ORDER BY name ASC;";
- }
- else
- {
- // pid_search was not set, assume absolute page ID
- list($page_id, $namespace) = RenderMan::strToPageID($_REQUEST['page_id']);
- $page_id = $db->escape(sanitize_page_id($page_id));
- $namespace = $db->escape($namespace);
-
- $sql = "SELECT * FROM " . table_prefix . "pages WHERE urlname = '$page_id' AND namespace = '$namespace';";
- }
-
- if ( !($q = $db->sql_query($sql)) )
- {
- $db->_die('PageManager selecting dataset for page');
- }
-
- if ( $db->numrows() < 1 )
- {
- echo '
- ' . $lang->get('acped_err_page_not_found') . '
-
';
- break;
- }
-
- if ( $db->numrows() > 1 )
- {
- // Ambiguous results
- if ( isset($_REQUEST['pid_search']) )
- {
- echo '' . $lang->get('acped_msg_results_ambiguous_title') . '
';
- echo '' . $lang->get('acped_msg_results_ambiguous_body') . '
';
- echo '';
- while ( $row = $db->fetchrow($q) )
- {
- echo '- ';
- $pathskey = $paths->nslist[$row['namespace']] . $row['urlname'];
- $edit_url = makeUrlNS($row['namespace'], $row['urlname']) . '#do:edit';
- $view_url = makeUrlNS($row['namespace'], $row['urlname']);
- $page_name = htmlspecialchars(get_page_title_ns( $row['urlname'], $row['namespace'] ));
- $view_link = $lang->get('acped_ambig_btn_viewpage');
- echo "$page_name ($view_link)";
- echo '
';
- }
- echo '
';
- $show_select = false;
- break;
- }
- else
- {
- echo '' . $lang->get('acped_err_ambig_absolute') . '
';
- break;
- }
- }
-
- // From this point on we can assume that exactly one matching page was found.
- $dataset = $db->fetchrow();
- $page_id = $dataset['urlname'];
- $namespace = $dataset['namespace'];
- $url = makeUrlNS($namespace, $page_id, false, true) . '#do:edit';
- $url = addslashes($url);
- echo '';
-
- $show_select = false;
- break;
- }
- }
-
- if ( $show_select )
- {
- echo '' . $lang->get('acped_hint') . '
';
-
- // Show the search form
-
- $form_action = makeUrlNS('Special', 'Administration', "module={$paths->nslist['Admin']}PageEditor", true);
- echo "";
-
- // Grab all pages from the database and show a list of pages on the site
-
- echo '' . $lang->get('acped_heading_select_page_from_list') . '
';
- echo '' . $lang->get('acped_hint_select_page_from_list') . '
';
-
- $q = $db->sql_query('SELECT COUNT(name) AS num_pages FROM ' . table_prefix . 'pages;');
- if ( !$q )
- $db->_die('PageManager doing initial page count');
- list($num_pages) = $db->fetchrow_num();
- $db->free_result();
-
- $pg_start = ( isset($_GET['offset']) ) ? intval($_GET['offset']) : 0;
-
- $q = $db->sql_query('SELECT urlname, name, namespace, ' . $num_pages . ' AS num_pages, ' . $pg_start . ' AS offset, \'edit\' AS mode FROM ' . table_prefix . 'pages ORDER BY name ASC;');
- if ( !$q )
- $db->_die('PageManager doing main select query for page list');
-
- // Paginate results
- $html = paginate(
- $q,
- '{urlname}',
- $num_pages,
- makeUrlNS('Special', 'Administration', "module={$paths->nslist['Admin']}PageEditor&offset=%s", false),
- $pg_start,
- 99,
- array('urlname' => 'admin_pagemanager_format_listing'),
- ''
- );
- echo $html;
- }
-
+ global $db, $session, $paths, $template, $plugins; // Common objects
+ global $lang;
+ if ( $session->auth_level < USER_LEVEL_ADMIN || $session->user_level < USER_LEVEL_ADMIN )
+ {
+ $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;
+ }
+
+ echo '' . $lang->get('acped_heading_main') . '
';
+ $show_select = true;
+
+ if ( isset($_REQUEST['action']) || isset($_REQUEST['source']) )
+ {
+ if ( isset($_REQUEST['action']) )
+ {
+ $act =& $_REQUEST['action'];
+ $act = strtolower($act);
+ }
+ else if ( isset($_REQUEST['source']) && $_REQUEST['source'] == 'ajax' )
+ {
+ $act = 'select';
+ }
+ switch ( $act )
+ {
+ case 'save':
+ case 'select':
+ // First step is to determine the page ID and namespace
+
+ if ( isset($_REQUEST['pid_search']) )
+ {
+ list($page_id, $namespace) = RenderMan::strToPageID($_REQUEST['page_id']);
+ $name = $db->escape(dirtify_page_id($page_id));
+ $page_id = $db->escape(sanitize_page_id($page_id));
+ $namespace = $db->escape($namespace);
+ $name = strtolower($name);
+ $page_id = strtolower($page_id);
+ $sql = "SELECT * FROM " . table_prefix . "pages WHERE ( " . ENANO_SQLFUNC_LOWERCASE . "(urlname) LIKE '%$page_id%' OR " . ENANO_SQLFUNC_LOWERCASE . "(name) LIKE '%$name%' ) ORDER BY name ASC;";
+ }
+ else
+ {
+ // pid_search was not set, assume absolute page ID
+ list($page_id, $namespace) = RenderMan::strToPageID($_REQUEST['page_id']);
+ $page_id = $db->escape(sanitize_page_id($page_id));
+ $namespace = $db->escape($namespace);
+
+ $sql = "SELECT * FROM " . table_prefix . "pages WHERE urlname = '$page_id' AND namespace = '$namespace';";
+ }
+
+ if ( !($q = $db->sql_query($sql)) )
+ {
+ $db->_die('PageManager selecting dataset for page');
+ }
+
+ if ( $db->numrows() < 1 )
+ {
+ echo '
+ ' . $lang->get('acped_err_page_not_found') . '
+
';
+ break;
+ }
+
+ if ( $db->numrows() > 1 )
+ {
+ // Ambiguous results
+ if ( isset($_REQUEST['pid_search']) )
+ {
+ echo '' . $lang->get('acped_msg_results_ambiguous_title') . '
';
+ echo '' . $lang->get('acped_msg_results_ambiguous_body') . '
';
+ echo '';
+ while ( $row = $db->fetchrow($q) )
+ {
+ echo '- ';
+ $pathskey = $paths->nslist[$row['namespace']] . $row['urlname'];
+ $edit_url = makeUrlNS($row['namespace'], $row['urlname']) . '#do:edit';
+ $view_url = makeUrlNS($row['namespace'], $row['urlname']);
+ $page_name = htmlspecialchars(get_page_title_ns( $row['urlname'], $row['namespace'] ));
+ $view_link = $lang->get('acped_ambig_btn_viewpage');
+ echo "$page_name ($view_link)";
+ echo '
';
+ }
+ echo '
';
+ $show_select = false;
+ break;
+ }
+ else
+ {
+ echo '' . $lang->get('acped_err_ambig_absolute') . '
';
+ break;
+ }
+ }
+
+ // From this point on we can assume that exactly one matching page was found.
+ $dataset = $db->fetchrow();
+ $page_id = $dataset['urlname'];
+ $namespace = $dataset['namespace'];
+ $url = makeUrlNS($namespace, $page_id, false, true) . '#do:edit';
+ $url = addslashes($url);
+ echo '';
+
+ $show_select = false;
+ break;
+ }
+ }
+
+ if ( $show_select )
+ {
+ echo '' . $lang->get('acped_hint') . '
';
+
+ // Show the search form
+
+ $form_action = makeUrlNS('Special', 'Administration', "module={$paths->nslist['Admin']}PageEditor", true);
+ echo "";
+
+ // Grab all pages from the database and show a list of pages on the site
+
+ echo '' . $lang->get('acped_heading_select_page_from_list') . '
';
+ echo '' . $lang->get('acped_hint_select_page_from_list') . '
';
+
+ $q = $db->sql_query('SELECT COUNT(name) AS num_pages FROM ' . table_prefix . 'pages;');
+ if ( !$q )
+ $db->_die('PageManager doing initial page count');
+ list($num_pages) = $db->fetchrow_num();
+ $db->free_result();
+
+ $pg_start = ( isset($_GET['offset']) ) ? intval($_GET['offset']) : 0;
+
+ $q = $db->sql_query('SELECT urlname, name, namespace, ' . $num_pages . ' AS num_pages, ' . $pg_start . ' AS offset, \'edit\' AS mode FROM ' . table_prefix . 'pages ORDER BY name ASC;');
+ if ( !$q )
+ $db->_die('PageManager doing main select query for page list');
+
+ // Paginate results
+ $html = paginate(
+ $q,
+ '{urlname}',
+ $num_pages,
+ makeUrlNS('Special', 'Administration', "module={$paths->nslist['Admin']}PageEditor&offset=%s", false),
+ $pg_start,
+ 99,
+ array('urlname' => 'admin_pagemanager_format_listing'),
+ ''
+ );
+ echo $html;
+ }
+
}
?>