\CGExtensions

A base class for all CMSMS modules written by me to provide optimizations and conveniences that are not built into CMSMS.

Summary

Methods
Properties
Constants
__construct()
GetFriendlyName()
GetVersion()
GetHelp()
GetAuthor()
GetAuthorEmail()
GetChangeLog()
IsPluginModule()
HasAdmin()
HandlesEvents()
GetAdminSection()
GetAdminDescription()
GetDependencies()
InstallPostMessage()
MinimumCMSVersion()
UninstallPostMessage()
VisibleToAdminUser()
GetHeaderHTML()
DoAction()
encrypt()
decrypt()
CreateURL()
CreateSortableListArea()
CreateInputYesNoDropdown()
CGCreateInputSubmit()
CreateInputCheckbox()
CGCreateFormStart()
CGCreateFrontendFormStart()
CreateInputHidden()
RedirectToTab()
Redirect()
IsAdminAction()
SetError()
SetMessage()
DisplayErrors()
DisplayMessages()
SetCurrentAction()
SetCurrentTab()
SetTabHeader()
DisplayErrorMessage()
GetErrorTemplate()
ResetErrorTemplate()
SetErrorTemplate()
CreateInputStateDropdown()
CreateInputCountryDropdown()
GetCountry()
GetState()
CreateImageDropdown()
CreateFileDropdown()
CreateColorDropdown()
CreateImageTag()
DisplayImage()
CreateImageLink()
AddImageDir()
ListTemplatesWithPrefix()
CreateTemplateDropdown()
ShowTemplateList()
GetDefaultTemplateForm()
EditDefaultTemplateForm()
CreateContentURL()
GetAdminUsername()
GetUploadErrorMessage()
GetSingleTemplateForm()
GetWatermarkError()
InitializeCharting()
InitializeAssocData()
session_clear()
session_put()
session_get()
param_session_get()
resolve_alias_or_id()
http_post()
http_get()
CGGetPreference()
CGGetUserPreference()
CGSetUserPreference()
CGRemoveUserPreference()
find_module_file()
get_module_files()
find_template_file()
CreateSmartyTemplate()
CGGetTemplateResource()
CGProcessTemplate()
GetActionModule()
GetShowMessageURL()
ShowFormattedMessage()
No public properties found
No constants found
get_state_list()
get_state_list_options()
get_country_list()
get_country_list_options()
No protected properties found
N/A
No private methods found
No private properties found
N/A

Methods

__construct()

__construct()

The constructor.

This method does numerous things, including setup an extended autoloader, create defines for the module itself. i.e: MOD_CGEXTENSIONS, or MOD_FRONTENDUSERS. sets up a built in cache driver for temporarily caching data. and register numerous smarty plugins (see the documentation for those).

GetFriendlyName()

GetFriendlyName() : string

The Friendly name for this module. For use in the admin navigation.

Returns

string

GetVersion()

GetVersion() : string

Return the version of this module.

Returns

string

GetHelp()

GetHelp() : string

Return the help of this module.

Returns

string

GetAuthor()

GetAuthor() : string

Return the Author of this module.

Returns

string

GetAuthorEmail()

GetAuthorEmail() : string

Return the email address for the author of this module.

Returns

string

GetChangeLog()

GetChangeLog() : string

Return the changelog for this module.

Returns

string

IsPluginModule()

IsPluginModule() : bool

Return if this is a plugin module (for the frontend of the website) or not.

Returns

bool

HasAdmin()

HasAdmin() : string

Return if this module has an admin section.

Returns

string

HandlesEvents()

HandlesEvents() : string

Return if this module handles events.

Returns

string

GetAdminSection()

GetAdminSection() : string

Get the section of the admin navigation that this module belongs to.

Returns

string

GetAdminDescription()

GetAdminDescription() : string

Get a human readable description for this module.

Returns

string

GetDependencies()

GetDependencies() : string

Get a hash containing dependent modules, and their minimum versions.

Returns

string

InstallPostMessage()

InstallPostMessage() : string

Display a custom message after the module has been installed.

Returns

string

MinimumCMSVersion()

MinimumCMSVersion() : string

Return the minimum CMSMS version that this module is compatible with.

Returns

string

UninstallPostMessage()

UninstallPostMessage() : string

Return a message to display after the module has been uninstalled.

Returns

string

VisibleToAdminUser()

VisibleToAdminUser() : bool

Test if this module is visible in the admin navigation to the currently logged in admin user.

Returns

bool

GetHeaderHTML()

GetHeaderHTML() : bool

Retrieve some HTML to be output in all admin requests for this module (and its descendants).

By default this module calls the jsloader::render method, and includes some standard styles

Returns

bool

DoAction()

DoAction(string $name, string $id, array $params, int $returnid)

A replacement for the built in DoAction method For CGExtensions derived modules some builtin smarty variables are created module hints are handled, and input type=image values are corrected in input parameters.

this method also handles setting the active tab, and displaying any messages or errors set with the SetError or SetMessage methods.

This method is called automatically by the system based on the incoming request, and the page template. It should almost never be called manually.

Parameters

string $name

the action name

string $id

The module action id

array $params

The module parameters

int $returnid

The page that will contain the HTML results. This is empty for admin requests.

encrypt()

encrypt(string $key, string $data) : string

A convenience method to encrypt some data

Parameters

string $key

The encryption key

string $data

The data to encrypt

Returns

string —

The encrypted data

decrypt()

decrypt(string $key, string $data) : string

A convenience method to decrypt some data

Parameters

string $key

The encryption key

string $data

The data to decrypt

Returns

string —

The derypted data

CreateURL()

CreateURL(string $id, string $action, string $returnid, array $params, bool $inline, string $prettyurl)

A convenience function to create a url for a module action.

This method is deprecated as the CMSModule::create_url method replaces it.

Parameters

string $id

the module action id

string $action

The module action

string $returnid

The page that the url will refer to. This is empty for admin requests

array $params

Module parameters

bool $inline

For frontend requests only dicates wether this url should be inline only.

string $prettyurl

CreateSortableListArea()

CreateSortableListArea(string $id, string $name, array $items, string $selected, bool $allowduplicates, int $max_selected, string $template, string $label_left, string $label_right) : string

A convenience method to create a control that contains a 'sortable list'.

The output control is translated, and interactive and suitable for use in forms.

Parameters

string $id

The module action id

string $name

The input element name

array $items

An associative array of the items for this list.

string $selected

A comma separated string of selected item keys

bool $allowduplicates
int $max_selected

The maximum number of items that can be selected

string $template

Specify an alternate template for the sortable list control

string $label_left

A label for the left column.

string $label_right

A label for the right column.

Returns

string

CreateInputYesNoDropdown()

CreateInputYesNoDropdown(string $id, string $name, int $selectedvalue, string $addtext) : string

Create a translated Yes/No dropdown.

The output control is translated, and suitable for use in forms. This method is deprecated. It is best to assign all data to smarty and then create input elements as necessary in the smarty template.

Parameters

string $id

the module action id

string $name

The name for the input element

int $selectedvalue

The selected value (0 == no, 1 == yes)

string $addtext

Returns

string

CGCreateInputSubmit()

CGCreateInputSubmit(string $id, string $name, string $value, string $addtext, string $image, string $confirmtext, string $class) : string

Create a custom submit button.

The output control is translated, and suitable for use in forms. This method is deprecated. It is best to assign all data to smarty and then create input elements as necessary in the smarty template.

Parameters

string $id

the module action id

string $name

The name for the input element

string $value

The value for the submit button

string $addtext

Additional text for the tag

string $image

an optional image path

string $confirmtext

Optional confirmation text

string $class

Optional value for the class attribute

Returns

string

CreateInputCheckbox()

CreateInputCheckbox(string $id, string $name, string $value, string $selectedvalue, string $addtext) : string

Create a custom checkbox.

This is similar to the standard checkbox but has a hidden field with the same name before it so that some value for this field is always returned to the form handler. This method is deprecated. It is best to assign all data to smarty and then create input elements as necessary in the smarty template.

Parameters

string $id

the module action id

string $name

The name for the input element

string $value

The value for the checkbox

string $selectedvalue

The current value of the field.

string $addtext

Additional text for the tag

Returns

string

CGCreateFormStart()

CGCreateFormStart(string $id, string $action, string $returnid, array $params, bool $inline, string $method, string $enctype, string $idsuffix, string $extra) : string

A Convenience function for creating form tags.

This method re-organises some of the parameters of the original CreateFormStart method and handles current tab functionalty, and sets the encoding type of the form to multipart/form-data

This method is deprecated and will be replaced in CMSMS 2.0 by the core {form_start} tag.

Parameters

string $id

the module action id

string $action

the destination action

string $returnid

The destination pagpe for the action handler. Empty for admin requests

array $params

additional parameters to be passed with the form

bool $inline

wether this is an inline form request (output will replace module tag rather than the entire content section of the template.

string $method

The form method.

string $enctype

The form encoding type

string $idsuffix
string $extra

Extra text for thhe form tag

Returns

string

CGCreateFrontendFormStart()

CGCreateFrontendFormStart(string $id, string $action, string $returnid, array $params, bool $inline, string $method, string $enctype, string $idsuffix, string $extra) : string

A convenience function for creating a frontend form This method re-organises some of the parameters of the original CreateFormStart method and sets the encoding type of the form to multipart/form-data

This method is deprecated and will be replaced in CMSMS 2.0 by the core {form_start} tag.

Parameters

string $id

the module action id

string $action

the destination action

string $returnid

The destination pagpe for the action handler. Empty for admin requests

array $params

additional parameters to be passed with the form

bool $inline

wether this is an inline form request (output will replace module tag rather than the entire content section of the template.

string $method

The form method.

string $enctype

The form encoding type

string $idsuffix
string $extra

Extra text for thhe form tag

Returns

string

CreateInputHidden()

CreateInputHidden(string $id, string $name, string $value, string $addtext, string $delim) : string

A convenience method to create a hidden input element for forms.

This method is deprecated. It is best to assign all data to smarty and then create input elements as necessary in the smarty template.

Parameters

string $id

the module action id

string $name

The name of the input element

string $value

The value of the input element

string $addtext

Additional text for the tag

string $delim

the delimiter for value separation.

Returns

string

RedirectToTab()

RedirectToTab(string $id, string $tab, string $params, string $action)

For admin requests only, pass variables so that the specified tab will be displayed by default in the resulting action.

Parameters

string $id

the module action id. For admin requests this is usually 'm1_'

string $tab

The name of the parameter

string $params

Extra parameters for the request

string $action

The designated module action. If none is specified 'defaultadmin' is assumed.

Redirect()

Redirect(string $id, string $action, int $returnid, array $params, bool $inline)

Redirect to a specified module action.

This method is usable both for admin and frontend requests.

Parameters

string $id

the module action id. For admin requests this is usually 'm1_'

string $action

The designated module action. If none is specified 'defaultadmin' is assumed.

int $returnid

The destination page. empty for admin requests.

array $params

Extra parameters for the URL

bool $inline

Wether the output should be an inline URL or not ??

IsAdminAction()

IsAdminAction() : bool

Test if the current code is handling an admin action or a frontend action

Returns

bool —

True for an admin action, false otherwise.

SetError()

SetError(string $str)

Set an error to display on the next admin request from a CGExtensions derived module.

The error message will be carried on to the next admin request and displayed.

Parameters

string $str

The error message.

SetMessage()

SetMessage(string $str)

Set a message to display on the next admin request from a CGExtensions derived module.

The message will be carried on to the next admin request and displayed.

Parameters

string $str

The informational message to display.

DisplayErrors()

DisplayErrors()

Display any set error message in the admin console.

DisplayMessages()

DisplayMessages()

Display any set informational messages in the admin console.

SetCurrentAction()

SetCurrentAction(string $action)

Set the current action for the next request of the admin console.

Used for the various admin forms.

Parameters

string $action

The action name

SetCurrentTab()

SetCurrentTab(string $tab)

Set the current tab for the next request of the admin console.

Used for the various template forms.

Parameters

string $tab

The tab name.

SetTabHeader()

SetTabHeader(string $name, string $str, mixed $state)

A replacement for the built in SetTabHeader.

This method is a smart replacement that will automatically handle an active tab on the requiest.

Parameters

string $name

The tab name (for coding purposes)

string $str

The human readable label for the tab.

mixed $state

If Empty or 'unknown' then detect any currently set tab.

DisplayErrorMessage()

DisplayErrorMessage(string $txt, string $class)

A function for using a template to display an error message.

This method is suitable for frontend displays.

Parameters

string $txt

The error message

string $class

An optional class attribute value.

GetErrorTemplate()

GetErrorTemplate()

A convenience function for retrieving the current error template

ResetErrorTemplate()

ResetErrorTemplate()

Reset the error template to factory defaults

SetErrorTemplate()

SetErrorTemplate(string $tmpl)

Set the error template

Parameters

string $tmpl

Smarty Template source

CreateInputStateDropdown()

CreateInputStateDropdown(string $id, string $name, string $value, mixed $selectone, string $addtext)

A convenience function to create a state dropdown list.

Parameters

string $id

The module action id

string $name

the name for the dropdown.

string $value

The initial value for the dropdown.

mixed $selectone

If true, then a hardcoded "Select One" string will be prepended to the list. If a string then that string will be used.

string $addtext

Additional text for the select tag.

CreateInputCountryDropdown()

CreateInputCountryDropdown(string $id, string $name, string $value, mixed $selectone, string $addtext)

A convenience function to create a country dropdown list

Parameters

string $id

The module action id

string $name

the name for the dropdown.

string $value

The initial value for the dropdown.

mixed $selectone

If true, then a hardcoded "Select One" string will be prepended to the list. If a string then that string will be used.

string $addtext

Additional text for the select tag.

GetCountry()

GetCountry(string $the_acronym) : string

A convenience function to get the country name given the acronym

Parameters

string $the_acronym

Returns

string

GetState()

GetState(string $the_acronym) : string

A convenience function to get the state name given the acronym

Parameters

string $the_acronym

Returns

string

CreateImageDropdown()

CreateImageDropdown(string $id, string $name, string $selectedfile, string $dir, mixed $none) : \string.

A convenience function to create an image dropdown from all of the image files in a specified directory.

This method will not ignore thumbnails.

Parameters

string $id

The module action id

string $name

the name for the dropdown.

string $selectedfile

The initial value for the dropdown (an image filename)

string $dir

The path (relative to the uploads path) to the directory to pull images from. If not specified, the image uploads path will be used.

mixed $none

If true, then 'None' will be prepended to the list of output images. If a string it's value will be used.

Returns

\string.

CreateFileDropdown()

CreateFileDropdown(string $id, string $name, string $selectedfile, string $dir, string $extensions, bool $allownone, bool $allowmultiple, int $size) : \string.

A convenience function to create a list of filenames in a specified directory.

Parameters

string $id

The module action id

string $name

the name for the dropdown.

string $selectedfile

The initial value for the dropdown (an image filename)

string $dir

The path (relative to the uploads path) to the directory to pull images from. If not specified, the image uploads path will be used.

string $extensions

A comma separated list of filename extensions to include in the list. If not specified the module preference will be used.

bool $allownone

Allow no files to be selected.

bool $allowmultiple

To allow selecting multiple files.

int $size

The size of the dropdown.

Returns

\string.

CreateColorDropdown()

CreateColorDropdown(string $id, string $name, string $selectedvalue) : string

A convenience function to create a color selection dropdown

Parameters

string $id

The module action id

string $name

the name for the dropdown.

string $selectedvalue

The initial value for the input field.

Returns

string

CreateImageTag()

CreateImageTag(string $id, string $alt, int $width, int $height, string $class, string $addtext) : string

A convenience method to create an image tag.

This method will automatically search through added image dirs for frontend and admin requests and through the admin theme directories for admin requests.

Parameters

string $id

The module action id

string $alt

The alt attribute for the tag

int $width

Width in pixels

int $height

Height in pixels

string $class

Value for the class attribute

string $addtext

Additional text for the img tag.

Returns

string

DisplayImage()

DisplayImage(string $image, string $alt, string $class, int $width, int $height) : string

A convenience method to display an image.

This method will automatically search through added image dirs for frontend and admin requests and through the admin theme directories for admin requests.

Parameters

string $image

The basename for the desired image.

string $alt

The alt attribute for the tag

string $class

Value for the class attribute

int $width

Width in pixels

int $height

Height in pixels

Returns

string

CreateImageLink()

CreateImageLink(string $id, string $action, int $returnid, string $contents, string $image, array $params, string $classname, string $warn_message, bool $imageonly, bool $inline, string $addtext, bool $targetcontentonly, string $prettyurl) : string

A convenience method to create a link to a module action containing an image and optionally some text.

This method will automatically search through added image dirs for frontend and admin requests and through the admin theme directories for admin requests.

Parameters

string $id

The module action id

string $action

The name of the destination action

int $returnid

The page for the destination of the request. Empty for admin requests.

string $contents

The text content of the image.

string $image

The basename of the image to display.

array $params

Additional link parameters

string $classname

Class for the img tag.

string $warn_message

An optional confirmation message

bool $imageonly

Wether the contents (if specified) should be ignored.

bool $inline
string $addtext
bool $targetcontentonly
string $prettyurl

An optional pretty url slug.

Returns

string

AddImageDir()

AddImageDir(string $dir)

Add a directory to the list of searchable directories

Parameters

string $dir

A directory relative to this modules installation directory.

ListTemplatesWithPrefix()

ListTemplatesWithPrefix(string $prefix, bool $trim) : array

List all templates stored with this module that begin with the same prefix.

Parameters

string $prefix

The optional prefix

bool $trim

Returns

array

CreateTemplateDropdown()

CreateTemplateDropdown(string $id, string $name, string $prefix, string $selectedvalue, string $addtext) : string

Create a dropdown of all templates beginning with the specified prefix

Parameters

string $id

The module action id

string $name

The name for the input element.

string $prefix

The optional prefix

string $selectedvalue

The default value for the input element

string $addtext

Returns

string

ShowTemplateList()

ShowTemplateList(string $id, int $returnid, string $prefix, string $defaulttemplatepref, string $active_tab, string $defaultprefname, string $title, string $info, string $destaction)

Part of the multiple database template functionality this function provides an interface for adding, editing, deleting and marking active all templates that match a prefix.

Parameters

string $id

The module action id (pass in the value from doaction)

int $returnid

The page id to use on subsequent forms and links.

string $prefix

The template prefix

string $defaulttemplatepref

The name of the template containing the system default template. This can either be the name of a database template or a filename ending with .tpl.

string $active_tab

The tab to return to

string $defaultprefname

The name of the preference that contains the name of the current default template. If empty string then there will be no possibility to set a default template for this list.

string $title

Title text to display in the add/edit template form

string $info

Information text to display in the add/edit template form

string $destaction

The action to return to.

GetDefaultTemplateForm()

GetDefaultTemplateForm(\GExtensions $module, string $id, string $returnid, string $prefname, string $action, string $active_tab, string $title, string $filename, string $info) : string

GetDefaultTemplateForm.

A function to return a form suitable for editing a single template.

Parameters

\GExtensions $module

A CGExtensions derived module reference

string $id
string $returnid
string $prefname
string $action
string $active_tab
string $title
string $filename
string $info

Returns

string

EditDefaultTemplateForm()

EditDefaultTemplateForm(\GExtensions $module, string $id, string $returnid, string $prefname, string $active_tab, string $title, string $filename, string $info, string $action) : string

EditDefaultTemplateForm

A function to return a form suitable for editing a single template.

Parameters

\GExtensions $module

A CGExtensions derived module reference

string $id
string $returnid
string $prefname
string $active_tab
string $title
string $filename
string $info
string $action

Returns

string

CreateContentURL()

CreateContentURL(mixed $pageid) : string

A convenience function to create a url to a certain CMS page

Parameters

mixed $pageid

A frontend page id or alias.

Returns

string

GetAdminUsername()

GetAdminUsername(int $uid) : string

Get the username of the currently logged in admin user.

Parameters

int $uid

Returns

string

GetUploadErrorMessage()

GetUploadErrorMessage(string $code) : string

Get a human readable error message for an upload code.

Parameters

string $code

The upload error code.

Returns

string

GetSingleTemplateForm()

GetSingleTemplateForm(\CGExtensions $module, string $id, int $returnid, string $tmplname, string $active_tab, string $title, string $filename, string $info, string $destaction,  $simple)

Get a form for adding or editing a single template.

Parameters

\CGExtensions $module

A CGExtensions module reference

string $id
int $returnid
string $tmplname

The name of the template to edit

string $active_tab
string $title
string $filename

The name of the file (in the module's template directory) containing the system default template.

string $info
string $destaction
$simple

GetWatermarkError()

GetWatermarkError(string $error) : string

Retrieve a human readable string for any error generated during watermarking.

Parameters

string $error

the watermarking error code

Returns

string

InitializeCharting()

InitializeCharting()

Setup and initializing charting functionality

InitializeAssocData()

InitializeAssocData()

Initialize associative data functionality

session_clear()

session_clear(string $key)

A convenience method to clear any session data associated with this module.

Parameters

string $key

If not specified clear all session data relative to this module."

session_put()

session_put(string $key, string $value)

A convenience method to store some session data associated with this module.

Parameters

string $key

The variable key.

string $value

The data to store.

session_get()

session_get(string $key, string $dfltvalue) : \mixed.

A convenience method to retrieve some session data associated with this module.

Parameters

string $key

The variable key.

string $dfltvalue

"The default value to return if the specified data does not exist."

Returns

\mixed.

param_session_get()

param_session_get(array $params, string $key, string $defaultvalue) : \mixed.

Return data identified by a key either from the supplied parameters, or from session.

Parameters

array $params

Input parameters

string $key

The data key

string $defaultvalue

The data to return if the specified data does not exist in the session or in the input parameters.

Returns

\mixed.

resolve_alias_or_id()

resolve_alias_or_id(mixed $txt, int $dflt) : int

Given a page alias resolve it to a page id.

Parameters

mixed $txt

The page alias to resolve. If an integer page id is passed in that is acceptable as well.

int $dflt

The default page id to return if no match can be found

Returns

int

http_post()

http_post(string $URL, array $data, string $referer) : string

Perform an HTTP post request.

Parameters

string $URL

the url to post to

array $data

The array to post.

string $referer

An optional referrer string.

Returns

string

http_get()

http_get(string $URL, string $referer) : string

Perform an HTTP GET request.

Parameters

string $URL

the url to post to

string $referer

An optional referrer string.

Returns

string

CGGetPreference()

CGGetPreference(string $pref_name, string $dflt_value, bool $allow_empty) : \string.

Similar to GetPreference except the default value is used even if the preference exists, but is blank.

Parameters

string $pref_name

The preference name

string $dflt_value

The default value for the preference if not set (or empty)

bool $allow_empty

Wether the default value should be used if the preference exists, but is empty.

Returns

\string.

CGGetUserPreference()

CGGetUserPreference(string $pref_name, string $dflt_value, bool $allow_empty) : \string.

A wrapper to get a module specific user preference.

this method only applies to admin users.

Parameters

string $pref_name

The preference name

string $dflt_value

The default value for the preference if not set (or empty)

bool $allow_empty

Wether the default value should be used if the preference exists, but is empty.

Returns

\string.

CGSetUserPreference()

CGSetUserPreference(string $pref_name, string $value)

A wrapper to set a user preference that is module specific.

this method only applies to admin users.

Parameters

string $pref_name

The preference name

string $value

The preference value.

CGRemoveUserPreference()

CGRemoveUserPreference(string $pref_name)

A wrapper to remove a user preference that is module specific.

this method only applies to admin users.

Parameters

string $pref_name

The preference name

find_module_file()

find_module_file(string $filename) : string

find a file for this module looks in module_custom, and in the module directory

Parameters

string $filename

Returns

string

get_module_files()

get_module_files(string $dirname, string $pattern) : string[]

Get a list of module files matching a specified pattern in a specified module subdirectory.

This method can be used for finding a list of files matching a pattern (i.e a list of classes, or even a list of templates). This method will search for files in a matching directory in the module_custom directory (if one exists) and in the module directory. i.e: $this->get_module_files('templates','summary*tpl');

Parameters

string $dirname

The directory name (relative to the module directory) to search in.

string $pattern

An optional pattern, if no pattern is specified, . is assumed.

Returns

string[]

find_template_file()

find_template_file(string $filename) : string

Given a filename, search for it in the module_custom and module's templates directory.

i.e.: $this->find_template_file('somereport.tpl');

Parameters

string $filename

The template filename (only the filename) to search for

Returns

string —

The absolute path to the filename.

CreateSmartyTemplate()

CreateSmartyTemplate(string $template_name, string $prefix, string $cache_id, string $compile_id,  $parent) : object

A convenience method to generate a new smarty template object given a resource string, and a prefix. This method will also automatically assign a few common smarty variables to the new scope.

Note: the parent smarty scope depends on how this function is called. If called directly from a module action for the same module the parent will be the current smarty scope. If called from any method that is using a different module than the action module, then the parent scope will be the global smarty scope.

Parameters

string $template_name

The desired template name.

string $prefix

an optional prefix for database templates.

string $cache_id

An optional smarty cache id.

string $compile_id

An optional smarty compile id.

$parent

Returns

object

CGGetTemplateResource()

CGGetTemplateResource(string $template_name, string $prefix) : string

A convenience method to generate a smarty resource string given a template name and an optional prefix.

if the supplied template name appears to be a smarty resource name we don't do anything. if the supplied template name ends with .tpl then a file template is assumed.

Parameters

string $template_name

The desired template name

string $prefix

an optional prefix for database templates.

Returns

string

CGProcessTemplate()

CGProcessTemplate(string $template_name, string $prefix) : string

An advanced method to process either a file, or database template for this module through smarty

Parameters

string $template_name

The template name. If the value of this parameter ends with .tpl then a file template is assumed. Otherwise a database template is assumed.

string $prefix

For database templates, optionally prefix thie template name with this value.

Returns

string —

The output from the processed smarty template.

GetActionModule()

GetActionModule() : string

Get the name of the module that the current action is for.

(only works with modules derived from CGExtensions). This method is useful to find the module action that was used to send an event.

Returns

string

GetShowMessageURL()

GetShowMessageURL( $page, string $msg, bool $is_key, bool $is_error) : string

Create a url to an action that will show a message.

This method is capable of using the \cge_message class to extract longer messages.

Parameters

$page
string $msg

The message to display. Or the message key name.

bool $is_key

If true, it indicates that the $msg parameter is a key to extract from \cge_message.

bool $is_error

Indicates if the message should be displayed as an error.

Returns

string —

The URL to the action.

ShowFormattedMessage()

ShowFormattedMessage( $msg, bool $is_error,  $title)

Show a message on the frontend of the website.

suitable for displaying errors and brief messages.

Parameters

$msg
bool $is_error

whether or not the msg is an error

$title

get_state_list()

get_state_list() : array

A function to return an array of of country codes and country names.

i.e: array( array('code'=>'AB','name'=>'Alberta'), array('code'=>'MB','code'=>'Manitoba'));

Returns

array

get_state_list_options()

get_state_list_options() : array

A function to return an array of of country codes and country names.

This method returns data that is suitable for use in a list. i.e: array( array('code'=>'AB','name'=>'Alberta'), array('code'=>'MB','code'=>'Manitoba'));

Returns

array

get_country_list()

get_country_list()

A function to return an array of of country codes and country names.

i.e: array( array('code'=>'US','name'=>'United States'), array('code'=>'CA','code'=>'Canada'));

get_country_list_options()

get_country_list_options()

A function to return an array of of country codes and country names.

This method returns data suitable for giving to smarty and displaying in a dropdown.