本文整理汇总了PHP中FormOptions::reset方法的典型用法代码示例。如果您正苦于以下问题:PHP FormOptions::reset方法的具体用法?PHP FormOptions::reset怎么用?PHP FormOptions::reset使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FormOptions
的用法示例。
在下文中一共展示了FormOptions::reset方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildMainQueryConds
/**
* Return an array of conditions depending of options set in $opts
*
* @param $opts FormOptions
* @return array
*/
public function buildMainQueryConds(FormOptions $opts)
{
global $wgUser;
$dbr = wfGetDB(DB_SLAVE);
$conds = array();
# It makes no sense to hide both anons and logged-in users
# Where this occurs, force anons to be shown
$forcebot = false;
if ($opts['hideanons'] && $opts['hideliu']) {
# Check if the user wants to show bots only
if ($opts['hidebots']) {
$opts['hideanons'] = false;
} else {
$forcebot = true;
$opts['hidebots'] = false;
}
}
// Calculate cutoff
$cutoff_unixtime = time() - $opts['days'] * 86400;
$cutoff_unixtime = $cutoff_unixtime - $cutoff_unixtime % 86400;
$cutoff = $dbr->timestamp($cutoff_unixtime);
$fromValid = preg_match('/^[0-9]{14}$/', $opts['from']);
if ($fromValid && $opts['from'] > wfTimestamp(TS_MW, $cutoff)) {
$cutoff = $dbr->timestamp($opts['from']);
} else {
$opts->reset('from');
}
$conds[] = 'rc_timestamp >= ' . $dbr->addQuotes($cutoff);
// Selected product changes
$product = addslashes(isset($_GET['product']) ? $_GET['product'] : PonyDocsProduct::GetSelectedProduct());
$conds[] = 'rc_title LIKE "' . $product . '%"';
$hidePatrol = $wgUser->useRCPatrol() && $opts['hidepatrolled'];
$hideLoggedInUsers = $opts['hideliu'] && !$forcebot;
$hideAnonymousUsers = $opts['hideanons'] && !$forcebot;
if ($opts['hideminor']) {
$conds['rc_minor'] = 0;
}
if ($opts['hidebots']) {
$conds['rc_bot'] = 0;
}
if ($hidePatrol) {
$conds['rc_patrolled'] = 0;
}
if ($forcebot) {
$conds['rc_bot'] = 1;
}
if ($hideLoggedInUsers) {
$conds[] = 'rc_user = 0';
}
if ($hideAnonymousUsers) {
$conds[] = 'rc_user != 0';
}
if ($opts['hidemyself']) {
if ($wgUser->getId()) {
$conds[] = 'rc_user != ' . $dbr->addQuotes($wgUser->getId());
} else {
$conds[] = 'rc_user_text != ' . $dbr->addQuotes($wgUser->getName());
}
}
# Namespace filtering
if ($opts['namespace'] !== '') {
if (!$opts['invert']) {
$conds[] = 'rc_namespace = ' . $dbr->addQuotes($opts['namespace']);
} else {
$conds[] = 'rc_namespace != ' . $dbr->addQuotes($opts['namespace']);
}
}
return $conds;
}
示例2: buildMainQueryConds
/**
* Return an array of conditions depending of options set in $opts
*
* @param FormOptions $opts
* @return array
*/
public function buildMainQueryConds(FormOptions $opts)
{
$dbr = wfGetDB(DB_SLAVE);
$conds = array();
# It makes no sense to hide both anons and logged-in users
# Where this occurs, force anons to be shown
$forcebot = false;
if ($opts['hideanons'] && $opts['hideliu']) {
# Check if the user wants to show bots only
if ($opts['hidebots']) {
$opts['hideanons'] = false;
} else {
$forcebot = true;
$opts['hidebots'] = false;
}
}
// Calculate cutoff
$cutoff_unixtime = time() - $opts['days'] * 86400;
$cutoff_unixtime = $cutoff_unixtime - $cutoff_unixtime % 86400;
$cutoff = $dbr->timestamp($cutoff_unixtime);
$fromValid = preg_match('/^[0-9]{14}$/', $opts['from']);
if ($fromValid && $opts['from'] > wfTimestamp(TS_MW, $cutoff)) {
$cutoff = $dbr->timestamp($opts['from']);
} else {
$opts->reset('from');
}
$conds[] = 'rc_timestamp >= ' . $dbr->addQuotes($cutoff);
$hidePatrol = $this->getUser()->useRCPatrol() && $opts['hidepatrolled'];
$hideLoggedInUsers = $opts['hideliu'] && !$forcebot;
$hideAnonymousUsers = $opts['hideanons'] && !$forcebot;
if ($opts['hideminor']) {
$conds['rc_minor'] = 0;
}
if ($opts['hidebots']) {
$conds['rc_bot'] = 0;
}
if ($hidePatrol) {
$conds['rc_patrolled'] = 0;
}
if ($forcebot) {
$conds['rc_bot'] = 1;
}
if ($hideLoggedInUsers) {
$conds[] = 'rc_user = 0';
}
if ($hideAnonymousUsers) {
$conds[] = 'rc_user != 0';
}
if ($opts['hidemyself']) {
if ($this->getUser()->getId()) {
$conds[] = 'rc_user != ' . $dbr->addQuotes($this->getUser()->getId());
} else {
$conds[] = 'rc_user_text != ' . $dbr->addQuotes($this->getUser()->getName());
}
}
# Namespace filtering
if ($opts['namespace'] !== '') {
$selectedNS = $dbr->addQuotes($opts['namespace']);
$operator = $opts['invert'] ? '!=' : '=';
$boolean = $opts['invert'] ? 'AND' : 'OR';
# namespace association (bug 2429)
if (!$opts['associated']) {
$condition = "rc_namespace {$operator} {$selectedNS}";
} else {
# Also add the associated namespace
$associatedNS = $dbr->addQuotes(MWNamespace::getAssociated($opts['namespace']));
$condition = "(rc_namespace {$operator} {$selectedNS} " . $boolean . " rc_namespace {$operator} {$associatedNS})";
}
$conds[] = $condition;
}
return $conds;
}