use dotclear methods for widget

This commit is contained in:
Jean-Christian Denis 2022-12-08 22:27:25 +01:00
parent 7b66f9ebda
commit bdbab6f9de
Signed by: JcDenis
GPG key ID: 1B5B8C5B90B6C951

View file

@ -32,12 +32,7 @@ class lastpostsextendWidget
__('Extended list of entries') __('Extended list of entries')
); );
# Title # Title
$w->lastpostsextend->setting( $w->lastpostsextend->addTitle(__('Last entries'));
'title',
__('Title:'),
__('Last entries'),
'text'
);
# type # type
$posttypes = [ $posttypes = [
__('Post') => 'post', __('Post') => 'post',
@ -204,38 +199,12 @@ class lastpostsextendWidget
0, 0,
'check' 'check'
); );
# Home only # common
$w->lastpostsextend->setting( $w->lastpostsextend
'homeonly', ->addHomeOnly()
__('Display on:'), ->addContentOnly()
0, ->addClass()
'combo', ->addOffline();
[
__('All pages') => 0,
__('Home page only') => 1,
__('Except on home page') => 2,
]
);
# widget option - content only
$w->lastpostsextend->setting(
'content_only',
__('Content only'),
0,
'check'
);
# widget option - additionnal CSS
$w->lastpostsextend->setting(
'class',
__('CSS class:'),
''
);
# widget option - put offline
$w->lastpostsextend->setting(
'offline',
__('Offline'),
0,
'check'
);
} }
public static function parseWidget($w) public static function parseWidget($w)
@ -252,8 +221,8 @@ class lastpostsextendWidget
} }
# Home page only # Home page only
if ($w->homeonly == 1 && dcCore::app()->url->type != 'default' if (($w->homeonly == 1 && !dcCore::app()->url->isHome(dcCore::app()->url->type))
|| $w->homeonly == 2 && dcCore::app()->url->type == 'default') { || ($w->homeonly == 2 && dcCore::app()->url->isHome(dcCore::app()->url->type))) {
return null; return null;
} }
@ -323,7 +292,7 @@ class lastpostsextendWidget
foreach ($tags as $i => $tag) { foreach ($tags as $i => $tag) {
$tags[$i] = trim($tag); $tags[$i] = trim($tag);
} }
$params['from'] .= ', ' . dcCore::app()->prefix . 'meta META '; $params['from'] .= ', ' . dcCore::app()->prefix . dcMeta::META_TABLE_NAME . ' 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 ' . dcCore::app()->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' ";