# HG changeset patch # User Dan # Date 1189134231 14400 # Node ID 77c75179bb952702ceb0d2689e3bc78c4f8fdbd3 # Parent 261f367623afe92088118f38de20df0560bef1ba 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) diff -r 261f367623af -r 77c75179bb95 includes/paths.php --- 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 = 'here'; + 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)) diff -r 261f367623af -r 77c75179bb95 index.php --- 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 @@ ?>

You are about to destroy all logged edits and actions on this page.

-

Unlike deleting or editing this page, this action is not reversible! You should only do this if you are desperate for +

Unlike deleting or editing this page, this action is not reversible! You should only do this if you are desparate for database space.

Do you really want to continue?

diff -r 261f367623af -r 77c75179bb95 plugins/SpecialAdmin.php --- 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\'=>\'\', )); '); diff -r 261f367623af -r 77c75179bb95 plugins/SpecialGroups.php --- 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\'=>\'\', )); '); diff -r 261f367623af -r 77c75179bb95 plugins/SpecialPageFuncs.php --- 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 = '' . htmlspecialchars($row['name']) . ''; + $td = '' . $link . ''; + + $return .= $td; + + if ( $rowtracker == ($per_row - 1) ) + $return .= "\n"; + + 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 '

Below is a list of all of the pages on this website.

'; - $cclass = 'row1'; - for ( $i = 0; $i < $sz; $i = $i ) - { - if ( $cclass == 'row1') - { - $cclass='row3'; - } - else if ( $cclass == 'row3') - { - $cclass='row1'; - } - echo ''; - 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 ''; - $j++; - } - else if ( $i >= $sz ) - { - echo ''; - $j++; - } - $i++; - } - echo ''; - } - echo '
'; - if ( $paths->pages[$i]['namespace'] != 'Article' ) - { - echo '('.$paths->pages[$i]['namespace'].') '; - } - echo $paths->pages[$i]['name'].'
'; + echo '

Below is a list of all of the pages on this website.

'; + + $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 + '
+ + ', // print at start + ' +
+
' // print at end + ); + + echo $result; + $template->footer(); } diff -r 261f367623af -r 77c75179bb95 plugins/SpecialSearch.php --- 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( diff -r 261f367623af -r 77c75179bb95 plugins/SpecialUpdownload.php --- 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\'=>\'\', )); '); diff -r 261f367623af -r 77c75179bb95 plugins/SpecialUserFuncs.php --- 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', '

The URL was incorrect.

'); + if(!$user) die_friendly('Account activation error', '

This page can only be accessed using links sent to users via e-mail.

'); $key = $paths->getParam(1); - if(!$key) die_friendly('Account activation error', '

The URL was incorrect.

'); + if(!$key) die_friendly('Account activation error', '

This page can only be accessed using links sent to users via e-mail.

'); $s = $session->activate_account(str_replace('_', ' ', $user), $key); if($s > 0) die_friendly('Activation successful', '

Your account is now active. Thank you for registering.

'); else die_friendly('Activation failed', '

The activation key was probably incorrect.

');