http://www.mediawiki.org/wiki/Special:Code/MediaWiki/73338

Revision: 73338
Author:   thomasv
Date:     2010-09-19 19:08:38 +0000 (Sun, 19 Sep 2010)

Log Message:
-----------
special page to list texts without scans

Modified Paths:
--------------
    trunk/extensions/ProofreadPage/ProofreadPage.i18n.php
    trunk/extensions/ProofreadPage/ProofreadPage.php

Added Paths:
-----------
    trunk/extensions/ProofreadPage/SpecialNakedPages.php

Modified: trunk/extensions/ProofreadPage/ProofreadPage.i18n.php
===================================================================
--- trunk/extensions/ProofreadPage/ProofreadPage.i18n.php       2010-09-19 
17:42:15 UTC (rev 73337)
+++ trunk/extensions/ProofreadPage/ProofreadPage.i18n.php       2010-09-19 
19:08:38 UTC (rev 73338)
@@ -10,6 +10,7 @@
 
 $messages['en'] = array(
        'indexpages'                      => 'List of index pages',
+       'nakedpages'                      => 'Naked pages',
        'proofreadpage_desc'              => 'Allow easy comparison of text to 
the original scan',
        'proofreadpage_namespace'         => 'Page',
        'proofreadpage_index_namespace'   => 'Index',

Modified: trunk/extensions/ProofreadPage/ProofreadPage.php
===================================================================
--- trunk/extensions/ProofreadPage/ProofreadPage.php    2010-09-19 17:42:15 UTC 
(rev 73337)
+++ trunk/extensions/ProofreadPage/ProofreadPage.php    2010-09-19 19:08:38 UTC 
(rev 73338)
@@ -43,6 +43,11 @@
 $wgSpecialPages['IndexPages'] = 'ProofreadPages';
 $wgSpecialPageGroups['IndexPages'] = 'pages';
 
+# special page
+$wgAutoloadClasses['NakedPages'] = dirname( __FILE__ ) . 
'/SpecialNakedPages.php';
+$wgSpecialPages['NakedPages'] = 'NakedPages';
+$wgSpecialPageGroups['NakedPages'] = 'maintenance';
+
 # Bump the version number every time you change proofread.js
 $wgProofreadPageVersion = 27;
 

Added: trunk/extensions/ProofreadPage/SpecialNakedPages.php
===================================================================
--- trunk/extensions/ProofreadPage/SpecialNakedPages.php                        
        (rev 0)
+++ trunk/extensions/ProofreadPage/SpecialNakedPages.php        2010-09-19 
19:08:38 UTC (rev 73338)
@@ -0,0 +1,110 @@
+<?php
+/**
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+  /*
+   * Special page that lists the texts that have no transclusions
+   * Pages in MediaWiki:Proofreadpage_notnaked_category are excluded.
+   * 
+   */
+
+class NakedPages extends SpecialPage {
+
+       function __construct() {
+               parent::__construct( 'NakedPages' );
+       }
+
+       function execute( $parameters ) {
+               global $wgOut, $wgRequest, $wgDisableTextSearch;
+               $this->setHeaders();
+               list( $limit, $offset ) = wfCheckLimits();
+               $cnl = new NakedPagesQuery( );
+               $cnl->doQuery( $offset, $limit );
+       }
+}
+
+
+class NakedPagesQuery extends QueryPage {
+
+       function __construct( ) {
+               wfLoadExtensionMessages( 'ProofreadPage' );
+               $this->page_namespace = preg_quote( wfMsgForContent( 
'proofreadpage_namespace' ), '/' );
+               $this->cat = wfMsgForContent( 'proofreadpage_notnaked_category' 
);
+       }
+
+       function getName() {
+               return 'NakedPages';
+       }
+
+       function isExpensive() {
+               return true;
+       }
+
+       function isSyndicated() {
+               return false;
+       }
+
+       function getSQL() {
+               global $wgContentNamespaces;
+
+               $dbr = wfGetDB( DB_SLAVE );
+               $page = $dbr->tableName( 'page' );
+               $templatelinks = $dbr->tableName( 'templatelinks' );
+               $categorylinks = $dbr->tableName( 'categorylinks' );
+               $forceindex = $dbr->useIndexClause("page_len");
+               $page_ns_index = MWNamespace::getCanonicalIndex( strtolower( 
$this->page_namespace ) );
+               $cat = $dbr->strencode( str_replace( ' ' , '_' , $this->cat ) );
+               $clause = "page_namespace=" . NS_MAIN . " AND 
page_is_redirect=0 AND page_id NOT IN ( SELECT DISTINCT tl_from FROM 
$templatelinks LEFT JOIN $page ON page_id=tl_from WHERE 
tl_namespace=$page_ns_index AND page_namespace=" . NS_MAIN . " ) AND page_id 
NOT IN ( SELECT DISTINCT cl_from FROM $categorylinks WHERE cl_to='$cat' )";
+
+               return
+                       "SELECT page_namespace as namespace,
+                               page_title as title,
+                               page_len AS value
+                       FROM $page $forceindex
+                       WHERE $clause";
+       }
+
+       function sortDescending() {
+               return true;
+       }
+
+       function formatResult( $skin, $result ) {
+               global $wgLang, $wgContLang;
+               $dm = $wgContLang->getDirMark();
+
+               $title = Title::makeTitleSafe( $result->namespace, 
$result->title );
+               if ( !$title ) {
+                       return '<!-- Invalid title ' .  htmlspecialchars( 
"{$result->namespace}:{$result->title}" ). '-->';
+               }
+               $hlink = $skin->linkKnown(
+                       $title,
+                       wfMsgHtml( 'hist' ),
+                       array(),
+                       array( 'action' => 'history' )
+               );
+               $plink = $this->isCached()
+                                       ? $skin->link( $title )
+                                       : $skin->linkKnown( $title );
+               $size = wfMsgExt( 'nbytes', array( 'parsemag', 'escape' ), 
$wgLang->formatNum( htmlspecialchars( $result->value ) ) );
+
+               return $title->exists()
+                               ? "({$hlink}) {$dm}{$plink} {$dm}[{$size}]"
+                               : "<s>({$hlink}) {$dm}{$plink} 
{$dm}[{$size}]</s>";
+       }
+}
+



_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to