Made most special pages "visible"; fixup for non-existent special page redirect in paths.php; rewrote Special:AllPages to have pagination (WiP, Special:SpecialPages is possibly next, depending on whether paginate_array works or not)
--- a/includes/paths.php Tue Sep 04 12:52:23 2007 -0400
+++ b/includes/paths.php Thu Sep 06 23:03:51 2007 -0400
@@ -347,10 +347,20 @@
{
$this->cpage['protected'] = 1;
}
- if($this->namespace=='Special')
+ if($this->namespace == 'Special')
{
// Can't load nonexistent pages
- $this->main_page();
+ if( is_string(getConfig('main_page')) )
+ {
+ $main_page = makeUrl(getConfig('main_page'));
+ }
+ else
+ {
+ $main_page = makeUrl($this->pages[0]['urlname']);
+ }
+ $sp_link = '<a href="' . makeUrlNS('Special', 'SpecialPages') . '">here</a>';
+ redirect($main_page, 'Can\'t load special page', 'The special page you requested could not be found. This may be due to a plugin failing to load. A list of all special pages on this website can be viewed '.$sp_link.'. You will be redirected to the main page in 15 seconds.', 14);
+ exit;
}
// Allow the user to create/modify his user page uncondtionally (admins can still protect the page)
if($this->page == $this->nslist['User'].str_replace(' ', '_', $session->username))
--- a/index.php Tue Sep 04 12:52:23 2007 -0400
+++ b/index.php Thu Sep 06 23:03:51 2007 -0400
@@ -263,7 +263,7 @@
?>
<form action="<?php echo makeUrl($paths->page, 'do=flushlogs'); ?>" method="post">
<h3>You are about to <span style="color: red;">destroy</span> all logged edits and actions on this page.</h3>
- <p>Unlike deleting or editing this page, this action is <u>not reversible</u>! You should only do this if you are desperate for
+ <p>Unlike deleting or editing this page, this action is <u>not reversible</u>! You should only do this if you are desparate for
database space.</p>
<p>Do you really want to continue?</p>
<p><input type="submit" name="_downthejohn" value="Flush logs" style="color: red; font-weight: bold;" /></p>
--- a/plugins/SpecialAdmin.php Tue Sep 04 12:52:23 2007 -0400
+++ b/plugins/SpecialAdmin.php Thu Sep 06 23:03:51 2007 -0400
@@ -28,14 +28,14 @@
\'name\'=>\'Administration\',
\'urlname\'=>\'Administration\',
\'namespace\'=>\'Special\',
- \'special\'=>0,\'visible\'=>0,\'comments_on\'=>0,\'protected\'=>1,\'delvotes\'=>0,\'delvote_ips\'=>\'\',
+ \'special\'=>0,\'visible\'=>1,\'comments_on\'=>0,\'protected\'=>1,\'delvotes\'=>0,\'delvote_ips\'=>\'\',
));
$paths->add_page(Array(
\'name\'=>\'Manage the Sidebar\',
\'urlname\'=>\'EditSidebar\',
\'namespace\'=>\'Special\',
- \'special\'=>0,\'visible\'=>0,\'comments_on\'=>0,\'protected\'=>1,\'delvotes\'=>0,\'delvote_ips\'=>\'\',
+ \'special\'=>0,\'visible\'=>1,\'comments_on\'=>0,\'protected\'=>1,\'delvotes\'=>0,\'delvote_ips\'=>\'\',
));
');
--- a/plugins/SpecialGroups.php Tue Sep 04 12:52:23 2007 -0400
+++ b/plugins/SpecialGroups.php Thu Sep 06 23:03:51 2007 -0400
@@ -26,7 +26,7 @@
\'name\'=>\'Group Membership\',
\'urlname\'=>\'Usergroups\',
\'namespace\'=>\'Special\',
- \'special\'=>0,\'visible\'=>0,\'comments_on\'=>0,\'protected\'=>1,\'delvotes\'=>0,\'delvote_ips\'=>\'\',
+ \'special\'=>0,\'visible\'=>1,\'comments_on\'=>0,\'protected\'=>1,\'delvotes\'=>0,\'delvote_ips\'=>\'\',
));
');
--- a/plugins/SpecialPageFuncs.php Tue Sep 04 12:52:23 2007 -0400
+++ b/plugins/SpecialPageFuncs.php Thu Sep 06 23:03:51 2007 -0400
@@ -200,47 +200,86 @@
$template->footer();
}
+function PagelistingFormatter($id, $row)
+{
+ global $db, $session, $paths, $template, $plugins; // Common objects
+ static $rowtracker = 0;
+ static $tdclass = 'row2';
+ static $per_row = 2;
+ $return = '';
+ if ( $crap === false && $row === false )
+ {
+ $rowtracker = 0;
+ return false;
+ }
+ $rowtracker++;
+ if ( $rowtracker == $per_row )
+ {
+ $rowtracker = 0;
+ $tdclass = ( $tdclass == 'row2' ) ? 'row1' : 'row2';
+ }
+
+ preg_match('/^ns=(' . implode('|', array_keys($paths->nslist)) . ');pid=(.*?)$/i', $id, $match);
+ $namespace =& $match[1];
+ $page_id =& $match[2];
+ $page_id = sanitize_page_id($page_id);
+
+ $url = makeUrlNS($namespace, $page_id);
+ $url = htmlspecialchars($url);
+
+ $link = '<a href="' . $url . '">' . htmlspecialchars($row['name']) . '</a>';
+ $td = '<td class="' . $tdclass . '" style="width: 50%;">' . $link . '</td>';
+
+ $return .= $td;
+
+ if ( $rowtracker == ($per_row - 1) )
+ $return .= "</tr>\n<tr>";
+
+ return $return;
+}
+
function page_Special_AllPages()
{
// This should be an easy one
global $db, $session, $paths, $template, $plugins; // Common objects
$template->header();
$sz = sizeof( $paths->pages ) / 2;
- echo '<p>Below is a list of all of the pages on this website.</p><div class="tblholder"><table border="0" width="100%" cellspacing="1" cellpadding="4">';
- $cclass = 'row1';
- for ( $i = 0; $i < $sz; $i = $i )
- {
- if ( $cclass == 'row1')
- {
- $cclass='row3';
- }
- else if ( $cclass == 'row3')
- {
- $cclass='row1';
- }
- echo '<tr>';
- for ( $j = 0; $j < 2; $j = $j )
- {
- if ( $i < $sz && $paths->pages[$i]['namespace'] != 'Special' && $paths->pages[$i]['namespace'] != 'Admin' && $paths->pages[$i]['visible'] == 1)
- {
- echo '<td style="width: 50%" class="'.$cclass.'"><a href="'.makeUrl($paths->pages[$i]['urlname']).'">';
- if ( $paths->pages[$i]['namespace'] != 'Article' )
- {
- echo '('.$paths->pages[$i]['namespace'].') ';
- }
- echo $paths->pages[$i]['name'].'</a></td>';
- $j++;
- }
- else if ( $i >= $sz )
- {
- echo '<td style="width: 50%" class="row2"></td>';
- $j++;
- }
- $i++;
- }
- echo '</tr>';
- }
- echo '</table></div>';
+ echo '<p>Below is a list of all of the pages on this website.</p>';
+
+ $q = $db->sql_query('SELECT COUNT(urlname) FROM '.table_prefix.'pages WHERE visible!=0;');
+ if ( !$q )
+ $db->_die();
+ $row = $db->fetchrow_num();
+ $count = $row[0];
+ $db->free_result();
+
+ $q = $db->sql_unbuffered_query('SELECT CONCAT("ns=",namespace,";pid=",urlname) AS identifier, name FROM '.table_prefix.'pages WHERE visible!=0 ORDER BY name ASC;');
+ if ( !$q )
+ $db->_die();
+
+ $offset = ( isset($_GET['offset']) ) ? intval($_GET['offset']) : 0;
+
+ // reset formatter
+ PagelistingFormatter(false, false);
+
+ $result = paginate(
+ $q, // result resource
+ '{identifier}', // formatting template
+ $count, // # of results
+ makeUrlNS('Special', 'AllPages', 'offset=%s'), // result URL
+ $offset, // start offset
+ 40, // results per page
+ array( 'identifier' => 'PagelistingFormatter' ), // hooks
+ '<div class="tblholder">
+ <table border="0" cellspacing="1" cellpadding="4">
+ <tr>', // print at start
+ ' </tr>
+ </table>
+ </div>' // print at end
+ );
+
+ echo $result;
+
$template->footer();
}
--- a/plugins/SpecialSearch.php Tue Sep 04 12:52:23 2007 -0400
+++ b/plugins/SpecialSearch.php Thu Sep 06 23:03:51 2007 -0400
@@ -26,7 +26,7 @@
\'name\'=>\'Rebuild search index\',
\'urlname\'=>\'SearchRebuild\',
\'namespace\'=>\'Special\',
- \'special\'=>0,\'visible\'=>0,\'comments_on\'=>0,\'protected\'=>1,\'delvotes\'=>0,\'delvote_ips\'=>\'\',
+ \'special\'=>0,\'visible\'=>1,\'comments_on\'=>0,\'protected\'=>1,\'delvotes\'=>0,\'delvote_ips\'=>\'\',
));
$paths->add_page(Array(
--- a/plugins/SpecialUpdownload.php Tue Sep 04 12:52:23 2007 -0400
+++ b/plugins/SpecialUpdownload.php Thu Sep 06 23:03:51 2007 -0400
@@ -36,7 +36,7 @@
\'name\'=>\'Download file\',
\'urlname\'=>\'DownloadFile\',
\'namespace\'=>\'Special\',
- \'special\'=>0,\'visible\'=>0,\'comments_on\'=>0,\'protected\'=>1,\'delvotes\'=>0,\'delvote_ips\'=>\'\',
+ \'special\'=>0,\'visible\'=>1,\'comments_on\'=>0,\'protected\'=>1,\'delvotes\'=>0,\'delvote_ips\'=>\'\',
));
');
--- a/plugins/SpecialUserFuncs.php Tue Sep 04 12:52:23 2007 -0400
+++ b/plugins/SpecialUserFuncs.php Thu Sep 06 23:03:51 2007 -0400
@@ -67,14 +67,14 @@
\'name\'=>\'Activate user account\',
\'urlname\'=>\'ActivateAccount\',
\'namespace\'=>\'Special\',
- \'special\'=>0,\'visible\'=>0,\'comments_on\'=>0,\'protected\'=>1,\'delvotes\'=>0,\'delvote_ips\'=>\'\',
+ \'special\'=>0,\'visible\'=>1,\'comments_on\'=>0,\'protected\'=>1,\'delvotes\'=>0,\'delvote_ips\'=>\'\',
));
$paths->add_page(Array(
\'name\'=>\'Captcha\',
\'urlname\'=>\'Captcha\',
\'namespace\'=>\'Special\',
- \'special\'=>0,\'visible\'=>0,\'comments_on\'=>0,\'protected\'=>1,\'delvotes\'=>0,\'delvote_ips\'=>\'\',
+ \'special\'=>0,\'visible\'=>1,\'comments_on\'=>0,\'protected\'=>1,\'delvotes\'=>0,\'delvote_ips\'=>\'\',
));
$paths->add_page(Array(
@@ -828,9 +828,9 @@
{
global $db, $session, $paths, $template, $plugins; // Common objects
$user = $paths->getParam(0);
- if(!$user) die_friendly('Account activation error', '<p>The URL was incorrect.</p>');
+ if(!$user) die_friendly('Account activation error', '<p>This page can only be accessed using links sent to users via e-mail.</p>');
$key = $paths->getParam(1);
- if(!$key) die_friendly('Account activation error', '<p>The URL was incorrect.</p>');
+ if(!$key) die_friendly('Account activation error', '<p>This page can only be accessed using links sent to users via e-mail.</p>');
$s = $session->activate_account(str_replace('_', ' ', $user), $key);
if($s > 0) die_friendly('Activation successful', '<p>Your account is now active. Thank you for registering.</p>');
else die_friendly('Activation failed', '<p>The activation key was probably incorrect.</p>');