upgrade to Dotclear 2.28

master v2.1
Jean-Christian Paul Denis 2023-10-15 20:49:39 +02:00
parent cc1cf73347
commit 3ffacaeb98
Signed by: JcDenis
GPG Key ID: 1B5B8C5B90B6C951
27 changed files with 451 additions and 523 deletions

View File

@ -1,3 +1,9 @@
cinecturlink2 2.1 - 2023.10.15
===========================================================
* Require Dotclear 2.28
* Require PHP 8.1+
* Upgrade to Dotclear 2.28
cinecturlink2 2.0 - 2023.08.24
===========================================================
* Require Dotclear 2.27

View File

@ -16,7 +16,7 @@ It is hightly based on cinecturlink for Dotclear 1 by Tigroux and maintain by br
## REQUIREMENTS
* Dotclear 2.27
* Dotclear 2.28
* PHP 8.1+
* Dotclear admin permission for configuration
* Dotclear contentadmin permission for management

View File

@ -1,41 +1,31 @@
<?php
/**
* @brief cinecturlink2, a plugin for Dotclear 2
* @file
* @brief The plugin cinecturlink2 definition
* @ingroup cinecturlink2
*
* @package Dotclear
* @subpackage Plugin
* @defgroup cinecturlink2 Plugin cinecturlink2.
*
* @author Jean-Christian Denis and Contributors
* Widgets and pages about books, musics, films, blogs you are interested in
*
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
/*
* Taken from cinecturlink for Dotclear 1
* By Tigroux and Brol
* Under GNU GPL 2.0 license
*
* @author Jean-Christian Denis (author)
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_RC_PATH')) {
return null;
}
declare(strict_types=1);
$this->registerModule(
'Cinecturlink 2',
'Widgets and pages about books, musics, films, blogs you are interested in',
'Jean-Christian Denis and Contributors',
'2.0',
'2.1',
[
'requires' => [
['php', '8.1'],
['core', '2.27'],
],
'settings' => [
'blog' => '#params.' . basename(__DIR__) . '_params',
],
'permissions' => dcCore::app()->auth->makePermissions([
dcAuth::PERMISSION_CONTENT_ADMIN,
]),
'requires' => [['core', '2.28']],
'settings' => ['blog' => '#params.' . basename(__DIR__) . '_params'],
'permissions' => 'My',
'type' => 'plugin',
'support' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/issues',
'details' => 'https://git.dotclear.watch/JcDenis/' . basename(__DIR__) . '/src/branch/master/README.md',

View File

@ -1,21 +0,0 @@
<?php
/**
* @brief cinecturlink2, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Jean-Christian Denis and Contributors
*
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_RC_PATH')) {
return null;
}
class initCinecturlink2
{
public const CINECTURLINK_TABLE_NAME = 'cinecturlink2';
public const CATEGORY_TABLE_NAME = 'cinecturlink2_cat';
}

View File

@ -2,11 +2,11 @@
<modules xmlns:da="http://dotaddict.org/da/">
<module id="cinecturlink2">
<name>Cinecturlink 2</name>
<version>2.0</version>
<version>2.1</version>
<author>Jean-Christian Denis and Contributors</author>
<desc>Widgets and pages about books, musics, films, blogs you are interested in</desc>
<file>https://git.dotclear.watch/JcDenis/cinecturlink2/releases/download/v2.0/plugin-cinecturlink2.zip</file>
<da:dcmin>2.27</da:dcmin>
<file>https://git.dotclear.watch/JcDenis/cinecturlink2/releases/download/v2.1/plugin-cinecturlink2.zip</file>
<da:dcmin>2.28</da:dcmin>
<da:details>https://git.dotclear.watch/JcDenis/cinecturlink2/src/branch/master/README.md</da:details>
<da:support>https://git.dotclear.watch/JcDenis/cinecturlink2/issues</da:support>
</module>

View File

@ -1,22 +1,12 @@
<?php
/**
* @brief cinecturlink2, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Jean-Christian Denis 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\cinecturlink2;
use ArrayObject;
use dcCore;
use dcSettings;
use Dotclear\App;
use Dotclear\Core\BlogSettings;
use Dotclear\Core\Backend\Favorites;
use Dotclear\Core\Process;
use Dotclear\Helper\Html\Form\{
@ -32,6 +22,13 @@ use Dotclear\Helper\Html\Form\{
};
use Dotclear\Helper\File\Files;
/**
* @brief cinecturlink2 backend class.
* @ingroup cinecturlink2
*
* @author Jean-Christian Denis (author)
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
class Backend extends Process
{
public static function init(): bool
@ -47,10 +44,8 @@ class Backend extends Process
My::addBackendMenuItem();
dcCore::app()->addBehavior('initWidgets', [Widgets::class, 'initLinks']);
dcCore::app()->addBehavior('initWidgets', [Widgets::class, 'initCats']);
dcCore::app()->addBehaviors([
App::behavior()->addBehaviors([
'initWidgets' => Widgets::init(...),
'adminColumnsListsV2' => function (ArrayObject $cols) {
$cols[My::id()] = [
My::name(),
@ -89,13 +84,13 @@ class Backend extends Process
'url' => My::manageUrl() . '#links',
'small-icon' => My::icons(),
'large-icon' => My::icons(),
'permissions' => dcCore::app()->auth->makePermissions([dcCore::app()->auth::PERMISSION_CONTENT_ADMIN]),
'permissions' => App::auth()->makePermissions([App::auth()::PERMISSION_CONTENT_ADMIN]),
]);
},
'adminBlogPreferencesFormV2' => function (dcSettings $blog_settings): void {
'adminBlogPreferencesFormV2' => function (BlogSettings $blog_settings): void {
$s = $blog_settings->get(My::id());
$url = (string) dcCore::app()->blog?->url . dcCore::app()->url->getBase(My::id());
$url = App::blog()->url() . App::url()->getBase(My::id());
$public_nbrpp = (int) $s->get('public_nbrpp');
if ($public_nbrpp < 1) {
$public_nbrpp = 10;
@ -202,7 +197,7 @@ class Backend extends Process
->render();
},
'adminBeforeBlogSettingsUpdate' => function (dcSettings $blog_settings): void {
'adminBeforeBlogSettingsUpdate' => function (BlogSettings $blog_settings): void {
$s = $blog_settings->get(My::id());
$active = !empty($_POST[My::id() . 'active']);
$widthmax = abs((int) $_POST[My::id() . 'widthmax']);
@ -218,12 +213,12 @@ class Backend extends Process
$public_nbrpp = 10;
}
if (empty($folder)) {
dcCore::app()->error->add(__('You must provide a specific folder for images.'));
App::error()->add(__('You must provide a specific folder for images.'));
return;
}
Utils::makePublicDir(
DC_ROOT . '/' . dcCore::app()->blog?->settings->get('system')->get('public_path'),
App::config()->dotclearRoot() . '/' . App::blog()->settings()->get('system')->get('public_path'),
$folder,
true
);

View File

@ -1,21 +1,11 @@
<?php
/**
* @brief cinecturlink2, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Jean-Christian Denis 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\cinecturlink2;
use ArrayObject;
use dcCore;
use Dotclear\App;
use Dotclear\Core\Backend\Action\Actions;
use Dotclear\Core\Backend\Page;
use Dotclear\Database\MetaRecord;
@ -25,9 +15,16 @@ use Dotclear\Helper\Html\Form\{
};
use Exception;
/**
* @brief cinecturlink2 links action class.
* @ingroup cinecturlink2
*
* @author Jean-Christian Denis (author)
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
class BackendActionsLinks extends Actions
{
protected $use_render = true;
protected bool $use_render = true;
public Utils $utils;
public function __construct(string $uri, array $redirect_args = [])
@ -49,7 +46,7 @@ class BackendActionsLinks extends Actions
BackendActionsLinksDefault::addDefaultLinksActions($this);
# --BEHAVIOR-- cinecturlink2AddDefaultLinksActions - BackendActionsLinks
dcCore::app()->callBehavior('cinecturlink2AddDefaultLinksActions', $this);
App::behavior()->callBehavior('cinecturlink2AddDefaultLinksActions', $this);
}
public function beginPage(string $breadcrumb = '', string $head = ''): void
@ -75,7 +72,7 @@ class BackendActionsLinks extends Actions
public function error(Exception $e): void
{
dcCore::app()->error->add($e->getMessage());
App::error()->add($e->getMessage());
$this->beginPage(
Page::breadcrumb([
__('Plugins') => '',

View File

@ -1,21 +1,11 @@
<?php
/**
* @brief cinecturlink2, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Jean-Christian Denis 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\cinecturlink2;
use ArrayObject;
use dcCore;
use Dotclear\App;
use Dotclear\Core\Backend\{
Notices,
Page
@ -31,21 +21,28 @@ use Dotclear\Helper\Html\Form\{
};
use Exception;
/**
* @brief cinecturlink2 links default action class.
* @ingroup cinecturlink2
*
* @author Jean-Christian Denis (author)
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
class BackendActionsLinksDefault
{
public static function addDefaultLinksActions(BackendActionsLinks $ap): void
{
$ap->addAction(
[__('Delete') => 'dellinks'],
[self::class, 'doDeleteLinks']
self::doDeleteLinks(...)
);
$ap->addAction(
[__('Change rating') => 'updlinksnote'],
[self::class, 'doChangeNote']
self::doChangeNote(...)
);
$ap->addAction(
[__('Change category') => 'updlinkscat'],
[self::class, 'doChangeCategory']
self::doChangeCategory(...)
);
}
@ -87,7 +84,7 @@ class BackendActionsLinksDefault
$cat_id = is_numeric($post['upd_cat_id']) ? abs((int) $post['upd_cat_id']) : null;
$cur = dcCore::app()->con->openCursor($ap->utils->table);
$cur = App::con()->openCursor($ap->utils->table);
foreach ($ids as $id) {
$cur->clean();
$cur->setField('cat_id', $cat_id == 0 ? null : $cat_id);
@ -125,7 +122,7 @@ class BackendActionsLinksDefault
(new Submit('do-action'))
->value(__('Save')),
(new Hidden(['action'], 'updlinkscat')),
dcCore::app()->formNonce(false),
App::nonce()->formNonce(),
]
)),
@ -152,7 +149,7 @@ class BackendActionsLinksDefault
$link_note = 10;
}
$cur = dcCore::app()->con->openCursor($ap->utils->table);
$cur = App::con()->openCursor($ap->utils->table);
foreach ($ids as $id) {
$cur->clean();
$cur->setField('link_note', $link_note);
@ -190,7 +187,7 @@ class BackendActionsLinksDefault
(new Submit('do-action'))
->value(__('Save')),
(new Hidden(['action'], 'updlinksnote')),
dcCore::app()->formNonce(false),
App::nonce()->formNonce(),
]
)),

View File

@ -1,21 +1,11 @@
<?php
/**
* @brief cinecturlink2, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Jean-Christian Denis 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\cinecturlink2;
use ArrayObject;
use dcCore;
use Dotclear\App;
use Dotclear\Core\Backend\Filter\Filters;
use Dotclear\Core\Backend\Listing\{
Listing,
@ -33,6 +23,13 @@ use Dotclear\Helper\Html\Form\{
};
use Dotclear\Helper\Html\Html;
/**
* @brief cinecturlink2 links list class.
* @ingroup cinecturlink2
*
* @author Jean-Christian Denis (author)
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
class BackendListingLinks extends Listing
{
private string $redir;
@ -56,7 +53,7 @@ class BackendListingLinks extends Listing
}
}
$pager = new Pager((int) $filter->value('page'), $this->rs_count, (int) $filter->value('nb'), 10);
$pager = new Pager((int) $filter->value('page'), (int) $this->rs_count, (int) $filter->value('nb'), 10);
$cols = new ArrayObject([
'title' => (new Th())
@ -161,7 +158,7 @@ class BackendListingLinks extends Listing
->text(Html::escapeHTML($this->rs->link_note))
->class('number'),
'date' => (new Td())
->text(Html::escapeHTML(Date::dt2str(__('%Y-%m-%d %H:%M'), $this->rs->link_upddt, (string) dcCore::app()->auth->getInfo('user_tz'))))
->text(Html::escapeHTML(Date::dt2str(__('%Y-%m-%d %H:%M'), $this->rs->link_upddt, (string) App::auth()->getInfo('user_tz'))))
->class('nowrap'),
]);

View File

@ -1,25 +1,21 @@
<?php
/**
* @brief cinecturlink2, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Jean-Christian Denis 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\cinecturlink2;
use dcCore;
use dcMedia;
use Dotclear\App;
use Dotclear\Helper\Html\Html;
use Dotclear\Helper\L10n;
use Exception;
/**
* @brief cinecturlink2 combo class.
* @ingroup cinecturlink2
*
* @author Jean-Christian Denis (author)
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
class Combo
{
/**
@ -65,10 +61,9 @@ class Combo
$dir = null;
try {
dcCore::app()->media = new dcMedia();
dcCore::app()->media->chdir(My::settings()->folder);
dcCore::app()->media->getDir();
$dir = & dcCore::app()->media->dir;
App::media()->chdir((string) My::settings()->get('folder'));
App::media()->getDir();
$dir = & App::media()->dir;
foreach ($dir['files'] as $file) {
if (!in_array($file->extension, My::ALLOWED_MEDIA_EXTENSION)) {

View File

@ -1,22 +1,19 @@
<?php
/**
* @brief cinecturlink2, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Jean-Christian Denis 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\cinecturlink2;
use dcCore;
use Dotclear\App;
use Dotclear\Core\Process;
/**
* @brief cinecturlink2 frontend class.
* @ingroup cinecturlink2
*
* @author Jean-Christian Denis (author)
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
class Frontend extends Process
{
public static function init(): bool
@ -30,8 +27,7 @@ class Frontend extends Process
return false;
}
dcCore::app()->addBehavior('initWidgets', [Widgets::class, 'initLinks']);
dcCore::app()->addBehavior('initWidgets', [Widgets::class, 'initCats']);
App::behavior()->addBehavior('initWidgets', Widgets::init(...));
$values = [
'c2PageFeedID',
@ -91,16 +87,17 @@ class Frontend extends Process
'c2CategoryIf',
];
if (My::settings()?->active) {
if (My::settings()->active) {
foreach ($blocks as $v) {
dcCore::app()->tpl->addBlock($v, [FrontendTemplate::class, $v]);
App::frontend()->template()->addBlock($v, [FrontendTemplate::class, $v]);
}
foreach ($values as $v) {
dcCore::app()->tpl->addValue($v, [FrontendTemplate::class, $v]);
App::frontend()->template()->addValue($v, [FrontendTemplate::class, $v]);
}
} else {
foreach (array_merge($blocks, $values) as $v) {
dcCore::app()->tpl->addBlock($v, [FrontendTemplate::class, 'disable']);
pdump($v);
App::frontend()->template()->addBlock($v, FrontendTemplate::disable(...));
}
}

View File

@ -1,30 +1,27 @@
<?php
/**
* @brief cinecturlink2, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Jean-Christian Denis 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\cinecturlink2;
use dcCore;
use Dotclear\App;
/**
* @brief cinecturlink2 frontend contxt class.
* @ingroup cinecturlink2
*
* @author Jean-Christian Denis (author)
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
class FrontendContext
{
public static function PaginationNbPages()
{
if (dcCore::app()->ctx->c2_pagination === null) {
if (App::frontend()->context()->c2_pagination === null) {
return false;
}
$nb_posts = dcCore::app()->ctx->c2_pagination->f(0);
$nb_per_page = dcCore::app()->ctx->c2_params['limit'][1];
$nb_posts = App::frontend()->context()->c2_pagination->f(0);
$nb_per_page = App::frontend()->context()->c2_params['limit'][1];
$nb_pages = ceil($nb_posts / $nb_per_page);
return $nb_pages;
@ -72,7 +69,7 @@ class FrontendContext
$args = preg_replace('#(^|/)c2page/([0-9]+)$#', '', $args);
$url = dcCore::app()->blog->url . $args;
$url = App::blog()->url() . $args;
if ($n > 1) {
$url = preg_replace('#/$#', '', $url);
@ -89,18 +86,18 @@ class FrontendContext
public static function categoryCurrent()
{
if (!isset(dcCore::app()->ctx->c2_page_params['cat_id'])
&& !isset(dcCore::app()->ctx->c2_page_params['cat_title'])
if (!isset(App::frontend()->context()->c2_page_params['cat_id'])
&& !isset(App::frontend()->context()->c2_page_params['cat_title'])
) {
return false;
}
if (isset(dcCore::app()->ctx->c2_page_params['cat_id'])
&& dcCore::app()->ctx->c2_page_params['cat_id'] == dcCore::app()->ctx->c2_categories->cat_id
if (isset(App::frontend()->context()->c2_page_params['cat_id'])
&& App::frontend()->context()->c2_page_params['cat_id'] == App::frontend()->context()->c2_categories->cat_id
) {
return true;
}
if (isset(dcCore::app()->ctx->c2_page_params['cat_title'])
&& dcCore::app()->ctx->c2_page_params['cat_title'] == dcCore::app()->ctx->c2_categories->cat_title
if (isset(App::frontend()->context()->c2_page_params['cat_title'])
&& App::frontend()->context()->c2_page_params['cat_title'] == App::frontend()->context()->c2_categories->cat_title
) {
return true;
}

View File

@ -1,24 +1,21 @@
<?php
/**
* @brief cinecturlink2, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Jean-Christian Denis 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\cinecturlink2;
use ArrayObject;
use dcCore;
use dcTemplate;
use Dotclear\App;
use Dotclear\Core\Frontend\Tpl;
use Dotclear\Helper\Html\Html;
/**
* @brief cinecturlink2 frontend template class.
* @ingroup cinecturlink2
*
* @author Jean-Christian Denis (author)
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
class FrontendTemplate
{
public static function disable(ArrayObject $a, ?string $c = null): string
@ -28,43 +25,43 @@ class FrontendTemplate
public static function c2PageURL(ArrayObject $a): string
{
return '<?php echo ' . sprintf(dcCore::app()->tpl->getFilters($a), 'dcCore::app()->blog->url.dcCore::app()->url->getBase(\'cinecturlink2\')') . '; ?>';
return '<?php echo ' . sprintf(App::frontend()->template()->getFilters($a), 'App::blog()->url().App::url()->getBase(\'cinecturlink2\')') . '; ?>';
}
public static function c2PageTitle(ArrayObject $a): string
{
return "<?php \$title = (string) dcCore::app()->blog->settings->cinecturlink2->public_title; if (empty(\$title)) { \$title = __('My cinecturlink'); } echo " . sprintf(dcCore::app()->tpl->getFilters($a), '$title') . '; ?>';
return "<?php \$title = (string) App::blog()->settings()->cinecturlink2->public_title; if (empty(\$title)) { \$title = __('My cinecturlink'); } echo " . sprintf(App::frontend()->template()->getFilters($a), '$title') . '; ?>';
}
public static function c2PageFeedURL(ArrayObject $a): string
{
return '<?php echo ' . sprintf(dcCore::app()->tpl->getFilters($a), 'dcCore::app()->blog->url.dcCore::app()->url->getBase("' . My::id() . '")."/feed/' . (!empty($a['type']) && preg_match('#^(rss2|atom)$#', $a['type']) ? $a['type'] : 'atom') . '"') . '; ?>';
return '<?php echo ' . sprintf(App::frontend()->template()->getFilters($a), 'App::blog()->url().App::url()->getBase("' . My::id() . '")."/feed/' . (!empty($a['type']) && preg_match('#^(rss2|atom)$#', $a['type']) ? $a['type'] : 'atom') . '"') . '; ?>';
}
public static function c2PageFeedID(ArrayObject $a): string
{
return 'urn:md5:<?php echo md5(dcCore::app()->blog->id."' . My::id() . '"); ?>';
return 'urn:md5:<?php echo md5(App::blog()->id()."' . My::id() . '"); ?>';
}
public static function c2PageDescription(ArrayObject $a): string
{
return '<?php $description = (string) dcCore::app()->blog->settings->cinecturlink2->public_description; echo ' . sprintf(dcCore::app()->tpl->getFilters($a), '$description') . '; ?>';
return '<?php $description = (string) App::blog()->settings()->cinecturlink2->public_description; echo ' . sprintf(App::frontend()->template()->getFilters($a), '$description') . '; ?>';
}
public static function c2If(ArrayObject $a, string $c): string
{
$if = [];
$operator = isset($a['operator']) ? dcTemplate::getOperator($a['operator']) : '&&';
$operator = isset($a['operator']) ? Tpl::getOperator($a['operator']) : '&&';
if (isset($a['request_link'])) {
$sign = (bool) $a['request_link'] ? '' : '!';
$if[] = $sign . '(isset(dcCore::app()->ctx->c2_page_params["link_id"]) || isset(dcCore::app()->ctx->c2_page_params["link_title"]))';
$if[] = $sign . '(isset(App::frontend()->context()->c2_page_params["link_id"]) || isset(App::frontend()->context()->c2_page_params["link_title"]))';
}
if (isset($a['request_cat'])) {
$sign = (bool) $a['request_cat'] ? '' : '!';
$if[] = $sign . '(isset(dcCore::app()->ctx->c2_page_params["cat_id"]) || isset(dcCore::app()->ctx->c2_page_params["cat_title"]))';
$if[] = $sign . '(isset(App::frontend()->context()->c2_page_params["cat_id"]) || isset(App::frontend()->context()->c2_page_params["cat_title"]))';
}
return empty($if) ? $c : '<?php if(' . implode(' ' . $operator . ' ', $if) . ") : ?>\n" . $c . "<?php endif; ?>\n";
@ -106,35 +103,35 @@ class FrontendTemplate
return
"<?php \n" .
"\$params = is_array(dcCore::app()->ctx->c2_page_params) ? dcCore::app()->ctx->c2_page_params : array(); \n" .
"\$params = is_array(App::frontend()->context()->c2_page_params) ? App::frontend()->context()->c2_page_params : array(); \n" .
$res .
"dcCore::app()->ctx->c2_params = \$params; unset(\$params);\n" .
"if (!dcCore::app()->ctx->exists('cinecturlink')) { dcCore::app()->ctx->cinecturlink = new " . Utils::class . "(); } \n" .
"dcCore::app()->ctx->c2_entries = dcCore::app()->ctx->cinecturlink->getLinks(dcCore::app()->ctx->c2_params); \n" .
'while (dcCore::app()->ctx->c2_entries->fetch()) : ?>' . $c . '<?php endwhile; ' . "\n" .
"dcCore::app()->ctx->pop('c2_entries'); dcCore::app()->ctx->pop('c2_params'); \n" .
"App::frontend()->context()->c2_params = \$params; unset(\$params);\n" .
"if (!App::frontend()->context()->exists('cinecturlink')) { App::frontend()->context()->cinecturlink = new " . Utils::class . "(); } \n" .
"App::frontend()->context()->c2_entries = App::frontend()->context()->cinecturlink->getLinks(App::frontend()->context()->c2_params); \n" .
'while (App::frontend()->context()->c2_entries->fetch()) : ?>' . $c . '<?php endwhile; ' . "\n" .
"App::frontend()->context()->pop('c2_entries'); App::frontend()->context()->pop('c2_params'); \n" .
"?>\n";
}
public static function c2EntriesHeader(ArrayObject $a, string $c): string
{
return '<?php if (dcCore::app()->ctx->c2_entries->isStart()) : ?>' . $c . '<?php endif; ?>';
return '<?php if (App::frontend()->context()->c2_entries->isStart()) : ?>' . $c . '<?php endif; ?>';
}
public static function c2EntriesFooter(ArrayObject $a, string $c): string
{
return '<?php if (dcCore::app()->ctx->c2_entries->isEnd()) : ?>' . $c . '<?php endif; ?>';
return '<?php if (App::frontend()->context()->c2_entries->isEnd()) : ?>' . $c . '<?php endif; ?>';
}
public static function c2EntryIf(ArrayObject $a, string $c): string
{
$if = [];
$operator = isset($a['operator']) ? dcTemplate::getOperator($a['operator']) : '&&';
$operator = isset($a['operator']) ? Tpl::getOperator($a['operator']) : '&&';
if (isset($a['has_category'])) {
$sign = (bool) $a['has_category'] ? '!' : '=';
$if[] = '(dcCore::app()->ctx->exists("c2_entries") && "" ' . $sign . '= dcCore::app()->ctx->c2_entries->cat_title)';
$if[] = '(App::frontend()->context()->exists("c2_entries") && "" ' . $sign . '= App::frontend()->context()->c2_entries->cat_title)';
}
return empty($if) ? $c : '<?php if(' . implode(' ' . $operator . ' ', $if) . ") : ?>\n" . $c . "<?php endif; ?>\n";
@ -142,105 +139,105 @@ class FrontendTemplate
public static function c2EntryIfFirst(ArrayObject $a): string
{
return '<?php if (dcCore::app()->ctx->c2_entries->index() == 0) { echo "' . (isset($a['return']) ? addslashes(Html::escapeHTML($a['return'])) : 'first') . '"; } ?>';
return '<?php if (App::frontend()->context()->c2_entries->index() == 0) { echo "' . (isset($a['return']) ? addslashes(Html::escapeHTML($a['return'])) : 'first') . '"; } ?>';
}
public static function c2EntryIfOdd(ArrayObject $a): string
{
return '<?php if ((dcCore::app()->ctx->c2_entries->index()+1)%2 == 1) { echo "' . (isset($a['return']) ? addslashes(Html::escapeHTML($a['return'])) : 'odd') . '"; } ?>';
return '<?php if ((App::frontend()->context()->c2_entries->index()+1)%2 == 1) { echo "' . (isset($a['return']) ? addslashes(Html::escapeHTML($a['return'])) : 'odd') . '"; } ?>';
}
public static function c2EntryFeedID(ArrayObject $a): string
{
return 'urn:md5:<?php echo md5(dcCore::app()->ctx->c2_entries->blog_id.dcCore::app()->ctx->c2_entries->link_id.dcCore::app()->ctx->c2_entries->link_creadt); ?>';
return 'urn:md5:<?php echo md5(App::frontend()->context()->c2_entries->blog_id.App::frontend()->context()->c2_entries->link_id.App::frontend()->context()->c2_entries->link_creadt); ?>';
}
public static function c2EntryID(ArrayObject $a): string
{
return self::getGenericValue('dcCore::app()->ctx->c2_entries->link_id', $a);
return self::getGenericValue('App::frontend()->context()->c2_entries->link_id', $a);
}
public static function c2EntryTitle(ArrayObject $a): string
{
return self::getGenericValue('dcCore::app()->ctx->c2_entries->link_title', $a);
return self::getGenericValue('App::frontend()->context()->c2_entries->link_title', $a);
}
public static function c2EntryDescription(ArrayObject $a): string
{
return self::getGenericValue('dcCore::app()->ctx->c2_entries->link_desc', $a);
return self::getGenericValue('App::frontend()->context()->c2_entries->link_desc', $a);
}
public static function c2EntryAuthorCommonName(ArrayObject $a): string
{
return self::getGenericValue('dcUtils::getUserCN(dcCore::app()->ctx->c2_entries->user_id,dcCore::app()->ctx->c2_entries->user_name,dcCore::app()->ctx->c2_entries->user_firstname,dcCore::app()->ctx->c2_entries->user_displayname)', $a);
return self::getGenericValue('App::users()->getUserCN(App::frontend()->context()->c2_entries->user_id,App::frontend()->context()->c2_entries->user_name,App::frontend()->context()->c2_entries->user_firstname,App::frontend()->context()->c2_entries->user_displayname)', $a);
}
public static function c2EntryAuthorDisplayName(ArrayObject $a): string
{
return self::getGenericValue('dcCore::app()->ctx->c2_entries->user_displayname', $a);
return self::getGenericValue('App::frontend()->context()->c2_entries->user_displayname', $a);
}
public static function c2EntryAuthorID(ArrayObject $a): string
{
return self::getGenericValue('dcCore::app()->ctx->c2_entries->user_id', $a);
return self::getGenericValue('App::frontend()->context()->c2_entries->user_id', $a);
}
public static function c2EntryAuthorEmail(ArrayObject $a): string
{
return self::getGenericValue((isset($a['spam_protected']) && !$a['spam_protected'] ? 'dcCore::app()->ctx->c2_entries->user_email' : "strtr(dcCore::app()->ctx->c2_entries->user_email,array('@'=>'%40','.'=>'%2e'))"), $a);
return self::getGenericValue((isset($a['spam_protected']) && !$a['spam_protected'] ? 'App::frontend()->context()->c2_entries->user_email' : "strtr(App::frontend()->context()->c2_entries->user_email,array('@'=>'%40','.'=>'%2e'))"), $a);
}
public static function c2EntryAuthorLink(ArrayObject $a): string
{
return self::getGenericValue('sprintf((dcCore::app()->ctx->c2_entries->user_url ? \'<a href="%2$s">%1$s</a>\' : \'%1$s\'),html::escapeHTML(dcUtils::getUserCN(dcCore::app()->ctx->c2_entries->user_id,dcCore::app()->ctx->c2_entries->user_name,dcCore::app()->ctx->c2_entries->user_firstname,dcCore::app()->ctx->c2_entries->user_displayname)),html::escapeHTML(dcCore::app()->ctx->c2_entries->user_url))', $a);
return self::getGenericValue('sprintf((App::frontend()->context()->c2_entries->user_url ? \'<a href="%2$s">%1$s</a>\' : \'%1$s\'),html::escapeHTML(App::users()->getUserCN(App::frontend()->context()->c2_entries->user_id,App::frontend()->context()->c2_entries->user_name,App::frontend()->context()->c2_entries->user_firstname,App::frontend()->context()->c2_entries->user_displayname)),html::escapeHTML(App::frontend()->context()->c2_entries->user_url))', $a);
}
public static function c2EntryAuthorURL(ArrayObject $a): string
{
return self::getGenericValue('dcCore::app()->ctx->c2_entries->user_url', $a);
return self::getGenericValue('App::frontend()->context()->c2_entries->user_url', $a);
}
public static function c2EntryFromAuthor(ArrayObject $a): string
{
return self::getGenericValue('dcCore::app()->ctx->c2_entries->link_author', $a);
return self::getGenericValue('App::frontend()->context()->c2_entries->link_author', $a);
}
public static function c2EntryLang(ArrayObject $a): string
{
return self::getGenericValue('dcCore::app()->ctx->c2_entries->link_lang', $a);
return self::getGenericValue('App::frontend()->context()->c2_entries->link_lang', $a);
}
public static function c2EntryURL(ArrayObject $a): string
{
return self::getGenericValue('dcCore::app()->ctx->c2_entries->link_url', $a);
return self::getGenericValue('App::frontend()->context()->c2_entries->link_url', $a);
}
public static function c2EntryCategory(ArrayObject $a): string
{
return self::getGenericValue('dcCore::app()->ctx->c2_entries->cat_title', $a);
return self::getGenericValue('App::frontend()->context()->c2_entries->cat_title', $a);
}
public static function c2EntryCategoryID(ArrayObject $a): string
{
return self::getGenericValue('dcCore::app()->ctx->c2_entries->cat_id', $a);
return self::getGenericValue('App::frontend()->context()->c2_entries->cat_id', $a);
}
public static function c2EntryCategoryURL(ArrayObject $a): string
{
return self::getGenericValue('dcCore::app()->blog->url.dcCore::app()->url->getBase("' . My::id() . '")."/".dcCore::app()->blog->settings->cinecturlink2->public_caturl."/".urlencode(dcCore::app()->ctx->c2_entries->cat_title)', $a);
return self::getGenericValue('App::blog()->url().App::url()->getBase("' . My::id() . '")."/".App::blog()->settings()->cinecturlink2->public_caturl."/".urlencode(App::frontend()->context()->c2_entries->cat_title)', $a);
}
public static function c2EntryImg(ArrayObject $a): string
{
$f = dcCore::app()->tpl->getFilters($a);
$f = App::frontend()->template()->getFilters($a);
$style = isset($a['style']) ? Html::escapeHTML($a['style']) : '';
return
"<?php if (dcCore::app()->ctx->exists('c2_entries')) { " .
'$widthmax = (integer) dcCore::app()->blog->settings->cinecturlink2->widthmax; ' .
"<?php if (App::frontend()->context()->exists('c2_entries')) { " .
'$widthmax = (integer) App::blog()->settings()->cinecturlink2->widthmax; ' .
"\$img = sprintf('<img src=\"%s\" alt=\"%s\" %s/>'," .
'dcCore::app()->ctx->c2_entries->link_img, ' .
"html::escapeHTML(dcCore::app()->ctx->c2_entries->link_title.' - '.dcCore::app()->ctx->c2_entries->link_author), " .
'App::frontend()->context()->c2_entries->link_img, ' .
"html::escapeHTML(App::frontend()->context()->c2_entries->link_title.' - '.App::frontend()->context()->c2_entries->link_author), " .
"(\$widthmax ? ' style=\"width:'.\$widthmax.'px;$style\"' : '') " .
'); ' .
'echo ' . sprintf($f, '$img') . "; unset(\$img); } ?> \n";
@ -251,13 +248,13 @@ class FrontendTemplate
$format = !empty($a['format']) ? addslashes($a['format']) : '';
if (!empty($a['rfc822'])) {
$p = 'dt::rfc822(strtotime(dcCore::app()->ctx->c2_entries->link_creadt), dcCore::app()->blog->settings->system->blog_timezone)';
$p = 'dt::rfc822(strtotime(App::frontend()->context()->c2_entries->link_creadt), App::blog()->settings()->system->blog_timezone)';
} elseif (!empty($a['iso8601'])) {
$p = 'dt::iso8601(strtotime(dcCore::app()->ctx->c2_entries->link_creadt), dcCore::app()->blog->settings->system->blog_timezone)';
$p = 'dt::iso8601(strtotime(App::frontend()->context()->c2_entries->link_creadt), App::blog()->settings()->system->blog_timezone)';
} elseif ($format) {
$p = "dt::dt2str('" . $format . "', dcCore::app()->ctx->c2_entries->link_creadt)";
$p = "dt::dt2str('" . $format . "', App::frontend()->context()->c2_entries->link_creadt)";
} else {
$p = 'dt::dt2str(dcCore::app()->blog->settings->system->date_format, dcCore::app()->ctx->c2_entries->link_creadt)';
$p = 'dt::dt2str(App::blog()->settings()->system->date_format, App::frontend()->context()->c2_entries->link_creadt)';
}
return self::getGenericValue($p, $a);
@ -265,17 +262,17 @@ class FrontendTemplate
public static function c2EntryTime(ArrayObject $a): string
{
return self::getGenericValue('dt::dt2str(' . (!empty($a['format']) ? "'" . addslashes($a['format']) . "'" : 'dcCore::app()->blog->settings->system->time_format') . ', dcCore::app()->ctx->c2_entries->link_creadt)', $a);
return self::getGenericValue('dt::dt2str(' . (!empty($a['format']) ? "'" . addslashes($a['format']) . "'" : 'App::blog()->settings()->system->time_format') . ', App::frontend()->context()->c2_entries->link_creadt)', $a);
}
public static function c2Pagination(ArrayObject $a, string $c): string
{
$p = "<?php\n" .
"\$params = dcCore::app()->ctx->c2_params;\n" .
"dcCore::app()->ctx->c2_pagination = dcCore::app()->ctx->cinecturlink->getLinks(\$params,true); unset(\$params);\n" .
"\$params = App::frontend()->context()->c2_params;\n" .
"App::frontend()->context()->c2_pagination = App::frontend()->context()->cinecturlink->getLinks(\$params,true); unset(\$params);\n" .
"?>\n";
return isset($a['no_context']) ? $p . $c : $p . '<?php if (dcCore::app()->ctx->c2_pagination->f(0) > dcCore::app()->ctx->c2_entries->count()) : ?>' . $c . '<?php endif; ?>';
return isset($a['no_context']) ? $p . $c : $p . '<?php if (App::frontend()->context()->c2_pagination->f(0) > App::frontend()->context()->c2_entries->count()) : ?>' . $c . '<?php endif; ?>';
}
public static function c2PaginationCounter(ArrayObject $a): string
@ -313,21 +310,21 @@ class FrontendTemplate
{
return
"<?php \n" .
"if (!dcCore::app()->ctx->exists('cinecturlink')) { dcCore::app()->ctx->cinecturlink = new " . Utils::class . "(); } \n" .
"dcCore::app()->ctx->c2_categories = dcCore::app()->ctx->cinecturlink->getCategories(); \n" .
'while (dcCore::app()->ctx->c2_categories->fetch()) : ?>' . $c . '<?php endwhile; ' . "\n" .
"dcCore::app()->ctx->c2_categories = null; \n" .
"if (!App::frontend()->context()->exists('cinecturlink')) { App::frontend()->context()->cinecturlink = new " . Utils::class . "(); } \n" .
"App::frontend()->context()->c2_categories = App::frontend()->context()->cinecturlink->getCategories(); \n" .
'while (App::frontend()->context()->c2_categories->fetch()) : ?>' . $c . '<?php endwhile; ' . "\n" .
"App::frontend()->context()->c2_categories = null; \n" .
"?>\n";
}
public static function c2CategoriesHeader(ArrayObject $a, string $c): string
{
return '<?php if (dcCore::app()->ctx->c2_categories->isStart()) : ?>' . $c . '<?php endif; ?>';
return '<?php if (App::frontend()->context()->c2_categories->isStart()) : ?>' . $c . '<?php endif; ?>';
}
public static function c2CategoriesFooter(ArrayObject $a, string $c): string
{
return '<?php if (dcCore::app()->ctx->c2_categories->isEnd()) : ?>' . $c . '<?php endif; ?>';
return '<?php if (App::frontend()->context()->c2_categories->isEnd()) : ?>' . $c . '<?php endif; ?>';
}
public static function c2CategoryIf(ArrayObject $a, string $c): string
@ -340,7 +337,7 @@ class FrontendTemplate
}
if (isset($a['first'])) {
$sign = (bool) $a['first'] ? '' : '!';
$if[] = $sign . 'dcCore::app()->ctx->c2_categories->isStart()';
$if[] = $sign . 'App::frontend()->context()->c2_categories->isStart()';
}
return empty($if) ? $c : '<?php if(' . implode(' && ', $if) . ') : ?>' . $c . '<?php endif; ?>';
@ -354,36 +351,36 @@ class FrontendTemplate
$p = 'atom';
}
return '<?php echo ' . sprintf(dcCore::app()->tpl->getFilters($a), 'dcCore::app()->blog->url.dcCore::app()->url->getBase("' . My::id() . '")."/".dcCore::app()->blog->settings->cinecturlink2->public_caturl."/".urlencode(dcCore::app()->ctx->c2_categories->cat_title)."/feed/' . $p . '"') . '; ?>';
return '<?php echo ' . sprintf(App::frontend()->template()->getFilters($a), 'App::blog()->url().App::url()->getBase("' . My::id() . '")."/".App::blog()->settings()->cinecturlink2->public_caturl."/".urlencode(App::frontend()->context()->c2_categories->cat_title)."/feed/' . $p . '"') . '; ?>';
}
public static function c2CategoryFeedID(ArrayObject $a): string
{
return 'urn:md5:<?php echo md5(dcCore::app()->blog->id."' . My::id() . '".dcCore::app()->ctx->c2_categories->cat_id); ?>';
return 'urn:md5:<?php echo md5(App::blog()->id()."' . My::id() . '".App::frontend()->context()->c2_categories->cat_id); ?>';
}
public static function c2CategoryID(ArrayObject $a): string
{
return "<?php if (dcCore::app()->ctx->exists('c2_categories')) { echo " . sprintf(dcCore::app()->tpl->getFilters($a), 'dcCore::app()->ctx->c2_categories->cat_id') . '; } ?>';
return "<?php if (App::frontend()->context()->exists('c2_categories')) { echo " . sprintf(App::frontend()->template()->getFilters($a), 'App::frontend()->context()->c2_categories->cat_id') . '; } ?>';
}
public static function c2CategoryTitle(ArrayObject $a): string
{
return "<?php if (dcCore::app()->ctx->exists('c2_categories')) { echo " . sprintf(dcCore::app()->tpl->getFilters($a), 'dcCore::app()->ctx->c2_categories->cat_title') . '; } ?>';
return "<?php if (App::frontend()->context()->exists('c2_categories')) { echo " . sprintf(App::frontend()->template()->getFilters($a), 'App::frontend()->context()->c2_categories->cat_title') . '; } ?>';
}
public static function c2CategoryDescription(ArrayObject $a): string
{
return "<?php if (dcCore::app()->ctx->exists('c2_categories')) { echo " . sprintf(dcCore::app()->tpl->getFilters($a), 'dcCore::app()->ctx->c2_categories->cat_desc') . '; } ?>';
return "<?php if (App::frontend()->context()->exists('c2_categories')) { echo " . sprintf(App::frontend()->template()->getFilters($a), 'App::frontend()->context()->c2_categories->cat_desc') . '; } ?>';
}
public static function c2CategoryURL(ArrayObject $a): string
{
return "<?php if (dcCore::app()->ctx->exists('c2_categories')) { echo " . sprintf(dcCore::app()->tpl->getFilters($a), 'dcCore::app()->blog->url.dcCore::app()->url->getBase("' . My::id() . '")."/".dcCore::app()->blog->settings->cinecturlink2->public_caturl."/".urlencode(dcCore::app()->ctx->c2_categories->cat_title)') . '; } ?>';
return "<?php if (App::frontend()->context()->exists('c2_categories')) { echo " . sprintf(App::frontend()->template()->getFilters($a), 'App::blog()->url().App::url()->getBase("' . My::id() . '")."/".App::blog()->settings()->cinecturlink2->public_caturl."/".urlencode(App::frontend()->context()->c2_categories->cat_title)') . '; } ?>';
}
protected static function getGenericValue(string $p, ArrayObject $a): string
{
return "<?php if (dcCore::app()->ctx->exists('c2_entries')) { echo " . sprintf(dcCore::app()->tpl->getFilters($a), "$p") . '; } ?>';
return "<?php if (App::frontend()->context()->exists('c2_entries')) { echo " . sprintf(App::frontend()->template()->getFilters($a), "$p") . '; } ?>';
}
}

View File

@ -1,26 +1,21 @@
<?php
/**
* @brief cinecturlink2, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Jean-Christian Denis 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\cinecturlink2;
use dcCore;
use dcUrlHandlers;
use context;
use Dotclear\Core\Frontend\Utility;
use Dotclear\App;
use Dotclear\Core\Frontend\Url;
use Dotclear\Helper\File\Path;
class FrontendUrl extends dcUrlHandlers
/**
* @brief cinecturlink2 frontend URLclass.
* @ingroup cinecturlink2
*
* @author Jean-Christian Denis (author)
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
class FrontendUrl extends Url
{
public static function c2Page(?string $args)
{
@ -31,9 +26,9 @@ class FrontendUrl extends dcUrlHandlers
self::p404();
}
$tplset = dcCore::app()->themes->getDefine(dcCore::app()->blog->settings->system->theme)->get('tplset');
$tpldir = Path::real(dcCore::app()->plugins->getDefine(My::id())->get('root')) . DIRECTORY_SEPARATOR . Utility::TPL_ROOT . DIRECTORY_SEPARATOR;
dcCore::app()->tpl->setPath(dcCore::app()->tpl->getPath(), $tpldir . (!empty($tplset) && is_dir($tpldir . $tplset) ? $tplset : DC_DEFAULT_TPLSET));
$tplset = App::themes()->getDefine(App::blog()->settings()->get('system')->get('theme'))->get('tplset');
$tpldir = Path::real(App::plugins()->getDefine(My::id())->get('root')) . DIRECTORY_SEPARATOR . App::frontend()::TPL_ROOT . DIRECTORY_SEPARATOR;
App::frontend()->template()->setPath(App::frontend()->template()->getPath(), $tpldir . (!empty($tplset) && is_dir($tpldir . $tplset) ? $tplset : App::config()->defaultTplset()));
$params = [];
@ -60,12 +55,12 @@ class FrontendUrl extends dcUrlHandlers
if (!empty($f) && in_array($f, ['atom', 'rss2'])) {
$mime = $f == 'atom' ? 'application/atom+xml' : 'application/xml';
//dcCore::app()->ctx->short_feed_items = dcCore::app()->blog->settings->system->short_feed_items;
//App::frontend()->context()->short_feed_items = App::blog()->settings()->system->short_feed_items;
$params['limit'] = dcCore::app()->blog->settings->system->nb_post_per_feed;
dcCore::app()->ctx->c2_page_params = $params;
$params['limit'] = App::blog()->settings()->get('system')->get('nb_post_per_feed');
App::frontend()->context()->c2_page_params = $params;
header('X-Robots-Tag: ' . context::robotsPolicy(dcCore::app()->blog->settings->system->robots_policy, ''));
header('X-Robots-Tag: ' . App::frontend()->context()::robotsPolicy(App::blog()->settings()->get('system')->get('robots_policy'), ''));
self::serveDocument('cinecturlink2-' . $f . '.xml', $mime);
} else {
$d = self::getPageArgs($args, 'c2detail');
@ -78,7 +73,7 @@ class FrontendUrl extends dcUrlHandlers
}
$params['limit'] = (int) My::settings()->public_nbrpp;
dcCore::app()->ctx->c2_page_params = $params;
App::frontend()->context()->c2_page_params = $params;
self::serveDocument('cinecturlink2.html', 'text/html');
}

View File

@ -1,26 +1,22 @@
<?php
/**
* @brief cinecturlink2, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Jean-Christian Denis 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\cinecturlink2;
use dcCore;
use dcNamespace;
use Dotclear\App;
use Dotclear\Core\Process;
use Dotclear\Database\Structure;
use Dotclear\Database\Statement\UpdateStatement;
use Exception;
/**
* @brief cinecturlink2 install class.
* @ingroup cinecturlink2
*
* @author Jean-Christian Denis (author)
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
class Install extends Process
{
public static function init(): bool
@ -37,7 +33,7 @@ class Install extends Process
try {
self::upgradeSettings();
$s = new Structure(dcCore::app()->con, dcCore::app()->prefix);
$s = new Structure(App::con(), App::con()->prefix());
$s->{My::CINECTURLINK_TABLE_NAME}
->link_id('bigint', 0, false)
->blog_id('varchar', 32, false)
@ -77,7 +73,7 @@ class Install extends Process
->index('idx_cinecturlink2_cat_blog_id', 'btree', 'blog_id')
->unique('uk_cinecturlink2_cat_title', 'cat_title', 'blog_id');
(new Structure(dcCore::app()->con, dcCore::app()->prefix))->synchronize($s);
(new Structure(App::con(), App::con()->prefix()))->synchronize($s);
$s = My::settings();
$s->put('avtive', true, 'boolean', 'Enable cinecturlink2', false, true);
@ -92,7 +88,7 @@ class Install extends Process
return true;
} catch (Exception $e) {
dcCore::app()->error->add($e->getMessage());
App::error()->add($e->getMessage());
return false;
}
@ -100,7 +96,7 @@ class Install extends Process
private static function upgradeSettings(): void
{
if (version_compare((string) dcCore::app()->getVersion(My::id()), '2.0', '<')) {
if (version_compare(App::version()->getVersion(My::id()), '2.0', '<')) {
$ids = [
'active',
'widthmax',
@ -116,7 +112,7 @@ class Install extends Process
foreach ($ids as $id) {
$sql = new UpdateStatement();
$sql
->ref(dcCore::app()->prefix . dcNamespace::NS_TABLE_NAME)
->ref(App::con()->prefix() . App::blogWorkspace()::NS_TABLE_NAME)
->column('setting_id')
->value($id)
->where('setting_id = ' . $sql->quote('cinecturlink2_' . $id))

View File

@ -1,21 +1,18 @@
<?php
/**
* @brief cinecturlink2, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Jean-Christian Denis 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\cinecturlink2;
use Dotclear\Core\Process;
/**
* @brief cinecturlink2 manage class.
* @ingroup cinecturlink2
*
* @author Jean-Christian Denis (author)
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
class Manage extends Process
{
public static function init(): bool

View File

@ -1,20 +1,10 @@
<?php
/**
* @brief cinecturlink2, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Jean-Christian Denis 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\cinecturlink2;
use dcCore;
use Dotclear\App;
use Dotclear\Core\Backend\{
Notices,
Page
@ -32,6 +22,13 @@ use Dotclear\Helper\Html\Form\{
use Dotclear\Helper\Html\Html;
use Exception;
/**
* @brief cinecturlink2 manage category class.
* @ingroup cinecturlink2
*
* @author Jean-Christian Denis (author)
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
class ManageCat extends Process
{
private static string $module_redir = '';
@ -64,7 +61,7 @@ class ManageCat extends Process
if ($exists) {
throw new Exception(__('Category with same name already exists.'));
}
$cur = dcCore::app()->con->openCursor($utils->cat_table);
$cur = App::con()->openCursor($utils->cat_table);
$cur->setField('cat_title', self::$cattitle);
$cur->setField('cat_desc', self::$catdesc);
@ -81,7 +78,7 @@ class ManageCat extends Process
if ($exists) {
throw new Exception(__('Category with same name already exists.'));
}
$cur = dcCore::app()->con->openCursor($C2->cat_table);
$cur = App::con()->openCursor($C2->cat_table);
$cur->setField('cat_title', self::$cattitle);
$cur->setField('cat_desc', self::$catdesc);
@ -102,7 +99,7 @@ class ManageCat extends Process
My::redirect(['part' => 'cats']);
}
} catch (Exception $e) {
dcCore::app()->error->add($e->getMessage());
App::error()->add($e->getMessage());
}
return true;

View File

@ -1,20 +1,10 @@
<?php
/**
* @brief cinecturlink2, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Jean-Christian Denis 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\cinecturlink2;
use dcCore;
use Dotclear\App;
use Dotclear\Core\Backend\{
Notices,
Page
@ -36,6 +26,13 @@ use Dotclear\Helper\Html\Form\{
use Dotclear\Helper\Html\Html;
use Exception;
/**
* @brief cinecturlink2 manage categories class.
* @ingroup cinecturlink2
*
* @author Jean-Christian Denis (author)
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
class ManageCats extends Process
{
private static string $module_redir = '';
@ -73,7 +70,7 @@ class ManageCats extends Process
$i = 0;
foreach ($catorder as $id) {
$i++;
$cur = dcCore::app()->con->openCursor($utils->cat_table);
$cur = App::con()->openCursor($utils->cat_table);
$cur->setField('cat_pos', $i);
$utils->updCategory((int) $id, $cur);
}
@ -93,7 +90,7 @@ class ManageCats extends Process
My::redirect(['part' => 'cats']);
}
} catch (Exception $e) {
dcCore::app()->error->add($e->getMessage());
App::error()->add($e->getMessage());
}
return true;
@ -157,7 +154,7 @@ class ManageCats extends Process
Page::openModule(
My::name(),
(!dcCore::app()->auth->user_prefs?->get('accessibility')->get('nodragdrop') ?
(!App::auth()->prefs()->get('accessibility')->get('nodragdrop') ?
Page::jsLoad('js/jquery/jquery-ui.custom.js') .
Page::jsLoad('js/jquery/jquery.ui.touch-punch.js') .
My::jsLoad('c2cats')

View File

@ -1,20 +1,10 @@
<?php
/**
* @brief cinecturlink2, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Jean-Christian Denis 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\cinecturlink2;
use dcCore;
use Dotclear\App;
use Dotclear\Core\Backend\{
Notices,
Page
@ -36,6 +26,13 @@ use Dotclear\Helper\Html\Html;
use Dotclear\Helper\Network\Http;
use Exception;
/**
* @brief cinecturlink2 manage link class.
* @ingroup cinecturlink2
*
* @author Jean-Christian Denis (author)
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
class ManageLink extends Process
{
private static string $module_redir = '';
@ -69,14 +66,14 @@ class ManageLink extends Process
self::$linkauthor = $_POST['linkauthor'] ?? '';
self::$linkurl = $_POST['linkurl'] ?? '';
self::$linkcat = $_POST['linkcat'] ?? null;
self::$linklang = $_POST['linklang'] ?? dcCore::app()->auth->getInfo('user_lang');
self::$linklang = $_POST['linklang'] ?? App::auth()->getInfo('user_lang');
self::$linkimage = $_POST['linkimage'] ?? '';
self::$linknote = $_POST['linknote'] ?? '';
if (!empty($_POST['save'])) {
try {
Utils::makePublicDir(
DC_ROOT . '/' . dcCore::app()->blog->settings->system->get('public_path'),
App::config()->dotclearRoot() . '/' . App::blog()->settings()->system->get('public_path'),
My::settings()->folder
);
if (empty(self::$linktitle)) {
@ -89,7 +86,7 @@ class ManageLink extends Process
//throw new Exception(__('You must provide a link to an image.'));
}
$cur = dcCore::app()->con->openCursor($utils->table);
$cur = App::con()->openCursor($utils->table);
$cur->setField('link_title', self::$linktitle);
$cur->setField('link_desc', self::$linkdesc);
$cur->setField('link_author', self::$linkauthor);
@ -130,7 +127,7 @@ class ManageLink extends Process
]
);
} catch (Exception $e) {
dcCore::app()->error->add($e->getMessage());
App::error()->add($e->getMessage());
}
}
@ -147,7 +144,7 @@ class ManageLink extends Process
My::redirect(['part' => 'links']);
}
} catch (Exception $e) {
dcCore::app()->error->add($e->getMessage());
App::error()->add($e->getMessage());
}
}
@ -178,7 +175,7 @@ class ManageLink extends Process
Page::openModule(
My::name(),
Page::jsVars(['dotclear.c2_lang' => dcCore::app()->auth->getInfo('user_lang')]) .
Page::jsVars(['dotclear.c2_lang' => App::auth()->getInfo('user_lang')]) .
My::jsLoad('c2link')
);
@ -286,7 +283,7 @@ class ManageLink extends Process
->items([
(new Link())
->class('modal hidden-if-no-js')
->href(dcCore::app()->adminurl->get('admin.media', ['d' => (string) My::settings()->folder]))
->href(App::backend()->url()->get('admin.media', ['d' => (string) My::settings()->folder]))
->title(__('Media manager'))
->text(__('Go to media manager to add image to cinecturlink path.')),
]),

View File

@ -1,20 +1,10 @@
<?php
/**
* @brief cinecturlink2, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Jean-Christian Denis 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\cinecturlink2;
use dcCore;
use Dotclear\App;
use Dotclear\Core\Backend\Action\Actions;
use Dotclear\Core\Backend\Filter\{
Filters,
@ -39,6 +29,13 @@ use Dotclear\Helper\Html\Form\{
};
use Exception;
/**
* @brief cinecturlink2 manage links class.
* @ingroup cinecturlink2
*
* @author Jean-Christian Denis (author)
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
class ManageLinks extends Process
{
private static Actions $module_action;
@ -86,7 +83,7 @@ class ManageLinks extends Process
self::$module_counter = (int) $utils->getLinks($params, true)->f(0);
self::$module_listing = new BackendListingLinks($links, self::$module_counter);
} catch (Exception $e) {
dcCore::app()->error->add($e->getMessage());
App::error()->add($e->getMessage());
}
return true;

View File

@ -1,39 +1,52 @@
<?php
/**
* @brief cinecturlink2, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Jean-Christian Denis 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\cinecturlink2;
use dcCore;
use Dotclear\App;
use Dotclear\Module\MyPlugin;
/**
* @brief cinecturlink2 My helper.
* @ingroup cinecturlink2
*
* @author Jean-Christian Denis (author)
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
class My extends MyPlugin
{
public const CINECTURLINK_TABLE_NAME = \initCinecturlink2::CINECTURLINK_TABLE_NAME;
public const CATEGORY_TABLE_NAME = \initCinecturlink2::CATEGORY_TABLE_NAME;
/**
* Link table name.
*
* @var string CINECTURLINK_TABLE_NAME
*/
public const CINECTURLINK_TABLE_NAME = 'cinecturlink2';
/**
* Category table name.
*
* @var string CATEGORY_TABLE_NAME
*/
public const CATEGORY_TABLE_NAME = 'cinecturlink2_cat';
/**
* Allowed media extension.
*
* @var array<int, string> ALLOWED_MEDIA_EXTENSION
*/
public const ALLOWED_MEDIA_EXTENSION = ['png', 'jpg', 'gif', 'bmp', 'jpeg'];
public static function checkCustomContext(int $context): ?bool
{
if (in_array($context, [My::MENU, My::BACKEND])) {
return defined('DC_CONTEXT_ADMIN')
&& !is_null(dcCore::app()->blog)
&& dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([
dcCore::app()->auth::PERMISSION_CONTENT_ADMIN,
]), dcCore::app()->blog->id);
}
return match ($context) {
self::MENU, self::MANAGE, self::BACKEND => App::task()->checkContext('BACKEND')
&& App::blog()->isDefined()
&& App::auth()->check(App::auth()->makePermissions([
App::auth()::PERMISSION_CONTENT_ADMIN,
]), App::blog()->id()),
return null;
default => null,
};
}
}

View File

@ -1,22 +1,19 @@
<?php
/**
* @brief cinecturlink2, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Jean-Christian Denis 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\cinecturlink2;
use dcCore;
use Dotclear\App;
use Dotclear\Plugin\activityReport\ActivityReport;
/**
* @brief cinecturlink2 activityReport class.
* @ingroup cinecturlink2
*
* @author Jean-Christian Denis (author)
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
class PluginActivityReport
{
public static function add()
@ -30,7 +27,7 @@ class PluginActivityReport
__('link creation'),
__('A new cineturlink named "%s" was added by "%s"'),
'cinecturlink2AfterAddLink',
[self::class, 'addLink']
self::addLink(...)
);
// from BEHAVIOR cinecturlink2AfterUpdLink in cinecturlink2/inc/class.cinecturlink2.php
ActivityReport::instance()->addAction(
@ -39,7 +36,7 @@ class PluginActivityReport
__('updating link'),
__('Cinecturlink named "%s" has been updated by "%s"'),
'cinecturlink2AfterUpdLink',
[self::class, 'updLink']
self::updLink(...)
);
// from BEHAVIOR cinecturlink2BeforeDelLink in cinecturlink2/inc/class.cinecturlink2.php
ActivityReport::instance()->addAction(
@ -48,7 +45,7 @@ class PluginActivityReport
__('link deletion'),
__('Cinecturlink named "%s" has been deleted by "%s"'),
'cinecturlink2BeforeDelLink',
[self::class, 'delLink']
self::delLink(...)
);
}
@ -56,7 +53,7 @@ class PluginActivityReport
{
$logs = [
$cur->link_title,
dcCore::app()->auth->getInfo('user_cn'),
App::auth()->getInfo('user_cn'),
];
ActivityReport::instance()->addLog('cinecturlink2', 'create', $logs);
}
@ -68,7 +65,7 @@ class PluginActivityReport
$logs = [
$rs->link_title,
dcCore::app()->auth->getInfo('user_cn'),
App::auth()->getInfo('user_cn'),
];
ActivityReport::instance()->addLog('cinecturlink2', 'update', $logs);
}
@ -80,7 +77,7 @@ class PluginActivityReport
$logs = [
$rs->link_title,
dcCore::app()->auth->getInfo('user_cn'),
App::auth()->getInfo('user_cn'),
];
ActivityReport::instance()->addLog('cinecturlink2', 'delete', $logs);
}

View File

@ -1,21 +1,18 @@
<?php
/**
* @brief cinecturlink2, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Jean-Christian Denis 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\cinecturlink2;
use dcCore;
use Dotclear\App;
/**
* @brief cinecturlink2 sitemaps class.
* @ingroup cinecturlink2
*
* @author Jean-Christian Denis (author)
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
class PluginSitemaps
{
public static function sitemapsDefineParts($map_parts)
@ -25,19 +22,19 @@ class PluginSitemaps
public static function sitemapsURLsCollect($sitemaps)
{
if (dcCore::app()->plugins->moduleExists('cinecturlink2')
&& dcCore::app()->blog->settings->sitemaps->sitemaps_cinecturlink2_url
if (App::plugins()->moduleExists('cinecturlink2')
&& App::blog()->settings()->get('sitemaps')->get('sitemaps_cinecturlink2_url')
) {
$freq = $sitemaps->getFrequency(dcCore::app()->blog->settings->sitemaps->sitemaps_cinecturlink2_fq);
$prio = $sitemaps->getPriority(dcCore::app()->blog->settings->sitemaps->sitemaps_cinecturlink2_pr);
$base = dcCore::app()->blog->url . dcCore::app()->url->getBase('cinecturlink2');
$freq = $sitemaps->getFrequency(App::blog()->settings()->get('sitemaps')->get('sitemaps_cinecturlink2_fq'));
$prio = $sitemaps->getPriority(App::blog()->settings()->get('sitemaps')->get('sitemaps_cinecturlink2_pr'));
$base = App::blog()->url() . App::url()->getBase('cinecturlink2');
$sitemaps->addEntry($base, $prio, $freq);
$C2 = new Utils();
$cats = $C2->getCategories();
while ($cats->fetch()) {
$sitemaps->addEntry($base . '/' . dcCore::app()->blog->settings->cinecturlink2->public_caturl . '/' . urlencode($cats->cat_title), $prio, $freq);
$sitemaps->addEntry($base . '/' . My::settings()->get('public_caturl') . '/' . urlencode($cats->cat_title), $prio, $freq);
}
}
}

View File

@ -1,22 +1,19 @@
<?php
/**
* @brief cinecturlink2, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Jean-Christian Denis 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\cinecturlink2;
use dcCore;
use Dotclear\App;
use Dotclear\Core\Process;
/**
* @brief cinecturlink2 prepend class.
* @ingroup cinecturlink2
*
* @author Jean-Christian Denis (author)
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
class Prepend extends Process
{
public static function init(): bool
@ -30,16 +27,16 @@ class Prepend extends Process
return false;
}
dcCore::app()->url->register(
App::url()->register(
My::id(),
'cinecturlink',
'^cinecturlink(?:/(.+))?$',
[FrontendUrl::class, 'c2Page']
FrontendUrl::c2Page(...)
);
dcCore::app()->addBehaviors([
'sitemapsDefineParts' => [PluginSitemaps::class, 'sitemapsDefineParts'],
'sitemapsURLsCollect' => [PluginSitemaps::class, 'sitemapsURLsCollect'],
App::behavior()->addBehaviors([
'sitemapsDefineParts' => PluginSitemaps::sitemapsDefineParts(...),
'sitemapsURLsCollect' => PluginSitemaps::sitemapsURLsCollect(...),
]);
if (defined('ACTIVITY_REPORT_V2')) {

View File

@ -1,23 +1,19 @@
<?php
/**
* @brief cinecturlink2, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Jean-Christian Denis 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\cinecturlink2;
use dcCore;
use Dotclear\Core\Process;
use Dotclear\Plugin\Uninstaller\Uninstaller;
/**
* @brief cinecturlink2 uninstall class.
* @ingroup cinecturlink2
*
* @author Jean-Christian Denis (author)
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
class Uninstall extends Process
{
public static function init(): bool
@ -27,7 +23,7 @@ class Uninstall extends Process
public static function process(): bool
{
if (!self::status() || !dcCore::app()->plugins->moduleExists('Uninstaller')) {
if (!self::status()) {
return false;
}

View File

@ -1,21 +1,10 @@
<?php
/**
* @brief cinecturlink2, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Jean-Christian Denis 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\cinecturlink2;
use dcCore;
use dcAuth;
use Dotclear\App;
use Dotclear\Database\{
AbstractHandler,
Cursor,
@ -27,24 +16,46 @@ use Dotclear\Database\Statement\{
SelectStatement,
UpdateStatement
};
use Dotclear\Interface\Core\ConnectionInterface;
use Dotclear\Helper\File\Files;
use Dotclear\Helper\Text;
use Exception;
/**
* @ingroup DC_PLUGIN_CINECTURLINK2
* @brief Share media you like - main methods.
* @since 2.6
* @brief cinecturlink2 utils class.
* @ingroup cinecturlink2
*
* @author Jean-Christian Denis (author)
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
class Utils
{
/** @var AbstractHandler AbstractHandler instance */
/**
* Connection instance.
*
* @var ConnectionInterface $con
*/
public $con;
/** @var string Cinecturlink table name */
/**
* Cinecturlink table name (with prefix).
*
* @var string $table
*/
public $table;
/** @var string Cinecturlink category table name */
/**
* Cinecturlink category table name (with prefix)
*
* @var string $cat_table
*/
public $cat_table;
/** @var string Blog ID */
/**
* Current blog ID.
*
* @var string $blog
*/
public $blog;
/**
@ -52,10 +63,10 @@ class Utils
*/
public function __construct()
{
$this->con = dcCore::app()->con;
$this->table = dcCore::app()->prefix . My::CINECTURLINK_TABLE_NAME;
$this->cat_table = dcCore::app()->prefix . My::CATEGORY_TABLE_NAME;
$this->blog = (string) dcCore::app()->blog?->id;
$this->con = App::con();
$this->table = App::con()->prefix() . My::CINECTURLINK_TABLE_NAME;
$this->cat_table = App::con()->prefix() . My::CATEGORY_TABLE_NAME;
$this->blog = App::blog()->id();
}
/**
@ -106,7 +117,7 @@ class Utils
->join(
(new JoinStatement())
->inner()
->from($sql->as(dcCore::app()->prefix . dcAuth::USER_TABLE_NAME, 'U'))
->from($sql->as(App::con()->prefix() . App::auth()::USER_TABLE_NAME, 'U'))
->on('U.user_id = L.user_id')
->statement()
)
@ -126,7 +137,7 @@ class Utils
$sql->from($params['from']);
}
$sql->where('L.blog_id = ' . $sql->quote(dcCore::app()->blog->id));
$sql->where('L.blog_id = ' . $sql->quote($this->blog));
if (isset($params['link_type'])) {
if (is_array($params['link_type']) && !empty($params['link_type'])) {
@ -227,7 +238,7 @@ class Utils
$cur->link_id = $this->getNextLinkId();
$cur->blog_id = $this->blog;
$cur->user_id = dcCore::app()->auth->userID();
$cur->user_id = App::auth()->userID();
$cur->link_creadt = date('Y-m-d H:i:s');
$cur->link_upddt = date('Y-m-d H:i:s');
$cur->link_pos = 0;
@ -242,7 +253,7 @@ class Utils
$this->trigger();
# --BEHAVIOR-- cinecturlink2AfterAddLink
dcCore::app()->callBehavior('cinecturlink2AfterAddLink', $cur);
App::behavior()->callBehavior('cinecturlink2AfterAddLink', $cur);
return (int) $cur->link_id;
}
@ -270,7 +281,7 @@ class Utils
if ($behavior) {
# --BEHAVIOR-- cinecturlink2AfterUpdLink
dcCore::app()->callBehavior('cinecturlink2AfterUpdLink', $cur, $id);
App::behavior()->callBehavior('cinecturlink2AfterUpdLink', $cur, $id);
}
}
@ -286,7 +297,7 @@ class Utils
}
# --BEHAVIOR-- cinecturlink2BeforeDelLink
dcCore::app()->callBehavior('cinecturlink2BeforeDelLink', $id);
App::behavior()->callBehavior('cinecturlink2BeforeDelLink', $id);
$sql = new DeleteStatement();
$sql
@ -348,7 +359,7 @@ class Utils
$sql->from($params['from']);
}
$sql->where('C.blog_id = ' . $sql->quote(dcCore::app()->blog->id));
$sql->where('C.blog_id = ' . $sql->quote($this->blog));
if (!empty($params['cat_id'])) {
if (is_array($params['cat_id'])) {
@ -528,7 +539,7 @@ class Utils
*/
private function trigger(): void
{
dcCore::app()->blog->triggerBlog();
App::blog()->triggerBlog();
}
/**
@ -563,9 +574,9 @@ class Utils
public static function getPublicDirs(): array
{
$dirs = [];
$all = Files::getDirList(dcCore::app()->blog->public_path);
$all = Files::getDirList(App::blog()->publicPath());
foreach ($all['dirs'] as $dir) {
$dir = substr($dir, strlen(dcCore::app()->blog->public_path) + 1);
$dir = substr($dir, strlen(App::blog()->publicPath()) + 1);
$dirs[$dir] = $dir;
}

View File

@ -1,27 +1,24 @@
<?php
/**
* @brief cinecturlink2, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Jean-Christian Denis 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\cinecturlink2;
use dcCore;
use Dotclear\App;
use Dotclear\Helper\Html\Html;
use Dotclear\Plugin\widgets\WidgetsStack;
use Dotclear\Plugin\widgets\WidgetsElement;
/**
* @brief cinecturlink2 widgets class.
* @ingroup cinecturlink2
*
* @author Jean-Christian Denis (author)
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
class Widgets
{
public static function initLinks(WidgetsStack $w): void
public static function init(WidgetsStack $w): void
{
$categories_combo = array_merge(
Combo::categoriesCombo(),
@ -44,7 +41,7 @@ class Widgets
->create(
'cinecturlink2links',
__('My cinecturlink'),
[self::class, 'parseLinks'],
self::parseLinks(...),
null,
__('Show selection of cinecturlinks')
)
@ -112,15 +109,12 @@ class Widgets
->addContentOnly()
->addClass()
->addOffline();
}
public static function initCats(WidgetsStack $w): void
{
$w
->create(
'cinecturlink2cats',
__('List of categories of cinecturlink'),
[self::class, 'parseCats'],
self::parseCats(...),
null,
__('List of categories of cinecturlink')
)
@ -148,7 +142,7 @@ class Widgets
public static function parseLinks(WidgetsElement $w): string
{
if (!My::settings()->avtive
|| !$w->checkHomeOnly(dcCore::app()->url->type)
|| !$w->checkHomeOnly(App::url()->type)
) {
return '';
}
@ -216,7 +210,7 @@ class Widgets
$count = abs((int) $rs->link_count);
# --BEHAVIOR-- cinecturlink2WidgetLinks
$bhv = dcCore::app()->callBehavior('cinecturlink2WidgetLinks', $rs->link_id);
$bhv = App::behavior()->callBehavior('cinecturlink2WidgetLinks', $rs->link_id);
$entries[] = '<p style="text-align:center;">' .
($w->withlink && !empty($url) ? '<a href="' . $url . '"' . $lang . ' title="' . $cat . '">' : '') .
@ -228,7 +222,7 @@ class Widgets
'</p>' . $bhv;
try {
$cur = dcCore::app()->con->openCursor($C2->table);
$cur = App::con()->openCursor($C2->table);
$cur->link_count = ($count + 1);
$C2->updLink((int) $rs->link_id, $cur, false);
} catch (Exception $e) {
@ -240,7 +234,7 @@ class Widgets
) {
shuffle($entries);
if (My::settings()->triggeronrandom) {
dcCore::app()->blog->triggerBlog();
App::blog()->triggerBlog();
}
}
@ -251,7 +245,7 @@ class Widgets
($w->title ? $w->renderTitle(Html::escapeHTML($w->title)) : '') . implode(' ', $entries) .
(
$w->showpagelink && My::settings()->public_active ?
'<p><a href="' . dcCore::app()->blog->url . dcCore::app()->url->getBase(My::id()) . '" title="' . __('view all links') . '">' . __('More links') . '</a></p>' : ''
'<p><a href="' . App::blog()->url() . App::url()->getBase(My::id()) . '" title="' . __('view all links') . '">' . __('More links') . '</a></p>' : ''
)
);
}
@ -260,7 +254,7 @@ class Widgets
{
if (!My::settings()->avtive
|| !My::settings()->public_active
|| !$w->checkHomeOnly(dcCore::app()->url->type)
|| !$w->checkHomeOnly(App::url()->type)
) {
return '';
}
@ -273,14 +267,14 @@ class Widgets
$res = [];
$res[] = '<li><a href="' .
dcCore::app()->blog->url . dcCore::app()->url->getBase(My::id()) .
App::blog()->url() . App::url()->getBase(My::id()) .
'" title="' . __('view all links') . '">' . __('all links') .
'</a>' . ($w->shownumlink ? ' (' . ($C2->getLinks([], true)->f(0)) . ')' : '') .
'</li>';
while ($rs->fetch()) {
$res[] = '<li><a href="' .
dcCore::app()->blog->url . dcCore::app()->url->getBase('cinecturlink2') . '/' .
App::blog()->url() . App::url()->getBase('cinecturlink2') . '/' .
My::settings()->public_caturl . '/' .
urlencode($rs->cat_title) .
'" title="' . __('view links of this category') . '">' .