Extension:Protected pages

Protected pages is a Special page that shows - yes, you guessed it right ;) - list of protected pages. Page was requested by Filip Maljković aka Dungodung, so he gets the credit for comming up with the idea.

The files
This extension is a Query Page / Special page extension, so it has to have two files (if anyone knows a better way to do this, I'm open for suggestions):

Protectedpages.php
This file registers the special page with Mediawiki; it goes into the extensions folder, and is what gets included in LocalSettings.php (that is, you have to put  in LocalSettings.php) &lt;?php require_once( "SpecialPage.php" );

$wgExtensionFunctions[] = "wfProtectedpagesSetup"; $wgExtensionCredits['other'][] = array(       'name' => 'ProtectedPages',        'description' => 'displays protected pages',        'author' => 'Branislav Jovanovic, acting on the request by Filip Maljkovic' );

function wfProtectedpagesSetup { SpecialPage::addPage( new SpecialPage("Protectedpages") ); global $wgMessageCache;

$wgMessageCache-&gt;addMessages(       array('protectedpages' =&gt; 'Protected pages')    ); } ?&gt;

SpecialProtectedpages.php
This is the actual code of special page. I wanted to put it all in one file, but apparently when you add a page via  method, you have to have a SpecialPAGENAME.php file :( thus two files. This one goes into te includes (or any other directory in include_path).

&lt;?php if (!defined('MEDIAWIKI')) die; /** * Display list of protected pages * * @package MediaWiki * @subpackage Extensions * * * @author Branislav Jovanović &lt;branej@gmail.com&gt; * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later * */ require_once( "QueryPage.php" );

class SpecialProtectedPages extends PageQueryPage { var $Namespace = null; var $Invert = false;

function isExpensive { return true; } function isSyndicated { return false; } function linkParameters { return array('namespace' =&gt; $this-&gt;Namespace,                    'invert'    =&gt; $this-&gt;Invert); }

function getPageHeader { global $wgContLang, $wgScript; $t = Title::makeTitle( NS_SPECIAL, 'Protectedpages' );

$namespaceselect = HTMLnamespaceselector($this-&gt;Namespace, ''); $submitbutton = '&lt;input type="submit" value="' . wfMsgHtml( 'allpagessubmit' ) . '" /&gt;'; $invertbox = "&lt;input type='checkbox' name='invert' value='1' id='nsinvert'". ( $this-&gt;Invert ? ' checked="checked"' : '' ). ' /&gt;';

$out = "&lt;div class='namespacesettings'&gt;&lt;form method='get' action='{$wgScript}'&gt;\n"; $out .= '&lt;input type="hidden" name="title" value="'.$t-&gt;getPrefixedText.'" /&gt;'; $out .= "   &lt;div id='nsselect' class='recentchanges'&gt;        &lt;label for='namespace'&gt;". wfMsgHtml('namespace'). "&lt;/label&gt;       $namespaceselect $submitbutton $invertbox &lt;label for='nsinvert'&gt;". wfMsgHtml('invert'). "&lt;/label&gt;   &lt;/div&gt;"; $out .= '&lt;/form&gt;&lt;/div&gt;'; return $out; }   function getName { return "Protectedpages"; } function getSQL { global $wgRequest; $this-&gt;Namespace = $wgRequest-&gt;getIntOrNull('namespace'); if ($this-&gt;Namespace === null) { $namespace = 'page_namespace'; } else { $namespace = $this-&gt;Namespace; }       $this-&gt;Invert = $wgRequest-&gt;getBool('invert'); $dbr =& wfGetDB( DB_SLAVE ); $page = $dbr-&gt;tableName( "page" ); $sql = "SELECT 'ProtectedPages' as type, $namespace as namespace, page_title as title,". "page_title as value FROM $page WHERE ". "page_restrictions NOT LIKE '' AND page_restrictions NOT LIKE 'move=:edit=' "; if ($this-&gt;Namespace !== null) { if ($this-&gt;Invert) { $sql .= "AND page_namespace != ". $this-&gt;Namespace. " ";           } else { $sql .= "AND page_namespace = ". $this-&gt;Namespace. " ";           }        }        return $sql; } } function wfSpecialProtectedpages { list( $limit, $offset ) = wfCheckLimits; $app = new SpecialProtectedPages; $app-&gt;doQuery( $offset, $limit ); } ?&gt;

Comments are welcome.