Index: trunk/extensions/phpbbData/hook_handleFromWikiQuery.php |
— | — | @@ -1,5 +1,11 @@ |
2 | 2 | <?php |
3 | | -function efPhpbbData_handleToWiki(&$hooks, $outputCache) { |
| 3 | + |
| 4 | +function efPhpbbData_handleToWiki(&$hook, $outputCache) { |
| 5 | + $result = $hook->previous_hook_result('BeforePageDisplay'); |
| 6 | + if (!empty($result['result'])) { |
| 7 | + $outputCache = $result['result']; |
| 8 | + } |
| 9 | + |
4 | 10 | if ( isset( $_REQUEST['toWiki'] ) ) { |
5 | 11 | |
6 | 12 | $domDoc = new DOMDocument(); |
— | — | @@ -29,12 +35,17 @@ |
30 | 36 | |
31 | 37 | return $domDoc->saveHTML(); |
32 | 38 | } else { |
33 | | - return false; |
| 39 | + return $outputCache; |
34 | 40 | } |
35 | 41 | } |
36 | 42 | $phpbb_hook->register('BeforePageDisplay', 'efPhpbbData_handleToWiki'); |
37 | 43 | |
38 | | -function efPhpbbData_doTokenReplacement(&$hooks, $outputCache) { |
| 44 | +function efPhpbbData_doTokenReplacement(&$hook, $outputCache) { |
| 45 | + $result = $hook->previous_hook_result('BeforePageDisplay'); |
| 46 | + if (!empty($result['result'])) { |
| 47 | + $outputCache = $result['result']; |
| 48 | + } |
| 49 | + |
39 | 50 | $validQueryKeys = array('f','t'); |
40 | 51 | $queryString = ''; |
41 | 52 | |
— | — | @@ -48,7 +59,9 @@ |
49 | 60 | } |
50 | 61 | |
51 | 62 | $tokens = array( |
52 | | - '{PAGE_URL_LOCAL_ESCAPED}' => urlencode( $_SERVER['PHP_SELF'] . $queryString ) ); |
| 63 | + '{PAGE_URL_LOCAL_ESCAPED}' => urlencode( $_SERVER['PHP_SELF'] . $queryString ), |
| 64 | + urlencode('{PAGE_URL_LOCAL_ESCAPED}') => urlencode( $_SERVER['PHP_SELF'] . $queryString ), |
| 65 | + ); |
53 | 66 | |
54 | 67 | foreach ($tokens as $key => $value) { |
55 | 68 | $outputCache = str_replace($key,$value,$outputCache); |
Index: trunk/extensions/phpbbData/hook_!OutputBufferHook.php |
— | — | @@ -1,25 +1,32 @@ |
2 | 2 | <?php |
| 3 | +class OutputBufferHook { |
| 4 | + function hookTemplateDisplay(&$hook, $handle, $include_once = true) { |
| 5 | + $result = $hook->previous_hook_result(array('template', 'display')); |
3 | 6 | |
4 | | -class OutputBufferHook { |
5 | | - function hookTemplateDisplay(&$hooks, $handle, $include_once = true) { |
6 | 7 | ob_start(); |
| 8 | + return $result['result']; |
7 | 9 | } |
8 | 10 | |
9 | | - function hookExitHandler(&$hooks) { |
| 11 | + function hookExitHandler(&$hook) { |
10 | 12 | $outputCache = ob_get_contents(); |
11 | 13 | ob_end_clean(); |
12 | 14 | |
| 15 | + $result = $hook->previous_hook_result('exit_handler'); |
| 16 | + |
13 | 17 | global $phpbb_hook; |
14 | | - if ( !empty($phpbb_hook) && $phpbb_hook->call_hook('BeforePageDisplay', $outputCache) ) { |
15 | | - if ($phpbb_hook->hook_return('BeforePageDisplay')) { |
16 | | - $hookReturn = $phpbb_hook->hook_return_result('BeforePageDisplay'); |
| 18 | + if ( !empty($hook) && $hook->call_hook('BeforePageDisplay', $outputCache) ) { |
| 19 | + if ($hook->hook_return('BeforePageDisplay')) { |
| 20 | + $hookReturn = $hook->hook_return_result('BeforePageDisplay'); |
17 | 21 | if ($hookReturn) { |
| 22 | + //return $hookReturn; |
18 | 23 | $outputCache = $hookReturn; |
19 | 24 | } |
20 | 25 | } |
21 | 26 | } |
22 | 27 | |
23 | 28 | eval(' ?>' . $outputCache . '<?php '); |
| 29 | + |
| 30 | + return $result['result']; |
24 | 31 | } |
25 | 32 | } |
26 | 33 | |
Index: trunk/extensions/phpbbData/phpbbData.php |
— | — | @@ -20,7 +20,8 @@ |
21 | 21 | ); |
22 | 22 | |
23 | 23 | $wgExtensionFunctions[] = 'efPhpbbData_Setup'; |
24 | | -$wgHooks['LanguageGetMagic'][] = 'efPhpbbData_LanguageGetMagic'; |
| 24 | +$wgHooks['LanguageGetMagic' ][] = 'efPhpbbData_LanguageGetMagic'; |
| 25 | +$wgHooks['BeforePageDisplay'][] = 'efPhpbbData_BeforePageDisplay'; |
25 | 26 | |
26 | 27 | function efPhpbbData_Setup() { |
27 | 28 | global $wgParser, $wgMessageCache; |
— | — | @@ -38,6 +39,32 @@ |
39 | 40 | return true; |
40 | 41 | } |
41 | 42 | |
| 43 | +function efPhpbbData_BeforePageDisplay(&$out) { |
| 44 | + global $wgRequest; |
| 45 | + |
| 46 | + # Check for toForum query string argument |
| 47 | + if ($wgRequest->getText('toForum')) { |
| 48 | + # Make a link that returns to the forum page the user |
| 49 | + # just came from |
| 50 | + $link = '<div style="float: right;"><a href="' . |
| 51 | + htmlspecialchars($wgRequest->getText('toForum')) . |
| 52 | + '">→ Return to Forum</a></div>' . $text; |
| 53 | + |
| 54 | + # Add the Return to Forum link in to the page title |
| 55 | + # Since we're making it render HTML in a second, |
| 56 | + # encode special characters in the old page title |
| 57 | + $out->mPagetitle = $link . htmlspecialchars($out->getPageTitle()); |
| 58 | + |
| 59 | + # Content of mPageLinkTitle doesn't actually get displayed |
| 60 | + # When there is a value in mPageLinkTitle, the template |
| 61 | + # forces HTML rather than Text rendering of $out->mPagetitle |
| 62 | + $out->mPageLinkTitle = $out->mPagetitle; |
| 63 | + } |
| 64 | + |
| 65 | + # Be nice. |
| 66 | + return true; |
| 67 | +} |
| 68 | + |
42 | 69 | function efPhpbbData_LanguageGetMagic( &$magicWords, $langCode ) { |
43 | 70 | # Add the magic word |
44 | 71 | # The first array element is case sensitive, in this case it is not case sensitive |
— | — | @@ -49,16 +76,16 @@ |
50 | 77 | } |
51 | 78 | |
52 | 79 | function efPhpbbData_makeTopicWikiLink($display_text='', $forum_id=null, $topic_id=null, $post_id=null) { |
53 | | - global $wgPhpbbDataRootPath, $wgTitle; |
| 80 | + global $wgPhpbbDataRootPath, $wgTitle, $wgServer; |
54 | 81 | |
55 | 82 | if (!empty($post_id)) { |
56 | | - $urlText = "{{SERVER}}/{$wgPhpbbDataRootPath}viewpost.php?p={$post_id}&toWiki=" . |
| 83 | + $urlText = "{$wgServer}/{$wgPhpbbDataRootPath}viewpost.php?p={$post_id}&toWiki=" . |
57 | 84 | urlencode($wgTitle->escapeLocalURL()); |
58 | 85 | } elseif (!empty($topic_id)) { |
59 | | - $urlText = "{{SERVER}}/{$wgPhpbbDataRootPath}viewtopic.php?t={$topic_id}&toWiki=" . |
| 86 | + $urlText = "{$wgServer}/{$wgPhpbbDataRootPath}viewtopic.php?t={$topic_id}&toWiki=" . |
60 | 87 | urlencode($wgTitle->escapeLocalURL()); |
61 | 88 | } elseif (!empty($forum_id)) { |
62 | | - $urlText = "{{SERVER}}/{$wgPhpbbDataRootPath}viewforum.php?t={$forum_id}&toWiki=" . |
| 89 | + $urlText = "{$wgServer}/{$wgPhpbbDataRootPath}viewforum.php?t={$forum_id}&toWiki=" . |
63 | 90 | urlencode($wgTitle->escapeLocalURL()); |
64 | 91 | } |
65 | 92 | |