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

View File

@ -79,7 +79,7 @@ if (!empty($_POST['save'])) {
dcAdminNotices::addSuccessNotice(
__('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) {
dcCore::app()->error->add($e->getMessage());
}
@ -108,7 +108,7 @@ echo '<h4>' . ($super ? __('All blogs') : __('Current blog')) . '</h4>';
if (dcCore::app()->auth->isSuperAdmin()) {
echo sprintf(
'<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'))
);
}
@ -141,13 +141,13 @@ form::hidden(['super'], $super);
if (!$super) {
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="' .
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 />' .
'<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="' .
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>';
}
echo '

View File

@ -28,8 +28,8 @@ $this->registerModule(
]),
'priority' => -1000000,
'type' => 'plugin',
'support' => 'https://github.com/JcDenis/activityReport',
'details' => 'http://plugins.dotaddict.org/dc2/details/activityReport',
'repository' => 'https://raw.githubusercontent.com/JcDenis/activityReport/master/dcstore.xml',
'support' => 'https://github.com/JcDenis/' . basename(__DIR__),
'details' => 'http://plugins.dotaddict.org/dc2/details/' . basename(__DIR__),
'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 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->{initActivityReport::ACTIVITY_TABLE_NAME}
->activity_id('bigint', 0, false)
->activity_type('varchar', 32, false, "'activityReport'")
->activity_type('varchar', 32, false, "'" . basename(__DIR__) . "'")
->blog_id('varchar', 32, true)
->activity_group('varchar', 32, false)
->activity_action('varchar', 32, false)

View File

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

View File

@ -42,7 +42,7 @@ $this->addUserAction(
/* action */
'delete',
/* ns */
'activityReport',
basename(__DIR__),
/* description */
__('delete plugin files')
);
@ -53,7 +53,7 @@ $this->addUserAction(
/* action */
'delete',
/* ns */
'activityReport',
basename(__DIR__),
/* description */
__('delete the version number')
);
@ -64,9 +64,9 @@ $this->addDirectAction(
/* action */
'delete',
/* ns */
'activityReport',
basename(__DIR__),
/* description */
sprintf(__('delete %s version number'), 'activityReport')
sprintf(__('delete %s version number'), basename(__DIR__))
);
$this->addDirectAction(
@ -75,7 +75,7 @@ $this->addDirectAction(
/* action */
'delete',
/* ns */
'activityReport',
basename(__DIR__),
/* 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()
{
// ActivityReport plugin
dcCore::app()->activityReport->addGroup('activityReport', __('ActivityReport messages'));
dcCore::app()->activityReport->addGroup(basename(dirname(__DIR__)), __('ActivityReport messages'));
dcCore::app()->activityReport->addAction(
'activityReport',
basename(dirname(__DIR__)),
'message',
__('Special messages'),
__('%s'),
@ -220,7 +220,7 @@ class activityReportBehaviors
public static function messageActivityReport($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)

View File

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

View File

@ -40,7 +40,7 @@ $format = [
'</style>' .
'</head><body>' .
'<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>',
],
'plain' => [

View File

@ -32,13 +32,13 @@ $logs = dcCore::app()->activityReport->getLogs([]);
if ($super) {
$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>' => '',
];
} else {
$breadcrumb = ['<span class="page-title">' . __('Current blog') . '</span>' => ''];
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]);
}
}