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.
Parameters: - $r (string) – The path
- $fn (Function) – 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.
Parameters: - $c (string) – The controller’s class name
- $fn (Function) – 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.
Parameters: - $c (string) – The controller’s class name
- $action (string) – The action
- $fn (Function) – Callback
Example:
gila::action('blog', 'topics', function(){ blog::tagsAction(); });
-
onAction
($c, $action, $fn)¶ (static) Runs after an action and before the display of view file.
Parameters: - $c (string) – The controller’s class name
- $action (string) – The action
- $fn (Function) – Callback
Example:
gila::onAction('blog', 'topics', function(){ view::set('new_variable', 'value'); });
-
before
($c, $action, $fn)¶ (static) Registers a function to run before the function of a specific action.
Parameters: - $c (string) – The controller’s class name
- $action (string) – The action
- $fn (Function) – Callback
Example:
gila::action('blog', 'topics', function(){ blog::tagsAction(); });
-
addLang
($path)¶ (static) Adds language translations from a json file.
Parameters: $path (string) – Path to the folder/prefix of language json files Example:
gila::addLang('mypackages/lang/');
-
addList
($list, $el)¶ (static) Adds en element in a global array.
Parameters: - $list (string) – Name of the list
- $el (mixed) – Value
-
getList
($list)¶ (static) Returns the array of a list.
Parameters: $list (string) – Name of the list
-
widgets
($list)¶ (static) Register new widgets.
Parameters: $list (Array) – Example:
gila::widgets( [‘wdg’=>’my_package/widgets/wdg’] );
-
content
($key, $path)¶ (static) Register new content type.
:param String $key Name of content type :param String $path Path to the table file
Example:
gila::content( 'mytable', 'package_name/content/mytable.php' );
-
contentInit
($key, $init)¶ (static) Make changes on an existing content type.
Parameters: - $key (String) – Name of content type
- $init (Function) – Function to run when initializes the content type object
Example:
gila::contentInit( 'mytable', function(&$table){ // unlist a column from content administration &$table['fields']['column1']['list] = false; } );
-
packages
($list)¶ (static) Returns an array with the active packages names.
(static) Add new elements on administration menu.
Parameters: Array $items (Assoc) – menu items Example:
gila::amenu([ 'item'=>['Item','controller/action','icon'=>'item-icon'] ]);
(static) Add a child element on administration menu.
Parameters: - $key (string) – Index of the parent item.
- $item (Array) –
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.
-
setConfig
($key, $value='')¶ (static) Sets the value of configuration element.
Parameters: - $key (string) – Index of the element.
- $value (*) – The value to set.
-
updateConfigFile
()¶ (static) Updates the config.php 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 path 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
-
mt
($arg)¶ (static) Returns modification times in seconds.
Parameters: $arg (string/Array) – Names of keys. Returns: string/Array Example:
gila::mt('my-table')
-
updateMt
($arg)¶ (static) Updates modification time in seconds. You can use this function from your model classes. The cm controller runs updateMt() for any content type in update action.
Parameters: $arg (string/Array) – Names of keys. Returns: string/Array Example:
gila::updateMt('my-table')
-