clean up code, first pass
parent
7ed1ad5b03
commit
c9e185a68c
23
_admin.php
23
_admin.php
|
@ -1,16 +1,15 @@
|
|||
<?php
|
||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||
#
|
||||
# This file is part of postWidgetText, a plugin for Dotclear 2.
|
||||
#
|
||||
# Copyright (c) 2009-2013 Jean-Christian Denis and contributors
|
||||
# contact@jcdenis.fr http://jcd.lv
|
||||
#
|
||||
# Licensed under the GPL version 2.0 license.
|
||||
# A copy of this license is available in LICENSE file or at
|
||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
#
|
||||
# -- END LICENSE BLOCK ------------------------------------
|
||||
/**
|
||||
* @brief postWidgetText, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis and Contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||
|
||||
|
|
23
_config.php
23
_config.php
|
@ -1,16 +1,15 @@
|
|||
<?php
|
||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||
#
|
||||
# This file is part of postWidgetText, a plugin for Dotclear 2.
|
||||
#
|
||||
# Copyright (c) 2009-2013 Jean-Christian Denis and contributors
|
||||
# contact@jcdenis.fr http://jcd.lv
|
||||
#
|
||||
# Licensed under the GPL version 2.0 license.
|
||||
# A copy of this license is available in LICENSE file or at
|
||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
#
|
||||
# -- END LICENSE BLOCK ------------------------------------
|
||||
/**
|
||||
* @brief postWidgetText, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis and Contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
if (!defined('DC_CONTEXT_MODULE')) {
|
||||
|
||||
|
|
24
_define.php
24
_define.php
|
@ -1,17 +1,15 @@
|
|||
<?php
|
||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||
#
|
||||
# This file is part of postWidgetText, a plugin for Dotclear 2.
|
||||
#
|
||||
# Copyright (c) 2009-2013 Jean-Christian Denis and contributors
|
||||
# contact@jcdenis.fr http://jcd.lv
|
||||
#
|
||||
# Licensed under the GPL version 2.0 license.
|
||||
# A copy of this license is available in LICENSE file or at
|
||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
#
|
||||
# -- END LICENSE BLOCK ------------------------------------
|
||||
|
||||
/**
|
||||
* @brief postWidgetText, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis and Contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
return null;
|
||||
|
|
23
_install.php
23
_install.php
|
@ -1,16 +1,15 @@
|
|||
<?php
|
||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||
#
|
||||
# This file is part of postWidgetText, a plugin for Dotclear 2.
|
||||
#
|
||||
# Copyright (c) 2009-2013 Jean-Christian Denis and contributors
|
||||
# contact@jcdenis.fr http://jcd.lv
|
||||
#
|
||||
# Licensed under the GPL version 2.0 license.
|
||||
# A copy of this license is available in LICENSE file or at
|
||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
#
|
||||
# -- END LICENSE BLOCK ------------------------------------
|
||||
/**
|
||||
* @brief postWidgetText, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis and Contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||
|
||||
|
|
23
_prepend.php
23
_prepend.php
|
@ -1,16 +1,15 @@
|
|||
<?php
|
||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||
#
|
||||
# This file is part of postWidgetText, a plugin for Dotclear 2.
|
||||
#
|
||||
# Copyright (c) 2009-2013 Jean-Christian Denis and contributors
|
||||
# contact@jcdenis.fr http://jcd.lv
|
||||
#
|
||||
# Licensed under the GPL version 2.0 license.
|
||||
# A copy of this license is available in LICENSE file or at
|
||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
#
|
||||
# -- END LICENSE BLOCK ------------------------------------
|
||||
/**
|
||||
* @brief postWidgetText, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis and Contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
|
||||
|
|
30
_public.php
30
_public.php
|
@ -1,15 +1,19 @@
|
|||
<?php
|
||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||
#
|
||||
# This file is part of postWidgetText, a plugin for Dotclear 2.
|
||||
#
|
||||
# Copyright (c) 2009-2013 Jean-Christian Denis and contributors
|
||||
# contact@jcdenis.fr http://jcd.lv
|
||||
#
|
||||
# Licensed under the GPL version 2.0 license.
|
||||
# A copy of this license is available in LICENSE file or at
|
||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
#
|
||||
# -- END LICENSE BLOCK ------------------------------------
|
||||
/**
|
||||
* @brief postWidgetText, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis and Contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
if (!defined('DC_RC_PATH')) {
return null;
}
require dirname(__FILE__).'/_widgets.php';
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
require dirname(__FILE__).'/_widgets.php';
|
122
_widgets.php
122
_widgets.php
|
@ -1,15 +1,111 @@
|
|||
<?php
|
||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||
#
|
||||
# This file is part of postWidgetText, a plugin for Dotclear 2.
|
||||
#
|
||||
# Copyright (c) 2009-2013 Jean-Christian Denis and contributors
|
||||
# contact@jcdenis.fr http://jcd.lv
|
||||
#
|
||||
# Licensed under the GPL version 2.0 license.
|
||||
# A copy of this license is available in LICENSE file or at
|
||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
#
|
||||
# -- END LICENSE BLOCK ------------------------------------
|
||||
/**
|
||||
* @brief postWidgetText, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis and Contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
if (!defined('DC_RC_PATH')) {
return null;
}
$core->blog->settings->addNamespace('postwidgettext');
$core->addBehavior(
'initWidgets',
array('postWidgetTextWidget', 'init')
);
/**
* @ingroup DC_PLUGIN_POSTWIDGETTEXT
* @brief postWidgetText - admin and public widget methods.
* @since 2.6
*/
class postWidgetTextWidget
{
public static function init($w)
{
global $core;
$w->create(
'postwidgettext',
__('Post widget text'),
array('postWidgetTextWidget', 'display'),
null,
__('Add a widget with a text related to an entry')
);
$w->postwidgettext->setting(
'title',
__('Title:'),
__('More about this entry'),
'text'
);
$w->postwidgettext->setting(
'excerpt',
__('Use excerpt if no content'),
0,
'check'
);
$w->postwidgettext->setting(
'show',
__('Show widget even if empty'),
0,
'check'
);
$w->postwidgettext->setting(
'content_only',
__('Content only'),
0,
'check'
);
$w->postwidgettext->setting(
'class',
__('CSS class:'),
''
);
}
public static function display($w)
{
global $core, $_ctx;
if (!$core->blog->settings->postwidgettext->postwidgettext_active
|| !$_ctx->exists('posts')
|| !$_ctx->posts->post_id
) {
return null;
}
$title = (strlen($w->title) > 0) ?
'<h2>'.html::escapeHTML($w->title).'</h2>' : null;
$content = '';
$pwt = new postWidgetText($core);
$rs = $pwt->getWidgets(array('post_id'=>$_ctx->posts->post_id));
if ('' != $rs->option_title) {
$title = '<h2>'.$rs->option_title.'</h2>';
}
if ('' != $rs->option_content_xhtml) {
$content = $rs->option_content_xhtml;
}
if ('' == $content && $w->excerpt) {
$content = $_ctx->posts->post_excerpt_xhtml;
}
return '' == $content && !$w->show ?
null :
($w->content_only ? '' : '<div class="postwidgettext'.
($w->class ? ' '.html::escapeHTML($w->class) : '').'">').
$title.
$content.
($w->content_only ? '' : '</div>');
}
}
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
$core->blog->settings->addNamespace('postwidgettext');
|
||||
|
||||
$core->addBehavior(
|
||||
'initWidgets',
|
||||
array('postWidgetTextWidget', 'init')
|
||||
);
|
||||
|
||||
/**
|
||||
* @ingroup DC_PLUGIN_POSTWIDGETTEXT
|
||||
* @brief postWidgetText - admin and public widget methods.
|
||||
* @since 2.6
|
||||
*/
|
||||
class postWidgetTextWidget
|
||||
{
|
||||
public static function init($w)
|
||||
{
|
||||
global $core;
|
||||
|
||||
$w->create(
|
||||
'postwidgettext',
|
||||
__('Post widget text'),
|
||||
array('postWidgetTextWidget', 'display'),
|
||||
null,
|
||||
__('Add a widget with a text related to an entry')
|
||||
);
|
||||
$w->postwidgettext->setting(
|
||||
'title',
|
||||
__('Title:'),
|
||||
__('More about this entry'),
|
||||
'text'
|
||||
);
|
||||
$w->postwidgettext->setting(
|
||||
'excerpt',
|
||||
__('Use excerpt if no content'),
|
||||
0,
|
||||
'check'
|
||||
);
|
||||
$w->postwidgettext->setting(
|
||||
'show',
|
||||
__('Show widget even if empty'),
|
||||
0,
|
||||
'check'
|
||||
);
|
||||
$w->postwidgettext->setting(
|
||||
'content_only',
|
||||
__('Content only'),
|
||||
0,
|
||||
'check'
|
||||
);
|
||||
$w->postwidgettext->setting(
|
||||
'class',
|
||||
__('CSS class:'),
|
||||
''
|
||||
);
|
||||
}
|
||||
|
||||
public static function display($w)
|
||||
{
|
||||
global $core, $_ctx;
|
||||
|
||||
if (!$core->blog->settings->postwidgettext->postwidgettext_active
|
||||
|| !$_ctx->exists('posts')
|
||||
|| !$_ctx->posts->post_id
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$title = (strlen($w->title) > 0) ?
|
||||
'<h2>'.html::escapeHTML($w->title).'</h2>' : null;
|
||||
$content = '';
|
||||
|
||||
$pwt = new postWidgetText($core);
|
||||
$rs = $pwt->getWidgets(array('post_id'=>$_ctx->posts->post_id));
|
||||
|
||||
if ('' != $rs->option_title) {
|
||||
$title = '<h2>'.$rs->option_title.'</h2>';
|
||||
}
|
||||
if ('' != $rs->option_content_xhtml) {
|
||||
$content = $rs->option_content_xhtml;
|
||||
}
|
||||
if ('' == $content && $w->excerpt) {
|
||||
$content = $_ctx->posts->post_excerpt_xhtml;
|
||||
}
|
||||
|
||||
return '' == $content && !$w->show ?
|
||||
null :
|
||||
($w->content_only ? '' : '<div class="postwidgettext'.
|
||||
($w->class ? ' '.html::escapeHTML($w->class) : '').'">').
|
||||
$title.
|
||||
$content.
|
||||
($w->content_only ? '' : '</div>');
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
<modules xmlns:da="http://dotaddict.org/da/">
|
||||
<module id="postWidgetText">
|
||||
<name>Widget texte de billet</name>
|
||||
<version>2021.00.00.1</version>
|
||||
<author>Jean-Christian Denis and Contributors</author>
|
||||
<desc>Add a widget with a text related to an entry</desc>
|
||||
<file>https://github.com/JcDenis/postWidgetText/releases/download/v2021.00.00.1/plugin-postWidgetText.zip</file>
|
||||
<da:dcmin>2.19</da:dcmin>
|
||||
<da:details>https://plugins.dotaddict.org/dc2/details/postWidgetText</da:details>
|
||||
<da:support>https://github.com/JcDenis/postWidgetText</da:support>
|
||||
</module>
|
||||
</modules>
|
File diff suppressed because one or more lines are too long
|
@ -1,16 +1,15 @@
|
|||
<?php
|
||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||
#
|
||||
# This file is part of postWidgetText, a plugin for Dotclear 2.
|
||||
#
|
||||
# Copyright (c) 2009-2013 Jean-Christian Denis and contributors
|
||||
# contact@jcdenis.fr http://jcd.lv
|
||||
#
|
||||
# Licensed under the GPL version 2.0 license.
|
||||
# A copy of this license is available in LICENSE file or at
|
||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
#
|
||||
# -- END LICENSE BLOCK ------------------------------------
|
||||
/**
|
||||
* @brief postWidgetText, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis and Contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||
|
||||
|
|
|
@ -1,16 +1,15 @@
|
|||
<?php
|
||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||
#
|
||||
# This file is part of postWidgetText, a plugin for Dotclear 2.
|
||||
#
|
||||
# Copyright (c) 2009-2013 Jean-Christian Denis and contributors
|
||||
# contact@jcdenis.fr http://jcd.lv
|
||||
#
|
||||
# Licensed under the GPL version 2.0 license.
|
||||
# A copy of this license is available in LICENSE file or at
|
||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
#
|
||||
# -- END LICENSE BLOCK ------------------------------------
|
||||
/**
|
||||
* @brief postWidgetText, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis and Contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||
|
||||
|
|
|
@ -1,16 +1,15 @@
|
|||
<?php
|
||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||
#
|
||||
# This file is part of postWidgetText, a plugin for Dotclear 2.
|
||||
#
|
||||
# Copyright (c) 2009-2013 Jean-Christian Denis and contributors
|
||||
# contact@jcdenis.fr http://jcd.lv
|
||||
#
|
||||
# Licensed under the GPL version 2.0 license.
|
||||
# A copy of this license is available in LICENSE file or at
|
||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
#
|
||||
# -- END LICENSE BLOCK ------------------------------------
|
||||
/**
|
||||
* @brief postWidgetText, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis and Contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||
|
||||
|
|
|
@ -1,16 +1,15 @@
|
|||
<?php
|
||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||
#
|
||||
# This file is part of postWidgetText, a plugin for Dotclear 2.
|
||||
#
|
||||
# Copyright (c) 2009-2013 Jean-Christian Denis and contributors
|
||||
# contact@jcdenis.fr http://jcd.lv
|
||||
#
|
||||
# Licensed under the GPL version 2.0 license.
|
||||
# A copy of this license is available in LICENSE file or at
|
||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
#
|
||||
# -- END LICENSE BLOCK ------------------------------------
|
||||
/**
|
||||
* @brief postWidgetText, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis and Contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||
|
||||
|
|
|
@ -1,16 +1,15 @@
|
|||
<?php
|
||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||
#
|
||||
# This file is part of postWidgetText, a plugin for Dotclear 2.
|
||||
#
|
||||
# Copyright (c) 2009-2013 Jean-Christian Denis and contributors
|
||||
# contact@jcdenis.fr http://jcd.lv
|
||||
#
|
||||
# Licensed under the GPL version 2.0 license.
|
||||
# A copy of this license is available in LICENSE file or at
|
||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
#
|
||||
# -- END LICENSE BLOCK ------------------------------------
|
||||
/**
|
||||
* @brief postWidgetText, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis and Contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
$records = $core->con->select(
|
||||
'SELECT W.*, P.post_lang, P.post_format FROM '.$core->prefix.'post_wtext W '.
|
||||
|
@ -51,4 +50,3 @@ if (!$records->isEmpty())
|
|||
}
|
||||
}
|
||||
}
|
||||
?>
|
23
index.php
23
index.php
|
@ -1,16 +1,15 @@
|
|||
<?php
|
||||
# -- BEGIN LICENSE BLOCK ----------------------------------
|
||||
#
|
||||
# This file is part of postWidgetText, a plugin for Dotclear 2.
|
||||
#
|
||||
# Copyright (c) 2009-2013 Jean-Christian Denis and contributors
|
||||
# contact@jcdenis.fr http://jcd.lv
|
||||
#
|
||||
# Licensed under the GPL version 2.0 license.
|
||||
# A copy of this license is available in LICENSE file or at
|
||||
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
#
|
||||
# -- END LICENSE BLOCK ------------------------------------
|
||||
/**
|
||||
* @brief postWidgetText, a plugin for Dotclear 2
|
||||
*
|
||||
* @package Dotclear
|
||||
* @subpackage Plugin
|
||||
*
|
||||
* @author Jean-Christian Denis and Contributors
|
||||
*
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||
|
||||
|
|
|
@ -77,5 +77,3 @@ $GLOBALS['__l10n']['Posts widgets'] = 'Widgets de billets';
|
|||
|
||||
#index.php:157
|
||||
$GLOBALS['__l10n']['Delete selected widgets'] = 'Effacer les widgets texte selectionnés';
|
||||
|
||||
?>
|
Loading…
Reference in New Issue