Horde
in package
Provides the base functionality shared by all Horde applications.
Tags
Table of Contents
Constants
- SSL_ALWAYS = 1
- SSL_AUTO = 2
- SSL_NEVER = 0
- SSL_ONLY_LOGIN = 3
Properties
- $_bufferLevel : int
- The current buffer level.
- $_contentSent : bool
- Has content been sent at the base buffer level?
- $_labels : array<string|int, mixed>
- The labels already used in this page.
- $_noAccessKey : bool
- Are accesskeys supported on this system.
- $_used : array<string|int, mixed>
- The access keys already used in this page.
Methods
- __callStatic() : mixed
- Handle deprecated methods (located in Horde_Deprecated).
- assertDriverConfig() : mixed
- 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() : bool
- Has any content been sent to the browser?
- debug() : mixed
- Debug method. Allows quick shortcut to produce debug output into a temporary file.
- endBuffer() : string
- End buffering output.
- escapeJson() : string
- Do necessary escaping to output JSON.
- externalUrl() : string
- Returns an external link passed through the dereferrer to strip session IDs from the referrer.
- getAccessKey() : string
- Returns an un-used access key from the label given.
- getAccessKeyAndTitle() : string
- Returns the appropriate "accesskey" and "title" attributes for an HTML tag and the given label.
- getCacheUrl() : Horde_Url
- Creates a URL for cached data.
- getDriverConfig() : array<string|int, mixed>
- 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
- Creates a temporary filename for the lifetime of the script, and (optionally) registers it to be deleted at request shutdown.
- highlightAccessKey() : string
- Highlights an access key in a label.
- isConnectionSecure() : bool
- Is the current HTTP connection considered secure?
- label() : 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() : string
- Returns an anchor tag with the relevant parameters
- linkTooltip() : string
- Uses DOM Tooltips to display the 'title' attribute for link() calls.
- log() : mixed
- Shortcut to logging method.
- logMessage() : mixed
- Shortcut to logging method.
- permissionDeniedError() : mixed
- Process a permission denied error, running a user-defined hook if necessary.
- popupJs() : string
- Output the javascript needed to call the popup JS function.
- requireSecureConnection() : mixed
- Throws an exception if not using a secure connection.
- selfUrl() : Horde_Url
- Returns a session-id-ified version of $SCRIPT_NAME resp. $PHP_SELF.
- selfUrlParams() : 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() : Horve_View_Sidebar
- Returns the sidebar for the current application.
- signQueryString() : mixed
- Adds a signature + timestamp to a query string and returns the signed query string.
- signUrl() : string|Horde_Url
- Adds a signature + timestamp to a URL and returns the signed URL.
- startBuffer() : mixed
- Start buffering output.
- stripAccessKey() : string
- Strips an access key from a label.
- url() : Horde_Url
- Returns a session-id-ified version of $uri.
- verifySignedQueryString() : bool
- Verifies a signature and timestamp on a query string.
- verifySignedUrl() : string|bool
- Verifies a signature and timestamp on a URL.
- webServerID() : string
- Returns the Web server being used.
- widget() : string
- Returns an anchor sequence with the relevant parameters for a widget with accesskey and text.
- wrapInlineScript() : string
- Print inline javascript to output buffer after wrapping with necessary javascript tags.
Constants
SSL_ALWAYS
public
mixed
SSL_ALWAYS
= 1
SSL_AUTO
public
mixed
SSL_AUTO
= 2
SSL_NEVER
public
mixed
SSL_NEVER
= 0
SSL_ONLY_LOGIN
public
mixed
SSL_ONLY_LOGIN
= 3
Properties
$_bufferLevel
The current buffer level.
protected
static int
$_bufferLevel
= 0
$_contentSent
Has content been sent at the base buffer level?
protected
static bool
$_contentSent
= \false
$_labels
The labels already used in this page.
protected
static array<string|int, mixed>
$_labels
= array()
$_noAccessKey
Are accesskeys supported on this system.
protected
static bool
$_noAccessKey
$_used
The access keys already used in this page.
protected
static array<string|int, mixed>
$_used
= array()
Methods
__callStatic()
Handle deprecated methods (located in Horde_Deprecated).
public
static __callStatic(mixed $name, mixed $arguments) : mixed
Parameters
- $name : mixed
- $arguments : mixed
assertDriverConfig()
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<string|int, mixed> $params, string $driver, array<string|int, mixed> $fields[, string $name = null ][, string $file = 'conf.php' ][, string $variable = '$conf' ]) : mixed
Parameters
- $params : array<string|int, mixed>
-
The configuration array with all parameters.
- $driver : string
-
The key name (in the configuration array) of the driver.
- $fields : array<string|int, mixed>
-
An array with mandatory parameter names for this driver.
- $name : string = null
-
The clear text name of the driver. If not specified, the application name will be used.
- $file : string = 'conf.php'
-
The configuration file that should contain these settings.
- $variable : string = '$conf'
-
The name of the configuration variable.
Tags
contentSent()
Has any content been sent to the browser?
public
static contentSent() : bool
Return values
bool —True if content has been sent.
debug()
Debug method. Allows quick shortcut to produce debug output into a temporary file.
public
static debug([mixed $event = null ][, string $fname = null ][, bool $backtrace = true ]) : mixed
Parameters
- $event : mixed = null
-
Item to log.
- $fname : string = null
-
Filename to log to. If empty, logs to 'horde_debug.txt' in the PHP temporary directory.
- $backtrace : bool = true
-
Include backtrace information?
endBuffer()
End buffering output.
public
static endBuffer() : string
Return values
string —The buffered output.
escapeJson()
Do necessary escaping to output JSON.
public
static escapeJson(mixed $data[, array<string|int, mixed> $options = array() ]) : string
Parameters
- $data : mixed
-
The data to JSON-ify.
- $options : array<string|int, mixed> = array()
-
Additional options:
- nodelimit: (boolean) Don't add security delimiters? DEFAULT: false
- urlencode: (boolean) URL encode the json string DEFAULT: false
Return values
string —The escaped string.
externalUrl()
Returns an external link passed through the dereferrer to strip session IDs from the referrer.
public
static externalUrl(string $url[, bool $tag = false ]) : string
Parameters
- $url : string
-
The external URL to link to.
- $tag : bool = false
-
If true, a complete tag is returned, only the url otherwise.
Return values
string —The link to the dereferrer script.
getAccessKey()
Returns an un-used access key from the label given.
public
static getAccessKey(string $label[, bool $nocheck = false ][, bool $shutdown = false ]) : string
Parameters
- $label : string
-
The label to choose an access key from.
- $nocheck : bool = false
-
Don't check if the access key already has been used?
- $shutdown : bool = false
-
Is this called as a shutdown function?
Return values
string —A single lower case character access key, or an empty string if no key can be found.
getAccessKeyAndTitle()
Returns the appropriate "accesskey" and "title" attributes for an HTML tag and the given label.
public
static getAccessKeyAndTitle(string $label[, bool $nocheck = false ][, bool $return_array = false ]) : string
Parameters
- $label : string
-
The title of an HTML element
- $nocheck : bool = false
-
Don't check if the access key already has been used?
- $return_array : bool = false
-
Return attributes as a hash?
Return values
string —The title, and if appropriate, the accesskey attributes for the element.
getCacheUrl()
Creates a URL for cached data.
public
static getCacheUrl(string $type[, array<string|int, mixed> $params = array() ]) : Horde_Url
Parameters
- $type : string
-
The cache type ('app', 'css', 'js').
- $params : array<string|int, mixed> = 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 values
Horde_Url —The URL to the cache page.
getDriverConfig()
Returns the driver parameters for the specified backend.
public
static getDriverConfig(mixed $backend[, string $type = 'sql' ]) : array<string|int, mixed>
Parameters
- $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 = 'sql'
-
The type of driver. If null, will not merge with base config.
Return values
array<string|int, mixed> —The connection parameters.
getTempDir()
Determines the location of the system temporary directory. If a specific configuration cannot be found, it defaults to /tmp.
public
static getTempDir() : string
Return values
string —A directory name that can be used for temp files. Returns false if one could not be found.
getTempFile()
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' ][, bool $delete = true ][, string $dir = '' ][, bool $secure = false ][, bool $session_remove = false ]) : string
Parameters
- $prefix : string = 'Horde'
-
Prefix to make the temporary name more recognizable.
- $delete : bool = true
-
Delete the file at the end of the request?
- $dir : string = ''
-
Directory to create the temporary file in.
- $secure : bool = false
-
If deleting file, should we securely delete the file?
- $session_remove : bool = false
-
Delete this file when session is destroyed?
Return values
string —Returns the full path-name to the temporary file or false if a temporary file could not be created.
highlightAccessKey()
Highlights an access key in a label.
public
static highlightAccessKey(string $label, string $accessKey) : string
Parameters
- $label : string
-
The label to highlight the access key in.
- $accessKey : string
-
The access key to highlight.
Return values
string —The HTML version of the label with the access key highlighted.
isConnectionSecure()
Is the current HTTP connection considered secure?
public
static isConnectionSecure() : bool
Tags
Return values
boollabel()
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
Parameters
- $for : string
-
The form field's id attribute.
- $label : string
-
The label text.
- $ak : string = null
-
The access key to use. If null a new access key will be generated.
Return values
string —The html code for the label element.
link()
Returns an anchor tag with the relevant parameters
public
static link([Horde_Url|string $url = '' ][, string $title = '' ][, string $class = '' ][, string $target = '' ][, string $onclick = '' ][, string $title2 = '' ][, string $accesskey = '' ][, array<string|int, mixed> $attributes = array() ][, bool $escape = true ]) : string
Parameters
- $url : Horde_Url|string = ''
-
The full URL to be linked to.
- $title : string = ''
-
The link title/description.
- $class : string = ''
-
The CSS class of the link.
- $target : string = ''
-
The window target to point to.
- $onclick : string = ''
-
JavaScript action for the 'onclick' event.
- $title2 : string = ''
-
The link title (tooltip) (deprecated - just use $title).
- $accesskey : string = ''
-
The access key to use.
- $attributes : array<string|int, mixed> = array()
-
Any other name/value pairs to add to the tag.
- $escape : bool = true
-
Whether to escape special characters in the title attribute.
Return values
string —The full tag.
linkTooltip()
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<string|int, mixed> $attributes = array() ]) : string
Parameters
- $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<string|int, mixed> = array()
-
Any other name/value pairs to add to the <a> tag.
Return values
string —The full tag.
log()
Shortcut to logging method.
public
static log(mixed $event[, mixed $priority = null ][, array<string|int, mixed> $options = array() ]) : mixed
Parameters
- $event : mixed
- $priority : mixed = null
- $options : array<string|int, mixed> = array()
Tags
logMessage()
Shortcut to logging method.
public
static logMessage(mixed $event[, mixed $priority = null ][, array<string|int, mixed> $options = array() ]) : mixed
Use log() instead
Parameters
- $event : mixed
- $priority : mixed = null
- $options : array<string|int, mixed> = array()
Tags
permissionDeniedError()
Process a permission denied error, running a user-defined hook if necessary.
public
static permissionDeniedError(string $app, string $perm[, string $error = null ]) : mixed
Parameters
- $app : string
-
Application name.
- $perm : string
-
Permission name.
- $error : string = null
-
An error message to output via the notification system.
popupJs()
Output the javascript needed to call the popup JS function.
public
static popupJs(string|Horde_Url $url[, array<string|int, mixed> $options = array() ]) : string
Parameters
- $url : string|Horde_Url
-
The page to load.
- $options : array<string|int, mixed> = 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 values
string —The javascript needed to call the popup code.
requireSecureConnection()
Throws an exception if not using a secure connection.
public
static requireSecureConnection() : mixed
Tags
selfUrl()
Returns a session-id-ified version of $SCRIPT_NAME resp. $PHP_SELF.
public
static selfUrl([bool $script_params = false ][, bool $nocache = true ][, bool $full = false ][, bool $force_ssl = false ]) : Horde_Url
Parameters
- $script_params : bool = false
-
Include script parameters like QUERY_STRING and PATH_INFO? (Deprecated: use Horde::selfUrlParams() instead.)
- $nocache : bool = true
-
Include a cache-buster parameter in the URL?
- $full : bool = false
-
Return a full URL?
- $force_ssl : bool = false
-
Ignore $conf['use_ssl'] and force creation of a SSL URL?
Return values
Horde_Url —The requested URL.
selfUrlParams()
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.
public
static selfUrlParams([array<string|int, mixed> $opts = array() ]) : Horde_Url
Parameters
- $opts : array<string|int, mixed> = 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.
Tags
Return values
Horde_Url —The self URL.
sidebar()
Returns the sidebar for the current application.
public
static sidebar([string $app = null ]) : Horve_View_Sidebar
Parameters
- $app : string = null
-
The application to generate the menu for. Defaults to the current app.
Return values
Horve_View_Sidebar —The sidebar.
signQueryString()
Adds a signature + timestamp to a query string and returns the signed query string.
public
static signQueryString(mixed $queryString[, int $now = null ]) : mixed
Parameters
- $queryString : mixed
-
The query string (or Horde_Url object) to sign.
- $now : int = null
-
The timestamp at which to sign. Leave blank for generating signatures; specify when testing.
Return values
mixed —The signed query string (or Horde_Url object).
signUrl()
Adds a signature + timestamp to a URL and returns the signed URL.
public
static signUrl(string|Horde_Url $url[, int $now = null ]) : string|Horde_Url
Parameters
- $url : string|Horde_Url
-
The URL to sign.
- $now : int = null
-
The timestamp at which to sign. Leave blank for generating signatures; specify when testing.
Tags
Return values
string|Horde_Url —The signed URL.
startBuffer()
Start buffering output.
public
static startBuffer() : mixed
stripAccessKey()
Strips an access key from a label.
public
static stripAccessKey(string $label) : string
For multibyte charset strings the access key gets removed completely, otherwise only the underscore gets removed.
Parameters
- $label : string
-
The label containing an access key.
Return values
string —The label with the access key being stripped.
url()
Returns a session-id-ified version of $uri.
public
static url(mixed $uri[, bool $full = false ][, mixed $opts = array() ]) : Horde_Url
If a full URL is requested, all parameter separators get converted to "&", otherwise to "&".
Parameters
- $uri : mixed
-
The URI to be modified (either a string or any object with a __toString() function).
- $full : bool = false
-
Generate a full (http://server/path/) URL.
- $opts : mixed = array()
-
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 values
Horde_Url —The URL with the session id appended (if needed).
verifySignedQueryString()
Verifies a signature and timestamp on a query string.
public
static verifySignedQueryString(string $data[, int $now = null ]) : bool
Parameters
- $data : string
-
The signed query string.
- $now : int = null
-
The current time (can override for testing).
Return values
bool —Whether or not the string was valid.
verifySignedUrl()
Verifies a signature and timestamp on a URL.
public
static verifySignedUrl(string $data[, int $now = null ]) : string|bool
Parameters
- $data : string
-
The signed URL.
- $now : int = null
-
The current time (can override for testing).
Tags
Return values
string|bool —The URL stripped off the signature, of false if not verified.
webServerID()
Returns the Web server being used.
public
static webServerID() : string
PHP string list built from the PHP 'configure' script.
Tags
Return values
string —A web server identification string.
widget()
Returns an anchor sequence with the relevant parameters for a widget with accesskey and text.
public
static widget(array<string|int, mixed> $params) : string
Parameters
- $params : array<string|int, mixed>
-
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 values
string —The full Title sequence.
wrapInlineScript()
Print inline javascript to output buffer after wrapping with necessary javascript tags.
public
static wrapInlineScript(array<string|int, mixed> $script) : string
Parameters
- $script : array<string|int, mixed>
-
The script to output.
Return values
string —The script with the necessary HTML javascript tags appended.