function coffee_result_handler in Coffee 7
Same name and namespace in other branches
- 6 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 53 - Coffee primary module file
Code
function coffee_result_handler($input = FALSE) {
// Based on the first char coffee should handle a function callback.
// Or it should handle the basic functionality (redirecting to paths).
$command_trigger = ':';
// Invoke all implementations of hook_coffee_command() on command_trigger.
$result = array();
if (strstr(check_plain(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.
print json_encode($result);
}
drupal_exit();
}