fix type hint (WIP)
This commit is contained in:
parent
043045f373
commit
2b6587d081
@ -22,7 +22,7 @@ class Combo
|
|||||||
/**
|
/**
|
||||||
* Mail content formats.
|
* Mail content formats.
|
||||||
*
|
*
|
||||||
* @return array The formats combo
|
* @return array<string,string> The formats combo
|
||||||
*/
|
*/
|
||||||
public static function mailformat(): array
|
public static function mailformat(): array
|
||||||
{
|
{
|
||||||
@ -37,7 +37,7 @@ class Combo
|
|||||||
/**
|
/**
|
||||||
* Get report intervals.
|
* Get report intervals.
|
||||||
*
|
*
|
||||||
* @return array The intervals combo
|
* @return array<string,int> The intervals combo
|
||||||
*/
|
*/
|
||||||
public static function interval(): array
|
public static function interval(): array
|
||||||
{
|
{
|
||||||
@ -54,7 +54,7 @@ class Combo
|
|||||||
/**
|
/**
|
||||||
* Get obsolete period.
|
* Get obsolete period.
|
||||||
*
|
*
|
||||||
* @return array The obsolete period combo
|
* @return array<string,int> The obsolete period combo
|
||||||
*/
|
*/
|
||||||
public static function obselete(): array
|
public static function obselete(): array
|
||||||
{
|
{
|
||||||
|
@ -110,6 +110,7 @@ class Config extends dcNsProcess
|
|||||||
}
|
}
|
||||||
|
|
||||||
$s = ActivityReport::instance()->settings;
|
$s = ActivityReport::instance()->settings;
|
||||||
|
$tz = is_string(dcCore::app()->auth?->getInfo('user_tz')) ? dcCore::app()->auth?->getInfo('user_tz') : 'UTC';
|
||||||
|
|
||||||
if (!$s->lastreport) {
|
if (!$s->lastreport) {
|
||||||
$last_report = __('never');
|
$last_report = __('never');
|
||||||
@ -118,12 +119,12 @@ class Config extends dcNsProcess
|
|||||||
$last_report = Date::str(
|
$last_report = Date::str(
|
||||||
dcCore::app()->blog?->settings->get('system')->get('date_format') . ', ' . dcCore::app()->blog?->settings->get('system')->get('time_format'),
|
dcCore::app()->blog?->settings->get('system')->get('date_format') . ', ' . dcCore::app()->blog?->settings->get('system')->get('time_format'),
|
||||||
$s->lastreport,
|
$s->lastreport,
|
||||||
dcCore::app()->auth?->getInfo('user_tz')
|
$tz
|
||||||
);
|
);
|
||||||
$next_report = Date::str(
|
$next_report = Date::str(
|
||||||
dcCore::app()->blog?->settings->get('system')->get('date_format') . ', ' . dcCore::app()->blog?->settings->get('system')->get('time_format'),
|
dcCore::app()->blog?->settings->get('system')->get('date_format') . ', ' . dcCore::app()->blog?->settings->get('system')->get('time_format'),
|
||||||
$s->interval + $s->lastreport,
|
$s->interval + $s->lastreport,
|
||||||
dcCore::app()->auth?->getInfo('user_tz')
|
$tz
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@ declare(strict_types=1);
|
|||||||
namespace Dotclear\Plugin\activityReport;
|
namespace Dotclear\Plugin\activityReport;
|
||||||
|
|
||||||
use dcCore;
|
use dcCore;
|
||||||
|
use Dotclear\Database\MetaRecord;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Template helper.
|
* Template helper.
|
||||||
@ -28,14 +29,20 @@ class Context
|
|||||||
*/
|
*/
|
||||||
public static function parseTitle(): string
|
public static function parseTitle(): string
|
||||||
{
|
{
|
||||||
if (!dcCore::app()->ctx || !dcCore::app()->ctx->exists('activityreports')) {
|
if (!dcCore::app()->ctx
|
||||||
|
|| !dcCore::app()->ctx->exists('activityreports')
|
||||||
|
|| !(dcCore::app()->ctx->__get('activityreports') instanceof MetaRecord)
|
||||||
|
) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
$group = dcCore::app()->ctx->__get('activityreports')->activity_group;
|
$group = dcCore::app()->ctx->__get('activityreports')->f('activity_group');
|
||||||
$action = dcCore::app()->ctx->__get('activityreports')->activity_action;
|
$action = dcCore::app()->ctx->__get('activityreports')->f('activity_action');
|
||||||
|
|
||||||
if (!ActivityReport::instance()->groups->get($group)->has($action)) {
|
if (!is_string($group)
|
||||||
|
|| !is_string($action)
|
||||||
|
|| !ActivityReport::instance()->groups->get($group)->has($action)
|
||||||
|
) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,15 +56,23 @@ class Context
|
|||||||
*/
|
*/
|
||||||
public static function parseContent(): string
|
public static function parseContent(): string
|
||||||
{
|
{
|
||||||
if (!dcCore::app()->ctx || !dcCore::app()->ctx->exists('activityreports')) {
|
if (!dcCore::app()->ctx
|
||||||
|
|| !dcCore::app()->ctx->exists('activityreports')
|
||||||
|
|| !(dcCore::app()->ctx->__get('activityreports') instanceof MetaRecord)
|
||||||
|
) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
$group = dcCore::app()->ctx->__get('activityreports')->activity_group;
|
$group = dcCore::app()->ctx->__get('activityreports')->f('activity_group');
|
||||||
$action = dcCore::app()->ctx->__get('activityreports')->activity_action;
|
$action = dcCore::app()->ctx->__get('activityreports')->f('activity_action');
|
||||||
$logs = json_decode((string) dcCore::app()->ctx->__get('activityreports')->activity_logs, true);
|
$logs = dcCore::app()->ctx->__get('activityreports')->f('activity_logs');
|
||||||
|
$logs = json_decode(is_string($logs) ? $logs : '', true);
|
||||||
|
|
||||||
if (!is_array($logs) || !ActivityReport::instance()->groups->get($group)->has($action)) {
|
if (!is_string($group)
|
||||||
|
|| !is_string($action)
|
||||||
|
|| !is_array($logs)
|
||||||
|
|| !ActivityReport::instance()->groups->get($group)->has($action)
|
||||||
|
) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ class Format
|
|||||||
* Constructor sets format id.
|
* Constructor sets format id.
|
||||||
*
|
*
|
||||||
* @param string $id The format ID
|
* @param string $id The format ID
|
||||||
* @param array $format The format values
|
* @param array<string,string> $format The format values
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
public readonly string $id,
|
public readonly string $id,
|
||||||
|
@ -31,6 +31,7 @@ class Install extends dcNsProcess
|
|||||||
public static function init(): bool
|
public static function init(): bool
|
||||||
{
|
{
|
||||||
static::$init = defined('DC_CONTEXT_ADMIN')
|
static::$init = defined('DC_CONTEXT_ADMIN')
|
||||||
|
&& is_string(dcCore::app()->plugins->moduleInfo(My::id(), 'version'))
|
||||||
&& dcCore::app()->newVersion(My::id(), dcCore::app()->plugins->moduleInfo(My::id(), 'version'));
|
&& dcCore::app()->newVersion(My::id(), dcCore::app()->plugins->moduleInfo(My::id(), 'version'));
|
||||||
|
|
||||||
return static::$init;
|
return static::$init;
|
||||||
@ -77,10 +78,10 @@ class Install extends dcNsProcess
|
|||||||
*/
|
*/
|
||||||
private static function beforeGrowUp(): void
|
private static function beforeGrowUp(): void
|
||||||
{
|
{
|
||||||
$current = dcCore::app()->getVersion('activityReport');
|
|
||||||
|
|
||||||
// sorry not sorry we restart from scratch
|
// sorry not sorry we restart from scratch
|
||||||
if ($current && version_compare($current, '3.0', '<')) {
|
if (is_string(dcCore::app()->getVersion('activityReport'))
|
||||||
|
&& version_compare(dcCore::app()->getVersion('activityReport'), '3.0', '<')
|
||||||
|
) {
|
||||||
$struct = new Structure(dcCore::app()->con, dcCore::app()->prefix);
|
$struct = new Structure(dcCore::app()->con, dcCore::app()->prefix);
|
||||||
|
|
||||||
if ($struct->tableExists('activity')) {
|
if ($struct->tableExists('activity')) {
|
||||||
|
@ -35,7 +35,9 @@ class ManageList extends adminGenericList
|
|||||||
echo '<p><strong>' . __('No log') . '</strong></p>';
|
echo '<p><strong>' . __('No log') . '</strong></p>';
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$pager = new dcPager((int) $filter->value('page'), (int) $this->rs_count, (int) $filter->value('nb'), 10);
|
$page = $filter->value('page');
|
||||||
|
$nbpp = $filter->value('nb');
|
||||||
|
$pager = new dcPager(is_numeric($page) ? (int) $page : 1, (int) $this->rs_count, is_numeric($nbpp) ? (int) $nbpp : 20, 10);
|
||||||
$pager->var_page = 'page';
|
$pager->var_page = 'page';
|
||||||
|
|
||||||
$html_block = '<div class="table-outer"><table><caption>' . (
|
$html_block = '<div class="table-outer"><table><caption>' . (
|
||||||
@ -75,12 +77,12 @@ class ManageList extends adminGenericList
|
|||||||
$offline = (int) $this->rs->f('activity_status') == ActivityReport::STATUS_REPORTED ? ' offline' : '';
|
$offline = (int) $this->rs->f('activity_status') == ActivityReport::STATUS_REPORTED ? ' offline' : '';
|
||||||
$group = ActivityReport::instance()->groups->get($this->rs->f('activity_group'));
|
$group = ActivityReport::instance()->groups->get($this->rs->f('activity_group'));
|
||||||
$action = $group->get($this->rs->f('activity_action'));
|
$action = $group->get($this->rs->f('activity_action'));
|
||||||
$message = json_decode((string) $this->rs->f('activity_logs'), true);
|
$data = json_decode((string) $this->rs->f('activity_logs'), true);
|
||||||
$message = ActivityReport::parseMessage(__($action->message), $message);
|
$message = ActivityReport::parseMessage(__($action->message), is_array($data) ? $data : []);
|
||||||
$date = Date::str(
|
$date = Date::str(
|
||||||
dcCore::app()->blog?->settings->get('system')->get('date_format') . ', ' . dcCore::app()->blog?->settings->get('system')->get('time_format'),
|
dcCore::app()->blog?->settings->get('system')->get('date_format') . ', ' . dcCore::app()->blog?->settings->get('system')->get('time_format'),
|
||||||
(int) strtotime((string) $this->rs->f('activity_dt')),
|
(int) strtotime((string) $this->rs->f('activity_dt')),
|
||||||
dcCore::app()->auth?->getInfo('user_tz')
|
is_string(dcCore::app()->auth?->getInfo('user_tz')) ? dcCore::app()->auth->getInfo('user_tz') : 'UTC'
|
||||||
);
|
);
|
||||||
$status = (int) $this->rs->f('activity_status') == ActivityReport::STATUS_PENDING ? __('pending') : __('reported');
|
$status = (int) $this->rs->f('activity_status') == ActivityReport::STATUS_PENDING ? __('pending') : __('reported');
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ class Settings
|
|||||||
/** @var int $lastreport The last report time */
|
/** @var int $lastreport The last report time */
|
||||||
public readonly int $lastreport;
|
public readonly int $lastreport;
|
||||||
|
|
||||||
/** @var array $mailinglist The mailing list */
|
/** @var array<int,string> $mailinglist The mailing list */
|
||||||
public readonly array $mailinglist;
|
public readonly array $mailinglist;
|
||||||
|
|
||||||
/** @var string $mailformat The mail content format */
|
/** @var string $mailformat The mail content format */
|
||||||
@ -43,7 +43,7 @@ class Settings
|
|||||||
/** @var string $date format The date format */
|
/** @var string $date format The date format */
|
||||||
public readonly string $dateformat;
|
public readonly string $dateformat;
|
||||||
|
|
||||||
/** @var array $requests The selected actions list to report */
|
/** @var array<string,array{string,int}> $requests The selected actions list to report */
|
||||||
public readonly array $requests;
|
public readonly array $requests;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -56,13 +56,13 @@ class Settings
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->feed_active = (bool) ($this->get('feed_active') ?? false);
|
$this->feed_active = (bool) ($this->get('feed_active') ?? false);
|
||||||
$this->obsolete = (int) ($this->get('obsolete') ?? 2419200);
|
$this->obsolete = is_numeric($this->get('obsolete')) ? (int) $this->get('obsolete') : 2419200;
|
||||||
$this->interval = (int) ($this->get('interval') ?? 86400);
|
$this->interval = is_numeric($this->get('interval')) ? (int) $this->get('interval') : 86400;
|
||||||
$this->lastreport = (int) ($this->get('lastreport') ?? 0);
|
$this->lastreport = is_numeric($this->get('lastreport')) ? (int) $this->get('lastreport') : 0;
|
||||||
$this->mailinglist = (array) ($this->get('mailinglist') ?? []);
|
$this->mailinglist = is_array($this->get('mailinglist')) ? $this->get('mailinglist') : [];
|
||||||
$this->mailformat = (string) ($this->get('mailformat') ?? 'plain');
|
$this->mailformat = is_string($this->get('mailformat')) ? $this->get('mailformat') : 'plain';
|
||||||
$this->dateformat = (string) ($this->get('dateformat') ?? '%Y-%m-%d %H:%M:%S');
|
$this->dateformat = is_string($this->get('dateformat')) ? $this->get('dateformat') : '%Y-%m-%d %H:%M:%S';
|
||||||
$this->requests = (array) ($this->get('requests') ?? []);
|
$this->requests = is_array($this->get('requests')) ? $this->get('requests') : [];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -39,7 +39,7 @@ class Template
|
|||||||
public static function activityReports(ArrayObject $attr, string $content): string
|
public static function activityReports(ArrayObject $attr, string $content): string
|
||||||
{
|
{
|
||||||
$lastn = 0;
|
$lastn = 0;
|
||||||
if (isset($attr['lastn'])) {
|
if (isset($attr['lastn']) && is_numeric($attr['lastn'])) {
|
||||||
$lastn = abs((int) $attr['lastn']) + 0;
|
$lastn = abs((int) $attr['lastn']) + 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,7 +139,7 @@ class Template
|
|||||||
public static function activityReportDate(ArrayObject $attr): string
|
public static function activityReportDate(ArrayObject $attr): string
|
||||||
{
|
{
|
||||||
$format = '';
|
$format = '';
|
||||||
if (!empty($attr['format'])) {
|
if (!empty($attr['format']) && is_string($attr['format'])) {
|
||||||
$format = addslashes($attr['format']);
|
$format = addslashes($attr['format']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,7 +38,11 @@ class UrlHandler extends dcUrlHandlers
|
|||||||
) {
|
) {
|
||||||
self::p404();
|
self::p404();
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
if (!is_array($m) || count($m) < 2 || !is_string($m[1]) || !is_string($m[2])) {
|
||||||
|
self::p404();
|
||||||
|
}
|
||||||
|
*/
|
||||||
// get type of feed
|
// get type of feed
|
||||||
$mime = $m[1] == 'atom' ? 'application/atom+xml' : 'application/xml';
|
$mime = $m[1] == 'atom' ? 'application/atom+xml' : 'application/xml';
|
||||||
if (false === ActivityReport::instance()->checkUserCode($m[2])) {
|
if (false === ActivityReport::instance()->checkUserCode($m[2])) {
|
||||||
@ -46,11 +50,15 @@ class UrlHandler extends dcUrlHandlers
|
|||||||
}
|
}
|
||||||
|
|
||||||
// feed limits
|
// feed limits
|
||||||
dcCore::app()->ctx->__set('nb_entry_per_page', (int) dcCore::app()->blog?->settings->get('system')->get('nb_post_per_feed'));
|
$nb = dcCore::app()->blog?->settings->get('system')->get('nb_post_per_feed');
|
||||||
dcCore::app()->ctx->__set('short_feed_items', (int) dcCore::app()->blog?->settings->get('system')->get('short_feed_items'));
|
//$it = dcCore::app()->blog?->settings->get('system')->get('short_feed_items');
|
||||||
|
$rb = dcCore::app()->blog?->settings->get('system')->get('robots_policy');
|
||||||
|
|
||||||
|
dcCore::app()->ctx->__set('nb_entry_per_page', is_numeric($nb) ? (int) $nb : 20);
|
||||||
|
// dcCore::app()->ctx->__set('short_feed_items', is_numerci($it) ? (int) $it : 1);
|
||||||
|
|
||||||
// serve activity feed template
|
// serve activity feed template
|
||||||
header('X-Robots-Tag: ' . context::robotsPolicy(dcCore::app()->blog?->settings->get('system')->get('robots_policy'), ''));
|
header('X-Robots-Tag: ' . context::robotsPolicy(is_string($rb) ? $rb : '', ''));
|
||||||
self::serveDocument('activityreport-' . $m[1] . '.xml', $mime);
|
self::serveDocument('activityreport-' . $m[1] . '.xml', $mime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user