PHP 클래스 ThemePlugin, pkp-lib

상속: extends LazyLoadPlugin
파일 보기 프로젝트 열기: pkp/pkp-lib 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$options Theme-specific options
$parent Parent theme (optional)
$scripts Collection of scripts
$styles Collection of styles

공개 메소드들

메소드 설명
__construct ( ) Constructor
_getBaseDir ( $path = '' ) : string Get the base path to be used for file references
_getBaseUrl ( $path = '' ) : string Get the base URL to be used for file paths
_registerScripts ( ) : null Register script assets
addOption ( $name, $type, $args = [] ) Add a theme option
addScript ( $name, $script, $args = [] ) Add a script to load with this theme
addStyle ( $name, $style, $args = [] ) Add a stylesheet to load with this theme
getOption ( $name ) : mixed Get the value of an option or default if the option is not set
getOptionConfig ( $name ) : false | array Get an option's configuration settings
getOptionValues ( ) : array Get all option values
getOptionsConfig ( ) : array Get all options' configuration settings.
getScript ( $name ) : array | null Get a script from this theme or any parent theme
getStyle ( $name ) : array | null Get a style from this theme or any parent theme
init ( ) : null The primary method themes should use to add styles, scripts and fonts, or register hooks. This method is only fired for the currently active theme.
initAfter ( ) Perform actions after the theme has been initialized
isActive ( ) : boolean Determine whether or not this plugin is currently active
isColourDark ( $colour, $limit = 130 ) Check if the passed colour is dark
modifyOptionsConfig ( $name, $args = [] ) : boolean Modify option configuration settings
modifyScript ( $name, $args = [] ) : null Modify the params of an existing script
modifyStyle ( $name, $args = [] ) : null Modify the params of an existing stylesheet
readOptionsFormUserVars ( $hookName, $args ) Retrieve user-entered values for options from any form
register ( $category, $path )
removeOption ( $name ) : boolean Remove an option
removeScript ( $name ) : boolean Remove a registered script
removeStyle ( $name ) : boolean Remove a registered stylesheet
saveOption ( $name, $value, $contextId = null ) Sanitize and save a theme option
saveOptionsForm ( $hookName, $args ) Save options in any form
setParent ( $parent ) : null Set a parent theme for this theme
themeRegistered ( $themes ) : null Fire the init() method when a theme is registered

비공개 메소드들

메소드 설명
_registerStyles ( ) : null Register stylesheets and font assets
_registerTemplates ( ) : null Register directories to search for template files

메소드 상세

__construct() 공개 메소드

Constructor
public __construct ( )

_getBaseDir() 공개 메소드

Get the base path to be used for file references
public _getBaseDir ( $path = '' ) : string
$path string An optional path to append to the base
리턴 string

_getBaseUrl() 공개 메소드

A base URL for loading LESS/CSS/JS files in elements. It will also be set to the @baseUrl variable before LESS files are compiloed so that images and fonts can be located.
public _getBaseUrl ( $path = '' ) : string
$path string An optional path to append to the base
리턴 string

_registerScripts() 공개 메소드

Passes scripts defined by the theme to the template manager for handling.
public _registerScripts ( ) : null
리턴 null

addOption() 공개 메소드

Theme options are added programmatically to the Settings > Website > Appearance form when this theme is activated. Common options are colour and typography selectors.
public addOption ( $name, $type, $args = [] )
$name string Unique name for this setting
$type string A pre-registered type of setting. Supported values: text|colour|radio. Default: `text`
$args array Optional parameters defining this setting. Some setting types may accept or require additional arguments. `label` string Locale key for a label for this field. `description` string Locale key for a description for this field. `default` mixed A default value. Default: ''

addScript() 공개 메소드

Add a script to load with this theme
public addScript ( $name, $script, $args = [] )
$name string A name for this script
$script string The script to be included. Should be path relative to the theme or, if the `inline` argument is included, script data to be output.
$args array Optional arguments hash. Supported args: `context` string Whether to load this on the `frontend` or `backend`. default: frontend `priority` int Controls order in which scripts are printed default: STYLE_SEQUENCE_NORMAL `inline` bool Whether the $script value should be output directly as script data. Used to pass backend data to the scripts.

addStyle() 공개 메소드

Style paths with a .less extension will be compiled and redirected to the compiled file.
public addStyle ( $name, $style, $args = [] )
$name string A name for this stylesheet
$style string The stylesheet. Should be a path relative to the theme directory or, if the `inline` argument is included, style data to be output.
$args array Optional arguments hash. Supported args: 'context': Whether to load this on the `frontend` or `backend`. default: `frontend` 'priority': Controls order in which styles are printed 'addLess': Additional LESS files to process before compiling. Array 'addLessVariables': A string containing additional LESS variables to parse before compiling. Example: "@bg:#000;" `inline` bool Whether the $style value should be output directly as style data.

getOption() 공개 메소드

Get the value of an option or default if the option is not set
public getOption ( $name ) : mixed
$name The name of the option value to retrieve
리턴 mixed The value of the option. Will return a default if set in the option config. False if no option exists

getOptionConfig() 공개 메소드

This retrives option settings for any option attached to this theme or any parent theme.
public getOptionConfig ( $name ) : false | array
$name The name of the option config to retrieve
리턴 false | array The config array for this option. Or false if no config is found.

getOptionValues() 공개 메소드

This retrieves a single array containing option values for this theme and any parent themes.
public getOptionValues ( ) : array
리턴 array

getOptionsConfig() 공개 메소드

This retrieves a single array containing options settings for this theme and any parent themes.
public getOptionsConfig ( ) : array
리턴 array

getScript() 공개 메소드

Get a script from this theme or any parent theme
public getScript ( $name ) : array | null
$name string The name of the script to retrieve
리턴 array | null Reference to the script or null if not found

getStyle() 공개 메소드

Get a style from this theme or any parent theme
public getStyle ( $name ) : array | null
$name string The name of the style to retrieve
리턴 array | null Reference to the style or null if not found

init() 추상적인 공개 메소드

The primary method themes should use to add styles, scripts and fonts, or register hooks. This method is only fired for the currently active theme.
abstract public init ( ) : null
리턴 null

initAfter() 공개 메소드

Registers templates, styles and scripts that have been added by the theme or any parent themes
public initAfter ( )

isActive() 공개 메소드

This only returns true if the theme is currently the selected theme in a given context. Use self::getEnabled() if you want to know if the theme is available for use on the site.
public isActive ( ) : boolean
리턴 boolean

isColourDark() 공개 메소드

This is a utility function to determine the darkness of a hex colour. This is designed to be used in theme colour options, so that text can be adjusted to ensure it's readable on light or dark backgrounds. You can specify the brightness threshold by passing in a $limit value. Higher values are brighter. Based on: http://stackoverflow.com/a/8468448/1723499
부터: 0.1
public isColourDark ( $colour, $limit = 130 )

modifyOptionsConfig() 공개 메소드

Modify option configuration settings
public modifyOptionsConfig ( $name, $args = [] ) : boolean
$name The name of the option config to retrieve
$args The new configuration settings for this option
리턴 boolean Whether the option was found and the config was updated.

modifyScript() 공개 메소드

Modify the params of an existing script
또한 보기: self::addScript()
public modifyScript ( $name, $args = [] ) : null
$name string The name of the script to modify
$args array Parameters to modify.
리턴 null

modifyStyle() 공개 메소드

Modify the params of an existing stylesheet
또한 보기: self::addStyle()
public modifyStyle ( $name, $args = [] ) : null
$name string The name of the stylesheet to modify
$args array Parameters to modify.
리턴 null

readOptionsFormUserVars() 공개 메소드

This helper function allows you to hook into any form to add theme option values to the form's user input data.
또한 보기: Form::readUserVar()
public readOptionsFormUserVars ( $hookName, $args )
$hookName string
$args array Arguments passed via the hook `form` Form The form object from which option values can be retrieved. `vars` Array Key/value store of the user vars read by the form

register() 공개 메소드

public register ( $category, $path )

removeOption() 공개 메소드

Remove an option
public removeOption ( $name ) : boolean
$name The name of the option to remove
리턴 boolean Whether the option was found and removed

removeScript() 공개 메소드

Remove a registered script
public removeScript ( $name ) : boolean
$name string The name of the script to remove
리턴 boolean Whether or not the stylesheet was found and removed.

removeStyle() 공개 메소드

Remove a registered stylesheet
public removeStyle ( $name ) : boolean
$name string The name of the stylesheet to remove
리턴 boolean Whether or not the stylesheet was found and removed.

saveOption() 공개 메소드

Sanitize and save a theme option
public saveOption ( $name, $value, $contextId = null )
$name string A unique id for the option to save
$value mixed The new value to save
$contextId int Optional context id. Defaults to the current context

saveOptionsForm() 공개 메소드

This helper function allows you to save theme options attached to any form by hooking into the form's execute function.
또한 보기: Form::execute()
public saveOptionsForm ( $hookName, $args )
$hookName string
$args array Arguments passed via the hook `form` Form The form object from which option values can be retrieved. `request` Request

setParent() 공개 메소드

Set a parent theme for this theme
public setParent ( $parent ) : null
$parent string Key in the plugin registry for the parent theme
리턴 null

themeRegistered() 공개 메소드

Fire the init() method when a theme is registered
public themeRegistered ( $themes ) : null
$themes array List of all loaded themes
리턴 null

프로퍼티 상세

$options 공개적으로 프로퍼티

Theme-specific options
public $options

$parent 공개적으로 프로퍼티

Parent theme (optional)
public $parent

$scripts 공개적으로 프로퍼티

Collection of scripts
또한 보기: self::_registerScripts
public $scripts

$styles 공개적으로 프로퍼티

Collection of styles
또한 보기: self::_registerStyles
public $styles