An auxilary class providing functionalities to other modules.
| DLSupport | An auxilary class providing functionalities to other modules. |
| Author | Duc Tri Le <cmsmadesimple---at---email.tiger-inc.com> |
| License | This class is released under the GNU General Public License. |
| Changelog | |
| Constants | |
| WordRegex | (String) The regex for our “word”. |
| Private Static Data | |
| $instance | (DLSupport) An instance of this class. |
| Protected Static Data | |
| $smarty_methods | (array) An array containing methods that can be called through Smarty using {DLSupport}. |
| Class Construction | |
| __construct | Create a new instance of DLSupport. |
| ModuleInstance | Get an instance of the given module unqiue name. |
| MySQLi | Retrieve an instance of the database class. |
| NewFormCollection | Retreive a new form collection. |
| NewTabCollection | Create a new tab collection. |
| Singleton | This method will return an instance of this class. |
| Override Methods | |
| Captcha Generation | |
| Captcha | Generate a new captcha image. |
| CaptchaRemove | Remove images created for captcha purposes that is older than the given number of hours. |
| CaptchaValidate | See if the user has entered the correct value for the captcha generated by the method Captcha. |
| Clean Admin - Deprecated | |
| GetCleanBreadcrumb | Retrieve the breadcrumb for a clean admin page. |
| GetCleanFooter | Retrieve the HTML for the footer of the clean admin page. |
| GetCleanHeader | Retrieve the HTML for the header of the clean admin page. |
| Cookies | |
| RemoveCookie | Remove the given cookie. |
| SetCookie | Store the given information with the given key in the cookie for the given number of days. |
| Cryptography | |
| Decrypt | Decrypt the given data using the given key. |
| Encrypt | Encrypt the given data using the given key. |
| CSS | |
| GetCSSFromTemplate | Get all of the CSS that is attached to the given template. |
| ParseCSS | Parse the given CSS to retrieve the class names. |
| Database | |
| AutoExecute | Create the necessary SQL query and execute the command. |
| Directory and Files | |
| ListDirectories | Retrieve a list of all direct sub directories of the given directory. |
| ListFiles | Retrieve a list of all the files in the given directory. |
| Miscellaneous | |
| CleanExit | Clear all the currently opened output buffer then terminate execution with the given message. |
| ConvertBytes | Convert the given bytes to the specified type. |
| ExecuteCommand | Execute the given list of commands. |
| GetIcon | Retrieve the HTML for an icon. |
| GetPageInfo | Retrieve information about the current page. |
| IncludeJavaScript | Include the JavaScript support file. |
| IsWord | Determien whether or not the provided string is a word using our regular pattern. |
| JSON | Terminate the execution of the script but outputting the given array as a JSON. |
| ModulePath | Retrieve the absolute path to the given module. |
| ModuleURL | Retrieve the absolute url to the given module. |
| NewFormStart | This is very similar to the method CreateFormStart except that it does not encode the content of the extras array. |
| OutputUploadResponse | Output the response page for the uploaded of a file. |
| Protoaculous | Retrieve the HTML for including Prototype, script.aculo.us from Google as well as the supporting JS frameworking. |
| SanitizeString | Wrapper method for the function “filter_var” with the filter FILTER_SANITIZE_STRING and the options FILTER_FLAG_ENCODE_LOW and FILTER_FLAG_ENCODE_HIGH. |
| UploadFileResponse | Retrieve the HTML for the response from the server. |
| UploadPageResponse | Output the upload response page. |
| Module Dependency | |
| CompareVersions | See if the installed version of the given module is less than the given version. |
| Smarty Related Methods | |
| CreateParameters | Create the appropriate parameters array to be send to the function call_user_func_array. |
| Deprecated Data | |
| $DLSupport_data | (array) An array contain various data. |
| Deprecated Methods | |
| ValidateDependency | Determine whether or not the given module name has been installed up to at least the given version. |
protected static $smarty_methods
(array) An array containing methods that can be called through Smarty using {DLSupport}.
For more information regarding how the parameters for the methods are set, refer to the method CreateParameters.
The structure of this protected variable should look like the following:
array(
{The name of the method.} => array(
parameters => {
(array) An array containing the parameters information
for this method. Refer to the $structure parameter of
the method CreateParameters for more information.
},
static => {
(boolean) Whether or not the method is static. Set this
to FALSE if it is an instance method.
}
),
...
)
public static function &MySQLi()
Retrieve an instance of the database class.
(DLDatabase) An instance of DLDatabase.
public static function &NewFormCollection()
Retreive a new form collection.
(DLForm) The DLForm object.
public static function &NewTabCollection( $tab_wrapper = '', $content_wrapper = '' )
Create a new tab collection.
| $tab_wrapper | (string) Optional and defaults to a randomly generated string. The ID of the tab wrapper. |
| $content_wrapper | (string) Optional and defaults to a randomly generated string. The ID of the content wrapper. |
(DLTab) The DLTab object.
| GetAbout | Get about information. |
| GetAuthor | Get the author. |
| GetAuthorEmail | Get the author e-mail address. |
| GetChangeLog | Get the changelog. |
| GetDescription | Get a description of module. |
| GetFriendlyName | Get module friendly name. |
| GetHelp | Get help information. |
| GetName | Get module name. |
| GetParameters | Get parameters. |
| GetVersion | Get version number of module. |
| HasAdmin | Whether or not module has admin panel. |
| InstallPostMessage | Message to be displayed after installation. |
| IsPluginModule | Whether or not this is a plugin module. |
| MinimumCMSVersion | Minimum CMS version to run this module. |
| UninstallPostMessage | Message to be displayed after uninstall. |
| UninstallPreMessage | Message to be alerted before uninstall. |
public static function Captcha( $hours = 2 )
Generate a new captcha image.
| $hours | (int) Optional and defaults to 2. The maximum number of hours the created captcha remains valid. |
(array) The returned array will have its structure similar to the following:
array(
image => {
(string) The HTML to display the captcha image.
},
field => {
(string) The HTML to display the input field.
}
)
public static function CaptchaValidate( $hours = 2 )
See if the user has entered the correct value for the captcha generated by the method Captcha.
| $hours | (int) Optional and defaults to 2. The maximum number of hours the created captcha remains valid. |
(boolean) Returns TRUE if the value is correct, FALSE, otherwise.
public static function GetCleanBreadcrumb( $data, $clean_object )
Retrieve the breadcrumb for a clean admin page.
| $data | (array) An array of pages containing the breadcrumb information. |
| $clean_object | (string) The name of the clean object that will call the <DLSupportJS.CleanAdmin.LinkToJavaScript>. |
The structure of the $data parameter, if given, should look like the following:
array(
array(
url => {
(string) The URL of the page. This can be an empty
string in which case, no link is created.
},
text => {
(string) The title of the page.
}
),
...
)(string) The HTML for the breadcrumb.
public static function GetCleanHeader( $page_title, $header_content = '' )
Retrieve the HTML for the header of the clean admin page.
| $page_title | (string) The title of the page. |
| $header_content | (string) Any content to be put inside of the HEAD tag. |
(string) The HTML for the header.
public static function SetCookie( $key, $value, $days )
Store the given information with the given key in the cookie for the given number of days.
| $key | (string) The key for the cookie. |
| $value | (string) The value of the cookie |
| $days | (int) The number of days in which the cookie should last. |
{DLSupport
method='SetCookie'
key={ Corresponds to the parameter $key. }
value={ Corresponds to the parameter $value. }
days={ Corresponds to the parameter $days. }
}
public static function Decrypt( $key, $data )
Decrypt the given data using the given key.
| $key | (string) The key for decrypting the data. |
| $data | (string) The data to be decrypted. |
Returns (mixed) The data after it has been decrypted.
{DLSupport
method='Decrypt'
key={ Corresponds to the parameter $key. }
data={ Corresponds to the parameter $data. }
}
public static function Encrypt( $key, $data, $algorithm = FALSE )
Encrypt the given data using the given key.
| $key | (string) The key for encrypting the data. |
| $data | (mixed) The data to be encrypted. |
| $algorithm | (mixed) Optional and defaults to FALSE. If given is a string, it should be the algorithm to use. |
(string) The data after it has been encrypted into a string.
{DLSupport
method='Encrypt'
key={ Corresponds to the parameter $key. }
data={ Corresponds to the parameter $data. }
algorithm={ Corresponds to the parameter $algorithm. }
}
public static function ParseCSS( $css, $period = TRUE )
Parse the given CSS to retrieve the class names. Note that this will only return class names, no IDs, tags, etc.
| $css | (string) The CSS to parse. |
| $period | (boolean) Optional and defaults to TRUE. If this is set to FALSE, then the period in front of the class name will be removed. |
(array) An array containing all of the CSS class names in the given class sorted in alphabetical order.
public static function AutoExecute( $table, $parameters, $type, $where = '' )
Create the necessary SQL query and execute the command.
Note that this will use the ADOdb Lite object.
| $table | (string) The name of the table where the query should take place. |
| $parameters | (array) The parameters to be inserted/updated. |
| $type | (string) The type of SQL to create. Possible values are: “INSERT” and “UPDATE”. |
| $where | (string) Optional and defaults to an empty string. If given, this should be the body of the WHERE clause. |
public static function ListDirectories( $path, $options = array() )
Retrieve a list of all direct sub directories of the given directory.
Note that the returned array will not contain the given directory or the parent directory.
| $path | (string) The absolute path to the base directory. |
| $options | (array) An associative array containing various options used by this method. Refer to the method ConvertBytes for more information regarding some of the attributes. Defaults to an empty array. |
The structure of the $options parameter, if given, should look like the following:
array(
bytes => {
(string) Refer to the parameter "$type" from the method
"ConvertBytes" for more information.
},
ignore_hidden => {
(boolean) Whether or not hidden directories should be
ignored. Defaults to TRUE.
},
reverse => {
(boolean) Whether or not the result should be inverted.
Defaults to FALSE.
},
sort => {
(string) The way the result should be sorted. Possible
values are: "name" and "total_space". Defaults to "name".
}
)(array) The returned array will have its structure similar to the following:
array(
Object(
name => {
(string) The name of the directory.
},
path => {
(string) The absolute path to the directory.
}
sub_dirs => {
(array) An array similar to this containing sub
directories of this directory.
},
total_space => {
(int) The size of all the files in directory.
}
),
...
)
public static function ListFiles( $path, $options = array() )
Retrieve a list of all the files in the given directory. Note that this will not include any files in sub directories.
| $path | (string) The absolute path to the base directory. |
| $options | (array) An associative array containing various options used by this method. Refer to the method ConvertBytes for more information regarding some of the attributes. Defaults to an empty array. |
The structure of the $options parameter, if given, should look like the following:
array(
bytes => {
(string) Refer to the parameter "$type" of the method
ConvertBytes for more information.
},
ignore_hidden => {
(boolean) Whether or not hidden directories should be
ignored. Defaults to TRUE.
},
reverse => {
(boolean) Whether or not the result should be inverted.
Defaults to FALSE.
},
sort => {
(string) The way the result should be sorted. Possible
values are: "access_time", "filename", "file_size", and
"modified_time". Defaults to "filename".
}
)(array) The returned array will have its structure similar to the following:
array(
Object(
access_time => {
(int) The time of last access as a UNIX timestamp.
},
filename => {
(string) The filename.
},
file_size => {
(int) The size of the file.
},
modified_time => {
(int) The time of last modification as a UNIX timestamp.
},
full_path => {
(string) The absolute path to the file.
}
),
...
)
public static function ConvertBytes( $bytes, $type )
Convert the given bytes to the specified type.
| $bytes | (numeric) The bytes to be converted. |
| $type | (string) The type to be converted to. This can be any of the following: “b” for bytes (stays the same), “k” for kilobytes, “m” for megabytes, “g” for gigabytes, and “t” for terrabytes. |
(numeric) The given bytes after it has been converted to the specified type.
{DLSupport
method='ConvertBytes'
bytes={ Corresponds to the parameter $bytes. }
type={ Corresponds to the parameter $type. }
}
public static function GetIcon( $size, $icon, $alt = '', $theme = 'aesthetica2' )
Retrieve the HTML for an icon.
| $size | (numeric) This is the dimension of the icon. Note that not all dimensions exist. Be sure to check that the dimension folder you are requesting exist. |
| $icon | (string) The filename of the icon to get without its file extension. Note that not all icons exist. Be sure to check that they exist first. |
| $alt | (string) Optional and defaults to an empty string. The text to be placed in the “alt” attribute of the IMG tag. If it is not given or empty, it will use the $icon value with underscores converted to whitespace and the first letter of each word would be capitalize. |
| $theme | (string) Optional and defaults to “aesthetica2”. The theme of the icon to get. |
(string) The HTML for the IMG tag with approropriate information for displaying the icon.
{DLSupport
method='GetIcon'
size={ Corresponds to the parameter $size. }
icon={ Corresponds to the parameter $icon. }
alt={ Corresponds to the parameter $alt. }
theme={ Corresponds to the parameter $theme. }
}
public static function GetPageInfo( $info )
Retrieve information about the current page.
| $info | (string) The piece of information that is requested. Supported values are: alias, content_id, create_date, menu_text, modified_date, root_path, root_url, template_id, title, uploads_path, and uploads_url. |
(string) The value of the requested information.
{DLSupport
method='GetPageInfo'
info={ Corresponds to the parameter $info. }
}
public static function IncludeJavaScript( $force = FALSE )
Include the JavaScript support file.
This method has been deprecated in favor of using Prototype’s framework but for the sake of backwards compatibility and the lack of flexibility on CMS’s front of a truly flexible framework, this will be kept indefinitely.
| $force | (boolean) Optional and defaults to FALSE. Technically, this should only be outputted once to the screen. For that reason, this will only return the result once. Any other time, it will just return an empty string. However, you can force the return of the output if you set this to TRUE. |
(string) The HTML that will include the neccessary JavaScript.
{DLSupport
method='IncludeJavaScript'
force={ Corresponds to the parameter $force. }
}
public static function IsWord( $word )
Determien whether or not the provided string is a word using our regular pattern. Refer to WordRegex.
| $word | (String) The string to test. |
(boolean) Returns true if the string matches our regular expression of a word, false otherwise.
public static function ModulePath( $module )
Retrieve the absolute path to the given module.
| $module | (string) The unique name of the module. |
(mixed) The absolute path to the module. If the path to the module does not exist, this returns FALSE.
{DLSupport
method='ModulePath'
module={ Corresponds to the parameter $module. }
}
public static function NewFormStart( & $module, $id, $action = 'default', $returnid = '', $method = 'post', $params = array(), $extras = array() )
This is very similar to the method CreateFormStart except that it does not encode the content of the extras array.
| $module | (CMSModule) The module object that is calling this method. |
| $id | (string) The id given to the module on execution. |
| $action | (string) Optional and defaults to “default”. The action that this form should do when it is submitted. |
| $returnid | (string) Optional and defaults to an empty string. The ID to eventually return to when the module is finished with its task. |
| $method | (string) Optional and defaults to “post”. The form method to use. |
| $params | (array) Optional and defaults to an empty array. This should be an associative array containing any extra parameters to be sent as a hidden input field. The key of the array should be the field name and the value of the array should be the value of the input field. |
| $extras | (array) Optional and defaults to an empty array. An array containing any other attributes to be included within the FORM tag. |
(string) The HTML for the start of a form. This will include the FORM tag along hidden INPUT tags if other fields are given.
public static function OutputUploadResponse( $data )
Output the response page for the uploaded of a file.
| $data | (array) An associative array containing any data that should be returned as a JSON so that a function can use it. Defaults to an empty array. |
(string) The HTML for the server response.
public static function SanitizeString( $data, $input = FALSE )
Wrapper method for the function “filter_var” with the filter FILTER_SANITIZE_STRING and the options FILTER_FLAG_ENCODE_LOW and FILTER_FLAG_ENCODE_HIGH.
| $data | (mixed) The data to be filtered. |
| $input | (mixed) Optional and defaults to FALSE. If this is given, it would use this value as the input type and use the function “filter_input” instead of “filter_var”. |
(mixed) The string after the data has been filtered. This will return FALSE if it failed.
public static function UploadFileResponse( $data = array() )
Retrieve the HTML for the response from the server.
| $data | (array) An associative array containing any data that should be returned as a JSON so that a function can use it. Defaults to an empty array. |
(string) The HTML for the server response.
public static function CompareVersions( $module, $version, & $validate_failed )
See if the installed version of the given module is less than the given version.
The checking scheme is: 2 = 2.0.0.0 > 2.0.0.0RC12 > 2.0.0.0RC2 > 1.11.12.34 > 1.2.12.43.
| $module | (string) The name of the module to test. |
| $version | (string) The version to test against. |
| $valide_failed | (boolean) The current result of the validation. If TRUE, then validation has failed, FALSE otherwise. |
(boolean) Returns TRUE if the installed version is less than the given version, FALSE otherwise.
public static function CreateParameters( $structures, $data )
Create the appropriate parameters array to be send to the function call_user_func_array.
| $structures | (array) An associative array containing how the parameters array should be built. |
| $data | (array) An associative array containing the data for the parameters. |
The structure of the $structures parameters, if given, should look like the following:
array(
{The name of the parameter.} => array(
default => {
(mixed) The default value to use for this parameter if
it is optional and wasn't provided by the user. Defaults
to NULL.
},
is_array => {
(boolean) Whether or not this parameter is expected to
be an array. Defaults to FALSE.
},
optional => {
(boolean) Whether or not this parameter is optional.
Defaults to FALSE.
},
string_to_array => {
(boolean) Whether to convert the provided value into an
array where the pipe character, "|", separates each item
and the equal plus greater than symbol, "=>", separates
the item's key and its value. Note that the keys are
optional. If it is not provided, then the array will
just be normally incremented. If this is set to FALSE,
then it is assumed that this parameter will be used to
be an inner array following this same structure.
Defaults to FALSE.
},
sub_elements => {
(array) If "is_array" is TRUE, then this should be
similar to the overlying array. Defaults to an empty
array.
}
),
...
)(array) The parameters array.
public static function ValidateDependency( $module, $version, & $validate_failed )
Determine whether or not the given module name has been installed up to at least the given version.
The checking scheme is: 2.0 > 1.2 > 1.12 > 1.1 > 1.1RC2 > 1.1RC1 > 1.0
Note that this kind of validation checking scheme is not really wide used so this is now considered deprecated.
| $module | (string) The name of the module to test. |
| $version | (string) The minimum version required to pass the test. |
| $validate_failed | (boolean) The current result of the validation. If TRUE, then validation has failed, FALSE otherwise. |
(boolean) Returns TRUE if the validation has failed, FALSE otherwise. Basically, this will have the same value as $validate_failed.
(String) The regex for our “word”.
const WordRegex
(DLSupport) An instance of this class.
private static $instance
(array) An array containing methods that can be called through Smarty using {DLSupport}.
protected static $smarty_methods
Create a new instance of DLSupport.
public function __construct()
Get an instance of the given module unqiue name.
public static function &ModuleInstance( $module )
Retrieve an instance of the database class.
public static function &MySQLi()
Retreive a new form collection.
public static function &NewFormCollection()
Create a new tab collection.
public static function &NewTabCollection( $tab_wrapper = '', $content_wrapper = '' )
This method will return an instance of this class.
public static function &Singleton()
Generate a new captcha image.
public static function Captcha( $hours = 2 )
Remove images created for captcha purposes that is older than the given number of hours.
public static function CaptchaRemove( $hours )
See if the user has entered the correct value for the captcha generated by the method Captcha.
public static function CaptchaValidate( $hours = 2 )
Retrieve the breadcrumb for a clean admin page.
public static function GetCleanBreadcrumb( $data, $clean_object )
Retrieve the HTML for the footer of the clean admin page.
public static function GetCleanFooter()
Retrieve the HTML for the header of the clean admin page.
public static function GetCleanHeader( $page_title, $header_content = '' )
Remove the given cookie.
public static function RemoveCookie( $key )
Store the given information with the given key in the cookie for the given number of days.
public static function SetCookie( $key, $value, $days )
Decrypt the given data using the given key.
public static function Decrypt( $key, $data )
Encrypt the given data using the given key.
public static function Encrypt( $key, $data, $algorithm = FALSE )
Get all of the CSS that is attached to the given template.
public static function GetCSSFromTemplate( $template_id )
Parse the given CSS to retrieve the class names.
public static function ParseCSS( $css, $period = TRUE )
Create the necessary SQL query and execute the command.
public static function AutoExecute( $table, $parameters, $type, $where = '' )
Retrieve a list of all direct sub directories of the given directory.
public static function ListDirectories( $path, $options = array() )
Retrieve a list of all the files in the given directory.
public static function ListFiles( $path, $options = array() )
Clear all the currently opened output buffer then terminate execution with the given message.
public static function CleanExit( $message )
Convert the given bytes to the specified type.
public static function ConvertBytes( $bytes, $type )
Execute the given list of commands.
public static function ExecuteCommand( $dir, $commands )
Retrieve the HTML for an icon.
public static function GetIcon( $size, $icon, $alt = '', $theme = 'aesthetica2' )
Retrieve information about the current page.
public static function GetPageInfo( $info )
Include the JavaScript support file.
public static function IncludeJavaScript( $force = FALSE )
Determien whether or not the provided string is a word using our regular pattern.
public static function IsWord( $word )
Terminate the execution of the script but outputting the given array as a JSON.
public static function JSON( $data )
Retrieve the absolute path to the given module.
public static function ModulePath( $module )
Retrieve the absolute url to the given module.
public static function ModuleURL( $module )
This is very similar to the method CreateFormStart except that it does not encode the content of the extras array.
public static function NewFormStart( & $module, $id, $action = 'default', $returnid = '', $method = 'post', $params = array(), $extras = array() )
Output the response page for the uploaded of a file.
public static function OutputUploadResponse( $data )
Retrieve the HTML for including Prototype, script.aculo.us from Google as well as the supporting JS frameworking.
public static function Protoaculous()
Wrapper method for the function “filter_var” with the filter FILTER_SANITIZE_STRING and the options FILTER_FLAG_ENCODE_LOW and FILTER_FLAG_ENCODE_HIGH.
public static function SanitizeString( $data, $input = FALSE )
Retrieve the HTML for the response from the server.
public static function UploadFileResponse( $data = array() )
Output the upload response page.
public static function UploadPageResponse( $data )
See if the installed version of the given module is less than the given version.
public static function CompareVersions( $module, $version, & $validate_failed )
Create the appropriate parameters array to be send to the function call_user_func_array.
public static function CreateParameters( $structures, $data )
(array) An array contain various data.
private $DLSupport_data
Determine whether or not the given module name has been installed up to at least the given version.
public static function ValidateDependency( $module, $version, & $validate_failed )
Process the server response.
ServerResponse: function( transport )