r23377 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r23376‎ | r23377 | r23378 >
Date:09:43, 25 June 2007
Author:robchurch
Status:old
Tags:
Comment:
Port Special:LonelyPages. Renamed to OrphanedPages, keeping old aliases.
Modified paths:
  • /branches/robchurch/reports/includes/AutoLoader.php (modified) (history)
  • /branches/robchurch/reports/includes/SpecialLonelypages.php (deleted) (history)
  • /branches/robchurch/reports/includes/SpecialPage.php (modified) (history)
  • /branches/robchurch/reports/includes/reports/OrphanedPagesReport.php (added) (history)
  • /branches/robchurch/reports/includes/reports/Report.php (modified) (history)
  • /branches/robchurch/reports/languages/messages/MessagesEn.php (modified) (history)
  • /branches/robchurch/reports/maintenance/language/messageTypes.inc (modified) (history)
  • /branches/robchurch/reports/maintenance/language/messages.inc (modified) (history)

Diff [purge]

Index: branches/robchurch/reports/maintenance/language/messages.inc
@@ -957,9 +957,8 @@
958958 'nviews',
959959 'nchanges',
960960 'specialpage-empty',
961 - 'lonelypages',
962 - 'lonelypages-summary',
963 - 'lonelypagestext',
 961+ 'orphanedpages',
 962+ 'orphanedpages-header',
964963 'unusedcategories',
965964 'unusedimages',
966965 'popularpages',
Index: branches/robchurch/reports/maintenance/language/messageTypes.inc
@@ -131,7 +131,6 @@
132132 'userrights-summary',
133133 'protectedpages-summary',
134134 'disambiguations-summary',
135 - 'lonelypages-summary',
136135 'unusedtemplates-summary',
137136 'fewestrevisions-summary',
138137 'variantname-zh-cn',
Index: branches/robchurch/reports/includes/SpecialLonelypages.php
@@ -1,60 +0,0 @@
2 -<?php
3 -/**
4 - *
5 - * @addtogroup SpecialPage
6 - */
7 -
8 -/**
9 - * A special page looking for articles with no article linking to them,
10 - * thus being lonely.
11 - * @addtogroup SpecialPage
12 - */
13 -class LonelyPagesPage extends PageQueryPage {
14 -
15 - function getName() {
16 - return "Lonelypages";
17 - }
18 - function getPageHeader() {
19 - return wfMsgExt( 'lonelypagestext', array( 'parse' ) );
20 - }
21 -
22 - function sortDescending() {
23 - return false;
24 - }
25 -
26 - function isExpensive() {
27 - return true;
28 - }
29 - function isSyndicated() { return false; }
30 -
31 - function getSQL() {
32 - $dbr = wfGetDB( DB_SLAVE );
33 - list( $page, $pagelinks ) = $dbr->tableNamesN( 'page', 'pagelinks' );
34 -
35 - return
36 - "SELECT 'Lonelypages' AS type,
37 - page_namespace AS namespace,
38 - page_title AS title,
39 - page_title AS value
40 - FROM $page
41 - LEFT JOIN $pagelinks
42 - ON page_namespace=pl_namespace AND page_title=pl_title
43 - WHERE pl_namespace IS NULL
44 - AND page_namespace=".NS_MAIN."
45 - AND page_is_redirect=0";
46 -
47 - }
48 -}
49 -
50 -/**
51 - * Constructor
52 - */
53 -function wfSpecialLonelypages() {
54 - list( $limit, $offset ) = wfCheckLimits();
55 -
56 - $lpp = new LonelyPagesPage();
57 -
58 - return $lpp->doQuery( $offset, $limit );
59 -}
60 -
61 -?>
Index: branches/robchurch/reports/includes/reports/Report.php
@@ -381,6 +381,7 @@
382382 'DeadEndPagesReport',
383383 'DoubleRedirectsReport',
384384 'LongPagesReport',
 385+ 'OrphanedPagesReport',
385386 'PopularPagesReport',
386387 'RedirectReport',
387388 'ShortPagesReport',
Index: branches/robchurch/reports/includes/reports/OrphanedPagesReport.php
@@ -0,0 +1,95 @@
 2+<?php
 3+
 4+/**
 5+ * Report generates a list of pages with no incoming links
 6+ *
 7+ * @addtogroup Reports
 8+ * @author Rob Church <robchur@gmail.com>
 9+ */
 10+class OrphanedPagesReport extends Report {
 11+
 12+ /**
 13+ * Constructor
 14+ */
 15+ public function __construct() {
 16+ parent::__construct();
 17+ }
 18+
 19+ /**
 20+ * Get the name of the report
 21+ *
 22+ * @return string
 23+ */
 24+ public function getName() {
 25+ return 'Orphanedpages';
 26+ }
 27+
 28+ /**
 29+ * Is it appropriate to allow filtering redirects?
 30+ *
 31+ * @return bool
 32+ */
 33+ public function allowRedirectFilter() {
 34+ return true;
 35+ }
 36+
 37+ /**
 38+ * Get a list of namespaces this report can be run
 39+ * against - false indicates *all* namespaces
 40+ *
 41+ * @return mixed
 42+ */
 43+ public function getApplicableNamespaces() {
 44+ return false;
 45+ }
 46+
 47+ /**
 48+ * Return base SQL for the report
 49+ *
 50+ * @param Database $dbr Database object being queried
 51+ * @return string
 52+ */
 53+ public function getBaseSql( $dbr ) {
 54+ list( $page, $pagelinks ) = $dbr->tableNamesN( 'page', 'pagelinks' );
 55+ return
 56+ "SELECT
 57+ page_id AS rp_id,
 58+ page_namespace AS rp_namespace,
 59+ page_title AS rp_title,
 60+ page_is_redirect AS rp_redirect
 61+ FROM {$page}
 62+ LEFT JOIN {$pagelinks} ON
 63+ pl_namespace = page_namespace
 64+ AND pl_title = page_title";
 65+ }
 66+
 67+ /**
 68+ * Return additional WHERE clauses and other conditions
 69+ * to which the paging clauses will be appened when
 70+ * the report runs live
 71+ *
 72+ * @param Database $dbr Database object being queried
 73+ * @return array
 74+ */
 75+ public function getExtraConditions( $dbr ) {
 76+ return array(
 77+ 'pl_from IS NULL',
 78+ );
 79+ }
 80+
 81+ /**
 82+ * Format an individual result row
 83+ *
 84+ * @param Title $title Result title
 85+ * @param object $row Result row
 86+ * @param array $params Result parameters
 87+ * @param Skin $skin User skin
 88+ * @return string
 89+ */
 90+ public function formatRow( $title, $row, $params, $skin ) {
 91+ return "<li>" . $skin->makeLinkObj( $title ) . "</li>\n";
 92+ }
 93+
 94+}
 95+
 96+?>
\ No newline at end of file
Property changes on: branches/robchurch/reports/includes/reports/OrphanedPagesReport.php
___________________________________________________________________
Added: svn:eol-style
197 + native
Index: branches/robchurch/reports/includes/AutoLoader.php
@@ -181,7 +181,6 @@
182182 'DBLockForm' => 'includes/SpecialLockdb.php',
183183 'LogReader' => 'includes/SpecialLog.php',
184184 'LogViewer' => 'includes/SpecialLog.php',
185 - 'LonelyPagesPage' => 'includes/SpecialLonelypages.php',
186185 'MIMEsearchPage' => 'includes/SpecialMIMEsearch.php',
187186 'MostcategoriesPage' => 'includes/SpecialMostcategories.php',
188187 'MostimagesPage' => 'includes/SpecialMostimages.php',
@@ -285,6 +284,7 @@
286285 'DeadEndPagesReport' => 'includes/reports/DeadEndPagesReport.php',
287286 'DoubleRedirectsReport' => 'includes/reports/DoubleRedirectsReport.php',
288287 'LongPagesReport' => 'includes/reports/LongPagesReport.php',
 288+ 'OrphanedPagesReport' => 'includes/reports/OrphanedPagesReport.php',
289289 'PopularPagesReport' => 'includes/reports/PopularPagesReport.php',
290290 'RedirectReport' => 'includes/reports/RedirectReport.php',
291291 'ShortPagesReport' => 'includes/reports/ShortPagesReport.php',
Index: branches/robchurch/reports/includes/SpecialPage.php
@@ -90,7 +90,7 @@
9191 'Listusers' => array( 'SpecialPage', 'Listusers' ),
9292 'Statistics' => array( 'SpecialPage', 'Statistics' ),
9393 'Randompage' => array( 'SpecialPage', 'Randompage' ),
94 - 'Lonelypages' => array( 'SpecialPage', 'Lonelypages' ),
 94+ 'Orphanedpages' => 'OrphanedPagesReport',
9595 'Uncategorizedpages' => 'UncategorisedPagesReport',
9696 'Uncategorizedcategories' => array( 'SpecialRedirect', 'Uncategorizedpages', array( 'namespace' => NS_CATEGORY ) ),
9797 'Uncategorizedimages' => array( 'SpecialRedirect', 'Uncategorizedpages', array( 'namespace' => NS_IMAGE ) ),
Index: branches/robchurch/reports/languages/messages/MessagesEn.php
@@ -364,7 +364,7 @@
365365 'Listusers' => array( 'Listusers', 'Userlist' ),
366366 'Statistics' => array( 'Statistics' ),
367367 'Randompage' => array( 'Random', 'Randompage' ),
368 - 'Lonelypages' => array( 'Lonelypages', 'Orphanedpages' ),
 368+ 'Orphanedpages' => array( 'Orphanedpages', 'Lonelypages' ),
369369 'Uncategorizedpages' => array( 'Uncategorizedpages' ),
370370 'Uncategorizedcategories' => array( 'Uncategorizedcategories' ),
371371 'Uncategorizedimages' => array( 'Uncategorizedimages' ),
@@ -1566,9 +1566,8 @@
15671567 'nrevisions' => '$1 {{PLURAL:$1|revision|revisions}}',
15681568 'nviews' => '$1 {{PLURAL:$1|view|views}}',
15691569 'specialpage-empty' => 'There are no results for this report.',
1570 -'lonelypages' => 'Orphaned pages',
1571 -'lonelypages-summary' => '', # only translate this message to other languages if you have to change it
1572 -'lonelypagestext' => 'The following pages are not linked from other pages in this wiki.',
 1570+'orphanedpages' => 'Orphaned pages',
 1571+'orphanedpages-header' => 'This report lists pages which have no incoming links.',
15731572 'unusedcategories' => 'Unused categories',
15741573 'unusedimages' => 'Unused files',
15751574 'popularpages' => 'Popular pages',

Status & tagging log