當前位置: 首頁>>代碼示例>>PHP>>正文


PHP FormOptions::reset方法代碼示例

本文整理匯總了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;
 }
開發者ID:Velody,項目名稱:ponydocs,代碼行數:75,代碼來源:SpecialRecentProductChanges.php

示例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;
 }
開發者ID:mangowi,項目名稱:mediawiki,代碼行數:78,代碼來源:SpecialRecentchanges.php


注:本文中的FormOptions::reset方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。