Api

Core Classes

class gila

Common methods for Gila CMS

controllers($list)

(static) Register new controllers.

Parameters:Array $list (Assoc) – Example: {‘ctrl’=>’my_package/controllers/ctrl’}
widgets($list)

(static) Register new widgets.

Parameters:$list (Array) – Example: {‘wdg’=>’my_package/widgets/wdg’}
amenu($list)

(static) Add new elements on administration menu.

Parameters:$list (Array) – Example: ['Item','controller/action','icon'=>'item-icon']
amenu_child($h, $item)

(static) Add a child element on administration menu item.

Parameters:
  • $h (string) – Index of the parent item.
  • $item (Array) – Example: ['SubItem','controller/action_1','icon'=>'item-icon']
config($key, $value = null)

(static) Sets or gets the value of configuration element.

Parameters:
  • $key (string) – Index of the element.
  • $value (*) – (optional) The value.
Returns:

The value if parameter $value is not sent.

updateConfigFile()

(static) Updats the configuration file.

equal($v1, $v2)

(static) Checks if two values are set and have the same value.

Parameters:
  • $v1 (*) – First value.
  • $v2 (*) – Second value.
Returns:

True or false.

hash($pass)

(static) Generates a hash passwrd from a string.

Parameters:$pass (string) – The string to be hashed.
Returns:Hashed password.
option($option, $default='')

(static) Gets an option value.

Parameters:
  • $option (string) – Option name.
  • $default (string) – (optional) The value to return if there option has not saved value.
Returns:

The option value.

hasPrivilege($pri)

(static) Checks if logged in user has at least one of the required privileges.

Parameters:$pri (string/Array) – The privilege(s) to check.
Returns:True or false.
make_url($c, $action='', $args=[])

(static) Generates a url.

Parameters:
  • $c (string) – The controller.
  • $action (string) – The action.
  • $args (Array) – The parameters in array.
Returns:

The full url to print.

Examples:

$url1 = gila::make_url('blog','post',[1]); returns mysite.com/blog/post/1 $url1 = gila::make_url('blog','',['page1']); returns mysite.com/blog/page1

class event

Registers and fires events (hooks)

listen($event, $handler)

(static) Sets a new function to run when an event is triggered later.

Parameters:
  • $event (string) – The event name.
  • $handler (function) – The function to call.
fire(string $event[, Array $params])

(static) Fires an event and calls all handling functions.

Parameters:
  • $event (string) – The event name.
  • $params (function) – (optional) Parameters to send to handlers.
class view

Have methods that outputs the HTML

function set($param,$value)

(static) Sets a parameter from a controller action that can be used later from a view file.

Parameters:
  • $param (string) – The parameter name.
  • $handler ((any)) – The value.
meta($meta, $value)

(static) Sets a meta value that is printed later from view::head().

Parameters:
  • $meta (string) – The meta name.
  • $value (string) – The value.
stylesheet($href)

(static) Adds a new stylesheet link that is printed later from view::head().

Parameters:$href (string) – The href attribute from the link.
script($script)

(static) Adds a new script to be included in the output HTML.

Parameters:$script (string) – The src attribute from the script.
getThemePath()

(static) Returns the path of the current theme.

head($meta=[])

(static) Prints all the head information in <head> tag.

Parameters:$file (Array) – (optional) Meta values to be printed.
findPath($file, $package = 'core')

(static) Returns the path of a file inside theme or package folder.

Parameters:
  • $file (Array) – The file path.
  • $package (string) – (optional) The package folder where the file is located if is not found in theme folder.
Returns:

False if file is not found.

render($file, $package = 'core')

(static) Prints the view file adding the header.php and footer.php from theme.

Parameters:
  • $file (string) – The file path.
  • $package (string) – (optional) The package folder where the file is located if is not found in theme folder.
renderAdmin($file, $package = 'core')

(static) Prints the view file adding the admin/header.php and admin/footer.php from theme.

Parameters:
  • $file (string) – The file path.
  • $package (string) – (optional) The package folder where the file is located if is not found in theme folder.
renderFile($file, $package = 'core')

(static) Prints the view file alone from theme.

Parameters:
  • $file (string) – The file path.
  • $package (string) – (optional) The package folder where the file is located if is not found in theme folder.
includeFile($file, $package = 'core')

(static) Includes the view file without passing the.

Parameters:
  • $file (string) – The file path.
  • $package (string) – (optional) The package folder where the file is located if is not found in theme folder.
widget_area($area, $div=true)

(static) Prints the widgets of a specific area.

Parameters:
  • $area (string) – The widget area name.
  • $div (bool) – (optional) Also print or not the widget inside a <div> tag with its title.
widget_area($area, $id, $max=180)

(static) Returns the path of a thumbnail image of specified dimensions. If thumbnail does not exist it will create one.

Parameters:
  • $src (string) – The path of original image.
  • $id (string) – The name of the thumbnail.
  • $max (int) – (optional) The maximum width or height of thumbnail in pixels.