PHP Class Horde, horde

Author: Chuck Hagenbuch ([email protected])
Author: Jon Parise ([email protected])
Show file Open project: horde/horde Class Usage Examples

Protected Properties

Property Type Description
$_bufferLevel integer The current buffer level.
$_contentSent boolean Has content been sent at the base buffer level?
$_labels array The labels already used in this page.
$_noAccessKey boolean Are accesskeys supported on this system.
$_used array The access keys already used in this page.

Public Methods

Method Description
__callStatic ( $name, $arguments ) Handle deprecated methods (located in Horde_Deprecated).
assertDriverConfig ( array $params, string $driver, array $fields, string $name = null, string $file = 'conf.php', string $variable = '$conf' ) Checks if all necessary parameters for a driver configuration are set and throws a fatal error with a detailed explanation how to fix this, if something is missing.
contentSent ( ) : boolean Has any content been sent to the browser?
debug ( mixed $event = null, string $fname = null, boolean $backtrace = true ) Debug method. Allows quick shortcut to produce debug output into a temporary file.
endBuffer ( ) : string End buffering output.
escapeJson ( mixed $data, array $options = [] ) : string Do necessary escaping to output JSON.
externalUrl ( string $url, boolean $tag = false ) : string Returns an external link passed through the dereferrer to strip session IDs from the referrer.
getAccessKey ( string $label, boolean $nocheck = false, boolean $shutdown = false ) : string Returns an un-used access key from the label given.
getAccessKeyAndTitle ( string $label, boolean $nocheck = false, boolean $return_array = false ) : string Returns the appropriate "accesskey" and "title" attributes for an HTML tag and the given label.
getCacheUrl ( string $type, array $params = [] ) : Horde_Url Creates a URL for cached data.
getDriverConfig ( mixed $backend, string $type = 'sql' ) : array Returns the driver parameters for the specified backend.
getTempDir ( ) : string Determines the location of the system temporary directory. If a specific configuration cannot be found, it defaults to /tmp.
getTempFile ( string $prefix = 'Horde', boolean $delete = true, string $dir = '', boolean $secure = false, boolean $session_remove = false ) : string Creates a temporary filename for the lifetime of the script, and (optionally) registers it to be deleted at request shutdown.
highlightAccessKey ( string $label, string $accessKey ) : string Highlights an access key in a label.
isConnectionSecure ( ) : boolean Is the current HTTP connection considered secure?
label ( string $for, string $label, string $ak = null ) : string Returns a label element including an access key for usage in conjuction with a form field. User preferences regarding access keys are respected.
link ( Horde_Url | string $url = '', string $title = '', string $class = '', string $target = '', string $onclick = '', string $title2 = '', string $accesskey = '', array $attributes = [], boolean $escape = true ) : string Returns an anchor tag with the relevant parameters
linkTooltip ( string $url, string $status = '', string $class = '', string $target = '', string $onclick = '', string $title = '', string $accesskey = '', array $attributes = [] ) : string Uses DOM Tooltips to display the 'title' attribute for link() calls.
log ( $event, $priority = null, array $options = [] ) Shortcut to logging method.
logMessage ( $event, $priority = null, array $options = [] ) Shortcut to logging method.
permissionDeniedError ( string $app, string $perm, string $error = null ) Process a permission denied error, running a user-defined hook if necessary.
popupJs ( string | Horde_Url $url, array $options = [] ) : string Output the javascript needed to call the popup JS function.
redirect ( string $url ) Utility function to send redirect headers to browser, handling any browser quirks.
requireSecureConnection ( ) Throws an exception if not using a secure connection.
selfUrl ( boolean $script_params = false, boolean $nocache = true, boolean $full = false, boolean $force_ssl = false ) : Horde_Url Returns a session-id-ified version of $SCRIPT_NAME resp. $PHP_SELF.
selfUrlParams ( array $opts = [] ) : Horde_Url Create a self URL of the current page, building the parameter list from the current Horde_Variables object (or via another Variables object passed as an optional argument) rather than the original request data.
sidebar ( string $app = null ) : Horve_View_Sidebar Returns the sidebar for the current application.
signQueryString ( mixed $queryString, integer $now = null ) : mixed Add a signature + timestamp to a query string and return the signed query string.
startBuffer ( ) Start buffering output.
stripAccessKey ( string $label ) : string Strips an access key from a label.
url ( mixed $uri, boolean $full = false, mixed $opts = [] ) : Horde_Url Returns a session-id-ified version of $uri.
verifySignedQueryString ( string $data, integer $now = null ) : boolean Verify a signature and timestamp on a query string.
webServerID ( ) : string Returns the Web server being used.
widget ( array $params ) : string Returns an anchor sequence with the relevant parameters for a widget with accesskey and text.
wrapInlineScript ( array $script ) : string Print inline javascript to output buffer after wrapping with necessary javascript tags.

Method Details

__callStatic() public static method

Handle deprecated methods (located in Horde_Deprecated).
public static __callStatic ( $name, $arguments )

assertDriverConfig() public static method

Checks if all necessary parameters for a driver configuration are set and throws a fatal error with a detailed explanation how to fix this, if something is missing.
public static assertDriverConfig ( array $params, string $driver, array $fields, string $name = null, string $file = 'conf.php', string $variable = '$conf' )
$params array The configuration array with all parameters.
$driver string The key name (in the configuration array) of the driver.
$fields array An array with mandatory parameter names for this driver.
$name string The clear text name of the driver. If not specified, the application name will be used.
$file string The configuration file that should contain these settings.
$variable string The name of the configuration variable.

contentSent() public static method

Has any content been sent to the browser?
public static contentSent ( ) : boolean
return boolean True if content has been sent.

debug() public static method

Debug method. Allows quick shortcut to produce debug output into a temporary file.
public static debug ( mixed $event = null, string $fname = null, boolean $backtrace = true )
$event mixed Item to log.
$fname string Filename to log to. If empty, logs to 'horde_debug.txt' in the PHP temporary directory.
$backtrace boolean Include backtrace information?

endBuffer() public static method

End buffering output.
public static endBuffer ( ) : string
return string The buffered output.

escapeJson() public static method

Do necessary escaping to output JSON.
public static escapeJson ( mixed $data, array $options = [] ) : string
$data mixed The data to JSON-ify.
$options array Additional options: - nodelimit: (boolean) Don't add security delimiters? DEFAULT: false - urlencode: (boolean) URL encode the json string DEFAULT: false
return string The escaped string.

externalUrl() public static method

Returns an external link passed through the dereferrer to strip session IDs from the referrer.
public static externalUrl ( string $url, boolean $tag = false ) : string
$url string The external URL to link to.
$tag boolean If true, a complete tag is returned, only the url otherwise.
return string The link to the dereferrer script.

getAccessKey() public static method

Returns an un-used access key from the label given.
public static getAccessKey ( string $label, boolean $nocheck = false, boolean $shutdown = false ) : string
$label string The label to choose an access key from.
$nocheck boolean Don't check if the access key already has been used?
$shutdown boolean Is this called as a shutdown function?
return string A single lower case character access key, or an empty string if no key can be found.

getAccessKeyAndTitle() public static method

Returns the appropriate "accesskey" and "title" attributes for an HTML tag and the given label.
public static getAccessKeyAndTitle ( string $label, boolean $nocheck = false, boolean $return_array = false ) : string
$label string The title of an HTML element
$nocheck boolean Don't check if the access key already has been used?
$return_array boolean Return attributes as a hash?
return string The title, and if appropriate, the accesskey attributes for the element.

getCacheUrl() public static method

Creates a URL for cached data.
public static getCacheUrl ( string $type, array $params = [] ) : Horde_Url
$type string The cache type ('app', 'css', 'js').
$params array Optional parameters: - app: REQUIRED for $type == 'app'. Identifies the application to call the 'cacheOutput' API call, which is passed in the value of the entire $params array (which may include parameters other than those listed here). The return from cacheOutput should be a 2-element array: 'data' (the cached data) and 'type' (the content-type of the data). - cid: REQUIRED for $type == 'css' || 'js'. The cacheid of the data (stored in Horde_Cache). - nocache: If true, sets the cache limiter to 'nocache' instead of the default 'public'.
return Horde_Url The URL to the cache page.

getDriverConfig() public static method

Returns the driver parameters for the specified backend.
public static getDriverConfig ( mixed $backend, string $type = 'sql' ) : array
$backend mixed The backend system (e.g. 'prefs', 'categories', 'contacts') being used. The used configuration array will be $conf[$backend]. If an array gets passed, it will be $conf[$key1][$key2].
$type string The type of driver. If null, will not merge with base config.
return array The connection parameters.

getTempDir() public static method

Determines the location of the system temporary directory. If a specific configuration cannot be found, it defaults to /tmp.
public static getTempDir ( ) : string
return string A directory name that can be used for temp files. Returns false if one could not be found.

getTempFile() public static method

Creates a temporary filename for the lifetime of the script, and (optionally) registers it to be deleted at request shutdown.
public static getTempFile ( string $prefix = 'Horde', boolean $delete = true, string $dir = '', boolean $secure = false, boolean $session_remove = false ) : string
$prefix string Prefix to make the temporary name more recognizable.
$delete boolean Delete the file at the end of the request?
$dir string Directory to create the temporary file in.
$secure boolean If deleting file, should we securely delete the file?
$session_remove boolean Delete this file when session is destroyed?
return string Returns the full path-name to the temporary file or false if a temporary file could not be created.

highlightAccessKey() public static method

Highlights an access key in a label.
public static highlightAccessKey ( string $label, string $accessKey ) : string
$label string The label to highlight the access key in.
$accessKey string The access key to highlight.
return string The HTML version of the label with the access key highlighted.

isConnectionSecure() public static method

Is the current HTTP connection considered secure?
public static isConnectionSecure ( ) : boolean
return boolean

label() public static method

Returns a label element including an access key for usage in conjuction with a form field. User preferences regarding access keys are respected.
public static label ( string $for, string $label, string $ak = null ) : string
$for string The form field's id attribute.
$label string The label text.
$ak string The access key to use. If null a new access key will be generated.
return string The html code for the label element.

linkTooltip() public static method

Uses DOM Tooltips to display the 'title' attribute for link() calls.
public static linkTooltip ( string $url, string $status = '', string $class = '', string $target = '', string $onclick = '', string $title = '', string $accesskey = '', array $attributes = [] ) : string
$url string The full URL to be linked to
$status string The JavaScript mouse-over string
$class string The CSS class of the link
$target string The window target to point to.
$onclick string JavaScript action for the 'onclick' event.
$title string The link title (tooltip). Most not contain HTML data other than <br>, which will be converted to a linebreak.
$accesskey string The access key to use.
$attributes array Any other name/value pairs to add to the <a> tag.
return string The full tag.

log() public static method

Shortcut to logging method.
See also: Horde_Core_Log_Logger
public static log ( $event, $priority = null, array $options = [] )
$options array

logMessage() public static method

Shortcut to logging method.
See also: log()
Deprecation: Use log() instead
public static logMessage ( $event, $priority = null, array $options = [] )
$options array

permissionDeniedError() public static method

Process a permission denied error, running a user-defined hook if necessary.
public static permissionDeniedError ( string $app, string $perm, string $error = null )
$app string Application name.
$perm string Permission name.
$error string An error message to output via the notification system.

popupJs() public static method

Output the javascript needed to call the popup JS function.
public static popupJs ( string | Horde_Url $url, array $options = [] ) : string
$url string | Horde_Url The page to load.
$options array Additional options: - height: (integer) The height of the popup window. DEFAULT: 650px - menu: (boolean) Show the browser menu in the popup window? DEFAULT: false - onload: (string) A JS function to call after the popup window is fully loaded. DEFAULT: None - params: (array) Additional parameters to pass to the URL. DEFAULT: None - urlencode: (boolean) URL encode the json string? DEFAULT: false - width: (integer) The width of the popup window. DEFAULT: 700 px
return string The javascript needed to call the popup code.

redirect() public static method

Utility function to send redirect headers to browser, handling any browser quirks.
public static redirect ( string $url )
$url string The URL to redirect to.

requireSecureConnection() public static method

Throws an exception if not using a secure connection.
public static requireSecureConnection ( )

selfUrl() public static method

Returns a session-id-ified version of $SCRIPT_NAME resp. $PHP_SELF.
public static selfUrl ( boolean $script_params = false, boolean $nocache = true, boolean $full = false, boolean $force_ssl = false ) : Horde_Url
$script_params boolean Include script parameters like QUERY_STRING and PATH_INFO? (Deprecated: use Horde::selfUrlParams() instead.)
$nocache boolean Include a cache-buster parameter in the URL?
$full boolean Return a full URL?
$force_ssl boolean Ignore $conf['use_ssl'] and force creation of a SSL URL?
return Horde_Url The requested URL.

selfUrlParams() public static method

Create a self URL of the current page, building the parameter list from the current Horde_Variables object (or via another Variables object passed as an optional argument) rather than the original request data.
Since: 2.3.0
public static selfUrlParams ( array $opts = [] ) : Horde_Url
$opts array Additional options: - force_ssl: (boolean) Force creation of an SSL URL? DEFAULT: false - full: (boolean) Return a full URL? DEFAULT: false - nocache: (boolean) Include a cache-buster parameter in the URL? DEFAULT: true - vars: (Horde_Variables) Use this Horde_Variables object instead of the Horde global object. DEFAULT: Use the Horde global object.
return Horde_Url The self URL.

sidebar() public static method

Returns the sidebar for the current application.
public static sidebar ( string $app = null ) : Horve_View_Sidebar
$app string The application to generate the menu for. Defaults to the current app.
return Horve_View_Sidebar The sidebar.

signQueryString() public static method

Add a signature + timestamp to a query string and return the signed query string.
public static signQueryString ( mixed $queryString, integer $now = null ) : mixed
$queryString mixed The query string (or Horde_Url object) to sign.
$now integer The timestamp at which to sign. Leave blank for generating signatures; specify when testing.
return mixed The signed query string (or Horde_Url object).

startBuffer() public static method

Start buffering output.
public static startBuffer ( )

stripAccessKey() public static method

For multibyte charset strings the access key gets removed completely, otherwise only the underscore gets removed.
public static stripAccessKey ( string $label ) : string
$label string The label containing an access key.
return string The label with the access key being stripped.

url() public static method

If a full URL is requested, all parameter separators get converted to "&", otherwise to "&".
public static url ( mixed $uri, boolean $full = false, mixed $opts = [] ) : Horde_Url
$uri mixed The URI to be modified (either a string or any object with a __toString() function).
$full boolean Generate a full (http://server/path/) URL.
$opts mixed Additional options. If a string/integer, it is taken to be the 'append_session' option. If an array, one of the following: - app: (string) Use this app for the webroot. DEFAULT: current application - append_session: (integer) 0 = only if needed [DEFAULT], 1 = always, -1 = never. - force_ssl: (boolean) Ignore $conf['use_ssl'] and force creation of a SSL URL? DEFAULT: false
return Horde_Url The URL with the session id appended (if needed).

verifySignedQueryString() public static method

Verify a signature and timestamp on a query string.
public static verifySignedQueryString ( string $data, integer $now = null ) : boolean
$data string The signed query string.
$now integer The current time (can override for testing).
return boolean Whether or not the string was valid.

webServerID() public static method

PHP string list built from the PHP 'configure' script.
See also: php_sapi_name()
public static webServerID ( ) : string
return string A web server identification string.

widget() public static method

Returns an anchor sequence with the relevant parameters for a widget with accesskey and text.
public static widget ( array $params ) : string
$params array A hash with widget options (other options will be passed as attributes to the link tag): - url: (string) The full URL to be linked to. - title: (string) The link title/description. - nocheck: (boolean, optional) Don't check if the accesskey already already has been used. Defaults to false (= check).
return string The full Title sequence.

wrapInlineScript() public static method

Print inline javascript to output buffer after wrapping with necessary javascript tags.
public static wrapInlineScript ( array $script ) : string
$script array The script to output.
return string The script with the necessary HTML javascript tags appended.

Property Details

$_bufferLevel protected static property

The current buffer level.
protected static int $_bufferLevel
return integer

$_contentSent protected static property

Has content been sent at the base buffer level?
protected static bool $_contentSent
return boolean

$_labels protected static property

The labels already used in this page.
protected static array $_labels
return array

$_noAccessKey protected static property

Are accesskeys supported on this system.
protected static bool $_noAccessKey
return boolean

$_used protected static property

The access keys already used in this page.
protected static array $_used
return array