code review
This commit is contained in:
parent
71e3de1834
commit
52a60eb47a
@ -1,3 +1,11 @@
|
|||||||
|
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
|
cinecturlink2 2.2 - 2023.10.18
|
||||||
===========================================================
|
===========================================================
|
||||||
* Require Dotclear 2.28
|
* Require Dotclear 2.28
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# README
|
# README
|
||||||
|
|
||||||
[![Release](https://img.shields.io/badge/release-2.2-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/cinecturlink2/releases)
|
[![Release](https://img.shields.io/badge/release-2.3-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/cinecturlink2/releases)
|
||||||
![Date](https://img.shields.io/badge/date-2023.10.18-c44d58.svg)]
|
![Date](https://img.shields.io/badge/date-2023.10.23-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.28-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)
|
||||||
|
@ -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.2',
|
'2.3',
|
||||||
[
|
[
|
||||||
'requires' => [['core', '2.28']],
|
'requires' => [['core', '2.28']],
|
||||||
'settings' => ['blog' => '#params.' . basename(__DIR__) . '_params'],
|
'settings' => ['blog' => '#params.' . basename(__DIR__) . '_params'],
|
||||||
|
@ -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.2</version>
|
<version>2.3</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.2/plugin-cinecturlink2.zip</file>
|
<file>https://git.dotclear.watch/JcDenis/cinecturlink2/releases/download/v2.3/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>
|
||||||
|
@ -65,35 +65,33 @@ class ActivityReportAction extends Process
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function addLink(Cursor $cur)
|
public static function addLink(Cursor $cur): void
|
||||||
{
|
{
|
||||||
$logs = [
|
$logs = [
|
||||||
$cur->link_title,
|
(string) $cur->getField('link_title'),
|
||||||
App::auth()->getInfo('user_cn'),
|
(string) App::auth()->getInfo('user_cn'),
|
||||||
];
|
];
|
||||||
ActivityReport::instance()->addLog('cinecturlink2', 'create', $logs);
|
ActivityReport::instance()->addLog('cinecturlink2', 'create', $logs);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function updLink(Cursor $cur, int $id)
|
public static function updLink(Cursor $cur, int $id): void
|
||||||
{
|
{
|
||||||
$C2 = new Utils();
|
$rs = (new Utils())->getLinks(['link_id' => $id]);
|
||||||
$rs = $C2->getLinks(['link_id' => $id]);
|
|
||||||
|
|
||||||
$logs = [
|
$logs = [
|
||||||
$rs->link_title,
|
(string) $rs->field('link_title'),
|
||||||
App::auth()->getInfo('user_cn'),
|
(string) App::auth()->getInfo('user_cn'),
|
||||||
];
|
];
|
||||||
ActivityReport::instance()->addLog('cinecturlink2', 'update', $logs);
|
ActivityReport::instance()->addLog('cinecturlink2', 'update', $logs);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function delLink(int $id)
|
public static function delLink(int $id): void
|
||||||
{
|
{
|
||||||
$C2 = new Utils();
|
$rs = (new Utils())->getLinks(['link_id' => $id]);
|
||||||
$rs = $C2->getLinks(['link_id' => $id]);
|
|
||||||
|
|
||||||
$logs = [
|
$logs = [
|
||||||
$rs->link_title,
|
(string) $rs->field('link_title'),
|
||||||
App::auth()->getInfo('user_cn'),
|
(string) App::auth()->getInfo('user_cn'),
|
||||||
];
|
];
|
||||||
ActivityReport::instance()->addLog('cinecturlink2', 'delete', $logs);
|
ActivityReport::instance()->addLog('cinecturlink2', 'delete', $logs);
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,12 @@ 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();
|
||||||
@ -92,7 +98,7 @@ class BackendActionsLinks extends Actions
|
|||||||
|
|
||||||
$rs = $this->utils->getLinks($params);
|
$rs = $this->utils->getLinks($params);
|
||||||
while ($rs->fetch()) {
|
while ($rs->fetch()) {
|
||||||
$this->entries[$rs->f('link_id')] = $rs->f('link_title');
|
$this->entries[(string) $rs->f('link_id')] = $rs->f('link_title');
|
||||||
}
|
}
|
||||||
$this->rs = $rs;
|
$this->rs = $rs;
|
||||||
} else {
|
} else {
|
||||||
|
@ -46,6 +46,9 @@ 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();
|
||||||
@ -57,7 +60,7 @@ class BackendActionsLinksDefault
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach ($ids as $id) {
|
foreach ($ids as $id) {
|
||||||
$ap->utils->delLink($id);
|
$ap->utils->delLink((int) $id);
|
||||||
}
|
}
|
||||||
|
|
||||||
Notices::addSuccessNotice(sprintf(
|
Notices::addSuccessNotice(sprintf(
|
||||||
@ -71,6 +74,9 @@ 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'])) {
|
||||||
@ -88,7 +94,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($id, $cur);
|
$ap->utils->updLink((int) $id, $cur);
|
||||||
}
|
}
|
||||||
|
|
||||||
Notices::addSuccessNotice(sprintf(
|
Notices::addSuccessNotice(sprintf(
|
||||||
@ -133,6 +139,9 @@ 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'])) {
|
||||||
@ -153,7 +162,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($id, $cur);
|
$ap->utils->updLink((int) $id, $cur);
|
||||||
}
|
}
|
||||||
|
|
||||||
Notices::addSuccessNotice(sprintf(
|
Notices::addSuccessNotice(sprintf(
|
||||||
|
@ -84,7 +84,7 @@ class BackendListingLinks extends Listing
|
|||||||
|
|
||||||
$lines = [];
|
$lines = [];
|
||||||
while ($this->rs->fetch()) {
|
while ($this->rs->fetch()) {
|
||||||
$lines[] = $this->linkLine(isset($links[$this->rs->link_id]));
|
$lines[] = $this->linkLine(new RecordLinksRow($this->rs), isset($links[$this->rs->f('link_id')]));
|
||||||
}
|
}
|
||||||
|
|
||||||
echo
|
echo
|
||||||
@ -112,60 +112,61 @@ class BackendListingLinks extends Listing
|
|||||||
$pager->getLinks();
|
$pager->getLinks();
|
||||||
}
|
}
|
||||||
|
|
||||||
private function linkLine(bool $checked): Para
|
private function linkLine(RecordLinksRow $row, 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($this->rs->link_id),
|
->value((string) $row->link_id),
|
||||||
]),
|
]),
|
||||||
'title' => (new Td())
|
'title' => (new Td())
|
||||||
->class('maximal')
|
->class('maximal')
|
||||||
->items([
|
->items([
|
||||||
(new Link())
|
(new Link())
|
||||||
->href(My::manageUrl(['part' => 'link', 'linkid' => $this->rs->link_id, 'redir' => $this->redir]))
|
->href(My::manageUrl(['part' => 'link', 'link_id' => $row->link_id, 'redir' => $this->redir]))
|
||||||
->title(__('Edit'))
|
->title(__('Edit'))
|
||||||
->text(Html::escapeHTML($this->rs->link_title)),
|
->text(Html::escapeHTML($row->link_title)),
|
||||||
]),
|
]),
|
||||||
'author' => (new Td())
|
'author' => (new Td())
|
||||||
->text(Html::escapeHTML($this->rs->link_author))
|
->text(Html::escapeHTML($row->link_author))
|
||||||
->class('nowrap'),
|
->class('nowrap'),
|
||||||
'desc' => (new Td())
|
'desc' => (new Td())
|
||||||
->text(Html::escapeHTML($this->rs->link_desc))
|
->text(Html::escapeHTML($row->link_desc))
|
||||||
->class('nowrap'),
|
->class('nowrap'),
|
||||||
'link' => (new Text('td'))
|
'link' => (new Td())
|
||||||
->separator(' ')
|
->separator(' ')
|
||||||
->items([
|
->items([
|
||||||
(new Link())
|
(new Link())
|
||||||
->href($this->rs->link_url)
|
->href($row->link_url)
|
||||||
->title(__('URL'))
|
->title(__('URL'))
|
||||||
->text(Html::escapeHTML($this->rs->link_title)),
|
->text(Html::escapeHTML($row->link_title)),
|
||||||
(new Link())
|
(new Link())
|
||||||
->href($this->rs->link_img)
|
->href($row->link_img)
|
||||||
->title(__('image'))
|
->title(__('image'))
|
||||||
->text(Html::escapeHTML($this->rs->link_title)),
|
->text(Html::escapeHTML($row->link_title)),
|
||||||
]),
|
])
|
||||||
|
->class('nowrap'),
|
||||||
'cat' => (new Td())
|
'cat' => (new Td())
|
||||||
->items([
|
->items([
|
||||||
(new Link())
|
(new Link())
|
||||||
->href(My::manageUrl(['part' => 'cat', 'catid' => $this->rs->cat_id, 'redir' => $this->redir]))
|
->href(My::manageUrl(['part' => 'cat', 'cat_id' => (string) $row->cat_id, 'redir' => $this->redir]))
|
||||||
->title(__('Edit'))
|
->title(__('Edit'))
|
||||||
->text(Html::escapeHTML($this->rs->cat_title)),
|
->text(Html::escapeHTML($row->cat_title)),
|
||||||
]),
|
]),
|
||||||
'note' => (new Td())
|
'note' => (new Td())
|
||||||
->text(Html::escapeHTML($this->rs->link_note))
|
->text(Html::escapeHTML($row->link_note))
|
||||||
->class('number'),
|
->class('number'),
|
||||||
'date' => (new Td())
|
'date' => (new Td())
|
||||||
->text(Html::escapeHTML(Date::dt2str(__('%Y-%m-%d %H:%M'), $this->rs->link_upddt, (string) App::auth()->getInfo('user_tz'))))
|
->text(Html::escapeHTML(Date::dt2str(__('%Y-%m-%d %H:%M'), $row->link_upddt, (string) App::auth()->getInfo('user_tz'))))
|
||||||
->class('nowrap'),
|
->class('nowrap'),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$this->userColumns(My::id(), $cols);
|
$this->userColumns(My::id(), $cols);
|
||||||
|
|
||||||
return
|
return
|
||||||
(new Para('p' . $this->rs->kut_id, 'tr'))
|
(new Para('p' . $row->link_id, 'tr'))
|
||||||
->class('line')
|
->class('line')
|
||||||
->items(iterator_to_array($cols));
|
->items(iterator_to_array($cols));
|
||||||
}
|
}
|
||||||
|
@ -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[$file->media_title] = $file->file_url;
|
$tmp[(string) $file->media_title] = (string) $file->file_url;
|
||||||
}
|
}
|
||||||
if (!empty($tmp)) {
|
if (!empty($tmp)) {
|
||||||
$stack = array_merge(['-' => ''], $tmp);
|
$stack = array_merge(['-' => ''], $tmp);
|
||||||
|
@ -96,7 +96,6 @@ 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(...));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,26 +15,26 @@ use Dotclear\App;
|
|||||||
*/
|
*/
|
||||||
class FrontendContext
|
class FrontendContext
|
||||||
{
|
{
|
||||||
public static function PaginationNbPages()
|
public static function PaginationNbPages(): int
|
||||||
{
|
{
|
||||||
if (App::frontend()->context()->c2_pagination === null) {
|
if (App::frontend()->context()->c2_pagination === null) {
|
||||||
return false;
|
return 0;
|
||||||
}
|
}
|
||||||
$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 $nb_pages;
|
return (int) $nb_pages;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function PaginationPosition($offset = 0)
|
public static function PaginationPosition(string|int $offset = 0): int
|
||||||
{
|
{
|
||||||
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 = $p + $offset;
|
$p = (int) $p + (int) $offset;
|
||||||
$n = self::PaginationNbPages();
|
$n = self::PaginationNbPages();
|
||||||
if (!$n) {
|
if (!$n) {
|
||||||
return $p;
|
return $p;
|
||||||
@ -43,25 +43,17 @@ class FrontendContext
|
|||||||
return $p > $n || $p <= 0 ? 1 : $p;
|
return $p > $n || $p <= 0 ? 1 : $p;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function PaginationStart()
|
public static function PaginationStart(): bool
|
||||||
{
|
{
|
||||||
if (isset($GLOBALS['c2_page_number'])) {
|
return isset($GLOBALS['c2_page_number']) ? self::PaginationPosition() == 1 : true;
|
||||||
return self::PaginationPosition() == 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function PaginationEnd()
|
public static function PaginationEnd(): bool
|
||||||
{
|
{
|
||||||
if (isset($GLOBALS['c2_page_number'])) {
|
return isset($GLOBALS['c2_page_number']) ? self::PaginationPosition() == self::PaginationNbPages() : false;
|
||||||
return self::PaginationPosition() == self::PaginationNbPages();
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function PaginationURL($offset = 0)
|
public static function PaginationURL(int|string $offset = 0): string
|
||||||
{
|
{
|
||||||
$args = $_SERVER['URL_REQUEST_PART'];
|
$args = $_SERVER['URL_REQUEST_PART'];
|
||||||
|
|
||||||
@ -84,7 +76,7 @@ class FrontendContext
|
|||||||
return $url;
|
return $url;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function categoryCurrent()
|
public static function categoryCurrent(): bool
|
||||||
{
|
{
|
||||||
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'])
|
||||||
|
@ -18,36 +18,57 @@ 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 = [];
|
||||||
@ -67,6 +88,9 @@ 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;
|
||||||
@ -113,16 +137,25 @@ 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 = [];
|
||||||
@ -137,96 +170,153 @@ 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);
|
||||||
@ -243,6 +333,9 @@ 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']) : '';
|
||||||
@ -260,11 +353,17 @@ 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" .
|
||||||
@ -275,16 +374,25 @@ 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 = [];
|
||||||
@ -301,11 +409,17 @@ 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
|
||||||
@ -317,16 +431,25 @@ 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 = [];
|
||||||
@ -343,6 +466,9 @@ 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';
|
||||||
@ -354,31 +480,49 @@ 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") . '; } ?>';
|
||||||
|
@ -17,7 +17,7 @@ use Dotclear\Helper\File\Path;
|
|||||||
*/
|
*/
|
||||||
class FrontendUrl extends Url
|
class FrontendUrl extends Url
|
||||||
{
|
{
|
||||||
public static function c2Page(?string $args)
|
public static function c2Page(?string $args): null
|
||||||
{
|
{
|
||||||
$args = (string) $args;
|
$args = (string) $args;
|
||||||
|
|
||||||
|
@ -32,9 +32,7 @@ use Exception;
|
|||||||
class ManageCat extends Process
|
class ManageCat extends Process
|
||||||
{
|
{
|
||||||
private static string $module_redir = '';
|
private static string $module_redir = '';
|
||||||
private static int $catid = 0;
|
private static RecordCatsRow $row;
|
||||||
private static string $cattitle = '';
|
|
||||||
private static string $catdesc = '';
|
|
||||||
|
|
||||||
public static function init(): bool
|
public static function init(): bool
|
||||||
{
|
{
|
||||||
@ -47,25 +45,18 @@ class ManageCat extends Process
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$utils = new Utils();
|
|
||||||
|
|
||||||
self::$module_redir = $_REQUEST['redir'] ?? '';
|
self::$module_redir = $_REQUEST['redir'] ?? '';
|
||||||
self::$catid = (int) ($_REQUEST['catid'] ?? 0);
|
self::$row = new RecordCatsRow();
|
||||||
self::$cattitle = $_POST['cattitle'] ?? '';
|
$utils = new Utils();
|
||||||
self::$catdesc = $_POST['catdesc'] ?? '';
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// create category
|
// create category
|
||||||
if (!empty($_POST['save']) && empty(self::$catid) && !empty(self::$cattitle) && !empty(self::$catdesc)) {
|
if (!empty($_POST['save']) && empty(self::$row->cat_id) && !empty(self::$row->cat_title) && !empty(self::$row->cat_desc)) {
|
||||||
$exists = $utils->getCategories(['cat_title' => self::$cattitle], true)->f(0);
|
$exists = $utils->getCategories(['cat_title' => self::$row->cat_title], 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.'));
|
||||||
}
|
}
|
||||||
$cur = App::con()->openCursor($utils->cat_table);
|
$cat_id = $utils->addCategory(self::$row->getCursor());
|
||||||
$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.')
|
||||||
@ -73,16 +64,12 @@ class ManageCat extends Process
|
|||||||
My::redirect(['part' => 'cats']);
|
My::redirect(['part' => 'cats']);
|
||||||
}
|
}
|
||||||
// update category
|
// update category
|
||||||
if (!empty($_POST['save']) && !empty(self::$catid) && !empty(self::$cattitle) && !empty(self::$catdesc)) {
|
if (!empty($_POST['save']) && !empty(self::$row->cat_id) && !empty(self::$row->cat_title) && !empty(self::$row->cat_desc)) {
|
||||||
$exists = $utils->getCategories(['cat_title' => self::$cattitle, 'exclude_cat_id' => self::$catid], true)->f(0);
|
$exists = $utils->getCategories(['cat_title' => self::$row->cat_title, 'exclude_cat_id' => self::$row->cat_id], 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.'));
|
||||||
}
|
}
|
||||||
$cur = App::con()->openCursor($C2->cat_table);
|
$cat_id = $utils->updCategory(self::$row->cat_id, self::$row->getCursor());
|
||||||
$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.')
|
||||||
@ -90,14 +77,20 @@ class ManageCat extends Process
|
|||||||
My::redirect(['part' => 'cats']);
|
My::redirect(['part' => 'cats']);
|
||||||
}
|
}
|
||||||
// delete category
|
// delete category
|
||||||
if (!empty($_POST['delete']) && !empty(self::$catid)) {
|
if (!empty($_POST['delete']) && !empty(self::$row->cat_id)) {
|
||||||
$utils->delCategory(self::$catid);
|
$utils->delCategory(self::$row->cat_id);
|
||||||
|
|
||||||
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());
|
||||||
}
|
}
|
||||||
@ -113,21 +106,13 @@ 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::$catid) ? __('New category') : __('Edit category')) => '',
|
(empty(self::$row->cat_id) ? __('New category') : __('Edit category')) => '',
|
||||||
]) .
|
]) .
|
||||||
Notices::getNotices();
|
Notices::getNotices();
|
||||||
|
|
||||||
@ -142,8 +127,8 @@ class ManageCat extends Process
|
|||||||
->render();
|
->render();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self::$catid) {
|
if (self::$row->cat_id) {
|
||||||
$links = (int) $utils->getLinks(['cat_id' => self::$catid], true)->f(0);
|
$links = (int) $utils->getLinks(['cat_id' => self::$row->cat_id], true)->f(0);
|
||||||
echo (new Note())
|
echo (new Note())
|
||||||
->class('info')
|
->class('info')
|
||||||
->text(
|
->text(
|
||||||
@ -161,20 +146,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('cattitle'),
|
->for('cat_title'),
|
||||||
(new Input('cattitle'))
|
(new Input('cat_title'))
|
||||||
->size(65)
|
->size(65)
|
||||||
->maxlength(64)
|
->maxlength(64)
|
||||||
->value(Html::escapeHTML(self::$cattitle)),
|
->value(Html::escapeHTML(self::$row->cat_title)),
|
||||||
]),
|
]),
|
||||||
(new Para())
|
(new Para())
|
||||||
->items([
|
->items([
|
||||||
(new Label(__('Description:'), Label::OUTSIDE_LABEL_BEFORE))
|
(new Label(__('Description:'), Label::OUTSIDE_LABEL_BEFORE))
|
||||||
->for('catdesc'),
|
->for('cat_desc'),
|
||||||
(new Input('catdesc'))
|
(new Input('cat_desc'))
|
||||||
->size(65)
|
->size(65)
|
||||||
->maxlength(64)
|
->maxlength(64)
|
||||||
->value(Html::escapeHTML(self::$catdesc)),
|
->value(Html::escapeHTML(self::$row->cat_desc)),
|
||||||
]),
|
]),
|
||||||
(new Para())
|
(new Para())
|
||||||
->class('border-top')
|
->class('border-top')
|
||||||
@ -194,9 +179,9 @@ class ManageCat extends Process
|
|||||||
->value(__('Delete') . ' (d)')
|
->value(__('Delete') . ' (d)')
|
||||||
->accesskey('d'),
|
->accesskey('d'),
|
||||||
... My::hiddenFields([
|
... My::hiddenFields([
|
||||||
'catid' => self::$catid,
|
'cat_id' => self::$row->cat_id,
|
||||||
'part' => 'cat',
|
'part' => 'cat',
|
||||||
'redir' => self::$module_redir,
|
'redir' => self::$module_redir,
|
||||||
]),
|
]),
|
||||||
]),
|
]),
|
||||||
])
|
])
|
||||||
|
@ -107,7 +107,8 @@ class ManageCats extends Process
|
|||||||
$items = [];
|
$items = [];
|
||||||
$i = 0;
|
$i = 0;
|
||||||
while ($categories->fetch()) {
|
while ($categories->fetch()) {
|
||||||
$id = $categories->f('cat_id');
|
$row = new RecordCatsRow($categories);
|
||||||
|
$id = (string) $row->cat_id;
|
||||||
|
|
||||||
$items[] = (new Tr('l_' . $i))
|
$items[] = (new Tr('l_' . $i))
|
||||||
->class('line')
|
->class('line')
|
||||||
@ -120,7 +121,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'), (string) $categories->f('cat_title')))),
|
->title(Html::escapeHTML(sprintf(__('position of %s'), $row->cat_title))),
|
||||||
(new Hidden(['dynorder[]', 'dynorder-' . $i], $id)),
|
(new Hidden(['dynorder[]', 'dynorder-' . $i], $id)),
|
||||||
]),
|
]),
|
||||||
(new Td())
|
(new Td())
|
||||||
@ -134,19 +135,19 @@ class ManageCats extends Process
|
|||||||
->items([
|
->items([
|
||||||
(new Link())
|
(new Link())
|
||||||
->href(My::manageUrl([
|
->href(My::manageUrl([
|
||||||
'part' => 'cat',
|
'part' => 'cat',
|
||||||
'catid' => $id,
|
'cat_id' => $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((string) $categories->f('cat_title'))),
|
->text(Html::escapeHTML($row->cat_title)),
|
||||||
]),
|
]),
|
||||||
(new Td())
|
(new Td())
|
||||||
->class('maximal')
|
->class('maximal')
|
||||||
->text(Html::escapeHTML((string) $categories->f('cat_desc'))),
|
->text(Html::escapeHTML($row->cat_desc)),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$i++;
|
$i++;
|
||||||
@ -187,7 +188,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 Link')),
|
->text(__('New Category')),
|
||||||
])
|
])
|
||||||
->render();
|
->render();
|
||||||
|
|
||||||
|
@ -36,15 +36,7 @@ use Exception;
|
|||||||
class ManageLink extends Process
|
class ManageLink extends Process
|
||||||
{
|
{
|
||||||
private static string $module_redir = '';
|
private static string $module_redir = '';
|
||||||
private static int $linkid = 0;
|
private static RecordLinksRow $row;
|
||||||
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
|
||||||
{
|
{
|
||||||
@ -57,18 +49,9 @@ class ManageLink extends Process
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$utils = new Utils();
|
|
||||||
|
|
||||||
self::$module_redir = $_REQUEST['redir'] ?? '';
|
self::$module_redir = $_REQUEST['redir'] ?? '';
|
||||||
self::$linkid = (int) ($_REQUEST['linkid'] ?? 0);
|
self::$row = new RecordLinksRow();
|
||||||
self::$linktitle = $_POST['linktitle'] ?? '';
|
$utils = new Utils();
|
||||||
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 {
|
||||||
@ -76,44 +59,34 @@ class ManageLink extends Process
|
|||||||
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::$linktitle)) {
|
if (empty(self::$row->link_title)) {
|
||||||
throw new Exception(__('You must provide a title.'));
|
throw new Exception(__('You must provide a title.'));
|
||||||
}
|
}
|
||||||
if (empty(self::$linkauthor)) {
|
if (empty(self::$row->link_author)) {
|
||||||
throw new Exception(__('You must provide an author.'));
|
throw new Exception(__('You must provide an author.'));
|
||||||
}
|
}
|
||||||
if (!preg_match('/https?:\/\/.+/', self::$linkimage)) {
|
if (!preg_match('/https?:\/\/.+/', self::$row->link_img)) {
|
||||||
//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 (empty(self::$linkid)) {
|
if (!self::$row->link_id) {
|
||||||
$exists = $utils->getLinks(['link_title' => self::$linktitle], true)->f(0);
|
$exists = $utils->getLinks(['link_title' => self::$row->link_title], 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.'));
|
||||||
}
|
}
|
||||||
self::$linkid = $utils->addLink($cur);
|
$link_id = $utils->addLink(self::$row->getCursor());
|
||||||
|
|
||||||
Notices::addSuccessNotice(
|
Notices::addSuccessNotice(
|
||||||
__('Link successfully created.')
|
__('Link successfully created.')
|
||||||
);
|
);
|
||||||
// update a link
|
// update a link
|
||||||
} else {
|
} else {
|
||||||
$exists = $utils->getLinks(['link_id' => self::$linkid], true)->f(0);
|
$exists = $utils->getLinks(['link_id' => self::$row->link_id], true)->f(0);
|
||||||
if (!$exists) {
|
if (!$exists) {
|
||||||
throw new Exception(__('Unknown link.'));
|
throw new Exception(__('Unknown link.'));
|
||||||
}
|
}
|
||||||
$utils->updLink(self::$linkid, $cur);
|
$link_id = $utils->updLink(self::$row->link_id, self::$row->getCursor());
|
||||||
|
|
||||||
Notices::addSuccessNotice(
|
Notices::addSuccessNotice(
|
||||||
__('Link successfully updated.')
|
__('Link successfully updated.')
|
||||||
@ -121,9 +94,9 @@ class ManageLink extends Process
|
|||||||
}
|
}
|
||||||
My::redirect(
|
My::redirect(
|
||||||
[
|
[
|
||||||
'part' => 'link',
|
'part' => 'link',
|
||||||
'linkid' => self::$linkid,
|
'link_id' => $link_id,
|
||||||
'redir' => self::$module_redir,
|
'redir' => self::$module_redir,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
@ -131,9 +104,9 @@ class ManageLink extends Process
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($_POST['delete']) && !empty(self::$linkid)) {
|
if (!empty($_POST['delete']) && self::$row->link_id) {
|
||||||
try {
|
try {
|
||||||
$utils->delLink(self::$linkid);
|
$utils->delLink(self::$row->link_id);
|
||||||
|
|
||||||
Notices::addSuccessNotice(
|
Notices::addSuccessNotice(
|
||||||
__('Link successfully deleted.')
|
__('Link successfully deleted.')
|
||||||
@ -148,18 +121,10 @@ class ManageLink extends Process
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty(self::$linkid)) {
|
if (self::$row->link_id) {
|
||||||
$link = $utils->getLinks(['link_id' => self::$linkid]);
|
self::$row = new RecordLinksRow(
|
||||||
if (!$link->isEmpty()) {
|
$utils->getLinks(['link_id' => self::$row->link_id])
|
||||||
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;
|
||||||
@ -181,9 +146,9 @@ class ManageLink extends Process
|
|||||||
|
|
||||||
echo
|
echo
|
||||||
Page::breadcrumb([
|
Page::breadcrumb([
|
||||||
__('Plugins') => '',
|
__('Plugins') => '',
|
||||||
My::name() => My::manageUrl(),
|
My::name() => My::manageUrl(),
|
||||||
(empty(self::$linkid) ? __('New link') : __('Edit link')) => '',
|
(empty(self::$row->link_id) ? __('New link') : __('Edit link')) => '',
|
||||||
]) .
|
]) .
|
||||||
Notices::getNotices();
|
Notices::getNotices();
|
||||||
|
|
||||||
@ -213,38 +178,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('linktitle'),
|
->for('link_title'),
|
||||||
(new Input('linktitle'))
|
(new Input('link_title'))
|
||||||
->size(65)
|
->size(65)
|
||||||
->maxlength(255)
|
->maxlength(255)
|
||||||
->value(Html::escapeHTML(self::$linktitle)),
|
->value(Html::escapeHTML(self::$row->link_title)),
|
||||||
]),
|
]),
|
||||||
(new Para())
|
(new Para())
|
||||||
->items([
|
->items([
|
||||||
(new Label(__('Description:'), Label::OUTSIDE_LABEL_BEFORE))
|
(new Label(__('Description:'), Label::OUTSIDE_LABEL_BEFORE))
|
||||||
->for('linkdesc'),
|
->for('link_desc'),
|
||||||
(new Input('linkdesc'))
|
(new Input('link_desc'))
|
||||||
->size(65)
|
->size(65)
|
||||||
->maxlength(255)
|
->maxlength(255)
|
||||||
->value(Html::escapeHTML(self::$linkdesc)),
|
->value(Html::escapeHTML(self::$row->link_desc)),
|
||||||
]),
|
]),
|
||||||
(new Para())
|
(new Para())
|
||||||
->items([
|
->items([
|
||||||
(new Label(__('Author:'), Label::OUTSIDE_LABEL_BEFORE))
|
(new Label(__('Author:'), Label::OUTSIDE_LABEL_BEFORE))
|
||||||
->for('linkauthor'),
|
->for('link_author'),
|
||||||
(new Input('linkauthor'))
|
(new Input('link_author'))
|
||||||
->size(65)
|
->size(65)
|
||||||
->maxlength(255)
|
->maxlength(255)
|
||||||
->value(Html::escapeHTML(self::$linkauthor)),
|
->value(Html::escapeHTML(self::$row->link_author)),
|
||||||
]),
|
]),
|
||||||
(new Para())
|
(new Para())
|
||||||
->items([
|
->items([
|
||||||
(new Label(__('Details URL:'), Label::OUTSIDE_LABEL_BEFORE))
|
(new Label(__('Details URL:'), Label::OUTSIDE_LABEL_BEFORE))
|
||||||
->for('linkurl'),
|
->for('link_url'),
|
||||||
(new Input('linkurl'))
|
(new Input('link_url'))
|
||||||
->size(65)
|
->size(65)
|
||||||
->maxlength(255)
|
->maxlength(255)
|
||||||
->value(Html::escapeHTML(self::$linkurl)),
|
->value(Html::escapeHTML(self::$row->link_url)),
|
||||||
(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')
|
||||||
@ -254,11 +219,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('linkimage'),
|
->for('link_img'),
|
||||||
(new Input('linkimage'))
|
(new Input('link_img'))
|
||||||
->size(65)
|
->size(65)
|
||||||
->maxlength(255)
|
->maxlength(255)
|
||||||
->value(Html::escapeHTML(self::$linkimage)),
|
->value(Html::escapeHTML(self::$row->link_img)),
|
||||||
(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')
|
||||||
@ -296,27 +261,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('linkcat'),
|
->for('cat_id'),
|
||||||
(new Select('linkcat'))
|
(new Select('cat_id'))
|
||||||
->items(Combo::categoriesCombo())
|
->items(Combo::categoriesCombo())
|
||||||
->default(self::$linkcat),
|
->default((string) self::$row->cat_id),
|
||||||
]),
|
]),
|
||||||
(new Para())
|
(new Para())
|
||||||
->items([
|
->items([
|
||||||
(new Label(__('Lang:'), Label::OUTSIDE_LABEL_BEFORE))
|
(new Label(__('Lang:'), Label::OUTSIDE_LABEL_BEFORE))
|
||||||
->for('linklang'),
|
->for('link_lang'),
|
||||||
(new Select('linklang'))
|
(new Select('link_lang'))
|
||||||
->items(Combo::langsCombo())
|
->items(Combo::langsCombo())
|
||||||
->default(self::$linklang),
|
->default(self::$row->link_lang),
|
||||||
]),
|
]),
|
||||||
(new Para())
|
(new Para())
|
||||||
->items([
|
->items([
|
||||||
(new Label(__('Rating:'), Label::OUTSIDE_LABEL_BEFORE))
|
(new Label(__('Rating:'), Label::OUTSIDE_LABEL_BEFORE))
|
||||||
->for('linknote'),
|
->for('link_note'),
|
||||||
(new Number('linknote'))
|
(new Number('link_note'))
|
||||||
->min(0)
|
->min(0)
|
||||||
->max(20)
|
->max(20)
|
||||||
->value(self::$linknote),
|
->value(self::$row->link_note),
|
||||||
]),
|
]),
|
||||||
]),
|
]),
|
||||||
]),
|
]),
|
||||||
@ -338,9 +303,9 @@ class ManageLink extends Process
|
|||||||
->value(__('Delete') . ' (d)')
|
->value(__('Delete') . ' (d)')
|
||||||
->accesskey('d'),
|
->accesskey('d'),
|
||||||
... My::hiddenFields([
|
... My::hiddenFields([
|
||||||
'linkid' => self::$linkid,
|
'link_id' => self::$row->link_id,
|
||||||
'part' => 'link',
|
'part' => 'link',
|
||||||
'redir' => self::$module_redir,
|
'redir' => self::$module_redir,
|
||||||
]),
|
]),
|
||||||
]),
|
]),
|
||||||
]),
|
]),
|
||||||
|
@ -10,7 +10,6 @@ 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
|
||||||
@ -40,7 +39,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 Listing $module_listing;
|
private static BackendListingLinks $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;
|
||||||
|
|
||||||
@ -67,7 +66,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(
|
||||||
'catid',
|
'cat_id',
|
||||||
__('Category:'),
|
__('Category:'),
|
||||||
Combo::categoriesCombo(),
|
Combo::categoriesCombo(),
|
||||||
'cat_id'
|
'cat_id'
|
||||||
@ -171,7 +170,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)),
|
||||||
|
@ -17,14 +17,14 @@ use Dotclear\Module\MyPlugin;
|
|||||||
class My extends MyPlugin
|
class My extends MyPlugin
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Link table name.
|
* Links table name.
|
||||||
*
|
*
|
||||||
* @var string CINECTURLINK_TABLE_NAME
|
* @var string CINECTURLINK_TABLE_NAME
|
||||||
*/
|
*/
|
||||||
public const CINECTURLINK_TABLE_NAME = 'cinecturlink2';
|
public const CINECTURLINK_TABLE_NAME = 'cinecturlink2';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Category table name.
|
* Categories table name.
|
||||||
*
|
*
|
||||||
* @var string CATEGORY_TABLE_NAME
|
* @var string CATEGORY_TABLE_NAME
|
||||||
*/
|
*/
|
||||||
|
@ -4,23 +4,30 @@ 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($sitemaps)
|
public static function sitemapsURLsCollect(Sitemap $sitemaps): void
|
||||||
{
|
{
|
||||||
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')
|
||||||
@ -34,7 +41,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($cats->cat_title), $prio, $freq);
|
$sitemaps->addEntry($base . '/' . My::settings()->get('public_caturl') . '/' . urlencode((string) $cats->field('cat_title')), $prio, $freq);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
41
src/RecordCatsRow.php
Normal file
41
src/RecordCatsRow.php
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
<?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;
|
||||||
|
}
|
||||||
|
}
|
63
src/RecordLinksRow.php
Normal file
63
src/RecordLinksRow.php
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
<?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;
|
||||||
|
}
|
||||||
|
}
|
@ -72,8 +72,9 @@ class Utils
|
|||||||
/**
|
/**
|
||||||
* Get links.
|
* Get links.
|
||||||
*
|
*
|
||||||
* @param array $params Query params
|
* @param array<string, mixed> $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
|
||||||
@ -264,8 +265,10 @@ 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): void
|
public function updLink(int $id, Cursor $cur, bool $behavior = true): int
|
||||||
{
|
{
|
||||||
if (empty($id)) {
|
if (empty($id)) {
|
||||||
throw new Exception(__('No such link ID'));
|
throw new Exception(__('No such link ID'));
|
||||||
@ -283,6 +286,8 @@ class Utils
|
|||||||
# --BEHAVIOR-- cinecturlink2AfterUpdLink
|
# --BEHAVIOR-- cinecturlink2AfterUpdLink
|
||||||
App::behavior()->callBehavior('cinecturlink2AfterUpdLink', $cur, $id);
|
App::behavior()->callBehavior('cinecturlink2AfterUpdLink', $cur, $id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -318,18 +323,20 @@ class Utils
|
|||||||
{
|
{
|
||||||
$sql = new SelectStatement();
|
$sql = new SelectStatement();
|
||||||
|
|
||||||
return $sql
|
$rs = $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 $params Query params
|
* @param array<string, mixed> $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
|
||||||
@ -451,8 +458,10 @@ 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): void
|
public function updCategory(int $id, Cursor $cur): int
|
||||||
{
|
{
|
||||||
if (empty($id)) {
|
if (empty($id)) {
|
||||||
throw new Exception(__('No such category ID'));
|
throw new Exception(__('No such category ID'));
|
||||||
@ -467,6 +476,8 @@ class Utils
|
|||||||
->update($cur);
|
->update($cur);
|
||||||
|
|
||||||
$this->trigger();
|
$this->trigger();
|
||||||
|
|
||||||
|
return $id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -510,11 +521,12 @@ class Utils
|
|||||||
{
|
{
|
||||||
$sql = new SelectStatement();
|
$sql = new SelectStatement();
|
||||||
|
|
||||||
return $sql
|
$rs = $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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -526,12 +538,13 @@ class Utils
|
|||||||
{
|
{
|
||||||
$sql = new SelectStatement();
|
$sql = new SelectStatement();
|
||||||
|
|
||||||
return $sql
|
$rs = $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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -569,12 +582,15 @@ 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;
|
||||||
|
32
src/WidgetCatsDescriptor.php
Normal file
32
src/WidgetCatsDescriptor.php
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
<?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'));
|
||||||
|
}
|
||||||
|
}
|
48
src/WidgetLinksDescriptor.php
Normal file
48
src/WidgetLinksDescriptor.php
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
<?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'));
|
||||||
|
}
|
||||||
|
}
|
153
src/Widgets.php
153
src/Widgets.php
@ -8,6 +8,7 @@ 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.
|
||||||
@ -18,6 +19,20 @@ use Dotclear\Plugin\widgets\WidgetsElement;
|
|||||||
*/
|
*/
|
||||||
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(
|
||||||
@ -39,7 +54,7 @@ class Widgets
|
|||||||
|
|
||||||
$w
|
$w
|
||||||
->create(
|
->create(
|
||||||
'cinecturlink2links',
|
self::WIDGET_ID_LINKS,
|
||||||
__('My cinecturlink'),
|
__('My cinecturlink'),
|
||||||
self::parseLinks(...),
|
self::parseLinks(...),
|
||||||
null,
|
null,
|
||||||
@ -112,7 +127,7 @@ class Widgets
|
|||||||
|
|
||||||
$w
|
$w
|
||||||
->create(
|
->create(
|
||||||
'cinecturlink2cats',
|
self::WIDGET_ID_CATS,
|
||||||
__('List of categories of cinecturlink'),
|
__('List of categories of cinecturlink'),
|
||||||
self::parseCats(...),
|
self::parseCats(...),
|
||||||
null,
|
null,
|
||||||
@ -139,30 +154,29 @@ class Widgets
|
|||||||
->addOffline();
|
->addOffline();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function parseLinks(WidgetsElement $w): string
|
public static function parseLinks(WidgetsElement $widget): string
|
||||||
{
|
{
|
||||||
if (!My::settings()->avtive
|
if (!My::settings()->get('active')
|
||||||
|| !$w->checkHomeOnly(App::url()->type)
|
|| !$widget->checkHomeOnly(App::url()->type)
|
||||||
) {
|
) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
$C2 = new Utils();
|
$wdesc = new WidgetLinksDescriptor($widget);
|
||||||
|
$utils = new Utils();
|
||||||
$params = [];
|
$params = [];
|
||||||
|
|
||||||
if ($w->category) {
|
if ($wdesc->category) {
|
||||||
if ($w->category == 'null') {
|
if ($wdesc->category == 'null') {
|
||||||
$params['sql'] = ' AND L.cat_id IS NULL ';
|
$params['sql'] = ' AND L.cat_id IS NULL ';
|
||||||
} elseif (is_numeric($w->category)) {
|
} elseif (is_numeric($wdesc->category)) {
|
||||||
$params['cat_id'] = (int) $w->category;
|
$params['cat_id'] = (int) $wdesc->category;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$limit = abs((int) $w->limit);
|
|
||||||
|
|
||||||
// Tirage aléatoire: Consomme beaucoup de ressources!
|
// Tirage aléatoire: Consomme beaucoup de ressources!
|
||||||
if ($w->sortby == 'RANDOM') {
|
if ($wdesc->sortby == 'RANDOM') {
|
||||||
$big_rs = $C2->getLinks($params);
|
$big_rs = $utils->getLinks($params);
|
||||||
|
|
||||||
if ($big_rs->isEmpty()) {
|
if ($big_rs->isEmpty()) {
|
||||||
return '';
|
return '';
|
||||||
@ -173,94 +187,93 @@ class Widgets
|
|||||||
$ids[] = $big_rs->link_id;
|
$ids[] = $big_rs->link_id;
|
||||||
}
|
}
|
||||||
shuffle($ids);
|
shuffle($ids);
|
||||||
$ids = array_slice($ids, 0, $limit);
|
$ids = array_slice($ids, 0, $wdesc->limit);
|
||||||
|
|
||||||
$params['link_id'] = [];
|
$params['link_id'] = [];
|
||||||
foreach ($ids as $id) {
|
foreach ($ids as $id) {
|
||||||
$params['link_id'][] = $id;
|
$params['link_id'][] = $id;
|
||||||
}
|
}
|
||||||
} elseif ($w->sortby == 'COUNTER') {
|
} elseif ($wdesc->sortby == 'COUNTER') {
|
||||||
$params['order'] = 'link_count asc';
|
$params['order'] = 'link_count asc';
|
||||||
$params['limit'] = $limit;
|
$params['limit'] = $wdesc->limit;
|
||||||
} else {
|
} else {
|
||||||
$params['order'] = $w->sortby;
|
$params['order'] = $wdesc->sortby . ' ' . $wdesc->sort;
|
||||||
$params['order'] .= $w->sort == 'asc' ? ' asc' : ' desc';
|
$params['limit'] = $wdesc->limit;
|
||||||
$params['limit'] = $limit;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$rs = $C2->getLinks($params);
|
$rs = $utils->getLinks($params);
|
||||||
|
|
||||||
if ($rs->isEmpty()) {
|
if ($rs->isEmpty()) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
$widthmax = (int) My::settings()->widthmax;
|
$widthmax = (int) My::settings()->get('widthmax');
|
||||||
$style = $widthmax ? ' style="width:' . $widthmax . 'px;"' : '';
|
$style = $widthmax ? ' style="width:' . $widthmax . 'px;"' : '';
|
||||||
|
|
||||||
$entries = [];
|
$entries = [];
|
||||||
while ($rs->fetch()) {
|
while ($rs->fetch()) {
|
||||||
$url = $rs->link_url;
|
$row = new RecordLinksRow($rs);
|
||||||
$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', $rs->link_id);
|
$bhv = App::behavior()->callBehavior('cinecturlink2WidgetLinks', $row->link_id);
|
||||||
|
|
||||||
$entries[] = '<p style="text-align:center;">' .
|
$tmp = '';
|
||||||
($w->withlink && !empty($url) ? '<a href="' . $url . '"' . $lang . ' title="' . $cat . '">' : '') .
|
if ($wdesc->withlink && !empty($row->link_url)) {
|
||||||
'<strong>' . $title . '</strong>' . $note . '<br />' .
|
$tmp .= '<a href="' . $row->link_url . '"' . ($row->link_lang ? ' hreflang="' . $row->link_lang . '"' : '') . ' title="' . Html::escapeHTML($row->cat_title) . '">';
|
||||||
($w->showauthor ? $author . '<br />' : '') . '<br />' .
|
}
|
||||||
'<img src="' . $img . '" alt="' . $title . ' - ' . $author . '"' . $style . ' />' .
|
$tmp .= '<strong>' . Html::escapeHTML($row->link_title) . '</strong>' . ($wdesc->shownote ? ' <em>(' . $row->link_note . '/20)</em>' : '') . '<br />';
|
||||||
$desc .
|
if ($wdesc->showauthor) {
|
||||||
($w->withlink && !empty($url) ? '</a>' : '') .
|
$tmp .= Html::escapeHTML($row->link_author) . '<br />';
|
||||||
'</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($C2->table);
|
$cur = App::con()->openCursor($utils->table);
|
||||||
$cur->link_count = ($count + 1);
|
$cur->setField('link_count', ($row->link_count + 1));
|
||||||
$C2->updLink((int) $rs->link_id, $cur, false);
|
$utils->updLink($row->link_id, $cur, false);
|
||||||
} catch (Exception $e) {
|
} catch (Exception) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
# Tirage aléatoire
|
# Tirage aléatoire
|
||||||
if ($w->sortby == 'RANDOM'
|
if (in_array($wdesc->sortby, ['RANDOM', 'COUNTER'])) {
|
||||||
|| $w->sortby == 'COUNTER'
|
|
||||||
) {
|
|
||||||
shuffle($entries);
|
shuffle($entries);
|
||||||
if (My::settings()->triggeronrandom) {
|
if (My::settings()->get('triggeronrandom')) {
|
||||||
App::blog()->triggerBlog();
|
App::blog()->triggerBlog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $w->renderDiv(
|
return $widget->renderDiv(
|
||||||
(bool) $w->content_only,
|
$wdesc->content_only,
|
||||||
'cinecturlink2list ' . $w->class,
|
$widget->id() . ' ' . $wdesc->class,
|
||||||
'',
|
'',
|
||||||
($w->title ? $w->renderTitle(Html::escapeHTML($w->title)) : '') . implode(' ', $entries) .
|
($wdesc->title ? $widget->renderTitle(Html::escapeHTML($wdesc->title)) : '') . implode(' ', $entries) .
|
||||||
(
|
(
|
||||||
$w->showpagelink && My::settings()->public_active ?
|
$wdesc->showpagelink && My::settings()->get('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 $w): string
|
public static function parseCats(WidgetsElement $widget): string
|
||||||
{
|
{
|
||||||
if (!My::settings()->avtive
|
if (!My::settings()->get('active')
|
||||||
|| !My::settings()->public_active
|
|| !My::settings()->get('public_active')
|
||||||
|| !$w->checkHomeOnly(App::url()->type)
|
|| !$widget->checkHomeOnly(App::url()->type)
|
||||||
) {
|
) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
$C2 = new Utils();
|
$wdesc = new WidgetCatsDescriptor($widget);
|
||||||
$rs = $C2->getCategories([]);
|
$utils = new Utils();
|
||||||
|
$rs = $utils->getCategories([]);
|
||||||
if ($rs->isEmpty()) {
|
if ($rs->isEmpty()) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
@ -269,26 +282,28 @@ 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>' . ($w->shownumlink ? ' (' . ($C2->getLinks([], true)->f(0)) . ')' : '') .
|
'</a>' . ($wdesc->shownumlink ? ' (' . ($utils->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()->public_caturl . '/' .
|
My::settings()->get('public_caturl') . '/' .
|
||||||
urlencode($rs->cat_title) .
|
urlencode($row->cat_title) .
|
||||||
'" title="' . __('view links of this category') . '">' .
|
'" title="' . __('view links of this category') . '">' .
|
||||||
Html::escapeHTML($rs->cat_title) .
|
Html::escapeHTML($row->cat_title) .
|
||||||
'</a>' . ($w->shownumlink ? ' (' .
|
'</a>' . ($wdesc->shownumlink ? ' (' .
|
||||||
($C2->getLinks(['cat_id' => $rs->cat_id], true)->f(0)) . ')' : '') .
|
($utils->getLinks(['cat_id' => $row->cat_id], true)->f(0)) . ')' : '') .
|
||||||
'</li>';
|
'</li>';
|
||||||
}
|
}
|
||||||
|
|
||||||
return $w->renderDiv(
|
return $widget->renderDiv(
|
||||||
(bool) $w->content_only,
|
$wdesc->content_only,
|
||||||
'cinecturlink2cat ' . $w->class,
|
$widget->id() . ' ' . $wdesc->class,
|
||||||
'',
|
'',
|
||||||
($w->title ? $w->renderTitle(Html::escapeHTML($w->title)) : '') .
|
($wdesc->title ? $widget->renderTitle(Html::escapeHTML($wdesc->title)) : '') .
|
||||||
'<ul>' . implode(' ', $res) . '</ul>'
|
'<ul>' . implode(' ', $res) . '</ul>'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user