use namespace
This commit is contained in:
parent
f3f0f59173
commit
22e13c903c
@ -7,11 +7,35 @@
|
|||||||
*
|
*
|
||||||
* @author Fran6t, Pierre Van Glabeke and Contributors
|
* @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
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
*/
|
*/
|
||||||
if (!defined('DC_CONTEXT_ADMIN')) {
|
declare(strict_types=1);
|
||||||
return;
|
|
||||||
|
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
|
* @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
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
*/
|
*/
|
||||||
if (!defined('DC_RC_PATH')) {
|
declare(strict_types=1);
|
||||||
return null;
|
|
||||||
|
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
|
* @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
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
*/
|
*/
|
||||||
if (!defined('DC_RC_PATH')) {
|
declare(strict_types=1);
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
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(
|
$w->create(
|
||||||
'blogAnniv',
|
My::id(),
|
||||||
__('Blog Anniv'),
|
My::name(),
|
||||||
['blogAnnivWidgets', 'BlogAnnivWidget'],
|
[self::class, 'parseWidget'],
|
||||||
null,
|
null,
|
||||||
__('Counting the number of days before and after a particular date')
|
__('Counting the number of days before and after a particular date')
|
||||||
)
|
)
|
||||||
@ -37,14 +40,10 @@ class blogAnnivWidgets
|
|||||||
->addOffline();
|
->addOffline();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function BlogAnnivWidget($w)
|
public static function parseWidget(WidgetsElement $w): string
|
||||||
{
|
{
|
||||||
if ($w->offline) {
|
if ($w->offline || !$w->checkHomeOnly(dcCore::app()->url->type)) {
|
||||||
return null;
|
return '';
|
||||||
}
|
|
||||||
|
|
||||||
if (!$w->checkHomeOnly(dcCore::app()->url->type)) {
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$ftdatecrea = $w->ftdatecrea;
|
$ftdatecrea = $w->ftdatecrea;
|
||||||
@ -93,8 +92,8 @@ class blogAnnivWidgets
|
|||||||
}
|
}
|
||||||
|
|
||||||
return $w->renderDiv(
|
return $w->renderDiv(
|
||||||
$w->content_only,
|
(bool) $w->content_only,
|
||||||
'bloganniv ' . $w->class,
|
My::id() . ' ' . $w->class,
|
||||||
'',
|
'',
|
||||||
($w->title ? $w->renderTitle(html::escapeHTML($w->title)) : '') .
|
($w->title ? $w->renderTitle(html::escapeHTML($w->title)) : '') .
|
||||||
'<ul>' .
|
'<ul>' .
|
||||||
|
Loading…
Reference in New Issue
Block a user