CMSModule View code

Base module class.

All modules should inherit and extend this class with their functionality.

since 0.9
version 2.0
package

CMS

Methods

__construct() 

Constructor

RegisterSmartyPlugin(string $name, string $type, callback $callback, boolean $cachable = TRUE, integer $usage) 

Register a smarty plugin and attach it to this module.

This method registers a static plugin to the plugins database table, and should be used only when a module is installed or upgraded.

Arguments

string $name

The plugin name

string $type

The plugin type (function,compiler,block, etc)

callback $callback

The function callback (must be a static function)

boolean $cachable

Wether this function is cachable.

integer $usage

Indicates frontend (0), or frontend and backend (1) availability.

RemoveSmartyPlugin(string $name = '') 

Unregister a smarty plugin from the system.

This method removes any matching rows from the database, and should only be used in a modules uninstall or upgrade routine.

Arguments

string $name

The smarty plugin name. If no name is specified all smarty plugins registered to this module will be removed.

RegisterModulePlugin(boolean $forcedb = FALSE, boolean|null $cachable = false) 

Register a plugin to smarty with the name of the module. This method should be called from the module constructor, or from the SetParameters method.

deprecated final

Note:

Arguments

boolean $forcedb

Indicate wether this registration should be forced to be entered in the database. Default value is false (for compatibility)

boolean|null $cachable

Indicate wether this plugins output should be cachable. If null, use the site preferences, and the can_cache_output method. Otherwise a bool is expected.

can_cache_output() : boolean

Callback to determine if the output from a call to the module can be cached by smarty.

final

Response

boolean

AllowSmartyCaching() : boolean

Callback to determine if the output from a call to the module can be cached by smarty.

Response

boolean

GetAbout() : string

Returns a sufficient about page for a module

Response

string

The about page HTML text.

GetHelpPage() : string

Returns a sufficient help page for a module this function should not be overridden

final

Response

string

The help page HTML text.

GetName() : string

Returns the name of the module

Response

string

The name of the module.

GetModulePath() : string

Returns the full path to the module directory.

final

Response

string

The full path to the module directory.

GetModuleURLPath(boolean $use_ssl = false) : string

Returns the URL path to the module directory.

final

Arguments

boolean $use_ssl

Optional generate an URL using HTTPS path

Response

string

The full path to the module directory.

GetFriendlyName() : string

Returns a translatable name of the module. For modulues who's names can probably be translated into another language (like News)

Response

string

GetVersion() : string

Returns the version of the module

abstract

Response

string

MinimumCMSVersion() : string

Returns the minimum version necessary to run this version of the module.

Response

string

GetHelp() : string

Returns the help for the module

Note: New for CMSMS 1.11.12 - If the global variable CMSMS_GENERATING_XML is set it indicates that the help output will be stored in an XML file. This variable can be used to check wether advanced html output (like links to other documents) should be generated.

Response

string

Help HTML Text.

GetHeaderHTML() : string

Returns XHTML that needs to go between the <head> tags when this module is called from an admin side action.

This method is called by the admin theme when executing an action for a specific module.

Response

string

XHTML text

SuppressAdminOutput(array &$request) : boolean

Use this method to prevent the admin interface from outputting header, footer, theme, etc, so your module can output files directly to the administrator.

Do this by returning true.

Arguments

array $request

The input request. This can be used to test conditions wether or not admin output should be suppressed.

Response

boolean

RegisterRoute(string $routeregex, array $defaults = array()) 

Register a dynamic route to use for pretty url parsing

final

Note: This method is not compatible wih lazy loading in the front end.

Arguments

string $routeregex

Regular Expression Route to register

array $defaults

Associative array containing defaults for parameters that might not be included in the url

CreateStaticRoutes() 

Register all static routes for this module.

SetParameters() 

Called from within the constructor, This method should be overridden to call the CreaeteParameter method for each parameter that the module understands.

deprecated

Note: In past versions of CMSMS This method was used for both admin and frontend requests to register routes, and create parameters, and register a module plugin, etc. As of version 1.10 this method is deprecated, and the appropriate functions are InitializeFrontend() and InitializeAdmin() This method is scheduled for removal in version 1.11

InitializeFrontend() 

Called from within the constructor, ONLY for frontend module actions. This method should be overridden to create routes, and set handled parameters, and perform other initialization tasks that need to be setup for all frontend actions.

InitializeAdmin() 

Called from within the constructor, ONLY for admin module actions. This method should be overridden to create routes, and set handled parameters, and perform other initialization tasks that need to be setup for all frontend actions.

RestrictUnknownParams(boolean $flag = true) 

A method to indicate that the system should drop and optionally generate an error about unknown parameters on frontend actions.

final

Arguments

boolean $flag

Indicaties wether unknown params should be restricted.

SetParameterType(string $param, \define $type) 

Indicate the name of, and type of a parameter that is acceptable for frontend actions.

final

possible values for type are: CLEAN_INT,CLEAN_FLOAT,CLEAN_NONE,CLEAN_STRING,CLEAN_REGEXP,CLEAN_FILE

i.e: $this->SetParameterType('numarticles',CLEAN_INT);

Arguments

string $param

Parameter name;

\define $type

Parameter type;

CreateParameter(string $param, string $defaultval = '', string $helpstring = '', boolean $optional = true) 

Create a parameter and it's documentation for display in the module help.

final

i.e: $this->CreateParameter('numarticles',100000,$this->Lang('help_numarticles'),true);

Arguments

string $param

Parameter name;

string $defaultval

Default parameter value

string $helpstring

Help String

boolean $optional

Flag indicating wether this parameter is optional or required.

GetDescription() : string

Returns a short description of the module

Response

string

GetAdminDescription() : string

Returns a description of what the admin link does.

Response

string

IsAdminOnly() : boolean

Returns whether this module should only be loaded from the admin

Response

boolean

GetChangeLog() : string

Returns the changelog for the module

Response

string

HTML text of the changelog.

GetAuthor() : string

Returns the name of the author

Response

string

The name of the author.

GetAuthorEmail() : string

Returns the email address of the author

Response

string

The email address of the author.

GetConfig() : array

Returns the cms->config object as a reference

deprecated final

Response

array

The config hash.

GetDb() : \ADOConnection

Returns the cms->db object as a reference

deprecated final

Response

\ADOConnection

Adodb Database object.

GetContentBlockFieldInput(string $blockName, mixed $value, array $params, boolean $adding, \ContentBase $content_obj) : mixed

Get an input field for a module generated content block type.

This method is called from the content edit form when a {content_module} tag is encountered.

This method can be overridden if the module is providing content block types to the CMSMS content objects.

Arguments

string $blockName

Content block name

mixed $value

Content block value

array $params

Associative array containing content block parameters

boolean $adding

A flag indicating wether the content editor is in create mode (adding) vs. edit mod.

\ContentBase $content_obj

The content object being edited.

Response

mixed

Either an array with two elements (prompt, and xhtml element) or a string containing only the xhtml input element.

GetContentBlockFieldValue(string $blockName, array $blockParams, array $inputParams, \ContentBase $content_obj) : mixed|false

Return a value for a module generated content block type.

This mehod is called from a {content_module} tag, when the content edit form is being edited.

Given input parameters (i.e: via _POST or _REQUEST), this method will extract a value for the given content block information.

This method can be overridden if the module is providing content block types to the CMSMS content objects.

Arguments

string $blockName

Content block name

array $blockParams

Content block parameters

array $inputParams

input parameters

\ContentBase $content_obj

The content object being edited.

Response

mixed|false

The content block value if possible.

ValidateContentBlockFieldValue(string $blockName, mixed $value, \arrray $blockparams, \contentBase $content_obj) : string

Validate the value for a module generated content block type.

This mehod is called from a {content_module} tag, when the content edit form is being validated.

This method can be overridden if the module is providing content block types to the CMSMS content objects.

Arguments

string $blockName

Content block name

mixed $value

Content block value

\arrray $blockparams

Content block parameters.

\contentBase $content_obj

The content object that is currently being edited.

Response

string

An error message if the value is invalid, empty otherwise.

RenderContentBlockField(string $blockName, string $value, array $blockparams, \ContentBase $content_obj) : string

Render the value of a module content block on the frontend of the website.

This gives modules the opportunity to render data stored in content blocks differently.

Arguments

string $blockName

Content block name

string $value

Content block value as stored in the database

array $blockparams

Content block parameters

\ContentBase $content_obj

The content object that is currently being displayed

Response

string

RegisterBulkContentFunction(string $label, string $action) 

Register a bulk content action

final

For use in the CMSMS content list this method allows a module to register a bulk content action.

Arguments

string $label

A label for the action

string $action

A module action name.

Install() : string|false

Function that will get called as module is installed. This function should do any initialization functions including creating database tables. It should return a string message if there is a failure. Returning nothing (FALSE) will allow the install procedure to proceed.

The default behavior of this method is to include a file named method.install.php in the module directory, if one can be found. This provides a way of splitting secondary functions into other files.

Response

string|false

A value of FALSE indicates no error. Any other value will be used as an error message.

InstallPostMessage() : \XHTML

Display a message after a successful installation of the module.

Response

\XHTML

Text

Uninstall() : string|false

Function that will get called as module is uninstalled. This function should remove any database tables that it uses and perform any other cleanup duties.

It should return a string message if there is a failure. Returning nothing (FALSE) will allow the uninstall procedure to proceed.

The default behaviour of this function is to include a file called method.uninstall.php in your module directory to do uninstall operations.

Response

string|false

A result of FALSE indicates that the module uninstalled correctly, any other value indicates an error message.

AllowUninstallCleanup() : boolean

Function that gets called upon module uninstall, and returns a bool to indicate whether or not the core should remove all module events, event handlers, module templates, and preferences.

The module must still remove its own database tables and permissions

Response

boolean

Whether the core may remove all module events, event handles, module templates, and preferences on uninstall (defaults to true)

UninstallPreMessage() : \XHTML

Display a message and a Yes/No dialog before doing an uninstall. Returning noting (FALSE) will go right to the uninstall.

Response

\XHTML

Text, or FALSE.

UninstallPostMessage() : \XHTML

Display a message after a successful uninstall of the module.

Response

\XHTML

Text, or FALSE

Upgrade(string $oldversion, string $newversion) : boolean

Function to perform any upgrade procedures. This is mostly used to for updating databsae tables, but can do other duties as well. It should return a string message if there is a failure. Returning nothing (FALSE) will allow the upgrade procedure to proceed. Upgrades should have a path so that they can be upgraded from more than one version back. While not a requirement, it makes life easy for your users.

The default behavior of this method is to call a function called method.upgrade.php in your module directory, if it exists.

Arguments

string $oldversion

The version we are upgrading from

string $newversion

The version we are upgrading to

Response

boolean

GetDependencies() : array

Returns a list of dependencies and minimum versions that this module requires. It should return an hash, eg.

return array('somemodule'=>'1.0', 'othermodule'=>'1.1');

Response

array

CreateXMLPackage(string &$message, integer &$filecount) : string

Creates an xml data package from the module directory.

final

Arguments

string $message

reference to returned message.

integer $filecount

reference to returned file count.

Response

string

XML Text

HasAdmin() : boolean

Return true if there is an admin for the module. Returns false by default.

Response

boolean

GetAdminSection() : string

Returns which admin section this module belongs to.

this is used to place the module in the appropriate admin navigation section. Valid options are currently:

main, content, layout, files, usersgroups, extensions, preferences, siteadmin, myprefs, ecommerce

Response

string

GetAdminMenuItems() : array

Return a array of CmsAdminMenuItem objects representing menu items for the admin nav for this module.

This method should do all permissions checking when building the array of objects.

Response

array

of CmsAdminMenuItem objects

VisibleToAdminUser() : boolean

Returns true or false, depending on whether the user has the right permissions to see the module in their Admin menus.

Typically permission checks are done in the overriden version of this method.

Defaults to true.

Response

boolean

IsPluginModule() : boolean

Returns true if the module should be treated as a plugin module (like {cms_module module='name'}. Returns false by default.

Response

boolean

LazyLoadFrontend() : boolean

Returns true if the module may support lazy loading in the front end

Note: The results of this function are not read on each request, only during install and upgrade therefore if the return value of this function changes the version number of the module should be increased to force a re-load

In CMSMS 1.10 routes are loaded upon each request, if a module registers routes it cannot be lazy loaded.

Response

boolean

LazyLoadAdmin() : boolean

Returns true if the module may support lazy loading in the admin interface.

Note: The results of this function are not read on each request, only during install and upgrade therefore if the return value of this function changes the version number of the module should be increased to force a re-load

In CMSMS 1.10 routes are loaded upon each request, if a module registers routes it cannot be lazy loaded.

Response

boolean

HasCapability(string $capability, array $params = array()) : boolean

Returns true if the modules thinks it has the capability specified

Arguments

string $capability

an id specifying which capability to check for, could be "wysiwyg" etc.

array $params

An associative array further params to get more detailed info about the capabilities. Should be syncronized with other modules of same type

Response

boolean

get_tasks() : array

Returns a list of the tasks that this module manages

Response

array

of CmsRegularTask objects, or one object. NULL if not handled.

SyntaxGenerateHeader() : string

Returns header code specific to this SyntaxHighlighter

Response

string

WYSIWYGGenerateHeader(string $selector = null, string $cssname = null) : string

Returns header code specific to this WYSIWYG

Arguments

string $selector

(optional) The id of the element that is being initialized, if null the WYSIWYG module should assume the selector to be textarea..

string $cssname

(optional) The name of the CMSMS stylesheet to associate with the wysiwyg editor for additional styling. if elementid is not null then the cssname is only used for the specific element. WYSIWYG modules may not obey the cssname paramter depending on their settings and capabilities.

Response

string

DoAction(string $name, string $id, string $params, integer $returnid = '') : string

Used for navigation between "pages" of a module. Forms and links should pass an action with them so that the module will know what to do next.

By default, DoAction will be passed 'default' and 'defaultadmin', depending on where the module was called from. If being used as a module or content type, 'default' will be passed. If the module was selected from the list on the admin menu, then 'defaultadmin' will be passed.

In order to allow splitting up functionality into multiple PHP files the default behaviour of this method is to look for a file named action..php in the modules directory, and if it exists include it.

Arguments

string $name

The Name of the action to perform

string $id

The ID of the module

string $params

The parameters targeted for this module

integer $returnid

The current page id that is being displayed.

Response

string

output XHTML.

CreateTooltip(string $helptext, string $linktext = "?", string $forcewidth = "", string $classname = "admin-tooltip admin-tooltip-box", string $href = "") : string

Returns the xhtml equivalent of a tooltip help link.

deprecated final

Arguments

string $helptext

The help text to be shown on mouse over

string $linktext

The text to be shown as the link, default to a simple question mark

string $forcewidth

Forces another width of the popupbox than the one set in admin css

string $classname

An alternative classname for the a-link of the tooltip

string $href

The URL or url portion to use in the href portion of the generated link.

Response

string

CreateFieldsetStart(string $id, string $name, string $legend_text = '', string $addtext = '', string $addtext_legend = '') : string

Returns the xhtml equivalent of an fieldset and legend. This is basically a nice little wrapper to make sure that id's are placed in names and also that it's xhtml compliant.

deprecated final

Arguments

string $id

The id given to the module on execution (not really used yet, but might be later)

string $name

The html name of the textbox (not really used yet, but might be later on)

string $legend_text

The legend_text for this fieldset, if applicaple

string $addtext

Any additional text that should be added into the tag when rendered

string $addtext_legend

Any additional text that should be added into the legend tag when rendered

Response

string

CreateFieldsetEnd() : string

Returns the end of the fieldset in a form. This is basically just a wrapper around </form>, but could be extended later on down the road. It's here mainly for consistency.

deprecated final

Response

string

CreateFrontendFormStart(string $id, string $returnid, string $action = 'default', string $method = 'post', string $enctype = '', boolean $inline = true, string $idsuffix = '', array $params = array()) : string

Returns the start of a module form, optimized for frontend use

deprecated

Arguments

string $id

The id given to the module on execution

string $returnid

The page id to eventually return to when the module is finished it's task

string $action

The name of the action that this form should do when the form is submitted

string $method

Method to use for the form tag. Defaults to 'post'

string $enctype

Optional enctype to use, Good for situations where files are being uploaded

boolean $inline

A flag to determine if actions should be handled inline (no moduleinterface.php -- only works for frontend)

string $idsuffix

Text to append to the end of the id and name of the form

array $params

Extra parameters to pass along when the form is submitted

Response

string

CreateFormStart(string $id, string $action = 'default', string $returnid = '', string $method = 'post', string $enctype = '', boolean $inline = false, string $idsuffix = '', array $params = array(), string $extra = '') : string

Returns the start of a module form

Arguments

string $id

The id given to the module on execution

string $action

The action that this form should do when the form is submitted

string $returnid

The page id to eventually return to when the module is finished it's task

string $method

Method to use for the form tag. Defaults to 'post'

string $enctype

Optional enctype to use, Good for situations where files are being uploaded

boolean $inline

A flag to determine if actions should be handled inline (no moduleinterface.php -- only works for frontend)

string $idsuffix

Text to append to the end of the id and name of the form

array $params

Extra parameters to pass along when the form is submitted

string $extra

Text to append to the

-statement, for instanse for javascript-validation code

Response

string

CreateFormEnd() : string

Returns the end of the a module form. This is basically just a wrapper around </form>, but could be extended later on down the road. It's here mainly for consistency.

Response

string

CreateInputText(string $id, string $name, string $value = '', string $size = '10', string $maxlength = '255', string $addttext = '') : string

Returns the xhtml equivalent of an input textbox. This is basically a nice little wrapper to make sure that id's are placed in names and also that it's xhtml compliant.

deprecated

Arguments

string $id

The id given to the module on execution

string $name

The html name of the textbox

string $value

The predefined value of the textbox, if any

string $size

The number of columns wide the textbox should be displayed

string $maxlength

The maximum number of characters that should be allowed to be entered

string $addttext

Any additional text that should be added into the tag when rendered

Response

string

CreateLabelForInput(string $id, string $name, string $labeltext = '', string $addttext = '') : string

Returns the xhtml equivalent of an label for input field. This is basically a nice little wrapper to make sure that id's are placed in names and also that it's xhtml compliant.

deprecated

Arguments

string $id

The id given to the module on execution

string $name

The html name of the input field this label is associated to

string $labeltext

The text in the label

string $addttext

Any additional text that should be added into the tag when rendered

Response

string

CreateInputTextWithLabel(string $id, string $name, string $value = '', string $size = '10', string $maxlength = '255', string $addttext = '', string $label = '', string $labeladdtext = '') : string

Returns the xhtml equivalent of an input textbox with label. This is basically a nice little wrapper to make sure that id's are placed in names and also that it's xhtml compliant.

deprecated

Arguments

string $id

The id given to the module on execution

string $name

The html name of the textbox

string $value

The predefined value of the textbox, if any

string $size

The number of columns wide the textbox should be displayed

string $maxlength

The maximum number of characters that should be allowed to be entered

string $addttext

Any additional text that should be added into the tag when rendered

string $label

The text for label

string $labeladdtext

Any additional text that should be added into the tag when rendered

Response

string

CreateInputColor(string $id, string $name, string $value = '', string $addttext = '') : string

Returns the html5 equivalent of an input of type color. This is basically a nice little wrapper to make sure that id's are placed in names and also that it's html5 compliant.

Arguments

string $id

The id given to the module on execution

string $name

The html name of the input field

string $value

The predefined value of the textbox, if any

string $addttext

Any additional text that should be added into the tag when rendered

Response

string

CreateInputDate(string $id, string $name, string $value = '', string $addttext = '') : string

Returns the html5 equivalent of an input of type date. This is basically a nice little wrapper to make sure that id's are placed in names and also that it's html5 compliant.

deprecated

Arguments

string $id

The id given to the module on execution

string $name

The html name of the input field

string $value

The predefined value of the textbox, if any

string $addttext

Any additional text that should be added into the tag when rendered

Response

string

CreateInputDatetime(string $id, string $name, string $value = '', string $addttext = '') : string

Returns the html5 equivalent of an input of type datetime. This is basically a nice little wrapper to make sure that id's are placed in names and also that it's html5 compliant.

deprecated

Arguments

string $id

The id given to the module on execution

string $name

The html name of the input field

string $value

The predefined value of the textbox, if any

string $addttext

Any additional text that should be added into the tag when rendered

Response

string

CreateInputDatetimeLocal(string $id, string $name, string $value = '', string $addttext = '') : string

Returns the html5 equivalent of an input of type datetime-local. This is basically a nice little wrapper to make sure that id's are placed in names and also that it's html5 compliant.

deprecated

Arguments

string $id

The id given to the module on execution

string $name

The html name of the input field

string $value

The predefined value of the textbox, if any

string $addttext

Any additional text that should be added into the tag when rendered

Response

string

CreateInputMonth(string $id, string $name, string $value = '', string $addttext = '') : string

Returns the html5 equivalent of an input of type month. This is basically a nice little wrapper to make sure that id's are placed in names and also that it's html5 compliant.

deprecated

Arguments

string $id

The id given to the module on execution

string $name

The html name of the input field

string $value

The predefined value of the textbox, if any

string $addttext

Any additional text that should be added into the tag when rendered

Response

string

CreateInputWeek(string $id, string $name, string $value = '', string $addttext = '') : string

Returns the html5 equivalent of an input of type week. This is basically a nice little wrapper to make sure that id's are placed in names and also that it's html5 compliant.

deprecated

Arguments

string $id

The id given to the module on execution

string $name

The html name of the input field

string $value

The predefined value of the textbox, if any

string $addttext

Any additional text that should be added into the tag when rendered

Response

string

CreateInputTime(string $id, string $name, string $value = '', string $addttext = '') : string

Returns the html5 equivalent of an input of type time. This is basically a nice little wrapper to make sure that id's are placed in names and also that it's html5 compliant.

deprecated

Arguments

string $id

The id given to the module on execution

string $name

The html name of the input field

string $value

The predefined value of the textbox, if any

string $addttext

Any additional text that should be added into the tag when rendered

Response

string

CreateInputNumber(string $id, string $name, string $value = '', string $addttext = '') : string

Returns the html5 equivalent of an input of type number. This is basically a nice little wrapper to make sure that id's are placed in names and also that it's html5 compliant.

Arguments

string $id

The id given to the module on execution

string $name

The html name of the input field

string $value

The predefined value of the textbox, if any

string $addttext

Any additional text that should be added into the tag when rendered

Response

string

CreateInputRange(string $id, string $name, string $value = '', string $addttext = '') : string

Returns the html5 equivalent of an input of type range. This is basically a nice little wrapper to make sure that id's are placed in names and also that it's html5 compliant.

deprecated

Arguments

string $id

The id given to the module on execution

string $name

The html name of the input field

string $value

The predefined value of the textbox, if any

string $addttext

Any additional text that should be added into the tag when rendered

Response

string

CreateInputEmail(string $id, string $name, string $value = '', string $size = '10', string $maxlength = '255', string $addttext = '') : string

Returns the html5 equivalent of an input textbox of type email. This is basically a nice little wrapper to make sure that id's are placed in names and also that it's html5 compliant.

deprecated

Arguments

string $id

The id given to the module on execution

string $name

The html name of the textbox

string $value

The predefined value of the textbox, if any

string $size

The number of columns wide the textbox should be displayed

string $maxlength

The maximum number of characters that should be allowed to be entered

string $addttext

Any additional text that should be added into the tag when rendered

Response

string

CreateInputTel(string $id, string $name, string $value = '', string $size = '10', string $maxlength = '255', string $addttext = '') : string

Returns the html5 equivalent of an input textbox of type tel. This is basically a nice little wrapper to make sure that id's are placed in names and also that it's html5 compliant.

deprecated

Arguments

string $id

The id given to the module on execution

string $name

The html name of the textbox

string $value

The predefined value of the textbox, if any

string $size

The number of columns wide the textbox should be displayed

string $maxlength

The maximum number of characters that should be allowed to be entered

string $addttext

Any additional text that should be added into the tag when rendered

Response

string

CreateInputSearch(string $id, string $name, string $value = '', string $size = '10', string $maxlength = '255', string $addttext = '') : string

Returns the html5 equivalent of an input of type search. This is basically a nice little wrapper to make sure that id's are placed in names and also that it's html5 compliant.

deprecated

Arguments

string $id

The id given to the module on execution

string $name

The html name of the textbox

string $value

The predefined value of the textbox, if any

string $size

The number of columns wide the textbox should be displayed

string $maxlength

The maximum number of characters that should be allowed to be entered

string $addttext

Any additional text that should be added into the tag when rendered

Response

string

CreateInputUrl(string $id, string $name, string $value = '', string $size = '10', string $maxlength = '255', string $addttext = '') : string

Returns the html5 equivalent of an input of type url. This is basically a nice little wrapper to make sure that id's are placed in names and also that it's xhtml compliant.

deprecated

Arguments

string $id

The id given to the module on execution

string $name

The html name of the textbox

string $value

The predefined value of the textbox, if any

string $size

The number of columns wide the textbox should be displayed

string $maxlength

The maximum number of characters that should be allowed to be entered

string $addttext

Any additional text that should be added into the tag when rendered

Response

string

CreateInputFile(string $id, string $name, string $accept = '', string $size = '10', string $addttext = '') : string

Returns the xhtml equivalent of a file-selector field. This is basically a nice little wrapper to make sure that id's are placed in names and also that it's xhtml compliant.

deprecated

Arguments

string $id

The id given to the module on execution

string $name

The html name of the textbox

string $accept

The MIME-type to be accepted, default is all

string $size

The number of columns wide the textbox should be displayed

string $addttext

Any additional text that should be added into the tag when rendered

Response

string

CreateInputPassword(string $id, string $name, string $value = '', string $size = '10', string $maxlength = '255', string $addttext = '') : string

Returns the xhtml equivalent of an input password-box. This is basically a nice little wrapper to make sure that id's are placed in names and also that it's xhtml compliant.

deprecated

Arguments

string $id

The id given to the module on execution

string $name

The html name of the textbox

string $value

The predefined value of the textbox, if any

string $size

The number of columns wide the textbox should be displayed

string $maxlength

The maximum number of characters that should be allowed to be entered

string $addttext

Any additional text that should be added into the tag when rendered

Response

string

CreateInputHidden(string $id, string $name, string $value = '', string $addttext = '') : string

Returns the xhtml equivalent of a hidden field. This is basically a nice little wrapper to make sure that id's are placed in names and also that it's xhtml compliant.

deprecated

Arguments

string $id

The id given to the module on execution

string $name

The html name of the hidden field

string $value

The predefined value of the field, if any

string $addttext

Any additional text that should be added into the tag when rendered

Response

string

CreateInputCheckbox(string $id, string $name, string $value = '', string $selectedvalue = '', string $addttext = '') : string

Returns the xhtml equivalent of a checkbox. This is basically a nice little wrapper to make sure that id's are placed in names and also that it's xhtml compliant.

deprecated

Arguments

string $id

The id given to the module on execution

string $name

The html name of the checkbox

string $value

The value returned from the input if selected

string $selectedvalue

The current value. If equal to $value the checkbox is selected

string $addttext

Any additional text that should be added into the tag when rendered

Response

string

CreateInputSubmit(string $id, string $name, string $value = '', string $addttext = '', string $image = '', string $confirmtext = '') : string

Returns the xhtml equivalent of a submit button. This is basically a nice little wrapper to make sure that id's are placed in names and also that it's xhtml compliant.

deprecated

Arguments

string $id

The id given to the module on execution

string $name

The html name of the button

string $value

The predefined value of the button, if any

string $addttext

Any additional text that should be added into the tag when rendered

string $image

Use an image instead of a regular button

string $confirmtext

Optional text to display in a confirmation message.

Response

string

CreateInputReset(string $id, string $name, string $value = 'Reset', string $addttext = '') : string

Returns the xhtml equivalent of a reset button. This is basically a nice little wrapper to make sure that id's are placed in names and also that it's xhtml compliant.

deprecated

Arguments

string $id

The id given to the module on execution

string $name

The html name of the button

string $value

The predefined value of the button, if any

string $addttext

Any additional text that should be added into the tag when rendered

Response

string

CreateFileUploadInput(string $id, string $name, string $addttext = '', integer $size = '10', integer $maxlength = '255') : string

Returns the xhtml equivalent of a file upload input. This is basically a nice little wrapper to make sure that id's are placed in names and also that it's xhtml compliant.

deprecated

Arguments

string $id

The id given to the module on execution

string $name

The html name of the input

string $addttext

Any additional text that should be added into the tag when rendered

integer $size

The size of the text field associated with the file upload field. Some browsers may not respect this value.

integer $maxlength

The maximim length of the content of the text field associated with the file upload field. Some browsers may not respect this value.

Response

string

CreateInputDropdown(string $id, string $name, string $items, string $selectedindex = -1, string $selectedvalue = '', string $addttext = '') : string

Returns the xhtml equivalent of a dropdown list. This is basically a nice little wrapper to make sure that id's are placed in names and also that it is xhtml compliant.

deprecated

Arguments

string $id

The id given to the module on execution

string $name

The html name of the dropdown list

string $items

An array of items to put into the dropdown list... they should be $key=>$value pairs

string $selectedindex

The default selected index of the dropdown list. Setting to -1 will result in the first choice being selected

string $selectedvalue

The default selected value of the dropdown list. Setting to '' will result in the first choice being selected

string $addttext

Any additional text that should be added into the tag when rendered

Response

string

CreateInputDataList(string $id, string $name, string $value = '', string $items, string $size = '10', string $maxlength = '255', string $addttext = '') : string

Returns the html5 equivalent input field with datalist options. This is basically a nice little wrapper to make sure that id's are placed in names and also that it's html5 compliant.

deprecated

Arguments

string $id

The id given to the module on execution

string $name

The html name of the textbox

string $value

The predefined value of the textbox, if any

string $items

An array of items to put into the list... they should be $key=>$value pairs

string $size

The number of columns wide the textbox should be displayed

string $maxlength

The maximum number of characters that should be allowed to be entered

string $addttext

Any additional text that should be added into the tag when rendered

Response

string

CreateInputSelectList(string $id, string $name, string $items, string $selecteditems = array(), string $size = 3, string $addttext = '', boolean $multiple = true) : string

Returns the xhtml equivalent of a multi-select list. This is basically a nice little wrapper to make sure that id's are placed in names and also that it is xhtml compliant.

deprecated

Arguments

string $id

The id given to the module on execution

string $name

The html name of the select list

string $items

An array of items to put into the list... they should be $key=>$value pairs

string $selecteditems

An array of items in the list that should default to selected.

string $size

The number of rows to be visible in the list (before scrolling).

string $addttext

Any additional text that should be added into the tag when rendered

boolean $multiple

indicates wether multiple selections are allowed (defaults to true)

Response

string

CreateInputRadioGroup(string $id, string $name, string $items, string $selectedvalue = '', string $addttext = '', string $delimiter = '') : string

Returns the xhtml equivalent of a set of radio buttons. This is basically a nice little wrapper to make sure that id's are placed in names and also that it is xhtml compliant.

Arguments

string $id

The id given to the module on execution

string $name

The html name of the radio group

string $items

An array of items to create as radio buttons... they should be $key=>$value pairs

string $selectedvalue

The default selected index of the radio group. Setting to -1 will result in the first choice being selected

string $addttext

Any additional text that should be added into the tag when rendered

string $delimiter

A delimiter to throw between each radio button, e.g., a
tag or something for formatting

Response

string

CreateTextArea(boolean $enablewysiwyg, string $id, string $text, string $name, string $classname = '', string $htmlid = '', string $encoding = '', string $stylesheet = '', string $cols = '', string $rows = '', string $forcewysiwyg = '', string $wantedsyntax = '', string $addtext = '') : string

Returns the xhtml equivalent of a textarea. Also takes WYSIWYG preference into consideration if it's called from the admin side.

deprecated

Arguments

boolean $enablewysiwyg

Should we try to create a WYSIWYG for this textarea?

string $id

The id given to the module on execution

string $text

The text to display in the textarea's content

string $name

The html name of the textarea

string $classname

The CSS class to associate this textarea to

string $htmlid

The html id to give to this textarea

string $encoding

The encoding to use for the content

string $stylesheet

The text of the stylesheet associated to this content. Only used for certain WYSIWYGs

string $cols

The number of characters wide (columns) the resulting textarea should be

string $rows

The number of characters high (rows) the resulting textarea should be

string $forcewysiwyg

The wysiwyg-system to be forced even if the user has chosen another one

string $wantedsyntax

The language the content should be syntaxhightlighted as

string $addtext

Any additional text to include with the textarea field.

Response

string

CreateSyntaxArea(string $id, string $text, string $name, string $classname = '', string $htmlid = '', string $encoding = '', string $stylesheet = '', string $cols = '80', string $rows = '15', string $addtext = '') : string

Returns the xhtml equivalent of a textarea. Also takes Syntax hilighter preference into consideration if it's called from the admin side.

deprecated

Arguments

string $id

The id given to the module on execution

string $text

The text to display in the textarea's content

string $name

The html name of the textarea

string $classname

The CSS class to associate this textarea to

string $htmlid

The html id to give to this textarea

string $encoding

The encoding to use for the content

string $stylesheet

The text of the stylesheet associated to this content. Only used for certain WYSIWYGs

string $cols

The number of characters wide (columns) the resulting textarea should be

string $rows

The number of characters high (rows) the resulting textarea should be

string $addtext

Additional text for the text area tag.

Response

string

create_url(string $id, string $action, integer $returnid = '', \hash $params = array(), boolean $inline = false, boolean $targetcontentonly = false, string $prettyurl = '') : \string.

Returns a URL to a module action This method is called by the CreateLink methods when creating a link to a module action.

Arguments

string $id

The module action id (cntnt01 indicates that the defaul content block of the destination page should be used).

string $action

The module action name

integer $returnid

The destination page.

\hash $params

Areay of parameters for the URL. These will be ignored if the prettyurl argument is specified.

boolean $inline

Wether the target of the output link is the same tag on the same page.

boolean $targetcontentonly

Wether the target of the output link targets the content area of the destination page.

string $prettyurl

An optional url segment related to the root of the page for pretty url purposes.

Response

\string.

get_pretty_url(string $id, string $action, integer $returnid = '', array $params = array(), boolean $inline = false) : string

Return a pretty url string for a module action This method is called by the create_url and the CreateLink methods if the pretty url argument is not specified in order to attempt automating a pretty url for an action.

Arguments

string $id

The module action id (cntnt01 indicates that the defaul content block of the destination page should be used).

string $action

The module action name

integer $returnid

The destination page.

array $params

Areay of parameters for the URL. These will be ignored if the prettyurl argument is specified.

boolean $inline

Wether the target of the output link is the same tag on the same page.

Response

string

RedirectToAdminTab(string $tab = '', mixed|null $params = '', string $action = '') 

Redirect to the specified tab.

Applicable only to admin actions.

Arguments

string $tab

The tab name. If empty, the current tab is used.

mixed|null $params

An assoiciative array of params, or null

string $action

The action name (if not specified, defaultadmin is assumed)

RedirectForFrontEnd(string $id, string $returnid, string $action, string $params = array(), boolean $inline = true) 

Redirects the user to another action of the module.

This function is optimized for frontend use.

Arguments

string $id

The id given to the module on execution

string $returnid

The action that this form should do when the form is submitted

string $action

The id to eventually return to when the module is finished it's task

string $params

An array of params that should be inlucded in the URL of the link. These should be in a $key=>$value format.

boolean $inline

A flag to determine if actions should be handled inline (no moduleinterface.php -- only works for frontend)

Redirect(string $id, string $action, string $returnid = '', string $params = array(), boolean $inline = false) 

Redirects the user to another action of the module.

Arguments

string $id

The id given to the module on execution

string $action

The action that this form should do when the form is submitted

string $returnid

The id to eventually return to when the module is finished it's task

string $params

An array of params that should be inlucded in the URL of the link. These should be in a $key=>$value format.

boolean $inline

A flag to determine if actions should be handled inline (no moduleinterface.php -- only works for frontend)

RedirectToAdmin(string $page, array $params = array()) 

Redirects to an admin page

deprecated

Arguments

string $page

php script to redirect to

array $params

optional array of url parameters

RedirectContent(integer $id) 

Redirects the user to a content page outside of the module. The passed around returnid is frequently used for this so that the user will return back to the page from which they first entered the module.

Arguments

integer $id

Content id to redirect to.

GetModuleInstance(string $module) : \CMSModule

Get a reference to another module object

static

Arguments

string $module

The required module name.

Response

\CMSModule

The module object, or FALSE

GetModulesWithCapability(string $capability, array $params = array()) : array

Returns an array of modulenames with the specified capability and which are installed and enabled, of course

final

Arguments

string $capability

name of the capability we are checking for. could be "wysiwyg" etc.

array $params

further params to get more detailed info about the capabilities. Should be syncronized with other modules of same type

Response

array

Lang() : string

Returns the corresponding translated string for the id given.

This method accepts variable arguments. The first argument (required) is the language string key (a string) Further arguments may be sprintf arguments matching the specified key.

Response

string

GetActionTemplateObject() : \Smarty_Internal_Template

Get a reference to the smarty template object that was passed in to the the action.

final

This method is only valid within a module action.

Response

\Smarty_Internal_Template

GetDatabaseResource(string $template) : string

Build a resource string for an old module templates resource.

final

If the template name provided ends with .tpl a module file template is assumed.

Arguments

string $template

The template name.

Response

string

GetTemplateResource(string $template) : string

A function to return a resource identifier to a module specific template if the template specified ends in .tpl then a file template is assumed.

final

Arguments

string $template

The template name.

Response

string

GetFileResource(string $template) : string

A function to return a resource identifier to a module specific file template

final

Arguments

string $template

The template name.

Response

string

ListTemplates(string $modulename = '') : array

List Templates associated with a module

deprecated final

Arguments

string $modulename

If empty the current module name is used.

Response

array

GetTemplate(string $tpl_name, string $modulename = '') : string

Returns a database saved template. This should be used for admin functions only, as it doesn't follow any smarty caching rules.

deprecated final

Arguments

string $tpl_name

the template name.

string $modulename

If empty the current module name is used.

Response

string

GetTemplateFromFile(string $template_name) : string

Returns contents of the template that resides in modules/ModuleName/templates/{template_name}.tpl Code adapted from the Guestbook module

final

Arguments

string $template_name

Response

string

SetTemplate(string $tpl_name, string $content, string $modulename = '') : boolean

Sets a smarty template into the database and associates it with a module.

deprecated final

Arguments

string $tpl_name

The template name

string $content

The template content

string $modulename

The module name, if empty the current module name is used.

Response

boolean

DeleteTemplate(string $tpl_name = '', string $modulename = '') : boolean

Delete a module template from the database

deprecated final

Arguments

string $tpl_name

The Template name, if empty all templates associated with the module are deleted.

string $modulename

The module name, if empty the current module name is used.

Response

boolean

ProcessTemplate(string $tpl_name, string $designation = '', boolean $cache = false, string $cacheid = '') : string

Process A File template through smarty

deprecated final

Arguments

string $tpl_name

Template name

string $designation

Cache Designation

boolean $cache

Cache flag

string $cacheid

Unique cache flag

Response

string

ProcessTemplateFromData(\data $data) : string

Given a template in a variable, this method processes it through smarty note, there is no caching involved.

deprecated final

Note: this function is deprecated and scheduled for removal.

Arguments

\data $data

Input template

Response

string

ProcessTemplateFromDatabase(string $tpl_name, string $designation = '', boolean $cache = false, string $modulename = '') : string

Process a smarty template associated with a module through smarty and return the results

deprecated final

Arguments

string $tpl_name

Template name

string $designation

(optional) Designation

boolean $cache

(optional) Cachable flag

string $modulename

(optional) module name, if empty the current module is used.

Response

string

ListUserTags() : array

Return a list of user defined tags

deprecated final

Response

array

CallUserTag(string $name, array $params = array()) : array

Call a specific user defined tag

deprecated final

Arguments

string $name

Name of the user defined tag

array $params

Parameters for the user defined tag.

Response

array

SetCurrentTab(string $tab) 

Set the current tab for the action.

Used for the various template forms, this method can be used to control the tab that is displayed by default when redirecting to an admin action that displays multiple tabs.

Arguments

string $tab

The tab name

StartTabHeaders() : string

Output a string suitable for staring tab headers.

i.e: echo $this->StartTabHeaders();

Response

string

SetTabHeader(string $tabid, string $title, boolean $active = false) : string

Set a specific tab header.

i.e: echo $this->SetTabHeader('preferences',$this->Lang('preferences'));

Arguments

string $tabid

The tab id

string $title

The tab title

boolean $active

wether the tab is active or not.

Response

string

EndTabHeaders() : string

Output a string to stop the output of headers and close the necessary XHTML div.

Response

string

StartTabContent() : string

Output a string to indicate the start of XHTML areas for tabs.

Response

string

EndTabContent() : string

Output a string to indicate the end of XHTML areas for tabs.

Response

string

StartTab(string $tabid, \arrray $params = array()) : string

Output a string to indicate the start of the output for a specific tab

Arguments

string $tabid

the tab id

\arrray $params

Parameters

Response

string

EndTab() : string

Output a string to indicate the end of the output for a specific tab.

Response

string

AdminStyle() 

Called in the admin theme for every installed module, this method allows the module to output style information for use in the admin theme.

SetContentType(string $contenttype) 

Set the content-type header.

Arguments

string $contenttype

Value to set the content-type header too

Audit(string $itemid = '', string $itemname, string $action) 

Put an event into the audit (admin) log. This should be done on most admin events for consistency.

final

Arguments

string $itemid

useful for working on a specific record (i.e article or user)

string $itemname

item name

string $action

action name

ShowMessage(string $message) : string

ShowMessage Returns a formatted page status message

Arguments

string $message

Message to be shown

Response

string

SetMessage(string|array<mixed,string> $str) 

Set a display message.

Arguments

string|array<mixed,string> $str

The message. Accepts either an array of messages or a single string.

ShowErrors(string|array<mixed,string> $errors) : string

ShowErrors Outputs errors in a nice error box with a troubleshooting link to the wiki

Arguments

string|array<mixed,string> $errors

array or string of errors to be shown

Response

string

SetError(string|array<mixed,string> $str) 

Set an error message.

Arguments

string|array<mixed,string> $str

The message. Accepts either an array of messages or a single string.

CreatePermission(string $permission_name, string $permission_text = null) 

Create's a new permission for use by the module.

final

Arguments

string $permission_name

Name of the permission to create

string $permission_text

Description of the permission

CheckPermission(string $permission_name) : boolean

Checks a permission against the currently logged in user.

final

Arguments

string $permission_name

The name of the permission to check against the current user

Response

boolean

RemovePermission(string $permission_name) 

Removes a permission from the system. If recreated, the permission would have to be set to all groups again.

final

Arguments

string $permission_name

The name of the permission to remove

GetPreference(string $preference_name, string $defaultvalue = '') : string

Returns a module preference if it exists.

final

Arguments

string $preference_name

The name of the preference to check

string $defaultvalue

The default value, just in case it doesn't exist

Response

string

SetPreference(string $preference_name, string $value) 

Sets a module preference.

final

Arguments

string $preference_name

The name of the preference to set

string $value

The value to set it to

RemovePreference(string $preference_name = '') : boolean

Removes a module preference. If no preference name is specified, removes all module preferences.

final

Arguments

string $preference_name

The name of the preference to remove. If empty all preferences associated with the module are removed.

Response

boolean

ListPreferencesByPrefix(string $prefix) : array<mixed,string>|null

List all preferences for a specific module by prefix.

final

Arguments

string $prefix

Response

array<mixed,string>|null

An array of preference names, or null.

AddEventHandler(string $modulename, string $eventname, boolean $removable = true) 

Add an event handler for an existing eg event.

final

Arguments

string $modulename

The name of the module sending the event, or 'Core'

string $eventname

The name of the event

boolean $removable

Can this event be removed from the list?

CreateEvent(string $eventname) 

Inform the system about a new event that can be generated

final

Arguments

string $eventname

The name of the event

DoEvent(string $originator, string $eventname, array &$params) : boolean

An event that this module is listening to has occurred, and should be handled.

This method must be over-ridden if this module is capable of handling events. of any type.

The default behavior of this method is to check for a function called event...php in the module directory, and if this file exists it, include it to handle the event.

Arguments

string $originator

The name of the originating module

string $eventname

The name of the event

array $params

Array of parameters provided with the event.

Response

boolean

GetEventDescription(string $eventname) : string

Get a (langified) description for an event this module created.

This method must be over-ridden if this module created any events.

Arguments

string $eventname

The name of the event

Response

string

GetEventHelp(string $eventname) : string

Get a (langified) descriptionof the details about when an event is created, and the parameters that are attached with it.

This method must be over-ridden if this module created any events.

Arguments

string $eventname

The name of the event

Response

string

HandlesEvents() : boolean

A callback indicating if this module has a DoEvent method to handle incoming events.

Response

boolean

RemoveEvent(string $eventname) 

Remove an event from the CMS system This function removes all handlers to the event, and completely removes all references to this event from the database

final

Note, only events created by this module can be removed.

Arguments

string $eventname

The name of the event

RemoveEventHandler(string $modulename, string $eventname) 

Remove an event handler from the CMS system This function removes all handlers to the event, and completely removes all references to this event from the database

final

Note, only events created by this module can be removed.

Arguments

string $modulename

The module name (or Core)

string $eventname

The name of the event

SendEvent(string $eventname, array $params) 

Trigger an event.

final

This function will call all registered event handlers for the event

Arguments

string $eventname

The name of the event

array $params

The parameters associated with this event.

Properties

cms

cms : \CmsApp

A reference to the application object (deprecated)

Type(s)

\CmsApp

smarty

smarty : \Smarty_CMS

A reference to the global smarty object (deprecated)

Type(s)

\Smarty_CMS

config

config : \cms_config

A reference to the global app configuration object (deprecated)

Type(s)

\cms_config

db

db : \ADOConnection

A reference to the global database configuration object (deprecated)

Type(s)

\ADOConnection