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
66 changes: 33 additions & 33 deletions adm/style/acp_newspage_settings.html
Original file line number Diff line number Diff line change
@@ -1,65 +1,65 @@
<!-- INCLUDE overall_header.html -->
{% include 'overall_header.html' %}

<h1>{L_ACP_NEWSPAGE}</h1>
<p>{L_ACP_NEWSPAGE_SETTINGS_EXPLAIN}</p>
<h1>{{ lang('ACP_NEWSPAGE') }}</h1>
<p>{{ lang('ACP_NEWSPAGE_SETTINGS_EXPLAIN') }}</p>

<form id="acp_newspage" method="post" action="{U_ACTION}">
<form id="acp_newspage" method="post" action="{{ U_ACTION }}">
<fieldset>
<legend>{L_ACP_NEWSPAGE_SETTINGS}</legend>
<legend>{{ lang('ACP_NEWSPAGE_SETTINGS') }}</legend>
<dl>
<dt><label for="news_icon">{L_NEWS_ICON}{L_COLON}</label><br /><span>{L_NEWS_ICON_EXPLAIN}</span></dt>
<dd><input type="text" id="news_icon" name="news_icon" value="{SETTING_NEWS_ICON}" /></dd>
<dt><label for="news_icon">{{ lang('NEWS_ICON') }}{{ lang('COLON') }}</label><br /><span>{{ lang('NEWS_ICON_EXPLAIN') }}</span></dt>
<dd><input type="text" id="news_icon" name="news_icon" value="{{ SETTING_NEWS_ICON }}" /></dd>
</dl>
<dl>
<dt><label for="news_forums">{L_NEWS_FORUMS}{L_COLON}</label></dt>
<dd><select id="news_forums" name="news_forums[]" multiple="multiple" size="10">{SETTING_NEWS_FORUMS}</select></dd>
<dt><label for="news_forums">{{ lang('NEWS_FORUMS') }}{{ lang('COLON') }}</label></dt>
<dd><select id="news_forums" name="news_forums[]" multiple="multiple" size="10">{{ SETTING_NEWS_FORUMS }}</select></dd>
</dl>
<dl>
<dt><label for="news_number">{L_NEWS_NUMBER}{L_COLON}</label></dt>
<dd><input type="number" id="news_number" name="news_number" min="1" value="{SETTING_NEWS_NUMBER}" /></dd>
<dt><label for="news_number">{{ lang('NEWS_NUMBER') }}{{ lang('COLON') }}</label></dt>
<dd><input type="number" id="news_number" name="news_number" min="1" value="{{ SETTING_NEWS_NUMBER }}" /></dd>
</dl>
<dl>
<dt><label for="news_pages">{L_NEWS_PAGES}{L_COLON}</label></dt>
<dd><input type="number" id="news_pages" name="news_pages" min="1" value="{SETTING_NEWS_PAGES}" /></dd>
<dt><label for="news_pages">{{ lang('NEWS_PAGES') }}{{ lang('COLON') }}</label></dt>
<dd><input type="number" id="news_pages" name="news_pages" min="1" value="{{ SETTING_NEWS_PAGES }}" /></dd>
</dl>
<dl>
<dt><label for="news_char_limit">{L_NEWS_CHAR_LIMIT}{L_COLON}</label><br /><span>{L_NEWS_CHAR_LIMIT_EXPLAIN}</span></dt>
<dd><input type="number" id="news_char_limit" name="news_char_limit" min="0" value="{SETTING_NEWS_CHAR_LIMIT}" /></dd>
<dt><label for="news_char_limit">{{ lang('NEWS_CHAR_LIMIT') }}{{ lang('COLON') }}</label><br /><span>{{ lang('NEWS_CHAR_LIMIT_EXPLAIN') }}</span></dt>
<dd><input type="number" id="news_char_limit" name="news_char_limit" min="0" value="{{ SETTING_NEWS_CHAR_LIMIT }}" /></dd>
</dl>
<dl>
<dt><label for="news_cat_show">{L_NEWS_CAT_SHOW}{L_COLON}</label></dt>
<dd><input type="checkbox" id="news_cat_show" name="news_cat_show" value="1"<!-- IF SETTING_NEWS_CAT_SHOW --> checked="checked"<!-- ENDIF --> /></dd>
<dt><label for="news_cat_show">{{ lang('NEWS_CAT_SHOW') }}{{ lang('COLON') }}</label></dt>
<dd><input type="checkbox" id="news_cat_show" name="news_cat_show" value="1"{% if SETTING_NEWS_CAT_SHOW %} checked="checked"{% endif %} /></dd>
</dl>
<dl>
<dt><label for="news_archive_show">{L_NEWS_ARCHIVE_SHOW}{L_COLON}</label></dt>
<dd><input type="checkbox" id="news_archive_show" name="news_archive_show" value="1"<!-- IF SETTING_NEWS_ARCHIVE_SHOW --> checked="checked"<!-- ENDIF --> /></dd>
<dt><label for="news_archive_show">{{ lang('NEWS_ARCHIVE_SHOW') }}{{ lang('COLON') }}</label></dt>
<dd><input type="checkbox" id="news_archive_show" name="news_archive_show" value="1"{% if SETTING_NEWS_ARCHIVE_SHOW %} checked="checked"{% endif %} /></dd>
</dl>
<dl>
<dt><label for="news_shadow_show">{L_NEWS_SHADOW_SHOW}{L_COLON}</label></dt>
<dd><input type="checkbox" id="news_shadow_show" name="news_shadow_show" value="1"<!-- IF SETTING_NEWS_SHADOW_SHOW --> checked="checked"<!-- ENDIF --> /></dd>
<dt><label for="news_shadow_show">{{ lang('NEWS_SHADOW_SHOW') }}{{ lang('COLON') }}</label></dt>
<dd><input type="checkbox" id="news_shadow_show" name="news_shadow_show" value="1"{% if SETTING_NEWS_SHADOW_SHOW %} checked="checked"{% endif %} /></dd>
</dl>
<dl>
<dt><label for="news_user_info">{L_NEWS_USER_INFO}{L_COLON}</label><br /><span>{L_NEWS_USER_INFO_EXPLAIN}</span></dt>
<dd><input type="checkbox" id="news_user_info" name="news_user_info" value="1"<!-- IF SETTING_NEWS_USER_INFO --> checked="checked"<!-- ENDIF --> /></dd>
<dt><label for="news_user_info">{{ lang('NEWS_USER_INFO') }}{{ lang('COLON') }}</label><br /><span>{{ lang('NEWS_USER_INFO_EXPLAIN') }}</span></dt>
<dd><input type="checkbox" id="news_user_info" name="news_user_info" value="1"{% if SETTING_NEWS_USER_INFO %} checked="checked"{% endif %} /></dd>
</dl>
<dl>
<dt><label for="news_post_buttons">{L_NEWS_POST_BUTTONS}{L_COLON}</label><br /><span>{L_NEWS_POST_BUTTONS_EXPLAIN}</span></dt>
<dd><input type="checkbox" id="news_post_buttons" name="news_post_buttons" value="1"<!-- IF SETTING_NEWS_POST_BUTTONS --> checked="checked"<!-- ENDIF --> /></dd>
<dt><label for="news_post_buttons">{{ lang('NEWS_POST_BUTTONS') }}{{ lang('COLON') }}</label><br /><span>{{ lang('NEWS_POST_BUTTONS_EXPLAIN') }}</span></dt>
<dd><input type="checkbox" id="news_post_buttons" name="news_post_buttons" value="1"{% if SETTING_NEWS_POST_BUTTONS %} checked="checked"{% endif %} /></dd>
</dl>
<dl>
<dt><label for="news_lead_image">{L_NEWS_LEAD_IMAGE}{L_COLON}</label><br /><span>{L_NEWS_LEAD_IMAGE_EXPLAIN}</span></dt>
<dd><input type="checkbox" id="news_lead_image" name="news_lead_image" value="1"<!-- IF SETTING_NEWS_LEAD_IMAGE --> checked="checked"<!-- ENDIF --> /></dd>
<dt><label for="news_lead_image">{{ lang('NEWS_LEAD_IMAGE') }}{{ lang('COLON') }}</label><br /><span>{{ lang('NEWS_LEAD_IMAGE_EXPLAIN') }}</span></dt>
<dd><input type="checkbox" id="news_lead_image" name="news_lead_image" value="1"{% if SETTING_NEWS_LEAD_IMAGE %} checked="checked"{% endif %} /></dd>
</dl>
<dl>
<dt><label for="news_attach_show">{L_NEWS_ATTACH_SHOW}{L_COLON}</label><br /><span>{L_NEWS_ATTACH_SHOW_EXPLAIN}</span></dt>
<dd><input type="checkbox" id="news_attach_show" name="news_attach_show" value="1"<!-- IF SETTING_NEWS_ATTACH_SHOW --> checked="checked"<!-- ENDIF --> /></dd>
<dt><label for="news_attach_show">{{ lang('NEWS_ATTACH_SHOW') }}{{ lang('COLON') }}</label><br /><span>{{ lang('NEWS_ATTACH_SHOW_EXPLAIN') }}</span></dt>
<dd><input type="checkbox" id="news_attach_show" name="news_attach_show" value="1"{% if SETTING_NEWS_ATTACH_SHOW %} checked="checked"{% endif %} /></dd>
</dl>
</fieldset>
<fieldset class="submit-buttons">
<input class="button1" type="submit" name="submit" value="{L_SUBMIT}" />
<input class="button2" type="reset" name="reset" value="{L_RESET}" />
{S_FORM_TOKEN}
<input class="button1" type="submit" name="submit" value="{{ lang('SUBMIT')|e('html_attr') }}" />
<input class="button2" type="reset" name="reset" value="{{ lang('RESET')|e('html_attr') }}" />
{{ S_FORM_TOKEN }}
</fieldset>
</form>

<!-- INCLUDE overall_footer.html -->
{% include 'overall_footer.html' %}
4 changes: 2 additions & 2 deletions config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ services:
- "@config"
- "@dispatcher"
- "@template"
- "@user"
- "@controller.helper"
- "@phpbbmodders.newspage"
- "%core.root_path%"
Expand All @@ -31,7 +30,7 @@ services:
- "@cache"
- "@config"
- "@dbal.conn"
- "@request"
- "@profilefields.manager"
- "@template"
- "@user"
- "@content.visibility"
Expand All @@ -58,6 +57,7 @@ services:
arguments:
- "@phpbbmodders.newspage.helper"
- "@user"
- "@auth"
- "%core.php_ext%"
tags:
- { name: event.listener }
42 changes: 1 addition & 41 deletions controller/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ class main
/* @var \phpbb\template\template */
protected $template;

/* @var \phpbb\user */
protected $user;

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

Expand All @@ -55,18 +52,16 @@ class main
* @param \phpbb\config\config $config
* @param \phpbb\event\dispatcher $dispatcher
* @param \phpbb\template\template $template
* @param \phpbb\user $user
* @param \phpbb\controller\helper $helper
* @param \phpbbmodders\newspage\newspage $newspage
* @param string $root_path
* @param string $php_ext
*/
public function __construct(\phpbb\config\config $config, \phpbb\event\dispatcher $dispatcher, \phpbb\template\template $template, \phpbb\user $user, \phpbb\controller\helper $helper, \phpbbmodders\newspage\newspage $newspage, $root_path, $php_ext)
public function __construct(\phpbb\config\config $config, \phpbb\event\dispatcher $dispatcher, \phpbb\template\template $template, \phpbb\controller\helper $helper, \phpbbmodders\newspage\newspage $newspage, $root_path, $php_ext)
{
$this->config = $config;
$this->dispatcher = $dispatcher;
$this->template = $template;
$this->user = $user;
$this->helper = $helper;
$this->newspage = $newspage;
$this->root_path = $root_path;
Expand Down Expand Up @@ -178,46 +173,11 @@ public function base($display_pagination = true)
}

$this->newspage->base();
$this->assign_images($this->config['news_user_info'], $this->config['news_post_buttons']);

$this->template->assign_vars(array(
'S_ON_NEWSPAGE' => true,
));

return $this->helper->render('newspage_body.html', $this->newspage->get_page_title());
}

/**
* @param bool $assign_user_buttons
* @param bool $assign_post_buttons
*/
protected function assign_images($assign_user_buttons, $assign_post_buttons)
{
$this->template->assign_vars(array(
'REPORTED_IMG' => $this->user->img('icon_topic_reported', 'POST_REPORTED'),
));

if ($assign_user_buttons)
{
$this->template->assign_vars(array(
'PROFILE_IMG' => $this->user->img('icon_user_profile', 'READ_PROFILE'),
'SEARCH_IMG' => $this->user->img('icon_user_search', 'SEARCH_USER_POSTS'),
'PM_IMG' => $this->user->img('icon_contact_pm', 'SEND_PRIVATE_MESSAGE'),
'EMAIL_IMG' => $this->user->img('icon_contact_email', 'SEND_EMAIL'),
'JABBER_IMG' => $this->user->img('icon_contact_jabber', 'JABBER'),
));
}

if ($assign_post_buttons)
{
$this->template->assign_vars(array(
'QUOTE_IMG' => $this->user->img('icon_post_quote', 'REPLY_WITH_QUOTE'),
'EDIT_IMG' => $this->user->img('icon_post_edit', 'EDIT_POST'),
'DELETE_IMG' => $this->user->img('icon_post_delete', 'DELETE_POST'),
'INFO_IMG' => $this->user->img('icon_post_info', 'VIEW_INFO'),
'REPORT_IMG' => $this->user->img('icon_post_report', 'REPORT_POST'),
'WARN_IMG' => $this->user->img('icon_user_warn', 'WARN_USER'),
));
}
}
}
2 changes: 0 additions & 2 deletions docs/TODO.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# TODO

- **German ACP and install strings**: `language/de/` only has `newspage.php`. The ACP settings page
(`info_acp_newspage.php`) and the enable messages (`install_newspage.php`) fall back to English.
- **Version check**: no phpBB.com listing for this extension could be confirmed. Once it has one, add an
`extra.version-check` block to `composer.json` pointing at it, so the ACP can report new releases.
16 changes: 14 additions & 2 deletions event/viewonline_listener.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ public static function getSubscribedEvents()
/* @var \phpbb\user */
protected $user;

/* @var \phpbb\auth\auth */
protected $auth;

/* @var string phpEx */
protected $php_ext;

Expand All @@ -48,12 +51,14 @@ public static function getSubscribedEvents()
*
* @param \phpbbmodders\newspage\helper $helper
* @param \phpbb\user $user
* @param \phpbb\auth\auth $auth
* @param string $php_ext
*/
public function __construct(\phpbbmodders\newspage\helper $helper, \phpbb\user $user, $php_ext)
public function __construct(\phpbbmodders\newspage\helper $helper, \phpbb\user $user, \phpbb\auth\auth $auth, $php_ext)
{
$this->helper = $helper;
$this->user = $user;
$this->auth = $auth;
$this->php_ext = $php_ext;
}

Expand All @@ -75,7 +80,14 @@ public function add_newspage_viewonline($event)
$forum_id = $this->get_category_from_route($parts);
$archive = $this->get_archive_from_route($parts);

if (count($parts) === 1)
// Name a forum only when it exists and the viewer may see it, as viewonline.php does
$hidden_forum = $forum_id && (!isset($event['forum_data'][$forum_id]) || !$this->auth->acl_get('f_list', $forum_id));
if ($hidden_forum)
{
$forum_id = false;
}

if (count($parts) === 1 || ($hidden_forum && !$archive))
{
$event['location_url'] = $route->get_url();
$event['location'] = $this->user->lang('VIEWONLINE_NEWS');
Expand Down
84 changes: 0 additions & 84 deletions language/de/newspage.php

This file was deleted.

3 changes: 0 additions & 3 deletions language/en/newspage.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,12 @@
'NEWS_FILTER_CLEAR' => 'Clear filters',
'NEWS_FILTER_SHOWING' => 'Showing',
'NEWS_FORUMS' => 'Select News-Forums',
'NEWS_GO_TO_TOPIC' => 'Link to topic',
'NEWS_NUMBER' => 'News per page',
'NEWS_PAGES' => 'Number of pages',
'NEWS_POLL' => 'Poll',
'NEWS_POLL_GOTO' => 'Click here to vote!',
'NEWS_POST_BUTTONS' => 'Show post-related buttons',
'NEWS_POST_BUTTONS_EXPLAIN' => 'Quote, Edit, etc.',
'NEWS_READ_FULL' => 'Read full news',
'NEWS_READ_HERE' => 'Here',
'NEWS_SAVED' => 'The settings have been saved successfully.',
'NEWS_SHADOW_SHOW' => 'Show moved topics',
'NEWS_USER_INFO' => 'Show user information',
Expand Down
Loading
Loading