/** * The function called if we're in index.php (as opposed to one of the * special pages) */ static function displayForm($action, $article) { global $wgOut, $sfgUseFormEditPage; // return "true" if the call failed (meaning, pass on handling // of the hook to others), and "false" otherwise if ($action != 'formedit') { return true; } // @todo: This looks like bad code. If we can't find a form, we // should be showing an informative error page rather than // making it look like an edit form page does not exist. $title = $article->getTitle(); $form_names = SFFormLinker::getDefaultFormsForPage($title); if (count($form_names) == 0) { return true; } if (count($form_names) > 1) { $warning_text = "\t" . '<div class="warningMessage">' . wfMsg('sf_formedit_morethanoneform') . "</div>\n"; $wgOut->addHTML($warning_text); } $form_name = $form_names[0]; if ($sfgUseFormEditPage) { # Experimental new feature extending from the internal # EditPage class $editor = new SFFormEditPage($article, $form_name); $editor->edit(); return false; } $page_name = SFUtils::titleString($title); $msg = SFFormEdit::printForm($form_name, $page_name); if ($msg) { // Some error occurred - display it. $msgdata = null; if (is_array($msg)) { if (count($msg) > 1) { $msgdata = $msg[1]; } $msg = $msg[0]; } $wgOut->addHTML(Html::element('p', array('class' => 'error'), wfMsg($msg, $msgdata))); } return false; }
/** * The function called if we're in index.php (as opposed to one of the * special pages) */ static function displayForm($action, $article) { global $sfgUseFormEditPage; // TODO: This function will be called as a hook handler and $action will // be a string before MW 1.18. From 1.18 onwards this function will# // only be called for formedit actions, i.e. the if statement can be // removed then. // return "true" if the call failed (meaning, pass on handling // of the hook to others), and "false" otherwise if (is_string($action) && $action !== 'formedit') { return true; } // @todo: This looks like bad code. If we can't find a form, we // should be showing an informative error page rather than // making it look like an edit form page does not exist. $title = $article->getTitle(); $form_names = SFFormLinker::getDefaultFormsForPage($title); if (count($form_names) == 0) { return true; } // For backward-compatibility if (is_string($action)) { global $wgOut; $output = $wgOut; } else { $output = $action->getOutput(); } if (count($form_names) > 1) { $warning_text = "\t" . '<div class="warningbox">' . wfMsg('sf_formedit_morethanoneform') . "</div>\n"; $output->addWikiText($warning_text); } $form_name = $form_names[0]; if ($sfgUseFormEditPage) { # Experimental new feature extending from the internal # EditPage class $editor = new SFFormEditPage($article, $form_name); $editor->edit(); return false; } $page_name = SFUtils::titleString($title); $msg = SFFormEdit::printForm($form_name, $page_name); if ($msg) { // Some error occurred - display it. $msgdata = null; if (is_array($msg)) { if (count($msg) > 1) { $msgdata = $msg[1]; } $msg = $msg[0]; } $output->addHTML(Html::element('p', array('class' => 'error'), wfMsg($msg, $msgdata))); } return false; }