r26219 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r26218‎ | r26219 | r26220 >
Date:17:55, 28 September 2007
Author:yaron
Status:old
Tags:
Comment:
Added Harold Solbrig's sffLinkText() replacement code (bug 11464), added
Sergey Chernyshev's code for handling blank/"main" namespace (bug 11379)
Modified paths:
  • /trunk/extensions/SemanticForms/includes/SF_GlobalFunctions.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticForms/includes/SF_GlobalFunctions.php
@@ -3,9 +3,10 @@
44 * Global functions and constants for Semantic Forms.
55 *
66 * @author Yaron Koren
 7+ * @author Harold Solbrig
78 */
89
9 -define('SF_VERSION','0.6.3');
 10+define('SF_VERSION','0.6.4');
1011
1112 $wgExtensionFunctions[] = 'sfgSetupExtension';
1213 $wgExtensionFunctions[] = 'sfgParserFunctions';
@@ -171,9 +172,16 @@
172173 * Creates HTML linking to a wiki page
173174 */
174175 function sffLinkText($namespace, $name, $text = NULL) {
175 - global $wgContLang;
176 - $iq = new SMWInlineQuery();
177 - return $iq->makeTitleString($wgContLang->getNsText($namespace) . ':' . $name, $text, true);
 176+ global $wgContLang;
 177+
 178+ $inText = $wgContLang->getNsText($namespace) . ':' . $name;
 179+ $title = Title::newFromText( $inText );
 180+ if ($title === NULL) {
 181+ return $inText; // TODO maybe report an error here?
 182+ }
 183+ if ( NULL === $text ) $text = $title->getText();
 184+ $l = new Linker();
 185+ return $l->makeLinkObj($title, $label);
178186 }
179187
180188 /**
@@ -243,7 +251,14 @@
244252 }
245253 // if that didn't work, check if this page's namespace
246254 // has a default form specified
247 - if ($add_data_link = sffGetAddDataLinkForPage($db, $title, $title->getNsText(), NS_PROJECT)) {
 255+ $namespace = $title->getNsText();
 256+ if ('' === $namespace) {
 257+ // if it's in the main (blank) namespace, check for
 258+ // the file named with the word for "Main" in this
 259+ // language
 260+ $namespace = wfMsgForContent('sf_blank_namespace');
 261+ }
 262+ if ($add_data_link = sffGetAddDataLinkForPage($db, $title, $namespace, NS_PROJECT)) {
248263 return $add_data_link;
249264 }
250265 // if nothing found still, return null

Follow-up revisions

RevisionCommit summaryAuthorDate
r26220Added 'sf_blank_namespace' content messge (bug 11379)yaron17:58, 28 September 2007

Status & tagging log