本文整理汇总了PHP中RecentChange::selectFields方法的典型用法代码示例。如果您正苦于以下问题:PHP RecentChange::selectFields方法的具体用法?PHP RecentChange::selectFields怎么用?PHP RecentChange::selectFields使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RecentChange
的用法示例。
在下文中一共展示了RecentChange::selectFields方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doMainQuery
/**
* Process the query
*
* @param array $conds
* @param FormOptions $opts
* @return bool|ResultWrapper Result or false
*/
public function doMainQuery($conds, $opts)
{
$tables = ['recentchanges'];
$fields = RecentChange::selectFields();
$query_options = [];
$join_conds = [];
ChangeTags::modifyDisplayQuery($tables, $fields, $conds, $join_conds, $query_options, '');
if (!$this->runMainQueryHook($tables, $fields, $conds, $query_options, $join_conds, $opts)) {
return false;
}
$dbr = $this->getDB();
return $dbr->select($tables, $fields, $conds, __METHOD__, $query_options, $join_conds);
}
示例2: doMainQuery
/**
* Process the query
*
* @param array $conds
* @param FormOptions $opts
* @return bool|ResultWrapper Result or false (for Recentchangeslinked only)
*/
public function doMainQuery($conds, $opts)
{
$dbr = $this->getDB();
$user = $this->getUser();
# Toggle watchlist content (all recent edits or just the latest)
if ($opts['extended']) {
$limitWatchlist = $user->getIntOption('wllimit');
$usePage = false;
} else {
# Top log Ids for a page are not stored
$nonRevisionTypes = array(RC_LOG);
Hooks::run('SpecialWatchlistGetNonRevisionTypes', array(&$nonRevisionTypes));
if ($nonRevisionTypes) {
$conds[] = $dbr->makeList(array('rc_this_oldid=page_latest', 'rc_type' => $nonRevisionTypes), LIST_OR);
}
$limitWatchlist = 0;
$usePage = true;
}
$tables = array('recentchanges', 'watchlist');
$fields = RecentChange::selectFields();
$query_options = array('ORDER BY' => 'rc_timestamp DESC');
$join_conds = array('watchlist' => array('INNER JOIN', array('wl_user' => $user->getId(), 'wl_namespace=rc_namespace', 'wl_title=rc_title')));
if ($this->getConfig()->get('ShowUpdatedMarker')) {
$fields[] = 'wl_notificationtimestamp';
}
if ($limitWatchlist) {
$query_options['LIMIT'] = $limitWatchlist;
}
$rollbacker = $user->isAllowed('rollback');
if ($usePage || $rollbacker) {
$tables[] = 'page';
$join_conds['page'] = array('LEFT JOIN', 'rc_cur_id=page_id');
if ($rollbacker) {
$fields[] = 'page_latest';
}
}
// Log entries with DELETED_ACTION must not show up unless the user has
// the necessary rights.
if (!$user->isAllowed('deletedhistory')) {
$bitmask = LogPage::DELETED_ACTION;
} elseif (!$user->isAllowedAny('suppressrevision', 'viewsuppressed')) {
$bitmask = LogPage::DELETED_ACTION | LogPage::DELETED_RESTRICTED;
} else {
$bitmask = 0;
}
if ($bitmask) {
$conds[] = $dbr->makeList(array('rc_type != ' . RC_LOG, $dbr->bitAnd('rc_deleted', $bitmask) . " != {$bitmask}"), LIST_OR);
}
ChangeTags::modifyDisplayQuery($tables, $fields, $conds, $join_conds, $query_options, '');
$this->runMainQueryHook($tables, $fields, $conds, $query_options, $join_conds, $opts);
return $dbr->select($tables, $fields, $conds, __METHOD__, $query_options, $join_conds);
}
示例3: doMainQuery
/**
* Process the query
*
* @param array $conds
* @param FormOptions $opts
* @return bool|ResultWrapper Result or false (for Recentchangeslinked only)
*/
public function doMainQuery($conds, $opts)
{
$tables = array('recentchanges');
$join_conds = array();
$query_options = array('USE INDEX' => array('recentchanges' => 'rc_timestamp'));
$uid = $this->getUser()->getId();
$dbr = wfGetDB(DB_SLAVE);
$limit = $opts['limit'];
$namespace = $opts['namespace'];
$invert = $opts['invert'];
$associated = $opts['associated'];
$fields = RecentChange::selectFields();
// JOIN on watchlist for users
if ($uid) {
$tables[] = 'watchlist';
$fields[] = 'wl_user';
$fields[] = 'wl_notificationtimestamp';
$join_conds['watchlist'] = array('LEFT JOIN', array('wl_user' => $uid, 'wl_title=rc_title', 'wl_namespace=rc_namespace'));
}
if ($this->getUser()->isAllowed('rollback')) {
$tables[] = 'page';
$fields[] = 'page_latest';
$join_conds['page'] = array('LEFT JOIN', 'rc_cur_id=page_id');
}
// Tag stuff.
ChangeTags::modifyDisplayQuery($tables, $fields, $conds, $join_conds, $query_options, $opts['tagfilter']);
if (!wfRunHooks('SpecialRecentChangesQuery', array(&$conds, &$tables, &$join_conds, $opts, &$query_options, &$fields))) {
return false;
}
// Don't use the new_namespace_time timestamp index if:
// (a) "All namespaces" selected
// (b) We want pages in more than one namespace (inverted/associated)
// (c) There is a tag to filter on (use tag index instead)
// (d) UNION + sort/limit is not an option for the DBMS
if ($namespace === '' || ($invert || $associated) || $opts['tagfilter'] != '' || !$dbr->unionSupportsOrderAndLimit()) {
$res = $dbr->select($tables, $fields, $conds, __METHOD__, array('ORDER BY' => 'rc_timestamp DESC', 'LIMIT' => $limit) + $query_options, $join_conds);
} else {
// We have a new_namespace_time index! UNION over new=(0,1) and sort result set!
// New pages
$sqlNew = $dbr->selectSQLText($tables, $fields, array('rc_new' => 1) + $conds, __METHOD__, array('ORDER BY' => 'rc_timestamp DESC', 'LIMIT' => $limit, 'USE INDEX' => array('recentchanges' => 'new_name_timestamp')), $join_conds);
// Old pages
$sqlOld = $dbr->selectSQLText($tables, $fields, array('rc_new' => 0) + $conds, __METHOD__, array('ORDER BY' => 'rc_timestamp DESC', 'LIMIT' => $limit, 'USE INDEX' => array('recentchanges' => 'new_name_timestamp')), $join_conds);
# Join the two fast queries, and sort the result set
$sql = $dbr->unionQueries(array($sqlNew, $sqlOld), false) . ' ORDER BY rc_timestamp DESC';
$sql = $dbr->limitResult($sql, $limit, false);
$res = $dbr->query($sql, __METHOD__);
}
return $res;
}
示例4: doMainQuery
/**
* Process the query
*
* @param array $conds
* @param FormOptions $opts
* @return bool|ResultWrapper Result or false (for Recentchangeslinked only)
*/
public function doMainQuery($conds, $opts)
{
$dbr = $this->getDB();
$user = $this->getUser();
$tables = array('recentchanges');
$fields = RecentChange::selectFields();
$query_options = array();
$join_conds = array();
// JOIN on watchlist for users
if ($user->getId() && $user->isAllowed('viewmywatchlist')) {
$tables[] = 'watchlist';
$fields[] = 'wl_user';
$fields[] = 'wl_notificationtimestamp';
$join_conds['watchlist'] = array('LEFT JOIN', array('wl_user' => $user->getId(), 'wl_title=rc_title', 'wl_namespace=rc_namespace'));
}
if ($user->isAllowed('rollback')) {
$tables[] = 'page';
$fields[] = 'page_latest';
$join_conds['page'] = array('LEFT JOIN', 'rc_cur_id=page_id');
}
ChangeTags::modifyDisplayQuery($tables, $fields, $conds, $join_conds, $query_options, $opts['tagfilter']);
if (!$this->runMainQueryHook($tables, $fields, $conds, $query_options, $join_conds, $opts)) {
return false;
}
// array_merge() is used intentionally here so that hooks can, should
// they so desire, override the ORDER BY / LIMIT condition(s); prior to
// MediaWiki 1.26 this used to use the plus operator instead, which meant
// that extensions weren't able to change these conditions
$query_options = array_merge(array('ORDER BY' => 'rc_timestamp DESC', 'LIMIT' => $opts['limit']), $query_options);
$rows = $dbr->select($tables, $fields, $conds + array('rc_new' => array(0, 1)), __METHOD__, $query_options, $join_conds);
// Build the final data
if ($this->getConfig()->get('AllowCategorizedRecentChanges')) {
$this->filterByCategories($rows, $opts);
}
return $rows;
}
示例5: doMainQuery
/**
* Process the query
*
* @param array $conds
* @param FormOptions $opts
* @return bool|ResultWrapper Result or false (for Recentchangeslinked only)
*/
public function doMainQuery($conds, $opts)
{
global $wgAllowCategorizedRecentChanges;
$dbr = $this->getDB();
$user = $this->getUser();
$tables = array('recentchanges');
$fields = RecentChange::selectFields();
$query_options = array();
$join_conds = array();
// JOIN on watchlist for users
if ($user->getId() && $user->isAllowed('viewmywatchlist')) {
$tables[] = 'watchlist';
$fields[] = 'wl_user';
$fields[] = 'wl_notificationtimestamp';
$join_conds['watchlist'] = array('LEFT JOIN', array('wl_user' => $user->getId(), 'wl_title=rc_title', 'wl_namespace=rc_namespace'));
}
if ($user->isAllowed('rollback')) {
$tables[] = 'page';
$fields[] = 'page_latest';
$join_conds['page'] = array('LEFT JOIN', 'rc_cur_id=page_id');
}
ChangeTags::modifyDisplayQuery($tables, $fields, $conds, $join_conds, $query_options, $opts['tagfilter']);
if (!wfRunHooks('SpecialRecentChangesQuery', array(&$conds, &$tables, &$join_conds, $opts, &$query_options, &$fields), '1.23')) {
return false;
}
// rc_new is not an ENUM, but adding a redundant rc_new IN (0,1) gives mysql enough
// knowledge to use an index merge if it wants (it may use some other index though).
$rows = $dbr->select($tables, $fields, $conds + array('rc_new' => array(0, 1)), __METHOD__, array('ORDER BY' => 'rc_timestamp DESC', 'LIMIT' => $opts['limit']) + $query_options, $join_conds);
// Build the final data
if ($wgAllowCategorizedRecentChanges) {
$this->filterByCategories($rows, $opts);
}
return $rows;
}
示例6: doMainQuery
public function doMainQuery($conds, $opts)
{
$target = $opts['target'];
$showlinkedto = $opts['showlinkedto'];
$limit = $opts['limit'];
if ($target === '') {
return false;
}
$outputPage = $this->getOutput();
$title = Title::newFromURL($target);
if (!$title || $title->isExternal()) {
$outputPage->addHtml('<div class="errorbox">' . $this->msg('allpagesbadtitle')->parse() . '</div>');
return false;
}
$outputPage->setPageTitle($this->msg('recentchangeslinked-title', $title->getPrefixedText()));
/*
* Ordinary links are in the pagelinks table, while transclusions are
* in the templatelinks table, categorizations in categorylinks and
* image use in imagelinks. We need to somehow combine all these.
* Special:Whatlinkshere does this by firing multiple queries and
* merging the results, but the code we inherit from our parent class
* expects only one result set so we use UNION instead.
*/
$dbr = wfGetDB(DB_SLAVE, 'recentchangeslinked');
$id = $title->getArticleID();
$ns = $title->getNamespace();
$dbkey = $title->getDBkey();
$tables = array('recentchanges');
$select = RecentChange::selectFields();
$join_conds = array();
$query_options = array();
// left join with watchlist table to highlight watched rows
$uid = $this->getUser()->getId();
if ($uid && $this->getUser()->isAllowed('viewmywatchlist')) {
$tables[] = 'watchlist';
$select[] = 'wl_user';
$join_conds['watchlist'] = array('LEFT JOIN', array('wl_user' => $uid, 'wl_title=rc_title', 'wl_namespace=rc_namespace'));
}
if ($this->getUser()->isAllowed('rollback')) {
$tables[] = 'page';
$join_conds['page'] = array('LEFT JOIN', 'rc_cur_id=page_id');
$select[] = 'page_latest';
}
ChangeTags::modifyDisplayQuery($tables, $select, $conds, $join_conds, $query_options, $opts['tagfilter']);
if (!wfRunHooks('SpecialRecentChangesQuery', array(&$conds, &$tables, &$join_conds, $opts, &$query_options, &$select), '1.23')) {
return false;
}
if ($ns == NS_CATEGORY && !$showlinkedto) {
// special handling for categories
// XXX: should try to make this less kludgy
$link_tables = array('categorylinks');
$showlinkedto = true;
} else {
// for now, always join on these tables; really should be configurable as in whatlinkshere
$link_tables = array('pagelinks', 'templatelinks');
// imagelinks only contains links to pages in NS_FILE
if ($ns == NS_FILE || !$showlinkedto) {
$link_tables[] = 'imagelinks';
}
}
if ($id == 0 && !$showlinkedto) {
return false;
// nonexistent pages can't link to any pages
}
// field name prefixes for all the various tables we might want to join with
$prefix = array('pagelinks' => 'pl', 'templatelinks' => 'tl', 'categorylinks' => 'cl', 'imagelinks' => 'il');
$subsql = array();
// SELECT statements to combine with UNION
foreach ($link_tables as $link_table) {
$pfx = $prefix[$link_table];
// imagelinks and categorylinks tables have no xx_namespace field,
// and have xx_to instead of xx_title
if ($link_table == 'imagelinks') {
$link_ns = NS_FILE;
} elseif ($link_table == 'categorylinks') {
$link_ns = NS_CATEGORY;
} else {
$link_ns = 0;
}
if ($showlinkedto) {
// find changes to pages linking to this page
if ($link_ns) {
if ($ns != $link_ns) {
continue;
}
// should never happen, but check anyway
$subconds = array("{$pfx}_to" => $dbkey);
} else {
$subconds = array("{$pfx}_namespace" => $ns, "{$pfx}_title" => $dbkey);
}
$subjoin = "rc_cur_id = {$pfx}_from";
} else {
// find changes to pages linked from this page
$subconds = array("{$pfx}_from" => $id);
if ($link_table == 'imagelinks' || $link_table == 'categorylinks') {
$subconds["rc_namespace"] = $link_ns;
$subjoin = "rc_title = {$pfx}_to";
} else {
$subjoin = array("rc_namespace = {$pfx}_namespace", "rc_title = {$pfx}_title");
}
//.........这里部分代码省略.........
示例7: execute
//.........这里部分代码省略.........
$form .= $this->msg( 'watchlist-details' )->numParams( $nitems )->parse() . "\n";
if ( $wgEnotifWatchlist && $user->getOption( 'enotifwatchlistpages' ) ) {
$form .= $this->msg( 'wlheader-enotif' )->parse() . "\n";
}
if ( $wgShowUpdatedMarker ) {
$form .= $this->msg( 'wlheader-showupdated' )->parse() . "\n";
}
$form .= "</p>";
if ( $wgShowUpdatedMarker ) {
$form .= Xml::openElement( 'form', array( 'method' => 'post',
'action' => $this->getTitle()->getLocalURL(),
'id' => 'mw-watchlist-resetbutton' ) ) . "\n" .
Xml::submitButton( $this->msg( 'enotif_reset' )->text(), array( 'name' => 'dummy' ) ) . "\n" .
Html::hidden( 'reset', 'all' ) . "\n";
foreach ( $nondefaults as $key => $value ) {
$form .= Html::hidden( $key, $value ) . "\n";
}
$form .= Xml::closeElement( 'form' ) . "\n";
}
$form .= Xml::openElement( 'form', array(
'method' => 'post',
'action' => $this->getTitle()->getLocalURL(),
'id' => 'mw-watchlist-form'
) );
$form .= Xml::fieldset(
$this->msg( 'watchlist-options' )->text(),
false,
array( 'id' => 'mw-watchlist-options' )
);
$tables = array( 'recentchanges', 'watchlist' );
$fields = RecentChange::selectFields();
$join_conds = array(
'watchlist' => array(
'INNER JOIN',
array(
'wl_user' => $user->getId(),
'wl_namespace=rc_namespace',
'wl_title=rc_title'
),
),
);
$options = array( 'ORDER BY' => 'rc_timestamp DESC' );
if ( $wgShowUpdatedMarker ) {
$fields[] = 'wl_notificationtimestamp';
}
if ( $limitWatchlist ) {
$options['LIMIT'] = $limitWatchlist;
}
$rollbacker = $user->isAllowed( 'rollback' );
if ( $usePage || $rollbacker ) {
$tables[] = 'page';
$join_conds['page'] = array( 'LEFT JOIN', 'rc_cur_id=page_id' );
if ( $rollbacker ) {
$fields[] = 'page_latest';
}
}
// Log entries with DELETED_ACTION must not show up unless the user has
// the necessary rights.
if ( !$user->isAllowed( 'deletedhistory' ) ) {
$bitmask = LogPage::DELETED_ACTION;
} elseif ( !$user->isAllowed( 'suppressrevision' ) ) {
示例8: doMainQuery
/**
* Process the query
*
* @param array $conds
* @param FormOptions $opts
* @return bool|ResultWrapper Result or false (for Recentchangeslinked only)
*/
public function doMainQuery( $conds, $opts ) {
$tables = array( 'recentchanges' );
$join_conds = array();
$query_options = array(
'USE INDEX' => array( 'recentchanges' => 'rc_timestamp' )
);
$uid = $this->getUser()->getId();
$dbr = wfGetDB( DB_SLAVE );
$limit = $opts['limit'];
$namespace = $opts['namespace'];
$invert = $opts['invert'];
$associated = $opts['associated'];
$fields = RecentChange::selectFields();
// JOIN on watchlist for users
if ( $uid && $this->getUser()->isAllowed( 'viewmywatchlist' ) ) {
$tables[] = 'watchlist';
$fields[] = 'wl_user';
$fields[] = 'wl_notificationtimestamp';
$join_conds['watchlist'] = array( 'LEFT JOIN', array(
'wl_user' => $uid,
'wl_title=rc_title',
'wl_namespace=rc_namespace'
) );
}
if ( $this->getUser()->isAllowed( 'rollback' ) ) {
$tables[] = 'page';
$fields[] = 'page_latest';
$join_conds['page'] = array( 'LEFT JOIN', 'rc_cur_id=page_id' );
}
// Tag stuff.
ChangeTags::modifyDisplayQuery(
$tables,
$fields,
$conds,
$join_conds,
$query_options,
$opts['tagfilter']
);
if ( !wfRunHooks( 'SpecialRecentChangesQuery',
array( &$conds, &$tables, &$join_conds, $opts, &$query_options, &$fields ) )
) {
return false;
}
// rc_new is not an ENUM, but adding a redundant rc_new IN (0,1) gives mysql enough
// knowledge to use an index merge if it wants (it may use some other index though).
return $dbr->select(
$tables,
$fields,
$conds + array( 'rc_new' => array( 0, 1 ) ),
__METHOD__,
array( 'ORDER BY' => 'rc_timestamp DESC', 'LIMIT' => $limit ) + $query_options,
$join_conds
);
}
示例9: execute
//.........这里部分代码省略.........
$conds[] = $nameSpaceClause;
}
# Toggle watchlist content (all recent edits or just the latest)
if ($user->getOption('extendwatchlist')) {
$limitWatchlist = intval($user->getOption('wllimit'));
$usePage = false;
} else {
# Top log Ids for a page are not stored
$conds[] = 'rc_this_oldid=page_latest OR rc_type=' . RC_LOG;
$limitWatchlist = 0;
$usePage = true;
}
# Show a message about slave lag, if applicable
$lag = wfGetLB()->safeGetLag($dbr);
if ($lag > 0) {
$output->showLagWarning($lag);
}
# Create output form
$form = Xml::fieldset($this->msg('watchlist-options')->text(), false, array('id' => 'mw-watchlist-options'));
# Show watchlist header
$form .= $this->msg('watchlist-details')->numParams($nitems)->parse();
if ($user->getOption('enotifwatchlistpages') && $wgEnotifWatchlist) {
$form .= $this->msg('wlheader-enotif')->parseAsBlock() . "\n";
}
if ($wgShowUpdatedMarker) {
$form .= Xml::openElement('form', array('method' => 'post', 'action' => $this->getTitle()->getLocalUrl(), 'id' => 'mw-watchlist-resetbutton')) . $this->msg('wlheader-showupdated')->parse() . ' ' . Xml::submitButton($this->msg('enotif_reset')->text(), array('name' => 'dummy')) . Html::hidden('reset', 'all');
foreach ($nondefaults as $key => $value) {
$form .= Html::hidden($key, $value);
}
$form .= Xml::closeElement('form');
}
$form .= '<hr />';
$tables = array('recentchanges', 'watchlist');
$fields = RecentChange::selectFields();
$join_conds = array('watchlist' => array('INNER JOIN', array('wl_user' => $user->getId(), 'wl_namespace=rc_namespace', 'wl_title=rc_title')));
$options = array('ORDER BY' => 'rc_timestamp DESC');
if ($wgShowUpdatedMarker) {
$fields[] = 'wl_notificationtimestamp';
}
if ($limitWatchlist) {
$options['LIMIT'] = $limitWatchlist;
}
$rollbacker = $user->isAllowed('rollback');
if ($usePage || $rollbacker) {
$tables[] = 'page';
$join_conds['page'] = array('LEFT JOIN', 'rc_cur_id=page_id');
if ($rollbacker) {
$fields[] = 'page_latest';
}
}
ChangeTags::modifyDisplayQuery($tables, $fields, $conds, $join_conds, $options, '');
wfRunHooks('SpecialWatchlistQuery', array(&$conds, &$tables, &$join_conds, &$fields));
$res = $dbr->select($tables, $fields, $conds, __METHOD__, $options, $join_conds);
$numRows = $res->numRows();
/* Start bottom header */
$lang = $this->getLanguage();
$wlInfo = '';
if ($values['days'] > 0) {
$timestamp = wfTimestampNow();
$wlInfo = $this->msg('wlnote')->numParams($numRows, round($values['days'] * 24))->params($lang->userDate($timestamp, $user), $lang->userTime($timestamp, $user))->parse() . '<br />';
}
$cutofflinks = "\n" . $this->cutoffLinks($values['days'], $nondefaults) . "<br />\n";
# Spit out some control panel links
$filters = array('hideMinor' => 'rcshowhideminor', 'hideBots' => 'rcshowhidebots', 'hideAnons' => 'rcshowhideanons', 'hideLiu' => 'rcshowhideliu', 'hideOwn' => 'rcshowhidemine', 'hidePatrolled' => 'rcshowhidepatr');
foreach ($this->customFilters as $key => $params) {
$filters[$key] = $params['msg'];
示例10: doMainQuery
/**
* Process the query
*
* @param array $conds
* @param FormOptions $opts
* @return bool|ResultWrapper Result or false
*/
public function doMainQuery($conds, $opts)
{
$tables = array('recentchanges');
$fields = RecentChange::selectFields();
$query_options = array();
$join_conds = array();
ChangeTags::modifyDisplayQuery($tables, $fields, $conds, $join_conds, $query_options, '');
if (!wfRunHooks('ChangesListSpecialPageQuery', array($this->getName(), &$tables, &$fields, &$conds, &$query_options, &$join_conds, $opts))) {
return false;
}
$dbr = $this->getDB();
return $dbr->select($tables, $fields, $conds, __METHOD__, $query_options, $join_conds);
}
示例11: doMainQuery
/**
* Process the query
*
* @param array $conds
* @param FormOptions $opts
* @return bool|ResultWrapper Result or false
*/
public function doMainQuery($conds, $opts)
{
$tables = array('recentchanges');
$fields = RecentChange::selectFields();
$query_options = array();
$join_conds = array();
ChangeTags::modifyDisplayQuery($tables, $fields, $conds, $join_conds, $query_options, '');
// @todo Fire a Special{$this->getName()}Query hook here
// @todo Uncomment and document
// if ( !wfRunHooks( 'ChangesListSpecialPageQuery',
// array( &$tables, &$fields, &$conds, &$query_options, &$join_conds, $opts ) )
// ) {
// return false;
// }
$dbr = $this->getDB();
return $dbr->select($tables, $fields, $conds, __METHOD__, $query_options, $join_conds);
}