Api

Class gila

class gila

Common methods for Gila CMS

controller($c, $file, $name=null)

(static) Register a new controller.

Parameters:
  • $c (String) – Controllers name
  • $file (String) – Controller’s filepath without the php extension
  • $name (String) – Optional. Controller’s class name, $c is used by default

Example: gila::controller('my-ctrl', 'my_package/controllers/ctrl','myctrl');

route($r, $fn)

(static) Registers a function call on a specific path.

:param String $r The path :param Function $fn Callback for the route

Example: gila::route('some.txt', function(){ echo 'Some text.'; });

onController($c, $fn)

(static) Registers a function to run right after the controller class construction.

:param String $c The controller’s class name :param Function $fn Callback

Example: gila::route('blog', function(){ blog::ppp = 24; });

action($c, $action, $fn)

(static) Registers a new action or replaces an existing for a controller.

:param String $c The controller’s class name :param String $action The action :param Function $fn Callback

Example: gila::action('blog', 'topics', function(){ blog::tagsAction(); });

before($c, $action, $fn)

(static) Registers a function to run before the function of a specific action.

:param String $c The controller’s class name :param String $action The action :param Function $fn Callback

Example: gila::action('blog', 'topics', function(){ blog::tagsAction(); });

addLang($path)

(static) Adds language translations from a json file.

:param String $path Path to the folder/prefix of language json files

Example: gila::addLang('mypackages/lang/');

widgets($list)

(static) Register new widgets.

:param Array $list

Example: gila::widgets( [‘wdg’=>’my_package/widgets/wdg’] );

content($key, $path)

(static) Register new widgets.

:param String $key Name of content type :param String $path Path to the table file

Example: gila::content( 'mytable', 'package_name/content/mytable.php' );

packages($list)

(static) Returns the list of active packages.

amenu($key, $item)

(static) Add new elements on administration menu.

:param Array $key Index name :param Array $item

Example: gila::amenu('item', ['Item','controller/action','icon'=>'item-icon']);

amenu_child($key, $item)

(static) Add a child element on administration menu.

Parameters:$key (string) – Index of the parent item.

:param Array $item

Example: gila::amenu_child('item', ['Child Item','controller/action','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) Updates 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 password 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.

setOption($option, $value='')

(static) Sets an option value.

Parameters:
  • $option (string) – Option name.
  • $default (string) – The value to set.
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.
dir($path)

(static) Creates the folder if does not exist and return the path.

Parameters:$path (string) – Folder path.
Returns:string
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

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

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, $prop = '')

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

Parameters:
  • $script (string) – The src attribute from the script.
  • $prop (string) – Optional. A property for 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.
getViewFile($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.
menu($menu='mainmenu', $tpl='tpl/menu.php')

(static) Displays a menu.

Parameters:
  • $menu (string) – Optional. Name of the menu.
  • $tpl (string) – Optional. The view template to generate html.
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.
thumb($area, $prefix, $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.
  • $prefix (string) – The prefix name of the thumbnail.
  • $max (int) – (optional) The maximum width or height of thumbnail in pixels.
thumb_stack($src_array, $file, $max=180)

(static) Returns the path of a stacked image. If image does not exist it will be created on the fly.

Parameters:
  • $src_array (Array) – The images to stack.
  • $file (string) – The name of the stucked image. It must have png extension.
  • $max (int) – (optional) The maximum width or height of thumbnails in pixels.
Returns:

The path to revisioned stucked image and the list of stucked photos.

Example:

$img = ["image1.png","image2.png"]; list($file,$stacked) = view::thumb_stack($img, "tmp/stacked_file.png",80);

$file: tmp/stacked_file.png?12

$stacked[0]: ["src"=>"image1.png","src_width"=>200,"src_height"=>150,"width"=>80,"height"=>60,"type"=>2,"top"=>0],

$stacked[1]: false 2nd image was not stacked