Default functions list - ThomasDC84/Proteus GitHub Wiki

callSubModule

This function is used inside a module to call a submodule, it is generally used if a module must have different behavior if an URL parameter change. It accept one optional parameter that specify the name of the submodule, if not given the name of the submodule is retrieved by the URL path, i.e.: mydomain.com/module/johnny/whatever, johnny will be considered the name of the submodule to load

get_template

This function needs two parameters, the first is the tag used to delimitate the text/html template that you want to manipulate, the second parameter can be either a file or a string containing text or html contents. It will return the string contained between the tags, i.e.:

$string =
<html>
  <head>
    <title>some title</title>
  </head>
  <body>
    <div>
      <!--foo-->  //start tag
        The %{template}% to modify
      <!--/foo--> //end tag
    </div>
  </body>
</html>
$output = get_template('foo', $string);
echo $output;

This will show the following output:

The %{template}% to modify

parse_template

This function will replace any %{tag}% in a string with the correspondenting value. It is similar to the php function str_replace, it takes three parameters:

  1. tags: a string or array containing the tag to replace, it must passed without %{ and }%;
  2. replacements: the contents that will replace the tag;
  3. template: the template containing the tags, it can be either a string or a file;

parse_array2template

Similar to parse_template, the difference is that it accept only two parameters.

  1. An associative array, every key will be replaced with the corresponding value
  2. A file or a string containing text/html contents.

escapeString

It takes a string as parameter and returns an escaped version of it. It can be used to filter queries or any input string.

report

This function creates report that you can read and manage through the module "Report Viewer", you can put text or html contents inside a report, as you wish.

how to use

Use the following code

PROTEUS\reporter::getReport('reportID')->addContents('your message', 0);

where

  • reportID - is an unique identifier for the report, if you call the function two times with the same report ID the contents will be concatenated generating a single report called reportID. If you reexecute the code containing this function, it will result in an overwrite of the report. If you want to avoid this, is it possible to add a date with the php date function, like 'reportID_' . date(DATE_ATOM)
  • 0 - is the error level that you gave to the message
  • your message - any kind of contents you want to report, commonly bug tracking contents
⚠️ **GitHub.com Fallback** ⚠️