function coffee_result_handler in Coffee 6
Same name and namespace in other branches
- 7 coffee.module \coffee_result_handler()
Handler for Coffee
The coffee_result_handler will process the input, look for matches and returns a json encoded result that is used in the javascript to display the results.
Parameters
string $input: String is used to build the query.
Return value
string JSON encoded output with results based on the input.
1 string reference to 'coffee_result_handler'
- coffee_menu in ./
coffee.module - Implements hook_menu().
File
- ./
coffee.module, line 48 - Coffee primary module file
Code
function coffee_result_handler($input = FALSE) {
if (empty($input)) {
return;
}
// Include the default hooks for Coffee.
module_load_include('inc', 'coffee', 'coffee.hooks');
// Based on the first char Coffee should handle a function callback.
// Or it should handle the basic functionality (redirecting to paths).
$command_trigger = ':';
$result = array();
// Invoke all implementations of hook_coffee_command() on command_trigger.
if (strstr(urldecode($input), $command_trigger)) {
// Execute command, invode hook_coffee.
foreach (module_implements('coffee_command') as $module) {
$op = str_ireplace($command_trigger, '', $input);
$result += (array) module_invoke($module, 'coffee_command', $op);
}
}
else {
// Fire the default implementation of Coffee.
$result = coffee_redirect($input);
}
if (!empty($result)) {
// Return should be in json format so the JavaScript can handle it.
return drupal_json($result);
}
drupal_exit();
}