本文整理汇总了PHP中SFUtils::addFormRLModules方法的典型用法代码示例。如果您正苦于以下问题:PHP SFUtils::addFormRLModules方法的具体用法?PHP SFUtils::addFormRLModules怎么用?PHP SFUtils::addFormRLModules使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SFUtils
的用法示例。
在下文中一共展示了SFUtils::addFormRLModules方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: showFormPreview
/**
* Appends a preview of the actual form, when a page in the "Form"
* namespace is previewed.
*
* @author Solitarius
* @since 2.4
*
* @param EditPage $editpage
* @param WebRequest $request
*
* @return true
*/
public static function showFormPreview(EditPage $editpage, WebRequest $request)
{
global $wgOut, $wgParser, $sfgFormPrinter;
wfDebug(__METHOD__ . ": enter.\n");
// Exit if we're not in preview mode.
if (!$editpage->preview) {
return true;
}
// Exit if we aren't in the "Form" namespace.
if ($editpage->getArticle()->getTitle()->getNamespace() != SF_NS_FORM) {
return true;
}
$editpage->previewTextAfterContent .= Html::element('h2', null, wfMessage('sf-preview-header')->text()) . "\n" . '<div class="previewnote" style="font-weight: bold">' . $wgOut->parse(wfMessage('sf-preview-note')->text()) . "</div>\n<hr />\n";
$form_definition = StringUtils::delimiterReplace('<noinclude>', '</noinclude>', '', $editpage->textbox1);
list($form_text, $javascript_text, $data_text, $form_page_title, $generated_page_name) = $sfgFormPrinter->formHTML($form_definition, null, false, null, null, "Semantic Forms form preview dummy title", null);
$parserOutput = $wgParser->getOutput();
if (method_exists($wgOut, 'addParserOutputMetadata')) {
$wgOut->addParserOutputMetadata($parserOutput);
} else {
$wgOut->addParserOutputNoText($parserOutput);
}
SFUtils::addFormRLModules();
$editpage->previewTextAfterContent .= '<div style="margin-top: 15px">' . $form_text . "</div>";
return true;
}
示例2: printPage
//.........这里部分代码省略.........
// Get the text of the results.
$resultsText = '';
if ($form_submitted) {
// @TODO - fix RunQuery's parsing so that this check
// isn't needed.
if ($wgParser->getOutput() == null) {
$headItems = array();
} else {
$headItems = $wgParser->getOutput()->getHeadItems();
}
foreach ($headItems as $key => $item) {
$wgOut->addHeadItem($key, "\t\t" . $item . "\n");
}
$wgParser->mOptions = ParserOptions::newFromUser($wgUser);
$resultsText = $wgParser->parse($data_text, $this->getTitle(), $wgParser->mOptions)->getText();
}
// Get the full text of the form.
$fullFormText = '';
$additionalQueryHeader = '';
$dividerText = '';
if (!$raw) {
// Create the "additional query" header, and the
// divider text - one of these (depending on whether
// the query form is at the top or bottom) is displayed
// if the form has already been submitted.
if ($form_submitted) {
$additionalQueryHeader = "\n" . Html::element('h2', null, wfMessage('sf_runquery_additionalquery')->text()) . "\n";
$dividerText = "\n<hr style=\"margin: 15px 0;\" />\n";
}
$action = htmlspecialchars($this->getTitle($form_name)->getLocalURL());
$fullFormText .= <<<END
\t<form id="sfForm" name="createbox" action="{$action}" method="post" class="createbox">
END;
$fullFormText .= Html::hidden('query', 'true');
$fullFormText .= $form_text;
}
// Either don't display a query form at all, or display the
// query form at the top, and the results at the bottom, or the
// other way around, depending on the settings.
if ($wgRequest->getVal('additionalquery') == 'false') {
$text .= $resultsText;
} elseif ($sfgRunQueryFormAtTop) {
$text .= Html::openElement('div', array('class' => 'sf-runquery-formcontent'));
$text .= $fullFormText;
$text .= $dividerText;
$text .= Html::closeElement('div');
$text .= $resultsText;
} else {
$text .= $resultsText;
$text .= Html::openElement('div', array('class' => 'sf-runquery-formcontent'));
$text .= $additionalQueryHeader;
$text .= $fullFormText;
$text .= Html::closeElement('div');
}
if ($embedded) {
$text = "<div class='runQueryEmbedded'>{$text}</div>";
}
// Armor against doBlockLevels()
$text = preg_replace('/^ +/m', '', $text);
// Now write everything to the screen.
$wgOut->addHTML($text);
SFUtils::addFormRLModules($embedded ? $wgParser : null);
$script = "\t\t" . '<script type="text/javascript">' . "\n" . $javascript_text . '</script>' . "\n";
if ($embedded) {
if (method_exists('ResourceLoader', 'makeInlineScript')) {
// MW 1.25+
$wgParser->getOutput()->addHeadItem(ResourceLoader::makeInlineScript($javascript_text));
} else {
$wgParser->getOutput()->addHeadItem($script);
}
} else {
if (method_exists('ResourceLoader', 'makeInlineScript')) {
// MW 1.25+
$wgOut->addScript(ResourceLoader::makeInlineScript($javascript_text));
} else {
$wgOut->addScript($script);
}
$po = $wgParser->getOutput();
if ($po) {
// addParserOutputMetadata was introduced in 1.24 when addParserOutputNoText was deprecated
if (method_exists($wgOut, 'addParserOutputMetadata')) {
$wgOut->addParserOutputMetadata($po);
} else {
$wgOut->addParserOutputNoText($po);
}
}
}
// Finally, set the page title - previously, this had to be
// called after addParserOutputNoText() for it to take effect;
// now the order doesn't matter.
if (!$embedded) {
if ($form_page_title != null) {
$wgOut->setPageTitle($form_page_title);
} else {
$s = wfMessage('sf_runquery_title', $form_title->getText())->text();
$wgOut->setPageTitle($s);
}
}
}
示例3: printForm
//.........这里部分代码省略.........
} else {
if (!empty($targetName) && Title::newFromText($targetName)->exists()) {
// If target page exists, do not overwrite it with
// preload data; just preload the page's data.
$module->setOption('preload', true);
} else {
if ($req->getCheck('preload')) {
// if page does not exist and preload parameter is set, pass that on
$module->setOption('preload', $req->getText('preload'));
} else {
// nothing set, so do not set preload
}
}
}
$module->execute();
$text = '';
// if action was successful and action was a Save, return
if ($module->getStatus() === 200) {
if ($module->getAction() === SFAutoeditAPI::ACTION_SAVE) {
return;
}
} else {
$resultData = $module->getResultData();
if (array_key_exists('errors', $resultData)) {
foreach ($resultData['errors'] as $error) {
// FIXME: This should probably not be hard-coded to WARNING but put into a setting
if ($error['level'] <= SFAutoeditAPI::WARNING) {
$text .= Html::rawElement('p', array('class' => 'error'), $error['message']) . "\n";
}
}
}
}
// Override the default title for this page if a title was
// specified in the form.
$result = $module->getOptions();
$targetTitle = Title::newFromText($result['target']);
// Set page title depending on whether an explicit title was
// specified in the form definition.
if (array_key_exists('formtitle', $result)) {
// set page title depending on whether the target page exists
if (empty($targetName)) {
$pageTitle = $result['formtitle'];
} else {
$pageTitle = $result['formtitle'] . ': ' . $targetName;
}
} elseif ($result['form'] !== '') {
// Set page title depending on whether the target page
// exists.
if (empty($targetName)) {
$pageTitle = wfMessage('sf_formedit_createtitlenotarget', $result['form'])->text();
} elseif ($targetTitle->exists()) {
$pageTitle = wfMessage('sf_formedit_edittitle', $result['form'], $targetName)->text();
} else {
$pageTitle = wfMessage('sf_formedit_createtitle', $result['form'], $targetName)->text();
}
} elseif (count($alt_forms) > 0) {
// We use the 'creating' message here, instead of
// 'sf_formedit_createtitlenotarget', to differentiate
// between a page with no (default) form, and one with
// no target; in English they'll show up as
// "Creating ..." and "Create ...", respectively.
// Does this make any difference? Who knows.
$pageTitle = wfMessage('creating', $targetName)->text();
} elseif ($result['form'] == '') {
//FIXME: This looks weird; a simple else should be enough, right?
// display error message if the form is not specified in the URL
$pageTitle = wfMessage('formedit')->text();
$text .= Html::element('p', array('class' => 'error'), wfMessage('sf_formedit_badurl')->text()) . "\n";
$out->addHTML($text);
}
$out->setPageTitle($pageTitle);
if (count($alt_forms) > 0) {
$text .= '<div class="infoMessage">';
if ($result['form'] != '') {
$text .= wfMessage('sf_formedit_altforms')->escaped();
} else {
$text .= wfMessage('sf_formedit_altformsonly')->escaped();
}
$text .= ' ' . $this->printAltFormsList($alt_forms, $targetName);
$text .= "</div>\n";
}
$text .= '<form name="createbox" id="sfForm" method="post" class="createbox">';
$pre_form_html = '';
Hooks::run('sfHTMLBeforeForm', array(&$targetTitle, &$pre_form_html));
$text .= $pre_form_html;
if (isset($result['formHTML'])) {
$text .= $result['formHTML'];
}
SFUtils::addFormRLModules();
if (isset($result['formJS'])) {
if (method_exists('ResourceLoader', 'makeInlineScript')) {
// MW 1.25+
$out->addScript(ResourceLoader::makeInlineScript($result['formJS']));
} else {
$out->addScript(' <script type="text/javascript">' . "\n{$result['formJS']}\n" . '</script>' . "\n");
}
}
$out->addHTML($text);
return null;
}