mirror of
https://github.com/getgrav/grav-plugin-admin.git
synced 2026-05-05 17:55:37 +02:00
Added keysOnly parameter to AdminPlugin::pagesTypes() and AdminPlugin::pagesModularTypes() methods, ignore parameter to Admin::types() and Admin::modularTypes() methods
This commit is contained in:
@@ -5,7 +5,8 @@
|
||||
* Enable admin cache by default (for existing sites, check `Plugins > Admin Panel > Enable Admin Caching`)
|
||||
* [](#improved)
|
||||
* Removed old `scss.sh` and `watch.sh` scripts, use `gulp watch-css`
|
||||
* Added a filter page type ignore list to admin configuration
|
||||
* Added keysOnly parameter to `AdminPlugin::pagesTypes()` and `AdminPlugin::pagesModularTypes()` methods
|
||||
* Added ignore parameter to `Admin::types()` and `Admin::modularTypes()` methods
|
||||
1. [](#bugfix)
|
||||
* Fixed minor UI padding in Flex pages [#1825](https://github.com/getgrav/grav-plugin-admin/issues/1825)
|
||||
|
||||
|
||||
28
admin.php
28
admin.php
@@ -842,14 +842,14 @@ class AdminPlugin extends Plugin
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to replace Pages::Types()
|
||||
* and to provide an event to manipulate the data
|
||||
* Helper function to replace Pages::Types() and to provide an event to manipulate the data
|
||||
*
|
||||
* Dispatches 'onAdminPageTypes' event
|
||||
* with 'types' data member which is a
|
||||
* reference to the data
|
||||
* Dispatches 'onAdminPageTypes' event with 'types' data member which is a reference to the data
|
||||
*
|
||||
* @param bool $keysOnly
|
||||
* @return array
|
||||
*/
|
||||
public static function pagesTypes()
|
||||
public static function pagesTypes(bool $keysOnly = false)
|
||||
{
|
||||
$types = Pages::types();
|
||||
|
||||
@@ -863,18 +863,18 @@ class AdminPlugin extends Plugin
|
||||
$e = new Event(['types' => &$types]);
|
||||
Grav::instance()->fireEvent('onAdminPageTypes', $e);
|
||||
|
||||
return $types;
|
||||
return $keysOnly ? array_keys($types) : $types;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to replace Pages::modularTypes()
|
||||
* and to provide an event to manipulate the data
|
||||
* Helper function to replace Pages::modularTypes() and to provide an event to manipulate the data
|
||||
*
|
||||
* Dispatches 'onAdminModularPageTypes' event
|
||||
* with 'types' data member which is a
|
||||
* reference to the data
|
||||
* Dispatches 'onAdminModularPageTypes' event with 'types' data member which is a reference to the data
|
||||
*
|
||||
* @param bool $keysOnly
|
||||
* @return array
|
||||
*/
|
||||
public static function pagesModularTypes()
|
||||
public static function pagesModularTypes(bool $keysOnly = false)
|
||||
{
|
||||
$types = Pages::modularTypes();
|
||||
|
||||
@@ -888,7 +888,7 @@ class AdminPlugin extends Plugin
|
||||
$e = new Event(['types' => &$types]);
|
||||
Grav::instance()->fireEvent('onAdminModularPageTypes', $e);
|
||||
|
||||
return $types;
|
||||
return $keysOnly ? array_keys($types) : $types;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -45,6 +45,3 @@ popularity:
|
||||
daily: 30
|
||||
monthly: 12
|
||||
visitors: 20
|
||||
flex_pages:
|
||||
filters:
|
||||
ignore: [simplesearch_results]
|
||||
|
||||
@@ -462,18 +462,3 @@ form:
|
||||
type: hidden
|
||||
label: Visitors history
|
||||
default: 20
|
||||
|
||||
section_flex:
|
||||
type: section
|
||||
title: Flex Pages
|
||||
underline: true
|
||||
|
||||
flex_pages.filters.ignore:
|
||||
type: selectize
|
||||
size: large
|
||||
label: Filters - Ignore Page Types
|
||||
help: Page types such as default, modular, simplesearch_results, etc
|
||||
classes: fancy
|
||||
# data-options@: '\Grav\Plugin\AdminPlugin::pagesTypes'
|
||||
validate:
|
||||
type: commalist
|
||||
|
||||
@@ -36,6 +36,7 @@ use Grav\Framework\Flex\Interfaces\FlexInterface;
|
||||
use Grav\Framework\Flex\Interfaces\FlexObjectInterface;
|
||||
use Grav\Framework\Route\Route;
|
||||
use Grav\Framework\Route\RouteFactory;
|
||||
use Grav\Plugin\AdminPlugin;
|
||||
use Grav\Plugin\Login\Login;
|
||||
use Grav\Plugin\Login\TwoFactorAuth\TwoFactorAuth;
|
||||
use PicoFeed\Parser\MalformedXmlException;
|
||||
@@ -986,21 +987,35 @@ class Admin
|
||||
/**
|
||||
* Get all template types
|
||||
*
|
||||
* @param array|null $ignore
|
||||
* @return array
|
||||
*/
|
||||
public function types()
|
||||
public function types(?array $ignore = [])
|
||||
{
|
||||
return Pages::types();
|
||||
if (null === $ignore) {
|
||||
return AdminPlugin::pagesTypes();
|
||||
}
|
||||
|
||||
$types = Pages::types();
|
||||
|
||||
return $ignore ? array_diff_key($types, array_flip($ignore)) : $types;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all modular template types
|
||||
*
|
||||
* @param array|null $ignore
|
||||
* @return array
|
||||
*/
|
||||
public function modularTypes()
|
||||
public function modularTypes(?array $ignore = [])
|
||||
{
|
||||
return Pages::modularTypes();
|
||||
if (null === $ignore) {
|
||||
return AdminPlugin::pagesModularTypes();
|
||||
}
|
||||
|
||||
$types = Pages::modularTypes();
|
||||
|
||||
return $ignore ? array_diff_key($types, array_flip($ignore)) : $types;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user