本文整理汇总了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());
}
}
示例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;
}
示例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;
}
}