ZenMagick 0.9.8


org.zenmagick.store.services.plugins.Plugin
\store\services\plugins\Plugin.php at line 38

Class Plugin

ZMObject
└─ZMPlugin
└─Plugin

public class Plugin
extends ZMPlugin

Store plugin base class.

Plugins are NOT compatible with zen-cart modules.

The plugin code (id) is based on the plugin class/file name.

Author:
DerManoMann
Version:
$Id: Plugin.php 2701 2009-12-07 03:15:38Z dermanomann $

Field Summary
final int

CONTEXT_ADMIN

Admin context.

final int

CONTEXT_STOREFRONT

Store context.

final str

KEY_ENABLED

internal key constant

final str

KEY_PREFIX

internal key constant

final str

KEY_SORT_ORDER

internal key constant

Fields inherited from org.zenmagick.core.services.plugins.ZMPlugin
LP_ALL, LP_FOLDER, LP_NONE, LP_PLUGIN
Fields inherited from org.zenmagick.core.ZMObject
properties_
Constructor Summary

Plugin(string title, string description, string version)

Create new plugin.

Method Summary
void

addConfigValue(string title, string key, string value, string description, string widget, int sortOrder)

Add a configuration value.

void

addMenuItem(string id, string title, string function, string menuKey)

Add plugin maintenance screen to navigation.

mixed

get(string name, mixed default)

Here, the $default parameter is always ingnored.

string

getConfigPath(string file)

Get a plugin config file path.

array

getConfigValues()

Get all the config values.

array

getGlobal()

Get optional files to be loaded in global scope.

array

getMessages()

Get optional installation messages.

int

getSortOrder()

Get the sort order.

void

init()

Init this plugin.

void

install()

Install this plugin.

boolean

isEnabled()

Check if the plugin is enabled.

boolean

isInstalled()

Check if the plugin is installed.

string

pluginURL(string uri, boolean echo)

Resolve a plugin relative URI.

void

remove(boolean keepSettings)

Remove this plugin.

void

set(string name, mixed value)

Support to set plugin config values by name.

void

setEnabled(boolean status)

Set the status.

void

setGroup(string group)

{@inheritDoc}

void

setPreferredSortOrder(int sortOrder)

Set the preferred sort order.

void

setSortOrder(int sortOrder)

Set the sort order.

Methods inherited from org.zenmagick.core.services.plugins.ZMPlugin
getContext, getDescription, getGroup, getId, getLoaderPolicy, getName, getPluginDirectory, getVersion, init, isEnabled, setContext, setDescription, setEnabled, setGroup, setId, setLoaderPolicy, setName, setPluginDirectory, setVersion
Methods inherited from org.zenmagick.core.ZMObject
attachMethod, get, getAttachedMethods, getPropertyNames, set, singleton

Field Detail

\store\services\plugins\Plugin.php at line 49

CONTEXT_ADMIN

public final int CONTEXT_ADMIN = 2

Admin context.


\store\services\plugins\Plugin.php at line 47

CONTEXT_STOREFRONT

public final int CONTEXT_STOREFRONT = 1

Store context.


\store\services\plugins\Plugin.php at line 42

KEY_ENABLED

public final str KEY_ENABLED = 'ENABLED'

internal key constant


\store\services\plugins\Plugin.php at line 40

KEY_PREFIX

public final str KEY_PREFIX = 'PLUGIN_'

internal key constant


\store\services\plugins\Plugin.php at line 44

KEY_SORT_ORDER

public final str KEY_SORT_ORDER = 'SORT_ORDER'

internal key constant


Constructor Detail

\store\services\plugins\Plugin.php at line 65

Plugin

public Plugin(string title, string description, string version)

Create new plugin.

Parameters:
title - The title.
description - The description.
version - The version.

Method Detail

\store\services\plugins\Plugin.php at line 298

addConfigValue

public void addConfigValue(string title, string key, string value, string description, string widget, int sortOrder)

Add a configuration value.

If no sort order is specified, entries will be listed in the order they are added. Effectively, this means sort order can be easier accomplished by adding values in the order they should be displayed.

Parameters:
title - The title.
key - The configuration key (with or without the common prefix).
value - The value.
description - The description; defaults to ''.
widget - The widget definitio; default is null for a default text field.
sortOrder - The sort order; defaults to 0.

\store\services\plugins\Plugin.php at line 345

addMenuItem

public void addMenuItem(string id, string title, string function, string menuKey)

Add plugin maintenance screen to navigation.

The provided function is free to implement content generation in one of two different ways:

  1. BASIC:
    The page contents is generated as-is. No output buffering or similar. Expected return value is null.
  2. ADVANCED:
    Content is not generated directly, but included as part of the returned ZMPluginPage instance.

Parameters:
id - The page id.
title - The page title.
function - The function to render the contents.
menuKey - Optional key determining where the menu item should appear; default is ZMAdminMenu::MENU_PLUGINS.

\store\services\plugins\Plugin.php at line 130

get

public mixed get(string name, mixed default)

Here, the $default parameter is always ingnored.

Parameters:
name - The property name.
default - A default value; default value is null.
Returns:
The value or null.

\store\services\plugins\Plugin.php at line 273

getConfigPath

public string getConfigPath(string file)

Get a plugin config file path.

Return a fully qualified filename; resolved either against the plugin directory or config/. If neither file exists, the config/ based filename is returned.

Parameters:
file - The filename.
Returns:
A fully qualified filename.

\store\services\plugins\Plugin.php at line 322

getConfigValues

public array getConfigValues()

Get all the config values.

Returns:
A list of ZMConfigValue instances.

\store\services\plugins\Plugin.php at line 105

getGlobal

public array getGlobal()

Get optional files to be loaded in global scope.

Files returned here would typically have an extension different to .php as otherwise the loader will load them as static.

Global

Returns:
List of filenames relative to the plugin location.

\store\services\plugins\Plugin.php at line 91

getMessages

public array getMessages()

Get optional installation messages.

Returns:
List of ZMMessage instances.

\store\services\plugins\Plugin.php at line 245

getSortOrder

public int getSortOrder()

Get the sort order.

Returns:
The sort order index.

\store\services\plugins\Plugin.php at line 209

init

public void init()

Init this plugin.

This method is part of the lifecylce of a plugin during storefront request handling.

Code to set up internal resources should be placed here, rather than in the * constructor.


\store\services\plugins\Plugin.php at line 179

install

public void install()

Install this plugin.

This default implementation will automatically create the following settings:


\store\services\plugins\Plugin.php at line 226

isEnabled

public boolean isEnabled()

Check if the plugin is enabled.

Returns:
true if the plugin is enabled, false if not.

\store\services\plugins\Plugin.php at line 217

isInstalled

public boolean isInstalled()

Check if the plugin is installed.

Returns:
true if the plugin is installed, false if not.

\store\services\plugins\Plugin.php at line 358

pluginURL

public string pluginURL(string uri, boolean echo)

Resolve a plugin relative URI.

The given uri is assumed to be relative to the plugin folder.

Parameters:
uri - The relative URI.
echo - If true, the URL will be echo'ed as well as returned.
Returns:
An absolute URL or null.

\store\services\plugins\Plugin.php at line 191

remove

public void remove(boolean keepSettings)

Remove this plugin.

Parameters:
keepSettings - If set to true, the settings will not be removed; default is false.

\store\services\plugins\Plugin.php at line 157

set

public void set(string name, mixed value)

Support to set plugin config values by name.

Parameters:
name - The property name.
value - The value.

\store\services\plugins\Plugin.php at line 236

setEnabled

public void setEnabled(boolean status)

Set the status.

Parameters:
status - The new status.

\store\services\plugins\Plugin.php at line 257

setGroup

public void setGroup(string group)

Parameters:
group - The group.

\store\services\plugins\Plugin.php at line 166

setPreferredSortOrder

public void setPreferredSortOrder(int sortOrder)

Set the preferred sort order.

Parameters:
sortOrder - The preferred sort order.

\store\services\plugins\Plugin.php at line 252

setSortOrder

public void setSortOrder(int sortOrder)

Set the sort order.

Parameters:
sortOrder - The sort order index.

ZenMagick 0.9.8