Compare commits

..

No commits in common. "master" and "v2.1" have entirely different histories.
master ... v2.1

28 changed files with 391 additions and 749 deletions

View File

@ -1,23 +1,3 @@
cinecturlink2 2.3.1 - 2023.11.04
===========================================================
* Require Dotclear 2.28
* Require PHP 8.1
* Use last minute changes from Dotclear 2.28
cinecturlink2 2.3 - 2023.10.23
===========================================================
* Require Dotclear 2.28
* Require PHP 8.1
* Use specific class for records
* Use specific class for widgets
* Code review (phpstan)
cinecturlink2 2.2 - 2023.10.18
===========================================================
* Require Dotclear 2.28
* Require PHP 8.1
* Upgrade plugin activityReport
cinecturlink2 2.1 - 2023.10.15 cinecturlink2 2.1 - 2023.10.15
=========================================================== ===========================================================
* Require Dotclear 2.28 * Require Dotclear 2.28

View File

@ -1,8 +1,8 @@
# README # README
[![Release](https://img.shields.io/badge/release-2.3.1-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/cinecturlink2/releases) [![Release](https://img.shields.io/badge/release-2.0-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/cinecturlink2/releases)
![Date](https://img.shields.io/badge/date-2023.11.04-c44d58.svg)] ![Date](https://img.shields.io/badge/date-2023.08.24-c44d58.svg)]
[![Dotclear](https://img.shields.io/badge/dotclear-v2.28-137bbb.svg)](https://fr.dotclear.org/download) [![Dotclear](https://img.shields.io/badge/dotclear-v2.27-137bbb.svg)](https://fr.dotclear.org/download)
[![Dotaddict](https://img.shields.io/badge/dotaddict-official-9ac123.svg)](https://plugins.dotaddict.org/dc2/details/cinecturlink2) [![Dotaddict](https://img.shields.io/badge/dotaddict-official-9ac123.svg)](https://plugins.dotaddict.org/dc2/details/cinecturlink2)
[![License](https://img.shields.io/badge/license-GPL--2.0-ececec.svg)](https://git.dotclear.watch/JcDenis/cinecturlink2/src/branch/master/LICENSE) [![License](https://img.shields.io/badge/license-GPL--2.0-ececec.svg)](https://git.dotclear.watch/JcDenis/cinecturlink2/src/branch/master/LICENSE)

View File

@ -21,7 +21,7 @@ $this->registerModule(
'Cinecturlink 2', 'Cinecturlink 2',
'Widgets and pages about books, musics, films, blogs you are interested in', 'Widgets and pages about books, musics, films, blogs you are interested in',
'Jean-Christian Denis and Contributors', 'Jean-Christian Denis and Contributors',
'2.3.1', '2.1',
[ [
'requires' => [['core', '2.28']], 'requires' => [['core', '2.28']],
'settings' => ['blog' => '#params.' . basename(__DIR__) . '_params'], 'settings' => ['blog' => '#params.' . basename(__DIR__) . '_params'],

View File

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

View File

@ -1,103 +0,0 @@
<?php
declare(strict_types=1);
namespace Dotclear\Plugin\cinecturlink2;
use Dotclear\App;
use Dotclear\Core\Process;
use Dotclear\Database\Cursor;
use Dotclear\Plugin\activityReport\{
Action,
ActivityReport,
Group
};
/**
* @brief cinecturlink2 plugin activityReport class.
* @ingroup cinecturlink2
*
* @author Jean-Christian Denis (author)
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
class ActivityReportAction extends Process
{
private const CINECTURLINK_CREATE = 'cinecturlink2Create';
private const CINECTURLINK_UPDATE = 'cinecturlink2Update';
private const CINECTURLINK_DELETE = 'cinecturlink2Delete';
public static function init(): bool
{
return self::status(true);
}
public static function process(): bool
{
if (!self::status()) {
return false;
}
$group = new Group(My::id(), My::name());
// from BEHAVIOR cinecturlink2AfterAddLink in cinecturlink2/inc/class.cinecturlink2.php
$group->add(new Action(
self::CINECTURLINK_CREATE,
__('link creation'),
__('A new cineturlink named "%s" was added by "%s"'),
'cinecturlink2AfterAddLink',
self::addLink(...)
));
// from BEHAVIOR cinecturlink2AfterUpdLink in cinecturlink2/inc/class.cinecturlink2.php
$group->add(new Action(
self::CINECTURLINK_UPDATE,
__('updating link'),
__('Cinecturlink named "%s" has been updated by "%s"'),
'cinecturlink2AfterUpdLink',
self::updLink(...)
));
// from BEHAVIOR cinecturlink2BeforeDelLink in cinecturlink2/inc/class.cinecturlink2.php
$group->add(new Action(
self::CINECTURLINK_DELETE,
__('link deletion'),
__('Cinecturlink named "%s" has been deleted by "%s"'),
'cinecturlink2BeforeDelLink',
self::delLink(...)
));
ActivityReport::instance()->groups->add($group);
return true;
}
public static function addLink(Cursor $cur): void
{
self::addLog(
self::CINECTURLINK_CREATE,
(string) $cur->getField('link_title')
);
}
public static function updLink(Cursor $cur, int $id): void
{
self::addLog(
self::CINECTURLINK_UPDATE,
(string) (new Utils())->getLinks(['link_id' => $id])->field('link_title')
);
}
public static function delLink(int $id): void
{
self::addLog(
self::CINECTURLINK_DELETE,
(string) (new Utils())->getLinks(['link_id' => $id])->field('link_title')
);
}
private static function addLog(string $action, string $title)
{
ActivityReport::instance()->addLog(My::id(), $action, [
$title,
(string) App::auth()->getInfo('user_cn'),
]);
}
}

View File

@ -6,6 +6,7 @@ namespace Dotclear\Plugin\cinecturlink2;
use ArrayObject; use ArrayObject;
use Dotclear\App; use Dotclear\App;
use Dotclear\Core\BlogSettings;
use Dotclear\Core\Backend\Favorites; use Dotclear\Core\Backend\Favorites;
use Dotclear\Core\Process; use Dotclear\Core\Process;
use Dotclear\Helper\Html\Form\{ use Dotclear\Helper\Html\Form\{
@ -20,7 +21,6 @@ use Dotclear\Helper\Html\Form\{
Text Text
}; };
use Dotclear\Helper\File\Files; use Dotclear\Helper\File\Files;
use Dotclear\Interface\Core\BlogSettingsInterface;
/** /**
* @brief cinecturlink2 backend class. * @brief cinecturlink2 backend class.
@ -88,7 +88,7 @@ class Backend extends Process
]); ]);
}, },
'adminBlogPreferencesFormV2' => function (BlogSettingsInterface $blog_settings): void { 'adminBlogPreferencesFormV2' => function (BlogSettings $blog_settings): void {
$s = $blog_settings->get(My::id()); $s = $blog_settings->get(My::id());
$url = App::blog()->url() . App::url()->getBase(My::id()); $url = App::blog()->url() . App::url()->getBase(My::id());
$public_nbrpp = (int) $s->get('public_nbrpp'); $public_nbrpp = (int) $s->get('public_nbrpp');
@ -124,7 +124,7 @@ class Backend extends Process
->for(My::id() . 'newdir'), ->for(My::id() . 'newdir'),
(new Input(My::id() . 'newdir')) (new Input(My::id() . 'newdir'))
->size(65) ->size(65)
->maxlength(255) ->maxlenght(255)
->value(''), ->value(''),
]), ]),
(new Para()) (new Para())
@ -171,7 +171,7 @@ class Backend extends Process
->for(My::id() . 'public_title'), ->for(My::id() . 'public_title'),
(new Input(My::id() . 'public_title')) (new Input(My::id() . 'public_title'))
->size(65) ->size(65)
->maxlength(255) ->maxlenght(255)
->value((string) $s->get('public_title')), ->value((string) $s->get('public_title')),
]), ]),
(new Para()) (new Para())
@ -180,7 +180,7 @@ class Backend extends Process
->for(My::id() . 'public_description'), ->for(My::id() . 'public_description'),
(new Input(My::id() . 'public_description')) (new Input(My::id() . 'public_description'))
->size(65) ->size(65)
->maxlength(255) ->maxlenght(255)
->value((string) $s->get('public_description')), ->value((string) $s->get('public_description')),
]), ]),
(new Para()) (new Para())
@ -197,7 +197,7 @@ class Backend extends Process
->render(); ->render();
}, },
'adminBeforeBlogSettingsUpdate' => function (BlogSettingsInterface $blog_settings): void { 'adminBeforeBlogSettingsUpdate' => function (BlogSettings $blog_settings): void {
$s = $blog_settings->get(My::id()); $s = $blog_settings->get(My::id());
$active = !empty($_POST[My::id() . 'active']); $active = !empty($_POST[My::id() . 'active']);
$widthmax = abs((int) $_POST[My::id() . 'widthmax']); $widthmax = abs((int) $_POST[My::id() . 'widthmax']);

View File

@ -27,12 +27,6 @@ class BackendActionsLinks extends Actions
protected bool $use_render = true; protected bool $use_render = true;
public Utils $utils; public Utils $utils;
/**
* Constructs a new instance.
*
* @param string $uri The form uri
* @param array<string, string> $redirect_args The redirection $_GET arguments,
*/
public function __construct(string $uri, array $redirect_args = []) public function __construct(string $uri, array $redirect_args = [])
{ {
$this->utils = new Utils(); $this->utils = new Utils();
@ -98,7 +92,7 @@ class BackendActionsLinks extends Actions
$rs = $this->utils->getLinks($params); $rs = $this->utils->getLinks($params);
while ($rs->fetch()) { while ($rs->fetch()) {
$this->entries[(string) $rs->f('link_id')] = $rs->f('link_title'); $this->entries[$rs->f('link_id')] = $rs->f('link_title');
} }
$this->rs = $rs; $this->rs = $rs;
} else { } else {

View File

@ -46,9 +46,6 @@ class BackendActionsLinksDefault
); );
} }
/**
* @param ArrayObject<string, int|string> $post
*/
public static function doDeleteLinks(BackendActionsLinks $ap, ArrayObject $post): void public static function doDeleteLinks(BackendActionsLinks $ap, ArrayObject $post): void
{ {
$ids = $ap->getIDs(); $ids = $ap->getIDs();
@ -60,7 +57,7 @@ class BackendActionsLinksDefault
} }
foreach ($ids as $id) { foreach ($ids as $id) {
$ap->utils->delLink((int) $id); $ap->utils->delLink($id);
} }
Notices::addSuccessNotice(sprintf( Notices::addSuccessNotice(sprintf(
@ -74,9 +71,6 @@ class BackendActionsLinksDefault
$ap->redirect(true); $ap->redirect(true);
} }
/**
* @param ArrayObject<string, int|string> $post
*/
public static function doChangeCategory(BackendActionsLinks $ap, ArrayObject $post): void public static function doChangeCategory(BackendActionsLinks $ap, ArrayObject $post): void
{ {
if (isset($post['upd_cat_id'])) { if (isset($post['upd_cat_id'])) {
@ -94,7 +88,7 @@ class BackendActionsLinksDefault
foreach ($ids as $id) { foreach ($ids as $id) {
$cur->clean(); $cur->clean();
$cur->setField('cat_id', $cat_id == 0 ? null : $cat_id); $cur->setField('cat_id', $cat_id == 0 ? null : $cat_id);
$ap->utils->updLink((int) $id, $cur); $ap->utils->updLink($id, $cur);
} }
Notices::addSuccessNotice(sprintf( Notices::addSuccessNotice(sprintf(
@ -139,9 +133,6 @@ class BackendActionsLinksDefault
} }
} }
/**
* @param ArrayObject<string, int|string> $post
*/
public static function doChangeNote(BackendActionsLinks $ap, ArrayObject $post): void public static function doChangeNote(BackendActionsLinks $ap, ArrayObject $post): void
{ {
if (isset($post['upd_link_note'])) { if (isset($post['upd_link_note'])) {
@ -162,7 +153,7 @@ class BackendActionsLinksDefault
foreach ($ids as $id) { foreach ($ids as $id) {
$cur->clean(); $cur->clean();
$cur->setField('link_note', $link_note); $cur->setField('link_note', $link_note);
$ap->utils->updLink((int) $id, $cur); $ap->utils->updLink($id, $cur);
} }
Notices::addSuccessNotice(sprintf( Notices::addSuccessNotice(sprintf(

View File

@ -84,7 +84,7 @@ class BackendListingLinks extends Listing
$lines = []; $lines = [];
while ($this->rs->fetch()) { while ($this->rs->fetch()) {
$lines[] = $this->linkLine(new RecordLinksRow($this->rs), isset($links[$this->rs->f('link_id')])); $lines[] = $this->linkLine(isset($links[$this->rs->link_id]));
} }
echo echo
@ -112,60 +112,60 @@ class BackendListingLinks extends Listing
$pager->getLinks(); $pager->getLinks();
} }
private function linkLine(RecordLinksRow $row, bool $checked): Para private function linkLine(bool $checked): Para
{ {
$cols = new ArrayObject([ $cols = new ArrayObject([
'check' => (new Td()) 'check' => (new Td())
->class('nowrap minimal') ->class('nowrap minimal')
->items([ ->items([
(new Checkbox(['entries[]'], $checked)) (new Checkbox(['entries[]'], $checked))
->value((string) $row->link_id), ->value($this->rs->link_id),
]), ]),
'title' => (new Td()) 'title' => (new Td())
->class('maximal') ->class('maximal')
->items([ ->items([
(new Link()) (new Link())
->href(My::manageUrl(['part' => 'link', 'link_id' => $row->link_id, 'redir' => $this->redir])) ->href(My::manageUrl(['part' => 'link', 'linkid' => $this->rs->link_id, 'redir' => $this->redir]))
->title(__('Edit')) ->title(__('Edit'))
->text(Html::escapeHTML($row->link_title)), ->text(Html::escapeHTML($this->rs->link_title)),
]), ]),
'author' => (new Td()) 'author' => (new Td())
->text(Html::escapeHTML($row->link_author)) ->text(Html::escapeHTML($this->rs->link_author))
->class('nowrap'), ->class('nowrap'),
'desc' => (new Td()) 'desc' => (new Td())
->text(Html::escapeHTML($row->link_desc)) ->text(Html::escapeHTML($this->rs->link_desc))
->class('nowrap'), ->class('nowrap'),
'link' => (new Td()) 'link' => (new Text('td'))
->separator(' ') ->separator(' ')
->items([ ->items([
(new Link()) (new Link())
->href($row->link_url) ->href($this->rs->link_url)
->title(__('URL')) ->title(__('URL'))
->text(Html::escapeHTML($row->link_title)), ->text(Html::escapeHTML($this->rs->link_title)),
(new Link()) (new Link())
->href($row->link_img) ->href($this->rs->link_img)
->title(__('image')) ->title(__('image'))
->text(Html::escapeHTML($row->link_title)), ->text(Html::escapeHTML($this->rs->link_title)),
]) ]),
->class('nowrap'),
'cat' => (new Td()) 'cat' => (new Td())
->items([ ->items([
(new Link()) (new Link())
->href(My::manageUrl(['part' => 'cat', 'cat_id' => (string) $row->cat_id, 'redir' => $this->redir])) ->href(My::manageUrl(['part' => 'cat', 'catid' => $this->rs->cat_id, 'redir' => $this->redir]))
->title(__('Edit')) ->title(__('Edit'))
->text(Html::escapeHTML($row->cat_title)), ->text(Html::escapeHTML($this->rs->cat_title)),
]), ]),
'note' => (new Td()) 'note' => (new Td())
->text(Html::escapeHTML($row->link_note)) ->text(Html::escapeHTML($this->rs->link_note))
->class('number'), ->class('number'),
'date' => (new Td()) 'date' => (new Td())
->text(Html::escapeHTML(Date::dt2str(__('%Y-%m-%d %H:%M'), $row->link_upddt, (string) 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'), ->class('nowrap'),
]); ]);
$this->userColumns(My::id(), $cols); $this->userColumns(My::id(), $cols);
return (new Para('p' . $row->link_id, 'tr')) return
(new Para('p' . $this->rs->kut_id, 'tr'))
->class('line') ->class('line')
->items(iterator_to_array($cols)); ->items(iterator_to_array($cols));
} }

View File

@ -69,7 +69,7 @@ class Combo
if (!in_array($file->extension, My::ALLOWED_MEDIA_EXTENSION)) { if (!in_array($file->extension, My::ALLOWED_MEDIA_EXTENSION)) {
continue; continue;
} }
$tmp[(string) $file->media_title] = (string) $file->file_url; $tmp[$file->media_title] = $file->file_url;
} }
if (!empty($tmp)) { if (!empty($tmp)) {
$stack = array_merge(['-' => ''], $tmp); $stack = array_merge(['-' => ''], $tmp);

View File

@ -96,6 +96,7 @@ class Frontend extends Process
} }
} else { } else {
foreach (array_merge($blocks, $values) as $v) { foreach (array_merge($blocks, $values) as $v) {
pdump($v);
App::frontend()->template()->addBlock($v, FrontendTemplate::disable(...)); App::frontend()->template()->addBlock($v, FrontendTemplate::disable(...));
} }
} }

View File

@ -15,26 +15,26 @@ use Dotclear\App;
*/ */
class FrontendContext class FrontendContext
{ {
public static function PaginationNbPages(): int public static function PaginationNbPages()
{ {
if (App::frontend()->context()->c2_pagination === null) { if (App::frontend()->context()->c2_pagination === null) {
return 0; return false;
} }
$nb_posts = App::frontend()->context()->c2_pagination->f(0); $nb_posts = App::frontend()->context()->c2_pagination->f(0);
$nb_per_page = App::frontend()->context()->c2_params['limit'][1]; $nb_per_page = App::frontend()->context()->c2_params['limit'][1];
$nb_pages = ceil($nb_posts / $nb_per_page); $nb_pages = ceil($nb_posts / $nb_per_page);
return (int) $nb_pages; return $nb_pages;
} }
public static function PaginationPosition(string|int $offset = 0): int public static function PaginationPosition($offset = 0)
{ {
if (isset($GLOBALS['c2_page_number'])) { if (isset($GLOBALS['c2_page_number'])) {
$p = $GLOBALS['c2_page_number']; $p = $GLOBALS['c2_page_number'];
} else { } else {
$p = 1; $p = 1;
} }
$p = (int) $p + (int) $offset; $p = $p + $offset;
$n = self::PaginationNbPages(); $n = self::PaginationNbPages();
if (!$n) { if (!$n) {
return $p; return $p;
@ -43,17 +43,25 @@ class FrontendContext
return $p > $n || $p <= 0 ? 1 : $p; return $p > $n || $p <= 0 ? 1 : $p;
} }
public static function PaginationStart(): bool public static function PaginationStart()
{ {
return isset($GLOBALS['c2_page_number']) ? self::PaginationPosition() == 1 : true; if (isset($GLOBALS['c2_page_number'])) {
return self::PaginationPosition() == 1;
} }
public static function PaginationEnd(): bool return true;
{
return isset($GLOBALS['c2_page_number']) ? self::PaginationPosition() == self::PaginationNbPages() : false;
} }
public static function PaginationURL(int|string $offset = 0): string public static function PaginationEnd()
{
if (isset($GLOBALS['c2_page_number'])) {
return self::PaginationPosition() == self::PaginationNbPages();
}
return false;
}
public static function PaginationURL($offset = 0)
{ {
$args = $_SERVER['URL_REQUEST_PART']; $args = $_SERVER['URL_REQUEST_PART'];
@ -76,7 +84,7 @@ class FrontendContext
return $url; return $url;
} }
public static function categoryCurrent(): bool public static function categoryCurrent()
{ {
if (!isset(App::frontend()->context()->c2_page_params['cat_id']) if (!isset(App::frontend()->context()->c2_page_params['cat_id'])
&& !isset(App::frontend()->context()->c2_page_params['cat_title']) && !isset(App::frontend()->context()->c2_page_params['cat_title'])

View File

@ -18,57 +18,36 @@ use Dotclear\Helper\Html\Html;
*/ */
class FrontendTemplate class FrontendTemplate
{ {
/**
* @param ArrayObject<string, mixed> $a The attributes
*/
public static function disable(ArrayObject $a, ?string $c = null): string public static function disable(ArrayObject $a, ?string $c = null): string
{ {
return ''; return '';
} }
/**
* @param ArrayObject<string, mixed> $a The attributes
*/
public static function c2PageURL(ArrayObject $a): string public static function c2PageURL(ArrayObject $a): string
{ {
return '<?php echo ' . sprintf(App::frontend()->template()->getFilters($a), 'App::blog()->url().App::url()->getBase(\'cinecturlink2\')') . '; ?>'; return '<?php echo ' . sprintf(App::frontend()->template()->getFilters($a), 'App::blog()->url().App::url()->getBase(\'cinecturlink2\')') . '; ?>';
} }
/**
* @param ArrayObject<string, mixed> $a The attributes
*/
public static function c2PageTitle(ArrayObject $a): string public static function c2PageTitle(ArrayObject $a): string
{ {
return "<?php \$title = (string) App::blog()->settings()->cinecturlink2->public_title; if (empty(\$title)) { \$title = __('My cinecturlink'); } echo " . sprintf(App::frontend()->template()->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') . '; ?>';
} }
/**
* @param ArrayObject<string, mixed> $a The attributes
*/
public static function c2PageFeedURL(ArrayObject $a): string public static function c2PageFeedURL(ArrayObject $a): string
{ {
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') . '"') . '; ?>'; 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') . '"') . '; ?>';
} }
/**
* @param ArrayObject<string, mixed> $a The attributes
*/
public static function c2PageFeedID(ArrayObject $a): string public static function c2PageFeedID(ArrayObject $a): string
{ {
return 'urn:md5:<?php echo md5(App::blog()->id()."' . My::id() . '"); ?>'; return 'urn:md5:<?php echo md5(App::blog()->id()."' . My::id() . '"); ?>';
} }
/**
* @param ArrayObject<string, mixed> $a The attributes
*/
public static function c2PageDescription(ArrayObject $a): string public static function c2PageDescription(ArrayObject $a): string
{ {
return '<?php $description = (string) App::blog()->settings()->cinecturlink2->public_description; echo ' . sprintf(App::frontend()->template()->getFilters($a), '$description') . '; ?>'; return '<?php $description = (string) App::blog()->settings()->cinecturlink2->public_description; echo ' . sprintf(App::frontend()->template()->getFilters($a), '$description') . '; ?>';
} }
/**
* @param ArrayObject<string, mixed> $a The attributes
*/
public static function c2If(ArrayObject $a, string $c): string public static function c2If(ArrayObject $a, string $c): string
{ {
$if = []; $if = [];
@ -88,9 +67,6 @@ class FrontendTemplate
return empty($if) ? $c : '<?php if(' . implode(' ' . $operator . ' ', $if) . ") : ?>\n" . $c . "<?php endif; ?>\n"; return empty($if) ? $c : '<?php if(' . implode(' ' . $operator . ' ', $if) . ") : ?>\n" . $c . "<?php endif; ?>\n";
} }
/**
* @param ArrayObject<string, mixed> $a The attributes
*/
public static function c2Entries(ArrayObject $a, string $c): string public static function c2Entries(ArrayObject $a, string $c): string
{ {
$lastn = isset($a['lastn']) ? abs((int) $a['lastn']) + 0 : -1; $lastn = isset($a['lastn']) ? abs((int) $a['lastn']) + 0 : -1;
@ -137,25 +113,16 @@ class FrontendTemplate
"?>\n"; "?>\n";
} }
/**
* @param ArrayObject<string, mixed> $a The attributes
*/
public static function c2EntriesHeader(ArrayObject $a, string $c): string public static function c2EntriesHeader(ArrayObject $a, string $c): string
{ {
return '<?php if (App::frontend()->context()->c2_entries->isStart()) : ?>' . $c . '<?php endif; ?>'; return '<?php if (App::frontend()->context()->c2_entries->isStart()) : ?>' . $c . '<?php endif; ?>';
} }
/**
* @param ArrayObject<string, mixed> $a The attributes
*/
public static function c2EntriesFooter(ArrayObject $a, string $c): string public static function c2EntriesFooter(ArrayObject $a, string $c): string
{ {
return '<?php if (App::frontend()->context()->c2_entries->isEnd()) : ?>' . $c . '<?php endif; ?>'; return '<?php if (App::frontend()->context()->c2_entries->isEnd()) : ?>' . $c . '<?php endif; ?>';
} }
/**
* @param ArrayObject<string, mixed> $a The attributes
*/
public static function c2EntryIf(ArrayObject $a, string $c): string public static function c2EntryIf(ArrayObject $a, string $c): string
{ {
$if = []; $if = [];
@ -170,153 +137,96 @@ class FrontendTemplate
return empty($if) ? $c : '<?php if(' . implode(' ' . $operator . ' ', $if) . ") : ?>\n" . $c . "<?php endif; ?>\n"; return empty($if) ? $c : '<?php if(' . implode(' ' . $operator . ' ', $if) . ") : ?>\n" . $c . "<?php endif; ?>\n";
} }
/**
* @param ArrayObject<string, mixed> $a The attributes
*/
public static function c2EntryIfFirst(ArrayObject $a): string public static function c2EntryIfFirst(ArrayObject $a): string
{ {
return '<?php if (App::frontend()->context()->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') . '"; } ?>';
} }
/**
* @param ArrayObject<string, mixed> $a The attributes
*/
public static function c2EntryIfOdd(ArrayObject $a): string public static function c2EntryIfOdd(ArrayObject $a): string
{ {
return '<?php if ((App::frontend()->context()->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') . '"; } ?>';
} }
/**
* @param ArrayObject<string, mixed> $a The attributes
*/
public static function c2EntryFeedID(ArrayObject $a): string public static function c2EntryFeedID(ArrayObject $a): string
{ {
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); ?>'; 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); ?>';
} }
/**
* @param ArrayObject<string, mixed> $a The attributes
*/
public static function c2EntryID(ArrayObject $a): string public static function c2EntryID(ArrayObject $a): string
{ {
return self::getGenericValue('App::frontend()->context()->c2_entries->link_id', $a); return self::getGenericValue('App::frontend()->context()->c2_entries->link_id', $a);
} }
/**
* @param ArrayObject<string, mixed> $a The attributes
*/
public static function c2EntryTitle(ArrayObject $a): string public static function c2EntryTitle(ArrayObject $a): string
{ {
return self::getGenericValue('App::frontend()->context()->c2_entries->link_title', $a); return self::getGenericValue('App::frontend()->context()->c2_entries->link_title', $a);
} }
/**
* @param ArrayObject<string, mixed> $a The attributes
*/
public static function c2EntryDescription(ArrayObject $a): string public static function c2EntryDescription(ArrayObject $a): string
{ {
return self::getGenericValue('App::frontend()->context()->c2_entries->link_desc', $a); return self::getGenericValue('App::frontend()->context()->c2_entries->link_desc', $a);
} }
/**
* @param ArrayObject<string, mixed> $a The attributes
*/
public static function c2EntryAuthorCommonName(ArrayObject $a): string public static function c2EntryAuthorCommonName(ArrayObject $a): string
{ {
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); 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);
} }
/**
* @param ArrayObject<string, mixed> $a The attributes
*/
public static function c2EntryAuthorDisplayName(ArrayObject $a): string public static function c2EntryAuthorDisplayName(ArrayObject $a): string
{ {
return self::getGenericValue('App::frontend()->context()->c2_entries->user_displayname', $a); return self::getGenericValue('App::frontend()->context()->c2_entries->user_displayname', $a);
} }
/**
* @param ArrayObject<string, mixed> $a The attributes
*/
public static function c2EntryAuthorID(ArrayObject $a): string public static function c2EntryAuthorID(ArrayObject $a): string
{ {
return self::getGenericValue('App::frontend()->context()->c2_entries->user_id', $a); return self::getGenericValue('App::frontend()->context()->c2_entries->user_id', $a);
} }
/**
* @param ArrayObject<string, mixed> $a The attributes
*/
public static function c2EntryAuthorEmail(ArrayObject $a): string public static function c2EntryAuthorEmail(ArrayObject $a): string
{ {
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); 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);
} }
/**
* @param ArrayObject<string, mixed> $a The attributes
*/
public static function c2EntryAuthorLink(ArrayObject $a): string public static function c2EntryAuthorLink(ArrayObject $a): string
{ {
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); 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);
} }
/**
* @param ArrayObject<string, mixed> $a The attributes
*/
public static function c2EntryAuthorURL(ArrayObject $a): string public static function c2EntryAuthorURL(ArrayObject $a): string
{ {
return self::getGenericValue('App::frontend()->context()->c2_entries->user_url', $a); return self::getGenericValue('App::frontend()->context()->c2_entries->user_url', $a);
} }
/**
* @param ArrayObject<string, mixed> $a The attributes
*/
public static function c2EntryFromAuthor(ArrayObject $a): string public static function c2EntryFromAuthor(ArrayObject $a): string
{ {
return self::getGenericValue('App::frontend()->context()->c2_entries->link_author', $a); return self::getGenericValue('App::frontend()->context()->c2_entries->link_author', $a);
} }
/**
* @param ArrayObject<string, mixed> $a The attributes
*/
public static function c2EntryLang(ArrayObject $a): string public static function c2EntryLang(ArrayObject $a): string
{ {
return self::getGenericValue('App::frontend()->context()->c2_entries->link_lang', $a); return self::getGenericValue('App::frontend()->context()->c2_entries->link_lang', $a);
} }
/**
* @param ArrayObject<string, mixed> $a The attributes
*/
public static function c2EntryURL(ArrayObject $a): string public static function c2EntryURL(ArrayObject $a): string
{ {
return self::getGenericValue('App::frontend()->context()->c2_entries->link_url', $a); return self::getGenericValue('App::frontend()->context()->c2_entries->link_url', $a);
} }
/**
* @param ArrayObject<string, mixed> $a The attributes
*/
public static function c2EntryCategory(ArrayObject $a): string public static function c2EntryCategory(ArrayObject $a): string
{ {
return self::getGenericValue('App::frontend()->context()->c2_entries->cat_title', $a); return self::getGenericValue('App::frontend()->context()->c2_entries->cat_title', $a);
} }
/**
* @param ArrayObject<string, mixed> $a The attributes
*/
public static function c2EntryCategoryID(ArrayObject $a): string public static function c2EntryCategoryID(ArrayObject $a): string
{ {
return self::getGenericValue('App::frontend()->context()->c2_entries->cat_id', $a); return self::getGenericValue('App::frontend()->context()->c2_entries->cat_id', $a);
} }
/**
* @param ArrayObject<string, mixed> $a The attributes
*/
public static function c2EntryCategoryURL(ArrayObject $a): string public static function c2EntryCategoryURL(ArrayObject $a): string
{ {
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); 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);
} }
/**
* @param ArrayObject<string, mixed> $a The attributes
*/
public static function c2EntryImg(ArrayObject $a): string public static function c2EntryImg(ArrayObject $a): string
{ {
$f = App::frontend()->template()->getFilters($a); $f = App::frontend()->template()->getFilters($a);
@ -333,9 +243,6 @@ class FrontendTemplate
'echo ' . sprintf($f, '$img') . "; unset(\$img); } ?> \n"; 'echo ' . sprintf($f, '$img') . "; unset(\$img); } ?> \n";
} }
/**
* @param ArrayObject<string, mixed> $a The attributes
*/
public static function c2EntryDate(ArrayObject $a): string public static function c2EntryDate(ArrayObject $a): string
{ {
$format = !empty($a['format']) ? addslashes($a['format']) : ''; $format = !empty($a['format']) ? addslashes($a['format']) : '';
@ -353,17 +260,11 @@ class FrontendTemplate
return self::getGenericValue($p, $a); return self::getGenericValue($p, $a);
} }
/**
* @param ArrayObject<string, mixed> $a The attributes
*/
public static function c2EntryTime(ArrayObject $a): string public static function c2EntryTime(ArrayObject $a): string
{ {
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); 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);
} }
/**
* @param ArrayObject<string, mixed> $a The attributes
*/
public static function c2Pagination(ArrayObject $a, string $c): string public static function c2Pagination(ArrayObject $a, string $c): string
{ {
$p = "<?php\n" . $p = "<?php\n" .
@ -374,25 +275,16 @@ class FrontendTemplate
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; ?>'; 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; ?>';
} }
/**
* @param ArrayObject<string, mixed> $a The attributes
*/
public static function c2PaginationCounter(ArrayObject $a): string public static function c2PaginationCounter(ArrayObject $a): string
{ {
return self::getGenericValue(FrontendContext::class . '::PaginationNbPages()', $a); return self::getGenericValue(FrontendContext::class . '::PaginationNbPages()', $a);
} }
/**
* @param ArrayObject<string, mixed> $a The attributes
*/
public static function c2PaginationCurrent(ArrayObject $a): string public static function c2PaginationCurrent(ArrayObject $a): string
{ {
return self::getGenericValue(FrontendContext::class . '::PaginationPosition(' . (isset($a['offset']) ? (int) $a['offset'] : 0) . ')', $a); return self::getGenericValue(FrontendContext::class . '::PaginationPosition(' . (isset($a['offset']) ? (int) $a['offset'] : 0) . ')', $a);
} }
/**
* @param ArrayObject<string, mixed> $a The attributes
*/
public static function c2PaginationIf(ArrayObject $a, string $c): string public static function c2PaginationIf(ArrayObject $a, string $c): string
{ {
$if = []; $if = [];
@ -409,17 +301,11 @@ class FrontendTemplate
return empty($if) ? $c : '<?php if(' . implode(' && ', $if) . ') : ?>' . $c . '<?php endif; ?>'; return empty($if) ? $c : '<?php if(' . implode(' && ', $if) . ') : ?>' . $c . '<?php endif; ?>';
} }
/** public static function c2PaginationURL($a): string
* @param ArrayObject<string, mixed> $a The attributes
*/
public static function c2PaginationURL(ArrayObject $a): string
{ {
return self::getGenericValue(FrontendContext::class . '::PaginationURL(' . (isset($a['offset']) ? (int) $a['offset'] : 0) . ')', $a); return self::getGenericValue(FrontendContext::class . '::PaginationURL(' . (isset($a['offset']) ? (int) $a['offset'] : 0) . ')', $a);
} }
/**
* @param ArrayObject<string, mixed> $a The attributes
*/
public static function c2Categories(ArrayObject $a, string $c): string public static function c2Categories(ArrayObject $a, string $c): string
{ {
return return
@ -431,25 +317,16 @@ class FrontendTemplate
"?>\n"; "?>\n";
} }
/**
* @param ArrayObject<string, mixed> $a The attributes
*/
public static function c2CategoriesHeader(ArrayObject $a, string $c): string public static function c2CategoriesHeader(ArrayObject $a, string $c): string
{ {
return '<?php if (App::frontend()->context()->c2_categories->isStart()) : ?>' . $c . '<?php endif; ?>'; return '<?php if (App::frontend()->context()->c2_categories->isStart()) : ?>' . $c . '<?php endif; ?>';
} }
/**
* @param ArrayObject<string, mixed> $a The attributes
*/
public static function c2CategoriesFooter(ArrayObject $a, string $c): string public static function c2CategoriesFooter(ArrayObject $a, string $c): string
{ {
return '<?php if (App::frontend()->context()->c2_categories->isEnd()) : ?>' . $c . '<?php endif; ?>'; return '<?php if (App::frontend()->context()->c2_categories->isEnd()) : ?>' . $c . '<?php endif; ?>';
} }
/**
* @param ArrayObject<string, mixed> $a The attributes
*/
public static function c2CategoryIf(ArrayObject $a, string $c): string public static function c2CategoryIf(ArrayObject $a, string $c): string
{ {
$if = []; $if = [];
@ -466,9 +343,6 @@ class FrontendTemplate
return empty($if) ? $c : '<?php if(' . implode(' && ', $if) . ') : ?>' . $c . '<?php endif; ?>'; return empty($if) ? $c : '<?php if(' . implode(' && ', $if) . ') : ?>' . $c . '<?php endif; ?>';
} }
/**
* @param ArrayObject<string, mixed> $a The attributes
*/
public static function c2CategoryFeedURL(ArrayObject $a): string public static function c2CategoryFeedURL(ArrayObject $a): string
{ {
$p = !empty($a['type']) ? $a['type'] : 'atom'; $p = !empty($a['type']) ? $a['type'] : 'atom';
@ -480,49 +354,31 @@ class FrontendTemplate
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 . '"') . '; ?>'; 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 . '"') . '; ?>';
} }
/**
* @param ArrayObject<string, mixed> $a The attributes
*/
public static function c2CategoryFeedID(ArrayObject $a): string public static function c2CategoryFeedID(ArrayObject $a): string
{ {
return 'urn:md5:<?php echo md5(App::blog()->id()."' . My::id() . '".App::frontend()->context()->c2_categories->cat_id); ?>'; return 'urn:md5:<?php echo md5(App::blog()->id()."' . My::id() . '".App::frontend()->context()->c2_categories->cat_id); ?>';
} }
/**
* @param ArrayObject<string, mixed> $a The attributes
*/
public static function c2CategoryID(ArrayObject $a): string public static function c2CategoryID(ArrayObject $a): string
{ {
return "<?php if (App::frontend()->context()->exists('c2_categories')) { echo " . sprintf(App::frontend()->template()->getFilters($a), 'App::frontend()->context()->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') . '; } ?>';
} }
/**
* @param ArrayObject<string, mixed> $a The attributes
*/
public static function c2CategoryTitle(ArrayObject $a): string public static function c2CategoryTitle(ArrayObject $a): string
{ {
return "<?php if (App::frontend()->context()->exists('c2_categories')) { echo " . sprintf(App::frontend()->template()->getFilters($a), 'App::frontend()->context()->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') . '; } ?>';
} }
/**
* @param ArrayObject<string, mixed> $a The attributes
*/
public static function c2CategoryDescription(ArrayObject $a): string public static function c2CategoryDescription(ArrayObject $a): string
{ {
return "<?php if (App::frontend()->context()->exists('c2_categories')) { echo " . sprintf(App::frontend()->template()->getFilters($a), 'App::frontend()->context()->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') . '; } ?>';
} }
/**
* @param ArrayObject<string, mixed> $a The attributes
*/
public static function c2CategoryURL(ArrayObject $a): string public static function c2CategoryURL(ArrayObject $a): string
{ {
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)') . '; } ?>'; 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)') . '; } ?>';
} }
/**
* @param ArrayObject<string, mixed> $a The attributes
*/
protected static function getGenericValue(string $p, ArrayObject $a): string protected static function getGenericValue(string $p, ArrayObject $a): string
{ {
return "<?php if (App::frontend()->context()->exists('c2_entries')) { echo " . sprintf(App::frontend()->template()->getFilters($a), "$p") . '; } ?>'; return "<?php if (App::frontend()->context()->exists('c2_entries')) { echo " . sprintf(App::frontend()->template()->getFilters($a), "$p") . '; } ?>';

View File

@ -6,6 +6,7 @@ namespace Dotclear\Plugin\cinecturlink2;
use Dotclear\App; use Dotclear\App;
use Dotclear\Core\Frontend\Url; use Dotclear\Core\Frontend\Url;
use Dotclear\Helper\File\Path;
/** /**
* @brief cinecturlink2 frontend URLclass. * @brief cinecturlink2 frontend URLclass.
@ -16,7 +17,7 @@ use Dotclear\Core\Frontend\Url;
*/ */
class FrontendUrl extends Url class FrontendUrl extends Url
{ {
public static function c2Page(?string $args): null public static function c2Page(?string $args)
{ {
$args = (string) $args; $args = (string) $args;
@ -26,10 +27,8 @@ class FrontendUrl extends Url
} }
$tplset = App::themes()->getDefine(App::blog()->settings()->get('system')->get('theme'))->get('tplset'); $tplset = App::themes()->getDefine(App::blog()->settings()->get('system')->get('theme'))->get('tplset');
if (empty($tplset) || !is_dir(implode(DIRECTORY_SEPARATOR, [My::path(), 'default-templates', $tplset]))) { $tpldir = Path::real(App::plugins()->getDefine(My::id())->get('root')) . DIRECTORY_SEPARATOR . App::frontend()::TPL_ROOT . DIRECTORY_SEPARATOR;
$tplset = App::config()->defaultTplset(); App::frontend()->template()->setPath(App::frontend()->template()->getPath(), $tpldir . (!empty($tplset) && is_dir($tpldir . $tplset) ? $tplset : App::config()->defaultTplset()));
}
App::frontend()->template()->appendPath(implode(DIRECTORY_SEPARATOR, [My::path(), 'default-templates', $tplset]));
$params = []; $params = [];

View File

@ -32,7 +32,9 @@ use Exception;
class ManageCat extends Process class ManageCat extends Process
{ {
private static string $module_redir = ''; private static string $module_redir = '';
private static RecordCatsRow $row; private static int $catid = 0;
private static string $cattitle = '';
private static string $catdesc = '';
public static function init(): bool public static function init(): bool
{ {
@ -45,18 +47,25 @@ class ManageCat extends Process
return false; return false;
} }
self::$module_redir = $_REQUEST['redir'] ?? '';
self::$row = new RecordCatsRow();
$utils = new Utils(); $utils = new Utils();
self::$module_redir = $_REQUEST['redir'] ?? '';
self::$catid = (int) ($_REQUEST['catid'] ?? 0);
self::$cattitle = $_POST['cattitle'] ?? '';
self::$catdesc = $_POST['catdesc'] ?? '';
try { try {
// create category // create category
if (!empty($_POST['save']) && empty(self::$row->cat_id) && !empty(self::$row->cat_title) && !empty(self::$row->cat_desc)) { if (!empty($_POST['save']) && empty(self::$catid) && !empty(self::$cattitle) && !empty(self::$catdesc)) {
$exists = $utils->getCategories(['cat_title' => self::$row->cat_title], true)->f(0); $exists = $utils->getCategories(['cat_title' => self::$cattitle], true)->f(0);
if ($exists) { if ($exists) {
throw new Exception(__('Category with same name already exists.')); throw new Exception(__('Category with same name already exists.'));
} }
$cat_id = $utils->addCategory(self::$row->getCursor()); $cur = App::con()->openCursor($utils->cat_table);
$cur->setField('cat_title', self::$cattitle);
$cur->setField('cat_desc', self::$catdesc);
$catid = $utils->addCategory($cur);
Notices::addSuccessNotice( Notices::addSuccessNotice(
__('Category successfully created.') __('Category successfully created.')
@ -64,12 +73,16 @@ class ManageCat extends Process
My::redirect(['part' => 'cats']); My::redirect(['part' => 'cats']);
} }
// update category // update category
if (!empty($_POST['save']) && !empty(self::$row->cat_id) && !empty(self::$row->cat_title) && !empty(self::$row->cat_desc)) { if (!empty($_POST['save']) && !empty(self::$catid) && !empty(self::$cattitle) && !empty(self::$catdesc)) {
$exists = $utils->getCategories(['cat_title' => self::$row->cat_title, 'exclude_cat_id' => self::$row->cat_id], true)->f(0); $exists = $utils->getCategories(['cat_title' => self::$cattitle, 'exclude_cat_id' => self::$catid], true)->f(0);
if ($exists) { if ($exists) {
throw new Exception(__('Category with same name already exists.')); throw new Exception(__('Category with same name already exists.'));
} }
$cat_id = $utils->updCategory(self::$row->cat_id, self::$row->getCursor()); $cur = App::con()->openCursor($C2->cat_table);
$cur->setField('cat_title', self::$cattitle);
$cur->setField('cat_desc', self::$catdesc);
$utils->updCategory(self::$catid, $cur);
Notices::addSuccessNotice( Notices::addSuccessNotice(
__('Category successfully updated.') __('Category successfully updated.')
@ -77,20 +90,14 @@ class ManageCat extends Process
My::redirect(['part' => 'cats']); My::redirect(['part' => 'cats']);
} }
// delete category // delete category
if (!empty($_POST['delete']) && !empty(self::$row->cat_id)) { if (!empty($_POST['delete']) && !empty(self::$catid)) {
$utils->delCategory(self::$row->cat_id); $utils->delCategory(self::$catid);
Notices::addSuccessNotice( Notices::addSuccessNotice(
__('Category successfully deleted.') __('Category successfully deleted.')
); );
My::redirect(['part' => 'cats']); My::redirect(['part' => 'cats']);
} }
if (self::$row->cat_id) {
self::$row = new RecordCatsRow(
$utils->getCategories(['cat_id' => self::$row->cat_id])
);
}
} catch (Exception $e) { } catch (Exception $e) {
App::error()->add($e->getMessage()); App::error()->add($e->getMessage());
} }
@ -106,13 +113,21 @@ class ManageCat extends Process
$utils = new Utils(); $utils = new Utils();
if (!empty(self::$catid)) {
$category = $utils->getCategories(['cat_id' => self::$catid]);
if (!$category->isEmpty()) {
self::$cattitle = (string) $category->f('cat_title');
self::$catdesc = (string) $category->f('cat_desc');
}
}
Page::openModule(My::name()); Page::openModule(My::name());
echo echo
Page::breadcrumb([ Page::breadcrumb([
__('Plugins') => '', __('Plugins') => '',
My::name() => My::manageUrl(), My::name() => My::manageUrl(),
(empty(self::$row->cat_id) ? __('New category') : __('Edit category')) => '', (empty(self::$catid) ? __('New category') : __('Edit category')) => '',
]) . ]) .
Notices::getNotices(); Notices::getNotices();
@ -127,8 +142,8 @@ class ManageCat extends Process
->render(); ->render();
} }
if (self::$row->cat_id) { if (self::$catid) {
$links = (int) $utils->getLinks(['cat_id' => self::$row->cat_id], true)->f(0); $links = (int) $utils->getLinks(['cat_id' => self::$catid], true)->f(0);
echo (new Note()) echo (new Note())
->class('info') ->class('info')
->text( ->text(
@ -146,20 +161,20 @@ class ManageCat extends Process
(new Para()) (new Para())
->items([ ->items([
(new Label(__('Title:'), Label::OUTSIDE_LABEL_BEFORE)) (new Label(__('Title:'), Label::OUTSIDE_LABEL_BEFORE))
->for('cat_title'), ->for('cattitle'),
(new Input('cat_title')) (new Input('cattitle'))
->size(65) ->size(65)
->maxlength(64) ->maxlenght(64)
->value(Html::escapeHTML(self::$row->cat_title)), ->value(Html::escapeHTML(self::$cattitle)),
]), ]),
(new Para()) (new Para())
->items([ ->items([
(new Label(__('Description:'), Label::OUTSIDE_LABEL_BEFORE)) (new Label(__('Description:'), Label::OUTSIDE_LABEL_BEFORE))
->for('cat_desc'), ->for('catdesc'),
(new Input('cat_desc')) (new Input('catdesc'))
->size(65) ->size(65)
->maxlength(64) ->maxlenght(64)
->value(Html::escapeHTML(self::$row->cat_desc)), ->value(Html::escapeHTML(self::$catdesc)),
]), ]),
(new Para()) (new Para())
->class('border-top') ->class('border-top')
@ -179,7 +194,7 @@ class ManageCat extends Process
->value(__('Delete') . ' (d)') ->value(__('Delete') . ' (d)')
->accesskey('d'), ->accesskey('d'),
... My::hiddenFields([ ... My::hiddenFields([
'cat_id' => self::$row->cat_id, 'catid' => self::$catid,
'part' => 'cat', 'part' => 'cat',
'redir' => self::$module_redir, 'redir' => self::$module_redir,
]), ]),

View File

@ -107,8 +107,7 @@ class ManageCats extends Process
$items = []; $items = [];
$i = 0; $i = 0;
while ($categories->fetch()) { while ($categories->fetch()) {
$row = new RecordCatsRow($categories); $id = $categories->f('cat_id');
$id = (string) $row->cat_id;
$items[] = (new Tr('l_' . $i)) $items[] = (new Tr('l_' . $i))
->class('line') ->class('line')
@ -121,7 +120,7 @@ class ManageCats extends Process
->max($categories->count()) ->max($categories->count())
->value($i + 1) ->value($i + 1)
->class('position') ->class('position')
->title(Html::escapeHTML(sprintf(__('position of %s'), $row->cat_title))), ->title(Html::escapeHTML(sprintf(__('position of %s'), (string) $categories->f('cat_title')))),
(new Hidden(['dynorder[]', 'dynorder-' . $i], $id)), (new Hidden(['dynorder[]', 'dynorder-' . $i], $id)),
]), ]),
(new Td()) (new Td())
@ -136,18 +135,18 @@ class ManageCats extends Process
(new Link()) (new Link())
->href(My::manageUrl([ ->href(My::manageUrl([
'part' => 'cat', 'part' => 'cat',
'cat_id' => $id, 'catid' => $id,
'redir' => My::manageUrl([ 'redir' => My::manageUrl([
'part' => 'cats', 'part' => 'cats',
'redir' => self::$module_redir, 'redir' => self::$module_redir,
]), ]),
])) ]))
->title(__('Edit')) ->title(__('Edit'))
->text(Html::escapeHTML($row->cat_title)), ->text(Html::escapeHTML((string) $categories->f('cat_title'))),
]), ]),
(new Td()) (new Td())
->class('maximal') ->class('maximal')
->text(Html::escapeHTML($row->cat_desc)), ->text(Html::escapeHTML((string) $categories->f('cat_desc'))),
]); ]);
$i++; $i++;
@ -188,7 +187,7 @@ class ManageCats extends Process
(new Link()) (new Link())
->class('button add') ->class('button add')
->href(My::manageUrl(['part' => 'cat', 'redir' => My::manageUrl(['part' => 'cats'])])) ->href(My::manageUrl(['part' => 'cat', 'redir' => My::manageUrl(['part' => 'cats'])]))
->text(__('New Category')), ->text(__('New Link')),
]) ])
->render(); ->render();

View File

@ -36,7 +36,15 @@ use Exception;
class ManageLink extends Process class ManageLink extends Process
{ {
private static string $module_redir = ''; private static string $module_redir = '';
private static RecordLinksRow $row; private static int $linkid = 0;
private static string $linktitle = '';
private static string $linkdesc = '';
private static string $linkauthor = '';
private static string $linkurl = '';
private static ?string $linkcat = '';
private static string $linklang = '';
private static string $linkimage = '';
private static string $linknote = '';
public static function init(): bool public static function init(): bool
{ {
@ -49,44 +57,63 @@ class ManageLink extends Process
return false; return false;
} }
self::$module_redir = $_REQUEST['redir'] ?? '';
self::$row = new RecordLinksRow();
$utils = new Utils(); $utils = new Utils();
self::$module_redir = $_REQUEST['redir'] ?? '';
self::$linkid = (int) ($_REQUEST['linkid'] ?? 0);
self::$linktitle = $_POST['linktitle'] ?? '';
self::$linkdesc = $_POST['linkdesc'] ?? '';
self::$linkauthor = $_POST['linkauthor'] ?? '';
self::$linkurl = $_POST['linkurl'] ?? '';
self::$linkcat = $_POST['linkcat'] ?? null;
self::$linklang = $_POST['linklang'] ?? App::auth()->getInfo('user_lang');
self::$linkimage = $_POST['linkimage'] ?? '';
self::$linknote = $_POST['linknote'] ?? '';
if (!empty($_POST['save'])) { if (!empty($_POST['save'])) {
try { try {
Utils::makePublicDir( Utils::makePublicDir(
App::config()->dotclearRoot() . '/' . App::blog()->settings()->system->get('public_path'), App::config()->dotclearRoot() . '/' . App::blog()->settings()->system->get('public_path'),
My::settings()->folder My::settings()->folder
); );
if (empty(self::$row->link_title)) { if (empty(self::$linktitle)) {
throw new Exception(__('You must provide a title.')); throw new Exception(__('You must provide a title.'));
} }
if (empty(self::$row->link_author)) { if (empty(self::$linkauthor)) {
throw new Exception(__('You must provide an author.')); throw new Exception(__('You must provide an author.'));
} }
if (!preg_match('/https?:\/\/.+/', self::$row->link_img)) { if (!preg_match('/https?:\/\/.+/', self::$linkimage)) {
//throw new Exception(__('You must provide a link to an image.')); //throw new Exception(__('You must provide a link to an image.'));
} }
$cur = App::con()->openCursor($utils->table);
$cur->setField('link_title', self::$linktitle);
$cur->setField('link_desc', self::$linkdesc);
$cur->setField('link_author', self::$linkauthor);
$cur->setField('link_url', self::$linkurl);
$cur->setField('cat_id', self::$linkcat == '' ? null : self::$linkcat);
$cur->setField('link_lang', self::$linklang);
$cur->setField('link_img', self::$linkimage);
$cur->setField('link_note', self::$linknote);
// create a link // create a link
if (!self::$row->link_id) { if (empty(self::$linkid)) {
$exists = $utils->getLinks(['link_title' => self::$row->link_title], true)->f(0); $exists = $utils->getLinks(['link_title' => self::$linktitle], true)->f(0);
if ($exists) { if ($exists) {
throw new Exception(__('Link with same name already exists.')); throw new Exception(__('Link with same name already exists.'));
} }
$link_id = $utils->addLink(self::$row->getCursor()); self::$linkid = $utils->addLink($cur);
Notices::addSuccessNotice( Notices::addSuccessNotice(
__('Link successfully created.') __('Link successfully created.')
); );
// update a link // update a link
} else { } else {
$exists = $utils->getLinks(['link_id' => self::$row->link_id], true)->f(0); $exists = $utils->getLinks(['link_id' => self::$linkid], true)->f(0);
if (!$exists) { if (!$exists) {
throw new Exception(__('Unknown link.')); throw new Exception(__('Unknown link.'));
} }
$link_id = $utils->updLink(self::$row->link_id, self::$row->getCursor()); $utils->updLink(self::$linkid, $cur);
Notices::addSuccessNotice( Notices::addSuccessNotice(
__('Link successfully updated.') __('Link successfully updated.')
@ -95,7 +122,7 @@ class ManageLink extends Process
My::redirect( My::redirect(
[ [
'part' => 'link', 'part' => 'link',
'link_id' => $link_id, 'linkid' => self::$linkid,
'redir' => self::$module_redir, 'redir' => self::$module_redir,
] ]
); );
@ -104,9 +131,9 @@ class ManageLink extends Process
} }
} }
if (!empty($_POST['delete']) && self::$row->link_id) { if (!empty($_POST['delete']) && !empty(self::$linkid)) {
try { try {
$utils->delLink(self::$row->link_id); $utils->delLink(self::$linkid);
Notices::addSuccessNotice( Notices::addSuccessNotice(
__('Link successfully deleted.') __('Link successfully deleted.')
@ -121,10 +148,18 @@ class ManageLink extends Process
} }
} }
if (self::$row->link_id) { if (!empty(self::$linkid)) {
self::$row = new RecordLinksRow( $link = $utils->getLinks(['link_id' => self::$linkid]);
$utils->getLinks(['link_id' => self::$row->link_id]) if (!$link->isEmpty()) {
); self::$linktitle = (string) $link->f('link_title');
self::$linkdesc = (string) $link->f('link_desc');
self::$linkauthor = (string) $link->f('link_author');
self::$linkurl = (string) $link->f('link_url');
self::$linkcat = (string) $link->f('cat_id');
self::$linklang = (string) $link->f('link_lang');
self::$linkimage = (string) $link->f('link_img');
self::$linknote = (string) $link->f('link_note');
}
} }
return true; return true;
@ -148,7 +183,7 @@ class ManageLink extends Process
Page::breadcrumb([ Page::breadcrumb([
__('Plugins') => '', __('Plugins') => '',
My::name() => My::manageUrl(), My::name() => My::manageUrl(),
(empty(self::$row->link_id) ? __('New link') : __('Edit link')) => '', (empty(self::$linkid) ? __('New link') : __('Edit link')) => '',
]) . ]) .
Notices::getNotices(); Notices::getNotices();
@ -178,38 +213,38 @@ class ManageLink extends Process
(new Para()) (new Para())
->items([ ->items([
(new Label(__('Title:'), Label::OUTSIDE_LABEL_BEFORE)) (new Label(__('Title:'), Label::OUTSIDE_LABEL_BEFORE))
->for('link_title'), ->for('linktitle'),
(new Input('link_title')) (new Input('linktitle'))
->size(65) ->size(65)
->maxlength(255) ->maxlenght(255)
->value(Html::escapeHTML(self::$row->link_title)), ->value(Html::escapeHTML(self::$linktitle)),
]), ]),
(new Para()) (new Para())
->items([ ->items([
(new Label(__('Description:'), Label::OUTSIDE_LABEL_BEFORE)) (new Label(__('Description:'), Label::OUTSIDE_LABEL_BEFORE))
->for('link_desc'), ->for('linkdesc'),
(new Input('link_desc')) (new Input('linkdesc'))
->size(65) ->size(65)
->maxlength(255) ->maxlenght(255)
->value(Html::escapeHTML(self::$row->link_desc)), ->value(Html::escapeHTML(self::$linkdesc)),
]), ]),
(new Para()) (new Para())
->items([ ->items([
(new Label(__('Author:'), Label::OUTSIDE_LABEL_BEFORE)) (new Label(__('Author:'), Label::OUTSIDE_LABEL_BEFORE))
->for('link_author'), ->for('linkauthor'),
(new Input('link_author')) (new Input('linkauthor'))
->size(65) ->size(65)
->maxlength(255) ->maxlenght(255)
->value(Html::escapeHTML(self::$row->link_author)), ->value(Html::escapeHTML(self::$linkauthor)),
]), ]),
(new Para()) (new Para())
->items([ ->items([
(new Label(__('Details URL:'), Label::OUTSIDE_LABEL_BEFORE)) (new Label(__('Details URL:'), Label::OUTSIDE_LABEL_BEFORE))
->for('link_url'), ->for('linkurl'),
(new Input('link_url')) (new Input('linkurl'))
->size(65) ->size(65)
->maxlength(255) ->maxlenght(255)
->value(Html::escapeHTML(self::$row->link_url)), ->value(Html::escapeHTML(self::$linkurl)),
(new Link('newlinksearch')) (new Link('newlinksearch'))
->class('modal hidden-if-no-js') ->class('modal hidden-if-no-js')
->href('http://google.com') ->href('http://google.com')
@ -219,11 +254,11 @@ class ManageLink extends Process
(new Para()) (new Para())
->items([ ->items([
(new Label(__('Image URL:'), Label::OUTSIDE_LABEL_BEFORE)) (new Label(__('Image URL:'), Label::OUTSIDE_LABEL_BEFORE))
->for('link_img'), ->for('linkimage'),
(new Input('link_img')) (new Input('linkimage'))
->size(65) ->size(65)
->maxlength(255) ->maxlenght(255)
->value(Html::escapeHTML(self::$row->link_img)), ->value(Html::escapeHTML(self::$linkimage)),
(new Link('newimagesearch')) (new Link('newimagesearch'))
->class('modal hidden-if-no-js') ->class('modal hidden-if-no-js')
->href('http://amazon.com') ->href('http://amazon.com')
@ -261,27 +296,27 @@ class ManageLink extends Process
(new Para()) (new Para())
->items([ ->items([
(new Label(__('Category:'), Label::OUTSIDE_LABEL_BEFORE)) (new Label(__('Category:'), Label::OUTSIDE_LABEL_BEFORE))
->for('cat_id'), ->for('linkcat'),
(new Select('cat_id')) (new Select('linkcat'))
->items(Combo::categoriesCombo()) ->items(Combo::categoriesCombo())
->default((string) self::$row->cat_id), ->default(self::$linkcat),
]), ]),
(new Para()) (new Para())
->items([ ->items([
(new Label(__('Lang:'), Label::OUTSIDE_LABEL_BEFORE)) (new Label(__('Lang:'), Label::OUTSIDE_LABEL_BEFORE))
->for('link_lang'), ->for('linklang'),
(new Select('link_lang')) (new Select('linklang'))
->items(Combo::langsCombo()) ->items(Combo::langsCombo())
->default(self::$row->link_lang), ->default(self::$linklang),
]), ]),
(new Para()) (new Para())
->items([ ->items([
(new Label(__('Rating:'), Label::OUTSIDE_LABEL_BEFORE)) (new Label(__('Rating:'), Label::OUTSIDE_LABEL_BEFORE))
->for('link_note'), ->for('linknote'),
(new Number('link_note')) (new Number('linknote'))
->min(0) ->min(0)
->max(20) ->max(20)
->value(self::$row->link_note), ->value(self::$linknote),
]), ]),
]), ]),
]), ]),
@ -303,7 +338,7 @@ class ManageLink extends Process
->value(__('Delete') . ' (d)') ->value(__('Delete') . ' (d)')
->accesskey('d'), ->accesskey('d'),
... My::hiddenFields([ ... My::hiddenFields([
'link_id' => self::$row->link_id, 'linkid' => self::$linkid,
'part' => 'link', 'part' => 'link',
'redir' => self::$module_redir, 'redir' => self::$module_redir,
]), ]),

View File

@ -10,6 +10,7 @@ use Dotclear\Core\Backend\Filter\{
Filters, Filters,
FiltersLibrary FiltersLibrary
}; };
use Dotclear\Core\Backend\Listing\Listing;
use Dotclear\Core\Backend\{ use Dotclear\Core\Backend\{
Notices, Notices,
Page Page
@ -39,7 +40,7 @@ class ManageLinks extends Process
{ {
private static Actions $module_action; private static Actions $module_action;
private static Filters $module_filter; private static Filters $module_filter;
private static BackendListingLinks $module_listing; private static Listing $module_listing;
private static int $module_counter = 0; private static int $module_counter = 0;
private static ?bool $module_rendered = null; private static ?bool $module_rendered = null;
@ -66,7 +67,7 @@ class ManageLinks extends Process
self::$module_filter->add(FiltersLibrary::getPageFilter()); self::$module_filter->add(FiltersLibrary::getPageFilter());
self::$module_filter->add(FiltersLibrary::getSearchFilter()); self::$module_filter->add(FiltersLibrary::getSearchFilter());
self::$module_filter->add(FiltersLibrary::getSelectFilter( self::$module_filter->add(FiltersLibrary::getSelectFilter(
'cat_id', 'catid',
__('Category:'), __('Category:'),
Combo::categoriesCombo(), Combo::categoriesCombo(),
'cat_id' 'cat_id'
@ -170,7 +171,7 @@ class ManageLinks extends Process
(new Label(__('Selected links action:'), Label::OUTSIDE_LABEL_BEFORE)) (new Label(__('Selected links action:'), Label::OUTSIDE_LABEL_BEFORE))
->for('action'), ->for('action'),
(new Select('action')) (new Select('action'))
->items(self::$module_action->getCombo() ?? []), ->items(self::$module_action->getCombo()),
(new Submit('do-action')) (new Submit('do-action'))
->value(__('ok')), ->value(__('ok')),
... My::hiddenFields(self::$module_filter->values(true)), ... My::hiddenFields(self::$module_filter->values(true)),

View File

@ -17,14 +17,14 @@ use Dotclear\Module\MyPlugin;
class My extends MyPlugin class My extends MyPlugin
{ {
/** /**
* Links table name. * Link table name.
* *
* @var string CINECTURLINK_TABLE_NAME * @var string CINECTURLINK_TABLE_NAME
*/ */
public const CINECTURLINK_TABLE_NAME = 'cinecturlink2'; public const CINECTURLINK_TABLE_NAME = 'cinecturlink2';
/** /**
* Categories table name. * Category table name.
* *
* @var string CATEGORY_TABLE_NAME * @var string CATEGORY_TABLE_NAME
*/ */
@ -40,8 +40,8 @@ class My extends MyPlugin
public static function checkCustomContext(int $context): ?bool public static function checkCustomContext(int $context): ?bool
{ {
return match ($context) { return match ($context) {
// Add content admin perm to backend self::MENU, self::MANAGE, self::BACKEND => App::task()->checkContext('BACKEND')
self::MENU, self::MANAGE => App::task()->checkContext('BACKEND') && App::blog()->isDefined()
&& App::auth()->check(App::auth()->makePermissions([ && App::auth()->check(App::auth()->makePermissions([
App::auth()::PERMISSION_CONTENT_ADMIN, App::auth()::PERMISSION_CONTENT_ADMIN,
]), App::blog()->id()), ]), App::blog()->id()),

View File

@ -0,0 +1,84 @@
<?php
declare(strict_types=1);
namespace Dotclear\Plugin\cinecturlink2;
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()
{
ActivityReport::instance()->addGroup('cinecturlink2', __('Plugin cinecturlink2'));
// from BEHAVIOR cinecturlink2AfterAddLink in cinecturlink2/inc/class.cinecturlink2.php
ActivityReport::instance()->addAction(
'cinecturlink2',
'create',
__('link creation'),
__('A new cineturlink named "%s" was added by "%s"'),
'cinecturlink2AfterAddLink',
self::addLink(...)
);
// from BEHAVIOR cinecturlink2AfterUpdLink in cinecturlink2/inc/class.cinecturlink2.php
ActivityReport::instance()->addAction(
'cinecturlink2',
'update',
__('updating link'),
__('Cinecturlink named "%s" has been updated by "%s"'),
'cinecturlink2AfterUpdLink',
self::updLink(...)
);
// from BEHAVIOR cinecturlink2BeforeDelLink in cinecturlink2/inc/class.cinecturlink2.php
ActivityReport::instance()->addAction(
'cinecturlink2',
'delete',
__('link deletion'),
__('Cinecturlink named "%s" has been deleted by "%s"'),
'cinecturlink2BeforeDelLink',
self::delLink(...)
);
}
public static function addLink($cur)
{
$logs = [
$cur->link_title,
App::auth()->getInfo('user_cn'),
];
ActivityReport::instance()->addLog('cinecturlink2', 'create', $logs);
}
public static function updLink($cur, $id)
{
$C2 = new Utils();
$rs = $C2->getLinks(['link_id' => $id]);
$logs = [
$rs->link_title,
App::auth()->getInfo('user_cn'),
];
ActivityReport::instance()->addLog('cinecturlink2', 'update', $logs);
}
public static function delLink($id)
{
$C2 = new Utils();
$rs = $C2->getLinks(['link_id' => $id]);
$logs = [
$rs->link_title,
App::auth()->getInfo('user_cn'),
];
ActivityReport::instance()->addLog('cinecturlink2', 'delete', $logs);
}
}

View File

@ -4,30 +4,23 @@ declare(strict_types=1);
namespace Dotclear\Plugin\cinecturlink2; namespace Dotclear\Plugin\cinecturlink2;
use ArrayObject;
use Dotclear\App; use Dotclear\App;
use Dotclear\Plugin\sitemaps\Sitemap;
/** /**
* @brief cinecturlink2 sitemaps class. * @brief cinecturlink2 sitemaps class.
* @ingroup cinecturlink2 * @ingroup cinecturlink2
* *
* Add Cinecturlink public main page and categories pages to plugin sitemap.
*
* @author Jean-Christian Denis (author) * @author Jean-Christian Denis (author)
* @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
*/ */
class PluginSitemaps class PluginSitemaps
{ {
/** public static function sitemapsDefineParts($map_parts)
* @param ArrayObject<string, string> $map_parts
*/
public static function sitemapsDefineParts(ArrayObject $map_parts): void
{ {
$map_parts->offsetSet(My::name(), My::id()); $map_parts->offsetSet(My::name(), My::id());
} }
public static function sitemapsURLsCollect(Sitemap $sitemaps): void public static function sitemapsURLsCollect($sitemaps)
{ {
if (App::plugins()->moduleExists('cinecturlink2') if (App::plugins()->moduleExists('cinecturlink2')
&& App::blog()->settings()->get('sitemaps')->get('sitemaps_cinecturlink2_url') && App::blog()->settings()->get('sitemaps')->get('sitemaps_cinecturlink2_url')
@ -41,7 +34,7 @@ class PluginSitemaps
$C2 = new Utils(); $C2 = new Utils();
$cats = $C2->getCategories(); $cats = $C2->getCategories();
while ($cats->fetch()) { while ($cats->fetch()) {
$sitemaps->addEntry($base . '/' . My::settings()->get('public_caturl') . '/' . urlencode((string) $cats->field('cat_title')), $prio, $freq); $sitemaps->addEntry($base . '/' . My::settings()->get('public_caturl') . '/' . urlencode($cats->cat_title), $prio, $freq);
} }
} }
} }

View File

@ -39,6 +39,10 @@ class Prepend extends Process
'sitemapsURLsCollect' => PluginSitemaps::sitemapsURLsCollect(...), 'sitemapsURLsCollect' => PluginSitemaps::sitemapsURLsCollect(...),
]); ]);
if (defined('ACTIVITY_REPORT_V2')) {
PluginActivityReport::add();
}
return true; return true;
} }
} }

View File

@ -1,41 +0,0 @@
<?php
declare(strict_types=1);
namespace Dotclear\Plugin\cinecturlink2;
use Dotclear\App;
use Dotclear\Database\Cursor;
use Dotclear\Database\MetaRecord;
/**
* @brief cinecturlink2 record categories row class.
* @ingroup cinecturlink2
*
* @author Jean-Christian Denis (author)
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
class RecordCatsRow
{
public readonly int $cat_id;
public readonly string $cat_title;
public readonly string $cat_desc;
public readonly int $cat_pos;
public function __construct(?MetaRecord $rs = null)
{
$this->cat_id = (int) ($rs?->field('cat_id') ?? $_REQUEST['cat_id'] ?? 0);
$this->cat_title = (string) ($rs?->field('cat_title') ?? $_POST['cat_title'] ?? '');
$this->cat_desc = (string) ($rs?->field('cat_desc') ?? $_POST['cat_desc'] ?? '');
$this->cat_pos = (int) ($rs?->field('cat_pos') ?? 0);
}
public function getCursor(): Cursor
{
$cur = App::con()->openCursor(App::con()->prefix() . My::CATEGORY_TABLE_NAME);
$cur->setField('cat_title', $this->cat_title);
$cur->setField('cat_desc', $this->cat_desc);
return $cur;
}
}

View File

@ -1,63 +0,0 @@
<?php
declare(strict_types=1);
namespace Dotclear\Plugin\cinecturlink2;
use Dotclear\App;
use Dotclear\Database\Cursor;
use Dotclear\Database\MetaRecord;
/**
* @brief cinecturlink2 record links row class.
* @ingroup cinecturlink2
*
* @author Jean-Christian Denis (author)
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
class RecordLinksRow
{
public readonly int $link_id;
public readonly string $link_title;
public readonly string $link_desc;
public readonly string $link_author;
public readonly string $link_url;
public readonly ?int $cat_id;
public readonly string $cat_title;
public readonly string $link_lang;
public readonly string $link_img;
public readonly string $link_note;
public readonly string $link_upddt;
public readonly int $link_count;
public function __construct(?MetaRecord $rs = null)
{
$this->link_id = (int) ($rs?->field('link_id') ?? $_REQUEST['link_id'] ?? 0);
$this->link_title = (string) ($rs?->field('link_title') ?? $_POST['link_title'] ?? '');
$this->link_desc = (string) ($rs?->field('link_desc') ?? $_POST['link_desc'] ?? '');
$this->link_author = (string) ($rs?->field('link_author') ?? $_POST['link_author'] ?? '');
$this->link_url = (string) ($rs?->field('link_url') ?? $_POST['link_url'] ?? '');
$this->cat_id = $rs?->field('cat_id') ? (int) $rs->field('cat_id') : (isset($_POST['cat_id']) ? (int) $_POST['cat_id'] : null);
$this->cat_title = (string) ($rs?->field('cat_title') ?? $_POST['cat_title'] ?? '');
$this->link_lang = (string) ($rs?->field('link_lang') ?? $_POST['link_lang'] ?? App::auth()->getInfo('user_lang'));
$this->link_img = (string) ($rs?->field('link_img') ?? $_POST['link_img'] ?? '');
$this->link_note = (string) ($rs?->field('link_note') ?? $_POST['link_note'] ?? '');
$this->link_upddt = (string) ($rs?->field('link_upddt') ?? '');
$this->link_count = abs((int) $rs?->field('link_count'));
}
public function getCursor(): Cursor
{
$cur = App::con()->openCursor(App::con()->prefix() . My::CINECTURLINK_TABLE_NAME);
$cur->setField('link_title', $this->link_title);
$cur->setField('link_desc', $this->link_desc);
$cur->setField('link_author', $this->link_author);
$cur->setField('link_url', $this->link_url);
$cur->setField('cat_id', $this->cat_id);
$cur->setField('link_lang', $this->link_lang);
$cur->setField('link_img', $this->link_img);
$cur->setField('link_note', $this->link_note);
return $cur;
}
}

View File

@ -72,9 +72,8 @@ class Utils
/** /**
* Get links. * Get links.
* *
* @param array<string, mixed> $params Query params * @param array $params Query params
* @param bool $count_only Count only result * @param bool $count_only Count only result
*
* @return MetaRecord MetaRecord instance * @return MetaRecord MetaRecord instance
*/ */
public function getLinks(array $params = [], bool $count_only = false): MetaRecord public function getLinks(array $params = [], bool $count_only = false): MetaRecord
@ -265,10 +264,8 @@ class Utils
* @param int $id Link ID * @param int $id Link ID
* @param Cursor $cur Cursor instance * @param Cursor $cur Cursor instance
* @param bool $behavior Call related behaviors * @param bool $behavior Call related behaviors
*
* @return int The link ID
*/ */
public function updLink(int $id, Cursor $cur, bool $behavior = true): int public function updLink(int $id, Cursor $cur, bool $behavior = true): void
{ {
if (empty($id)) { if (empty($id)) {
throw new Exception(__('No such link ID')); throw new Exception(__('No such link ID'));
@ -286,8 +283,6 @@ class Utils
# --BEHAVIOR-- cinecturlink2AfterUpdLink # --BEHAVIOR-- cinecturlink2AfterUpdLink
App::behavior()->callBehavior('cinecturlink2AfterUpdLink', $cur, $id); App::behavior()->callBehavior('cinecturlink2AfterUpdLink', $cur, $id);
} }
return $id;
} }
/** /**
@ -323,20 +318,18 @@ class Utils
{ {
$sql = new SelectStatement(); $sql = new SelectStatement();
$rs = $sql return $sql
->column($sql->max('link_id')) ->column($sql->max('link_id'))
->from($this->table) ->from($this->table)
->select(); ->select()
->f(0) + 1;
return is_null($rs) ? 1 : (int) $rs->f(0) + 1;
} }
/** /**
* Get categories. * Get categories.
* *
* @param array<string, mixed> $params Query params * @param array $params Query params
* @param bool $count_only Count only result * @param bool $count_only Count only result
*
* @return MetaRecord Record instance * @return MetaRecord Record instance
*/ */
public function getCategories(array $params = [], bool $count_only = false): MetaRecord public function getCategories(array $params = [], bool $count_only = false): MetaRecord
@ -458,10 +451,8 @@ class Utils
* *
* @param int $id Category ID * @param int $id Category ID
* @param Cursor $cur Cursor instance * @param Cursor $cur Cursor instance
*
* @return int The category ID
*/ */
public function updCategory(int $id, Cursor $cur): int public function updCategory(int $id, Cursor $cur): void
{ {
if (empty($id)) { if (empty($id)) {
throw new Exception(__('No such category ID')); throw new Exception(__('No such category ID'));
@ -476,8 +467,6 @@ class Utils
->update($cur); ->update($cur);
$this->trigger(); $this->trigger();
return $id;
} }
/** /**
@ -521,12 +510,11 @@ class Utils
{ {
$sql = new SelectStatement(); $sql = new SelectStatement();
$rs = $sql return $sql
->column($sql->max('cat_id')) ->column($sql->max('cat_id'))
->from($this->cat_table) ->from($this->cat_table)
->select(); ->select()
->f(0) + 1;
return is_null($rs) ? 1 : (int) $rs->f(0) + 1;
} }
/** /**
@ -538,13 +526,12 @@ class Utils
{ {
$sql = new SelectStatement(); $sql = new SelectStatement();
$rs = $sql return $sql
->column($sql->max('cat_pos')) ->column($sql->max('cat_pos'))
->from($this->cat_table) ->from($this->cat_table)
->where('blog_id = ' . $sql->quote($this->blog)) ->where('blog_id = ' . $sql->quote($this->blog))
->select(); ->select()
->f(0) + 1;
return is_null($rs) ? 1 : (int) $rs->f(0) + 1;
} }
/** /**
@ -582,15 +569,12 @@ class Utils
/** /**
* Get list of public directories. * Get list of public directories.
* *
* @return array<string, string> Directories * @return array<string,string> Directories
*/ */
public static function getPublicDirs(): array public static function getPublicDirs(): array
{ {
$dirs = []; $dirs = [];
$all = Files::getDirList(App::blog()->publicPath()); $all = Files::getDirList(App::blog()->publicPath());
if (empty($all['dirs'])) {
return $dirs;
}
foreach ($all['dirs'] as $dir) { foreach ($all['dirs'] as $dir) {
$dir = substr($dir, strlen(App::blog()->publicPath()) + 1); $dir = substr($dir, strlen(App::blog()->publicPath()) + 1);
$dirs[$dir] = $dir; $dirs[$dir] = $dir;

View File

@ -1,32 +0,0 @@
<?php
declare(strict_types=1);
namespace Dotclear\Plugin\cinecturlink2;
use Dotclear\Plugin\widgets\WidgetsElement;
/**
* @brief cinecturlink2 widget categories descriptor class.
* @ingroup cinecturlink2
*
* @author Jean-Christian Denis (author)
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
class WidgetCatsDescriptor
{
public readonly string $title;
public readonly string $class;
public readonly bool $content_only;
public readonly bool $shownumlink;
public function __construct(WidgetsElement $w)
{
$this->title = (string) $w->get('title');
$this->class = (string) $w->get('class');
$this->content_only = !empty($w->get('content_only'));
$this->shownumlink = !empty($w->get('shownumlink'));
}
}

View File

@ -1,48 +0,0 @@
<?php
declare(strict_types=1);
namespace Dotclear\Plugin\cinecturlink2;
use Dotclear\Plugin\widgets\WidgetsElement;
/**
* @brief cinecturlink2 widget links descriptor class.
* @ingroup cinecturlink2
*
* @author Jean-Christian Denis (author)
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
class WidgetLinksDescriptor
{
public readonly string $title;
public readonly string $class;
public readonly bool $content_only;
public readonly string $category;
public readonly string $sortby;
public readonly string $sort;
public readonly int $limit;
public readonly bool $shownote;
public readonly bool $showdesc;
public readonly bool $withlink;
public readonly bool $showauthor;
public readonly bool $showpagelink;
public function __construct(WidgetsElement $w)
{
$this->title = (string) $w->get('title');
$this->class = (string) $w->get('class');
$this->content_only = !empty($w->get('content_only'));
$this->category = (string) $w->get('category');
$this->sortby = (string) $w->get('sortby');
$this->sort = $w->get('sort') == 'desc' ? 'desc' : 'asc';
$this->limit = abs((int) $w->get('limit'));
$this->shownote = !empty($w->get('shownote'));
$this->showdesc = !empty($w->get('showdesc'));
$this->withlink = !empty($w->get('withlink'));
$this->showauthor = !empty($w->get('showauthor'));
$this->showpagelink = !empty($w->get('showpagelink'));
}
}

View File

@ -8,7 +8,6 @@ use Dotclear\App;
use Dotclear\Helper\Html\Html; use Dotclear\Helper\Html\Html;
use Dotclear\Plugin\widgets\WidgetsStack; use Dotclear\Plugin\widgets\WidgetsStack;
use Dotclear\Plugin\widgets\WidgetsElement; use Dotclear\Plugin\widgets\WidgetsElement;
use Exception;
/** /**
* @brief cinecturlink2 widgets class. * @brief cinecturlink2 widgets class.
@ -19,20 +18,6 @@ use Exception;
*/ */
class Widgets class Widgets
{ {
/**
* Widget cinecturlink links ID.
*
* @var string WIDGET_ID_LINKS
*/
private const WIDGET_ID_LINKS = 'cinecturlink2links';
/**
* Widget cinecturlink categories ID.
*
* @var string WIDGET_ID_CATS
*/
private const WIDGET_ID_CATS = 'cinecturlink2cats';
public static function init(WidgetsStack $w): void public static function init(WidgetsStack $w): void
{ {
$categories_combo = array_merge( $categories_combo = array_merge(
@ -54,7 +39,7 @@ class Widgets
$w $w
->create( ->create(
self::WIDGET_ID_LINKS, 'cinecturlink2links',
__('My cinecturlink'), __('My cinecturlink'),
self::parseLinks(...), self::parseLinks(...),
null, null,
@ -127,7 +112,7 @@ class Widgets
$w $w
->create( ->create(
self::WIDGET_ID_CATS, 'cinecturlink2cats',
__('List of categories of cinecturlink'), __('List of categories of cinecturlink'),
self::parseCats(...), self::parseCats(...),
null, null,
@ -154,29 +139,30 @@ class Widgets
->addOffline(); ->addOffline();
} }
public static function parseLinks(WidgetsElement $widget): string public static function parseLinks(WidgetsElement $w): string
{ {
if (!My::settings()->get('active') if (!My::settings()->avtive
|| !$widget->checkHomeOnly(App::url()->type) || !$w->checkHomeOnly(App::url()->type)
) { ) {
return ''; return '';
} }
$wdesc = new WidgetLinksDescriptor($widget); $C2 = new Utils();
$utils = new Utils();
$params = []; $params = [];
if ($wdesc->category) { if ($w->category) {
if ($wdesc->category == 'null') { if ($w->category == 'null') {
$params['sql'] = ' AND L.cat_id IS NULL '; $params['sql'] = ' AND L.cat_id IS NULL ';
} elseif (is_numeric($wdesc->category)) { } elseif (is_numeric($w->category)) {
$params['cat_id'] = (int) $wdesc->category; $params['cat_id'] = (int) $w->category;
} }
} }
$limit = abs((int) $w->limit);
// Tirage aléatoire: Consomme beaucoup de ressources! // Tirage aléatoire: Consomme beaucoup de ressources!
if ($wdesc->sortby == 'RANDOM') { if ($w->sortby == 'RANDOM') {
$big_rs = $utils->getLinks($params); $big_rs = $C2->getLinks($params);
if ($big_rs->isEmpty()) { if ($big_rs->isEmpty()) {
return ''; return '';
@ -187,93 +173,94 @@ class Widgets
$ids[] = $big_rs->link_id; $ids[] = $big_rs->link_id;
} }
shuffle($ids); shuffle($ids);
$ids = array_slice($ids, 0, $wdesc->limit); $ids = array_slice($ids, 0, $limit);
$params['link_id'] = []; $params['link_id'] = [];
foreach ($ids as $id) { foreach ($ids as $id) {
$params['link_id'][] = $id; $params['link_id'][] = $id;
} }
} elseif ($wdesc->sortby == 'COUNTER') { } elseif ($w->sortby == 'COUNTER') {
$params['order'] = 'link_count asc'; $params['order'] = 'link_count asc';
$params['limit'] = $wdesc->limit; $params['limit'] = $limit;
} else { } else {
$params['order'] = $wdesc->sortby . ' ' . $wdesc->sort; $params['order'] = $w->sortby;
$params['limit'] = $wdesc->limit; $params['order'] .= $w->sort == 'asc' ? ' asc' : ' desc';
$params['limit'] = $limit;
} }
$rs = $utils->getLinks($params); $rs = $C2->getLinks($params);
if ($rs->isEmpty()) { if ($rs->isEmpty()) {
return ''; return '';
} }
$widthmax = (int) My::settings()->get('widthmax'); $widthmax = (int) My::settings()->widthmax;
$style = $widthmax ? ' style="width:' . $widthmax . 'px;"' : ''; $style = $widthmax ? ' style="width:' . $widthmax . 'px;"' : '';
$entries = []; $entries = [];
while ($rs->fetch()) { while ($rs->fetch()) {
$row = new RecordLinksRow($rs); $url = $rs->link_url;
$img = $rs->link_img;
$title = Html::escapeHTML($rs->link_title);
$author = Html::escapeHTML($rs->link_author);
$cat = Html::escapeHTML($rs->cat_title);
$note = $w->shownote ? ' <em>(' . $rs->link_note . '/20)</em>' : '';
$desc = $w->showdesc ? '<br /><em>' . Html::escapeHTML($rs->link_desc) . '</em>' : '';
$lang = $rs->link_lang ? ' hreflang="' . $rs->link_lang . '"' : '';
$count = abs((int) $rs->link_count);
# --BEHAVIOR-- cinecturlink2WidgetLinks # --BEHAVIOR-- cinecturlink2WidgetLinks
$bhv = App::behavior()->callBehavior('cinecturlink2WidgetLinks', $row->link_id); $bhv = App::behavior()->callBehavior('cinecturlink2WidgetLinks', $rs->link_id);
$tmp = ''; $entries[] = '<p style="text-align:center;">' .
if ($wdesc->withlink && !empty($row->link_url)) { ($w->withlink && !empty($url) ? '<a href="' . $url . '"' . $lang . ' title="' . $cat . '">' : '') .
$tmp .= '<a href="' . $row->link_url . '"' . ($row->link_lang ? ' hreflang="' . $row->link_lang . '"' : '') . ' title="' . Html::escapeHTML($row->cat_title) . '">'; '<strong>' . $title . '</strong>' . $note . '<br />' .
} ($w->showauthor ? $author . '<br />' : '') . '<br />' .
$tmp .= '<strong>' . Html::escapeHTML($row->link_title) . '</strong>' . ($wdesc->shownote ? ' <em>(' . $row->link_note . '/20)</em>' : '') . '<br />'; '<img src="' . $img . '" alt="' . $title . ' - ' . $author . '"' . $style . ' />' .
if ($wdesc->showauthor) { $desc .
$tmp .= Html::escapeHTML($row->link_author) . '<br />'; ($w->withlink && !empty($url) ? '</a>' : '') .
} '</p>' . $bhv;
$tmp .= '<br /><img src="' . $row->link_img . '" alt="' . Html::escapeHTML($row->link_title) . ' - ' . Html::escapeHTML($row->link_author) . '"' . $style . ' />';
if ($wdesc->showdesc) {
$tmp .= '<br /><em>' . Html::escapeHTML($row->link_desc) . '</em>';
}
if ($wdesc->withlink && !empty($row->link_url)) {
$tmp .= '</a>';
}
$entries[] = '<p style="text-align:center;">' . $tmp . '</p>' . $bhv;
try { try {
$cur = App::con()->openCursor($utils->table); $cur = App::con()->openCursor($C2->table);
$cur->setField('link_count', ($row->link_count + 1)); $cur->link_count = ($count + 1);
$utils->updLink($row->link_id, $cur, false); $C2->updLink((int) $rs->link_id, $cur, false);
} catch (Exception) { } catch (Exception $e) {
} }
} }
# Tirage aléatoire # Tirage aléatoire
if (in_array($wdesc->sortby, ['RANDOM', 'COUNTER'])) { if ($w->sortby == 'RANDOM'
|| $w->sortby == 'COUNTER'
) {
shuffle($entries); shuffle($entries);
if (My::settings()->get('triggeronrandom')) { if (My::settings()->triggeronrandom) {
App::blog()->triggerBlog(); App::blog()->triggerBlog();
} }
} }
return $widget->renderDiv( return $w->renderDiv(
$wdesc->content_only, (bool) $w->content_only,
$widget->id() . ' ' . $wdesc->class, 'cinecturlink2list ' . $w->class,
'', '',
($wdesc->title ? $widget->renderTitle(Html::escapeHTML($wdesc->title)) : '') . implode(' ', $entries) . ($w->title ? $w->renderTitle(Html::escapeHTML($w->title)) : '') . implode(' ', $entries) .
( (
$wdesc->showpagelink && My::settings()->get('public_active') ? $w->showpagelink && My::settings()->public_active ?
'<p><a href="' . App::blog()->url() . 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>' : ''
) )
); );
} }
public static function parseCats(WidgetsElement $widget): string public static function parseCats(WidgetsElement $w): string
{ {
if (!My::settings()->get('active') if (!My::settings()->avtive
|| !My::settings()->get('public_active') || !My::settings()->public_active
|| !$widget->checkHomeOnly(App::url()->type) || !$w->checkHomeOnly(App::url()->type)
) { ) {
return ''; return '';
} }
$wdesc = new WidgetCatsDescriptor($widget); $C2 = new Utils();
$utils = new Utils(); $rs = $C2->getCategories([]);
$rs = $utils->getCategories([]);
if ($rs->isEmpty()) { if ($rs->isEmpty()) {
return ''; return '';
} }
@ -282,28 +269,26 @@ class Widgets
$res[] = '<li><a href="' . $res[] = '<li><a href="' .
App::blog()->url() . App::url()->getBase(My::id()) . App::blog()->url() . App::url()->getBase(My::id()) .
'" title="' . __('view all links') . '">' . __('all links') . '" title="' . __('view all links') . '">' . __('all links') .
'</a>' . ($wdesc->shownumlink ? ' (' . ($utils->getLinks([], true)->f(0)) . ')' : '') . '</a>' . ($w->shownumlink ? ' (' . ($C2->getLinks([], true)->f(0)) . ')' : '') .
'</li>'; '</li>';
while ($rs->fetch()) { while ($rs->fetch()) {
$row = new RecordCatsRow($rs);
$res[] = '<li><a href="' . $res[] = '<li><a href="' .
App::blog()->url() . App::url()->getBase('cinecturlink2') . '/' . App::blog()->url() . App::url()->getBase('cinecturlink2') . '/' .
My::settings()->get('public_caturl') . '/' . My::settings()->public_caturl . '/' .
urlencode($row->cat_title) . urlencode($rs->cat_title) .
'" title="' . __('view links of this category') . '">' . '" title="' . __('view links of this category') . '">' .
Html::escapeHTML($row->cat_title) . Html::escapeHTML($rs->cat_title) .
'</a>' . ($wdesc->shownumlink ? ' (' . '</a>' . ($w->shownumlink ? ' (' .
($utils->getLinks(['cat_id' => $row->cat_id], true)->f(0)) . ')' : '') . ($C2->getLinks(['cat_id' => $rs->cat_id], true)->f(0)) . ')' : '') .
'</li>'; '</li>';
} }
return $widget->renderDiv( return $w->renderDiv(
$wdesc->content_only, (bool) $w->content_only,
$widget->id() . ' ' . $wdesc->class, 'cinecturlink2cat ' . $w->class,
'', '',
($wdesc->title ? $widget->renderTitle(Html::escapeHTML($wdesc->title)) : '') . ($w->title ? $w->renderTitle(Html::escapeHTML($w->title)) : '') .
'<ul>' . implode(' ', $res) . '</ul>' '<ul>' . implode(' ', $res) . '</ul>'
); );
} }