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 README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ A wiki for phpBB with version history, side-by-side compare, and a moderation qu
- A contributions page for every member, at `/wiki/contributions/<username>`, lists every version they saved across all articles, newest first. Author names on articles and in the version history link to it. Versions waiting for approval, and those of switched-off articles, show only to moderators and to the author.
- Files can be uploaded to an article by members who hold the **Can upload files to articles** permission. They are checked against the board's allowed file types and size limit, stored outside public view under `store/phpbbmodders_wiki/`, and read only through the wiki, which checks that the reader may see the article. In the text, `[[File:Diagram.png]]` shows an uploaded image and `[[File:notes.zip|the notes]]` links to any other file. The member who uploaded a file, or a moderator who may delete versions, can remove it, and deleting an article deletes its files.
- Notifications when an edit is waiting for approval.
- **Watch article** on every article page, for signed-in members: they are notified when a new version of a watched article goes live (a moderator approved an edit, or a trusted editor's edit went live directly), never about their own edit. It is a notification type in phpBB's notification settings, so members choose the bell, email or both. With the ACP setting **Watch edited articles** (on by default, under **Extensions > Wiki > Settings**), saving an edit also starts watching the article. Watches are removed with the article and with the member.
- The Wiki link in the board header shows the Wikipedia icon by default. Under **Extensions > Wiki > Settings** in the ACP the icon can be changed to any [Font Awesome](https://fontawesome.com/v4.7.0/icons/) icon name, or left blank for no icon.
- A **Start discussion** button on each article creates its discussion topic in a forum chosen under **Extensions > Wiki > Settings** in the ACP, and links the topic to the article. It shows to members who hold the "Can change the discussion topic for an article" permission and may post in that forum, and stays hidden until a forum is chosen.
- Separate permissions for viewing, editing, version history, deleting and moderating.
Expand Down
3 changes: 3 additions & 0 deletions acp/main_module.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public function main($id, $mode)
$forum_id = $request->variable('wiki_discussion_forum_id', 0);
$icon = trim($request->variable('wiki_icon', ''));
$feed_format = $request->variable('wiki_feed_format', '');
$auto_watch = $request->variable('wiki_auto_watch', 0) ? 1 : 0;

if (!\phpbbmodders\wiki\wiki\feed::is_valid_setting($feed_format))
{
Expand Down Expand Up @@ -85,6 +86,7 @@ public function main($id, $mode)
$config->set('wiki_discussion_forum_id', $forum_id);
$config->set('wiki_icon', $icon);
$config->set('wiki_feed_format', $feed_format);
$config->set('wiki_auto_watch', $auto_watch);

trigger_error($language->lang('CONFIG_UPDATED') . adm_back_link($this->u_action));
}
Expand All @@ -98,6 +100,7 @@ public function main($id, $mode)

$template->assign_vars(array(
'S_WIKI_FEED_OPTIONS' => $feed_options,
'S_WIKI_AUTO_WATCH' => !isset($config['wiki_auto_watch']) || !empty($config['wiki_auto_watch']),
'WIKI_ICON' => isset($config['wiki_icon']) ? $config['wiki_icon'] : \phpbbmodders\wiki\wiki\icon::DEFAULT_ICON,
'U_ACTION' => $this->u_action,
'S_WIKI_FORUM_OPTIONS' => '<option value="0"' . (empty($config['wiki_discussion_forum_id']) ? ' selected="selected"' : '') . '>' . $language->lang('WIKI_DISCUSSION_FORUM_NONE') . '</option>'
Expand Down
7 changes: 7 additions & 0 deletions adm/style/acp_wiki_settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ <h1>{L_ACP_WIKI_SETTINGS}</h1>
<dt><label for="wiki_icon">{L_WIKI_ICON}{L_COLON}</label><br><span>{L_WIKI_ICON_EXPLAIN}</span></dt>
<dd><input id="wiki_icon" type="text" name="wiki_icon" size="30" maxlength="50" value="{WIKI_ICON}"></dd>
</dl>
<dl>
<dt><label for="wiki_auto_watch_yes">{L_WIKI_AUTO_WATCH}{L_COLON}</label><br><span>{L_WIKI_AUTO_WATCH_EXPLAIN}</span></dt>
<dd>
<label><input type="radio" class="radio" id="wiki_auto_watch_yes" name="wiki_auto_watch" value="1"<!-- IF S_WIKI_AUTO_WATCH --> checked="checked"<!-- ENDIF -->> {L_YES}</label>
<label><input type="radio" class="radio" name="wiki_auto_watch" value="0"<!-- IF not S_WIKI_AUTO_WATCH --> checked="checked"<!-- ENDIF -->> {L_NO}</label>
</dd>
</dl>
<dl>
<dt><label for="wiki_feed_format">{L_WIKI_FEED_FORMAT}{L_COLON}</label><br><span>{L_WIKI_FEED_FORMAT_EXPLAIN}</span></dt>
<dd><select id="wiki_feed_format" name="wiki_feed_format">{S_WIKI_FEED_OPTIONS}</select></dd>
Expand Down
32 changes: 31 additions & 1 deletion config/services.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
parameters:
tables.wiki.article: '%core.table_prefix%wiki_article'
tables.wiki.file: '%core.table_prefix%wiki_file'
tables.wiki.watch: '%core.table_prefix%wiki_watch'

services:
_defaults:
Expand Down Expand Up @@ -52,6 +53,18 @@ services:
- '%core.root_path%'
- '%core.php_ext%'

phpbbmodders.wiki.watch:
class: phpbbmodders\wiki\wiki\watch
arguments:
- '@auth'
- '@dbal.conn'
- '@controller.helper'
- '@request'
- '@template'
- '@user'
- '%tables.wiki.watch%'
- '%tables.wiki.article%'

phpbbmodders.wiki.files:
class: phpbbmodders\wiki\wiki\files
arguments:
Expand Down Expand Up @@ -83,6 +96,7 @@ services:
- '@phpbbmodders.wiki.view'
- '@phpbbmodders.wiki.discussion'
- '@phpbbmodders.wiki.files'
- '@phpbbmodders.wiki.watch'
- '%core.root_path%'
- '%core.php_ext%'
phpbbmodders.wiki.listener:
Expand All @@ -94,6 +108,7 @@ services:
- '@notification_manager'
- '@template'
- '@user'
- '@phpbbmodders.wiki.watch'
tags:
- { name: event.listener }
phpbbmodders.wiki.edit:
Expand All @@ -110,6 +125,7 @@ services:
- '%tables.wiki.article%'
- '%core.root_path%'
- '%core.php_ext%'
- '@phpbbmodders.wiki.watch'
phpbbmodders.wiki.compare:
class: phpbbmodders\wiki\wiki\compare
arguments:
Expand All @@ -134,6 +150,7 @@ services:
- '%tables.wiki.article%'
- '@phpbbmodders.wiki.files'
- '@request'
- '@phpbbmodders.wiki.watch'
phpbbmodders.wiki.view:
class: phpbbmodders\wiki\wiki\view
arguments:
Expand All @@ -150,6 +167,7 @@ services:
- '@phpbbmodders.wiki.links'
- '@phpbbmodders.wiki.discussion'
- '@phpbbmodders.wiki.files'
- '@phpbbmodders.wiki.watch'
phpbbmodders.wiki.discussion:
class: phpbbmodders\wiki\wiki\discussion
arguments:
Expand Down Expand Up @@ -196,4 +214,16 @@ services:
calls:
- [set_name, [phpbbmodders_wiki_article]]
tags:
- { name: text_reparser.plugin}
- { name: text_reparser.plugin}
phpbbmodders.wiki.notification.type.article_watch:
class: phpbbmodders\wiki\notification\article_watch
parent: notification.type.base
# Symfony 3.4 (phpBB 3.3.x) does not let a service with a parent take "public" from _defaults.
public: true
shared: false
calls:
- [set_user_loader, ['@user_loader']]
- [set_helper, ['@controller.helper']]
- [set_watch, ['@phpbbmodders.wiki.watch']]
tags:
- { name: notification.type }
13 changes: 12 additions & 1 deletion controller/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ class main
/** @var \phpbbmodders\wiki\wiki\files */
protected $files;

/** @var \phpbbmodders\wiki\wiki\watch */
protected $watch;

/** @var string phpbb_root_path */
protected $phpbb_root_path;

Expand All @@ -65,10 +68,11 @@ class main
* @param \phpbbmodders\wiki\wiki\view $view View Wiki object
* @param \phpbbmodders\wiki\wiki\discussion $discussion Start discussion object
* @param \phpbbmodders\wiki\wiki\files $files Uploaded files object
* @param \phpbbmodders\wiki\wiki\watch $watch Watched articles object
* @param string $phpbb_root_path
* @param string $php_ext
*/
public function __construct(\phpbb\auth\auth $auth, \phpbb\controller\helper $helper, \phpbb\request\request $request, \phpbb\template\template $template, \phpbb\user $user, \phpbbmodders\wiki\wiki\delete $delete, \phpbbmodders\wiki\wiki\edit $edit, \phpbbmodders\wiki\wiki\compare $compare, \phpbbmodders\wiki\wiki\view $view, \phpbbmodders\wiki\wiki\discussion $discussion, \phpbbmodders\wiki\wiki\files $files, $phpbb_root_path, $php_ext)
public function __construct(\phpbb\auth\auth $auth, \phpbb\controller\helper $helper, \phpbb\request\request $request, \phpbb\template\template $template, \phpbb\user $user, \phpbbmodders\wiki\wiki\delete $delete, \phpbbmodders\wiki\wiki\edit $edit, \phpbbmodders\wiki\wiki\compare $compare, \phpbbmodders\wiki\wiki\view $view, \phpbbmodders\wiki\wiki\discussion $discussion, \phpbbmodders\wiki\wiki\files $files, \phpbbmodders\wiki\wiki\watch $watch, $phpbb_root_path, $php_ext)
{
$this->auth = $auth;
$this->helper = $helper;
Expand All @@ -81,6 +85,7 @@ public function __construct(\phpbb\auth\auth $auth, \phpbb\controller\helper $he
$this->view = $view;
$this->discussion = $discussion;
$this->files = $files;
$this->watch = $watch;
$this->phpbb_root_path = $phpbb_root_path;
$this->php_ext = $php_ext;
}
Expand Down Expand Up @@ -154,6 +159,12 @@ public function article($article)
case 'start_discussion':
return $this->discussion->start($article);

case 'watch':
return $this->watch->handle($article, true);

case 'unwatch':
return $this->watch->handle($article, false);

case 'upload':
return $this->files->upload($article);

Expand Down
8 changes: 0 additions & 8 deletions docs/TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,6 @@ new URL and losing the connection to its history. Needs a "move" action
permission) that renames `article_url` across all of an article's versions
and optionally leaves a redirect stub at the old URL.

## Watch/subscribe to an article

The existing notification type only fires for "pending approval" (aimed at
moderators). Regular readers have no way to ask "notify me when this
specific article changes" the way forum topic-watching works. Would need a
second notification type plus a subscribe/unsubscribe action on the article
view page.

## Categories/tags

Browsing is flat today — Popular/Latest/All/Sticky/Pending on the overview
Expand Down
18 changes: 17 additions & 1 deletion event/listener.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ class listener implements EventSubscriberInterface
/** @var \phpbb\config\config */
protected $config;

/** @var \phpbbmodders\wiki\wiki\watch */
protected $watch;

/** @var \phpbb\controller\helper */
protected $helper;

Expand All @@ -48,8 +51,9 @@ class listener implements EventSubscriberInterface
* @param \phpbb\template $template Template object
* @param \phpbb\user $user User object
*/
public function __construct(\phpbb\auth\auth $auth, \phpbb\config\config $config, \phpbb\controller\helper $helper, \phpbb\notification\manager $notification_manager, \phpbb\template\template $template, \phpbb\user $user)
public function __construct(\phpbb\auth\auth $auth, \phpbb\config\config $config, \phpbb\controller\helper $helper, \phpbb\notification\manager $notification_manager, \phpbb\template\template $template, \phpbb\user $user, \phpbbmodders\wiki\wiki\watch $watch)
{
$this->watch = $watch;
$this->auth = $auth;
$this->config = $config;
$this->helper = $helper;
Expand All @@ -64,6 +68,7 @@ public static function getSubscribedEvents()
'core.page_header' => 'page_header',
'core.permissions' => 'permissions',
'core.user_setup' => 'user_setup',
'core.delete_user_after' => 'delete_user_after',
);
}

Expand Down Expand Up @@ -193,4 +198,15 @@ public function user_setup($event)
$event['lang_set_ext'] = $lang_ary;
}


/**
* A deleted member no longer watches anything.
*
* @param \phpbb\event\data $event The event object
* @return void
*/
public function delete_user_after($event)
{
$this->watch->delete_for_users(array_map('intval', (array) $event['user_ids']));
}
}
9 changes: 6 additions & 3 deletions ext.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ class ext extends \phpbb\extension\base
];
const NEW_NOTIFICATION_TYPE = 'phpbbmodders.wiki.notification.type.article_edit';

/** Notification type that tells watchers a new version went live */
const WATCH_NOTIFICATION_TYPE = 'phpbbmodders.wiki.notification.type.article_watch';

/** Text reparser service name (the key of its CLI resume data) before and after the rename */
const OLD_REPARSER_NAME = 'tas2580.wiki.text_reparser.article_text';
const NEW_REPARSER_NAME = 'phpbbmodders.wiki.text_reparser.article_text';
Expand Down Expand Up @@ -120,7 +123,7 @@ public function enable_step($old_state)
{
case false:
case '':
return $this->notification_handler('enable', [self::NEW_NOTIFICATION_TYPE]);
return $this->notification_handler('enable', [self::NEW_NOTIFICATION_TYPE, self::WATCH_NOTIFICATION_TYPE]);

default:
return parent::enable_step($old_state);
Expand All @@ -139,7 +142,7 @@ public function disable_step($old_state)
{
case false:
case '':
return $this->notification_handler('disable', [self::NEW_NOTIFICATION_TYPE]);
return $this->notification_handler('disable', [self::NEW_NOTIFICATION_TYPE, self::WATCH_NOTIFICATION_TYPE]);

default:
return parent::disable_step($old_state);
Expand All @@ -158,7 +161,7 @@ public function purge_step($old_state)
{
case false:
case '':
return $this->notification_handler('purge', [self::NEW_NOTIFICATION_TYPE]);
return $this->notification_handler('purge', [self::NEW_NOTIFICATION_TYPE, self::WATCH_NOTIFICATION_TYPE]);

default:
return parent::purge_step($old_state);
Expand Down
2 changes: 2 additions & 0 deletions language/de/acp_wiki.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
'WIKI_ICON' => 'Symbol des Kopfzeilen-Links',
'WIKI_ICON_EXPLAIN' => 'Gib den Namen eines <a href="https://fontawesome.com/v4.7.0/icons/" target="_blank"><strong>Font-Awesome</strong></a>-Symbols für den Wiki-Link in der Kopfzeile des Forums ein. Standard ist <code>wikipedia-w</code>.<br> Lass das Feld leer, um kein Symbol anzuzeigen.',
'WIKI_ICON_INVALID' => 'Das Symbol des Wiki-Links enthält ungültige Zeichen.',
'WIKI_AUTO_WATCH' => 'Bearbeitete Artikel beobachten',
'WIKI_AUTO_WATCH_EXPLAIN' => 'Wenn aktiv, beobachtet ein Mitglied einen Artikel automatisch, sobald es eine Bearbeitung speichert, und wird benachrichtigt, wenn eine neue Version aktiv wird. Das Beobachten kann im Artikel beendet werden.',
'WIKI_FEED_FORMAT' => 'Feed der letzten Änderungen',
'WIKI_FEED_FORMAT_EXPLAIN' => 'Welche Feed-Formate die Seite „Letzte Änderungen“ anbietet und die Kopfzeile Feed-Readern mitteilt.',
'WIKI_FEED_FORMAT_BOTH' => 'RSS und Atom',
Expand Down
4 changes: 4 additions & 0 deletions language/de/common.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@
'CONTRIBUTIONS_SAVED' => 'Gespeichert',
'CONTRIBUTIONS_STATUS' => 'Status',
'CONTRIBUTIONS_NONE' => 'Es gibt keine Versionen, die angezeigt werden können.',
'WIKI_WATCH' => 'Artikel beobachten',
'WIKI_UNWATCH' => 'Nicht mehr beobachten',
'WIKI_NOW_WATCHING' => 'Du beobachtest diesen Artikel jetzt. Du wirst benachrichtigt, wenn eine neue Version aktiv wird.',
'WIKI_NO_LONGER_WATCHING' => 'Du beobachtest diesen Artikel nicht mehr.',
'WIKI_RECENT_CHANGES' => 'Letzte Änderungen',
'WIKI_RECENT_CHANGES_EXPLAIN' => 'Jede im Wiki gespeicherte Version, die aktiv ist oder war, die neuesten zuerst.',
'WIKI_FEED_RSS_LINK' => 'RSS-Feed',
Expand Down
14 changes: 14 additions & 0 deletions language/de/email/mail_article_watch.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Subject: "{SITENAME}" — Beobachteter Wiki-Artikel aktualisiert

Hallo {USERNAME},

{NOTIFICATION_SUBJECT}

Artikel ansehen: {U_LINK}

Du erhältst diese Nachricht, weil du den Artikel beobachtest. Beende das Beobachten auf der Artikelseite oder ändere die Benachrichtigungen in deinen Benachrichtigungseinstellungen im Kontrollzentrum.

Zur Forenübersicht:
{U_INDEX}

{EMAIL_SIG}
2 changes: 2 additions & 0 deletions language/de/link.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,7 @@
$lang = array_merge($lang, array(
'WIKI' => 'KB',
'WIKI_NEW_ARTICLE_UPDATE' => 'Ein neue Version zum Artikel <strong>%1$s</strong> in der KB wartet auf Freischaltung.',
'WIKI_WATCHED_ARTICLE' => 'Ein Wiki-Artikel, den du beobachtest, hat eine neue Version',
'WIKI_WATCHED_ARTICLE_LIVE' => 'Eine neue Version des Wiki-Artikels <strong>%1$s</strong> ist jetzt aktiv.',

));
2 changes: 2 additions & 0 deletions language/en/acp_wiki.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
'WIKI_ICON' => 'Header link icon',
'WIKI_ICON_EXPLAIN' => 'Enter the name of a <a href="https://fontawesome.com/v4.7.0/icons/" target="_blank"><strong>Font Awesome</strong></a> icon to use for the Wiki link in the board header. The default is <code>wikipedia-w</code>.<br> Leave this field blank for no icon.',
'WIKI_ICON_INVALID' => 'The Wiki link icon contains invalid characters.',
'WIKI_AUTO_WATCH' => 'Watch edited articles',
'WIKI_AUTO_WATCH_EXPLAIN' => 'When on, a member who saves an edit also starts watching that article and is notified when a new version goes live. They can stop watching from the article.',
'WIKI_FEED_FORMAT' => 'Recent changes feed',
'WIKI_FEED_FORMAT_EXPLAIN' => 'Which feed formats the Recent changes page offers, and the header advertises to feed readers.',
'WIKI_FEED_FORMAT_BOTH' => 'RSS and Atom',
Expand Down
4 changes: 4 additions & 0 deletions language/en/common.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@
'CONTRIBUTIONS_SAVED' => 'Saved',
'CONTRIBUTIONS_STATUS' => 'Status',
'CONTRIBUTIONS_NONE' => 'There are no versions to show.',
'WIKI_WATCH' => 'Watch article',
'WIKI_UNWATCH' => 'Stop watching',
'WIKI_NOW_WATCHING' => 'You are now watching this article. You will be notified when a new version goes live.',
'WIKI_NO_LONGER_WATCHING' => 'You are no longer watching this article.',
'WIKI_RECENT_CHANGES' => 'Recent changes',
'WIKI_RECENT_CHANGES_EXPLAIN' => 'Every version saved to the wiki that is or was live, newest first.',
'WIKI_FEED_RSS_LINK' => 'RSS feed',
Expand Down
14 changes: 14 additions & 0 deletions language/en/email/mail_article_watch.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Subject: "{SITENAME}" — Watched wiki article updated

Hello {USERNAME},

{NOTIFICATION_SUBJECT}

View the article: {U_LINK}

You are receiving this because you watch the article. Stop watching it from the article page, or change how you are notified under Notification settings in your control panel.

Board index:
{U_INDEX}

{EMAIL_SIG}
3 changes: 3 additions & 0 deletions language/en/link.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
$lang = array_merge($lang, array(
'WIKI' => 'Wiki',
'WIKI_NEW_ARTICLE_UPDATE' => 'A new version of the article <strong>%1$s</strong> in the Wiki is awaiting approval.',
'WIKI_ARTICLE_UPDATE' => 'An edit of a wiki article is awaiting approval',
'WIKI_WATCHED_ARTICLE' => 'A wiki article you watch has a new version',
'WIKI_WATCHED_ARTICLE_LIVE' => 'A new version of the wiki article <strong>%1$s</strong> is now live.',
'WIKI_LINK_BUTTON' => 'Wiki link: [[Article name]] or [[Article name|link text]]',
'WIKI_LINK_NEW_ARTICLE' => 'This article doesn’t exist yet. Follow the link to create it.',
'WIKI_WHAT_LINKS_HERE' => 'What links here',
Expand Down
Loading
Loading