PortableInfobox/includes/querypage/AllinfoboxesQueryPage.php

79 lines
1.7 KiB
PHP
Raw Normal View History

<?php
class AllinfoboxesQueryPage extends PageQueryPage {
const ALL_INFOBOXES_TYPE = 'AllInfoboxes';
function __construct() {
parent::__construct( self::ALL_INFOBOXES_TYPE );
}
2018-08-03 09:54:47 +00:00
function getGroupName() {
return 'pages';
2018-08-06 13:16:36 +00:00
}
2018-08-03 09:54:47 +00:00
public function sortDescending() {
2018-08-03 08:49:28 +00:00
return false;
}
public function isExpensive() {
return true;
}
2018-08-06 13:16:36 +00:00
public function getOrderFields() {
return [ 'title' ];
}
public function getCacheOrderFields() {
return $this->getOrderFields();
}
2018-08-16 09:25:53 +00:00
2018-08-03 08:49:28 +00:00
function getQueryInfo() {
$query = [
'tables' => [ 'page', 'page_props' ],
2018-08-03 08:49:28 +00:00
'fields' => [
'namespace' => 'page.page_namespace',
'title' => 'page.page_title',
'value' => 'page.page_id',
'infoboxes' => 'page_props.pp_value'
2018-08-03 08:49:28 +00:00
],
'conds' => [
'page.page_is_redirect' => 0,
'page.page_namespace' => NS_TEMPLATE,
'page_props.pp_value IS NOT NULL',
'page_props.pp_value != \'\''
],
'join_conds' => [
'page_props' => [
'INNER JOIN',
'page.page_id = page_props.pp_page AND page_props.pp_propname = "infoboxes"'
]
2018-08-03 08:49:28 +00:00
]
];
$subpagesBlacklist = $this->getConfig( 'AllInfoboxesSubpagesBlacklist' );
foreach ( $subpagesBlacklist as $subpage ) {
$query['conds'][] = 'page.page_title NOT LIKE %/' . mysql_real_escape_string( $subpage );
}
return $query;
}
/**
* Update the querycache table
*
2018-08-06 13:16:36 +00:00
* @see QueryPage::recache
*
* @param bool $limit Limit for SQL statement
2018-08-06 13:16:36 +00:00
* @param bool $ignoreErrors Whether to ignore database errors
*
* @return int number of rows updated
*/
public function recache( $limit = false, $ignoreErrors = true ) {
$res = parent::recache( $limit, $ignoreErrors );
2017-07-12 12:21:06 +00:00
Hooks::run( 'AllInfoboxesQueryRecached' );
2018-08-03 08:49:28 +00:00
return $res;
}
}