mirror of
https://github.com/felixfoertsch/wordpress-dev-env.git
synced 2026-04-18 15:28:44 +02:00
Initial commit
This commit is contained in:
@@ -0,0 +1,219 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
namespace WCFE\Pluggable;
|
||||
|
||||
#Imports
|
||||
use WCFE\Modules\Editor\Model\EditorModel;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
class DeferredExtender
|
||||
{
|
||||
|
||||
/**
|
||||
* put your comment there...
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
protected $baseNs;
|
||||
|
||||
/**
|
||||
* put your comment there...
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
protected $fields;
|
||||
|
||||
/**
|
||||
* put your comment there...
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
protected $flatFields = array();
|
||||
|
||||
/**
|
||||
* put your comment there...
|
||||
*
|
||||
* @var \WCFE\Plugin
|
||||
*/
|
||||
protected $wcfePlugin;
|
||||
|
||||
/**
|
||||
* put your comment there...
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
protected $uiContainers;
|
||||
|
||||
/**
|
||||
* put your comment there...
|
||||
*
|
||||
* @param \WCFE\Plugin $wcfePlugin
|
||||
* @param mixed $baseNs
|
||||
* @param mixed $fields
|
||||
* @return DeferredExtender
|
||||
*/
|
||||
public function __construct( \WCFE\Plugin & $wcfePlugin, $baseNs, $fields )
|
||||
{
|
||||
# Initialize
|
||||
$this->wcfePlugin =& $wcfePlugin;
|
||||
$this->baseNs = $baseNs;
|
||||
$this->fields = $fields;
|
||||
|
||||
# Model (model-map, form and genertor) fields registration hooks
|
||||
add_filter( \WCFE\hooks::FILTER_MODEL_EDITOR_REGISTER_FIELDS, array( $this, '_registerModelFields' ) );
|
||||
add_filter( \WCFE\hooks::FILTER_MODEL_EDITOR_FORM_FIELDS, array( $this, '_registerFormFields' ) );
|
||||
add_filter( \WCFE\hooks::FILTER_MODEL_EDITOR_GENERATOR_FIELDS, array( $this, '_registerGeneratorFields' ) );
|
||||
|
||||
# View hooks
|
||||
foreach ( $this->fields as $fieldsViewHookName => $fieldsData )
|
||||
{
|
||||
# Register filter for every view/tab/ui-container
|
||||
add_filter( $fieldsViewHookName, array( $this, '_registerViewFields' ) );
|
||||
|
||||
# Aggregate all field names in one array
|
||||
$this->flatFields = array_merge( $this->flatFields, $fieldsData[ 'list' ] );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* put your comment there...
|
||||
*
|
||||
* @param mixed $fields
|
||||
*/
|
||||
public function _registerFormFields( $fields )
|
||||
{
|
||||
|
||||
$fields = $this->buildNsFields( $fields, 'Form' );
|
||||
|
||||
return $fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* put your comment there...
|
||||
*
|
||||
* @param mixed $fields
|
||||
*/
|
||||
public function _registerGeneratorFields( $fields )
|
||||
{
|
||||
|
||||
$fields = $this->buildNsFields( $fields, 'Generator' );
|
||||
|
||||
return $fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* put your comment there...
|
||||
*
|
||||
* @param mixed $fields
|
||||
*/
|
||||
public function _registerModelFields( $fields )
|
||||
{
|
||||
# Reisgter all fields by its given name
|
||||
return array_merge( $fields, $this->flatFields );
|
||||
}
|
||||
|
||||
/**
|
||||
* put your comment there...
|
||||
*
|
||||
* @param mixed $tabs
|
||||
*/
|
||||
public function _registerUIContainers( $list )
|
||||
{
|
||||
|
||||
foreach ( $this->uiContainers as $uiContainer )
|
||||
{
|
||||
$list = array_merge( $list, EditorModel::makeClassesList( $uiContainer ) );
|
||||
}
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
/**
|
||||
* put your comment there...
|
||||
*
|
||||
* @param mixed $fields
|
||||
*/
|
||||
public function _registerViewFields( $fields )
|
||||
{
|
||||
|
||||
# Get requested container fields data fro\\m filter name
|
||||
$filterName = current_filter();
|
||||
$uiContainer = $this->fields[ $filterName ];
|
||||
|
||||
# build fields list
|
||||
$namespace = $this->getUIContainerNamespace( 'Renderer', $uiContainer[ 'namespace' ] );
|
||||
|
||||
$renderersList = EditorModel::makeClassesList( array( $namespace => $uiContainer[ 'list' ] ) );
|
||||
|
||||
return array_merge( $fields, $renderersList );
|
||||
}
|
||||
|
||||
/**
|
||||
* put your comment there...
|
||||
*
|
||||
* @param mixed $coreFields
|
||||
* @param mixed $namespace
|
||||
*/
|
||||
protected function buildNsFields( $coreFields, $typeNamespace )
|
||||
{
|
||||
|
||||
$nsFields = array();
|
||||
|
||||
foreach ( $this->fields as $fieldsData )
|
||||
{
|
||||
|
||||
# Get full namespace for requested type (form ,generator, renderer)
|
||||
$fieldNamespace = $this->getUIContainerNamespace( $typeNamespace, $fieldsData[ 'namespace' ] );
|
||||
|
||||
# Build full field class names (merged with the namespace)
|
||||
$fieldsList = EditorModel::makeClassesList( array( $fieldNamespace => $fieldsData[ 'list' ] ) );
|
||||
|
||||
$nsFields = array_merge( $nsFields, $fieldsList );
|
||||
|
||||
}
|
||||
|
||||
$nsFields = array_merge( $coreFields, $nsFields );
|
||||
|
||||
return $nsFields;
|
||||
}
|
||||
|
||||
/**
|
||||
* put your comment there...
|
||||
*
|
||||
* @param mixed $typeNamespace
|
||||
* @param mixed $uiContainerNs
|
||||
*/
|
||||
protected function getUIContainerNamespace( $typeNamespace, $uiContainerNs )
|
||||
{
|
||||
|
||||
$namespace = "{$this->baseNs}\\{$typeNamespace}\\{$uiContainerNs}";
|
||||
|
||||
return $namespace;
|
||||
}
|
||||
|
||||
/**
|
||||
* put your comment there...
|
||||
*
|
||||
* @param mixed $list
|
||||
*/
|
||||
public function registerUIContainers( $list )
|
||||
{
|
||||
|
||||
$this->uiContainers = $list;
|
||||
|
||||
# Register ui container hooks
|
||||
foreach ( $list as $filterName => $names )
|
||||
{
|
||||
add_filter( $filterName, array( $this, '_registerUIContainers' ) );
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
namespace WCFE;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
abstract class Hooks
|
||||
{
|
||||
|
||||
const ACTION_PLUGIN_BINDING_HOOKS = 'wcfe_plugin-binding-hooks';
|
||||
const ACTION_PLUGIN_LOADED = 'wcfe_plugin-loaded';
|
||||
|
||||
const FILTER_MODEL_EDITOR_FORM_FIELDS = 'wcfe_model-editor-form-fields';
|
||||
const FILTER_MODEL_EDITOR_GENERATOR_FIELDS = 'wcfe_model-editor-generator-fields';
|
||||
const FILTER_MODEL_EDITOR_REGISTER_FIELDS = 'wcfe_model-editor-register-fields';
|
||||
|
||||
const FILTER_VIEW_TABS_REGISTER_TABS = 'wcfe_view-tabs-register-tabs';
|
||||
|
||||
const FILTER_VIEW_TABS_TAB_DATABASE_FIELDS = 'wcfe_view-tabs-tab-database-fields';
|
||||
const FILTER_VIEW_TABS_TAB_DEVELOPER_FIELDS = 'wcfe_view-tabs-tab-developer-fields';
|
||||
const FILTER_VIEW_TABS_TAB_LOCALIZATION_FIELDS = 'wcfe_view-tabs-tab-localization-fields';
|
||||
const FILTER_VIEW_TABS_TAB_MAINTENANCE_FIELDS = 'wcfe_view-tabs-tab-maintenance-fields';
|
||||
const FILTER_VIEW_TABS_TAB_MULTISITE_FIELDS = 'wcfe_view-tabs-tab-multisite-fields';
|
||||
const FILTER_VIEW_TABS_TAB_SECUREKEYS_FIELDS = 'wcfe_view-tabs-tab-securekeys-fields';
|
||||
const FILTER_VIEW_TABS_TAB_POST_FIELDS = 'wcfe_view-tabs-tab-post-fields';
|
||||
const FILTER_VIEW_TABS_TAB_CRON_FIELDS = 'wcfe_view-tabs-tab-cron-fields';
|
||||
const FILTER_VIEW_TABS_TAB_SECURITY_FIELDS = 'wcfe_view-tabs-tab-security-fields';
|
||||
const FILTER_VIEW_TABS_TAB_PATHS_FIELDS = 'wcfe_view-tabs-tab-paths-fields';
|
||||
const FILTER_VIEW_TABS_TAB_UPGRADE_FIELDS = 'wcfe_view-tabs-tab-upgrade-fields';
|
||||
const FILTER_VIEW_TABS_TAB_PROXY_FIELDS = 'wcfe_view-tabs-tab-proxy-fields';
|
||||
const FILTER_VIEW_TABS_TAB_COOKIES_FIELDS = 'wcfe_view-tabs-tab-cookies-fields';
|
||||
|
||||
# SYS Filters Hooks
|
||||
const FILTER_VIEW_TABS_SYSFILTERS_REGISTER_TABS = 'wcfe_view-tabs-sysfilters-register-tabs';
|
||||
const FILTER_VIEW_TABS_TAB_SYSFILTERS_HTTP_FIELDS = 'wcfe_view-tabs-tab-sysfilters-http-fields';
|
||||
const FILTER_VIEW_TABS_TAB_SYSFILTERS_EDITOR_FIELDS = 'wcfe_view-tabs-tab-sysfilters-editor-fields';
|
||||
const FILTER_VIEW_TABS_TAB_SYSFILTERS_MISC_FIELDS = 'wcfe_view-tabs-tab-sysfilters-misc-fields';
|
||||
const FILTER_VIEW_TABS_TAB_SYSFILTERS_KSES_FIELDS = 'wcfe_view-tabs-tab-sysfilters-kses-fields';
|
||||
}
|
||||
Reference in New Issue
Block a user