r28514 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r28513‎ | r28514 | r28515 >
Date:14:25, 15 December 2007
Author:tlaqua
Status:old
Tags:
Comment:
Simplified #phpbblink syntax. Still only supports topic linking atm.
Modified paths:
  • /trunk/extensions/phpbbData/phpbbData.php (modified) (history)

Diff [purge]

Index: trunk/extensions/phpbbData/phpbbData.php
@@ -49,11 +49,19 @@
5050 return true;
5151 }
5252
53 -function efPhpbbData_makeTopicWikiLink($display_text, $forum_id, $topic_id) {
 53+function efPhpbbData_makeTopicWikiLink($display_text='', $forum_id=null, $topic_id=null, $post_id=null) {
5454 global $wgPhpbbDataRootPath;
5555
56 - $urlText = "https://" . $_SERVER['SERVER_ADDR'] .
57 - "/{$wgPhpbbDataRootPath}viewtopic.php?f={$forum_id}&t={$topic_id}";
 56+ if (!empty($post_id)) {
 57+ $urlText = "https://" . $_SERVER['SERVER_ADDR'] .
 58+ "/{$wgPhpbbDataRootPath}viewpost.php?p={$post_id}";
 59+ } elseif (!empty($topic_id)) {
 60+ $urlText = "https://" . $_SERVER['SERVER_ADDR'] .
 61+ "/{$wgPhpbbDataRootPath}viewtopic.php?t={$topic_id}";
 62+ } elseif (!empty($forum_id)) {
 63+ $urlText = "https://" . $_SERVER['SERVER_ADDR'] .
 64+ "/{$wgPhpbbDataRootPath}viewforum.php?t={$forum_id}";
 65+ }
5866
5967 if ($display_text != '')
6068 $display_text = ' ' . $display_text;
@@ -63,27 +71,17 @@
6472 return "<span class='plainlinks'>[{$urlText}{$display_text}]</span>";
6573 }
6674
67 -function efPhpbbData_RenderLink( &$parser, $linktype, $options='none', $text='') {
68 - $optsTemp = explode(',', $options);
69 - $opts = array();
 75+function efPhpbbData_RenderLink( &$parser, $linktype, $id, $text='', $options = 'none') {
7076
71 - foreach ($optsTemp as $opt) {
72 - $optArr = explode('=',$opt);
73 - if (isset($optArr[1])) {
74 - $opts[$optArr[0]] = $optArr[1];
75 - }
76 - }
77 -
7877 switch ($linktype) {
7978 case 'topic':
80 - if ( isset($opts['forum']) && isset($opts['topic'] ) ) {
81 - $fid = intval($opts['forum']);
82 - $tid = intval($opts['topic']);
 79+ if ( isset($id) ) {
 80+ $id = intval($id);
8381 $text = htmlspecialchars($text);
8482
85 - return efPhpbbData_makeTopicWikiLink($text, $fid, $tid);
 83+ return efPhpbbData_makeTopicWikiLink($text, null, $id);
8684 } else {
87 - return "Bad options";
 85+ return "Bad ID";
8886 }
8987 break;
9088 default:

Status & tagging log