use namespace
This commit is contained in:
parent
f3f0f59173
commit
22e13c903c
@ -7,11 +7,35 @@
|
||||
*
|
||||
* @author Fran6t, Pierre Van Glabeke and Contributors
|
||||
*
|
||||
* @copyright Jean-Crhistian Denis
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||
return;
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\bloganniv;
|
||||
|
||||
use dcCore;
|
||||
use dcNsProcess;
|
||||
|
||||
class Backend extends dcNsProcess
|
||||
{
|
||||
public static function init(): bool
|
||||
{
|
||||
static::$init = defined('DC_CONTEXT_ADMIN') && My::phpCompliant();
|
||||
|
||||
return static::$init;
|
||||
}
|
||||
|
||||
require __DIR__ . '/_widgets.php';
|
||||
public static function process(): bool
|
||||
{
|
||||
if (!static::$init) {
|
||||
return false;
|
||||
}
|
||||
|
||||
dcCore::app()->addBehaviors([
|
||||
'initWidgets' => [Widgets::class, 'initWidgets'],
|
||||
]);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -7,11 +7,35 @@
|
||||
*
|
||||
* @author Fran6t, Pierre Van Glabeke and Contributors
|
||||
*
|
||||
* @copyright Jean-Crhistian Denis
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
return null;
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\bloganniv;
|
||||
|
||||
use dcCore;
|
||||
use dcNsProcess;
|
||||
|
||||
class Frontend extends dcNsProcess
|
||||
{
|
||||
public static function init(): bool
|
||||
{
|
||||
static::$init = My::phpCompliant();
|
||||
|
||||
return static::$init;
|
||||
}
|
||||
|
||||
require __DIR__ . '/_widgets.php';
|
||||
public static function process(): bool
|
||||
{
|
||||
if (!static::$init) {
|
||||
return false;
|
||||
}
|
||||
|
||||
dcCore::app()->addBehaviors([
|
||||
'initWidgets' => [Widgets::class, 'initWidgets'],
|
||||
]);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
50
src/My.php
Normal file
50
src/My.php
Normal file
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief bloganniv, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Fran6t, Pierre Van Glabeke and Contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\bloganniv;
|
||||
|
||||
use dcCore;
|
||||
|
||||
/**
|
||||
* Plugin definitions
|
||||
*/
|
||||
class My
|
||||
{
|
||||
/** @var string Required php version */
|
||||
public const PHP_MIN = '7.4';
|
||||
|
||||
/**
|
||||
* This module id
|
||||
*/
|
||||
public static function id(): string
|
||||
{
|
||||
return basename(dirname(__DIR__));
|
||||
}
|
||||
|
||||
/**
|
||||
* This module name
|
||||
*/
|
||||
public static function name(): string
|
||||
{
|
||||
return __((string) dcCore::app()->plugins->moduleInfo(self::id(), 'name'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Check php version
|
||||
*/
|
||||
public static function phpCompliant(): bool
|
||||
{
|
||||
return version_compare(phpversion(), self::PHP_MIN, '>=');
|
||||
}
|
||||
}
|
@ -7,23 +7,26 @@
|
||||
*
|
||||
* @author Fran6t, Pierre Van Glabeke and Contributors
|
||||
*
|
||||
* @copyright Jean-Crhistian Denis
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
return null;
|
||||
}
|
||||
declare(strict_types=1);
|
||||
|
||||
dcCore::app()->addBehavior('initWidgets', ['blogAnnivWidgets', 'initWidgets']);
|
||||
namespace Dotclear\Plugin\bloganniv;
|
||||
|
||||
class blogAnnivWidgets
|
||||
use dcCore;
|
||||
use Dotclear\Helper\Html\Html;
|
||||
use Dotclear\Plugin\widgets\WidgetsStack;
|
||||
use Dotclear\Plugin\widgets\WidgetsElement;
|
||||
|
||||
class Widgets
|
||||
{
|
||||
public static function initWidgets($w)
|
||||
public static function initWidgets(WidgetsStack $w): void
|
||||
{
|
||||
$w->create(
|
||||
'blogAnniv',
|
||||
__('Blog Anniv'),
|
||||
['blogAnnivWidgets', 'BlogAnnivWidget'],
|
||||
My::id(),
|
||||
My::name(),
|
||||
[self::class, 'parseWidget'],
|
||||
null,
|
||||
__('Counting the number of days before and after a particular date')
|
||||
)
|
||||
@ -37,14 +40,10 @@ class blogAnnivWidgets
|
||||
->addOffline();
|
||||
}
|
||||
|
||||
public static function BlogAnnivWidget($w)
|
||||
public static function parseWidget(WidgetsElement $w): string
|
||||
{
|
||||
if ($w->offline) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!$w->checkHomeOnly(dcCore::app()->url->type)) {
|
||||
return null;
|
||||
if ($w->offline || !$w->checkHomeOnly(dcCore::app()->url->type)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$ftdatecrea = $w->ftdatecrea;
|
||||
@ -93,8 +92,8 @@ class blogAnnivWidgets
|
||||
}
|
||||
|
||||
return $w->renderDiv(
|
||||
$w->content_only,
|
||||
'bloganniv ' . $w->class,
|
||||
(bool) $w->content_only,
|
||||
My::id() . ' ' . $w->class,
|
||||
'',
|
||||
($w->title ? $w->renderTitle(html::escapeHTML($w->title)) : '') .
|
||||
'<ul>' .
|
||||
|
Loading…
Reference in New Issue
Block a user