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


PHP WebRequest::getArray方法代碼示例

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


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

示例1: loadDataFromRequest

 /**
  * @param WebRequest $request
  *
  * @return string
  */
 function loadDataFromRequest($request)
 {
     if ($this->mParent->getMethod() == 'post') {
         if ($request->wasPosted()) {
             # Checkboxes are just not added to the request arrays if they're not checked,
             # so it's perfectly possible for there not to be an entry at all
             return $request->getArray($this->mName, array());
         } else {
             # That's ok, the user has not yet submitted the form, so show the defaults
             return $this->getDefault();
         }
     } else {
         # This is the impossible case: if we look at $_GET and see no data for our
         # field, is it because the user has not yet submitted the form, or that they
         # have submitted it with all the options unchecked? We will have to assume the
         # latter, which basically means that you can't specify 'positive' defaults
         # for GET forms.
         # @todo FIXME...
         return $request->getArray($this->mName, array());
     }
 }
開發者ID:eliagbayani,項目名稱:LiteratureEditor,代碼行數:26,代碼來源:HTMLMultiSelectField.php

示例2: parseCreateEditQuizArticleRequest

 private static function parseCreateEditQuizArticleRequest(WebRequest $request, WikiaQuizElement $quizElement, &$error)
 {
     if (!empty($quizElement)) {
         $title = $quizElement->getTitle();
         $quiz = $quizElement->getQuizTitle();
         $order = $quizElement->getOrder();
     } else {
         $order = '';
         $title = trim($request->getVal('question'));
         $quiz = trim($request->getVal('quiz'));
     }
     $image = trim($request->getVal('image'));
     $explanation = trim($request->getVal('explanation'));
     $video = trim($request->getVal('video'));
     $answers = $request->getArray('answer');
     // array
     $correctAnswer = trim($request->getVal('correct'));
     $answerImages = $request->getArray('answer-image');
     // array
     $content = "";
     $content .= WikiaQuizElement::TITLE_MARKER . $title . "\n";
     if ($image) {
         if (!self::isValidImage($image)) {
             $error = wfMsg('wikiaquiz-error-invalid-image', $image);
             return;
         }
         $content .= WikiaQuizElement::IMAGE_MARKER . $image . "\n";
     }
     if ($video) {
         if (!self::isValidVideo($video)) {
             $error = wfMsg('wikiaquiz-error-invalid-video', $video);
             return;
         }
         $content .= WikiaQuizElement::VIDEO_MARKER . $video . "\n";
     }
     if ($explanation) {
         $content .= WikiaQuizElement::EXPLANATION_MARKER . $explanation . "\n";
     }
     if ($quiz) {
         $content .= self::getCategoryText($quiz, $order);
     } else {
         $error = wfMsg('wikiaquiz-error-invalid-quiz');
         return;
     }
     $answerExists = false;
     $correctAnswerExists = false;
     foreach ($answers as $index => $answer) {
         $answer = trim($answer);
         if ($answer) {
             $answerExists = true;
             $correctAnswerContent = "";
             if ($index == $correctAnswer) {
                 if ($correctAnswerExists) {
                     $error = wfMsg('wikiaquiz-error-invalid-correct-answer');
                     return;
                 } else {
                     $correctAnswerExists = true;
                 }
                 $correctAnswerContent .= WikiaQuizElement::CORRECT_ANSWER_MARKER . ' ';
             }
             $answerImageContent = "";
             $answerImage = trim($answerImages[$index]);
             if ($answerImage) {
                 if (!self::isValidImage($answerImage)) {
                     $error = wfMsg('wikiaquiz-error-invalid-image', $answerImage);
                     return;
                 }
                 $answerImageContent .= WikiaQuizElement::ANSWER_IMAGE_MARKER . $answerImages[$index];
             }
             $content .= WikiaQuizElement::ANSWER_MARKER . "{$correctAnswerContent}{$answer}{$answerImageContent}\n";
         }
     }
     if (!$answerExists) {
         $error = wfMsg('wikiaquiz-error-missing-answers');
         return;
     }
     if (!$correctAnswerExists) {
         $error = wfMsg('wikiaquiz-error-invalid-correct-answer');
         return;
     }
     return $content;
 }
開發者ID:schwarer2006,項目名稱:wikia,代碼行數:82,代碼來源:WikiaQuizAjax.class.php

示例3: processFormatOptions

 /**
  * Generates form elements for a (web)requested format.
  *
  * Required by getFormatSelectBox() to recieve form elements from the
  * Web. UIs may need to overload processFormatOptions(),
  * processFormatSelectBox() and getFormatSelectBox() to change behavior.
  *
  * @param WebRequest $wgRequest
  * @return boolean true if format options were requested and returned, else false
  */
 protected function processFormatOptions($wgRequest)
 {
     global $wgOut;
     if ($wgRequest->getCheck('showformatoptions')) {
         // handle Ajax action
         $format = $wgRequest->getVal('showformatoptions');
         $params = $wgRequest->getArray('params');
         $wgOut->disable();
         echo $this->showFormatOptions($format, $params);
         return true;
     } else {
         return false;
     }
 }
開發者ID:Tjorriemorrie,項目名稱:app,代碼行數:24,代碼來源:SMW_QueryUI.php


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