use abstract plugin name

This commit is contained in:
Jean-Christian Paul Denis 2022-12-16 00:32:15 +01:00
parent 5b225a3b29
commit 50f4eb46b6
Signed by: JcDenis
GPG Key ID: 1B5B8C5B90B6C951
11 changed files with 39 additions and 38 deletions

View File

@ -19,10 +19,10 @@ if (!defined('ACTIVITY_REPORT_V2')) {
dcCore::app()->menu[dcAdmin::MENU_PLUGINS]->addItem( dcCore::app()->menu[dcAdmin::MENU_PLUGINS]->addItem(
__('Activity report'), __('Activity report'),
dcCore::app()->adminurl->get('admin.plugin.activityReport'), dcCore::app()->adminurl->get('admin.plugin.' . basename(__DIR__)),
dcPage::getPF('activityReport/icon.png'), dcPage::getPF(basename(__DIR__) . '/icon.png'),
preg_match( preg_match(
'/' . preg_quote(dcCore::app()->adminurl->get('admin.plugin.activityReport')) . '(&.*)?$/', '/' . preg_quote(dcCore::app()->adminurl->get('admin.plugin.' . basename(__DIR__))) . '(&.*)?$/',
$_SERVER['REQUEST_URI'] $_SERVER['REQUEST_URI']
), ),
dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([ dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([
@ -40,8 +40,8 @@ class activityReportAdmin
{ {
public static function adminDashboardContents($items) public static function adminDashboardContents($items)
{ {
dcCore::app()->auth->user_prefs->addWorkspace('activityReport'); dcCore::app()->auth->user_prefs->addWorkspace(basename(__DIR__));
$limit = abs((int) dcCore::app()->auth->user_prefs->activityReport->dashboard_item); $limit = abs((int) dcCore::app()->auth->user_prefs->__get(basename(__DIR__))->dashboard_item);
if (!$limit) { if (!$limit) {
return null; return null;
} }
@ -83,10 +83,10 @@ class activityReportAdmin
'<h3>' . __('Activity report') . '</h3>' . '<h3>' . __('Activity report') . '</h3>' .
'<dl id="reports">' . implode('', $lines) . '</dl>' . '<dl id="reports">' . implode('', $lines) . '</dl>' .
'<p class="modules"><a class="module-details" href="' . '<p class="modules"><a class="module-details" href="' .
dcCore::app()->adminurl->get('admin.plugin.activityReport') . '">' . dcCore::app()->adminurl->get('admin.plugin.' . basename(__DIR__)) . '">' .
__('View all logs') . '</a> - <a class="module-config" href="' . __('View all logs') . '</a> - <a class="module-config" href="' .
dcCore::app()->adminurl->get('admin.plugins', [ dcCore::app()->adminurl->get('admin.plugins', [
'module' => 'activityReport', 'module' => basename(__DIR__),
'conf' => 1, 'conf' => 1,
'redir' => dcCore::app()->adminurl->get('admin.home') . '#activity-report-logs', 'redir' => dcCore::app()->adminurl->get('admin.home') . '#activity-report-logs',
]) . '">' . ]) . '">' .
@ -97,7 +97,7 @@ class activityReportAdmin
public static function adminDashboardOptionsForm() public static function adminDashboardOptionsForm()
{ {
dcCore::app()->auth->user_prefs->addWorkspace('activityReport'); dcCore::app()->auth->user_prefs->addWorkspace(basename(__DIR__));
echo echo
'<div class="fieldset">' . '<div class="fieldset">' .
@ -107,7 +107,7 @@ class activityReportAdmin
form::combo( form::combo(
'activityReport_dashboard_item', 'activityReport_dashboard_item',
self::comboList(), self::comboList(),
self::comboList(dcCore::app()->auth->user_prefs->activityReport->dashboard_item) self::comboList(dcCore::app()->auth->user_prefs->__get(basename(__DIR__))->dashboard_item)
) . '</p>' . ) . '</p>' .
'</div>'; '</div>';
} }
@ -118,8 +118,8 @@ class activityReportAdmin
return; return;
} }
dcCore::app()->auth->user_prefs->addWorkspace('activityReport'); dcCore::app()->auth->user_prefs->addWorkspace(basename(__DIR__));
dcCore::app()->auth->user_prefs->activityReport->put( dcCore::app()->auth->user_prefs->__get(basename(__DIR__))->put(
'dashboard_item', 'dashboard_item',
self::comboList(@$_POST['activityReport_dashboard_item']), self::comboList(@$_POST['activityReport_dashboard_item']),
'integer' 'integer'

View File

@ -79,7 +79,7 @@ if (!empty($_POST['save'])) {
dcAdminNotices::addSuccessNotice( dcAdminNotices::addSuccessNotice(
__('Configuration successfully updated.') __('Configuration successfully updated.')
); );
dcCore::app()->adminurl->redirect('admin.plugins', ['module' => 'activityReport', 'conf' => 1, 'super' => $super]); dcCore::app()->adminurl->redirect('admin.plugins', ['module' => basename(__DIR__), 'conf' => 1, 'super' => $super]);
} catch (Exception $e) { } catch (Exception $e) {
dcCore::app()->error->add($e->getMessage()); dcCore::app()->error->add($e->getMessage());
} }
@ -108,7 +108,7 @@ echo '<h4>' . ($super ? __('All blogs') : __('Current blog')) . '</h4>';
if (dcCore::app()->auth->isSuperAdmin()) { if (dcCore::app()->auth->isSuperAdmin()) {
echo sprintf( echo sprintf(
'<p class="modules right"><a class="module-config" href="%s">%s</a><br class="clear"/></p>', '<p class="modules right"><a class="module-config" href="%s">%s</a><br class="clear"/></p>',
dcCore::app()->adminurl->get('admin.plugins', ['module' => 'activityReport', 'conf' => 1, 'super' => !$super]), dcCore::app()->adminurl->get('admin.plugins', ['module' => basename(__DIR__), 'conf' => 1, 'super' => !$super]),
sprintf(__('Configure activity report for %s'), $super ? __('current blog') : __('all blogs')) sprintf(__('Configure activity report for %s'), $super ? __('current blog') : __('all blogs'))
); );
} }
@ -141,13 +141,13 @@ form::hidden(['super'], $super);
if (!$super) { if (!$super) {
echo echo
'<p><img alt="' . __('RSS feed') . '" src="' . dcPage::getPF('activityReport/inc/img/feed.png') . '" />' . '<p><img alt="' . __('RSS feed') . '" src="' . dcPage::getPF(basename(__DIR__) . '/inc/img/feed.png') . '" />' .
'<a title="' . __('RSS feed') . '" href="' . '<a title="' . __('RSS feed') . '" href="' .
dcCore::app()->blog->url . dcCore::app()->url->getBase('activityReport') . '/rss2/' . dcCore::app()->activityReport->getUserCode() . '">' . dcCore::app()->blog->url . dcCore::app()->url->getBase(basename(__DIR__)) . '/rss2/' . dcCore::app()->activityReport->getUserCode() . '">' .
__('Rss2 feed for activity on this blog') . '</a><br />' . __('Rss2 feed for activity on this blog') . '</a><br />' .
'<img alt="' . __('Atom feed') . '" src="' . dcPage::getPF('activityReport/inc/img/feed.png') . '" />' . '<img alt="' . __('Atom feed') . '" src="' . dcPage::getPF(basename(__DIR__) . '/inc/img/feed.png') . '" />' .
'<a title="' . __('Atom feed') . '" href="' . '<a title="' . __('Atom feed') . '" href="' .
dcCore::app()->blog->url . dcCore::app()->url->getBase('activityReport') . '/atom/' . dcCore::app()->activityReport->getUserCode() . '">' . dcCore::app()->blog->url . dcCore::app()->url->getBase(basename(__DIR__)) . '/atom/' . dcCore::app()->activityReport->getUserCode() . '">' .
__('Atom feed for activity on this blog') . '</a></p>'; __('Atom feed for activity on this blog') . '</a></p>';
} }
echo ' echo '

View File

@ -28,8 +28,8 @@ $this->registerModule(
]), ]),
'priority' => -1000000, 'priority' => -1000000,
'type' => 'plugin', 'type' => 'plugin',
'support' => 'https://github.com/JcDenis/activityReport', 'support' => 'https://github.com/JcDenis/' . basename(__DIR__),
'details' => 'http://plugins.dotaddict.org/dc2/details/activityReport', 'details' => 'http://plugins.dotaddict.org/dc2/details/' . basename(__DIR__),
'repository' => 'https://raw.githubusercontent.com/JcDenis/activityReport/master/dcstore.xml', 'repository' => 'https://raw.githubusercontent.com/JcDenis/' . basename(__DIR__) . '/master/dcstore.xml',
] ]
); );

View File

@ -18,4 +18,5 @@ class initActivityReport
{ {
public const ACTIVITY_TABLE_NAME = 'activity'; public const ACTIVITY_TABLE_NAME = 'activity';
public const SETTING_TABLE_NAME = 'activity_setting'; public const SETTING_TABLE_NAME = 'activity_setting';
public const CACHE_DIR_NAME = 'activityreport';
} }

View File

@ -25,7 +25,7 @@ try {
$s = new dbStruct(dcCore::app()->con, dcCore::app()->prefix); $s = new dbStruct(dcCore::app()->con, dcCore::app()->prefix);
$s->{initActivityReport::ACTIVITY_TABLE_NAME} $s->{initActivityReport::ACTIVITY_TABLE_NAME}
->activity_id('bigint', 0, false) ->activity_id('bigint', 0, false)
->activity_type('varchar', 32, false, "'activityReport'") ->activity_type('varchar', 32, false, "'" . basename(__DIR__) . "'")
->blog_id('varchar', 32, true) ->blog_id('varchar', 32, true)
->activity_group('varchar', 32, false) ->activity_group('varchar', 32, false)
->activity_action('varchar', 32, false) ->activity_action('varchar', 32, false)

View File

@ -24,7 +24,7 @@ try {
dcCore::app()->__set('activityReport', new activityReport()); dcCore::app()->__set('activityReport', new activityReport());
dcCore::app()->url->register( dcCore::app()->url->register(
'activityReport', basename(__DIR__),
'reports', 'reports',
'^reports/((atom|rss2)/(.+))$', '^reports/((atom|rss2)/(.+))$',
['activityReportPublicUrl', 'feed'] ['activityReportPublicUrl', 'feed']

View File

@ -42,7 +42,7 @@ $this->addUserAction(
/* action */ /* action */
'delete', 'delete',
/* ns */ /* ns */
'activityReport', basename(__DIR__),
/* description */ /* description */
__('delete plugin files') __('delete plugin files')
); );
@ -53,7 +53,7 @@ $this->addUserAction(
/* action */ /* action */
'delete', 'delete',
/* ns */ /* ns */
'activityReport', basename(__DIR__),
/* description */ /* description */
__('delete the version number') __('delete the version number')
); );
@ -64,9 +64,9 @@ $this->addDirectAction(
/* action */ /* action */
'delete', 'delete',
/* ns */ /* ns */
'activityReport', basename(__DIR__),
/* description */ /* description */
sprintf(__('delete %s version number'), 'activityReport') sprintf(__('delete %s version number'), basename(__DIR__))
); );
$this->addDirectAction( $this->addDirectAction(
@ -75,7 +75,7 @@ $this->addDirectAction(
/* action */ /* action */
'delete', 'delete',
/* ns */ /* ns */
'activityReport', basename(__DIR__),
/* description */ /* description */
sprintf(__('delete %s plugin files'), 'activityReport') sprintf(__('delete %s plugin files'), basename(__DIR__))
); );

View File

@ -23,10 +23,10 @@ class activityReportBehaviors
public static function registerBehaviors() public static function registerBehaviors()
{ {
// ActivityReport plugin // ActivityReport plugin
dcCore::app()->activityReport->addGroup('activityReport', __('ActivityReport messages')); dcCore::app()->activityReport->addGroup(basename(dirname(__DIR__)), __('ActivityReport messages'));
dcCore::app()->activityReport->addAction( dcCore::app()->activityReport->addAction(
'activityReport', basename(dirname(__DIR__)),
'message', 'message',
__('Special messages'), __('Special messages'),
__('%s'), __('%s'),
@ -220,7 +220,7 @@ class activityReportBehaviors
public static function messageActivityReport($message) public static function messageActivityReport($message)
{ {
$logs = [$message]; $logs = [$message];
dcCore::app()->activityReport->addLog('activityReport', 'message', $logs); dcCore::app()->activityReport->addLog(basename(dirname(__DIR__)), 'message', $logs);
} }
public static function blogUpdate($cur, $blog_id) public static function blogUpdate($cur, $blog_id)

View File

@ -18,7 +18,7 @@ class activityReport
{ {
public $con; public $con;
private $ns = 'activityReport'; private $ns = null;
private $_global = 0; private $_global = 0;
private $blog = null; private $blog = null;
private $groups = []; private $groups = [];
@ -26,11 +26,11 @@ class activityReport
private $lock_blog = null; private $lock_blog = null;
private $lock_global = null; private $lock_global = null;
public function __construct($ns = 'activityReport') public function __construct($ns = null)
{ {
$this->con = dcCore::app()->con; $this->con = dcCore::app()->con;
$this->blog = dcCore::app()->con->escape(dcCore::app()->blog->id); $this->blog = dcCore::app()->con->escape(dcCore::app()->blog->id);
$this->ns = dcCore::app()->con->escape($ns); $this->ns = dcCore::app()->con->escape($ns ?? basename(dirname(__DIR__)));
$this->getSettings(); $this->getSettings();
@ -535,7 +535,7 @@ class activityReport
$cached_file = sprintf( $cached_file = sprintf(
'%s/%s/%s/%s/%s.txt', '%s/%s/%s/%s/%s.txt',
DC_TPL_CACHE, DC_TPL_CACHE,
'activityreport', initActivityReport::CACHE_DIR_NAME,
substr($f_md5, 0, 2), substr($f_md5, 0, 2),
substr($f_md5, 2, 2), substr($f_md5, 2, 2),
$f_md5 $f_md5

View File

@ -40,7 +40,7 @@ $format = [
'</style>' . '</style>' .
'</head><body>' . '</head><body>' .
'<div class="info">%PERIOD%</div><div class="content">%TEXT%</div>' . '<div class="info">%PERIOD%</div><div class="content">%TEXT%</div>' .
'<div class="foot"><p>Powered by <a href="http://dotclear.jcdenis.com/go/activityReport">activityReport</a></p></div>' . '<div class="foot"><p>Powered by <a href="https://github.com/JcDenis/activityReport">activityReport</a></p></div>' .
'</body></html>', '</body></html>',
], ],
'plain' => [ 'plain' => [

View File

@ -32,13 +32,13 @@ $logs = dcCore::app()->activityReport->getLogs([]);
if ($super) { if ($super) {
$breadcrumb = [ $breadcrumb = [
__('Current blog') => dcCore::app()->adminurl->get('admin.plugin.activityReport', ['super' => 0]), __('Current blog') => dcCore::app()->adminurl->get('admin.plugin.' . basename(__DIR__), ['super' => 0]),
'<span class="page-title">' . __('All blogs') . '</span>' => '', '<span class="page-title">' . __('All blogs') . '</span>' => '',
]; ];
} else { } else {
$breadcrumb = ['<span class="page-title">' . __('Current blog') . '</span>' => '']; $breadcrumb = ['<span class="page-title">' . __('Current blog') . '</span>' => ''];
if (dcCore::app()->auth->isSuperAdmin()) { if (dcCore::app()->auth->isSuperAdmin()) {
$breadcrumb[__('All blogs')] = dcCore::app()->adminurl->get('admin.plugin.activityReport', ['super' => 1]); $breadcrumb[__('All blogs')] = dcCore::app()->adminurl->get('admin.plugin.' . basename(__DIR__), ['super' => 1]);
} }
} }