prepare to DC 2.24
This commit is contained in:
parent
ab88b8beaf
commit
32672d605f
@ -15,4 +15,4 @@ if (!defined('DC_CONTEXT_ADMIN')) {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
require dirname(__FILE__) . '/_widgets.php';
|
require __DIR__ . '/_widgets.php';
|
@ -19,10 +19,10 @@ $this->registerModule(
|
|||||||
'Last entries (Extended)',
|
'Last entries (Extended)',
|
||||||
'Extended list of entries',
|
'Extended list of entries',
|
||||||
'Jean-Christian Denis and contributors',
|
'Jean-Christian Denis and contributors',
|
||||||
'2021.09.17',
|
'2022.11.12',
|
||||||
[
|
[
|
||||||
'requires' => [['core', '2.19']],
|
'requires' => [['core', '2.24']],
|
||||||
'permissions' => 'admin',
|
'permissions' => dcAuth::PERMISSION_ADMIN,
|
||||||
'type' => 'plugin',
|
'type' => 'plugin',
|
||||||
'support' => 'https://github.com/JcDenis/lastpostsExtend',
|
'support' => 'https://github.com/JcDenis/lastpostsExtend',
|
||||||
'details' => 'http://plugins.dotaddict.org/dc2/details/lastpostsExtend',
|
'details' => 'http://plugins.dotaddict.org/dc2/details/lastpostsExtend',
|
||||||
|
@ -15,4 +15,4 @@ if (!defined('DC_RC_PATH')) {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
require dirname(__FILE__) . '/_widgets.php';
|
require __DIR__ . '/_widgets.php';
|
49
_widgets.php
49
_widgets.php
@ -15,7 +15,7 @@ if (!defined('DC_RC_PATH')) {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$core->addBehavior(
|
dcCore::app()->addBehavior(
|
||||||
'initWidgets',
|
'initWidgets',
|
||||||
['lastpostsextendWidget', 'initWidget']
|
['lastpostsextendWidget', 'initWidget']
|
||||||
);
|
);
|
||||||
@ -24,8 +24,6 @@ class lastpostsextendWidget
|
|||||||
{
|
{
|
||||||
public static function initWidget($w)
|
public static function initWidget($w)
|
||||||
{
|
{
|
||||||
global $core;
|
|
||||||
|
|
||||||
# Create widget
|
# Create widget
|
||||||
$w->create(
|
$w->create(
|
||||||
'lastpostsextend',
|
'lastpostsextend',
|
||||||
@ -48,7 +46,7 @@ class lastpostsextendWidget
|
|||||||
__('Gallery') => 'galitem'
|
__('Gallery') => 'galitem'
|
||||||
];
|
];
|
||||||
# plugin muppet types
|
# plugin muppet types
|
||||||
if ($core->plugins->moduleExists('muppet')) {
|
if (dcCore::app()->plugins->moduleExists('muppet')) {
|
||||||
$muppet_types = muppet::getPostTypes();
|
$muppet_types = muppet::getPostTypes();
|
||||||
if(is_array($muppet_types) && !empty($muppet_types)) {
|
if(is_array($muppet_types) && !empty($muppet_types)) {
|
||||||
|
|
||||||
@ -65,7 +63,7 @@ class lastpostsextendWidget
|
|||||||
$posttypes
|
$posttypes
|
||||||
);
|
);
|
||||||
# Category (post and page have same category)
|
# Category (post and page have same category)
|
||||||
$rs = $core->blog->getCategories([
|
$rs = dcCore::app()->blog->getCategories([
|
||||||
'post_type' => 'post'
|
'post_type' => 'post'
|
||||||
]);
|
]);
|
||||||
$categories = [
|
$categories = [
|
||||||
@ -128,7 +126,7 @@ class lastpostsextendWidget
|
|||||||
'check'
|
'check'
|
||||||
);
|
);
|
||||||
# Tag
|
# Tag
|
||||||
if ($core->plugins->moduleExists('tags')) {
|
if (dcCore::app()->plugins->moduleExists('tags')) {
|
||||||
$w->lastpostsextend->setting(
|
$w->lastpostsextend->setting(
|
||||||
'tag',
|
'tag',
|
||||||
__('Limit to tags:'),
|
__('Limit to tags:'),
|
||||||
@ -245,8 +243,6 @@ class lastpostsextendWidget
|
|||||||
|
|
||||||
public static function parseWidget($w)
|
public static function parseWidget($w)
|
||||||
{
|
{
|
||||||
global $core;
|
|
||||||
|
|
||||||
$params = [
|
$params = [
|
||||||
'sql' => '',
|
'sql' => '',
|
||||||
'columns' => [],
|
'columns' => [],
|
||||||
@ -259,8 +255,8 @@ class lastpostsextendWidget
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Home page only
|
# Home page only
|
||||||
if ($w->homeonly == 1 && $core->url->type != 'default'
|
if ($w->homeonly == 1 && dcCore::app()->url->type != 'default'
|
||||||
|| $w->homeonly == 2 && $core->url->type == 'default') {
|
|| $w->homeonly == 2 && dcCore::app()->url->type == 'default') {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -328,19 +324,19 @@ class lastpostsextendWidget
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Tags
|
# Tags
|
||||||
if ($core->plugins->moduleExists('tags') && $w->tag) {
|
if (dcCore::app()->plugins->moduleExists('tags') && $w->tag) {
|
||||||
$tags = explode(',', $w->tag);
|
$tags = explode(',', $w->tag);
|
||||||
foreach($tags as $i => $tag) {
|
foreach($tags as $i => $tag) {
|
||||||
$tags[$i] = trim($tag);
|
$tags[$i] = trim($tag);
|
||||||
}
|
}
|
||||||
$params['from'] .= ', ' . $core->prefix . 'meta META ';
|
$params['from'] .= ', ' . dcCore::app()->prefix . 'meta META ';
|
||||||
$params['sql'] .= 'AND META.post_id = P.post_id ';
|
$params['sql'] .= 'AND META.post_id = P.post_id ';
|
||||||
$params['sql'] .= "AND META.meta_id " . $core->con->in($tags) . " ";
|
$params['sql'] .= "AND META.meta_id " . dcCore::app()->con->in($tags) . " ";
|
||||||
$params['sql'] .= "AND META.meta_type = 'tag' ";
|
$params['sql'] .= "AND META.meta_type = 'tag' ";
|
||||||
}
|
}
|
||||||
|
|
||||||
$rs = $core->auth->sudo(
|
$rs = dcCore::app()->auth->sudo(
|
||||||
[$core->blog, 'getPosts'],
|
[dcCore::app()->blog, 'getPosts'],
|
||||||
$params,
|
$params,
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
@ -358,11 +354,11 @@ class lastpostsextendWidget
|
|||||||
'<' . ($rs->post_status == 1 ? 'a href="' . $rs->getURL() . '"' : 'span') .
|
'<' . ($rs->post_status == 1 ? 'a href="' . $rs->getURL() . '"' : 'span') .
|
||||||
' title="' .
|
' title="' .
|
||||||
dt::dt2str(
|
dt::dt2str(
|
||||||
$core->blog->settings->system->date_format,
|
dcCore::app()->blog->settings->system->date_format,
|
||||||
$rs->post_upddt
|
$rs->post_upddt
|
||||||
) . ', ' .
|
) . ', ' .
|
||||||
dt::dt2str(
|
dt::dt2str(
|
||||||
$core->blog->settings->system->time_format,
|
dcCore::app()->blog->settings->system->time_format,
|
||||||
$rs->post_upddt
|
$rs->post_upddt
|
||||||
) . '">' .
|
) . '">' .
|
||||||
html::escapeHTML($rs->post_title) .
|
html::escapeHTML($rs->post_title) .
|
||||||
@ -376,7 +372,6 @@ class lastpostsextendWidget
|
|||||||
# First image
|
# First image
|
||||||
if ($w->firstimage != '') {
|
if ($w->firstimage != '') {
|
||||||
$res .= self::entryFirstImage(
|
$res .= self::entryFirstImage(
|
||||||
$core,
|
|
||||||
$rs->post_type,
|
$rs->post_type,
|
||||||
$rs->post_id,
|
$rs->post_id,
|
||||||
$w->firstimage
|
$w->firstimage
|
||||||
@ -387,9 +382,9 @@ class lastpostsextendWidget
|
|||||||
if ($w->excerpt) {
|
if ($w->excerpt) {
|
||||||
$excerpt = $rs->post_excerpt;
|
$excerpt = $rs->post_excerpt;
|
||||||
if ($rs->post_format == 'wiki') {
|
if ($rs->post_format == 'wiki') {
|
||||||
$core->initWikiComment();
|
dcCore::app()->initWikiComment();
|
||||||
$excerpt = $core->wikiTransform($excerpt);
|
$excerpt = dcCore::app()->wikiTransform($excerpt);
|
||||||
$excerpt = $core->HTMLfilter($excerpt);
|
$excerpt = dcCore::app()->HTMLfilter($excerpt);
|
||||||
}
|
}
|
||||||
if (strlen($excerpt) > 0) {
|
if (strlen($excerpt) > 0) {
|
||||||
$cut = text::cutString(
|
$cut = text::cutString(
|
||||||
@ -412,15 +407,15 @@ class lastpostsextendWidget
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static function entryFirstImage($core, $type, $id, $size = 's')
|
private static function entryFirstImage($type, $id, $size = 's')
|
||||||
{
|
{
|
||||||
if (!in_array($type, ['post', 'page', 'galitem'])) {
|
if (!in_array($type, ['post', 'page', 'galitem'])) {
|
||||||
|
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
$rs = $core->auth->sudo(
|
$rs = dcCore::app()->auth->sudo(
|
||||||
[$core->blog, 'getPosts'],
|
[dcCore::app()->blog, 'getPosts'],
|
||||||
['post_id' => $id, 'post_type' => $type],
|
['post_id' => $id, 'post_type' => $type],
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
@ -433,13 +428,13 @@ class lastpostsextendWidget
|
|||||||
$size = 's';
|
$size = 's';
|
||||||
}
|
}
|
||||||
|
|
||||||
$p_url = $core->blog->settings->system->public_url;
|
$p_url = dcCore::app()->blog->settings->system->public_url;
|
||||||
$p_site = preg_replace(
|
$p_site = preg_replace(
|
||||||
'#^(.+?//.+?)/(.*)$#',
|
'#^(.+?//.+?)/(.*)$#',
|
||||||
'$1',
|
'$1',
|
||||||
$core->blog->url
|
dcCore::app()->blog->url
|
||||||
);
|
);
|
||||||
$p_root = $core->blog->public_path;
|
$p_root = dcCore::app()->blog->public_path;
|
||||||
|
|
||||||
$pattern = '(?:' . preg_quote($p_site, '/') . ')?' . preg_quote($p_url, '/');
|
$pattern = '(?:' . preg_quote($p_site, '/') . ')?' . preg_quote($p_url, '/');
|
||||||
$pattern = sprintf('/<img.+?src="%s(.*?\.(?:jpg|gif|png))"[^>]+/msu', $pattern);
|
$pattern = sprintf('/<img.+?src="%s(.*?\.(?:jpg|gif|png))"[^>]+/msu', $pattern);
|
||||||
|
Loading…
Reference in New Issue
Block a user