Page 1 of 1

[ABD] User's Post Count on Index

Posted: Sat Oct 20, 2018 7:14 pm
by Restless Rancor
:!: I no longer have the time to dedicate to developing this extension. It failed validation for a number of reasons, so do not use it on a live environment. Feel free to continue the development under the GNU General Public License v2.0. :!:

Extension Name: User's Post Count on Index
Author: Restless Rancor

Extension Description: Displays a logged in member their post count on the index page.
Clicking the text will search their posts, matching the behavior of the post count in memberlist_body.html, memberlist_view.html,viewtopic_body.html etc.

Extension Version: Image
Requirements: Image Image

GitHub Repository: https://github.com/restless-rancor/rr-p ... t-on-index
Extension Download: https://github.com/restless-rancor/rr-p ... master.zip

Notes:
  • This is my first extension and I am always learning: I am not a competent extension writer/php developer.
  • As of v0.3.0-beta I do not plan to add any more to the extension. The next stage is to optimize and review code.
  • Only install this extension in a test environment.
Plans:
  • Set the default location to directly opposite 'Mark Forums Read'. (Not above and opposite). [DONE!]
  • /language/en/common.php [Done, needs improving.] [DONE!]
  • ACP options to change location: [DONE!]
    • Above forumlist
    • Next to Notifications
    • In Index Statistics
Screenshots:
Above Forumlist:
Image
Next to Notifications:
Image
In Statistics:
Image
ACP Options:
Image
Changelog:
d.m.Y H:i TO | version
  • 01.11.2018 17:44 UTC | 1.0.0-RC2
    • EOL Conversion > Unix (LF)
  • 01.11.2018 16:47 UTC | 1.0.0-RC1
    • (tr) Translation added
    • Push to version 1.0.0-RC1 for validation.
  • 01.11.2018 14:57 UTC | 0.3.3-beta
    • Code optimization to comply with phpBB coding guidelines.
    • Global enable/disable removed:
      • This setting was exactly the same as enabling/disabling the extension in Extension Management and therefore pointless.
    • phpBB syntax fully updated to Twig syntax.
  • 29.10.2018 15:54 UTC | 0.3.2-beta
    • 'Preview' button in ACP settings removed
    • ACP Language file renamed
  • 28.10.2018 13:56 UTC | 0.3.1-beta
    • Update acme_demo references in migrations
  • 28.10.2018 13:29 UTC | 0.3.0-beta
    • Twig syntax updated in adm/style/acp_pcoi_body.html
    • Added display location settings:
      • In Navbar
      • Above Forumlist
      • In Board Statistics
  • 28.10.2018 11:27 UTC | 0.2.1-dev
    • ACP module added:
      • Currently only with a global enable/disable option.
    • Template optimized:
      • {% if U_MARK_FORUMS %} moved so if 'mark forums read' is disabled the post count will still show if the extension is enabled.
    • Language updated.
  • 25.10.2018 16:32 UTC+1 | 0.2.0-dev
    • Removed duplicate language call
  • 22.10.2018 15:14 UTC+1 | 0.1.3-dev
    • Requirements updated to indicate supported version.
  • 21.10.2018 18:08 UTC+1 | 0.1.2-dev
    • Plurals in language now work as intended
    • phpBB syntax completely replaced with Twig syntax in templates
      • No need for {% if USER_POST_COUNT == '1' %} anymore.
    • Language file renamed to common.php
  • 21.10.2018 12:05 UTC+1 | 0.1.1-dev
    • Updated version check path
  • 20.10.2018 19:53 UTC+1 | 0.1.0-dev
    • Version change to 0.1.0-dev in prep for phpBB.com [DEV] topic.
  • 20.10.2018 17:01 UTC+1 | 0.0.6-dev
    • {% if U_MARK_FORUMS %} now has an {% endif %}. Whoops.
  • 20.10.2018 16:59 UTC+1 | 0.0.5-dev
    • phpBB syntax replaced with Twig syntax in template files.
  • 20.10.2018 14:36 UTC+1 | 0.0.4-dev
    • Added language files.
  • 20.10.2018 12:08 UTC+1 | 0.0.3-dev
    • Version check added.
  • 19.10.2018 20:16 UTC+1 | 0.0.2-dev
    • CSS added: The post count now displays directly opposite 'mark forums read' as desired.
  • 19.10.2018 16:47 UTC+1 | 0.0.1-dev
    • Initial development release.

Re: [DEV] User's Post Count on Index

Posted: Sat Oct 20, 2018 8:45 pm
by pikachuturkey
is there any screenshot? (for language translation)

Re: [DEV] User's Post Count on Index

Posted: Sun Oct 21, 2018 3:00 am
by kinerity
Restless Rancor wrote:
Sat Oct 20, 2018 7:14 pm
  • I'm having trouble getting the language to produce plurals. (i.e. "Post" for 1 post and "Posts" for not 1 post). I'm going to give another crack at it tomorrow but will ask what I could be doing wrong if I can't get it.
The language system will handle this automatically. You only need to pass it one language var and the array of language definitions. For example, in one of my extensions.

Code: Select all

'PM_POST_LIMIT_ERROR'   => array(
    1  => 'Due to restrictions on this board, users must have a minimum of %d post and a registration date of more than 24 hours ago to proceed. You <strong>may</strong> still PM team members.',
    2  => 'Due to restrictions on this board, users must have a minimum of %d posts and a registration date of more than 24 hours ago to proceed. You <strong>may</strong> still PM team members.',
),
Hope this helps.

Re: [DEV] User's Post Count on Index

Posted: Sun Oct 21, 2018 10:57 am
by Restless Rancor
pikachuturkey wrote:
Sat Oct 20, 2018 8:45 pm
is there any screenshot? (for language translation)
Hi, it's not really ready for translations yet as I want to change how the language is handled and this will mean changing the language file, but I'll add a couple of screenshots to support the OP.

kinerity wrote:
Sun Oct 21, 2018 3:00 am
The language system will handle this automatically. You only need to pass it one language var and the array of language definitions. For example, in one of my extensions.

Code: Select all

'PM_POST_LIMIT_ERROR'   => array(
    1  => 'Due to restrictions on this board, users must have a minimum of %d post and a registration date of more than 24 hours ago to proceed. You <strong>may</strong> still PM team members.',
    2  => 'Due to restrictions on this board, users must have a minimum of %d posts and a registration date of more than 24 hours ago to proceed. You <strong>may</strong> still PM team members.',
),
Hope this helps.
Hi kinerity, yep that's what I've been trying, but I think it's either in the listener or template where I'm falling over myself.

Code: Select all

$lang = array_merge($lang, array(
	'PCOI'	=> array(
		1	=> 'You have %d post.',
		2	=> 'You have %d posts!',
	),
));
But when using {L_PCOI} I get [phpBB Debug] PHP Warning: in file [ROOT]/phpbb/language/language.php on line 372: vsprintf(): Too few arguments - I'm fairly sure this is because I haven't told it to use {USER_POST_COUNT} in that array. So, hopefully I'll get that figured out today :?

Re: [DEV] User's Post Count on Index

Posted: Sun Oct 21, 2018 5:12 pm
by kinerity
Yes, you need to pass your var to the array.

Re: [DEV] User's Post Count on Index

Posted: Sun Oct 21, 2018 5:28 pm
by Restless Rancor
  • 21.10.2018 18:08 UTC+1 | 0.1.2-dev
    • Plurals in language now work as intended
    • phpBB syntax completely replaced with Twig syntax in templates
      • No need for {% if USER_POST_COUNT == '1' %} anymore.
    • Language file renamed to common.php
I did have a lot of guidance on these changes, so am going to focus on learning precisely what's happening before moving forward with adding new features.

Re: [DEV] User's Post Count on Index

Posted: Sun Oct 21, 2018 7:46 pm
by pikachuturkey
Why there is "!" for plural and "." for singular :D

Turkish (tr) language for "[DEV] User's Post Count on Index" version 0.1.2

language/tr/common.php

Code: Select all

<?php
if (!defined('IN_PHPBB'))
{
	exit;
}
if (empty($lang) || !is_array($lang))
{
	$lang = array();
}
$lang = array_merge($lang, array(
	'USER_POSTS'	=> array(
		0	=> 'Hiç gönderiniz yok.',
		1	=> '%d gönderiniz var.',
		2	=> '%d gönderiniz var!',
	),
));

Re: [DEV] User's Post Count on Index

Posted: Mon Oct 22, 2018 9:28 am
by Restless Rancor
pikachuturkey wrote:
Sun Oct 21, 2018 7:46 pm
Why there is "!" for plural and "." for singular :D
That's just the way I've put it :)

I'll get the translation added soon, although there'll probably be more to add, as I plan on adding ACP options to chose where the post count is located.

Thanks.

Re: [DEV] User's Post Count on Index

Posted: Mon Oct 22, 2018 2:18 pm
by Restless Rancor
I've updated the requirements to php >=5.6 and phpBB >=3.2.0<3.3 to clarify and indicate the supported versions. The extension may work on earlier versions, but it is not guaranteed.

Re: [DEV] User's Post Count on Index

Posted: Mon Oct 22, 2018 2:26 pm
by david63
Restless Rancor wrote:
Mon Oct 22, 2018 2:18 pm
The extension may work on earlier versions
It will not work on 3.1.x

Re: [DEV] User's Post Count on Index

Posted: Mon Oct 22, 2018 2:28 pm
by Restless Rancor
david63 wrote:
Mon Oct 22, 2018 2:26 pm
Restless Rancor wrote:
Mon Oct 22, 2018 2:18 pm
The extension may work on earlier versions
It will not work on 3.1.x
Thanks for clarifying. I'd originally had it set to >=3.1.9<3.2.0@dev as the template event it uses was introduced in 3.1.9, and I interpreted that as ">=3.1.9<3.2 development branch".

Always a learning process. From now on it'd be indicating the latest stable branch I've tested it on. When 3.3 is released if the ext works I can expand the parameters etc. or update the ext :geek:

Re: [3.2][DEV] User's Post Count on Index

Posted: Sat Oct 27, 2018 8:22 pm
by Restless Rancor
I've had quite a bit of difficulty adding an ACP module this week, but the solution struck me earlier today and I finally have the acme demo module working with the extension.
More info on that if you're interested...

This week I aim to tailor that to the extension, adding a 'location on index' and a global enable/disable setting.

Re: [3.2][BETA] User's Post Count on Index

Posted: Sun Oct 28, 2018 1:45 pm
by Restless Rancor
  • 28.10.2018 13:29 UTC | 0.3.0-beta
    • Twig syntax updated in adm/style/acp_pcoi_body.html
    • Added display location settings:
      • In Navbar
      • Above Forumlist
      • In Board Statistics
As of 0.3.0-beta, the extension has everything I originally planned, so the next step is to review and optimize the code.
Suggestions for improvements are greatly appreciated :mrgreen:

Re: [3.2][BETA] User's Post Count on Index

Posted: Thu Nov 01, 2018 4:10 pm
by pikachuturkey
Turkish (tr) translation of "[3.2][BETA] User's Post Count on Index" (version: 0.3.3 ////// 01.11.2018 github datas)

language/tr/info_acp_pcoi.php

Code: Select all

<?php
/**
*
* Post Count on Index. An extension for the phpBB Forum Software package.
*
* @copyright (c) 2018, Restless Rancor, https://www.restlessrancor.com
* @license GNU General Public License, version 2 (GPL-2.0)
*
*/
if (!defined('IN_PHPBB'))
{
	exit;
}
if (empty($lang) || !is_array($lang))
{
	$lang = array();
}
$lang = array_merge($lang, array(
	'PCOI_TITLE'			=> 'İndekste Gönderi Sayısı',
	'PCOI_SETTINGS'			=> 'Ayarlar',
	'PCOI_ENABLE_FAIL'		=> 'Eklentiyi aktifleştirme başarısız!',
	'PCOI_ENABLE_SUCCESS'	=> 'Başarıyla aktifleştirildi!',
	'PCOI_SAVED'			=> 'Ayarlar başarıyla kaydedildi!.',
	'PCOI_UPDATED'			=> 'İndekste Gönderi Sayısı yapılandırması güncellendi.',
	
	'PCOI_ENABLE_EXPLAIN'	=> 'Eğer kapatırsanız gönderi sayıları aşağıda seçtiğiniz konumda <strong>gösterilmeyecek</strong>.',
	'PCOI_NAVBAR'			=> '<em>navbar</em>da göster?',
	'PCOI_FORUMLIST'		=> '<em>Forum listesi</em>nin üzerinde göster?',
	'PCOI_STATISTICS'		=> '<em>Site istatistiklerinde</em>lerinde göster?',
));
language/tr/common.php

Code: Select all

<?php
/**
*
* Post Count on Index. An extension for the phpBB Forum Software package.
*
* @copyright (c) 2018, Restless Rancor, https://www.restlessrancor.com
* @license GNU General Public License, version 2 (GPL-2.0)
*
*/
 
if (!defined('IN_PHPBB'))
{
	exit;
}
if (empty($lang) || !is_array($lang))
{
	$lang = array();
}
$lang = array_merge($lang, array(
	'USER_POSTS'	=> array(
		0	=> 'Hiç gönderiniz yok.',
		1	=> '%d gönderiniz var.',
		2	=> '%d gönderiniz var!',
	),
));

Re: [3.2][BETA] User's Post Count on Index

Posted: Thu Nov 01, 2018 4:26 pm
by Restless Rancor
Thanks, I'll get those added shortly and will be submitting for validation very soon.