Open Journal Systems  3.3.0
ThemePlugin Class Reference
Inheritance diagram for ThemePlugin:
LazyLoadPlugin Plugin BootstrapThreeThemePlugin CriticalTimesThemePlugin DefaultThemePlugin HealthSciencesThemePlugin ImmersionThemePlugin

Public Member Functions

 _getBaseDir ($path='')
 
 _getBaseUrl ($path='')
 
 _registerScripts ()
 
 addMenuArea ($menuAreas)
 
 addOption ($name, $type, $args=array())
 
 addScript ($name, $script, $args=array())
 
 addStyle ($name, $style, $args=array())
 
 getMenuAreas ($existingAreas=array())
 
 getOption ($name)
 
 getOptionConfig ($name)
 
 getOptionsConfig ()
 
 getOptionValues ($contextId)
 
getScript ($name)
 
getStyle ($name)
 
 init ()
 
 initAfter ()
 
 isActive ()
 
 isColourDark ($color, $limit=130)
 
 modifyOptionsConfig ($name, $args=array())
 
 modifyScript ($name, $args=array())
 
 modifyStyle ($name, $args=array())
 
 register ($category, $path, $mainContextId=null)
 
 removeMenuArea ($menuArea)
 
 removeOption ($name)
 
 removeScript ($name)
 
 removeStyle ($name)
 
 saveOption ($name, $value, $contextId=null)
 
 setParent ($parent)
 
 themeRegistered ($themes)
 
 validateOptions ($options, $themePluginPath, $contextId, $request)
 
- Public Member Functions inherited from LazyLoadPlugin
 getCanDisable ()
 
 getCanEnable ()
 
 getCurrentContextId ()
 
 getEnabled ($contextId=null)
 
 getName ()
 
 setEnabled ($enabled)
 
- Public Member Functions inherited from Plugin
 __construct ()
 
 _overridePluginTemplates ($hookName, $args)
 
 addLocaleData ($locale=null)
 
 getActions ($request, $actionArgs)
 
 getCategory ()
 
 getContextSpecificPluginSettingsFile ()
 
 getCurrentVersion ()
 
 getDescription ()
 
 getDirName ()
 
 getDisplayName ()
 
 getEnabled ()
 
 getHideManagement ()
 
 getInstallControlledVocabFiles ()
 
 getInstallDataFile ()
 
 getInstallEmailTemplateDataFile ()
 
 getInstallEmailTemplatesFile ()
 
 getInstallFilterConfigFiles ()
 
 getInstallMigration ()
 
 getInstallSchemaFile ()
 
 getInstallSitePluginSettingsFile ()
 
 getLocaleFilename ($locale)
 
 getPluginPath ()
 
getRequest ()
 
 getSeq ()
 
 getSetting ($contextId, $name)
 
 getTemplatePath ($inCore=false)
 
 getTemplateResource ($template=null, $inCore=false)
 
 import ($class)
 
 installContextSpecificSettings ($hookName, $args)
 
 installControlledVocabs ($hookName, $args)
 
 installData ($hookName, $args)
 
 installEmailTemplateData ($hookName, $args)
 
 installEmailTemplates ($hookName, $args)
 
 installFilters ($hookName, $args)
 
 installLocale ($hookName, $args)
 
 installSiteSettings ($hookName, $args)
 
 isSitePlugin ()
 
 manage ($args, $request)
 
 smartyPluginUrl ($params, $smarty)
 
 updateSchema ($hookName, $args)
 
 updateSetting ($contextId, $name, $value, $type=null)
 

Data Fields

 $menuAreas = array()
 
 $options = array()
 
 $parent
 
 $scripts = array()
 
 $styles = array()
 
- Data Fields inherited from Plugin
 $pluginCategory
 
 $pluginPath
 
 $request
 

Protected Attributes

 $_optionValues = null
 

Additional Inherited Members

- Protected Member Functions inherited from Plugin
 _registerTemplateResource ($inCore=false)
 

Detailed Description

Abstract class for theme plugins.

Definition at line 21 of file ThemePlugin.inc.php.

Member Function Documentation

◆ _getBaseDir()

ThemePlugin::_getBaseDir (   $path = '')

Get the base path to be used for file references

Parameters
$pathstring An optional path to append to the base
Returns
string

Definition at line 827 of file ThemePlugin.inc.php.

References Core\getBaseDir().

Referenced by addStyle(), and modifyStyle().

◆ _getBaseUrl()

ThemePlugin::_getBaseUrl (   $path = '')

Get the base URL to be used for file paths

A base URL for loading LESS/CSS/JS files in <link> elements. It will also be set to the @baseUrl variable before LESS files are compiloed so that images and fonts can be located.

Parameters
$pathstring An optional path to append to the base
Returns
string

Definition at line 815 of file ThemePlugin.inc.php.

References PKPApplication\get().

Referenced by addScript(), addStyle(), modifyScript(), and modifyStyle().

◆ _registerScripts()

ThemePlugin::_registerScripts ( )

Register script assets

Passes scripts defined by the theme to the template manager for handling.

Returns
null

Definition at line 789 of file ThemePlugin.inc.php.

References PKPApplication\get(), and PKPTemplateManager\getManager().

Referenced by initAfter().

◆ addMenuArea()

ThemePlugin::addMenuArea (   $menuAreas)

Register a navigation menu area for this theme

Parameters
$menuAreasstring|array One or more menu area names

Definition at line 662 of file ThemePlugin.inc.php.

Referenced by ImmersionThemePlugin\init(), HealthSciencesThemePlugin\init(), BootstrapThreeThemePlugin\init(), CriticalTimesThemePlugin\init(), and DefaultThemePlugin\init().

◆ addOption()

ThemePlugin::addOption (   $name,
  $type,
  $args = array() 
)

Add a theme option

Theme options are added programmatically to the Settings > Website > Appearance form when this theme is activated. Common options are colour and typography selectors.

Parameters
$namestring Unique name for this setting
$typestring One of the Field* class names
$argsarray 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: ''

Definition at line 393 of file ThemePlugin.inc.php.

References $options, and Plugin\getDisplayName().

Referenced by ImmersionThemePlugin\init(), HealthSciencesThemePlugin\init(), BootstrapThreeThemePlugin\init(), CriticalTimesThemePlugin\init(), and DefaultThemePlugin\init().

◆ addScript()

ThemePlugin::addScript (   $name,
  $script,
  $args = array() 
)

Add a script to load with this theme

Parameters
$namestring A name for this script
$scriptstring The script to be included. Should be path relative to the theme or, if the inline argument is included, script data to be output.
$argsarray 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.

Definition at line 304 of file ThemePlugin.inc.php.

References _getBaseUrl().

Referenced by ImmersionThemePlugin\init(), HealthSciencesThemePlugin\init(), BootstrapThreeThemePlugin\init(), CriticalTimesThemePlugin\init(), and DefaultThemePlugin\init().

◆ addStyle()

ThemePlugin::addStyle (   $name,
  $style,
  $args = array() 
)

Add a stylesheet to load with this theme

Style paths with a .less extension will be compiled and redirected to the compiled file.

Parameters
$namestring A name for this stylesheet
$stylestring The stylesheet. Should be a path relative to the theme directory or, if the inline argument is included, style data to be output.
$argsarray 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.

Definition at line 191 of file ThemePlugin.inc.php.

References _getBaseDir(), and _getBaseUrl().

Referenced by ImmersionThemePlugin\init(), HealthSciencesThemePlugin\init(), BootstrapThreeThemePlugin\init(), CriticalTimesThemePlugin\init(), and DefaultThemePlugin\init().

◆ getMenuAreas()

ThemePlugin::getMenuAreas (   $existingAreas = array())

Get all menu areas registered by this theme and any parents

Parameters
$existingAreasarray Any existing menu areas from child themes
Returns
array All menua reas

Definition at line 694 of file ThemePlugin.inc.php.

◆ getOption()

ThemePlugin::getOption (   $name)

Get the value of an option or default if the option is not set

Parameters
$namestring The name of the option value to retrieve
Returns
mixed The value of the option. Will return a default if set in the option config. False if no option exists. Null if no value or default exists.

Definition at line 454 of file ThemePlugin.inc.php.

References PKPApplication\get(), and getOptionValues().

Referenced by ImmersionThemePlugin\addIssueTemplateData(), CriticalTimesThemePlugin\getAuthorString(), CriticalTimesThemePlugin\getTranslatorString(), ImmersionThemePlugin\homepageAnnouncements(), ImmersionThemePlugin\homepageJournalDescription(), BootstrapThreeThemePlugin\init(), HealthSciencesThemePlugin\init(), DefaultThemePlugin\init(), CriticalTimesThemePlugin\loadSpotlightTemplateData(), and modifyOptionsConfig().

◆ getOptionConfig()

ThemePlugin::getOptionConfig (   $name)

Get an option's configuration settings

This retrives option settings for any option attached to this theme or any parent theme.

Parameters
$nameThe name of the option config to retrieve
Returns
false|array The config array for this option. Or false if no config is found.

Definition at line 491 of file ThemePlugin.inc.php.

◆ getOptionsConfig()

ThemePlugin::getOptionsConfig ( )

Get all options' configuration settings.

This retrieves a single array containing options settings for this theme and any parent themes.

Returns
array

Definition at line 508 of file ThemePlugin.inc.php.

References $options.

◆ getOptionValues()

ThemePlugin::getOptionValues (   $contextId)

Get all option values

This retrieves a single array containing option values for this theme and any parent themes.

Parameters
$contextIdint
Returns
array

Definition at line 564 of file ThemePlugin.inc.php.

References DAORegistry\getDAO().

Referenced by getOption().

◆ getScript()

& ThemePlugin::getScript (   $name)

Get a script from this theme or any parent theme

Parameters
$namestring The name of the script to retrieve
Returns
array|null Reference to the script or null if not found

Definition at line 362 of file ThemePlugin.inc.php.

Referenced by modifyScript().

◆ getStyle()

& ThemePlugin::getStyle (   $name)

Get a style from this theme or any parent theme

Parameters
$namestring The name of the style to retrieve
Returns
array|null Reference to the style or null if not found

Definition at line 272 of file ThemePlugin.inc.php.

Referenced by modifyStyle().

◆ init()

ThemePlugin::init ( )
abstract

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.

Returns
null

Reimplemented in DefaultThemePlugin, CriticalTimesThemePlugin, HealthSciencesThemePlugin, BootstrapThreeThemePlugin, and ImmersionThemePlugin.

Referenced by themeRegistered().

◆ initAfter()

ThemePlugin::initAfter ( )

Perform actions after the theme has been initialized

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

Definition at line 142 of file ThemePlugin.inc.php.

References _registerScripts().

◆ isActive()

ThemePlugin::isActive ( )

Determine whether or not this plugin is currently active

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.

Returns
boolean

Reimplemented in DefaultThemePlugin.

Definition at line 157 of file ThemePlugin.inc.php.

References Plugin\$request, PKPApplication\get(), and Plugin\getPluginPath().

Referenced by register().

◆ isColourDark()

ThemePlugin::isColourDark (   $color,
  $limit = 130 
)

Check if the passed colour is dark

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

Since
0.1

Definition at line 845 of file ThemePlugin.inc.php.

Referenced by ImmersionThemePlugin\addIssueTemplateData(), ImmersionThemePlugin\homepageAnnouncements(), ImmersionThemePlugin\homepageJournalDescription(), HealthSciencesThemePlugin\init(), and DefaultThemePlugin\init().

◆ modifyOptionsConfig()

ThemePlugin::modifyOptionsConfig (   $name,
  $args = array() 
)

Modify option configuration settings

Deprecated:
Unnecessary since 3.2 because options are stored as objects, so changes can be made directly (via reference) and args don't need to be manually merged
Parameters
$nameThe name of the option config to retrieve
$argsThe new configuration settings for this option
Returns
bool Whether the option was found and the config was updated.

Definition at line 530 of file ThemePlugin.inc.php.

References getOption().

◆ modifyScript()

ThemePlugin::modifyScript (   $name,
  $args = array() 
)

Modify the params of an existing script

Parameters
$namestring The name of the script to modify
$argsarray Parameters to modify.
See also
self::addScript()
Returns
null

Definition at line 325 of file ThemePlugin.inc.php.

References _getBaseUrl(), and getScript().

◆ modifyStyle()

ThemePlugin::modifyStyle (   $name,
  $args = array() 
)

Modify the params of an existing stylesheet

Parameters
$namestring The name of the stylesheet to modify
$argsarray Parameters to modify.
See also
self::addStyle()
Returns
null

Definition at line 229 of file ThemePlugin.inc.php.

References _getBaseDir(), _getBaseUrl(), and getStyle().

Referenced by HealthSciencesThemePlugin\init(), and DefaultThemePlugin\init().

◆ register()

ThemePlugin::register (   $category,
  $path,
  $mainContextId = null 
)

Load and initialize the plug-in and register plugin hooks.

For backwards compatibility this method will be called whenever the plug-in's category is being loaded. If, however, registerOn() returns an array then this method will only be called when the plug-in is enabled and an entry in the result set of registerOn() matches the current request operation. An empty array matches all request operations.

Parameters
$categoryString Name of category plugin was registered to
$pathString The path the plugin was found in
$mainContextIdinteger To identify if the plugin is enabled we need a context. This context is usually taken from the request but sometimes there is no context in the request (e.g. when executing CLI commands). Then the main context can be given as an explicit ID.
Returns
boolean True iff plugin registered successfully; if false, the plugin will not be executed.

Reimplemented from LazyLoadPlugin.

Definition at line 90 of file ThemePlugin.inc.php.

References isActive(), and HookRegistry\register().

◆ removeMenuArea()

ThemePlugin::removeMenuArea (   $menuArea)

Remove a registered navigation menu area

Parameters
$menuAreastring The menu area to remove
Returns
bool Whether or not the menuArea was found and removed.

Definition at line 677 of file ThemePlugin.inc.php.

◆ removeOption()

ThemePlugin::removeOption (   $name)

Remove an option

Parameters
$nameThe name of the option to remove
Returns
bool Whether the option was found and removed

Definition at line 545 of file ThemePlugin.inc.php.

◆ removeScript()

ThemePlugin::removeScript (   $name)

Remove a registered script

Parameters
$namestring The name of the script to remove
Returns
bool Whether or not the stylesheet was found and removed.

Definition at line 346 of file ThemePlugin.inc.php.

◆ removeStyle()

ThemePlugin::removeStyle (   $name)

Remove a registered stylesheet

Parameters
$namestring The name of the stylesheet to remove
Returns
bool Whether or not the stylesheet was found and removed.

Definition at line 256 of file ThemePlugin.inc.php.

◆ saveOption()

ThemePlugin::saveOption (   $name,
  $value,
  $contextId = null 
)

Sanitize and save a theme option

Parameters
$namestring A unique id for the option to save
$valuemixed The new value to save
$contextIdint Optional context id. Defaults to the current context

Definition at line 631 of file ThemePlugin.inc.php.

References PKPApplication\get(), and DAORegistry\getDAO().

◆ setParent()

ThemePlugin::setParent (   $parent)

Set a parent theme for this theme

Parameters
$parentstring Key in the plugin registry for the parent theme
Returns
null

Definition at line 707 of file ThemePlugin.inc.php.

References PluginRegistry\getPlugin().

◆ themeRegistered()

ThemePlugin::themeRegistered (   $themes)

Fire the init() method when a theme is registered

Parameters
$themesarray List of all loaded themes
Returns
null

Definition at line 116 of file ThemePlugin.inc.php.

References init().

◆ validateOptions()

ThemePlugin::validateOptions (   $options,
  $themePluginPath,
  $contextId,
  $request 
)

Overwrite this function to perform any validation on options before they are saved

If this is a child theme, you must call $this->parent->validateOptions() to perform any validation defined on the parent theme.

Parameters
$optionsarray Key/value list of options to validate
$themePluginPathstring The theme these options are for
$contextIdint The context these theme options are for, or CONTEXT_ID_NONE for the site-wide settings.
$requestRequest
Returns
array List of errors with option name as the key and the value as an array of error messages. Example: [ 'color' => [ 'This color is too dark for this area and some people will not be able to read it.', ] ]

Definition at line 619 of file ThemePlugin.inc.php.

Field Documentation

◆ $_optionValues

$_optionValues ThemePlugin::$_optionValues = null
protected

Stored reference to option values

A null value indicates that no lookup has occured. If no options are set, the lookup will assign an empty array.

null|array;

Definition at line 85 of file ThemePlugin.inc.php.

◆ $menuAreas

$menuAreas ThemePlugin::$menuAreas = array()

Theme-specific navigation menu areas

array;

Definition at line 62 of file ThemePlugin.inc.php.

◆ $options

$options ThemePlugin::$options = array()

Theme-specific options

array;

Definition at line 52 of file ThemePlugin.inc.php.

Referenced by addOption(), getOptionsConfig(), and CriticalTimesThemePlugin\init().

◆ $parent

$parent ThemePlugin::$parent

Parent theme (optional)

ThemePlugin

Definition at line 72 of file ThemePlugin.inc.php.

◆ $scripts

$scripts ThemePlugin::$scripts = array()

Collection of scripts

See also
self::_registerScripts

array

Definition at line 42 of file ThemePlugin.inc.php.

◆ $styles

$styles ThemePlugin::$styles = array()

Collection of styles

See also
self::_registerStyles

array

Definition at line 31 of file ThemePlugin.inc.php.


The documentation for this class was generated from the following file: