/** * Gets the set of all properties that point to this page, anywhere * in the wiki. */ static function getIncomingProperties($title) { $store = smwfGetStore(); // SMW 1.6+ if (class_exists('SMWDataItem')) { $value = SMWDIWikiPage::newFromTitle($title); } else { $title_text = SFUtils::titleString($title); $value = SMWDataValueFactory::newTypeIDValue('_wpg', $title_text); } $properties = $store->getInProperties($value); $propertyNames = array(); foreach ($properties as $property) { // SMW 1.6+ if ($property instanceof SMWDIProperty) { $property_name = $property->getKey(); } else { $property_name = $property->getWikiValue(); } if (!empty($property_name)) { $propertyNames[] = $property_name; } } return $propertyNames; }
protected function showContentForm() { $target_title = $this->mArticle->getTitle(); $target_name = SFUtils::titleString($target_title); if ($target_title->exists()) { SFEditData::printEditForm($this->form_name, $target_name, $this->textbox1); } else { SFAddData::printAddForm($this->form_name, $target_name, array(), $this->textbox1); } // @todo This needs a proper form builder }
/** * Helper function for formEditLink() - gets the 'default form' and * 'alternate form' properties for a page, and creates the * corresponding Special:FormEdit link, if any such properties are * defined */ static function getFormEditLinkForPage($target_page_title, $page_name, $page_namespace) { $default_forms = self::getFormsThatPagePointsTo($page_name, $page_namespace, self::DEFAULT_FORM); $alt_forms = self::getFormsThatPagePointsTo($page_name, $page_namespace, self::ALTERNATE_FORM); if (count($default_forms) == 0 && count($alt_forms) == 0) { return null; } $fe = SpecialPageFactory::getPage('FormEdit'); $fe_url = $fe->getTitle()->getLocalURL(); if (count($default_forms) > 0) { $form_edit_url = $fe_url . "/" . $default_forms[0] . "/" . SFUtils::titleURLString($target_page_title); } else { $form_edit_url = $fe_url; $form_edit_url .= strpos($form_edit_url, "?") ? "&" : "?"; $form_edit_url .= 'target=' . urlencode(SFUtils::titleString($target_page_title)); } foreach ($alt_forms as $i => $alt_form) { $form_edit_url .= strpos($form_edit_url, "?") ? "&" : "?"; $form_edit_url .= "alt_form[{$i}]={$alt_form}"; } // Add "redlink=1" to the query string, so that the user will // go to the actual page if it now exists. $form_edit_url .= strpos($form_edit_url, "?") ? "&" : "?"; $form_edit_url .= "redlink=1"; return $form_edit_url; }
/** * 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) { // @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; } $output = $action->getOutput(); if (count($form_names) > 1) { $warning_text = "\t" . '<div class="warningbox">' . wfMessage('sf_formedit_morethanoneform')->text() . "</div>\n"; $output->addWikiText($warning_text); } $form_name = $form_names[0]; $page_name = SFUtils::titleString($title); SFFormEdit::printForm($form_name, $page_name); return false; }
/** * The function called if we're in index.php (as opposed to one of the * special pages) */ static function displayForm($action, $article) { $output = $action->getOutput(); $title = $article->getTitle(); $form_names = SFFormLinker::getDefaultFormsForPage($title); if (count($form_names) == 0) { // If no form is set, display an interface to let the // user choose out of all the forms defined on this wiki // (or none at all). self::displayFormChooser($output, $title); return true; } if (count($form_names) > 1) { $warning_text = "\t" . '<div class="warningbox">' . wfMessage('sf_formedit_morethanoneform')->text() . "</div>\n"; $output->addWikiText($warning_text); } $form_name = $form_names[0]; $page_name = SFUtils::titleString($title); $sfFormEdit = new SFFormEdit(); $sfFormEdit->printForm($form_name, $page_name); return false; }
/** * The function called if we're in index.php (as opposed to one of the * special pages) */ static function displayForm($action, $article) { // 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">' . wfMessage('sf_formedit_morethanoneform')->text() . "</div>\n"; $output->addWikiText($warning_text); } $form_name = $form_names[0]; $page_name = SFUtils::titleString($title); SFFormEdit::printForm($form_name, $page_name); 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; }