diff --git a/.gitattributes b/.gitattributes index b95b36e..ff7a412 100644 --- a/.gitattributes +++ b/.gitattributes @@ -3,3 +3,11 @@ *.png binary *.jpg binary *.phar binary + +tests/ export-ignore +.github/ export-ignore +.gitignore export-ignore +.gitattributes export-ignore +phpunit.xml.* export-ignore +README.md export-ignore +docs/images/ export-ignore diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml deleted file mode 100644 index 619246d..0000000 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ /dev/null @@ -1,29 +0,0 @@ -name: Bug report -description: Report a reproducible problem with NV Newspage. -labels: ["bug"] -body: - - type: input - id: versions - attributes: - label: Versions - description: Include the extension revision, phpBB version, PHP version, and database backend. - validations: - required: true - - type: textarea - id: reproduce - attributes: - label: Steps to reproduce - description: Explain how to reproduce the problem on a disposable board. - validations: - required: true - - type: textarea - id: behavior - attributes: - label: Expected and actual behavior - validations: - required: true - - type: textarea - id: logs - attributes: - label: Relevant errors - description: Remove credentials and private board data before posting logs. diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml deleted file mode 100644 index a28f37b..0000000 --- a/.github/ISSUE_TEMPLATE/config.yml +++ /dev/null @@ -1,5 +0,0 @@ -blank_issues_enabled: false -contact_links: - - name: Questions, feature requests, and general discussion - url: https://github.com/phpbbmodders/phpbb-ext-newspage/discussions - about: For anything that isn't a bug report, please use Discussions instead. diff --git a/.github/epv-allowed.txt b/.github/epv-allowed.txt new file mode 100644 index 0000000..2a462b3 --- /dev/null +++ b/.github/epv-allowed.txt @@ -0,0 +1,13 @@ +# EPV findings this extension keeps on purpose, checked by the epv job in +# .github/workflows/tests.yml. One finding per line as EPV prints it, without +# "on line N", with paths relative to the extension; give the reason above it. + +# ext.php reads phpBB's own serialized migration dependency lists when it moves +# an old nickvergessen/newspage install, with allowed_classes off, so no +# objects can be created. +Error: Using unserialize in /ext.php + +# The post subject, poll question and edit reason are stored escaped. These +# calls escape them for the news page without escaping them twice +# (double_encode off), which utf8_htmlspecialchars() can't do. +Error: Using htmlspecialchars in /newspage.php diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..1cd5e40 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,38 @@ +name: Lint + +# PHP syntax check on the lowest PHP version this extension supports and the +# newest one phpBB 3.3 supports. tests.yml runs the tests, code sniffer and +# EPV on phpBB 3.3 and 4.0. +on: + push: + branches: + - main + pull_request: + branches: + - main + +permissions: + contents: read + +jobs: + lint: + name: PHP ${{ matrix.php }} lint + runs-on: ubuntu-24.04 + strategy: + matrix: + php: ['7.4', '8.4'] + steps: + - uses: actions/checkout@v4 + + - name: Set up PHP ${{ matrix.php }} + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + coverage: none + tools: composer:v2 + + - name: PHP syntax check + run: find . -name '*.php' -not -path './.git/*' -not -path './vendor/*' -print0 | xargs -0 -n1 php -l + + - name: Validate composer.json + run: composer validate --no-check-all --no-check-publish diff --git a/.github/workflows/php-syntax.yml b/.github/workflows/php-syntax.yml deleted file mode 100644 index fe364fc..0000000 --- a/.github/workflows/php-syntax.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: PHP syntax - -on: - push: - branches: [main] - pull_request: - branches: [main] - -permissions: - contents: read - -jobs: - lint: - name: PHP syntax - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6 - - name: Check tracked PHP files - shell: bash - run: | - set -euo pipefail - php --version - while IFS= read -r -d '' file; do - php -l "$file" - done < <(git ls-files -z '*.php') diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..f1f25a7 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,45 @@ +name: Tests + +on: + push: + branches: + - main + + pull_request: + branches: + - main + +jobs: + # phpBB 3.3.x compatibility + call-tests-3-3-x: + name: Extension tests (phpBB 3.3.x) + uses: phpbb-extensions/test-framework/.github/workflows/tests.yml@3.3.x + with: + EXTNAME: phpbbmodders/newspage + # EPV runs in the epv job below instead + EPV: 0 + PHPBB_BRANCH: '3.3.x' + RUN_FUNCTIONAL_TESTS: 0 + PRIMARY_PHP_VERSION: '7.4' + PHP_VERSION_MATRIX: '["7.4", "8.0", "8.1", "8.2"]' + + # phpBB 4.0 (master) compatibility + call-tests-master: + name: Extension tests (phpBB master / 4.0) + uses: phpbb-extensions/test-framework/.github/workflows/tests.yml@master + with: + EXTNAME: phpbbmodders/newspage + # EPV runs in the epv job below instead + EPV: 0 + PHPBB_BRANCH: 'master' + RUN_FUNCTIONAL_TESTS: 0 + PRIMARY_PHP_VERSION: '8.2' + PHP_VERSION_MATRIX: '["8.2", "8.3", "8.4"]' + + # EPV (Extension Pre Validator), failing on any Fatal or Error finding not + # listed in .github/epv-allowed.txt + epv: + uses: phpbbmodders/.github/.github/workflows/epv.yml@v1 + with: + EXTNAME: phpbbmodders/newspage + PHPBB_BRANCHES: '["3.3.x", "master"]' diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index d1ba183..0000000 --- a/.travis.yml +++ /dev/null @@ -1,57 +0,0 @@ -language: php - -matrix: - include: - - php: 5.3.3 - env: DB=mysqli - - php: 5.3 - env: DB=mysqli # MyISAM - - php: 5.4 - env: DB=mysqli - - php: 5.4 - env: DB=mysql - - php: 5.4 - env: DB=mariadb - - php: 5.4 - env: DB=postgres - - php: 5.4 - env: DB=sqlite3 - - php: 5.5 - env: DB=mysqli - - php: 5.6 - env: DB=mysqli - - php: hhvm - env: DB=mysqli - allow_failures: - - php: hhvm - fast_finish: true - -env: - global: - - EXTNAME="nickvergessen/newspage" - - SNIFF="1" - - IMAGE_ICC="0" # Disabled until vendor/ is ignored for extensions - - EPV="1" - - PHPBB_BRANCH="3.1.x" - -branches: - only: - - master - - /^(3\.[1-9]|[4-9]\.\d)\.x$/ - -install: - - php composer.phar install --dev --no-interaction --prefer-source - - - travis/prepare-phpbb.sh $EXTNAME $PHPBB_BRANCH - - cd ../../phpBB3 - - travis/prepare-extension.sh $EXTNAME $PHPBB_BRANCH - - travis/setup-phpbb.sh $DB $TRAVIS_PHP_VERSION - -before_script: - - travis/setup-database.sh $DB $TRAVIS_PHP_VERSION - -script: - - sh -c "if [ '$SNIFF' != '0' ]; then travis/ext-sniff.sh $DB $TRAVIS_PHP_VERSION $EXTNAME; fi" - - sh -c "if [ '$IMAGE_ICC' != '0' ]; then travis/check-image-icc-profiles.sh $DB $TRAVIS_PHP_VERSION; fi" - - phpBB/vendor/bin/phpunit --configuration phpBB/ext/$EXTNAME/travis/phpunit-$DB-travis.xml --bootstrap ./tests/bootstrap.php - - sh -c "if [ '$EPV' != '0' -a '$TRAVIS_PHP_VERSION' = '5.5' ]; then phpBB/ext/$EXTNAME/vendor/bin/EPV.php run --dir=phpBB/ext/$EXTNAME/; fi" diff --git a/README.md b/README.md index 9e6f3a7..fa8a674 100644 --- a/README.md +++ b/README.md @@ -1,42 +1,57 @@ -# NV Newspage Extension +# NV Newspage -An independent continuation of NV Newspage for [phpBB](https://www.phpbb.com/), maintained under phpbbmodders. +[![Tests](https://github.com/phpbbmodders/phpbb-ext-newspage/actions/workflows/tests.yml/badge.svg)](https://github.com/phpbbmodders/phpbb-ext-newspage/actions/workflows/tests.yml) [![Lint](https://github.com/phpbbmodders/phpbb-ext-newspage/actions/workflows/lint.yml/badge.svg)](https://github.com/phpbbmodders/phpbb-ext-newspage/actions/workflows/lint.yml) -## Compatibility +A news page that shows the latest topics from chosen forums, shortened to a set length, with monthly archives and categories. -The imported code targets phpBB 3.1. Work toward phpBB 3.3 support is planned; compatibility has not yet been implemented or verified. Do not install this development branch on a production board. +## Features -The original branches and release tags are preserved as historical upstream snapshots. They do not represent phpbbmodders releases or phpBB 3.3 support. +- A **News** page at `/news`, linked from the board's navigation bar with an icon you choose. +- Shows the first post of the newest topics in the forums you pick, with a set number of news per page and pages. +- Shortens long news to a set number of characters, with a "Read full news" link. Formatting is kept and no tag is cut in half. +- Visitors can filter the news by forum and by month, and open a single news item. +- Optional poster information (avatar, rank, profile fields), post buttons, attachments and moved topics. +- Shows in **Who is online** when someone is reading the news. +- Settings under **ACP → Extensions → Newspage**. +## Screenshots -## Description + + + + + +
News pageACP settings
-Adds an extra page to the board where a switchable number of news can be displayed. -The news texts can be shorten to a given number of characters. -Also the icons can be switched on/off (post icons, user icons) +Click an image for the full size. See the [screenshot gallery](docs/images/screenshots/README.md) for the rest. +## Requirements -## Development Installation +- phpBB 3.3.19 or later, including phpBB 4.0 (tested on its 4.0.0-a3 development version) +- PHP 7.4 or later (phpBB 4.0 itself needs PHP 8.2 or later), with the DOM extension -Clone into phpBB/ext/nickvergessen/newspage: +## Installation - git clone https://github.com/phpbbmodders/phpbb-ext-newspage.git phpBB/ext/nickvergessen/newspage +1. Copy the extension to `/ext/phpbbmodders/newspage` +2. In the Administration Control Panel, go to **Customise → Manage extensions** +3. Enable the **NV Newspage** extension +4. Choose the news forums under **ACP → Extensions → Newspage → Settings** -Set up the dependencies: +### Upgrading from `nickvergessen/newspage` - php composer.phar install --dev +This extension used to be installed as `nickvergessen/newspage`. Your settings carry over: -Go to "ACP" > "Customise" > "Extensions" and enable the "phpBB 3.1 NV Newspage Extension" extension. +1. Disable the old **NV Newspage** extension in the ACP. Do **not** delete its data. +2. Upload this version to `/ext/phpbbmodders/newspage` and enable it. The old install's migration history is moved to the new name automatically. +3. Delete the `/ext/nickvergessen/newspage` folder and purge the board cache. +If you disable the old extension from the command line (`bin/phpbbcli.php`) instead of the ACP, run `bin/phpbbcli.php cache:purge` before enabling the new one; the command-line disable doesn't clear the cache. -## List of events +The settings moved from the news page itself to the ACP. The News link's icon is a Font Awesome class: phpBB 3.3 uses Font Awesome 4.7 and phpBB 4.0 uses Font Awesome 6, so pick a name both have (the default, `fa-bullhorn`, works on both). -See the [documentation](docs/events.md) for a list of available php and template events. +## Events - -## Testing - -GitHub Actions checks PHP syntax. This does not establish phpBB runtime compatibility. The imported PHPUnit suite and Travis configuration target phpBB 3.1 and need updating before they can validate the 3.3 port. +The PHP and template events other extensions can use are listed in [docs/events.md](docs/events.md). ## TODO @@ -47,15 +62,17 @@ Ideas not yet built, practical and speculative alike: [`docs/TODO.md`](docs/TODO Contributions are welcome! - **Bug reports**: [Open an issue](https://github.com/phpbbmodders/phpbb-ext-newspage/issues). -- **Everything else** (questions, feature requests, ideas, general discussion): [Use Discussions](https://github.com/phpbbmodders/phpbb-ext-newspage/discussions). +- **Everything else** (questions, feature requests, ideas, general discussion): [Use Discussions](https://github.com/orgs/phpbbmodders/discussions), or the [community forum](https://www.phpbbmodders.com/community/). - Pull requests are welcome for bug fixes or discussed features. ## Acknowledgments -- Based on [nickv-phpbb/phpbb-ext-newspage](https://github.com/nickv-phpbb/phpbb-ext-newspage), originally developed by Joas Schilling (nickvergessen). Original history, authorship, and licensing are preserved. -- Code review and documentation assisted by [Codex](https://www.anthropic.com/Codex). - +- Based on [nickv-phpbb/phpbb-ext-newspage](https://github.com/nickv-phpbb/phpbb-ext-newspage), originally developed by Joas Schilling ([nickvergessen](https://github.com/nickvergessen)). Original history, authorship and licensing are preserved. +- Code review, bug fixes, and documentation assisted by [Claude](https://www.anthropic.com/claude). +- Code review and documentation assisted by [Codex](https://openai.com/codex/). ## License -[GPLv2](license.txt) +This extension is licensed under the **GNU General Public License v2.0**. + +See [license.txt](license.txt) for more information. diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 4652f81..0000000 --- a/SECURITY.md +++ /dev/null @@ -1,9 +0,0 @@ -# Security Policy - -Report suspected vulnerabilities privately to security@williamjacoby.cc. -Include the organization name (phpbbmodders), repository name -(phpbb-ext-newspage), affected revision, and reproduction details. -Do not include credentials or private board data. - -This development branch contains imported phpBB 3.1 code. phpBB 3.3 -compatibility is planned and has not yet been verified. diff --git a/acp/main_info.php b/acp/main_info.php new file mode 100644 index 0000000..f8aa5e0 --- /dev/null +++ b/acp/main_info.php @@ -0,0 +1,29 @@ + '\\phpbbmodders\\newspage\\acp\\main_module', + 'title' => 'ACP_NEWSPAGE', + 'modes' => array( + 'settings' => array( + 'title' => 'ACP_NEWSPAGE_SETTINGS', + 'auth' => 'ext_phpbbmodders/newspage && acl_a_board', + 'cat' => array('ACP_NEWSPAGE'), + ), + ), + ); + } +} diff --git a/acp/main_module.php b/acp/main_module.php new file mode 100644 index 0000000..caa45e4 --- /dev/null +++ b/acp/main_module.php @@ -0,0 +1,68 @@ +add_lang_ext('phpbbmodders/newspage', array('newspage', 'info_acp_newspage')); + $this->tpl_name = 'acp_newspage_settings'; + $this->page_title = 'ACP_NEWSPAGE_SETTINGS'; + + if (!$auth->acl_get('a_board')) + { + trigger_error($user->lang('NO_AUTH_OPERATION'), E_USER_WARNING); + } + + add_form_key('acp_newspage'); + + if ($request->is_set_post('submit')) + { + if (!check_form_key('acp_newspage')) + { + trigger_error($user->lang('FORM_INVALID') . adm_back_link($this->u_action), E_USER_WARNING); + } + + $icon = trim($request->variable('news_icon', 'fa-bullhorn')); + if (!preg_match('/\Afa-[a-z0-9]+(?:-[a-z0-9]+)*\z/', $icon)) + { + trigger_error($user->lang('NEWS_ICON_INVALID') . adm_back_link($this->u_action), E_USER_WARNING); + } + + $phpbb_container->get('phpbbmodders.newspage.controller.settings')->save_settings(); + $config->set('news_icon', $icon); + $phpbb_log->add('admin', $user->data['user_id'], $user->ip, 'LOG_NEWSPAGE_SETTINGS'); + trigger_error($user->lang('NEWS_SAVED') . adm_back_link($this->u_action)); + } + + $template->assign_vars(array( + 'U_ACTION' => $this->u_action, + 'SETTING_NEWS_ICON' => isset($config['news_icon']) ? $config['news_icon'] : 'fa-bullhorn', + 'SETTING_NEWS_FORUMS' => make_forum_select(explode(',', $config['news_forums']), false, false, true), + 'SETTING_NEWS_NUMBER' => (int) $config['news_number'], + 'SETTING_NEWS_PAGES' => (int) $config['news_pages'], + 'SETTING_NEWS_CHAR_LIMIT' => (int) $config['news_char_limit'], + 'SETTING_NEWS_CAT_SHOW' => (bool) $config['news_cat_show'], + 'SETTING_NEWS_ARCHIVE_SHOW' => (bool) $config['news_archive_show'], + 'SETTING_NEWS_SHADOW_SHOW' => (bool) $config['news_shadow'], + 'SETTING_NEWS_USER_INFO' => (bool) $config['news_user_info'], + 'SETTING_NEWS_POST_BUTTONS' => (bool) $config['news_post_buttons'], + 'SETTING_NEWS_ATTACH_SHOW' => (bool) $config['news_attach_show'], + )); + } +} diff --git a/adm/style/acp_newspage_settings.html b/adm/style/acp_newspage_settings.html new file mode 100644 index 0000000..f7c19f9 --- /dev/null +++ b/adm/style/acp_newspage_settings.html @@ -0,0 +1,61 @@ + + +

{L_ACP_NEWSPAGE}

+

{L_ACP_NEWSPAGE_SETTINGS_EXPLAIN}

+ +
+
+ {L_ACP_NEWSPAGE_SETTINGS} +
+

{L_NEWS_ICON_EXPLAIN}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

{L_NEWS_CHAR_LIMIT_EXPLAIN}
+
+
+
+
+
checked="checked" />
+
+
+
+
checked="checked" />
+
+
+
+
checked="checked" />
+
+
+

{L_NEWS_USER_INFO_EXPLAIN}
+
checked="checked" />
+
+
+

{L_NEWS_POST_BUTTONS_EXPLAIN}
+
checked="checked" />
+
+
+

{L_NEWS_ATTACH_SHOW_EXPLAIN}
+
checked="checked" />
+
+
+
+ + + {S_FORM_TOKEN} +
+
+ + diff --git a/build.xml b/build.xml deleted file mode 100644 index 9cd33ef..0000000 --- a/build.xml +++ /dev/null @@ -1,113 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/composer.json b/composer.json index e3a0ab3..09a1214 100644 --- a/composer.json +++ b/composer.json @@ -1,31 +1,39 @@ { - "name": "nickvergessen/newspage", + "name": "phpbbmodders/newspage", "type": "phpbb-extension", - "description": "Adds a extra-page to the board where a switchable number of news are displayed. The text can be shorten to a certain number of chars. Also the Icons can be switched of (post icons, user icons)", - "homepage": "https://github.com/nickv-phpbb/phpbb-ext-newspage", - "version": "1.3", - "time": "2015-06-14", - "license": "GPL-2.0", + "description": "A news page that shows the latest topics from chosen forums, shortened to a set length, with monthly archives and categories.", + "homepage": "https://www.phpbbmodders.com/", + "version": "1.4.0-dev", + "keywords": [ + "phpbb", + "extension", + "news", + "newspage" + ], + "license": "GPL-2.0-only", "authors": [ + { + "name": "phpBB Modders", + "email": "board@phpbbmodders.com", + "homepage": "https://www.phpbbmodders.com/", + "role": "Extension Developer" + }, { "name": "Joas Schilling", "email": "nickvergessen@gmx.de", "homepage": "https://github.com/nickvergessen", - "role": "Developer" + "role": "Past Developer" } ], "require": { - "nickvergessen/phpbb-tool-trimmessage": "1.3.*", - "php": ">=5.3.3" - }, - "require-dev": { - "phing/phing": "2.4.*", - "phpbb/epv": "dev-master" + "php": ">=7.4", + "ext-dom": "*", + "composer/installers": "^1.0 || ^2.0" }, "extra": { - "display-name": "phpBB 3.1 - NV Newspage Extension", + "display-name": "NV Newspage", "soft-require": { - "phpbb/phpbb": ">=3.1.3,<3.2.*@dev" + "phpbb/phpbb": ">=3.3.19,<4.1.0@dev" } } } diff --git a/composer.lock b/composer.lock deleted file mode 100644 index bde5580..0000000 --- a/composer.lock +++ /dev/null @@ -1,503 +0,0 @@ -{ - "_readme": [ - "This file locks the dependencies of your project to a known state", - "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file" - ], - "hash": "78a55812528c922938e844a03a288f46", - "packages": [ - { - "name": "nickvergessen/phpbb-tool-trimmessage", - "version": "1.3.0", - "source": { - "type": "git", - "url": "https://github.com/nickvergessen/phpbb-tool-trimmessage.git", - "reference": "2a3d8273dc1238dd06454688bcb6496f62f66c3b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/nickvergessen/phpbb-tool-trimmessage/zipball/2a3d8273dc1238dd06454688bcb6496f62f66c3b", - "reference": "2a3d8273dc1238dd06454688bcb6496f62f66c3b", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "phpunit/phpunit": "4.1.*" - }, - "type": "library", - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "GPL-2.0" - ], - "authors": [ - { - "name": "Joas Schilling", - "email": "nickvergessen@gmx.de", - "homepage": "https://github.com/nickvergessen", - "role": "Developer" - } - ], - "description": "This tool contains a class, that is able to trim a message from the phpbb message_parser to a maximum length without breaking the bbcodes/smilies and links.", - "homepage": "https://github.com/nickvergessen/phpbb-tool-trimmessage", - "time": "2014-07-06 19:42:34" - } - ], - "packages-dev": [ - { - "name": "gitonomy/gitlib", - "version": "v0.1.7", - "source": { - "type": "git", - "url": "https://github.com/gitonomy/gitlib.git", - "reference": "7a46107cfb8552b312101e0d5906e95d54d7ddc6" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/gitonomy/gitlib/zipball/7a46107cfb8552b312101e0d5906e95d54d7ddc6", - "reference": "7a46107cfb8552b312101e0d5906e95d54d7ddc6", - "shasum": "" - }, - "require": { - "symfony/process": "~2.4" - }, - "require-dev": { - "psr/log": "~1" - }, - "suggest": { - "psr/log": "Add some log" - }, - "type": "library", - "autoload": { - "psr-0": { - "Gitonomy\\Git": [ - "src/", - "tests/" - ] - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Alexandre Salomé", - "email": "alexandre.salome@gmail.com", - "homepage": "http://alexandre-salome.fr" - }, - { - "name": "Julien DIDIER", - "email": "genzo.wm@gmail.com", - "homepage": "http://www.jdidier.net" - } - ], - "description": "Library for accessing git", - "homepage": "http://gitonomy.com", - "time": "2014-07-13 19:02:31" - }, - { - "name": "nikic/php-parser", - "version": "v0.9.5", - "source": { - "type": "git", - "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "ef70767475434bdb3615b43c327e2cae17ef12eb" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/ef70767475434bdb3615b43c327e2cae17ef12eb", - "reference": "ef70767475434bdb3615b43c327e2cae17ef12eb", - "shasum": "" - }, - "require": { - "ext-tokenizer": "*", - "php": ">=5.2" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "0.9-dev" - } - }, - "autoload": { - "psr-0": { - "PHPParser": "lib/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Nikita Popov" - } - ], - "description": "A PHP parser written in PHP", - "keywords": [ - "parser", - "php" - ], - "time": "2014-07-23 18:24:17" - }, - { - "name": "phing/phing", - "version": "2.4.14", - "source": { - "type": "git", - "url": "https://github.com/phingofficial/phing.git", - "reference": "41075d93ca254f1c90c79ec7ce81be2b2629e138" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phingofficial/phing/zipball/41075d93ca254f1c90c79ec7ce81be2b2629e138", - "reference": "41075d93ca254f1c90c79ec7ce81be2b2629e138", - "shasum": "" - }, - "require": { - "php": ">=5.2.0" - }, - "bin": [ - "bin/phing" - ], - "type": "library", - "autoload": { - "classmap": [ - "classes/phing/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "include-path": [ - "classes" - ], - "license": [ - "LGPL3" - ], - "authors": [ - { - "name": "Michiel Rook", - "email": "mrook@php.net", - "role": "Lead" - }, - { - "name": "Phing Community", - "homepage": "http://www.phing.info/trac/wiki/Development/Contributors" - } - ], - "description": "PHing Is Not GNU make; it's a PHP project build system or build tool based on Apache Ant.", - "homepage": "http://www.phing.info/", - "keywords": [ - "build", - "task", - "tool" - ], - "time": "2012-11-29 21:23:47" - }, - { - "name": "phpbb/epv", - "version": "dev-master", - "source": { - "type": "git", - "url": "https://github.com/phpbb/epv.git", - "reference": "c092d70a3ee6da3604464f3f8b4e5dbb34fd4f9d" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpbb/epv/zipball/c092d70a3ee6da3604464f3f8b4e5dbb34fd4f9d", - "reference": "c092d70a3ee6da3604464f3f8b4e5dbb34fd4f9d", - "shasum": "" - }, - "require": { - "gitonomy/gitlib": "0.1.*@dev", - "nikic/php-parser": "0.9.*@dev", - "php": ">=5.3.3", - "sensiolabs/ansi-to-html": "~1.1", - "symfony/console": ">=2.3.0", - "symfony/finder": ">=2.3.0", - "symfony/yaml": ">=2.3.0|>=2.4.0|>=2.5.0" - }, - "require-dev": { - "phpunit/phpunit": "4.4.*", - "phpunit/phpunit-mock-objects": "2.3.*" - }, - "bin": [ - "src/EPV.php" - ], - "type": "library", - "autoload": { - "psr-4": { - "Phpbb\\Epv\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "GPL-2.0" - ], - "authors": [ - { - "name": "Paul Sohier", - "email": "paul@phpbb.com" - } - ], - "description": "A extension validator for phpBB extensions. Extensions are required to pass the validator when submitted to the extension database.", - "time": "2015-02-05 18:25:28" - }, - { - "name": "sensiolabs/ansi-to-html", - "version": "v1.1.0", - "source": { - "type": "git", - "url": "https://github.com/sensiolabs/ansi-to-html.git", - "reference": "92d2ef7ffba5418be060d8ba8adaf7223d741f93" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sensiolabs/ansi-to-html/zipball/92d2ef7ffba5418be060d8ba8adaf7223d741f93", - "reference": "92d2ef7ffba5418be060d8ba8adaf7223d741f93", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "suggest": { - "twig/twig": "Provides nice templating features" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.1-dev" - } - }, - "autoload": { - "psr-0": { - "SensioLabs\\AnsiConverter": "." - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - } - ], - "description": "A library to convert a text with ANSI codes to HTML", - "time": "2014-08-01 14:02:39" - }, - { - "name": "symfony/console", - "version": "v2.6.4", - "target-dir": "Symfony/Component/Console", - "source": { - "type": "git", - "url": "https://github.com/symfony/Console.git", - "reference": "e44154bfe3e41e8267d7a3794cd9da9a51cfac34" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/Console/zipball/e44154bfe3e41e8267d7a3794cd9da9a51cfac34", - "reference": "e44154bfe3e41e8267d7a3794cd9da9a51cfac34", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "psr/log": "~1.0", - "symfony/event-dispatcher": "~2.1", - "symfony/process": "~2.1" - }, - "suggest": { - "psr/log": "For using the console logger", - "symfony/event-dispatcher": "", - "symfony/process": "" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.6-dev" - } - }, - "autoload": { - "psr-0": { - "Symfony\\Component\\Console\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" - }, - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - } - ], - "description": "Symfony Console Component", - "homepage": "http://symfony.com", - "time": "2015-01-25 04:39:26" - }, - { - "name": "symfony/finder", - "version": "v2.6.4", - "target-dir": "Symfony/Component/Finder", - "source": { - "type": "git", - "url": "https://github.com/symfony/Finder.git", - "reference": "16513333bca64186c01609961a2bb1b95b5e1355" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/Finder/zipball/16513333bca64186c01609961a2bb1b95b5e1355", - "reference": "16513333bca64186c01609961a2bb1b95b5e1355", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.6-dev" - } - }, - "autoload": { - "psr-0": { - "Symfony\\Component\\Finder\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" - }, - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - } - ], - "description": "Symfony Finder Component", - "homepage": "http://symfony.com", - "time": "2015-01-03 08:01:59" - }, - { - "name": "symfony/process", - "version": "v2.6.4", - "target-dir": "Symfony/Component/Process", - "source": { - "type": "git", - "url": "https://github.com/symfony/Process.git", - "reference": "ecfc23e89d9967999fa5f60a1e9af7384396e9ae" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/Process/zipball/ecfc23e89d9967999fa5f60a1e9af7384396e9ae", - "reference": "ecfc23e89d9967999fa5f60a1e9af7384396e9ae", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.6-dev" - } - }, - "autoload": { - "psr-0": { - "Symfony\\Component\\Process\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" - }, - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - } - ], - "description": "Symfony Process Component", - "homepage": "http://symfony.com", - "time": "2015-01-25 04:39:26" - }, - { - "name": "symfony/yaml", - "version": "v2.6.4", - "target-dir": "Symfony/Component/Yaml", - "source": { - "type": "git", - "url": "https://github.com/symfony/Yaml.git", - "reference": "60ed7751671113cf1ee7d7778e691642c2e9acd8" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/Yaml/zipball/60ed7751671113cf1ee7d7778e691642c2e9acd8", - "reference": "60ed7751671113cf1ee7d7778e691642c2e9acd8", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.6-dev" - } - }, - "autoload": { - "psr-0": { - "Symfony\\Component\\Yaml\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" - }, - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - } - ], - "description": "Symfony Yaml Component", - "homepage": "http://symfony.com", - "time": "2015-01-25 04:39:26" - } - ], - "aliases": [], - "minimum-stability": "stable", - "stability-flags": { - "phpbb/epv": 20 - }, - "platform": { - "php": ">=5.3.3" - }, - "platform-dev": [] -} diff --git a/composer.phar b/composer.phar deleted file mode 100644 index b00eef5..0000000 Binary files a/composer.phar and /dev/null differ diff --git a/config/newspage_routing.yml b/config/newspage_routing.yml index 02db9bd..0d9fd9e 100644 --- a/config/newspage_routing.yml +++ b/config/newspage_routing.yml @@ -1,60 +1,56 @@ -nickvergessen_newspage_settings: - path: /settings - defaults: { _controller: nickvergessen.newspage.controller.settings:manage } - -nickvergessen_newspage_page_controller: +phpbbmodders_newspage_page_controller: path: /page/{page} - defaults: { _controller: nickvergessen.newspage.controller:newspage, forum_id: 0, year: 0, month: 0 } + defaults: { _controller: phpbbmodders.newspage.controller:newspage, forum_id: 0, year: 0, month: 0 } requirements: page: \d+ -nickvergessen_newspage_archive_controller: +phpbbmodders_newspage_archive_controller: path: /archive/{year}/{month} - defaults: { _controller: nickvergessen.newspage.controller:newspage, forum_id: 0, page: 1 } + defaults: { _controller: phpbbmodders.newspage.controller:newspage, forum_id: 0, page: 1 } requirements: year: \d+ month: \d+ -nickvergessen_newspage_archive_page_controller: +phpbbmodders_newspage_archive_page_controller: path: /archive/{year}/{month}/page/{page} - defaults: { _controller: nickvergessen.newspage.controller:newspage, forum_id: 0 } + defaults: { _controller: phpbbmodders.newspage.controller:newspage, forum_id: 0 } requirements: year: \d+ month: \d+ page: \d+ -nickvergessen_newspage_category_controller: +phpbbmodders_newspage_category_controller: path: /category/{forum_id} - defaults: { _controller: nickvergessen.newspage.controller:newspage, year: 0, month: 0, page: 1 } + defaults: { _controller: phpbbmodders.newspage.controller:newspage, year: 0, month: 0, page: 1 } requirements: forum_id: \d+ -nickvergessen_newspage_category_page_controller: +phpbbmodders_newspage_category_page_controller: path: /category/{forum_id}/page/{page} - defaults: { _controller: nickvergessen.newspage.controller:newspage, year: 0, month: 0 } + defaults: { _controller: phpbbmodders.newspage.controller:newspage, year: 0, month: 0 } requirements: forum_id: \d+ page: \d+ -nickvergessen_newspage_category_archive_controller: +phpbbmodders_newspage_category_archive_controller: path: /category/{forum_id}/archive/{year}/{month} - defaults: { _controller: nickvergessen.newspage.controller:newspage, page: 1 } + defaults: { _controller: phpbbmodders.newspage.controller:newspage, page: 1 } requirements: forum_id: \d+ year: \d+ month: \d+ -nickvergessen_newspage_category_archive_page_controller: +phpbbmodders_newspage_category_archive_page_controller: path: /category/{forum_id}/archive/{year}/{month}/page/{page} - defaults: { _controller: nickvergessen.newspage.controller:newspage } + defaults: { _controller: phpbbmodders.newspage.controller:newspage } requirements: forum_id: \d+ year: \d+ month: \d+ page: \d+ -nickvergessen_newspage_singlenews_controller: +phpbbmodders_newspage_singlenews_controller: path: /{topic_id} - defaults: { _controller: nickvergessen.newspage.controller:single_news } + defaults: { _controller: phpbbmodders.newspage.controller:single_news } requirements: topic_id: \d+ diff --git a/config/routing.yml b/config/routing.yml index 0ef6d27..21742b4 100644 --- a/config/routing.yml +++ b/config/routing.yml @@ -1,7 +1,7 @@ -nickvergessen_newspage_controller: +phpbbmodders_newspage_controller: path: /news - defaults: { _controller: nickvergessen.newspage.controller:newspage, forum_id: 0, year: 0, month: 0, page: 1 } + defaults: { _controller: phpbbmodders.newspage.controller:newspage, forum_id: 0, year: 0, month: 0, page: 1 } -nickvergessen_newspage_subpages: +phpbbmodders_newspage_subpages: resource: "newspage_routing.yml" prefix: /news diff --git a/config/services.yml b/config/services.yml index 7f6a324..2a37252 100644 --- a/config/services.yml +++ b/config/services.yml @@ -1,61 +1,63 @@ services: - nickvergessen.newspage.controller: - class: nickvergessen\newspage\controller\main + phpbbmodders.newspage.controller: + class: phpbbmodders\newspage\controller\main arguments: - - @config - - @dispatcher - - @template - - @user - - @controller.helper - - @nickvergessen.newspage - - %core.root_path% - - %core.php_ext% + - "@config" + - "@dispatcher" + - "@template" + - "@user" + - "@controller.helper" + - "@phpbbmodders.newspage" + - "%core.root_path%" + - "%core.php_ext%" - nickvergessen.newspage.controller.settings: - class: nickvergessen\newspage\controller\settings + phpbbmodders.newspage.controller.settings: + class: phpbbmodders\newspage\controller\settings arguments: - - @auth - - @config - - @request - - @controller.helper - - @user + - "@auth" + - "@config" + - "@request" - nickvergessen.newspage.helper: - class: nickvergessen\newspage\helper + phpbbmodders.newspage.helper: + class: phpbbmodders\newspage\helper arguments: - - @controller.helper - - @config + - "@controller.helper" + - "@config" - nickvergessen.newspage: - class: nickvergessen\newspage\newspage + phpbbmodders.newspage: + class: phpbbmodders\newspage\newspage arguments: - - @auth - - @cache - - @config - - @dbal.conn - - @request - - @template - - @user - - @content.visibility - - @controller.helper - - @nickvergessen.newspage.helper - - @pagination - - %core.root_path% - - %core.php_ext% + - "@auth" + - "@cache" + - "@config" + - "@dbal.conn" + - "@request" + - "@template" + - "@user" + - "@content.visibility" + - "@controller.helper" + - "@phpbbmodders.newspage.helper" + - "@pagination" + - "%core.root_path%" + - "%core.php_ext%" + calls: + # phpBB 4.0's avatar helper; phpBB 3.3 has none, so it gets null + - [set_avatar_helper, ['@?avatar.helper']] - nickvergessen.newspage.menu_link_listener: - class: nickvergessen\newspage\event\menu_link_listener + phpbbmodders.newspage.menu_link_listener: + class: phpbbmodders\newspage\event\menu_link_listener arguments: - - @nickvergessen.newspage.helper - - @template + - "@phpbbmodders.newspage.helper" + - "@template" + - "@config" tags: - { name: event.listener } - nickvergessen.newspage.viewonline_listener: - class: nickvergessen\newspage\event\viewonline_listener + phpbbmodders.newspage.viewonline_listener: + class: phpbbmodders\newspage\event\viewonline_listener arguments: - - @nickvergessen.newspage.helper - - @user - - %core.php_ext% + - "@phpbbmodders.newspage.helper" + - "@user" + - "%core.php_ext%" tags: - { name: event.listener } diff --git a/controller/main.php b/controller/main.php index c7008ca..15bb624 100644 --- a/controller/main.php +++ b/controller/main.php @@ -1,16 +1,16 @@ + * @copyright (c) 2026, phpBB Modders, https://www.phpbbmodders.com/ * @license GNU General Public License, version 2 (GPL-2.0) * - * For full copyright and license information, please see - * the license.txt file. */ -namespace nickvergessen\newspage\controller; +namespace phpbbmodders\newspage\controller; /** * Class main @@ -21,7 +21,7 @@ * /page/{page} [optional] * /news/{topic_id} [optional] * - * @package nickvergessen\newspage\controller + * @package phpbbmodders\newspage\controller */ class main { @@ -40,7 +40,7 @@ class main /* @var \phpbb\controller\helper */ protected $helper; - /* @var \nickvergessen\newspage\newspage */ + /* @var \phpbbmodders\newspage\newspage */ protected $newspage; /* @var string phpBB root path */ @@ -57,11 +57,11 @@ class main * @param \phpbb\template\template $template * @param \phpbb\user $user * @param \phpbb\controller\helper $helper - * @param \nickvergessen\newspage\newspage $newspage + * @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, \nickvergessen\newspage\newspage $newspage, $root_path, $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) { $this->config = $config; $this->dispatcher = $dispatcher; @@ -72,11 +72,7 @@ public function __construct(\phpbb\config\config $config, \phpbb\event\dispatche $this->root_path = $root_path; $this->php_ext = $php_ext; - if (!class_exists('bbcode')) - { - include($this->root_path . 'includes/bbcode.' . $this->php_ext); - } - if (!function_exists('get_user_rank')) + if (!function_exists('phpbb_get_user_rank')) { include($this->root_path . 'includes/functions_display.' . $this->php_ext); } @@ -118,6 +114,11 @@ public function newspage($forum_id, $year, $month, $page) ); extract($this->dispatcher->trigger_event('nickvergessen.newspage.newspage', compact($vars))); + if ($page < 1 || $month < 0 || $month > 12 || ($year && !$month) || (!$year && $month)) + { + throw new \phpbb\exception\http_exception(404, 'NO_NEWS'); + } + $this->newspage->set_category($forum_id) ->set_archive($year, $month) ->set_start(($page - 1) * $this->config['news_number']); @@ -177,8 +178,7 @@ public function base($display_pagination = true) } $this->newspage->base(); - // $this->assign_images($this->config['news_user_info'], $this->config['news_post_buttons']); - $this->assign_images(true, true); + $this->assign_images($this->config['news_user_info'], $this->config['news_post_buttons']); $this->template->assign_vars(array( 'S_ON_NEWSPAGE' => true, diff --git a/controller/settings.php b/controller/settings.php index bb91cc4..8ca461f 100644 --- a/controller/settings.php +++ b/controller/settings.php @@ -1,24 +1,21 @@ + * @copyright (c) 2026, phpBB Modders, https://www.phpbbmodders.com/ * @license GNU General Public License, version 2 (GPL-2.0) * - * For full copyright and license information, please see - * the license.txt file. */ -namespace nickvergessen\newspage\controller; +namespace phpbbmodders\newspage\controller; use phpbb\exception\http_exception; -use Symfony\Component\HttpFoundation\Response; /** - * Class settings - * - * @package nickvergessen\newspage\controller + * Saves the news page settings from the ACP settings form. */ class settings { @@ -31,51 +28,33 @@ class settings /* @var \phpbb\request\request_interface */ protected $request; - /* @var \phpbb\controller\helper */ - protected $helper; - - /* @var \phpbb\user */ - protected $user; - /** * Constructor * * @param \phpbb\auth\auth $auth * @param \phpbb\config\config $config * @param \phpbb\request\request_interface $request - * @param \phpbb\controller\helper $helper - * @param \phpbb\user $user */ - public function __construct(\phpbb\auth\auth $auth, \phpbb\config\config $config, \phpbb\request\request_interface $request, \phpbb\controller\helper $helper, \phpbb\user $user) + public function __construct(\phpbb\auth\auth $auth, \phpbb\config\config $config, \phpbb\request\request_interface $request) { $this->auth = $auth; $this->config = $config; $this->request = $request; - $this->helper = $helper; - $this->user = $user; } /** - * Newspage controller to display multiple news - * @return Response A Symfony Response object - * @throws http_exception + * Save the submitted settings. The caller checks the form token. + * + * @return void + * @throws http_exception When the user may not change board settings */ - public function manage() + public function save_settings() { - $this->meta_refresh(); - - // Redirect non admins back to the newspage if (!$this->auth->acl_get('a_board')) { throw new http_exception(403, 'NO_AUTH_OPERATION'); } - // Is someone trying to fool us? - if (!check_form_key('newspage') || !$this->request->is_set_post('submit')) - { - throw new http_exception(400, 'FORM_INVALID'); - } - if ($this->request->variable('news_char_limit', 0) !== 0) { $this->config->set('news_char_limit', max(100, $this->request->variable('news_char_limit', 0))); @@ -95,18 +74,5 @@ public function manage() $this->config->set('news_attach_show', $this->request->variable('news_attach_show', false)); $this->config->set('news_cat_show', $this->request->variable('news_cat_show', false)); $this->config->set('news_archive_show', $this->request->variable('news_archive_show', false)); - - $this->user->add_lang_ext('nickvergessen/newspage', 'newspage'); - return $this->helper->message('NEWS_SAVED'); - } - - /** - * Only put into a method for better mockability - * - * @return null - */ - public function meta_refresh() - { - meta_refresh(3, $this->helper->route('nickvergessen_newspage_controller')); } } diff --git a/docs/TODO.md b/docs/TODO.md index fe4e312..e521630 100644 --- a/docs/TODO.md +++ b/docs/TODO.md @@ -1,14 +1,6 @@ # TODO -## phpBB 3.3 Compatibility - -- Choose the minimum supported phpBB 3.3 and PHP versions. -- Update Composer metadata and add an enforced extension enableability check. -- Quote service references and parameters in YAML for Symfony compatibility. -- Check the message-trimming dependency and news rendering against phpBB 3.3. -- Update prosilver templates and review output escaping. -- Update the imported test suite and add phpBB 3.3 runtime CI. -- Validate fresh install, upgrade, disable/re-enable, purge, permissions, - settings, news filters, pagination, archives, and attachments on disposable boards. - -Preserve existing migrations. Add new migrations only when needed. +- **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. diff --git a/docs/events.md b/docs/events.md index 0d55aff..69b8ceb 100644 --- a/docs/events.md +++ b/docs/events.md @@ -1,5 +1,8 @@ # Available php Events +The PHP and template events keep the names they had in `nickvergessen/newspage`, +so listeners and style templates written for it keep working. + ### nickvergessen.newspage.newspage * Locations: + controller/main.php diff --git a/docs/images/screenshots/README.md b/docs/images/screenshots/README.md new file mode 100644 index 0000000..1fa46f8 --- /dev/null +++ b/docs/images/screenshots/README.md @@ -0,0 +1,37 @@ +# NV Newspage screenshots + +Captured with [phpbb-release-tools](https://github.com/phpbbmodders/phpbb-release-tools)’ `phpbb-test-board/screenshots.py` on a disposable phpBB 3.3.19 board, with three example news topics. Poster information and the post buttons are turned off; the other settings are the defaults. + +## News page + +News page + +## With poster information and post buttons + +**Show user information** and **Show post-related buttons** on, seen by the admin, who gets every button. + +News page with poster information and post buttons + +## Shortened news + +**Shorten news text** set to 120 characters. Longer news ends with "…", and **Read full news** opens the whole post. + +News page with shortened news + +## Without the filters + +**Allow to filter by forums** and **Allow to filter by date** off. + +News page without the filters + +## A single news item + +A single news item + +## ACP settings + +ACP settings + +## News page on a phone + +News page on a phone diff --git a/docs/images/screenshots/newspage-acp-settings.png b/docs/images/screenshots/newspage-acp-settings.png new file mode 100644 index 0000000..b3dfcb0 Binary files /dev/null and b/docs/images/screenshots/newspage-acp-settings.png differ diff --git a/docs/images/screenshots/newspage-news-full.png b/docs/images/screenshots/newspage-news-full.png new file mode 100644 index 0000000..d75a9ac Binary files /dev/null and b/docs/images/screenshots/newspage-news-full.png differ diff --git a/docs/images/screenshots/newspage-news-no-filters.png b/docs/images/screenshots/newspage-news-no-filters.png new file mode 100644 index 0000000..e639049 Binary files /dev/null and b/docs/images/screenshots/newspage-news-no-filters.png differ diff --git a/docs/images/screenshots/newspage-news-phone.png b/docs/images/screenshots/newspage-news-phone.png new file mode 100644 index 0000000..df72f62 Binary files /dev/null and b/docs/images/screenshots/newspage-news-phone.png differ diff --git a/docs/images/screenshots/newspage-news-shortened.png b/docs/images/screenshots/newspage-news-shortened.png new file mode 100644 index 0000000..e55a42d Binary files /dev/null and b/docs/images/screenshots/newspage-news-shortened.png differ diff --git a/docs/images/screenshots/newspage-news.png b/docs/images/screenshots/newspage-news.png new file mode 100644 index 0000000..7e64d27 Binary files /dev/null and b/docs/images/screenshots/newspage-news.png differ diff --git a/docs/images/screenshots/newspage-single.png b/docs/images/screenshots/newspage-single.png new file mode 100644 index 0000000..65a488d Binary files /dev/null and b/docs/images/screenshots/newspage-single.png differ diff --git a/event/menu_link_listener.php b/event/menu_link_listener.php index 7b6b2a3..ac6628f 100644 --- a/event/menu_link_listener.php +++ b/event/menu_link_listener.php @@ -1,16 +1,16 @@ + * @copyright (c) 2026, phpBB Modders, https://www.phpbbmodders.com/ * @license GNU General Public License, version 2 (GPL-2.0) * - * For full copyright and license information, please see - * the license.txt file. */ -namespace nickvergessen\newspage\event; +namespace phpbbmodders\newspage\event; use Symfony\Component\EventDispatcher\EventSubscriberInterface; @@ -18,22 +18,25 @@ * Class menu_link_listener * Creates the link in the head navbar * - * @package nickvergessen\newspage\event + * @package phpbbmodders\newspage\event */ class menu_link_listener implements EventSubscriberInterface { - /* @var \nickvergessen\newspage\helper */ + /* @var \phpbbmodders\newspage\helper */ protected $helper; /* @var \phpbb\template\template */ protected $template; + /** @var \phpbb\config\config */ + protected $config; + /** * Register to the events * * @return array */ - static public function getSubscribedEvents() + public static function getSubscribedEvents() { return array( 'core.user_setup' => 'load_language_on_setup', @@ -44,13 +47,15 @@ static public function getSubscribedEvents() /** * Constructor * - * @param \nickvergessen\newspage\helper $helper + * @param \phpbbmodders\newspage\helper $helper * @param \phpbb\template\template $template + * @param \phpbb\config\config $config */ - public function __construct(\nickvergessen\newspage\helper $helper, \phpbb\template\template $template) + public function __construct(\phpbbmodders\newspage\helper $helper, \phpbb\template\template $template, \phpbb\config\config $config) { $this->helper = $helper; $this->template = $template; + $this->config = $config; } /** @@ -61,7 +66,7 @@ public function load_language_on_setup($event) { $lang_set_ext = $event['lang_set_ext']; $lang_set_ext[] = array( - 'ext_name' => 'nickvergessen/newspage', + 'ext_name' => 'phpbbmodders/newspage', 'lang_set' => 'newspage', ); $event['lang_set_ext'] = $lang_set_ext; @@ -74,6 +79,7 @@ public function add_page_header_link() { $this->template->assign_vars(array( 'U_NEWSPAGE' => $this->helper->generate_route()->get_url(), + 'NEWSPAGE_ICON' => isset($this->config['news_icon']) ? $this->config['news_icon'] : 'fa-bullhorn', )); } } diff --git a/event/viewonline_listener.php b/event/viewonline_listener.php index dee7e0f..d8f9547 100644 --- a/event/viewonline_listener.php +++ b/event/viewonline_listener.php @@ -1,16 +1,16 @@ + * @copyright (c) 2026, phpBB Modders, https://www.phpbbmodders.com/ * @license GNU General Public License, version 2 (GPL-2.0) * - * For full copyright and license information, please see - * the license.txt file. */ -namespace nickvergessen\newspage\event; +namespace phpbbmodders\newspage\event; use Symfony\Component\EventDispatcher\EventSubscriberInterface; @@ -18,7 +18,7 @@ * Class viewonline_listener * Handles displaying the route name and link on viewonline.php * - * @package nickvergessen\newspage\event + * @package phpbbmodders\newspage\event */ class viewonline_listener implements EventSubscriberInterface { @@ -27,14 +27,14 @@ class viewonline_listener implements EventSubscriberInterface * * @return array */ - static public function getSubscribedEvents() + public static function getSubscribedEvents() { return array( 'core.viewonline_overwrite_location' => 'add_newspage_viewonline', ); } - /* @var \nickvergessen\newspage\helper */ + /* @var \phpbbmodders\newspage\helper */ protected $helper; /* @var \phpbb\user */ @@ -46,11 +46,11 @@ static public function getSubscribedEvents() /** * Constructor * - * @param \nickvergessen\newspage\helper $helper + * @param \phpbbmodders\newspage\helper $helper * @param \phpbb\user $user * @param string $php_ext */ - public function __construct(\nickvergessen\newspage\helper $helper, \phpbb\user $user, $php_ext) + public function __construct(\phpbbmodders\newspage\helper $helper, \phpbb\user $user, $php_ext) { $this->helper = $helper; $this->user = $user; @@ -58,73 +58,98 @@ public function __construct(\nickvergessen\newspage\helper $helper, \phpbb\user } /** - * @param array $event - * @return null + * Name the news page a user is on in the Who is online list. + * + * @param \phpbb\event\data $event + * @return void */ public function add_newspage_viewonline($event) { + $parts = $this->get_news_route_parts(isset($event['row']['session_page']) ? $event['row']['session_page'] : ''); + if ($parts === false) + { + return; + } + $route = $this->helper->generate_route(); - if ($event['on_page'][1] == 'app') + $forum_id = $this->get_category_from_route($parts); + $archive = $this->get_archive_from_route($parts); + + if (count($parts) === 1) + { + $event['location_url'] = $route->get_url(); + $event['location'] = $this->user->lang('VIEWONLINE_NEWS'); + } + else if ($forum_id && $archive) + { + $archive_start = $this->user->get_timestamp_from_format('Y/n-d H:i:s', $archive . '-01 0:00:00'); + + $event['location_url'] = $route->get_url($forum_id, $archive); + $event['location'] = $this->user->lang('VIEWONLINE_NEWS_CATEGORY_ARCHIVE', $event['forum_data'][$forum_id]['forum_name'], $this->user->format_date($archive_start, 'F Y')); + } + else if ($forum_id) { - if ($event['row']['session_page'] === 'app.' . $this->php_ext . '/news') - { - $event['location_url'] = $route->get_url(); - $event['location'] = $this->user->lang('VIEWONLINE_NEWS'); - } - else if (($forum_id = $this->get_category_from_route($event['row']['session_page'])) && - ($archive = $this->get_archive_from_route($event['row']['session_page']))) - { - $archive_start = $this->user->get_timestamp_from_format('Y/n-d H:i:s', $archive . '-01 0:00:00'); - - $event['location_url'] = $route->get_url($forum_id, $archive); - $event['location'] = $this->user->lang('VIEWONLINE_NEWS_CATEGORY_ARCHIVE', $event['forum_data'][$forum_id]['forum_name'], $this->user->format_date($archive_start, 'F Y')); - } - else if ($forum_id = $this->get_category_from_route($event['row']['session_page'])) - { - $event['location_url'] = $route->get_url($forum_id); - $event['location'] = $this->user->lang('VIEWONLINE_NEWS_CATEGORY', $event['forum_data'][$forum_id]['forum_name']); - } - else if ($archive = $this->get_archive_from_route($event['row']['session_page'])) - { - $archive_start = $this->user->get_timestamp_from_format('Y/n-d H:i:s', $archive . '-01 0:00:00'); - - $event['location_url'] = $route->get_url(false, $archive); - $event['location'] = $this->user->lang('VIEWONLINE_NEWS_ARCHIVE', $this->user->format_date($archive_start, 'F Y')); - } + $event['location_url'] = $route->get_url($forum_id); + $event['location'] = $this->user->lang('VIEWONLINE_NEWS_CATEGORY', $event['forum_data'][$forum_id]['forum_name']); + } + else if ($archive) + { + $archive_start = $this->user->get_timestamp_from_format('Y/n-d H:i:s', $archive . '-01 0:00:00'); + + $event['location_url'] = $route->get_url(false, $archive); + $event['location'] = $this->user->lang('VIEWONLINE_NEWS_ARCHIVE', $this->user->format_date($archive_start, 'F Y')); } } /** - * @param string $route - * @return int|bool + * Split a session page into its route parts when it is a news page. + * + * phpBB 3.3 records news pages as "app.php/news/...", phpBB 4.0 as + * "index.php/news/...". Both become ['news', ...]. + * + * @param string $session_page The session's page, as phpBB stores it + * @return array|bool The parts from "news" on, or false for other pages */ - protected function get_category_from_route($route) + protected function get_news_route_parts($session_page) { - $route_ary = explode('/', $route); + $path = (string) parse_url($session_page, PHP_URL_PATH); + $parts = explode('/', trim($path, '/')); - if (sizeof($route_ary) >= 3 && $route_ary[0] === 'app.' . $this->php_ext && $route_ary[1] === 'news' && $route_ary[2] === 'category') + if (in_array($parts[0], array('app.' . $this->php_ext, 'index.' . $this->php_ext), true)) { - return (int) $route_ary[3]; + array_shift($parts); } - return false; + return (isset($parts[0]) && $parts[0] === 'news') ? $parts : false; } /** - * @param string $route - * @return string|bool + * @param array $parts Route parts from get_news_route_parts() + * @return int|bool */ - protected function get_archive_from_route($route) + protected function get_category_from_route(array $parts) { - $route_ary = explode('/', $route); + if (isset($parts[1], $parts[2]) && $parts[1] === 'category') + { + return (int) $parts[2]; + } - if (sizeof($route_ary) >= 4 && $route_ary[0] === 'app.' . $this->php_ext && $route_ary[1] === 'news' && $route_ary[2] === 'archive') + return false; + } + + /** + * @param array $parts Route parts from get_news_route_parts() + * @return string|bool Year and month as "Y/n" + */ + protected function get_archive_from_route(array $parts) + { + if (isset($parts[1], $parts[3]) && $parts[1] === 'archive') { - return (int) $route_ary[3] . '/' . (int) $route_ary[4]; + return (int) $parts[2] . '/' . (int) $parts[3]; } - else if (sizeof($route_ary) >= 6 && $route_ary[0] === 'app.' . $this->php_ext && $route_ary[1] === 'news' && $route_ary[4] === 'archive') + else if (isset($parts[3], $parts[5]) && $parts[3] === 'archive') { - return (int) $route_ary[5] . '/' . (int) $route_ary[6]; + return (int) $parts[4] . '/' . (int) $parts[5]; } return false; diff --git a/ext.php b/ext.php new file mode 100644 index 0000000..4435fb3 --- /dev/null +++ b/ext.php @@ -0,0 +1,223 @@ + + * @copyright (c) 2026, phpBB Modders, https://www.phpbbmodders.com/ + * @license GNU General Public License, version 2 (GPL-2.0) + * + */ + +namespace phpbbmodders\newspage; + +/** + * NV Newspage extension base + * + * Handles the switch from the old "nickvergessen/newspage" package name: an existing + * install's data is moved over to the new name when this extension is + * enabled, so nothing is installed twice and no settings are lost. + */ +class ext extends \phpbb\extension\base +{ + /** Package name this extension used before the rename */ + const OLD_EXT_NAME = 'nickvergessen/newspage'; + + /** Package name this extension uses now */ + const NEW_EXT_NAME = 'phpbbmodders/newspage'; + + /** PHP namespace prefix used before the rename */ + const OLD_NAMESPACE = '\\nickvergessen\\newspage\\'; + + /** PHP namespace prefix used now */ + const NEW_NAMESPACE = '\\phpbbmodders\\newspage\\'; + + /** + * Refuse to enable below the minimum phpBB and PHP versions, or without + * PHP's DOM extension, which shortens the news text. + * + * Refuse to enable while the old copy is still enabled; both would run + * at once and the old one's data can't be moved while it's in use. + * + * @return bool|string|array True if enableable, otherwise a reason string or array of reasons + */ + public function is_enableable() + { + if (!$this->check_phpbb_version() || !$this->check_php_version() || !extension_loaded('dom')) + { + $language = $this->container->get('language'); + $language->add_lang('install_newspage', 'phpbbmodders/newspage'); + + return $language->lang('NEWSPAGE_NOT_ENABLEABLE'); + } + + if ($this->container->get('ext.manager')->is_enabled(self::OLD_EXT_NAME)) + { + $language = $this->container->get('language'); + $language->add_lang('install_newspage', 'phpbbmodders/newspage'); + + return $language->lang('NEWSPAGE_DISABLE_OLD', self::OLD_EXT_NAME); + } + + return true; + } + + /** + * Require phpBB 3.3.19 + * + * @return bool + */ + public function check_phpbb_version() + { + return phpbb_version_compare(PHPBB_VERSION, '3.3.19', '>='); + } + + /** + * Require PHP 7.4 + * + * @return bool + */ + public function check_php_version() + { + return PHP_VERSION_ID >= 70400; + } + + /** + * Move an old install's data to the new name, then enable as usual. + * + * @param mixed $old_state State returned by previous call of this method + * @return bool|string + */ + public function enable_step($old_state) + { + if ($old_state === false) + { + $this->move_old_install(); + + // The migrator loaded its state before this ran; reload it so the + // moved migration history counts as already installed. + $this->migrator->load_migration_state(); + } + + return parent::enable_step($old_state); + } + + /** + * Rewrite everything the database stores under the old name. + * + * Rows are filtered in PHP rather than with LIKE, because namespace + * backslashes and underscores are special characters in LIKE patterns + * on some databases. The tables involved are small, and each changed row + * gets its own new value, so it is one UPDATE per row; this runs once, + * when an old install is moved. + */ + protected function move_old_install() + { + $db = $this->container->get('dbal.conn'); + + $db->sql_transaction('begin'); + + // Migration history, including each migration's dependency list + $sql = 'SELECT migration_name, migration_depends_on + FROM ' . MIGRATIONS_TABLE; + $result = $db->sql_query($sql); + $rows = $db->sql_fetchrowset($result); + $db->sql_freeresult($result); + + $recorded = array_column($rows, 'migration_name', 'migration_name'); + + foreach ($rows as $row) + { + // Other extensions' migrations may depend on ours, so their + // dependency lists are rewritten too, not just our own rows + $old_depends_on = unserialize($row['migration_depends_on'], ['allowed_classes' => false]); + $old_depends_on = is_array($old_depends_on) ? $old_depends_on : []; + $depends_on = array_map([$this, 'new_class_name'], $old_depends_on); + $name = $this->new_class_name($row['migration_name']); + + if ($name === $row['migration_name'] && $depends_on === $old_depends_on) + { + continue; + } + + // The new name is already recorded when the old extension was + // enabled again after an earlier move: drop the old row rather + // than collide with the unique index on the name + if ($name !== $row['migration_name'] && isset($recorded[$name])) + { + $sql = 'DELETE FROM ' . MIGRATIONS_TABLE . " + WHERE migration_name = '" . $db->sql_escape($row['migration_name']) . "'"; + $db->sql_query($sql); + continue; + } + + $recorded[$name] = $name; + + $sql = 'UPDATE ' . MIGRATIONS_TABLE . ' + SET ' . $db->sql_build_array('UPDATE', [ + 'migration_name' => $name, + 'migration_depends_on' => serialize($depends_on), + ]) . " + WHERE migration_name = '" . $db->sql_escape($row['migration_name']) . "'"; + $db->sql_query($sql); + } + + // Module classes and their "ext_vendor/name" auth checks + $sql = 'SELECT module_id, module_basename, module_auth + FROM ' . MODULES_TABLE; + $result = $db->sql_query($sql); + $rows = $db->sql_fetchrowset($result); + $db->sql_freeresult($result); + + foreach ($rows as $row) + { + $basename = $this->new_class_name($row['module_basename']); + $auth = str_replace('ext_' . self::OLD_EXT_NAME, 'ext_' . self::NEW_EXT_NAME, $row['module_auth']); + + if ($basename !== $row['module_basename'] || $auth !== $row['module_auth']) + { + $sql = 'UPDATE ' . MODULES_TABLE . ' + SET ' . $db->sql_build_array('UPDATE', [ + 'module_basename' => $basename, + 'module_auth' => $auth, + ]) . ' + WHERE module_id = ' . (int) $row['module_id']; + $db->sql_query($sql); + } + } + + // The old extension's own record (only once it's disabled) + $sql = 'DELETE FROM ' . EXT_TABLE . " + WHERE ext_name = '" . $db->sql_escape(self::OLD_EXT_NAME) . "' + AND ext_active = 0"; + $db->sql_query($sql); + + $db->sql_transaction('commit'); + } + + /** + * Map an old fully qualified class name to the new namespace. + * + * @param string $class_name Class name, possibly under the old namespace + * @return string + */ + protected function new_class_name($class_name) + { + if (!is_string($class_name)) + { + return $class_name; + } + + // Class names may be stored with or without the leading backslash + foreach ([self::OLD_NAMESPACE, ltrim(self::OLD_NAMESPACE, '\\')] as $old) + { + if (strpos($class_name, $old) === 0) + { + $new = ($old === self::OLD_NAMESPACE) ? self::NEW_NAMESPACE : ltrim(self::NEW_NAMESPACE, '\\'); + return $new . substr($class_name, strlen($old)); + } + } + + return $class_name; + } +} diff --git a/helper.php b/helper.php index 96427b4..0c254b5 100644 --- a/helper.php +++ b/helper.php @@ -1,21 +1,21 @@ + * @copyright (c) 2026, phpBB Modders, https://www.phpbbmodders.com/ * @license GNU General Public License, version 2 (GPL-2.0) * - * For full copyright and license information, please see - * the license.txt file. */ -namespace nickvergessen\newspage; +namespace phpbbmodders\newspage; /** * Class helper * - * @package nickvergessen\newspage + * @package phpbbmodders\newspage */ class helper { @@ -43,7 +43,7 @@ public function __construct(\phpbb\controller\helper $helper, \phpbb\config\conf * @param mixed $force_category Overwrites the category, false for disabled, integer otherwise * @param mixed $force_archive Overwrites the archive, false for disabled, string otherwise * @param mixed $force_page Overwrites the page, false for disabled, string otherwise - * @return \nickvergessen\newspage\route Full URL with append_sid performed on it + * @return \phpbbmodders\newspage\route Full URL with append_sid performed on it */ public function generate_route($force_category = false, $force_archive = false, $force_page = false) { diff --git a/language/de/newspage.php b/language/de/newspage.php index e1f6c97..369f9c6 100644 --- a/language/de/newspage.php +++ b/language/de/newspage.php @@ -1,13 +1,13 @@ + * @copyright (c) 2026, phpBB Modders, https://www.phpbbmodders.com/ * @license GNU General Public License, version 2 (GPL-2.0) * - * For full copyright and license information, please see - * the license.txt file. */ if (!defined('IN_PHPBB')) diff --git a/language/en/info_acp_newspage.php b/language/en/info_acp_newspage.php new file mode 100644 index 0000000..b73dbe9 --- /dev/null +++ b/language/en/info_acp_newspage.php @@ -0,0 +1,29 @@ + 'Newspage', + 'ACP_NEWSPAGE_SETTINGS' => 'Settings', + 'ACP_NEWSPAGE_SETTINGS_EXPLAIN' => 'Configure the news forums and how news is displayed.', + 'LOG_NEWSPAGE_SETTINGS' => 'Changed Newspage settings', + 'NEWS_ICON' => 'News navigation icon', + 'NEWS_ICON_EXPLAIN' => 'Font Awesome icon class, for example fa-bullhorn or fa-rss. phpBB 3.3 uses Font Awesome 4.7 and phpBB 4.0 uses Font Awesome 6, so choose a name both have.', + 'NEWS_ICON_INVALID' => 'Enter a Font Awesome icon class in the format fa-bullhorn.', +)); diff --git a/language/en/install_newspage.php b/language/en/install_newspage.php new file mode 100644 index 0000000..f0a69df --- /dev/null +++ b/language/en/install_newspage.php @@ -0,0 +1,27 @@ + 'NV Newspage could not be enabled. It needs phpBB 3.3.19 or later, PHP 7.4.0 or later, and the PHP DOM extension.', + 'NEWSPAGE_DISABLE_OLD' => 'Disable the old “%s” extension first. Keep its data; do not delete it.', +]); diff --git a/language/en/newspage.php b/language/en/newspage.php index ed44851..e5cda0d 100644 --- a/language/en/newspage.php +++ b/language/en/newspage.php @@ -1,13 +1,13 @@ + * @copyright (c) 2026, phpBB Modders, https://www.phpbbmodders.com/ * @license GNU General Public License, version 2 (GPL-2.0) * - * For full copyright and license information, please see - * the license.txt file. */ if (!defined('IN_PHPBB')) diff --git a/message_trimmer.php b/message_trimmer.php new file mode 100644 index 0000000..08539e8 --- /dev/null +++ b/message_trimmer.php @@ -0,0 +1,75 @@ +loadHTML('
' . $html . '
', LIBXML_NONET); + libxml_clear_errors(); + libxml_use_internal_errors($previous); + if (!$loaded) + { + return $html; + } + + $wrapper = $document->getElementsByTagName('div')->item(0); + if (utf8_strlen($wrapper->textContent) <= $limit) + { + return $html; + } + + $remaining = $limit; + $this->trim_children($wrapper, $remaining); + $wrapper->appendChild($document->createTextNode('...')); + $result = ''; + foreach ($wrapper->childNodes as $node) + { + $result .= $document->saveHTML($node); + } + return $result; + } + + protected function trim_children(\DOMNode $parent, &$remaining) + { + foreach (iterator_to_array($parent->childNodes) as $node) + { + if ($remaining === 0) + { + $parent->removeChild($node); + } + else if ($node instanceof \DOMText) + { + $length = utf8_strlen($node->nodeValue); + $node->nodeValue = utf8_substr($node->nodeValue, 0, $remaining); + $remaining -= min($remaining, $length); + } + else if ($node->hasChildNodes()) + { + $this->trim_children($node, $remaining); + } + } + } +} diff --git a/migrations/v10x/release_1_0_0.php b/migrations/v10x/release_1_0_0.php index 0ff0723..06a752c 100644 --- a/migrations/v10x/release_1_0_0.php +++ b/migrations/v10x/release_1_0_0.php @@ -1,21 +1,21 @@ + * @copyright (c) 2026, phpBB Modders, https://www.phpbbmodders.com/ * @license GNU General Public License, version 2 (GPL-2.0) * - * For full copyright and license information, please see - * the license.txt file. */ -namespace nickvergessen\newspage\migrations\v10x; +namespace phpbbmodders\newspage\migrations\v10x; use phpbb\db\migration\migration; /** - * @package nickvergessen\newspage\migrations\v10x + * @package phpbbmodders\newspage\migrations\v10x */ class release_1_0_0 extends migration { @@ -30,7 +30,7 @@ public function effectively_installed() /** * {@inheritdoc} */ - static public function depends_on() + public static function depends_on() { return array('\phpbb\db\migration\data\v310\dev'); } diff --git a/migrations/v10x/release_1_0_1.php b/migrations/v10x/release_1_0_1.php index a63a54d..763595b 100644 --- a/migrations/v10x/release_1_0_1.php +++ b/migrations/v10x/release_1_0_1.php @@ -1,21 +1,21 @@ + * @copyright (c) 2026, phpBB Modders, https://www.phpbbmodders.com/ * @license GNU General Public License, version 2 (GPL-2.0) * - * For full copyright and license information, please see - * the license.txt file. */ -namespace nickvergessen\newspage\migrations\v10x; +namespace phpbbmodders\newspage\migrations\v10x; use phpbb\db\migration\migration; /** - * @package nickvergessen\newspage\migrations\v10x + * @package phpbbmodders\newspage\migrations\v10x */ class release_1_0_1 extends migration { @@ -30,9 +30,9 @@ public function effectively_installed() /** * {@inheritdoc} */ - static public function depends_on() + public static function depends_on() { - return array('\nickvergessen\newspage\migrations\v10x\release_1_0_0'); + return array('\phpbbmodders\newspage\migrations\v10x\release_1_0_0'); } /** diff --git a/migrations/v10x/release_1_0_2.php b/migrations/v10x/release_1_0_2.php index da59efb..a7796a5 100644 --- a/migrations/v10x/release_1_0_2.php +++ b/migrations/v10x/release_1_0_2.php @@ -1,21 +1,21 @@ + * @copyright (c) 2026, phpBB Modders, https://www.phpbbmodders.com/ * @license GNU General Public License, version 2 (GPL-2.0) * - * For full copyright and license information, please see - * the license.txt file. */ -namespace nickvergessen\newspage\migrations\v10x; +namespace phpbbmodders\newspage\migrations\v10x; use phpbb\db\migration\migration; /** - * @package nickvergessen\newspage\migrations\v10x + * @package phpbbmodders\newspage\migrations\v10x */ class release_1_0_2 extends migration { @@ -30,9 +30,9 @@ public function effectively_installed() /** * {@inheritdoc} */ - static public function depends_on() + public static function depends_on() { - return array('\nickvergessen\newspage\migrations\v10x\release_1_0_1'); + return array('\phpbbmodders\newspage\migrations\v10x\release_1_0_1'); } /** diff --git a/migrations/v10x/release_1_0_3.php b/migrations/v10x/release_1_0_3.php index b508da9..05c27ed 100644 --- a/migrations/v10x/release_1_0_3.php +++ b/migrations/v10x/release_1_0_3.php @@ -1,21 +1,21 @@ + * @copyright (c) 2026, phpBB Modders, https://www.phpbbmodders.com/ * @license GNU General Public License, version 2 (GPL-2.0) * - * For full copyright and license information, please see - * the license.txt file. */ -namespace nickvergessen\newspage\migrations\v10x; +namespace phpbbmodders\newspage\migrations\v10x; use phpbb\db\migration\migration; /** - * @package nickvergessen\newspage\migrations\v10x + * @package phpbbmodders\newspage\migrations\v10x */ class release_1_0_3 extends migration { @@ -30,9 +30,9 @@ public function effectively_installed() /** * {@inheritdoc} */ - static public function depends_on() + public static function depends_on() { - return array('\nickvergessen\newspage\migrations\v10x\release_1_0_2'); + return array('\phpbbmodders\newspage\migrations\v10x\release_1_0_2'); } /** diff --git a/migrations/v10x/release_1_0_4.php b/migrations/v10x/release_1_0_4.php index 396b672..29e2461 100644 --- a/migrations/v10x/release_1_0_4.php +++ b/migrations/v10x/release_1_0_4.php @@ -1,21 +1,21 @@ + * @copyright (c) 2026, phpBB Modders, https://www.phpbbmodders.com/ * @license GNU General Public License, version 2 (GPL-2.0) * - * For full copyright and license information, please see - * the license.txt file. */ -namespace nickvergessen\newspage\migrations\v10x; +namespace phpbbmodders\newspage\migrations\v10x; use phpbb\db\migration\migration; /** - * @package nickvergessen\newspage\migrations\v10x + * @package phpbbmodders\newspage\migrations\v10x */ class release_1_0_4 extends migration { @@ -30,9 +30,9 @@ public function effectively_installed() /** * {@inheritdoc} */ - static public function depends_on() + public static function depends_on() { - return array('\nickvergessen\newspage\migrations\v10x\release_1_0_3'); + return array('\phpbbmodders\newspage\migrations\v10x\release_1_0_3'); } /** diff --git a/migrations/v10x/release_1_0_5.php b/migrations/v10x/release_1_0_5.php index 332e0bb..de78bc6 100644 --- a/migrations/v10x/release_1_0_5.php +++ b/migrations/v10x/release_1_0_5.php @@ -1,21 +1,21 @@ + * @copyright (c) 2026, phpBB Modders, https://www.phpbbmodders.com/ * @license GNU General Public License, version 2 (GPL-2.0) * - * For full copyright and license information, please see - * the license.txt file. */ -namespace nickvergessen\newspage\migrations\v10x; +namespace phpbbmodders\newspage\migrations\v10x; use phpbb\db\migration\migration; /** - * @package nickvergessen\newspage\migrations\v10x + * @package phpbbmodders\newspage\migrations\v10x */ class release_1_0_5 extends migration { @@ -30,9 +30,9 @@ public function effectively_installed() /** * {@inheritdoc} */ - static public function depends_on() + public static function depends_on() { - return array('\nickvergessen\newspage\migrations\v10x\release_1_0_4'); + return array('\phpbbmodders\newspage\migrations\v10x\release_1_0_4'); } /** diff --git a/migrations/v10x/release_1_0_5_1.php b/migrations/v10x/release_1_0_5_1.php index f68d9c3..be67963 100644 --- a/migrations/v10x/release_1_0_5_1.php +++ b/migrations/v10x/release_1_0_5_1.php @@ -1,21 +1,21 @@ + * @copyright (c) 2026, phpBB Modders, https://www.phpbbmodders.com/ * @license GNU General Public License, version 2 (GPL-2.0) * - * For full copyright and license information, please see - * the license.txt file. */ -namespace nickvergessen\newspage\migrations\v10x; +namespace phpbbmodders\newspage\migrations\v10x; use phpbb\db\migration\migration; /** - * @package nickvergessen\newspage\migrations\v10x + * @package phpbbmodders\newspage\migrations\v10x */ class release_1_0_5_1 extends migration { @@ -30,9 +30,9 @@ public function effectively_installed() /** * {@inheritdoc} */ - static public function depends_on() + public static function depends_on() { - return array('\nickvergessen\newspage\migrations\v10x\release_1_0_5'); + return array('\phpbbmodders\newspage\migrations\v10x\release_1_0_5'); } /** diff --git a/migrations/v10x/release_1_0_6.php b/migrations/v10x/release_1_0_6.php index ee29cfe..e83989d 100644 --- a/migrations/v10x/release_1_0_6.php +++ b/migrations/v10x/release_1_0_6.php @@ -1,21 +1,21 @@ + * @copyright (c) 2026, phpBB Modders, https://www.phpbbmodders.com/ * @license GNU General Public License, version 2 (GPL-2.0) * - * For full copyright and license information, please see - * the license.txt file. */ -namespace nickvergessen\newspage\migrations\v10x; +namespace phpbbmodders\newspage\migrations\v10x; use phpbb\db\migration\migration; /** - * @package nickvergessen\newspage\migrations\v10x + * @package phpbbmodders\newspage\migrations\v10x */ class release_1_0_6 extends migration { @@ -30,9 +30,9 @@ public function effectively_installed() /** * {@inheritdoc} */ - static public function depends_on() + public static function depends_on() { - return array('\nickvergessen\newspage\migrations\v10x\release_1_0_5_1'); + return array('\phpbbmodders\newspage\migrations\v10x\release_1_0_5_1'); } /** diff --git a/migrations/v10x/release_1_0_7.php b/migrations/v10x/release_1_0_7.php index dd626d4..e36e20f 100644 --- a/migrations/v10x/release_1_0_7.php +++ b/migrations/v10x/release_1_0_7.php @@ -1,21 +1,21 @@ + * @copyright (c) 2026, phpBB Modders, https://www.phpbbmodders.com/ * @license GNU General Public License, version 2 (GPL-2.0) * - * For full copyright and license information, please see - * the license.txt file. */ -namespace nickvergessen\newspage\migrations\v10x; +namespace phpbbmodders\newspage\migrations\v10x; use phpbb\db\migration\migration; /** - * @package nickvergessen\newspage\migrations\v10x + * @package phpbbmodders\newspage\migrations\v10x */ class release_1_0_7 extends migration { @@ -30,9 +30,9 @@ public function effectively_installed() /** * {@inheritdoc} */ - static public function depends_on() + public static function depends_on() { - return array('\nickvergessen\newspage\migrations\v10x\release_1_0_6'); + return array('\phpbbmodders\newspage\migrations\v10x\release_1_0_6'); } /** diff --git a/migrations/v10x/release_1_0_8.php b/migrations/v10x/release_1_0_8.php index 1652a2d..fa13401 100644 --- a/migrations/v10x/release_1_0_8.php +++ b/migrations/v10x/release_1_0_8.php @@ -1,21 +1,21 @@ + * @copyright (c) 2026, phpBB Modders, https://www.phpbbmodders.com/ * @license GNU General Public License, version 2 (GPL-2.0) * - * For full copyright and license information, please see - * the license.txt file. */ -namespace nickvergessen\newspage\migrations\v10x; +namespace phpbbmodders\newspage\migrations\v10x; use phpbb\db\migration\migration; /** - * @package nickvergessen\newspage\migrations\v10x + * @package phpbbmodders\newspage\migrations\v10x */ class release_1_0_8 extends migration { @@ -30,9 +30,9 @@ public function effectively_installed() /** * {@inheritdoc} */ - static public function depends_on() + public static function depends_on() { - return array('\nickvergessen\newspage\migrations\v10x\release_1_0_7'); + return array('\phpbbmodders\newspage\migrations\v10x\release_1_0_7'); } /** diff --git a/migrations/v11x/acp_settings.php b/migrations/v11x/acp_settings.php new file mode 100644 index 0000000..ac5fda4 --- /dev/null +++ b/migrations/v11x/acp_settings.php @@ -0,0 +1,31 @@ + '\\phpbbmodders\\newspage\\acp\\main_module', + 'modes' => array('settings'), + ))), + ); + } +} diff --git a/migrations/v11x/better_archive_config_option.php b/migrations/v11x/better_archive_config_option.php index 36cb48f..0d720a9 100644 --- a/migrations/v11x/better_archive_config_option.php +++ b/migrations/v11x/better_archive_config_option.php @@ -1,21 +1,21 @@ + * @copyright (c) 2026, phpBB Modders, https://www.phpbbmodders.com/ * @license GNU General Public License, version 2 (GPL-2.0) * - * For full copyright and license information, please see - * the license.txt file. */ -namespace nickvergessen\newspage\migrations\v11x; +namespace phpbbmodders\newspage\migrations\v11x; use phpbb\db\migration\migration; /** - * @package nickvergessen\newspage\migrations\v11x + * @package phpbbmodders\newspage\migrations\v11x */ class better_archive_config_option extends migration { @@ -30,9 +30,9 @@ public function effectively_installed() /** * {@inheritdoc} */ - static public function depends_on() + public static function depends_on() { - return array('\nickvergessen\newspage\migrations\v11x\release_1_1_0'); + return array('\phpbbmodders\newspage\migrations\v11x\release_1_1_0'); } /** diff --git a/migrations/v11x/release_1_1_0.php b/migrations/v11x/release_1_1_0.php index f166d46..8974b3b 100644 --- a/migrations/v11x/release_1_1_0.php +++ b/migrations/v11x/release_1_1_0.php @@ -1,21 +1,21 @@ + * @copyright (c) 2026, phpBB Modders, https://www.phpbbmodders.com/ * @license GNU General Public License, version 2 (GPL-2.0) * - * For full copyright and license information, please see - * the license.txt file. */ -namespace nickvergessen\newspage\migrations\v11x; +namespace phpbbmodders\newspage\migrations\v11x; use phpbb\db\migration\migration; /** - * @package nickvergessen\newspage\migrations\v11x + * @package phpbbmodders\newspage\migrations\v11x */ class release_1_1_0 extends migration { @@ -30,9 +30,9 @@ public function effectively_installed() /** * {@inheritdoc} */ - static public function depends_on() + public static function depends_on() { - return array('\nickvergessen\newspage\migrations\v10x\release_1_0_8'); + return array('\phpbbmodders\newspage\migrations\v10x\release_1_0_8'); } /** diff --git a/migrations/v11x/release_1_1_1.php b/migrations/v11x/release_1_1_1.php index 0fca067..628f824 100644 --- a/migrations/v11x/release_1_1_1.php +++ b/migrations/v11x/release_1_1_1.php @@ -1,21 +1,21 @@ + * @copyright (c) 2026, phpBB Modders, https://www.phpbbmodders.com/ * @license GNU General Public License, version 2 (GPL-2.0) * - * For full copyright and license information, please see - * the license.txt file. */ -namespace nickvergessen\newspage\migrations\v11x; +namespace phpbbmodders\newspage\migrations\v11x; use phpbb\db\migration\migration; /** - * @package nickvergessen\newspage\migrations\v11x + * @package phpbbmodders\newspage\migrations\v11x */ class release_1_1_1 extends migration { @@ -30,12 +30,12 @@ public function effectively_installed() /** * {@inheritdoc} */ - static public function depends_on() + public static function depends_on() { return array( - '\nickvergessen\newspage\migrations\v11x\release_1_1_0', - '\nickvergessen\newspage\migrations\v11x\better_archive_config_option', - '\nickvergessen\newspage\migrations\v11x\replace_acp_module_with_controller', + '\phpbbmodders\newspage\migrations\v11x\release_1_1_0', + '\phpbbmodders\newspage\migrations\v11x\better_archive_config_option', + '\phpbbmodders\newspage\migrations\v11x\replace_acp_module_with_controller', ); } diff --git a/migrations/v11x/replace_acp_module_with_controller.php b/migrations/v11x/replace_acp_module_with_controller.php index b62e8e7..bb91dec 100644 --- a/migrations/v11x/replace_acp_module_with_controller.php +++ b/migrations/v11x/replace_acp_module_with_controller.php @@ -1,30 +1,30 @@ + * @copyright (c) 2026, phpBB Modders, https://www.phpbbmodders.com/ * @license GNU General Public License, version 2 (GPL-2.0) * - * For full copyright and license information, please see - * the license.txt file. */ -namespace nickvergessen\newspage\migrations\v11x; +namespace phpbbmodders\newspage\migrations\v11x; use phpbb\db\migration\migration; /** - * @package nickvergessen\newspage\migrations\v11x + * @package phpbbmodders\newspage\migrations\v11x */ class replace_acp_module_with_controller extends migration { /** * {@inheritdoc} */ - static public function depends_on() + public static function depends_on() { - return array('\nickvergessen\newspage\migrations\v11x\release_1_1_0'); + return array('\phpbbmodders\newspage\migrations\v11x\release_1_1_0'); } /** diff --git a/newspage.php b/newspage.php index d206a21..a14e36e 100644 --- a/newspage.php +++ b/newspage.php @@ -1,23 +1,21 @@ + * @copyright (c) 2026, phpBB Modders, https://www.phpbbmodders.com/ * @license GNU General Public License, version 2 (GPL-2.0) * - * For full copyright and license information, please see - * the license.txt file. */ -namespace nickvergessen\newspage; - -use Nickvergessen\TrimMessage\TrimMessage; +namespace phpbbmodders\newspage; /** * Class newspage * - * @package nickvergessen\newspage + * @package phpbbmodders\newspage */ class newspage { @@ -39,10 +37,12 @@ class newspage protected $content_visibility; /** @var \phpbb\controller\helper */ protected $helper; - /** @var \nickvergessen\newspage\helper */ + /** @var \phpbbmodders\newspage\helper */ protected $news_helper; /** @var \phpbb\pagination */ protected $pagination; + /** @var \phpbb\avatar\helper|null phpBB 4.0's avatar helper; null on phpBB 3.3 */ + protected $avatar_helper; /** @var string */ protected $root_path; @@ -54,13 +54,13 @@ class newspage /** @var string */ protected $page_title; /** @var int */ - protected $start; + protected $start = 0; /** @var int */ - protected $news; + protected $news = 0; /** @var array */ - protected $archive; + protected $archive = array('y' => 0, 'm' => 0); /** @var int */ - protected $category; + protected $category = 0; const ARCHIVE_SHOW = 1; const ARCHIVE_PER_YEAR = 2; @@ -86,12 +86,12 @@ class newspage * @param \phpbb\user $user User object * @param \phpbb\content_visibility $content_visibility Content visibility object * @param \phpbb\controller\helper $helper Controller helper object - * @param \nickvergessen\newspage\helper $news_helper Controller helper object + * @param \phpbbmodders\newspage\helper $news_helper Controller helper object * @param \phpbb\pagination $pagination Pagination object * @param string $root_path phpBB root path * @param string $php_ext phpEx */ - public function __construct(\phpbb\auth\auth $auth, \phpbb\cache\service $cache, \phpbb\config\config $config, \phpbb\db\driver\driver_interface $db, \phpbb\request\request_interface $request, \phpbb\template\template $template, \phpbb\user $user, \phpbb\content_visibility $content_visibility, \phpbb\controller\helper $helper, \nickvergessen\newspage\helper $news_helper, \phpbb\pagination $pagination, $root_path, $php_ext) + public function __construct(\phpbb\auth\auth $auth, \phpbb\cache\service $cache, \phpbb\config\config $config, \phpbb\db\driver\driver_interface $db, \phpbb\request\request_interface $request, \phpbb\template\template $template, \phpbb\user $user, \phpbb\content_visibility $content_visibility, \phpbb\controller\helper $helper, \phpbbmodders\newspage\helper $news_helper, \phpbb\pagination $pagination, $root_path, $php_ext) { $this->auth = $auth; $this->cache = $cache; @@ -107,10 +107,6 @@ public function __construct(\phpbb\auth\auth $auth, \phpbb\cache\service $cache, $this->root_path = $root_path; $this->php_ext = $php_ext; - if (!class_exists('bbcode')) - { - include($this->root_path . 'includes/bbcode.' . $this->php_ext); - } if (!function_exists('phpbb_get_user_rank')) { include($this->root_path . 'includes/functions_display.' . $this->php_ext); @@ -118,6 +114,50 @@ public function __construct(\phpbb\auth\auth $auth, \phpbb\cache\service $cache, $this->page_title = $this->user->lang['NEWS']; } + /** + * Set phpBB 4.0's avatar helper. phpBB 3.3 has none and passes null. + * + * @param \phpbb\avatar\helper|null $avatar_helper + * @return void + */ + public function set_avatar_helper($avatar_helper = null) + { + $this->avatar_helper = $avatar_helper; + } + + /** + * The poster's avatar as an image tag, as phpBB 3.3 makes it. + * + * phpBB 4.0 has no phpbb_get_user_avatar(); its avatar helper returns the + * avatar's data instead, which is turned into the same markup here so the + * news templates work on both versions. + * + * @param array $row User row with the user_avatar* columns + * @return string Image tag, or an empty string for no avatar + */ + protected function get_poster_avatar(array $row) + { + if (function_exists('phpbb_get_user_avatar')) + { + return phpbb_get_user_avatar($row); + } + + if ($this->avatar_helper === null) + { + return ''; + } + + $avatar = $this->avatar_helper->get_user_avatar($row); + if (empty($avatar['src'])) + { + return ''; + } + + return '' . utf8_htmlspecialchars($avatar['title']) . ''; + } + /** * @return string */ @@ -247,11 +287,6 @@ public function get_news_ids() public function base() { - if ($this->auth->acl_get('a_board')) - { - $this->display_newspage_settings(); - } - $this->get_news_ids(); if (empty($this->topic_ids)) @@ -309,15 +344,14 @@ public function base() { $this->page_title = censor_text($row['post_subject']); } - else if (((int) $this->config['news_char_limit']) !== 0 && class_exists('\Nickvergessen\TrimMessage\TrimMessage')) - { - $trim = new TrimMessage($row['post_text'], $row['bbcode_uid'], $this->config['news_char_limit']); - $row['post_text'] = $trim->message(); - unset($trim); - } - $parse_flags = ($row['bbcode_bitfield'] ? OPTION_FLAG_BBCODE : 0) | OPTION_FLAG_SMILIES; + $parse_flags = ($row['enable_bbcode'] ? OPTION_FLAG_BBCODE : 0) | ($row['enable_smilies'] ? OPTION_FLAG_SMILIES : 0) | ($row['enable_magic_url'] ? OPTION_FLAG_LINKS : 0); $message = generate_text_for_display($row['post_text'], $row['bbcode_uid'], $row['bbcode_bitfield'], $parse_flags, true); + if (!$this->news && (int) $this->config['news_char_limit'] > 0) + { + $trimmer = new message_trimmer(); + $message = $trimmer->trim($message, (int) $this->config['news_char_limit']); + } if (!$this->auth->acl_get('f_download', $forum_id)) { @@ -349,8 +383,6 @@ public function base() $this->db->sql_freeresult($result2); } - $l_edit_time_total = ($row['post_edit_count'] == 1) ? $this->user->lang['EDITED_TIME_TOTAL'] : $this->user->lang['EDITED_TIMES_TOTAL']; - if (!$row['post_edit_user'] || $row['post_edit_user'] == $poster_id) { $display_username = get_username_string('full', $poster_id, $row['username'], $row['user_colour'], $row['post_username']); @@ -360,14 +392,7 @@ public function base() $display_username = get_username_string('full', $row['post_edit_user'], $post_edit_list[$row['post_edit_user']]['username'], $post_edit_list[$row['post_edit_user']]['user_colour']); } - if ($row['post_edit_reason']) - { - $l_edited_by = sprintf($l_edit_time_total, $display_username, $this->user->format_date($row['post_edit_time'], false, true), $row['post_edit_count']); - } - else - { - $l_edited_by = sprintf($l_edit_time_total, $display_username, $this->user->format_date($row['post_edit_time'], false, true), $row['post_edit_count']); - } + $l_edited_by = $this->user->lang('EDITED_TIMES_TOTAL', (int) $row['post_edit_count'], $display_username, $this->user->format_date($row['post_edit_time'], false, true)); } else { @@ -382,7 +407,8 @@ public function base() $row['rank_image'] = $rank_data['img']; $row['rank_image_src'] = $rank_data['img_src']; - $row['user_jabber'] = ($row['user_jabber'] && $this->auth->acl_get('u_sendim')) ? append_sid("{$this->root_path}memberlist.{$this->php_ext}", "mode=contact&action=jabber&u=$poster_id") : ''; + // phpBB 4.0 has no Jabber field, so the column may be missing + $row['user_jabber'] = (!empty($row['user_jabber']) && $this->auth->acl_get('u_sendim')) ? append_sid("{$this->root_path}memberlist.{$this->php_ext}", "mode=contact&action=jabber&u=$poster_id") : ''; // Can this user receive a Private Message? $can_receive_pm = ( @@ -428,14 +454,16 @@ public function base() 'U_REPORT' => ($this->auth->acl_get('f_report', $forum_id)) ? append_sid("{$this->root_path}report.{$this->php_ext}", 'f=' . $forum_id . '&p=' . $row['post_id']) : '', 'U_NOTES' => ($this->auth->acl_getf_global('m_')) ? append_sid("{$this->root_path}mcp.{$this->php_ext}", 'i=notes&mode=user_notes&u=' . $poster_id, true, $this->user->session_id) : '', 'U_WARN' => ($this->auth->acl_get('m_warn') && $poster_id != $this->user->data['user_id'] && $poster_id != ANONYMOUS) ? append_sid("{$this->root_path}mcp.{$this->php_ext}", 'i=warn&mode=warn_post&f=' . $forum_id . '&p=' . $post_id, true, $this->user->session_id) : '', - 'U_NEWS' => $this->helper->route('nickvergessen_newspage_singlenews_controller', array('topic_id' => $topic_id)), + 'U_NEWS' => $this->helper->route('phpbbmodders_newspage_singlenews_controller', array('topic_id' => $topic_id)), 'POST_ICON_IMG' => (!empty($row['icon_id'])) ? $icons[$row['icon_id']]['img'] : '', 'POST_ICON_IMG_WIDTH' => (!empty($row['icon_id'])) ? $icons[$row['icon_id']]['width'] : '', 'POST_ICON_IMG_HEIGHT' => (!empty($row['icon_id'])) ? $icons[$row['icon_id']]['height'] : '', 'U_MINI_POST' => append_sid("{$this->root_path}viewtopic.{$this->php_ext}", 'p=' . $row['post_id']) . (($row['topic_type'] == POST_GLOBAL) ? '&f=' . $forum_id : '') . '#p' . $row['post_id'], - 'POST_SUBJECT' => censor_text($row['post_subject']), + 'POST_SUBJECT' => htmlspecialchars(censor_text($row['post_subject']), ENT_QUOTES, 'UTF-8', false), 'MINI_POST_IMG' => ($post_unread) ? $this->user->img('icon_post_target_unread', 'NEW_POST') : $this->user->img('icon_post_target', 'POST'), + 'MINI_POST' => ($post_unread) ? $this->user->lang['UNREAD_POST'] : $this->user->lang['POST'], + 'S_UNREAD_POST' => $post_unread, 'POST_AUTHOR_FULL' => get_username_string('full', $poster_id, $row['username'], $row['user_colour'], $row['post_username']), 'POST_DATE' => $this->user->format_date($row['post_time']), @@ -447,24 +475,25 @@ public function base() 'MESSAGE' => $row['post_text'], 'S_HAS_POLL' => (!empty($row['poll_start'])) ? true : false, - 'POLL_QUESTION' => $row['poll_title'], + 'POLL_QUESTION' => htmlspecialchars(censor_text($row['poll_title']), ENT_QUOTES, 'UTF-8', false), 'S_HAS_ATTACHMENTS' => (!empty($attachments[$row['post_id']]) && $this->config['news_attach_show']) ? true : false, 'S_DISPLAY_NOTICE' => $display_notice && $row['post_attachment'], 'EDITED_MESSAGE' => $l_edited_by, - 'EDIT_REASON' => $row['post_edit_reason'], + 'EDIT_REASON' => htmlspecialchars($row['post_edit_reason'], ENT_QUOTES, 'UTF-8', false), 'SIGNATURE' => ($row['enable_sig']) ? $row['user_sig'] : '', 'NEWS_COMMENTS' => $this->content_visibility->get_count('topic_posts', $row, $forum_id) - 1, - 'POSTER_AVATAR' => ($this->user->optionget('viewavatars')) ? phpbb_get_user_avatar($row) : '', + 'POSTER_AVATAR' => ($this->user->optionget('viewavatars')) ? $this->get_poster_avatar($row) : '', 'U_POST_AUTHOR' => get_username_string('profile', $poster_id, $row['username'], $row['user_colour'], $row['post_username']), 'RANK_TITLE' => $row['rank_title'], 'RANK_IMG' => $row['rank_image'], 'RANK_IMG_SRC' => $row['rank_image_src'], 'POSTER_POSTS' => $row['user_posts'], 'POSTER_JOINED' => $this->user->format_date($row['user_regdate']), + 'U_SEARCH' => $this->auth->acl_get('u_search') ? append_sid("{$this->root_path}search.{$this->php_ext}", 'author_id=' . $poster_id . '&sr=posts') : '', - 'U_PM' => ($poster_id != ANONYMOUS && $this->config['allow_privmsg'] && $this->auth->acl_get('u_sendpm') && ($row['user_allow_pm'] || $this->auth->acl_gets('a_', 'm_') || $this->auth->acl_getf_global('m_'))) ? append_sid("{$this->root_path}ucp.{$this->php_ext}", 'i=pm&mode=compose&action=quotepost&p=' . $row['post_id']) : '', - 'U_EMAIL' => $row['user_email'], + 'U_PM' => $u_pm, + 'U_EMAIL' => $u_email, 'U_JABBER' => $row['user_jabber'], )); @@ -479,12 +508,16 @@ public function base() 'NAME' => $this->user->lang['SEND_EMAIL'], 'U_CONTACT' => $u_email, ), - array( + ); + + if ($row['user_jabber']) + { + $contact_fields[] = array( 'ID' => 'jabber', 'NAME' => $this->user->lang['JABBER'], - 'U_CONTACT' => ($row['user_jabber'] && $this->auth->acl_get('u_sendim')) ? append_sid("{$this->root_path}memberlist.{$this->php_ext}", "mode=contact&action=jabber&u=$poster_id") : '', - ), - ); + 'U_CONTACT' => $row['user_jabber'], + ); + } foreach ($contact_fields as $field) { @@ -526,8 +559,8 @@ public function base() // Specify some images $this->template->assign_vars(array( - 'NEWS_USER_INFO' => true, // $this->config['news_user_info'], - 'NEWS_POST_BUTTONS' => true, // $this->config['news_post_buttons'], + 'NEWS_USER_INFO' => (bool) $this->config['news_user_info'], + 'NEWS_POST_BUTTONS' => (bool) $this->config['news_post_buttons'], 'S_NEWS_ARCHIVE_PER_YEAR' => $this->config['news_archive_show'] == self::ARCHIVE_PER_YEAR, 'NEWS_ONLY' => $this->news, @@ -608,7 +641,9 @@ public function get_newstopic_sql() else if ($this->is_archive()) { $archive_start = $this->user->get_timestamp_from_format('Y-n-d H:i:s', $this->archive['y'] . '-' . $this->archive['m'] . '-01 0:00:00'); - $archive_end = $this->user->get_timestamp_from_format('Y-n-d H:i:s', $this->archive['y'] . '-' . ($this->archive['m'] + 1) . '-01 0:00:00') - 1; + $next_month = $this->archive['m'] == 12 ? 1 : $this->archive['m'] + 1; + $next_year = $this->archive['y'] + ($this->archive['m'] == 12 ? 1 : 0); + $archive_end = $this->user->get_timestamp_from_format('Y-n-d H:i:s', $next_year . '-' . $next_month . '-01 0:00:00') - 1; $archive_name = $this->user->lang('NEWS_ARCHIVE_OF', $this->user->format_date($archive_start, 'F Y')); $this->page_title = $archive_name; @@ -679,7 +714,7 @@ public function generate_category_list() ORDER BY left_id ASC'; $result = $this->db->sql_query($sql); - /** @var \nickvergessen\newspage\route $route */ + /** @var \phpbbmodders\newspage\route $route */ $route = $this->news_helper->generate_route($this->category, $this->archive); while ($row = $this->db->sql_fetchrow($result)) { @@ -775,7 +810,7 @@ protected function assign_archive_list(array $archiv_years, array $archiv_months $this->num_pagination_items += $archive['count']; } - /** @var \nickvergessen\newspage\route $route */ + /** @var \phpbbmodders\newspage\route $route */ $route = $this->news_helper->generate_route($this->category, $this->archive); $this->template->assign_block_vars('archive_block.archive_row', array( 'U_NEWS_MONTH' => $route->get_url(($active_archive) ? '' : empty($this->config['news_cat_show']), $archive['url']), @@ -835,7 +870,7 @@ public function generate_pagination() $pagination_news = $this->num_pagination_items; } - /** @var \nickvergessen\newspage\route $route */ + /** @var \phpbbmodders\newspage\route $route */ $route = $this->news_helper->generate_route($this->category, $this->archive); $this->pagination->generate_template_pagination( array( @@ -852,28 +887,4 @@ public function generate_pagination() )); } - protected function display_newspage_settings() - { - if (!function_exists('make_forum_select')) - { - include($this->root_path . 'includes/functions_admin.' . $this->php_ext); - } - - add_form_key('newspage'); - $this->template->assign_vars(array( - 'U_SETTING_ACTION' => $this->helper->route('nickvergessen_newspage_settings'), - 'SETTING_NEWS_CHAR_LIMIT' => (int) $this->config['news_char_limit'], - 'SETTING_NEWS_NUMBER' => (int) $this->config['news_number'], - 'SETTING_NEWS_PAGES' => (int) $this->config['news_pages'], - 'SETTING_NEWS_SHADOW_SHOW' => (bool) $this->config['news_shadow'], - 'SETTING_NEWS_ATTACH_SHOW' => (bool) $this->config['news_attach_show'], - 'SETTING_NEWS_CAT_SHOW' => (bool) $this->config['news_cat_show'], - 'SETTING_NEWS_ARCHIVE_SHOW' => (bool) $this->config['news_archive_show'], - 'SETTING_NEWS_FORUMS' => make_forum_select(explode(',', $this->config['news_forums'])), - - 'SETTING_BUTTON_RESPONSIVE_FIXED' => false, - 'SETTING_NEWS_USER_INFO' => (bool) $this->config['news_user_info'], - 'SETTING_NEWS_POST_BUTTONS' => (bool) $this->config['news_post_buttons'], - )); - } } diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 289449d..67ba99f 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -8,31 +8,23 @@ convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" - syntaxCheck="false" verbose="true" bootstrap="../../../../tests/bootstrap.php" > - - - ./tests - ./tests/functional - - - ./tests/functional/ - - + + + ./tests + + - - - ./tests/ - - - ./ - - ./language/ - ./migrations/ - ./tests/ - - - + + + ./ + + ./language/ + ./migrations/ + ./tests/ + + + diff --git a/route.php b/route.php index 5b2eeaa..d912988 100644 --- a/route.php +++ b/route.php @@ -1,21 +1,21 @@ + * @copyright (c) 2026, phpBB Modders, https://www.phpbbmodders.com/ * @license GNU General Public License, version 2 (GPL-2.0) * - * For full copyright and license information, please see - * the license.txt file. */ -namespace nickvergessen\newspage; +namespace phpbbmodders\newspage; /** * Class route * - * @package nickvergessen\newspage + * @package phpbbmodders\newspage */ class route { @@ -123,7 +123,7 @@ public function get_url($force_category = false, $force_archive = false, $force_ */ public function get_route($force_category = false, $force_archive = false, $force_page = false) { - $route = 'nickvergessen_newspage'; + $route = 'phpbbmodders_newspage'; if ($this->config['news_cat_show']) { $route .= $this->get_route_category($force_category); diff --git a/styles/prosilver/template/event/overall_header_head_append.html b/styles/prosilver/template/event/overall_header_head_append.html index 4b8b36b..06a8fe3 100644 --- a/styles/prosilver/template/event/overall_header_head_append.html +++ b/styles/prosilver/template/event/overall_header_head_append.html @@ -1,4 +1,4 @@ - - - + + + diff --git a/styles/prosilver/template/event/overall_header_navigation_prepend.html b/styles/prosilver/template/event/overall_header_navigation_prepend.html index e7fc41b..63f6126 100644 --- a/styles/prosilver/template/event/overall_header_navigation_prepend.html +++ b/styles/prosilver/template/event/overall_header_navigation_prepend.html @@ -1 +1 @@ -
  • {L_NEWSPAGE}
  • +
  • {L_NEWSPAGE}
  • diff --git a/styles/prosilver/template/newspage_body.html b/styles/prosilver/template/newspage_body.html index ee6fa6a..9d94982 100644 --- a/styles/prosilver/template/newspage_body.html +++ b/styles/prosilver/template/newspage_body.html @@ -2,16 +2,15 @@ -

    {NEWS_TITLE}{L_NEWS}

    +

    {NEWS_TITLE}{L_NEWS}

    - +
    -