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


PHP WebRequest::getIntOrNull方法代碼示例

本文整理匯總了PHP中WebRequest::getIntOrNull方法的典型用法代碼示例。如果您正苦於以下問題:PHP WebRequest::getIntOrNull方法的具體用法?PHP WebRequest::getIntOrNull怎麽用?PHP WebRequest::getIntOrNull使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在WebRequest的用法示例。


在下文中一共展示了WebRequest::getIntOrNull方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: fetchValuesFromRequest

 public function fetchValuesFromRequest(WebRequest $r, $values = false)
 {
     if (!$values) {
         $values = array_keys($this->options);
     }
     foreach ($values as $name) {
         $default = $this->options[$name]['default'];
         $type = $this->options[$name]['type'];
         switch ($type) {
             case self::BOOL:
                 $value = $r->getBool($name, $default);
                 break;
             case self::INT:
                 $value = $r->getInt($name, $default);
                 break;
             case self::STRING:
                 $value = $r->getText($name, $default);
                 break;
             case self::INTNULL:
                 $value = $r->getIntOrNull($name);
                 break;
             default:
                 throw new MWException('Unsupported datatype');
         }
         if ($value !== null) {
             $this->options[$name]['value'] = $value === $default ? null : $value;
         }
     }
 }
開發者ID:amjadtbssm,項目名稱:website,代碼行數:29,代碼來源:FormOptions.php

示例2: getBaseRevId

 /**
  * Guess the rev ID the text of this form is based off
  * Note: baseRevId trusted for Reviewers - check text for others.
  * @return int
  */
 protected static function getBaseRevId(EditPage $editPage, WebRequest $request)
 {
     if (!isset($editPage->fr_baseRevId)) {
         $article = $editPage->getArticle();
         // convenience
         $latestId = $article->getLatest();
         // current rev
         $undo = $request->getIntOrNull('undo');
         # Undoing consecutive top edits...
         if ($undo && $undo === $latestId) {
             # Treat this like a revert to a base revision.
             # We are undoing all edits *after* some rev ID (undoafter).
             # If undoafter is not given, then it is the previous rev ID.
             $revId = $request->getInt('undoafter', $article->getTitle()->getPreviousRevisionID($latestId, Title::GAID_FOR_UPDATE));
             # Undoing other edits...
         } elseif ($undo) {
             $revId = $latestId;
             // current rev is the base rev
             # Other edits...
         } else {
             # If we are editing via oldid=X, then use that rev ID.
             # Otherwise, check if the client specified the ID (bug 23098).
             $revId = $article->getOldID() ? $article->getOldID() : $request->getInt('baseRevId');
             // e.g. "show changes"/"preview"
         }
         # Zero oldid => draft revision
         if (!$revId) {
             $revId = $latestId;
         }
         $editPage->fr_baseRevId = $revId;
     }
     return $editPage->fr_baseRevId;
 }
開發者ID:realsoc,項目名稱:mediawiki-extensions,代碼行數:38,代碼來源:FlaggablePageView.php

示例3: getAltBaseRevId

 /**
  * Guess the alternative rev ID the text of this form is based off.
  * When undoing the top X edits, the base can be though of as either
  * the current or the edit X edits prior to the latest.
  * Note: baseRevId trusted for Reviewers - check text for others.
  * @param EditPage $editPage
  * @param WebRequest $request
  * @return int
  */
 protected static function getAltBaseRevId(EditPage $editPage, WebRequest $request)
 {
     if ($editPage->isConflict) {
         return 0;
         // throw away these values (bug 33481)
     }
     if (!isset($editPage->fr_altBaseRevId)) {
         $article = $editPage->getArticle();
         // convenience
         $latestId = $article->getLatest();
         // current rev
         $undo = $request->getIntOrNull('undo');
         # Undoing consecutive top edits...
         if ($undo && $undo === $latestId) {
             # Treat this like a revert to a base revision.
             # We are undoing all edits *after* some rev ID (undoafter).
             # If undoafter is not given, then it is the previous rev ID.
             $revId = $request->getInt('undoafter', $article->getTitle()->getPreviousRevisionID($latestId, Title::GAID_FOR_UPDATE));
         } else {
             $revId = $request->getInt('altBaseRevId');
         }
         $editPage->fr_altBaseRevId = $revId;
     }
     return $editPage->fr_altBaseRevId;
 }
開發者ID:crippsy14,項目名稱:orange-smorange,代碼行數:34,代碼來源:FlaggablePageView.php


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