Q Class
Core Qbix platform functionality
Item Index
Methods
- autoload static
- b static
- backtrace static
- call static
- canHandle static
- compareVersion static
- do_dump static
- dump_table static
- errorHandler
- evalExpression static
- event static
- eventStack static
- exceptionHandler
- handle static
- ifset
- includeFile static
- interpolate static
- log static
- milliseconds
- parse_str static
- parse_str static
- readFile static
- realPath static
- reverseLengthCompare
- startsWith static
- t static
- take
- test
- text static
- textMode static
- tool static
- var_dump static
- var_export static
- view static
Properties
- $bootstrapped static
- $cache static
- $controller static
- $event_empty static
- $event_stack static
- $event_stack_length static
- $included_files static
- $state static
- $toolName static
- $toolWasRendered static
- $var_dump_max_levels static
Methods
autoload
-
$className
Default autoloader for Q
Parameters:
-
$className
String
b
-
$separator=", <br>\n"
Backtrace as html
Parameters:
-
$separator=", <br>\n"
String
Returns:
backtrace
-
$pattern='$class::$function (from line $line)'
-
$skip=2
Return backtrace
Parameters:
-
$pattern='$class::$function (from line $line)'
String -
$skip=2
Integer
call
-
$callback
-
$params=array()
A replacement for call_user_func_array that implements some conveniences.
Parameters:
-
$callback
Callable -
$params=array()
Array
Returns:
Returns whatever the function returned.
canHandle
-
$handler_name
-
$skip_include=false
Tests whether a particular handler exists
Parameters:
-
$handler_name
StringThe name of the handler. The handler can be overridden via the include path, but an exception is thrown if it is missing.
-
$skip_include=false
BooleanDefaults to false. If true, no file is loaded; the handler is executed only if the function is already defined; otherwise, null is returned.
Returns:
Whether the handler exists
compareVersion
-
$a
-
$b
Compares version strings in the format A.B.C...
Parameters:
-
$a
String -
$b
String
Returns:
do_dump
-
$var
-
$var_name=null
-
$indent=null
-
$reference=null
-
$as_text=false
Parameters:
-
$var
&mixed -
$var_name=null
String -
$indent=null
String -
$reference=null
String -
$as_text=false
Boolean
dump_table
-
$rows
Dumps as a table
Parameters:
-
$rows
Array
errorHandler
-
$errno
-
$errstr
-
$errfile
-
$errline
-
$errcontext
Error handler
Parameters:
-
$errno
Integer -
$errstr
String -
$errfile
String -
$errline
Integer -
$errcontext
Array
evalExpression
-
$expression
-
$params=array()
Evaluates a string containing an expression, with possible references to parameters. CAUTION: make sure the expression is safe!!
Parameters:
-
$expression
StringThe code to eval.
-
$params=array()
ArrayOptional. An array of parameters to the expression. Variable names in the expression can refer to them.
Returns:
The result of the expression
event
-
$eventName
-
$params=array()
-
$pure=false
-
$skipIncludes=false
-
$result=null
Fires a particular event. Might result in several handlers being called.
Parameters:
-
$eventName
StringThe name of the event
-
$params=array()
ArrayParameters to pass to the event
-
$pure=false
BooleanDefaults to false. If true, the handler of the same name is not invoked. Put true here if you just want to fire a pure event, without any default behavior. If 'before', only runs the "before" handlers, if any. If 'after', only runs the "after" handlers, if any. You'd want to signal events with 'before' and 'after' before and after some "default behavior" happens. Check for a non-null return value on "before", and cancel the default behavior if it is present.
-
$skipIncludes=false
BooleanDefaults to false. If true, no new files are loaded. Only handlers which have already been defined as functions are run.
-
$result=null
ReferenceDefaults to null. You can pass here a reference to a variable. It will be returned by this function when event handling has finished, or has been aborted by an event handler. It is passed to all the event handlers, which can modify it.
Returns:
Whatever the default event handler returned, or the final value of $result if it is modified by any event handlers.
eventStack
-
$eventName=null
Returns stack of events currently being executed.
Parameters:
-
$eventName=null
StringOptional. If supplied, searches event stack for this event name. If found, returns the latest call with this event name. Otherwise, returns false
Returns:
exceptionHandler
-
$exception
Default exception handler for Q
Parameters:
-
$exception
Exception
handle
-
$handler_name
-
$params=array()
-
$skip_include=false
-
$result=null
Executes a particular handler
Parameters:
-
$handler_name
StringThe name of the handler. The handler can be overridden via the include path, but an exception is thrown if it is missing.
-
$params=array()
ArrayParameters to pass to the handler. They may be altered by the handler, if it accepts $params as a reference.
-
$skip_include=false
BooleanDefaults to false. If true, no file is loaded; the handler is executed only if the function is already defined; otherwise, null is returned.
-
$result=null
&mixedOptional. Lets handlers modify return values of events.
Returns:
Whatever the particular handler returned, or null otherwise;
ifset
-
$ref
-
$def=null
Used for shorthand for avoiding when you don't want to write (isset($some_long_expression) ? $some_long_expression: null) when you want to avoid possible "undefined variable" errors.
Parameters:
-
$ref
&mixedThe reference to test. Only lvalues can be passed. If $ref is an array or object, it can be followed by one or more strings or numbers, which will be used to index deeper into the contained arrays or objects. You can also pass arrays instead of the strings and numbers, which will then widen the search to try all combinations of the strings and numbers in all the arrays, before returning the default.
-
$def=null
MixedThe default, if the reference isn't set
Returns:
includeFile
-
$filename
-
$params=array()
-
$once=false
-
$get_vars=false
Includes a file and evaluates code from it. Uses Q::realPath().
Parameters:
-
$filename
StringThe filename to include
-
$params=array()
ArrayOptional. Extracts this array before including the file.
-
$once=false
BooleanOptional. Whether to use include_once instead of include.
-
$get_vars=false
BooleanOptional. If true, returns the result of get_defined_vars() at the end. Otherwise, returns whatever the file returned.
Returns:
Depends on $get_vars
interpolate
-
$expression
-
$params=array()
Goes through the params and replaces any references to their names in the string with their value. References are expected to be of the form {{varname}} or $varname. However, dollar signs prefixed with backslashes will not be replaced.
Parameters:
-
$expression
StringThe string containing possible references to interpolate values for.
-
$params=array()
Array | StringAn array of parameters to the expression. Variable names in the expression can refer to them. You can also pass an indexed array, in which case the expression's placeholders of the form {{0}}, {{1}}, or $0, $1 will be replaced by the corresponding strings. If the expression is missing {{0}} and $0, then {{1}} or $1 is replaced by the first string, {{2}} or $2 by the second string, and so on.
Returns:
The result of the interpolation
log
-
$message
-
$key=null
-
$timestamp=true
-
$options
Append a message to the main log
Parameters:
-
$message
Mixedthe message to append. Usually a string.
-
$key=null
StringThe name of log file. Defaults to "$app_name.log"
-
$timestamp=true
Boolwhether to prepend the current timestamp
-
$options
Array-
[maxLength=ini_get('log_errors_max_len')]
Integer optional -
[maxDepth=3]
Integer optional
-
milliseconds
-
$sinceEpoch
Returns the number of milliseconds since the first call to this function (i.e. since script started).
Parameters:
-
$sinceEpoch
BooleanDefaults to false. If true, just returns the number of milliseconds in the UNIX timestamp.
Returns:
The number of milliseconds, with fractional part
parse_str
-
$search
-
$replace
-
$source
Replaces strings in all keys and values of an array, and nested arrays
Parameters:
-
$search
Stringthe first parameter to pass to str_replace
-
$replace
Stringthe first parameter to pass to str_replace
-
$source
Arraythe array in which the values are found
Returns:
the resulting array
parse_str
-
$str
-
$arr
Parses a querystring like mb_parse_str but without converting some characters to underscores like PHP's version does
Parameters:
-
$str
String -
$arr
Referencereference to an array to fill, just like in parse_str
Returns:
the resulting array of $field => $value pairs
readFile
-
$filename
-
$options
Reads a file and caches it for a time period. Uses Q::realPath().
Parameters:
-
$filename
StringThe name of the file to get the content of
-
$options
Array-
[duration=0]
Integer optionalNumber of seconds to cache it for
-
[dontCache=false]
Boolean optionalwhether to skip caching it
-
[ignoreCache=false]
Boolean optionalwhether to ignore already cached result
-
Returns:
the content of the file
realPath
-
$filename
-
$ignoreCache=false
Check if a file exists in the include path And if it does, return the absolute path.
Parameters:
-
$filename
StringName of the file to look for
-
$ignoreCache=false
BooleanDefaults to false. If true, then this function ignores the cached value, if any, and attempts to search for the file. It will cache the new value.
Returns:
The absolute path if file exists, false if it does not
reverseLengthCompare
()
Integer
private
Returns:
startsWith
-
$text
-
$prefix
Test whether $text is prefixed by $prefix
Parameters:
-
$text
String | ArrayThe string or array of strings to check
-
$prefix
String
Returns:
t
-
$text
Use for surrounding text, so it can later be processed throughout.
Parameters:
-
$text
String
Returns:
take
-
$source
-
$fields
-
&$dest
Parameters:
-
$source
Array | ObjectAn array or object from which to take things.
-
$fields
ArrayAn array of fields to take or an associative array of fieldname => default pairs
-
&$dest
Array | ObjectOptional reference to an array or object in which we will set values. Otherwise an empty array is used.
Returns:
The $dest array or object, otherwise an array that has been filled with values.
test
-
$pattern
Parameters:
-
$pattern
String
text
-
$expression
-
$params
-
[$convert=array()]
-
[$unconvert=array()]
A convenience method to use in your PHP templates. It is short for Q_Html::text(Q::interpolate($expression, ...)). In Handlebars templates, you just use {{interpolate expression ...}}
Parameters:
-
$expression
StringSame as in Q::interpolate()
-
$params
ArraySame as in Q::interpolate()
-
[$convert=array()]
String optionalSame as in Q_Html::text().
-
[$unconvert=array()]
String optionalSame as in Q_Html::text().
textMode
()
Boolean
static
Check if Qbix is ran as script
Returns:
tool
-
$name
-
$options=array()
-
[$extra=array()]
Instantiates a particular tool. Also generates javascript around it.
Parameters:
-
$name
StringThe name of the tool, of the form "$moduleName/$toolName" The handler is found in handlers/$moduleName/tool/$toolName Also can be an array of $toolName => $toolOptions, in which case the following parameter, $options, is skipped.
-
$options=array()
ArrayThe options passed to the tool (or array of options arrays passed to the tools).
-
[$extra=array()]
Array optionalOptions used by Qbix when rendering the tool.
-
[id]
String optionalAn additional ID to distinguish tools instantiated side-by-side from each other, within the same parent HTMLElement.
-
[prefix]
String optionalSet a custom prefix for the tool's id
-
[cache=false]
Boolean optionalIf true, then the Qbix front end will not replace existing tools with same id during Q.loadUrl when this tool appears in the rendered HTML
-
[merge=false]
Boolean optionalIf true, the element for this tool is merged with the element of the tool already being rendered (if any), producing one element with markup for both tools and their options. This can be used more than once, merging multiple tools in one element. As part of the mege, the content this tool (if any) is prepended to the content of the tool which is already being rendered.
-
var_dump
-
$var
-
$max_levels=null
-
$label='$'
-
$return_content=null
Dumps a variable. Note: cannot show protected or private members of classes.
Parameters:
-
$var
Mixedthe variable to dump
-
$max_levels=null
Integerthe maximum number of levels to recurse
-
$label='$'
Stringoptional - label of the dumped variable. Defaults to $.
-
$return_content=null
Booleanif true, returns the content instead of dumping it. You can also set to "text" to return text instead of HTML
Returns:
var_export
-
$var
Exports a simple variable into something that looks nice, nothing fancy (for now) Does not preserve order of array keys.
Parameters:
-
$var
&mixedthe variable to export
Returns:
view
-
$viewName
-
$params=array()
-
$options
Renders a particular view
Parameters:
-
$viewName
StringThe full name of the view
-
$params=array()
ArrayParameters to pass to the view
-
$options
ArraySome options
-
language
String | NullPreferred language
-
Returns:
The rendered content of the view
Properties
$bootstrapped
Boolean
static
This is set to true when the bootstrapping process has completed successfully.
$cache
Array
static
$controller
Array
static
$event_empty
Array
protected
static
$event_stack
Array
protected
static
$event_stack_length
Integer
protected
static
$included_files
Array
protected
static
$state
Array
static
$toolName
String
static
$toolWasRendered
Array
static
$var_dump_max_levels
Integer
protected
static
Events
$toolHandler
Renders the tool
Event Payload:
-
$options
ArrayThe options passed to the tool
Q/autoload
After
Event Payload:
-
className
String -
filename
String
Q/autoload
Before
Event Payload:
-
$className
String
Q/error
Event Payload:
-
errno
Integer -
errstr
String -
errfile
String -
errline
Integer -
errcontext
Array
Q/exception
Event Payload:
-
exception
Exception
Q/exception
Event Payload:
-
$exception
Exception
Q/exception/native
Event Payload:
-
$exception
Exception
Q/includeFile
Before
Skips includes to prevent recursion
Event Payload:
-
filename
StringThe filename to include
-
params
ArrayOptional. Extracts this array before including the file.
-
once
BooleanOptional. Whether to use include_once instead of include.
-
get_vars
BooleanOptional. Set to true to return result of get_defined_vars() at the end.
Q/missingTool
Renders the 'Missing Tool' content
Event Payload:
-
name
ArrayThe name of the tool
Q/missingView
Renders 'Missing View' page
Event Payload:
-
viewName
String -
viewpath
String
Q/readFile
Before
Skips includes to prevent recursion
Event Payload:
-
$filename
StringThe name of the file to get the content of
-
$options
Array-
duration
IntegerNumber of seconds to cache it for
-
dontCache
Booleanwhether to skip caching it
-
ignoreCache
Booleanwhether to ignore already cached result
-
Q/realPath
After
Event Payload:
-
$result
String
Q/t
Before
Q/tool/render
Before
Event Payload:
-
info
StringAn array of $toolName => $options pairs
-
extra
ArrayOptions used by Qbix when rendering the tool. Can include:
"id" => an additional ID to distinguish tools instantiated side-by-side from each other. Usually numeric.
"cache" => if true, then the Qbix front end will not replace existing tools with same id during Q.loadUrl when this tool appears in the rendered HTML
Q/tool/render
After
Event Payload:
-
info
StringAn array of $toolName => $options pairs
-
'extra'
ArrayOptions used by Qbix when rendering the tool. Can include:
"id" => an additional ID to distinguish tools instantiated side-by-side from each other. Usually numeric.
"cache" => if true, then the Qbix front end will not replace existing tools with same id during Q.loadUrl when this tool appears in the rendered HTML
Q/view
Before
Event Payload:
-
viewName
String -
viewPath
String -
params
String