static string AssocImplode(
string
$majorglue, string
$minorglue,
$array
)
|
|
A function to implode an associative array preserving keys
This function is an extension of http://www.php.net/implode for use when you want to preserve the keys of the array as well.
Parameters:
|
string |
$majorglue: |
The glue for between the array entries |
|
string |
$minorglue: |
The glue for between key => value pairs |
|
array |
$array: |
The array to implode |
API Tags:
static boolean AutoLoad(
string
$_class
)
|
|
Loads the file for a module or action name
This function attempts to load the file containing the class named by the parameter. It is configured to have success with modules and actions placed in the usual places.
Parameters:
|
string |
$_class: |
The name of the class |
API Tags:
| Return: | The success of the loading |
| Access: | public |
Information Tags:
static string DetermineRequest(
)
|
|
Determines the request to be used from server variables.
This function parses the http://www.php.net/$_SERVER REQUEST_URI variable in order to determine what request was actually made (taking into account the BASEURI set in the configuration file). It is called in Krai::Run() unless an overriding request is passed to that function
API Tags:
| Return: | The actual request to parse. |
| Access: | private |
Ends the application run after cleaning up
This function cleans everything up, including closing logs, commiting the php session, and setting a Content-type if one was not set in the processed request. Additionally, it flushes the output buffer, and exits the program.
API Tags:
static void Error(
string
$message
)
|
|
Save an error message
This function records an error message to the message queue
Parameters:
|
string |
$message: |
Message to save |
API Tags:
static mixed GetConfig(
string
$_key
)
|
|
Gets information from the configuration array Krai::$_CONFIG.
This method retrieves the values set in the configuration file passed to Krai::Setup(). For instance, if the configuration file had the line
# snippet from the config file
BASEURI: myapp
Then you can do the following:
# => myapp
You can only retrieve the first level of information from the configuration file in this manner. To get lower levels, do the following:
# snippet from the config file
CONFIG_CACHE:
DIR: /some/path
TIMEOUT: 3600
# Getting those configuration settings
print $config_cache["DIR"];
# => /some/path
Parameters:
|
string |
$_key: |
The name of the configuration key to get |
API Tags:
| Return: | The value of the key |
| Access: | public |
Information Tags:
| Throws: | Exception When the key is not found |
static array GetErrors(
)
|
|
Returns the logged errors
This function returns the error messages currently in the queue and clears the queue.
API Tags:
| Return: | The error messages |
| Access: | public |
static array GetNotices(
)
|
|
Returns the logged notices
This function returns the notice messages currently in the queue and clears the queue.
API Tags:
| Return: | The notice messages |
| Access: | public |
static boolean IsErrors(
)
|
|
Determine whether there are errors or not
This function determines whether any error messages are in the queue
API Tags:
| Return: | Whether or not there are errors |
| Access: | public |
static boolean IsNotices(
)
|
|
Determine whether there are notices or not
This function determines whether any notice messages are in the queue
API Tags:
| Return: | Whether or not there are notices |
| Access: | public |
static boolean LoadActionFile(
string
$_module, string
$_action
)
|
|
Tries to load the file for an action
This function attempts to load the file containing a certain action.
Parameters:
|
string |
$_module: |
The name of the module of the action |
|
string |
$_action: |
The name of the action |
API Tags:
| Return: | The success of the loading |
| Access: | private |
Information Tags:
static boolean LoadModuleFile(
string
$_module
)
|
|
Tries to load the file for a module
This function attempts to load the file containing a certain module.
Parameters:
|
string |
$_module: |
The name of the module |
API Tags:
| Return: | The success of the loading |
| Access: | private |
Information Tags:
| Throws: | Krai_Router_Exception |
static void Notice(
string
$message
)
|
|
Save a notice message
This function records a notice message to the message queue
Parameters:
|
string |
$message: |
Message to save |
API Tags:
static void ReloadMessages(
)
|
|
Reloads messages from session if available
This function reloads notice and error messages that may have been saved in the php session.
API Tags:
static void Run(
[string
$_uri = null]
)
|
|
Makes everything start up and work
This function starts everything in motion. According to the configuration, it loads and initializes all necessary and sufficient framework components. It initializes database connections, and finally initializes scrubbed versions of input variables.
Parameters:
|
string |
$_uri: |
An override for the usually determined request to process |
API Tags:
Information Tags:
static void SaveMessages(
)
|
|
Saves messages to the session
This function saves notice and error messages to the session for retrieval at the next request execution.
API Tags:
static void SetMime(
string
$type, [boolean
$force = false]
)
|
|
Sets the mime-type header for the response
This function is used to set the Content-type header for a response. It is most often used when the script is outputting an image or JSON. If it is not called by the application on a given request, the Content-type defaults to "text/html" for compatibility. However, some users may want to use "application/xhtml+xml" for strict XHTML compliance.
Parameters:
|
string |
$type: |
The mime-type to set |
|
boolean |
$force: |
Flag to force a reset if the type had previously been set |
API Tags:
static void Setup(
string
$_conf_file
)
|
|
This is the configuration function for the framework.
This function sets up the framework in preparation of being run. It expects a parameter of a string of the location and name of the YAML configuration file. If the application skeleton is being used, this should be "../includes/configs/krai.yml" from the usual default.php location.
The function sets up the Krai::$APPDIR, Krai::$FRAMEWORK, Krai::$INCLUDES, Krai::$MODULES, and Krai::$LAYOUTS variables, as well as starts a PHP session (unless disabled) and an output buffer (unless disabled).
Parameters:
|
string |
$_conf_file: |
The path to the configuration file. |
API Tags:
Information Tags:
A wrapper for including files and logging such. Uses http://www.php.net/func_get_args() for variable argument number.
This function accepts an unlimited number of arguments, each of which should be a string of a file that needs to be included into the application execution. The function uses http://www.php.net/include_once, so it is not suitable for files that need to be included multiple times.
Additionally, the function provides logging for all the includes processed through it, at the Krai::LOG_DEBUG level.
API Tags:
| Return: | Whether or not the file was included successfully |
| Access: | public |
Information Tags:
static void WriteBackLogs(
)
|
|
Writes the back logs to the logger
This function writes the messages stored up in Krai::$_BACKLOGS to the logger. If this is called and the logger is still not initialized, an Exception is thrown.
API Tags:
Information Tags:
static void WriteLog(
string
$message, [integer
$level = Krai::LOG_INFO], [
$logs = array()], [string
$cat = null], [
$forces = array()]
)
|
|
Provides an interface to the loghandler, whatever that might be.
This function is a wrapper for the logger currently in use (namely, Krai_Log). If the logger has been started, it writes to the log right away. Otherwise, it writes to the Krai::$_BACKLOGS array, so the log entries can be written if/when the logger gets initialized.
Parameters:
|
string |
$message: |
The message to write |
|
integer |
$level: |
The level of the message |
|
array |
$logs: |
The identifiers of the logs to which to write (default is the default log) |
|
string |
$cat: |
The category of the log message |
|
array |
$forces: |
I forget... the logger is being rewritten anyhow, so this will probably change... |
API Tags: