ZenMagick 0.9.6


org.zenmagick.plugins.ZMPlugin

Class ZMPlugin

ZMObject
|
+--ZMPlugin

public class ZMPlugin
extends ZMObject

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: ZMPlugin.php 2149 2009-04-13 22:59:14Z dermanomann $

Field Summary
final mixed

KEY_ENABLED_SUFFIX

final mixed

KEY_ORDER_SUFFIX

final mixed

KEY_PREFIX

final mixed

LP_ALL

final mixed

LP_FOLDER

final mixed

LP_NONE

final mixed

LP_PLUGIN

final mixed

SCOPE_ADMIN

final mixed

SCOPE_ALL

final mixed

SCOPE_STORE

Fields inherited from org.zenmagick.ZMObject
properties_
Constructor Summary

ZMPlugin(string title, string description, string version)

Create new plugin.

Method Summary
void

addConfigValue(string title, string key, string value, string description, string setFunction, string useFunction, 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)

Support to access plugin config values by name.

string

getConfigPath(string file)

Get a plugin config file path.

array

getConfigValues(boolean prefix)

Get all the config values.

string

getDescription()

Get description.

array

getGlobal()

Get optional files to be loaded in global scope.

string

getId()

Get Id.

array

getKeys()

Get a list of configuration keys used by this plugin.

string

getLoaderPolicy()

Get this plugin's loader policy.

array

getMessages()

Get optional installation messages.

string

getName()

Get name.

string

getPluginDir()

Get the plugin directory.

string

getScope()

Get this plugins scope.

int

getSortOrder()

Get the sort order.

string

getType()

Get the plugin type.

string

getVersion()

Get version.

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.

boolean

isTraditional()

Get the traditional flag.

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

setKeys(array keys)

Set the list of configuration keys the actual implementation is using.

void

setLoaderPolicy(string loaderPolicy)

Set the loader policy for this plugin.

void

setPluginDir(string pluginDir)

Set the plugin directory.

void

setPreferredSortOrder(int sortOrder)

Set the preferred sort order.

void

setScope(string scope)

Set the scope.

void

setSortOrder(int sortOrder)

Set the sort order.

void

setTraditional(boolean traditional)

Set the traditional flag.

void

setType(string type)

Set the plugin type.

void

zcoSubscribe()

Register this plugin as zen-cart zco subscriber.

void

zcoUnsubscribe()

Un-register this plugin as zen-cart zco subscriber.

Methods inherited from org.zenmagick.ZMObject
attachMethod, get, getAttachedMethods, getPropertyNames, set, singleton

Field Detail

KEY_ENABLED_SUFFIX

public final mixed KEY_ENABLED_SUFFIX = 'ENABLED'

KEY_ORDER_SUFFIX

public final mixed KEY_ORDER_SUFFIX = 'ORDER'

KEY_PREFIX

public final mixed KEY_PREFIX = 'PLUGIN_'

LP_ALL

public final mixed LP_ALL = 'ALL'

LP_FOLDER

public final mixed LP_FOLDER = 'FOLDER'

LP_NONE

public final mixed LP_NONE = 'NONE'

LP_PLUGIN

public final mixed LP_PLUGIN = 'PLUGIN'

SCOPE_ADMIN

public final mixed SCOPE_ADMIN = 'admin'

SCOPE_ALL

public final mixed SCOPE_ALL = 'all'

SCOPE_STORE

public final mixed SCOPE_STORE = 'store'

Constructor Detail

ZMPlugin

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

Create new plugin.

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

Method Detail

addConfigValue

public void addConfigValue(string title, string key, string value, string description, string setFunction, string useFunction, 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 ''.
setFunction - The set function; defaults to null.
useFunction - The use function; defaults to null.
sortOrder - The sort order; defaults to 0.

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.

get

public mixed get(string name, mixed default)

Support to access plugin config values by name.

Parameters:
name - The property name.
Returns:
The value or null.

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.

getConfigValues

public array getConfigValues(boolean prefix)

Get all the config values.

Parameters:
prefix - If true, the plugin prefix will be kept, otherwise it will be stripped.
Returns:
A list of ZMConfigValue instances.

getDescription

public string getDescription()

Get description.

Returns:
The description.

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.

getId

public string getId()

Get Id.

Returns:
A unique id.

getKeys

public array getKeys()

Get a list of configuration keys used by this plugin.

Returns:
List of configuration keys.

getLoaderPolicy

public string getLoaderPolicy()

Get this plugin's loader policy.

The policy controlls the extend of automatic ZMLoader support this plugin requests.

It also affects the code included in core.php. Valid values are:

ZMPlugin::LP_NONE
Not supported.
ZMPlugin::LP_PLUGIN
Only the plugin class may be added; this is the default.
ZMPlugin::LP_FOLDER
Everything in the plugin folder, excluding all subfolder and their contents.
ZMPlugin::LP_ALL
All (.php) files can be added to core.php.

Returns:
The loader policy.

getMessages

public array getMessages()

Get optional installation messages.

Returns:
List of ZMMessage instances.

getName

public string getName()

Get name.

Returns:
The name.

getPluginDir

public string getPluginDir()

Get the plugin directory.

Returns:
The directory or null if this plugin is single file only.

getScope

public string getScope()

Get this plugins scope.

Returns:
The scope.

getSortOrder

public int getSortOrder()

Get the sort order.

Returns:
The sort order index.

getType

public string getType()

Get the plugin type.

The plugin type is determined by the plugin folder. The type controls if and when a plugin is loaded during the init process. Valid types are:


getVersion

public string getVersion()

Get version.

Returns:
The version.

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.

/


install

public void install()

Install this plugin.

This default implementation will automatically create the following settings:

/


isEnabled

public boolean isEnabled()

Check if the plugin is enabled.

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

isInstalled

public boolean isInstalled()

Check if the plugin is installed.

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

isTraditional

public boolean isTraditional()

Get the traditional flag.

Returns:
true if this plugin required traditional configuration handling, false if not.

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.

remove

public void remove(boolean keepSettings)

Remove this plugin.

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

set

public void set(string name, mixed value)

Support to set plugin config values by name.

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

setKeys

public void setKeys(array keys)

Set the list of configuration keys the actual implementation is using.

Parameters:
keys - List of configuration keys with or without the config prefix.

setLoaderPolicy

public void setLoaderPolicy(string loaderPolicy)

Set the loader policy for this plugin.

Parameters:
loaderPolicy - The loader policy.

setPluginDir

public void setPluginDir(string pluginDir)

Set the plugin directory.

Parameters:
pluginDir - The directory.

setPreferredSortOrder

public void setPreferredSortOrder(int sortOrder)

Set the preferred sort order.

Parameters:
sortOrder - The preferred sort order.

setScope

public void setScope(string scope)

Set the scope.

This determines where a plugin is active. Allowed values are:

Please note that there are constants that may be used intead of plain strings:

The default scope is

  • self::SCOPE_ALL
  • .

    Parameters:
    scope - The scope.

    setSortOrder

    public void setSortOrder(int sortOrder)

    Set the sort order.

    Parameters:
    sortOrder - The sort order index.

    setTraditional

    public void setTraditional(boolean traditional)

    Set the traditional flag.

    Parameters:
    traditional - true if this plugin required traditional configuration handling, false if not.

    setType

    public void setType(string type)

    Set the plugin type.

    Parameters:
    type - The type.

    zcoSubscribe

    public void zcoSubscribe()

    Register this plugin as zen-cart zco subscriber. /


    zcoUnsubscribe

    public void zcoUnsubscribe()

    Un-register this plugin as zen-cart zco subscriber. /


    ZenMagick 0.9.6