function creationHTML($template_num) { $field_form_text = $template_num . "_" . $this->mNum; $template_field = $this->template_field; $text = '<h3>' . wfMessage('sf_createform_field')->escaped() . " '" . $template_field->getFieldName() . "'</h3>\n"; $prop_link_text = SFUtils::linkText(SMW_NS_PROPERTY, $template_field->getSemanticProperty()); // TODO - remove this probably-unnecessary check? if ($template_field->getSemanticProperty() == "") { // Print nothing if there's no semantic property. } elseif ($template_field->getPropertyType() == "") { $text .= '<p>' . wfMessage('sf_createform_fieldpropunknowntype', $prop_link_text)->parseAsBlock() . "</p>\n"; } else { if ($template_field->isList()) { $propDisplayMsg = 'sf_createform_fieldproplist'; } else { $propDisplayMsg = 'sf_createform_fieldprop'; } // Get the display label for this property type. global $smwgContLang; $propertyTypeStr = ''; if ($smwgContLang != null) { $datatypeLabels = $smwgContLang->getDatatypeLabels(); $datatypeLabels['enumeration'] = 'enumeration'; $propTypeID = $template_field->getPropertyType(); // Special handling for SMW 1.9 if ($propTypeID == '_str' && !array_key_exists('_str', $datatypeLabels)) { $propTypeID = '_txt'; } $propertyTypeStr = $datatypeLabels[$propTypeID]; } $text .= Html::rawElement('p', null, wfMessage($propDisplayMsg, $prop_link_text, $propertyTypeStr)->parse()) . "\n"; } // If it's not a semantic field - don't add any text. $form_label_text = wfMessage('sf_createform_formlabel')->text(); $form_label_input = Html::input('label_' . $field_form_text, $template_field->getLabel(), 'text', array('size' => 20)); $input_type_text = wfMessage('sf_createform_inputtype')->escaped(); $text .= <<<END \t<div class="formField"> \t<p>{$form_label_text} {$form_label_input} \t  {$input_type_text} END; global $sfgFormPrinter; if (is_null($template_field->getPropertyType())) { $default_input_type = null; $possible_input_types = $sfgFormPrinter->getAllInputTypes(); } else { $default_input_type = $sfgFormPrinter->getDefaultInputType($template_field->isList(), $template_field->getPropertyType()); $possible_input_types = $sfgFormPrinter->getPossibleInputTypes($template_field->isList(), $template_field->getPropertyType()); } $text .= $this->inputTypeDropdownHTML($field_form_text, $default_input_type, $possible_input_types, $template_field->getInputType()); if (!is_null($template_field->getInputType())) { $cur_input_type = $template_field->getInputType(); } elseif (!is_null($default_input_type)) { $cur_input_type = $default_input_type; } else { $cur_input_type = $possible_input_types[0]; } global $wgRequest; $paramValues = array(); foreach ($wgRequest->getValues() as $key => $value) { if (($pos = strpos($key, '_' . $field_form_text)) != false) { $paramName = substr($key, 0, $pos); // Spaces got replaced by underlines in the // query. $paramName = str_replace('_', ' ', $paramName); $paramValues[$paramName] = $value; } } $other_param_text = wfMessage('sf_createform_otherparameters')->escaped(); $text .= "<fieldset class=\"sfCollapsibleFieldset\"><legend>{$other_param_text}</legend>\n"; $text .= Html::rawElement('div', array('class' => 'otherInputParams'), SFCreateForm::showInputTypeOptions($cur_input_type, $field_form_text, $paramValues)) . "\n"; $text .= "</fieldset>\n"; $text .= <<<END \t</p> \t</div> \t<hr> END; return $text; }
function formatResult($skin, $result) { $title = Title::makeTitle(NS_TEMPLATE, $result->value); $text = Linker::link($title, htmlspecialchars($title->getText())); $category = $this->getCategoryDefinedByTemplate($title); if ($category !== '') { $text .= ' ' . wfMessage('sf_templates_definescat', SFUtils::linkText(NS_CATEGORY, $category))->parse(); } return $text; }
function printPage($form_name, $embedded = false) { global $wgOut, $wgRequest, $sfgFormPrinter, $wgParser, $sfgRunQueryFormAtTop; global $wgUser; // Get contents of form-definition page. $form_title = Title::makeTitleSafe(SF_NS_FORM, $form_name); if (!$form_title || !$form_title->exists()) { if ($form_name === '') { $text = Html::element('p', array('class' => 'error'), wfMessage('sf_runquery_badurl')->text()) . "\n"; } else { $text = Html::rawElement('p', array('class' => 'error'), wfMessage('sf_formstart_badform', SFUtils::linkText(SF_NS_FORM, $form_name))->parse()) . "\n"; } $wgOut->addHTML($text); return; } // Initialize variables. $form_definition = SFUtils::getPageText($form_title); if ($embedded) { $run_query = false; $content = null; $raw = false; } else { $run_query = $wgRequest->getCheck('wpRunQuery'); $content = $wgRequest->getVal('wpTextbox1'); $raw = $wgRequest->getBool('raw', false); } $form_submitted = $run_query; if ($raw) { $wgOut->setArticleBodyOnly(true); } // If user already made some action, ignore the edited // page and just get data from the query string. if (!$embedded && $wgRequest->getVal('query') == 'true') { $edit_content = null; $is_text_source = false; } elseif ($content != null) { $edit_content = $content; $is_text_source = true; } else { $edit_content = null; $is_text_source = true; } list($form_text, $javascript_text, $data_text, $form_page_title) = $sfgFormPrinter->formHTML($form_definition, $form_submitted, $is_text_source, $form_title->getArticleID(), $edit_content, null, null, true, $embedded); $text = ""; // 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); } } }
static function printForm(&$form_name, &$target_name, $alt_forms = array(), $redirectOnError = false) { global $wgOut, $wgRequest, $wgUser, $sfgFormPrinter; // initialize some variables $target_title = null; $page_name_formula = null; $form_title = Title::makeTitleSafe(SF_NS_FORM, $form_name); // If the given form is not a valid title, bail out. if (!$form_title) { return 'sf_formedit_badurl'; } $form_article = new Article($form_title, 0); $form_definition = $form_article->getContent(); // If the form page is a redirect, use the other form // instead. if ($form_title->isRedirect()) { $form_title = Title::newFromRedirectRecurse($form_definition); $form_article = new Article($form_title, 0); $form_definition = $form_article->getContent(); } $form_definition = StringUtils::delimiterReplace('<noinclude>', '</noinclude>', '', $form_definition); if (is_null($target_name)) { $target_name = ''; } if ($target_name === '') { // parse the form to see if it has a 'page name' value set $matches; if (preg_match('/{{{info.*page name\\s*=\\s*(.*)}}}/m', $form_definition, $matches)) { $page_name_elements = SFUtils::getFormTagComponents($matches[1]); $page_name_formula = $page_name_elements[0]; } elseif (count($alt_forms) == 0) { return 'sf_formedit_badurl'; } } else { $target_title = Title::newFromText($target_name); if ($target_title && $target_title->exists()) { if ($wgRequest->getVal('query') == 'true') { $page_contents = null; //$page_is_source = false; } else { // If page already exists and 'redlink' // is in the query string, redirect to // the actual page, just like // MediaWiki does it. if ($wgRequest->getBool('redlink')) { $wgOut->redirect($target_title->getFullURL()); wfProfileOut(__METHOD__); return; } $target_article = new Article($target_title, 0); $page_contents = $target_article->getContent(); //$page_is_source = true; } } else { $target_name = str_replace('_', ' ', $target_name); } } if (!$form_title || !$form_title->exists()) { if (count($alt_forms) > 0) { $text = '<div class="infoMessage">' . wfMsg('sf_formedit_altformsonly') . ' ' . self::printAltFormsList($alt_forms, $form_name) . "</div>\n"; } else { $text = Html::rawElement('p', array('class' => 'error'), wfMsgExt('sf_formstart_badform', 'parseinline', SFUtils::linkText(SF_NS_FORM, $form_name))) . "\n"; } } elseif ($target_name === '' && $page_name_formula === '') { $text = Html::element('p', array('class' => 'error'), wfMsg('sf_formedit_badurl')) . "\n"; } else { $save_page = $wgRequest->getCheck('wpSave'); $preview_page = $wgRequest->getCheck('wpPreview'); $diff_page = $wgRequest->getCheck('wpDiff'); $form_submitted = $save_page || $preview_page || $diff_page; // get 'preload' query value, if it exists if (!$form_submitted) { if ($wgRequest->getCheck('preload')) { $page_is_source = true; $page_contents = SFFormUtils::getPreloadedText($wgRequest->getVal('preload')); } else { // let other extensions preload the page, if they want wfRunHooks('sfEditFormPreloadText', array(&$page_contents, $target_title, $form_title)); $page_is_source = $page_contents != null; } } else { $page_is_source = false; $page_contents = null; } list($form_text, $javascript_text, $data_text, $form_page_title, $generated_page_name) = $sfgFormPrinter->formHTML($form_definition, $form_submitted, $page_is_source, $form_article->getID(), $page_contents, $target_name, $page_name_formula); // Before we do anything else, set the form header // title - this needs to be done after formHTML() is // called, because otherwise it doesn't take hold // for some reason if the form is disabled. if (empty($target_title)) { $s = wfMsg('sf_formedit_createtitlenotarget', $form_title->getText()); } elseif ($target_title->exists()) { $s = wfMsg('sf_formedit_edittitle', $form_title->getText(), $target_title->getPrefixedText()); } else { $s = wfMsg('sf_formedit_createtitle', $form_title->getText(), $target_title->getPrefixedText()); } $wgOut->setPageTitle($s); if ($form_submitted) { if (!is_null($page_name_formula) && $page_name_formula !== '') { $target_name = $generated_page_name; // prepend a super-page, if one was specified if ($wgRequest->getCheck('super_page')) { $target_name = $wgRequest->getVal('super_page') . '/' . $target_name; } // prepend a namespace, if one was specified if ($wgRequest->getCheck('namespace')) { $target_name = $wgRequest->getVal('namespace') . ':' . $target_name; } // replace "unique number" tag with one // that won't get erased by the next line $target_name = preg_replace('/<unique number(.*)>/', '{num\\1}', $target_name, 1); // if any formula stuff is still in the // name after the parsing, just remove it $target_name = StringUtils::delimiterReplace('<', '>', '', $target_name); // now run the parser on it global $wgParser; // ...but first, replace spaces back // with underlines, in case a magic word // or parser function name contains // underlines - hopefully this won't // cause problems of its own $target_name = str_replace(' ', '_', $target_name); $target_name = $wgParser->preprocess($target_name, $wgOut->getTitle(), ParserOptions::newFromUser(null)); $title_number = ""; $isRandom = false; $randomNumHasPadding = false; $randomNumDigits = 6; if (strpos($target_name, '{num') !== false) { // Random number if (preg_match('/{num;random(;(0)?([1-9][0-9]*))?}/', $target_name, $matches)) { $isRandom = true; $randomNumHasPadding = array_key_exists(2, $matches); $randomNumDigits = array_key_exists(3, $matches) ? $matches[3] : $randomNumDigits; $title_number = self::makeRandomNumber($randomNumDigits, $randomNumHasPadding); } else { // get unique number start value // from target name; if it's not // there, or it's not a positive // number, start it out as blank preg_match('/{num.*start[_]*=[_]*([^;]*).*}/', $target_name, $matches); if (count($matches) == 2 && is_numeric($matches[1]) && $matches[1] >= 0) { // the "start" value" $title_number = $matches[1]; } } // set target title $target_title = Title::newFromText(preg_replace('/{num.*}/', $title_number, $target_name)); // if title exists already // cycle through numbers for // this tag until we find one // that gives a nonexistent page // title while ($target_title->exists()) { if ($isRandom) { $title_number = self::makeRandomNumber($randomNumDigits, $randomNumHasPadding); } elseif ($title_number == "") { $title_number = 2; } else { $title_number = str_pad($title_number + 1, strlen($title_number), '0', STR_PAD_LEFT); } $target_title = Title::newFromText(preg_replace('/{num.*}/', $title_number, $target_name)); } $target_name = $target_title->getPrefixedText(); } else { $target_title = Title::newFromText($target_name); } } if (is_null($target_title)) { if ($target_name) { return array('sf_formstart_badtitle', array($target_name)); } else { return 'sf_formedit_emptytitle'; } } if ($save_page) { $permErrors = $target_title->getUserPermissionsErrors('edit', $wgUser); if ($permErrors) { // just return the first error and let them fix it one by one return array_shift($permErrors); } // Set up all the variables for the // page save. $data = array('wpTextbox1' => $data_text, 'wpSummary' => $wgRequest->getVal('wpSummary'), 'wpStarttime' => $wgRequest->getVal('wpStarttime'), 'wpEdittime' => $wgRequest->getVal('wpEdittime'), 'wpEditToken' => $wgUser->isLoggedIn() ? $wgUser->editToken() : EDIT_TOKEN_SUFFIX, 'wpSave' => '', 'action' => 'submit'); if ($wgRequest->getCheck('wpMinoredit')) { $data['wpMinoredit'] = true; } if ($wgRequest->getCheck('wpWatchthis')) { $data['wpWatchthis'] = true; } $request = new FauxRequest($data, true); // Find existing article if it exists, // or create a new one. $article = new Article($target_title, 0); $editor = new EditPage($article); $editor->importFormData($request); // Try to save the page! $resultDetails = array(); $saveResult = $editor->internalAttemptSave($resultDetails); // Return value was made an object in MW 1.19 if (is_object($saveResult)) { $saveResultCode = $saveResult->value; } else { $saveResultCode = $saveResult; } if (($saveResultCode == EditPage::AS_HOOK_ERROR || $saveResultCode == EditPage::AS_HOOK_ERROR_EXPECTED) && $redirectOnError) { $wgOut->clearHTML(); $wgOut->setArticleBodyOnly(true); // Lets other code process additional form-definition syntax wfRunHooks('sfWritePageData', array($form_name, $target_title, &$data_text)); $text = SFUtils::printRedirectForm($target_title, $data_text, $wgRequest->getVal('wpSummary'), $save_page, $preview_page, $diff_page, $wgRequest->getCheck('wpMinoredit'), $wgRequest->getCheck('wpWatchthis'), $wgRequest->getVal('wpStarttime'), $wgRequest->getVal('wpEdittime')); } else { if ($saveResultCode == EditPage::AS_SUCCESS_UPDATE || $saveResultCode == EditPage::AS_SUCCESS_NEW_ARTICLE) { $wgOut->redirect($target_title->getFullURL()); } return SFUtils::processEditErrors($saveResultCode); } } else { // Lets other code process additional form-definition syntax wfRunHooks('sfWritePageData', array($form_name, $target_title, &$data_text)); $text = SFUtils::printRedirectForm($target_title, $data_text, $wgRequest->getVal('wpSummary'), $save_page, $preview_page, $diff_page, $wgRequest->getCheck('wpMinoredit'), $wgRequest->getCheck('wpWatchthis'), $wgRequest->getVal('wpStarttime'), $wgRequest->getVal('wpEdittime')); // extract its data } } else { // override the default title for this page if // a title was specified in the form if ($form_page_title != null) { if ($target_name === '') { $wgOut->setPageTitle($form_page_title); } else { $wgOut->setPageTitle("{$form_page_title}: {$target_title->getPrefixedText()}"); } } $text = ""; if (count($alt_forms) > 0) { $text .= '<div class="infoMessage">' . wfMsg('sf_formedit_altforms') . ' '; $text .= self::printAltFormsList($alt_forms, $target_name); $text .= "</div>\n"; } $text .= '<form name="createbox" id="sfForm" method="post" class="createbox">'; $pre_form_html = ''; wfRunHooks('sfHTMLBeforeForm', array(&$target_title, &$pre_form_html)); $text .= $pre_form_html; $text .= $form_text; } } SFUtils::addJavascriptAndCSS(); if (!empty($javascript_text)) { $wgOut->addScript(' <script type="text/javascript">' . "\n{$javascript_text}\n" . '</script>' . "\n"); } $wgOut->addHTML($text); return null; }
function execute($query) { global $wgOut, $wgRequest; $this->setHeaders(); $form_name = $wgRequest->getVal('form'); $target_namespace = $wgRequest->getVal('namespace'); $super_page = $wgRequest->getVal('super_page'); $params = $wgRequest->getVal('params'); // If the query string did not contain a form name, try the URL if (!$form_name) { $queryparts = explode('/', $query, 2); $form_name = isset($queryparts[0]) ? $queryparts[0] : ''; // If a target was specified, it means we should // redirect to 'FormEdit' for this target page. if (isset($queryparts[1])) { $target_name = $queryparts[1]; $this->doRedirect($form_name, $target_name, $params); } // Get namespace from the URL, if it's there. if ($namespace_label_loc = strpos($form_name, "/Namespace:")) { $target_namespace = substr($form_name, $namespace_label_loc + 11); $form_name = substr($form_name, 0, $namespace_label_loc); } } // Remove forbidden characters from the form name. $forbidden_chars = array('"', "'", '<', '>', '{', '}', '(', ')', '[', ']', '='); $form_name = str_replace($forbidden_chars, "", $form_name); // Get title of form. $form_title = Title::makeTitleSafe(SF_NS_FORM, $form_name); // Handle submission of this form. $form_submitted = $wgRequest->getCheck('page_name'); if ($form_submitted) { $page_name = $wgRequest->getVal('page_name'); // This form can be used to create a sub-page for an // existing page if (!is_null($super_page) && $super_page !== '') { $page_name = "{$super_page}/{$page_name}"; } if ($page_name !== '') { // Append the namespace prefix to the page name, // if this namespace was not already entered. if (strpos($page_name, $target_namespace . ':') === false && !is_null($target_namespace)) { $page_name = $target_namespace . ':' . $page_name; } // If there was no page title, it's probably an // invalid page name, containing forbidden // characters - in that case, display an error // message. $page_title = Title::newFromText($page_name); if (!$page_title) { $wgOut->addHTML(htmlspecialchars(wfMsg('sf_formstart_badtitle', $page_name))); return; } else { $this->doRedirect($form_name, $page_name, $params); return; } } } if ((!$form_title || !$form_title->exists()) && $form_name !== '') { $text = Html::rawElement('p', array('class' => 'error'), wfMsgExt('sf_formstart_badform', 'parseinline', SFUtils::linkText(SF_NS_FORM, $form_name))) . "\n"; } else { if ($form_name === '') { $description = htmlspecialchars(wfMsg('sf_formstart_noform_docu', $form_name)); } else { $description = htmlspecialchars(wfMsg('sf_formstart_docu', $form_name)); } $text = <<<END \t<form action="" method="post"> \t<p>{$description}</p> \t<p><input type="text" size="40" name="page_name" /> END; // If no form was specified, display a dropdown letting // the user choose the form. if ($form_name === '') { $text .= SFUtils::formDropdownHTML(); } $text .= "\t</p>\n"; $text .= Html::hidden('namespace', $target_namespace); $text .= Html::hidden('super_page', $super_page); $text .= Html::hidden('params', $params); $text .= "\n\t" . Html::input(null, wfMsg('sf_formstart_createoredit'), 'submit') . "\n"; $text .= "\t</form>\n"; } $wgOut->addHTML($text); }
/** * Print the edit form. Mostly copied from the SemanticForms extension * SF_FormEdit.php but simplyfied to the requirements. No page is supposed * to be modified. When submiting the form, javascript is added that reads * the actual data for the form and adds them for the template call. The * page never does a redirect but calls itself again. Buttons for preview * and show changes as well as checkboxes are removed as they are not needed. * * @param string form name * @param string target name (i.e. page name) * @param string content whih is page content (optional, default null) */ static function printEditForm($form_name, $target_name, $content = null) { global $wgOut, $wgRequest, $wgScriptPath, $sfgScriptPath, $sfgFormPrinter, $sfgYUIBase; // within the popup of the FCK, don't load another FCK for text fields global $wgFCKEditorDir; $original_wgFCKEditorDir = $wgFCKEditorDir; $wgFCKEditorDir = null; wfLoadExtensionMessages('SemanticForms'); $javascript_text = ""; // get contents of form definition file $form_title = Title::makeTitleSafe(SF_NS_FORM, $form_name); // get contents of target page $target_title = Title::newFromText($target_name); // typical handling to check, if we know that we have a form and a target if (!$form_title || !$form_title->exists()) { if ($form_name == '') { $text = '<p class="error">' . wfMsg('sf_editdata_badurl') . "</p>\n"; } else { $text = '<p class="error">Error: No form page was found at ' . SFUtils::linkText(SF_NS_FORM, $form_name) . ".</p>\n"; } } elseif (!$target_title || !$target_title->exists()) { if ($target_name == '') { $text = '<p class="error">' . wfMsg('sf_editdata_badurl') . "</p>\n"; } else { $text = '<p class="error">Error: No page was found at ' . SFUtils::linkText(null, $target_name) . ".</p>\n"; } } else { $s = wfMsg('sf_editdata_title', $form_title->getText(), $target_title->getPrefixedText()); $wgOut->setPageTitle($s); $form_article = new Article($form_title); $form_definition = $form_article->getContent(); $page_title = str_replace('_', ' ', $target_name); // if user already made some action, ignore the edited page // and just get data from the query string if ($wgRequest->getVal('query') == 'true') { $edit_content = null; $is_text_source = false; } elseif ($content != null) { $edit_content = $content; $is_text_source = true; } else { $target_article = new Article($target_title); $edit_content = $target_article->getContent(); $is_text_source = true; } // the form is never submited (we need the Javascript at onsubmit only) // therefore set the submit to false, this will dispay the form always // like we will see it when calling it for the first time $form_submitted = false; list($form_text, $javascript_text, $data_text, $form_page_title) = $sfgFormPrinter->formHTML($form_definition, $form_submitted, $is_text_source, $edit_content, $page_title); // override the default title for this page if // a title was specified in the form if ($form_page_title != NULL) { $wgOut->setPageTitle("{$form_page_title}: {$target_title->getPrefixedText()}"); } // remove preview and diff buttons and checkboxes for minor edit // and watch this page self::removeButtonsAndLinksFromPage($form_text); $text = <<<END <form name="createbox" onsubmit="return validate_all_and_save();" action="" method="post" class="createbox"> \t<input type="hidden" name="query" value="true" /> END; $text .= $form_text; // add extra javascript that reads form data and fills the // template popup in the FCK $javascript_text .= self::getFckTemplatePopupJavascript(); } // add javascript and css to the page header SFUtils::addJavascriptAndCSS(); $wgOut->addScript(' <script type="text/javascript">' . "\n" . $javascript_text . '</script>' . "\n"); $wgOut->addHTML($text); // set the $wgFCKEditorDir again to the original (maybe not needed) $wgFCKEditorDir = $original_wgFCKEditorDir; }