Compare commits
10 Commits
b857875b0f
...
ff3efb0705
Author | SHA1 | Date |
---|---|---|
Jean-Christian Paul Denis | ff3efb0705 | |
Jean-Christian Paul Denis | 2682b07c4a | |
Jean-Christian Paul Denis | 9356b136b8 | |
Jean-Christian Paul Denis | fe0b009122 | |
Jean-Christian Paul Denis | 7528bd357c | |
Jean-Christian Paul Denis | 39ab49bcac | |
Jean-Christian Paul Denis | e96f5a1039 | |
Jean-Christian Paul Denis | 322fe47d55 | |
Jean-Christian Paul Denis | 7d64224bfa | |
Jean-Christian Paul Denis | 7208abc9d6 |
12
CHANGELOG.md
12
CHANGELOG.md
|
@ -1,3 +1,15 @@
|
|||
1.0 - 2023.04.23
|
||||
- require dotclear 2.26
|
||||
- use latest dotclear namespace
|
||||
- remove all the magic
|
||||
|
||||
0.9 - 2023.03.21
|
||||
- require Dotclear 2.25
|
||||
- use namespace
|
||||
|
||||
0.8 - 2022.11.20
|
||||
- fix compatibility with Dotclear 2.24 (required)
|
||||
|
||||
0.7 - 2021.09.17
|
||||
- clean up and cosmetics
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
[![Release](https://img.shields.io/github/v/release/JcDenis/postInfoWidget)](https://github.com/JcDenis/postInfoWidget/releases)
|
||||
[![Date](https://img.shields.io/github/release-date/JcDenis/postInfoWidget)](https://github.com/JcDenis/postInfoWidget/releases)
|
||||
[![Issues](https://img.shields.io/github/issues/JcDenis/postInfoWidget)](https://github.com/JcDenis/postInfoWidget/issues)
|
||||
[![Dotclear](https://img.shields.io/badge/dotclear-v2.19-blue.svg)](https://fr.dotclear.org/download)
|
||||
[![Dotclear](https://img.shields.io/badge/dotclear-v2.26-blue.svg)](https://fr.dotclear.org/download)
|
||||
[![Dotaddict](https://img.shields.io/badge/dotaddict-official-green.svg)](https://plugins.dotaddict.org/dc2/details/postInfoWidget)
|
||||
[![License](https://img.shields.io/github/license/JcDenis/postInfoWidget)](https://github.com/JcDenis/postInfoWidget/blob/master/LICENSE)
|
||||
|
||||
|
@ -19,7 +19,7 @@ Show entry details in a widget.
|
|||
_postInfoWidget_ requires:
|
||||
|
||||
* permissions to manage widgets
|
||||
* Dotclear 2.19
|
||||
* Dotclear 2.26
|
||||
|
||||
## USAGE
|
||||
|
||||
|
@ -32,7 +32,7 @@ Add and configure "Entry information list" from widgets manager.
|
|||
|
||||
* License : [GNU GPL v2](https://www.gnu.org/licenses/old-licenses/lgpl-2.0.html)
|
||||
* Source & contribution : [GitHub Page](https://github.com/JcDenis/postInfoWidget)
|
||||
* Packages & details: [Dotaddict Page](https://plugins.dotaddict.org/dc2/details/postInfoWidget)
|
||||
* Packages & details : [Dotaddict Page](https://plugins.dotaddict.org/dc2/details/postInfoWidget)
|
||||
* Discuss and help : [Dotclear Forum](http://forum.dotclear.org/viewtopic.php?pid=332974#p332974)
|
||||
|
||||
## CONTRIBUTORS
|
||||
|
|
18
_admin.php
18
_admin.php
|
@ -1,18 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief postInfoWidget, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis, Pierre Van Glabeke
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
require dirname(__FILE__) . '/_widgets.php';
|
28
_define.php
28
_define.php
|
@ -1,17 +1,16 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief postInfoWidget, a plugin for Dotclear 2
|
||||
*
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
*
|
||||
* @author Jean-Christian Denis, Pierre Van Glabeke
|
||||
*
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
if (!defined('DC_RC_PATH') || is_null(dcCore::app()->auth)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -19,13 +18,16 @@ $this->registerModule(
|
|||
'Entry information list',
|
||||
'Show Entry informations on a widget',
|
||||
'Jean-Christian Denis, Pierre Van Glabeke',
|
||||
'0.7',
|
||||
'1.0',
|
||||
[
|
||||
'requires' => [['core', '2.19']],
|
||||
'permissions' => 'usage,contentadmin',
|
||||
'type' => 'plugin',
|
||||
'support' => 'http://forum.dotclear.org/viewtopic.php?pid=332974#p332974',
|
||||
'details' => 'http://plugins.dotaddict.org/dc2/details/postInfoWidget',
|
||||
'repository' => 'https://raw.githubusercontent.com/JcDenis/postInfoWidget/master/dcstore.xml'
|
||||
'requires' => [['core', '2.26']],
|
||||
'permissions' => dcCore::app()->auth->makePermissions([
|
||||
dcAuth::PERMISSION_USAGE,
|
||||
dcAuth::PERMISSION_CONTENT_ADMIN,
|
||||
]),
|
||||
'type' => 'plugin',
|
||||
'support' => 'http://forum.dotclear.org/viewtopic.php?pid=332974#p332974',
|
||||
'details' => 'http://plugins.dotaddict.org/dc2/details/postInfoWidget',
|
||||
'repository' => 'https://raw.githubusercontent.com/JcDenis/postInfoWidget/master/dcstore.xml',
|
||||
]
|
||||
);
|
||||
);
|
||||
|
|
18
_public.php
18
_public.php
|
@ -1,18 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief postInfoWidget, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis, Pierre Van Glabeke
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
require dirname(__FILE__) . '/_widgets.php';
|
23
dcstore.xml
23
dcstore.xml
|
@ -1,12 +1,13 @@
|
|||
<?xml version="1.0"?>
|
||||
<modules xmlns:da="http://dotaddict.org/da/">
|
||||
<module id="postInfoWidget">
|
||||
<name>Entry information list</name>
|
||||
<version>0.7</version>
|
||||
<author>Jean-Christian Denis, Pierre Van Glabeke</author>
|
||||
<desc>Show Entry informations on a widget</desc>
|
||||
<file>https://github.com/JcDenis/postInfoWidget/releases/download/v0.7/plugin-postInfoWidget.zip</file>
|
||||
<da:dcmin>2.19</da:dcmin>
|
||||
<da:details>http://plugins.dotaddict.org/dc2/details/postInfoWidget</da:details>
|
||||
<da:support>http://forum.dotclear.org/viewtopic.php?pid=332974#p332974</da:support>
|
||||
</module>
|
||||
</modules>
|
||||
<module id="postInfoWidget">
|
||||
<name>Entry information list</name>
|
||||
<version>1.0</version>
|
||||
<author>Jean-Christian Denis, Pierre Van Glabeke</author>
|
||||
<desc>Show Entry informations on a widget</desc>
|
||||
<file>https://github.com/JcDenis/postInfoWidget/releases/download/v1.0/plugin-postInfoWidget.zip</file>
|
||||
<da:dcmin>2.26</da:dcmin>
|
||||
<da:details>http://plugins.dotaddict.org/dc2/details/postInfoWidget</da:details>
|
||||
<da:support>http://forum.dotclear.org/viewtopic.php?pid=332974#p332974</da:support>
|
||||
</module>
|
||||
</modules>
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
<?php
|
||||
/**
|
||||
* @package Dotclear
|
||||
*
|
||||
* @copyright Olivier Meunier & Association Dotclear
|
||||
* @copyright GPL-2.0-only
|
||||
*/
|
||||
#
|
||||
# DOT NOT MODIFY THIS FILE !
|
||||
#
|
||||
|
||||
use Dotclear\Helper\L10n;
|
||||
|
||||
L10n::$locales['PostInfoWidget: entry information list'] = 'PostInfoWidget : liste d\'information du billet';
|
||||
L10n::$locales['Show Entry informations on a widget'] = 'Afficher les informations d\'un billet dans un widget';
|
||||
L10n::$locales['About this entry'] = 'Á propos de ce billet';
|
||||
L10n::$locales['Publish date text:'] = 'Texte pour la date de publication :';
|
||||
L10n::$locales['Publish on %Y-%m-%d %H:%M'] = 'Publié le %d/%m/%Y à %H:%M';
|
||||
L10n::$locales['Create date text:'] = 'Texte pour la date de création :';
|
||||
L10n::$locales['Create on %Y-%m-%d %H:%M'] = 'Créé le %d/%m/%Y à %H:%M';
|
||||
L10n::$locales['Update date text:'] = 'Texte pour la date de dernière mise à jour :';
|
||||
L10n::$locales['Update on %Y-%m-%d %H:%M'] = 'Mis à jour le %d/%m/%Y à %H:%M';
|
||||
L10n::$locales['Language (%T = name, %C = code, %F = flag):'] = 'Texte pour la langue (%T = nom, %C = code, %F = drapeau) :';
|
||||
L10n::$locales['Language: %T %F'] = 'Langue : %T %F';
|
||||
L10n::$locales['Author text (%T = author):'] = 'Texte pour l\'auteur (%T = auteur) :';
|
||||
L10n::$locales['Author: %T'] = 'Auteur : %T';
|
||||
L10n::$locales['Category text (%T = category):'] = 'Texte pour la catégorie (%T = catégorie) :';
|
||||
L10n::$locales['Category: %T'] = 'Catégorie : %T';
|
||||
L10n::$locales['Tags text (%T = tags list):'] = 'Texte pour les mots-clés (%T = liste des mots-clés) :';
|
||||
L10n::$locales['Tags: %T'] = 'Mots-clés : %T';
|
||||
L10n::$locales['Attachments text (%T = text, %D = numeric):'] = 'Texte pour le nombre d\'annexes (%T = texte, %D = nombre) :';
|
||||
L10n::$locales['Attachments: %T'] = 'Annexes : %T';
|
||||
L10n::$locales['Comments text (%T = text, %D = numeric):'] = 'Texte pour le nombre de commentaires (%T = texte, %D = nombre) :';
|
||||
L10n::$locales['Comments: %T'] = 'Commentaires : %T';
|
||||
L10n::$locales['Trackbacks text (%T = text, %D = numeric):'] = 'Texte pour le nombre de rétroliens (%T = texte, %D = nombre) :';
|
||||
L10n::$locales['Trackbacks: %T'] = 'Rétroliens : %T';
|
||||
L10n::$locales['Permalink text (%T = text link, %F = full link):'] = 'Texte pour le lien pemanent (%T = texte, %F = complet) :';
|
||||
L10n::$locales['%T'] = '%T';
|
||||
L10n::$locales['Show comment feed url'] = 'Afficher l\'URL du flux des commentaires';
|
||||
L10n::$locales['Link to previous entry (%T = navigation text, %F = entry title):'] = 'Lien vers le billet précédent (%T = texte de navigation, %F = titre du billet) :';
|
||||
L10n::$locales['Link to next entry (%T = navigation text, %F = entry title):'] = 'Lien vers le billet suivant (%T = texte de navigation, %F = titre du billet) :';
|
||||
L10n::$locales['Link to previous entry of this category (%T = navigation text, %F = entry title):'] = 'Lien vers le billet précédent de la catégorie (%T = texte de navigation, %F = titre du billet) :';
|
||||
L10n::$locales['Link to next entry of this category (%T = navigation text, %F = entry title):'] = 'Lien vers le billet suivant de la catégorie (%T = texte de navigation, %F = titre du billet) :';
|
||||
L10n::$locales['No style'] = 'sans style';
|
||||
L10n::$locales['Small icon'] = 'petite icône';
|
||||
L10n::$locales['Normal icon'] = 'icône normale';
|
||||
L10n::$locales['Try to remove entry information'] = 'Essayer de cacher les informations du billet';
|
||||
L10n::$locales['Try to remove entry tags'] = 'Essayer de cacher la liste des mots-clés du billet';
|
||||
L10n::$locales['Try to remove entry navigation'] = 'Essayer de cacher les liens de navigation';
|
||||
L10n::$locales['no attachment'] = 'aucune annexe';
|
||||
L10n::$locales['no comment'] = 'aucun commentaire';
|
||||
L10n::$locales['no trackback'] = 'aucun rétrolien';
|
||||
L10n::$locales['Previous entry'] = 'Billet précédent';
|
||||
L10n::$locales['Next entry'] = 'Billet suivant';
|
||||
L10n::$locales['Previous entry of this category'] = 'Billet précédent de cette catégorie';
|
||||
L10n::$locales['Next entry of this category'] = 'Billet suivant de cette catégorie';
|
||||
L10n::$locales['Try to adapt style:'] = 'Essayer d\'adapter le style :';
|
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief postInfoWidget, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis, Pierre Van Glabeke
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\postInfoWidget;
|
||||
|
||||
use dcCore;
|
||||
use dcNsProcess;
|
||||
|
||||
class Backend extends dcNsProcess
|
||||
{
|
||||
public static function init(): bool
|
||||
{
|
||||
static::$init = defined('DC_CONTEXT_ADMIN');
|
||||
|
||||
return static::$init;
|
||||
}
|
||||
|
||||
public static function process(): bool
|
||||
{
|
||||
if (!static::$init) {
|
||||
return false;
|
||||
}
|
||||
|
||||
dcCore::app()->addBehaviors([
|
||||
'initWidgets' => [Widgets::class, 'initWidgets'],
|
||||
]);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief postInfoWidget, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis, Pierre Van Glabeke
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\postInfoWidget;
|
||||
|
||||
use dcCore;
|
||||
use dcNsProcess;
|
||||
|
||||
class Frontend extends dcNsProcess
|
||||
{
|
||||
public static function init(): bool
|
||||
{
|
||||
static::$init = true;
|
||||
|
||||
return static::$init;
|
||||
}
|
||||
|
||||
public static function process(): bool
|
||||
{
|
||||
if (!static::$init) {
|
||||
return false;
|
||||
}
|
||||
|
||||
dcCore::app()->addBehaviors([
|
||||
'initWidgets' => [Widgets::class, 'initWidgets'],
|
||||
]);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,36 +1,40 @@
|
|||
<?php
|
||||
/**
|
||||
* @brief postInfoWidget, a plugin for Dotclear 2
|
||||
*
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
*
|
||||
* @author Jean-Christian Denis, Pierre Van Glabeke
|
||||
*
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
return null;
|
||||
}
|
||||
namespace Dotclear\Plugin\postInfoWidget;
|
||||
|
||||
$core->addBehavior(
|
||||
'initWidgets',
|
||||
['postInfoWidget', 'adminWidget']
|
||||
);
|
||||
use dcCore;
|
||||
use Dotclear\Database\MetaRecord;
|
||||
use Dotclear\Helper\{
|
||||
Date,
|
||||
Html\Html,
|
||||
L10n
|
||||
};
|
||||
use Dotclear\Plugin\widgets\{
|
||||
WidgetsStack,
|
||||
WidgetsElement
|
||||
};
|
||||
|
||||
class postInfoWidget
|
||||
class Widgets
|
||||
{
|
||||
public static function adminWidget($w)
|
||||
public static function initWidgets(WidgetsStack $w): void
|
||||
{
|
||||
global $core;
|
||||
|
||||
$w
|
||||
->create(
|
||||
'postinfowidget',
|
||||
__('PostInfoWidget: entry information list'),
|
||||
['postInfoWidget', 'publicWidget'],
|
||||
[self::class, 'publicWidget'],
|
||||
null,
|
||||
__('Show Entry informations on a widget')
|
||||
)
|
||||
|
@ -72,8 +76,8 @@ class postInfoWidget
|
|||
'text'
|
||||
);
|
||||
|
||||
if ($core->plugins->moduleExists('tags')) {
|
||||
$w->postinfowidget->setting(
|
||||
if (dcCore::app()->plugins->moduleExists('tags')) {
|
||||
$w->__get('postinfowidget')->setting(
|
||||
'tag_str',
|
||||
__('Tags text (%T = tags list):'),
|
||||
__('Tags: %T'),
|
||||
|
@ -81,7 +85,7 @@ class postInfoWidget
|
|||
);
|
||||
}
|
||||
|
||||
$w->postinfowidget
|
||||
$w->__get('postinfowidget')
|
||||
->setting(
|
||||
'attachment_str',
|
||||
__('Attachments text (%T = text, %D = numeric):'),
|
||||
|
@ -141,181 +145,180 @@ class postInfoWidget
|
|||
__('Try to adapt style'),
|
||||
'small',
|
||||
'combo',
|
||||
array(
|
||||
__('No style') => '-',
|
||||
__('Small icon') => 'small',
|
||||
__('Normal icon') => 'normal'
|
||||
)
|
||||
[
|
||||
__('No style') => '-',
|
||||
__('Small icon') => 'small',
|
||||
__('Normal icon') => 'normal',
|
||||
]
|
||||
);
|
||||
/*
|
||||
$w->postinfowidget
|
||||
->setting(
|
||||
'rmvinfo',
|
||||
__('Try to remove entry information'),
|
||||
1,
|
||||
'check'
|
||||
)
|
||||
->setting(
|
||||
'rmvtags',
|
||||
__('Try to remove entry tags'),
|
||||
1,
|
||||
'check'
|
||||
)
|
||||
->setting(
|
||||
'rmvnav',
|
||||
__('Try to remove entry navigation'),
|
||||
1,
|
||||
'check'
|
||||
);
|
||||
//*/
|
||||
/*
|
||||
$w->postinfowidget
|
||||
->setting(
|
||||
'rmvinfo',
|
||||
__('Try to remove entry information'),
|
||||
1,
|
||||
'check'
|
||||
)
|
||||
->setting(
|
||||
'rmvtags',
|
||||
__('Try to remove entry tags'),
|
||||
1,
|
||||
'check'
|
||||
)
|
||||
->setting(
|
||||
'rmvnav',
|
||||
__('Try to remove entry navigation'),
|
||||
1,
|
||||
'check'
|
||||
);
|
||||
//*/
|
||||
# --BEHAVIOR-- postInfoWidgetAdmin
|
||||
$core->callBehavior('postInfoWidgetAdmin', $w);
|
||||
dcCore::app()->callBehavior('postInfoWidgetAdmin', $w);
|
||||
|
||||
$w->postinfowidget
|
||||
$w->__get('postinfowidget')
|
||||
->addContentOnly()
|
||||
->addClass()
|
||||
->addOffline();
|
||||
}
|
||||
|
||||
public static function publicWidget($w)
|
||||
public static function publicWidget(WidgetsElement $w): string
|
||||
{
|
||||
global $core, $_ctx;
|
||||
|
||||
if ($w->offline) {
|
||||
return null;
|
||||
// nullsafe
|
||||
if (is_null(dcCore::app()->blog) || is_null(dcCore::app()->ctx)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if ($core->url->type != 'post'
|
||||
|| !$_ctx->posts->post_id){
|
||||
return null;
|
||||
if ($w->__get('offline')
|
||||
|| dcCore::app()->url->type != 'post'
|
||||
|| !dcCore::app()->ctx->__get('posts')->f('post_id')
|
||||
) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$link = '<a href="%s">%s</a>';
|
||||
$link = '<a href="%s">%s</a>';
|
||||
$content = '';
|
||||
|
||||
if ($w->dt_str != '') {
|
||||
$content .= postInfoWidget::li(
|
||||
if ($w->__get('dt_str') != '') {
|
||||
$content .= self::li(
|
||||
$w,
|
||||
'date',
|
||||
dt::str(
|
||||
$w->dt_str,
|
||||
strtotime($_ctx->posts->post_dt),
|
||||
$core->blog->settings->system->blog_timezone
|
||||
Date::str(
|
||||
$w->__get('dt_str'),
|
||||
(int) strtotime(dcCore::app()->ctx->__get('posts')->f('post_dt')),
|
||||
dcCore::app()->blog->settings->get('system')->get('blog_timezone')
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if ($w->creadt_str != '') {
|
||||
$content .= postInfoWidget::li(
|
||||
if ($w->__get('creadt_str') != '') {
|
||||
$content .= self::li(
|
||||
$w,
|
||||
'create',
|
||||
dt::str(
|
||||
$w->creadt_str,
|
||||
strtotime($_ctx->posts->post_creadt),
|
||||
$core->blog->settings->system->blog_timezone
|
||||
Date::str(
|
||||
$w->__get('creadt_str'),
|
||||
(int) strtotime(dcCore::app()->ctx->__get('posts')->post_creadt),
|
||||
dcCore::app()->blog->settings->get('system')->get('blog_timezone')
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if ($w->upddt_str != '') {
|
||||
$content .= postInfoWidget::li(
|
||||
if ($w->__get('upddt_str') != '') {
|
||||
$content .= self::li(
|
||||
$w,
|
||||
'update',
|
||||
dt::str(
|
||||
$w->upddt_str,
|
||||
strtotime($_ctx->posts->post_upddt),
|
||||
$core->blog->settings->system->blog_timezone
|
||||
Date::str(
|
||||
$w->__get('upddt_str'),
|
||||
(int) strtotime(dcCore::app()->ctx->__get('posts')->f('post_upddt')),
|
||||
dcCore::app()->blog->settings->get('system')->get('blog_timezone')
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if ($w->lang_str != '') {
|
||||
$ln = l10n::getISOcodes();
|
||||
$lang_code = $_ctx->posts->post_lang ?
|
||||
$_ctx->posts->post_lang :
|
||||
$core->blog->settings->system->lang;
|
||||
$lang_name = isset($ln[$lang_code]) ?
|
||||
$ln[$lang_code] :
|
||||
$lang_code;
|
||||
if ($w->__get('lang_str') != '') {
|
||||
$ln = L10n::getISOcodes();
|
||||
$lang_code = dcCore::app()->ctx->__get('posts')->f('post_lang') ?
|
||||
dcCore::app()->ctx->__get('posts')->f('post_lang') :
|
||||
dcCore::app()->blog->settings->get('system')->get('lang');
|
||||
$lang_name = $ln[$lang_code] ?? $lang_code;
|
||||
$lang_flag = file_exists(
|
||||
dirname(__FILE__) .
|
||||
'/img/flags/' .
|
||||
$lang_code . '.png'
|
||||
) ?
|
||||
'<img src="' . $core->blog->getQmarkURL() .
|
||||
dirname(__DIR__) .
|
||||
'/img/flags/' .
|
||||
$lang_code . '.png'
|
||||
) ?
|
||||
'<img src="' . dcCore::app()->blog->getQmarkURL() .
|
||||
'pf=postInfoWidget/img/flags/' .
|
||||
$lang_code . '.png" alt="' . $lang_name . '" />' :
|
||||
$lang_code . '.png" alt="' . $lang_name . '" />' :
|
||||
'';
|
||||
|
||||
$content .= postInfoWidget::li(
|
||||
$content .= self::li(
|
||||
$w,
|
||||
'lang',
|
||||
str_replace(
|
||||
['%T', '%C', '%F'],
|
||||
[$lang_name, $lang_code, $lang_flag],
|
||||
html::escapeHTML($w->lang_str)
|
||||
Html::escapeHTML($w->__get('lang_str'))
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if ($w->author_str != '') {
|
||||
$content .= postInfoWidget::li(
|
||||
if ($w->__get('author_str') != '') {
|
||||
$content .= self::li(
|
||||
$w,
|
||||
'author',
|
||||
str_replace(
|
||||
'%T',
|
||||
$_ctx->posts->getAuthorLink(),
|
||||
html::escapeHTML($w->author_str)
|
||||
dcCore::app()->ctx->__get('posts')->getAuthorLink(),
|
||||
Html::escapeHTML($w->__get('author_str'))
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if ($w->category_str != '' && $_ctx->posts->cat_id) {
|
||||
$content .= postInfoWidget::li(
|
||||
if ($w->__get('category_str') != '' && dcCore::app()->ctx->__get('posts')->f('cat_id')) {
|
||||
$content .= self::li(
|
||||
$w,
|
||||
'category',
|
||||
str_replace(
|
||||
'%T',
|
||||
sprintf(
|
||||
$link,
|
||||
$_ctx->posts->getCategoryURL(),
|
||||
html::escapeHTML($_ctx->posts->cat_title)
|
||||
dcCore::app()->ctx->__get('posts')->__call('getCategoryURL', []),
|
||||
Html::escapeHTML(dcCore::app()->ctx->__get('posts')->f('cat_title'))
|
||||
),
|
||||
html::escapeHTML($w->category_str)
|
||||
Html::escapeHTML($w->__get('category_str'))
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if ($w->tag_str != '' && $core->plugins->moduleExists('tags')) {
|
||||
$meta = $core->meta->getMetadata([
|
||||
if ($w->__get('tag_str') != '' && dcCore::app()->plugins->moduleExists('tags')) {
|
||||
$meta = dcCore::app()->meta->getMetadata([
|
||||
'meta_type' => 'tag',
|
||||
'post_id' => $_ctx->posts->post_id
|
||||
'post_id' => dcCore::app()->ctx->__get('posts')->f('post_id'),
|
||||
]);
|
||||
$metas = [];
|
||||
while ($meta->fetch()) {
|
||||
$metas[$meta->meta_id] = sprintf(
|
||||
$metas[$meta->f('meta_id')] = sprintf(
|
||||
$link,
|
||||
$core->blog->url .
|
||||
$core->url->getBase('tag') . "/" .
|
||||
rawurlencode($meta->meta_id),
|
||||
$meta->meta_id
|
||||
dcCore::app()->blog->url .
|
||||
dcCore::app()->url->getBase('tag') . '/' .
|
||||
rawurlencode($meta->f('meta_id')),
|
||||
$meta->f('meta_id')
|
||||
);
|
||||
}
|
||||
if (!empty($metas)) {
|
||||
$content .= postInfoWidget::li(
|
||||
$content .= self::li(
|
||||
$w,
|
||||
'tag',
|
||||
str_replace(
|
||||
'%T',
|
||||
implode(', ', $metas),
|
||||
html::escapeHTML($w->tag_str)
|
||||
Html::escapeHTML($w->__get('tag_str'))
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if ($w->attachment_str != '') {
|
||||
$nb = $_ctx->posts->countMedia();
|
||||
if ($w->__get('attachment_str') != '') {
|
||||
$nb = dcCore::app()->ctx->__get('posts')->__call('countMedia', []);
|
||||
if ($nb == 0) {
|
||||
$attachment_numeric = 0;
|
||||
$attachment_textual = __('no attachment');
|
||||
|
@ -343,19 +346,19 @@ class postInfoWidget
|
|||
);
|
||||
}
|
||||
|
||||
$content .= postInfoWidget::li(
|
||||
$content .= self::li(
|
||||
$w,
|
||||
'attachment',
|
||||
str_replace(
|
||||
['%T', '%D'],
|
||||
[$attachment_textual, $attachment_numeric],
|
||||
html::escapeHTML($w->attachment_str)
|
||||
Html::escapeHTML($w->__get('attachment_str'))
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if ($w->comment_str != '' && $_ctx->posts->commentsActive()) {
|
||||
$nb = $_ctx->posts->nb_comment;
|
||||
if ($w->__get('comment_str') != '' && dcCore::app()->ctx->__get('posts')->__call('commentsActive', [])) {
|
||||
$nb = (int) dcCore::app()->ctx->__get('posts')->f('nb_comment');
|
||||
if ($nb == 0) {
|
||||
$comment_numeric = 0;
|
||||
$comment_textual = __('no comment');
|
||||
|
@ -383,19 +386,19 @@ class postInfoWidget
|
|||
);
|
||||
}
|
||||
|
||||
$content .= postInfoWidget::li(
|
||||
$content .= self::li(
|
||||
$w,
|
||||
'comment',
|
||||
str_replace(
|
||||
['%T', '%D'],
|
||||
[$comment_textual, $comment_numeric],
|
||||
html::escapeHTML($w->comment_str)
|
||||
Html::escapeHTML($w->__get('comment_str'))
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if ($w->trackback_str != '' && $_ctx->posts->trackbacksActive()) {
|
||||
$nb = $_ctx->posts->nb_trackback;
|
||||
if ($w->__get('trackback_str') != '' && dcCore::app()->ctx->__get('posts')->__call('trackbacksActive', [])) {
|
||||
$nb = (int) dcCore::app()->ctx->__get('posts')->f('nb_trackback');
|
||||
if ($nb == 0) {
|
||||
$trackback_numeric = 0;
|
||||
$trackback_textual = __('no trackback');
|
||||
|
@ -423,19 +426,19 @@ class postInfoWidget
|
|||
);
|
||||
}
|
||||
|
||||
$content .= postInfoWidget::li(
|
||||
$content .= self::li(
|
||||
$w,
|
||||
'trackback',
|
||||
str_replace(
|
||||
['%T', '%D'],
|
||||
array($trackback_textual, $trackback_numeric),
|
||||
html::escapeHTML($w->trackback_str)
|
||||
[$trackback_textual, $trackback_numeric],
|
||||
Html::escapeHTML($w->__get('trackback_str'))
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if ($w->permalink_str) {
|
||||
$content .= postInfoWidget::li(
|
||||
if ($w->__get('permalink_str')) {
|
||||
$content .= self::li(
|
||||
$w,
|
||||
'permalink',
|
||||
str_replace(
|
||||
|
@ -443,58 +446,57 @@ class postInfoWidget
|
|||
[
|
||||
sprintf(
|
||||
$link,
|
||||
$_ctx->posts->getURL(),
|
||||
dcCore::app()->ctx->__get('posts')->__call('getURL', []),
|
||||
__('Permalink')
|
||||
),
|
||||
$_ctx->posts->getURL()
|
||||
dcCore::app()->ctx->__get('posts')->__call('getURL', []),
|
||||
],
|
||||
html::escapeHTML($w->permalink_str)
|
||||
Html::escapeHTML($w->__get('permalink_str'))
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if ($w->feed && $_ctx->posts->commentsActive()) {
|
||||
$content .= postInfoWidget::li(
|
||||
if ($w->__get('feed') && dcCore::app()->ctx->__get('posts')->__call('commentsActive', [])) {
|
||||
$content .= self::li(
|
||||
$w,
|
||||
'feed',
|
||||
sprintf(
|
||||
$link,
|
||||
$core->blog->url .
|
||||
$core->url->getBase('feed') .
|
||||
dcCore::app()->blog->url .
|
||||
dcCore::app()->url->getBase('feed') .
|
||||
'/atom/comments/' .
|
||||
$_ctx->posts->post_id,
|
||||
__("This post's comments feed"),
|
||||
html::escapeHTML($w->tag_str)
|
||||
dcCore::app()->ctx->__get('posts')->f('post_id'),
|
||||
__("This post's comments feed")
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if ($w->navprevpost) {
|
||||
$npp = postInfoWidget::nav(
|
||||
$_ctx->posts,
|
||||
if ($w->__get('navprevpost')) {
|
||||
$npp = self::nav(
|
||||
dcCore::app()->ctx->__get('posts'),
|
||||
-1,
|
||||
false,
|
||||
__('Previous entry'),
|
||||
$w->navprevpost
|
||||
$w->__get('navprevpost')
|
||||
);
|
||||
if ($npp) {
|
||||
$content .= postInfoWidget::li(
|
||||
$content .= self::li(
|
||||
$w,
|
||||
'previous',
|
||||
$npp
|
||||
);
|
||||
}
|
||||
}
|
||||
if ($w->navnextpost) {
|
||||
$nnp = postInfoWidget::nav(
|
||||
$_ctx->posts,
|
||||
if ($w->__get('navnextpost')) {
|
||||
$nnp = self::nav(
|
||||
dcCore::app()->ctx->__get('posts'),
|
||||
1,
|
||||
false,
|
||||
__('Next entry'),
|
||||
$w->navnextpost
|
||||
$w->__get('navnextpost')
|
||||
);
|
||||
if ($nnp) {
|
||||
$content .= postInfoWidget::li(
|
||||
$content .= self::li(
|
||||
$w,
|
||||
'next',
|
||||
$nnp
|
||||
|
@ -502,16 +504,16 @@ class postInfoWidget
|
|||
}
|
||||
}
|
||||
|
||||
if ($w->navprevcat) {
|
||||
$npc = postInfoWidget::nav(
|
||||
$_ctx->posts,
|
||||
if ($w->__get('navprevcat')) {
|
||||
$npc = self::nav(
|
||||
dcCore::app()->ctx->__get('posts'),
|
||||
-1,
|
||||
true,
|
||||
__('Previous entry of this category'),
|
||||
$w->navprevcat
|
||||
$w->__get('navprevcat')
|
||||
);
|
||||
if ($npc) {
|
||||
$content .= postInfoWidget::li(
|
||||
$content .= self::li(
|
||||
$w,
|
||||
'previous',
|
||||
$npc
|
||||
|
@ -519,16 +521,16 @@ class postInfoWidget
|
|||
}
|
||||
}
|
||||
|
||||
if ($w->navnextcat) {
|
||||
$nnc = postInfoWidget::nav(
|
||||
$_ctx->posts,
|
||||
if ($w->__get('navnextcat')) {
|
||||
$nnc = self::nav(
|
||||
dcCore::app()->ctx->__get('posts'),
|
||||
1,
|
||||
true,
|
||||
__('Next entry of this category'),
|
||||
$w->navnextcat
|
||||
$w->__get('navnextcat')
|
||||
);
|
||||
if ($nnc) {
|
||||
$content .= postInfoWidget::li(
|
||||
$content .= self::li(
|
||||
$w,
|
||||
'next',
|
||||
$nnc
|
||||
|
@ -537,56 +539,59 @@ class postInfoWidget
|
|||
}
|
||||
|
||||
# --BEHAVIOR-- postInfoWidgetPublic
|
||||
$content .= $core->callBehavior('postInfoWidgetPublic', $w);
|
||||
$content .= dcCore::app()->callBehavior('postInfoWidgetPublic', $w);
|
||||
|
||||
if (empty($content)) {
|
||||
return null;
|
||||
return '';
|
||||
}
|
||||
/*
|
||||
$rmv = '';
|
||||
if ($w->rmvinfo || $w->rmvtags || $w->rmvnav) {
|
||||
$rmv .=
|
||||
'<script type="text/javascript">'."\n".
|
||||
'$(function() {'."\n";
|
||||
if ($w->rmvinfo) {
|
||||
$rmv .=
|
||||
'var piw_pi=$("#content .post-info");'."\n".
|
||||
'if ($(piw_pi).length!=0){$(piw_pi).hide();}'."\n";
|
||||
}
|
||||
if ($w->rmvtags) {
|
||||
$rmv .=
|
||||
'var piw_pt=$("#content .post-tags");'."\n".
|
||||
'if ($(piw_pt).length!=0){$(piw_pt).hide();}'."\n";
|
||||
}
|
||||
if ($w->rmvnav) {
|
||||
$rmv .=
|
||||
'var piw_pn=$("#content #navlinks");'."\n".
|
||||
'if ($(piw_pn).length!=0){$(piw_pn).hide();}'."\n";
|
||||
}
|
||||
$rmv .=
|
||||
'});'."\n".
|
||||
"</script>\n";
|
||||
}
|
||||
//*/
|
||||
/*
|
||||
$rmv = '';
|
||||
if ($w->rmvinfo || $w->rmvtags || $w->rmvnav) {
|
||||
$rmv .=
|
||||
'<script type="text/javascript">'."\n".
|
||||
'$(function() {'."\n";
|
||||
if ($w->rmvinfo) {
|
||||
$rmv .=
|
||||
'var piw_pi=$("#content .post-info");'."\n".
|
||||
'if ($(piw_pi).length!=0){$(piw_pi).hide();}'."\n";
|
||||
}
|
||||
if ($w->rmvtags) {
|
||||
$rmv .=
|
||||
'var piw_pt=$("#content .post-tags");'."\n".
|
||||
'if ($(piw_pt).length!=0){$(piw_pt).hide();}'."\n";
|
||||
}
|
||||
if ($w->rmvnav) {
|
||||
$rmv .=
|
||||
'var piw_pn=$("#content #navlinks");'."\n".
|
||||
'if ($(piw_pn).length!=0){$(piw_pn).hide();}'."\n";
|
||||
}
|
||||
$rmv .=
|
||||
'});'."\n".
|
||||
"</script>\n";
|
||||
}
|
||||
//*/
|
||||
return $w->renderDiv(
|
||||
$w->content_only,
|
||||
'postinfowidget ' . $w->class,
|
||||
(bool) $w->__get('content_only'),
|
||||
'postinfowidget ' . $w->__get('class'),
|
||||
'',
|
||||
($w->title ? $w->renderTitle(html::escapeHTML($w->title)) : '').
|
||||
($w->__get('title') ? $w->renderTitle(Html::escapeHTML($w->__get('title'))) : '') .
|
||||
sprintf('<ul>%s</ul>', $content)
|
||||
);
|
||||
}
|
||||
|
||||
public static function li($w, $i, $c)
|
||||
public static function li(WidgetsElement $w, string $i, string $c): string
|
||||
{
|
||||
global $core;
|
||||
// nullsafe
|
||||
if (is_null(dcCore::app()->blog)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$s = ' style="padding-left:%spx;background: transparent url(\'' .
|
||||
$core->blog->getQmarkURL() .
|
||||
dcCore::app()->blog->getQmarkURL() .
|
||||
'pf=postInfoWidget/img/%s%s.png\') no-repeat left center;"';
|
||||
if ($w->style == 'small') {
|
||||
if ($w->__get('style') == 'small') {
|
||||
$s = sprintf($s, 16, $i, '-small');
|
||||
} elseif($w->style == 'normal') {
|
||||
} elseif ($w->__get('style') == 'normal') {
|
||||
$s = sprintf($s, 20, $i, '');
|
||||
} else {
|
||||
$s = '';
|
||||
|
@ -596,17 +601,20 @@ class postInfoWidget
|
|||
return sprintf($l, $i, $s, $c);
|
||||
}
|
||||
|
||||
public static function nav($p, $d, $r, $t, $c)
|
||||
public static function nav(MetaRecord $p, int $d, bool $r, string $t, string $c): string
|
||||
{
|
||||
global $core;
|
||||
// nullsafe
|
||||
if (is_null(dcCore::app()->blog)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$rs = $core->blog->getNextPost($p, $d, $r);
|
||||
$rs = dcCore::app()->blog->getNextPost($p, $d, $r);
|
||||
if (is_null($rs)) {
|
||||
return '';
|
||||
}
|
||||
$l = '<a href="%s" title="%s">%s</a>';
|
||||
$u = $rs->getURL();
|
||||
$e = html::escapeHTML($rs->post_title);
|
||||
$u = $rs->__call('getURL', []);
|
||||
$e = Html::escapeHTML($rs->f('post_title'));
|
||||
|
||||
return str_replace(
|
||||
['%T', '%F'],
|
||||
|
@ -614,4 +622,4 @@ class postInfoWidget
|
|||
$c
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue