Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
.gitignore export-ignore
.github/ export-ignore
docs/images/ export-ignore
docs/update/ export-ignore
tests/ export-ignore
README.md export-ignore
version-check.json export-ignore
3 changes: 2 additions & 1 deletion docs/TODO/todo-wiki-markup.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ table of contents (`__TOC__`, `__FORCETOC__`, `__NOTOC__`, automatic from four
headings) and the `#REDIRECT [[Article]]` first line are done. They are read only
while a wiki article is saved or previewed, by switching the `WIKIHEADING` and
`WIKIMAGIC` tags on in `core.text_formatter_s9e_parse_before` (see `wiki/markup.php`),
and a migration reparses saved articles. What is left below is tables, the text
and articles saved earlier are converted with
`php bin/phpbbcli.php reparser:reparse phpbbmodders_wiki_article`. What is left below is tables, the text
styles and references (not wanted yet), `[[Category:Name]]`, and templates.

## Scope: wiki articles only
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/update/2026-10-12/02-file-uploads.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/update/2026-10-12/04-recent-changes.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/update/2026-10-12/05-contributions.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/update/2026-10-12/06-overview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/update/2026-10-12/07-acp-settings.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
45 changes: 45 additions & 0 deletions docs/update/2026-10-12/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Wiki update screenshots, 2026-10-12

Taken with Playwright on a throwaway phpBB 3.3.19 board (prosilver, MySQL 8.0), filled by `seed-wiki-fixtures.php` from seed-forum.

## Headings and contents

An article with headings, the contents box, and `[[Article#Section]]` and `[[#Section]]` links.

![Article with headings, a contents box and section links](01-headings-and-contents.png)

## File uploads

An uploaded diagram embedded with `[[File:name.png]]`.

![Article with an embedded uploaded image](02-file-uploads.png)

## Watch and discussion buttons

The article header: edit, history, watch (bell) and discussion.

![Article header with edit, history, watch and discussion buttons](03-watch-and-discussion-buttons.png)

## Recent changes

Every saved version, with RSS and Atom feed links.

![Recent changes page](04-recent-changes.png)

## Contributions

A member's saved versions.

![Contributions page for a member](05-contributions.png)

## Overview

The overview page with pending articles, as a moderator sees it.

![Wiki overview with pending articles](06-overview.png)

## ACP settings

ACP > Extensions > Wiki > Settings.

![Wiki settings in the ACP](07-acp-settings.png)
2 changes: 1 addition & 1 deletion event/wikilink_listener.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public function configure_wikilink($event)
$tag->attributes->add('text')->required = false;
$tag->template = '<a class="wikilink" data-wiki-article="{@name}" data-wiki-section="{@section}">'
. '<xsl:choose><xsl:when test="@text"><xsl:value-of select="@text"/></xsl:when>'
. '<xsl:otherwise><xsl:value-of select="@name"/></xsl:otherwise></xsl:choose></a>';
. '<xsl:otherwise><xsl:value-of select="@name"/><xsl:if test="@section">#<xsl:value-of select="@section"/></xsl:if></xsl:otherwise></xsl:choose></a>';

$configurator->Preg->match(
'/\[\[\s*(?!File:)(?=[^\]|])(?<name>' . self::NAME_CLASS . '{0,255}?)\s*(?:#\s*(?<section>[^\[\]|<>"\n]{1,255}?)\s*)?(?:\|\s*(?<text>[^\[\]\n]{1,255}?)\s*)?\]\]/',
Expand Down
45 changes: 45 additions & 0 deletions migrations/purge_text_formatter_cache.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php
/**
*
* Wiki extension for the phpBB Forum Software package
*
* @copyright (c) 2026, phpBB Modders, https://www.phpbbmodders.com/
* @license GNU General Public License, version 2 (GPL-2.0)
*
*/

namespace phpbbmodders\wiki\migrations;

/**
* Throws away the cached text formatter configuration.
*
* add_wiki_markup rebuilds that cache while the extension is being enabled, before
* its listeners exist, so on a fresh install the cached configuration had no
* wiki tags (no [[links]], [[File:]] or headings) until something purged the cache.
* This runs after it and clears the cache; phpBB rebuilds it, with the wiki's tags,
* on the next page.
*/
class purge_text_formatter_cache extends \phpbb\db\migration\container_aware_migration
{
public static function depends_on()
{
return array(
'\phpbbmodders\wiki\migrations\add_wiki_markup',
);
}

public function update_data()
{
return array(
array('custom', array(array($this, 'purge_cache'))),
);
}

/**
* @return void
*/
public function purge_cache()
{
$this->container->get('cache')->purge();
}
}
4 changes: 2 additions & 2 deletions styles/prosilver/template/recent_changes.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ <h2>{L_WIKI_RECENT_CHANGES}</h2>
<th class="middle">{L_CONTRIBUTIONS_SAVED}</th>
<th>{L_CONTRIBUTIONS_ARTICLE}</th>
<th class="middle">{L_USER}</th>
<th class="big">{L_REASON_EDIT}</th>
<th class="big">{L_CONTRIBUTIONS_STATUS}</th>
<th>{L_REASON_EDIT}</th>
<th class="middle">{L_CONTRIBUTIONS_STATUS}</th>
</tr>
</thead>
<tbody>
Expand Down
37 changes: 37 additions & 0 deletions tests/unit/markup_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -218,4 +218,41 @@ public function test_file_embeds_are_still_their_own_tag()
$this->assertSame(2, substr_count($xml, '<WIKIFILE'));
$this->assertSame(1, substr_count($xml, '<WIKILINK'));
}

private function render(string $text): string
{
$listener = new \phpbbmodders\wiki\event\wikilink_listener(
$this->createMock(\phpbb\controller\helper::class),
$this->createMock(\phpbb\language\language::class),
$this->createMock(\phpbbmodders\wiki\wiki\links::class),
$this->createMock(\phpbbmodders\wiki\wiki\files::class)
);

$configurator = new \s9e\TextFormatter\Configurator;
// The PHP renderer, like phpBB's own: the default XSLT one needs ext-xsl, which some CI runners lack
$configurator->rendering->setEngine('PHP');
$listener->configure_wikilink(array('configurator' => $configurator));
extract($configurator->finalize());

return $renderer->render($parser->parse($text));
}

/** @dataProvider link_texts */
public function test_a_link_shows_a_readable_text(string $text, string $expected)
{
$html = $this->render($text);

$this->assertMatchesRegularExpression('/<a class="wikilink"[^>]*>' . preg_quote($expected, '/') . '<\/a>/', $html, $html);
}

public static function link_texts(): array
{
return array(
'article' => array('[[Main Page]]', 'Main Page'),
'article with section' => array('[[Main Page#History]]', 'Main Page#History'),
'same-page section' => array('[[#History]]', '#History'),
'own text' => array('[[Main Page#History|the history]]', 'the history'),
'own text, same page' => array('[[#History|below]]', 'below'),
);
}
}
Loading