fix nullsafe warning
This commit is contained in:
parent
76b78278e0
commit
6e656d65f8
@ -16,7 +16,6 @@ namespace Dotclear\Plugin\fac;
|
|||||||
|
|
||||||
use cursor;
|
use cursor;
|
||||||
use ArrayObject;
|
use ArrayObject;
|
||||||
use dcAuth;
|
|
||||||
use dcCore;
|
use dcCore;
|
||||||
use dcPage;
|
use dcPage;
|
||||||
use dcPostsActions;
|
use dcPostsActions;
|
||||||
@ -79,6 +78,9 @@ class BackendBehaviors
|
|||||||
*/
|
*/
|
||||||
public static function adminBlogPreferencesFormV2(dcSettings $blog_settings): void
|
public static function adminBlogPreferencesFormV2(dcSettings $blog_settings): void
|
||||||
{
|
{
|
||||||
|
if (is_null(dcCore::app()->auth) || is_null(dcCore::app()->adminurl)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
$lines = '';
|
$lines = '';
|
||||||
$fac_public_tpltypes = json_decode($blog_settings->get(My::id())->get('public_tpltypes'), true);
|
$fac_public_tpltypes = json_decode($blog_settings->get(My::id())->get('public_tpltypes'), true);
|
||||||
if (!is_array($fac_public_tpltypes)) {
|
if (!is_array($fac_public_tpltypes)) {
|
||||||
@ -168,7 +170,7 @@ class BackendBehaviors
|
|||||||
*/
|
*/
|
||||||
public static function adminPostFormItems(ArrayObject $main_items, ArrayObject $sidebar_items, ?dcRecord $post): void
|
public static function adminPostFormItems(ArrayObject $main_items, ArrayObject $sidebar_items, ?dcRecord $post): void
|
||||||
{
|
{
|
||||||
if (!dcCore::app()->blog->settings->get(My::id())->get('active')) {
|
if (is_null(dcCore::app()->blog) || !dcCore::app()->blog->settings->get(My::id())->get('active')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -231,7 +233,7 @@ class BackendBehaviors
|
|||||||
*/
|
*/
|
||||||
public static function adminPostsActions(dcPostsActions $pa): void
|
public static function adminPostsActions(dcPostsActions $pa): void
|
||||||
{
|
{
|
||||||
if (!dcCore::app()->blog->settings->get(My::id())->get('active')) {
|
if (is_null(dcCore::app()->blog) || is_null(dcCore::app()->auth) || !dcCore::app()->blog->settings->get(My::id())->get('active')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -241,8 +243,8 @@ class BackendBehaviors
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (!dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([
|
if (!dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([
|
||||||
dcAuth::PERMISSION_DELETE,
|
dcCore::app()->auth::PERMISSION_DELETE,
|
||||||
dcAuth::PERMISSION_CONTENT_ADMIN,
|
dcCore::app()->auth::PERMISSION_CONTENT_ADMIN,
|
||||||
]), dcCore::app()->blog->id)) {
|
]), dcCore::app()->blog->id)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -260,6 +262,9 @@ class BackendBehaviors
|
|||||||
*/
|
*/
|
||||||
public static function callbackRemove(dcPostsActions $pa, ArrayObject $post): void
|
public static function callbackRemove(dcPostsActions $pa, ArrayObject $post): void
|
||||||
{
|
{
|
||||||
|
if (is_null(dcCore::app()->blog) || is_null(dcCore::app()->auth)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
# No entry
|
# No entry
|
||||||
$posts_ids = $pa->getIDs();
|
$posts_ids = $pa->getIDs();
|
||||||
if (empty($posts_ids)) {
|
if (empty($posts_ids)) {
|
||||||
@ -268,8 +273,8 @@ class BackendBehaviors
|
|||||||
|
|
||||||
# No right
|
# No right
|
||||||
if (!dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([
|
if (!dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([
|
||||||
dcAuth::PERMISSION_DELETE,
|
dcCore::app()->auth::PERMISSION_DELETE,
|
||||||
dcAuth::PERMISSION_CONTENT_ADMIN,
|
dcCore::app()->auth::PERMISSION_CONTENT_ADMIN,
|
||||||
]), dcCore::app()->blog->id)) {
|
]), dcCore::app()->blog->id)) {
|
||||||
throw new Exception(__('No enough right'));
|
throw new Exception(__('No enough right'));
|
||||||
}
|
}
|
||||||
@ -291,6 +296,9 @@ class BackendBehaviors
|
|||||||
*/
|
*/
|
||||||
public static function callbackAdd(dcPostsActions $pa, ArrayObject $post): void
|
public static function callbackAdd(dcPostsActions $pa, ArrayObject $post): void
|
||||||
{
|
{
|
||||||
|
if (is_null(dcCore::app()->blog)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
# No entry
|
# No entry
|
||||||
$posts_ids = $pa->getIDs();
|
$posts_ids = $pa->getIDs();
|
||||||
if (empty($posts_ids)) {
|
if (empty($posts_ids)) {
|
||||||
@ -341,7 +349,7 @@ class BackendBehaviors
|
|||||||
*/
|
*/
|
||||||
protected static function formFeed(string $url = '', string $format = ''): string
|
protected static function formFeed(string $url = '', string $format = ''): string
|
||||||
{
|
{
|
||||||
if (!dcCore::app()->blog->settings->get(My::id())->get('active')) {
|
if (is_null(dcCore::app()->blog) || !dcCore::app()->blog->settings->get(My::id())->get('active')) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -369,6 +377,9 @@ class BackendBehaviors
|
|||||||
*/
|
*/
|
||||||
protected static function comboFac(): array
|
protected static function comboFac(): array
|
||||||
{
|
{
|
||||||
|
if (is_null(dcCore::app()->blog)) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
$formats = json_decode(dcCore::app()->blog->settings->get(My::id())->get('formats'), true);
|
$formats = json_decode(dcCore::app()->blog->settings->get(My::id())->get('formats'), true);
|
||||||
if (!is_array($formats) || empty($formats)) {
|
if (!is_array($formats) || empty($formats)) {
|
||||||
return [];
|
return [];
|
||||||
|
@ -35,7 +35,8 @@ class Config extends dcNsProcess
|
|||||||
public static function init(): bool
|
public static function init(): bool
|
||||||
{
|
{
|
||||||
static::$init == defined('DC_CONTEXT_ADMIN')
|
static::$init == defined('DC_CONTEXT_ADMIN')
|
||||||
&& dcCore::app()->auth?->isSuperAdmin();
|
&& !is_null(dcCore::app()->auth)
|
||||||
|
&& dcCore::app()->auth->isSuperAdmin();
|
||||||
|
|
||||||
return static::$init;
|
return static::$init;
|
||||||
}
|
}
|
||||||
@ -46,6 +47,11 @@ class Config extends dcNsProcess
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//nullsafe
|
||||||
|
if (is_null(dcCore::app()->blog) || is_null(dcCore::app()->adminurl)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$redir = empty($_REQUEST['redir']) ?
|
$redir = empty($_REQUEST['redir']) ?
|
||||||
dcCore::app()->admin->__get('list')->getURL() . '#plugins' : $_REQUEST['redir'];
|
dcCore::app()->admin->__get('list')->getURL() . '#plugins' : $_REQUEST['redir'];
|
||||||
|
|
||||||
@ -85,7 +91,7 @@ class Config extends dcNsProcess
|
|||||||
dcPage::addSuccessNotice(
|
dcPage::addSuccessNotice(
|
||||||
__('Configuration successfully updated.')
|
__('Configuration successfully updated.')
|
||||||
);
|
);
|
||||||
dcCore::app()->adminurl?->redirect(
|
dcCore::app()->adminurl->redirect(
|
||||||
'admin.plugins',
|
'admin.plugins',
|
||||||
['module' => My::id(), 'conf' => 1, 'redir' => dcCore::app()->admin->__get('list')->getRedir()]
|
['module' => My::id(), 'conf' => 1, 'redir' => dcCore::app()->admin->__get('list')->getRedir()]
|
||||||
);
|
);
|
||||||
@ -102,6 +108,12 @@ class Config extends dcNsProcess
|
|||||||
if (!static::$init) {
|
if (!static::$init) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//nullsafe
|
||||||
|
if (is_null(dcCore::app()->blog)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$s = dcCore::app()->blog->settings->get(My::id());
|
$s = dcCore::app()->blog->settings->get(My::id());
|
||||||
|
|
||||||
$fac_formats = json_decode($s->get('formats'), true);
|
$fac_formats = json_decode($s->get('formats'), true);
|
||||||
|
@ -33,24 +33,29 @@ class Frontend extends dcNsProcess
|
|||||||
|
|
||||||
public static function process(): bool
|
public static function process(): bool
|
||||||
{
|
{
|
||||||
if (!static::$init || !dcCore::app()->blog->settings->get(My::id())->get('active')) {
|
if (!static::$init || is_null(dcCore::app()->blog) || !dcCore::app()->blog->settings->get(My::id())->get('active')) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
dcCore::app()->addBehavior('publicEntryAfterContent', function (dcCore $core, context $_ctx): void {
|
dcCore::app()->addBehavior('publicEntryAfterContent', function (dcCore $core, context $_ctx): void {
|
||||||
# Not a post
|
//nullsafe
|
||||||
|
if (is_null(dcCore::app()->blog) || is_null(dcCore::app()->ctx)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Not a post
|
||||||
if (!dcCore::app()->ctx->exists('posts')) {
|
if (!dcCore::app()->ctx->exists('posts')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Not in page to show
|
// Not in page to show
|
||||||
$types = json_decode((string) dcCore::app()->blog->settings->get(My::id())->get('public_tpltypes'), true);
|
$types = json_decode((string) dcCore::app()->blog->settings->get(My::id())->get('public_tpltypes'), true);
|
||||||
if (!is_array($types)
|
if (!is_array($types)
|
||||||
|| !in_array(dcCore::app()->url->type, $types)) {
|
|| !in_array(dcCore::app()->url->type, $types)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Get related feed
|
// Get related feed
|
||||||
$fac_url = dcCore::app()->meta->getMetadata([
|
$fac_url = dcCore::app()->meta->getMetadata([
|
||||||
'meta_type' => 'fac',
|
'meta_type' => 'fac',
|
||||||
'post_id' => dcCore::app()->ctx->__get('posts')->f('post_id'),
|
'post_id' => dcCore::app()->ctx->__get('posts')->f('post_id'),
|
||||||
@ -60,7 +65,7 @@ class Frontend extends dcNsProcess
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Get related format
|
// Get related format
|
||||||
$fac_format = dcCore::app()->meta->getMetadata([
|
$fac_format = dcCore::app()->meta->getMetadata([
|
||||||
'meta_type' => 'facformat',
|
'meta_type' => 'facformat',
|
||||||
'post_id' => dcCore::app()->ctx->__get('posts')->f('post_id'),
|
'post_id' => dcCore::app()->ctx->__get('posts')->f('post_id'),
|
||||||
@ -70,7 +75,7 @@ class Frontend extends dcNsProcess
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Get format info
|
// Get format info
|
||||||
$default_format = [
|
$default_format = [
|
||||||
'name' => 'default',
|
'name' => 'default',
|
||||||
'dateformat' => '',
|
'dateformat' => '',
|
||||||
@ -98,7 +103,7 @@ class Frontend extends dcNsProcess
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
# Read feed url
|
// Read feed url
|
||||||
$cache = is_dir(DC_TPL_CACHE . '/fac') ? DC_TPL_CACHE . '/fac' : null;
|
$cache = is_dir(DC_TPL_CACHE . '/fac') ? DC_TPL_CACHE . '/fac' : null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -107,12 +112,12 @@ class Frontend extends dcNsProcess
|
|||||||
$feed = null;
|
$feed = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
# No entries
|
// No entries
|
||||||
if (!$feed) {
|
if (!$feed) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Feed title
|
// Feed title
|
||||||
$feedtitle = '';
|
$feedtitle = '';
|
||||||
if ('' != dcCore::app()->blog->settings->get(My::id())->get('defaultfeedtitle')) {
|
if ('' != dcCore::app()->blog->settings->get(My::id())->get('defaultfeedtitle')) {
|
||||||
$feedtitle = '<h3>' . Html::escapeHTML(
|
$feedtitle = '<h3>' . Html::escapeHTML(
|
||||||
@ -130,7 +135,7 @@ class Frontend extends dcNsProcess
|
|||||||
) . '</h3>';
|
) . '</h3>';
|
||||||
}
|
}
|
||||||
|
|
||||||
# Feed desc
|
// Feed desc
|
||||||
$feeddesc = '';
|
$feeddesc = '';
|
||||||
if (dcCore::app()->blog->settings->get(My::id())->get('showfeeddesc')
|
if (dcCore::app()->blog->settings->get(My::id())->get('showfeeddesc')
|
||||||
&& '' != $feed->description) {
|
&& '' != $feed->description) {
|
||||||
@ -140,12 +145,12 @@ class Frontend extends dcNsProcess
|
|||||||
) . '</p>';
|
) . '</p>';
|
||||||
}
|
}
|
||||||
|
|
||||||
# Date format
|
// Date format
|
||||||
$dateformat = '' != $format['dateformat'] ?
|
$dateformat = '' != $format['dateformat'] ?
|
||||||
$format['dateformat'] :
|
$format['dateformat'] :
|
||||||
dcCore::app()->blog->settings->get('system')->get('date_format') . ',' . dcCore::app()->blog->settings->get('system')->get('time_format');
|
dcCore::app()->blog->settings->get('system')->get('date_format') . ',' . dcCore::app()->blog->settings->get('system')->get('time_format');
|
||||||
|
|
||||||
# Enrties limit
|
// Enrties limit
|
||||||
$entrieslimit = abs((int) $format['lineslimit']);
|
$entrieslimit = abs((int) $format['lineslimit']);
|
||||||
$uselimit = $entrieslimit > 0 ? true : false;
|
$uselimit = $entrieslimit > 0 ? true : false;
|
||||||
|
|
||||||
@ -159,7 +164,7 @@ class Frontend extends dcNsProcess
|
|||||||
# Format date
|
# Format date
|
||||||
$date = Date::dt2str($dateformat, $item->pubdate);
|
$date = Date::dt2str($dateformat, $item->pubdate);
|
||||||
|
|
||||||
# Entries title
|
// Entries title
|
||||||
$title = context::global_filters(
|
$title = context::global_filters(
|
||||||
str_replace(
|
str_replace(
|
||||||
[
|
[
|
||||||
@ -181,7 +186,7 @@ class Frontend extends dcNsProcess
|
|||||||
['remove_html', 'cut_string' => abs((int) $format['linestitlelength'])],
|
['remove_html', 'cut_string' => abs((int) $format['linestitlelength'])],
|
||||||
);
|
);
|
||||||
|
|
||||||
# Entries over title
|
// Entries over title
|
||||||
$overtitle = context::global_filters(
|
$overtitle = context::global_filters(
|
||||||
str_replace(
|
str_replace(
|
||||||
[
|
[
|
||||||
@ -203,7 +208,7 @@ class Frontend extends dcNsProcess
|
|||||||
['remove_html', 'cut_string' => 350],
|
['remove_html', 'cut_string' => 350],
|
||||||
);
|
);
|
||||||
|
|
||||||
# Entries description
|
// Entries description
|
||||||
$description = '';
|
$description = '';
|
||||||
if ($format['showlinesdescription']
|
if ($format['showlinesdescription']
|
||||||
&& '' != $item->description) {
|
&& '' != $item->description) {
|
||||||
@ -214,7 +219,7 @@ class Frontend extends dcNsProcess
|
|||||||
) . '</dd>';
|
) . '</dd>';
|
||||||
}
|
}
|
||||||
|
|
||||||
# Entries content
|
// Entries content
|
||||||
$content = '';
|
$content = '';
|
||||||
if ($format['showlinescontent']
|
if ($format['showlinescontent']
|
||||||
&& '' != $item->content) {
|
&& '' != $item->content) {
|
||||||
|
@ -35,6 +35,10 @@ class Install extends dcNsProcess
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (is_null(dcCore::app()->blog)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Module specs
|
// Module specs
|
||||||
$mod_conf = [
|
$mod_conf = [
|
||||||
[
|
[
|
||||||
|
Loading…
Reference in New Issue
Block a user