fix prepend: cleanup, update license, move activityReport behavior

This commit is contained in:
Jean-Christian Denis 2021-09-07 15:05:53 +02:00
parent 14343aa882
commit 956d48b4f4
2 changed files with 107 additions and 113 deletions

View file

@ -1,46 +1,43 @@
<?php <?php
# -- BEGIN LICENSE BLOCK ---------------------------------- /**
# * @brief cinecturlink2, a plugin for Dotclear 2
# This file is part of cinecturlink2, a plugin for Dotclear 2. *
# * @package Dotclear
# Copyright (c) 2009-2013 Jean-Christian Denis and contributors * @subpackage Plugin
# contact@jcdenis.fr http://jcd.lv *
# * @author Jean-Christian Denis and Contributors
# Licensed under the GPL version 2.0 license. *
# A copy of this license is available in LICENSE file or at * @copyright Jean-Christian Denis
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
# */
# -- END LICENSE BLOCK ------------------------------------
if (!defined('DC_RC_PATH')) { if (!defined('DC_RC_PATH')) {
return null;
return null;
} }
$d = dirname(__FILE__).'/inc/'; $d = dirname(__FILE__) . '/inc/';
$__autoload['cinecturlink2'] = $d.'class.cinecturlink2.php'; $__autoload['cinecturlink2'] = $d . 'class.cinecturlink2.php';
$__autoload['cinecturlink2Context'] = $d.'lib.cinecturlink2.context.php'; $__autoload['cinecturlink2Context'] = $d . 'lib.cinecturlink2.context.php';
$__autoload['sitemapsCinecturlink2'] = $d.'lib.sitemaps.cinecturlink2.php'; $__autoload['sitemapsCinecturlink2'] = $d . 'lib.sitemaps.cinecturlink2.php';
$__autoload['cinecturlink2ActivityReportBehaviors'] = $d . 'lib.cinecturlink2.activityreport.php';
$core->url->register( $core->url->register(
'cinecturlink2', 'cinecturlink2',
'cinecturlink', 'cinecturlink',
'^cinecturlink(?:/(.+))?$', '^cinecturlink(?:/(.+))?$',
array('urlCinecturlink2', 'c2Page') ['urlCinecturlink2', 'c2Page']
);
$core->addBehavior(
'sitemapsDefineParts',
['sitemapsCinecturlink2', 'sitemapsDefineParts']
);
$core->addBehavior(
'sitemapsURLsCollect',
['sitemapsCinecturlink2', 'sitemapsURLsCollect']
); );
# Add cinecturlink2 report on plugin activityReport
if (defined('ACTIVITY_REPORT')) { if (defined('ACTIVITY_REPORT')) {
require_once $d.'lib.cinecturlink2.activityreport.php'; cinecturlink2ActivityReportBehaviors::add($core);
} }
# cinecturlink2 libraries for sitemaps
$core->addBehavior(
'sitemapsDefineParts',
array('sitemapsCinecturlink2', 'sitemapsDefineParts')
);
$core->addBehavior(
'sitemapsURLsCollect',
array('sitemapsCinecturlink2', 'sitemapsURLsCollect')
);

View file

@ -1,92 +1,89 @@
<?php <?php
# -- BEGIN LICENSE BLOCK ---------------------------------- /**
# * @brief cinecturlink2, a plugin for Dotclear 2
# This file is part of cinecturlink2, a plugin for Dotclear 2. *
# * @package Dotclear
# Copyright (c) 2009-2013 Jean-Christian Denis and contributors * @subpackage Plugin
# contact@jcdenis.fr http://jcd.lv *
# * @author Jean-Christian Denis and Contributors
# Licensed under the GPL version 2.0 license. *
# A copy of this license is available in LICENSE file or at * @copyright Jean-Christian Denis
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
# */
# -- END LICENSE BLOCK ------------------------------------
if (!defined('DC_RC_PATH')) { if (!defined('DC_RC_PATH')) {
return null;
return null;
} }
# This file is used with plugin activityReport
$core->activityReport->addGroup('cinecturlink2', __('Plugin cinecturlink2'));
# from BEHAVIOR cinecturlink2AfterAddLink in cinecturlink2/inc/class.cinecturlink2.php
$core->activityReport->addAction(
'cinecturlink2',
'create',
__('link creation'),
__('A new cineturlink named "%s" was added by "%s"'),
'cinecturlink2AfterAddLink',
array('cinecturlink2ActivityReportBehaviors', 'addLink')
);
# from BEHAVIOR cinecturlink2AfterUpdLink in cinecturlink2/inc/class.cinecturlink2.php
$core->activityReport->addAction(
'cinecturlink2',
'update',
__('updating link'),
__('Cinecturlink named "%s" has been updated by "%s"'),
'cinecturlink2AfterUpdLink',
array('cinecturlink2ActivityReportBehaviors', 'updLink')
);
# from BEHAVIOR cinecturlink2BeforeDelLink in cinecturlink2/inc/class.cinecturlink2.php
$core->activityReport->addAction(
'cinecturlink2',
'delete',
__('link deletion'),
__('Cinecturlink named "%s" has been deleted by "%s"'),
'cinecturlink2BeforeDelLink',
array('cinecturlink2ActivityReportBehaviors', 'delLink')
);
class cinecturlink2ActivityReportBehaviors class cinecturlink2ActivityReportBehaviors
{ {
public static function addLink($cur) public static function add($core)
{ {
global $core; $core->activityReport->addGroup('cinecturlink2', __('Plugin cinecturlink2'));
$logs = array( // from BEHAVIOR cinecturlink2AfterAddLink in cinecturlink2/inc/class.cinecturlink2.php
$cur->link_title, $core->activityReport->addAction(
$core->auth->getInfo('user_cn') 'cinecturlink2',
); 'create',
__('link creation'),
__('A new cineturlink named "%s" was added by "%s"'),
'cinecturlink2AfterAddLink',
['cinecturlink2ActivityReportBehaviors', 'addLink']
);
// from BEHAVIOR cinecturlink2AfterUpdLink in cinecturlink2/inc/class.cinecturlink2.php
$core->activityReport->addAction(
'cinecturlink2',
'update',
__('updating link'),
__('Cinecturlink named "%s" has been updated by "%s"'),
'cinecturlink2AfterUpdLink',
['cinecturlink2ActivityReportBehaviors', 'updLink']
);
// from BEHAVIOR cinecturlink2BeforeDelLink in cinecturlink2/inc/class.cinecturlink2.php
$core->activityReport->addAction(
'cinecturlink2',
'delete',
__('link deletion'),
__('Cinecturlink named "%s" has been deleted by "%s"'),
'cinecturlink2BeforeDelLink',
['cinecturlink2ActivityReportBehaviors', 'delLink']
);
}
$core->activityReport->addLog('cinecturlink2', 'create', $logs); public static function addLink($cur)
} {
global $core;
public static function updLink($cur, $id) $logs = [
{ $cur->link_title,
global $core; $core->auth->getInfo('user_cn')
$C2 = new cinecturlink2($core); ];
$rs = $C2->getLinks(array('link_id'=>$id)); $core->activityReport->addLog('cinecturlink2', 'create', $logs);
}
$logs = array( public static function updLink($cur, $id)
$rs->link_title, {
$core->auth->getInfo('user_cn') global $core;
); $C2 = new cinecturlink2($core);
$rs = $C2->getLinks(['link_id' => $id]);
$core->activityReport->addLog('cinecturlink2', 'update', $logs); $logs = [
} $rs->link_title,
$core->auth->getInfo('user_cn')
];
$core->activityReport->addLog('cinecturlink2', 'update', $logs);
}
public static function delLink($id) public static function delLink($id)
{ {
global $core; global $core;
$C2 = new cinecturlink2($core); $C2 = new cinecturlink2($core);
$rs = $C2->getLinks(array('link_id'=>$id)); $rs = $C2->getLinks(['link_id' => $id]);
$logs = array( $logs = [
$rs->link_title, $rs->link_title,
$core->auth->getInfo('user_cn') $core->auth->getInfo('user_cn')
); ];
$core->activityReport->addLog('cinecturlink2', 'delete', $logs);
$core->activityReport->addLog('cinecturlink2', 'delete', $logs); }
} }
}