Web Gear is a free, lightweight open source web development platform written in PHP, aimed at developing fast web applications, based on a well defined MVC structure.

Helpers

Predefined helpers

There are some helpers that we included in the base distribution to provide you with a starting point. They are described below.

Links Helper

This helper assists you in building links for your website. Of course, for more complex links, you might need additional methods. The point is, by using helpers, you only need to make a change in only one place, and it will be reflected in the whole application/website.

boolean Links_Helper->isHomepage()

Returns true if the page you are viewing is the homepage (that means if the controller name is Default, and the action is Index), false otherwise.

string Links_Helper->buildURL([string controller_name = 'Default'[, string controller_action = 'Index'[, array uriParts = array()[, string queryString = ''[, int type = 0]]]]])

Parameters

  • controller_name: The controller name
  • controller_action: The controller action
  • uriParts: The parts of the URI to be appended to the URL (action parameters in the form of param_name => param_value)
  • queryString: The query string to append to the URL
  • type: The type of the URL (0 - website, 1 - admin panel)

Returns the string representation of the target URL.

Template Helper

void Template_Helper->addStylesheet(string src[, string rel = 'stylesheet'[, string media = 'screen'[, array extra = array()]]])

Stores a stylesheet to the internal stylesheet collection for later parsing.

Parameters

  • src: The URL to the stylesheet
  • rel: The relationship type with the document
  • media: The type of media this stylesheet should be loaded for
  • extra: Any number of extra parameters to be added to the link element (a key => value mapping)
void Template_Helper->addScript(string src[, array extra = array()])

Stores a javascript external script file pointer to the internal scripts collection for later parsing.

Parameters

  • src: The URL to the script file
  • extra: Any number of extra parameters to be added to the link element (a key => value mapping). By default, only the type attribute is automatically added, having a value of text/javascript.
string Template_Helper->loadStylesheets()

Parses the internal collection of stylesheets and returns the HTML output for it.

string Template_Helper->loadJavascripts()

Parses the internal collection of javascript scripts and returns the HTML output for it.