tina_mvc/helpers/tina_mvc_functions.php

Show: PublicProtectedPrivateinherited
Table of Contents
General Tina MVC helper functions
Author
Francis Crossen  
Package
Tina-MVC  
Subpackage
Core  

Constants

>VConstant  TINA_MVC_PRIMARY_APP_FOLDER = $primary_app_folder
>VConstant  TINA_MVC_SECONDARY_APP_FOLDER = $secondary_app_folder
>VConstant  TINA_MVC_MULTISITE_BLOG_NAME = $blog_name

Functions

functionapp_folder() : string

Find the path to the application folder

In multisite, this is in tina-mvc/user_apps/multisite/example or tina-mvc/user_apps/default, in non multisite, in tina-mvc/user_apps/default.

This is an internal helper function. You don't generally need to call it.

Returns
TypeDescription
stringthe path to your app folder (no trailing slash)
Details
Uses
\TINA_MVC\tina_mvc_find_plugin_folder()  
functionerror(string $msg = '', boolean $suppress_esc = FALSE) : void

A basic error handler

Tina calls this whenever it encounters an error. Hack/override this to help you debug your applications

Parameters
NameTypeDescription
$msgstring

The error message

$suppress_escboolean

Suppress escaping of the message

functionesc_html_recursive(mixed $data = FALSE) : mixed

Escape a data structure for rendering in a browser

Recurses into arrays and objects

Parameters
NameTypeDescription
$datamixed

An array or object containing data to be escaped

Returns
TypeDescription
mixedThe $escaped $data
Details
Uses
to escape non-XML entities  
functionfind_app_file(string $filename = '', string $tina_mvc_page = '', string $called_from = 'PAGE_FILTER', array $find_app_file_error) : mixed

Searches for a file in the standard Tina MVC application folders

In case of error the locations we looked in are stored in $find_app_file_error for use in an error message later.

Parameters
NameTypeDescription
$filenamestring
$tina_mvc_pagestring

the page the controller is accessed through

$called_fromstring

PAGE_FILTER, WIDGET, SHORTCODE, CALLABLE_CONTROLLER

$find_app_file_errorarray

contains a list of places searched (for use in case of error)

Returns
TypeDescription
mixedFALSE or the full path and filename to the file to be included
functionget_abs_controller_link(string $controller = '', string $link_text = FALSE, string $extra_attribs = '') : string

Makes an HTML link a Tina MVC controller.

Makes links to arbitrary Tina MVC controllers. You should use this function in your widget and shortcode page controllers when there is no active Tina MVC page.

Parameters
NameTypeDescription
$controllerstring

The 'tina-page/controller/method/data' we want to call

$link_textstring

The link text to display in the element (default $controller)

$extra_attribsstring

Attributes to put in the tag. e.g. style or script attributes

Returns
TypeDescription
stringAn <a> element ready for browser output
Details
Uses
\TINA_MVC\get_controller_url()  
functionget_controller_link(string $controller = '', string $link_text = FALSE, string $extra_attribs = '') : string

Gets a HTML link a Tina MVC controller

Uses the current active Tina MVC front end page controller.

Parameters
NameTypeDescription
$controllerstring

The 'controller/action/data' we want to call

$link_textstring

The link text to display in the element (default $controller)

$extra_attribsstring

Attributes to put in the tag. e.g. style or script attributes

Returns
TypeDescription
stringAn <a> element ready for browser output
Details
Uses
\TINA_MVC\get_controller_url()  
functionget_controller_url(string $controller = '', boolean $absolute_controller_path = false) : string

Gets a url to a Tina MVC controller

For example, you want to call 'my-app/my-action' and your controller is accessed through the Tina MVC page 'tina-mvc', this function will return http://example.com/tina-mvc/my-app/my-action. This will fail when used from shortcodes and widgets (because they are not accessed through a Tina MVC page). In that case you can specify the absolute path to your controller by setting $absolute_controller_path to 'true'

This function can be called directly from with your controllers (for example if you want to do a browser header redirect) but is typically used in view files (templates) with get_controller_link() and get_abs_controller_link() functions

Parameters
NameTypeDescription
$controllerstring

The 'controller/action/data' we want to call

$absolute_controller_pathboolean

set to true to prevent pre-pending the current Tina MVC page to the url (for use in shortcodes and widgets). In this case you must specify the Tina MVC page in the contoller path e.g. 'tina-mvc/my-page-controller/some-action'

Returns
TypeDescription
stringan absolute URL to the controller
Details
See
and get_abs_controller_link()  
functionget_get(string $var = NULL) : mixed

Gets a value from $_GET

Parameters
NameTypeDescription
$varstring

The variable name to retrieve

Returns
TypeDescription
mixedThe $_GET var
Details
See
in get_post()  
functionget_getpost(string $var) : mixed

Gets a value from $_GET and if not set look in $_POST

Parameters
NameTypeDescription
$varstring

The variable name to retrieve

Returns
TypeDescription
mixedThe $_GET/$_POST var
Details
See
in tina_mvc_get_post()  
Uses
and tina_mvc_get_Post()  
functionget_mailer_from_address() : string

Gets an email address for use by the Tina MVC mailer function.

Emails are sent from this address

Returns
TypeDescription
string
functionget_multisite_blog_name() : \TINA_MVC\strng

Gets the blog name in a Wordpress Multisite installation

Returns
TypeDescription
\TINA_MVC\strngthe blog name
functionget_post(string $var = NULL) : mixed

Gets a value from $_POST

Wordpress has some funky ways of treating global $_POST and $_GET variables. Look at wp-settings.php (line 624 for v2.9.1):

// If already slashed, strip.
if ( get_magic_quotes_gpc() ) {
$_GET    = stripslashes_deep($_GET   );
$_POST   = stripslashes_deep($_POST  );
$_COOKIE = stripslashes_deep($_COOKIE);
}

// Escape with wpdb.
$_GET    = add_magic_quotes($_GET   );
$_POST   = add_magic_quotes($_POST  );
$_COOKIE = add_magic_quotes($_COOKIE);
$_SERVER = add_magic_quotes($_SERVER);

Tina assumes that you want to deal with unescaped data. If you want to store it in a DB then do your own escaping or use the $wpdb class (recommended)

Parameters
NameTypeDescription
$varstring

Variable name to retrieve

Returns
TypeDescription
mixedThe $_POST var
functionget_tina_mvc_folder_url() : string

Gets the url to the Tina MVC plugin folder

Handy for adding js or css files using wp_enqueue_* functions

Returns
TypeDescription
string
functionget_tina_mvc_setting(string $option_name = '') : mixed

Gets a Tina MVC setting

This is stored in the Wordpress option table as 'tina_mvc_settings'

Parameters
NameTypeDescription
$option_namestring
Returns
TypeDescription
mixeddefault FALSE
functionhelpers_folder() : string

Returns the path to the tina_mvc/helpers folder

Returns
TypeDescription
string
functioninclude_helper(string $h = '') : object

Locates and loads a helper.

Returns an instantiated object.

Parameters
NameTypeDescription
$hstring

the helper to include (for, table, pagination, etc)

Returns
TypeDescription
object
functionlog(string $msg = '') : void

Display a message as a PHP E_USER_NOTICE Error

Handy for quick debugging when you can't use tmpr() or tmprd() but can view your PHP error logs instead

Parameters
NameTypeDescription
$msgstring

The message to log

Details
Uses
\TINA_MVC\trigger_error()  
functionplugin_folder() : string

Returns the path to the main Tina MVC plugin folder

Returns
TypeDescription
string
functionpr(mixed $a = NULL, string $l = 'Variable Dump') : string

Alias to tina_mvc_print_r()

Parameters
NameTypeDescription
$amixed

Stuff to dump to screen...

$lstring

An optional label to output e.g. the variable name...

Returns
TypeDescription
string
Details
See
\TINA_MVC\tina_mvc_print_r  
functionprd(mixed $a = NULL, string $l = 'Variable Dump') : string

Alias to tina_mvc_print_r() and die();

Parameters
NameTypeDescription
$amixed

Stuff to dump to screen...

$lstring

An optional label to output e.g. the variable name...

Returns
TypeDescription
string
Details
See
\TINA_MVC\tina_mvc_print_r  
functiontina_mvc_folder() : string

Returns the path to the tina_mvc folder

Returns
TypeDescription
string
functiontina_mvc_print_r(mixed $arg = NULL, string $label = 'Variable Dump') : string

Wrapper for print_r()

A convenient way of examining variables during development. $arg is passed by reference, so you cannot use a function return. To avoid this limitation use the following construct:

tina_mvc_print_r( ( $_a = some_function() ) )
Parameters
NameTypeDescription
$argmixed

Stuff to dump to screen...

$labelstring

An optional label to output e.g. the variable name...

Returns
TypeDescription
string
Details
See
\TINA_MVC\pr()  
See
\TINA_MVC\prd()  
functionuser_has_capability(array | string $cap_to_check = array()) : \TINA_MVC\bolean

Check if a user has been assigned a capability

Parameters
NameTypeDescription
$cap_to_checkarray | string

a list capabilities to check (array or comma separated string)

Returns
TypeDescription
\TINA_MVC\bolean
functionuser_has_role(array | string $roles_to_check = array()) : \TINA_MVC\bolean

Check if a user has been assigned to a role

This is safe to use when users can have multiple roles

Parameters
NameTypeDescription
$roles_to_checkarray | string

a list roles to check (array or comma separated string)

Returns
TypeDescription
\TINA_MVC\bolean
Documentation was generated by phpDocumentor 2.0.0a12.