-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathWatchAnalyticsPageTablePager.php
More file actions
99 lines (78 loc) · 2.51 KB
/
Copy pathWatchAnalyticsPageTablePager.php
File metadata and controls
99 lines (78 loc) · 2.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<?php
class WatchAnalyticsPageTablePager extends WatchAnalyticsTablePager {
protected $isSortable = [
'page_ns_and_title' => true,
'num_watches' => true,
'num_reviewed' => true,
'percent_pending' => true,
'max_pending_minutes' => true,
'avg_pending_minutes' => true,
'watch_quality' => true,
];
public function __construct( $page, $conds, $filters = [] ) {
global $wgRequest;
$this->watchQuery = new PageWatchesQuery();
parent::__construct( $page, $conds, $filters );
$sortField = $wgRequest->getVal( 'sort' );
$this->mQueryNamespace = $wgRequest->getVal( 'ns' );
if ( ! isset( $sortField ) ) {
$this->mDefaultDirection = false;
}
$this->mExtraSortFields = [ 'num_watches', 'num_reviewed', 'page_ns_and_title' ];
}
public function getQueryInfo() {
$namespaces = MWNamespace::getCanonicalNamespaces();
if ( $this->mQueryNamespace !== null
&& $this->mQueryNamespace >= 0
&& isset( $namespaces[ $this->mQueryNamespace ] ) ) {
$conds = [
'p.page_namespace = ' . $this->mQueryNamespace
];
} else {
$conds = [];
}
return $this->watchQuery->getQueryInfo( $conds );
}
public function formatValue( $fieldName, $value ) {
if ( $fieldName === 'page_ns_and_title' ) {
$pageInfo = explode( ':', $value, 2 );
$pageNsIndex = $pageInfo[0];
$pageTitleText = $pageInfo[1];
$title = Title::makeTitle( $pageNsIndex, $pageTitleText );
$titleURL = $title->getLinkURL();
$titleNsText = $title->getNsText();
if ( $titleNsText === '' ) {
$titleFullText = $title->getText();
} else {
$titleFullText = $titleNsText . ':' . $title->getText();
}
$pageLink = Xml::element(
'a',
[ 'href' => $titleURL ],
$titleFullText
);
// FIXME: page stats not currently enabled. Uncomment when enabled
$url = SpecialPage::getTitleFor( 'PageStatistics' )->getInternalURL( [
'page' => $title->getPrefixedText()
] );
$msg = wfMessage( 'watchanalytics-view-page-stats' );
$pageStatsLink = Xml::element(
'a',
[ 'href' => $url ],
$msg
);
$pageLink .= ' <small>(' . $pageStatsLink . ' | ' . WatchSuggest::getWatchLink( $title ) . ')</small>';
return $pageLink;
} elseif ( $fieldName === 'max_pending_minutes' || $fieldName === 'avg_pending_minutes' ) {
return ( $value === null ) ? null : $this->watchQuery->createTimeStringFromMinutes( $value );
} else {
return $value;
}
}
public function getFieldNames() {
return $this->watchQuery->getFieldNames();
}
public function getDefaultSort() {
return 'num_reviewed';
}
}