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:
-
$classNameString
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=2Integer
call
-
$callback -
$params=array()
A replacement for call_user_func_array that implements some conveniences.
Parameters:
-
$callbackCallable -
$params=array()Array
Returns:
Returns whatever the function returned.
canHandle
-
$handler_name -
$skip_include=false
Tests whether a particular handler exists
Parameters:
-
$handler_nameStringThe name of the handler. The handler can be overridden via the include path, but an exception is thrown if it is missing.
-
$skip_include=falseBooleanDefaults 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:
-
$aString -
$bString
Returns:
do_dump
-
$var -
$var_name=null -
$indent=null -
$reference=null -
$as_text=false
Parameters:
-
$var&mixed -
$var_name=nullString -
$indent=nullString -
$reference=nullString -
$as_text=falseBoolean
dump_table
-
$rows
Dumps as a table
Parameters:
-
$rowsArray
errorHandler
-
$errno -
$errstr -
$errfile -
$errline -
$errcontext
Error handler
Parameters:
-
$errnoInteger -
$errstrString -
$errfileString -
$errlineInteger -
$errcontextArray
evalExpression
-
$expression -
$params=array()
Evaluates a string containing an expression, with possible references to parameters. CAUTION: make sure the expression is safe!!
Parameters:
-
$expressionStringThe 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:
-
$eventNameStringThe name of the event
-
$params=array()ArrayParameters to pass to the event
-
$pure=falseBooleanDefaults 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=falseBooleanDefaults to false. If true, no new files are loaded. Only handlers which have already been defined as functions are run.
-
$result=nullReferenceDefaults 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=nullStringOptional. 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:
-
$exceptionException
handle
-
$handler_name -
$params=array() -
$skip_include=false -
$result=null
Executes a particular handler
Parameters:
-
$handler_nameStringThe 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=falseBooleanDefaults 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=nullMixedThe 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:
-
$filenameStringThe filename to include
-
$params=array()ArrayOptional. Extracts this array before including the file.
-
$once=falseBooleanOptional. Whether to use include_once instead of include.
-
$get_vars=falseBooleanOptional. 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:
-
$expressionStringThe 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:
-
$messageMixedthe message to append. Usually a string.
-
$key=nullStringThe name of log file. Defaults to "$app_name.log"
-
$timestamp=trueBoolwhether to prepend the current timestamp
-
$optionsArray-
[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:
-
$sinceEpochBooleanDefaults 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:
-
$searchStringthe first parameter to pass to str_replace
-
$replaceStringthe first parameter to pass to str_replace
-
$sourceArraythe 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:
-
$strString -
$arrReferencereference 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:
-
$filenameStringThe name of the file to get the content of
-
$optionsArray-
[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:
-
$filenameStringName of the file to look for
-
$ignoreCache=falseBooleanDefaults 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:
-
$textString | ArrayThe string or array of strings to check
-
$prefixString
Returns:
t
-
$text
Use for surrounding text, so it can later be processed throughout.
Parameters:
-
$textString
Returns:
take
-
$source -
$fields -
&$dest
Parameters:
-
$sourceArray | ObjectAn array or object from which to take things.
-
$fieldsArrayAn array of fields to take or an associative array of fieldname => default pairs
-
&$destArray | 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:
-
$patternString
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:
-
$expressionStringSame as in Q::interpolate()
-
$paramsArraySame 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:
-
$nameStringThe 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:
-
$varMixedthe variable to dump
-
$max_levels=nullIntegerthe maximum number of levels to recurse
-
$label='$'Stringoptional - label of the dumped variable. Defaults to $.
-
$return_content=nullBooleanif 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:
-
$viewNameStringThe full name of the view
-
$params=array()ArrayParameters to pass to the view
-
$optionsArraySome options
-
languageString | 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:
-
$optionsArrayThe options passed to the tool
Q/autoload
After
Event Payload:
-
classNameString -
filenameString
Q/autoload
Before
Event Payload:
-
$classNameString
Q/error
Event Payload:
-
errnoInteger -
errstrString -
errfileString -
errlineInteger -
errcontextArray
Q/exception
Event Payload:
-
exceptionException
Q/exception
Event Payload:
-
$exceptionException
Q/exception/native
Event Payload:
-
$exceptionException
Q/includeFile
Before
Skips includes to prevent recursion
Event Payload:
-
filenameStringThe filename to include
-
paramsArrayOptional. Extracts this array before including the file.
-
onceBooleanOptional. Whether to use include_once instead of include.
-
get_varsBooleanOptional. Set to true to return result of get_defined_vars() at the end.
Q/missingTool
Renders the 'Missing Tool' content
Event Payload:
-
nameArrayThe name of the tool
Q/missingView
Renders 'Missing View' page
Event Payload:
-
viewNameString -
viewpathString
Q/readFile
Before
Skips includes to prevent recursion
Event Payload:
-
$filenameStringThe name of the file to get the content of
-
$optionsArray-
durationIntegerNumber of seconds to cache it for
-
dontCacheBooleanwhether to skip caching it
-
ignoreCacheBooleanwhether to ignore already cached result
-
Q/realPath
After
Event Payload:
-
$resultString
Q/t
Before
Q/tool/render
Before
Event Payload:
-
infoStringAn array of $toolName => $options pairs
-
extraArrayOptions 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:
-
infoStringAn 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:
-
viewNameString -
viewPathString -
paramsString