aboutsummaryrefslogtreecommitdiff
path: root/engine/lib/actions.php
diff options
context:
space:
mode:
Diffstat (limited to 'engine/lib/actions.php')
-rw-r--r--engine/lib/actions.php30
1 files changed, 15 insertions, 15 deletions
diff --git a/engine/lib/actions.php b/engine/lib/actions.php
index bcd7e759e..35f9dc4b3 100644
--- a/engine/lib/actions.php
+++ b/engine/lib/actions.php
@@ -100,7 +100,7 @@ function action($action, $forwarder = "") {
// @todo make this better!
if ($event_result) {
if (!include($CONFIG->actions[$action]['file'])) {
- register_error(sprintf(elgg_echo('actionnotfound'), $action));
+ register_error(elgg_echo('actionnotfound', array($action)));
}
}
} else {
@@ -110,7 +110,7 @@ function action($action, $forwarder = "") {
register_error(elgg_echo('actionunauthorized'));
}
} else {
- register_error(sprintf(elgg_echo('actionundefined'), $action));
+ register_error(elgg_echo('actionundefined', array($action)));
}
forward($forwarder);
@@ -359,26 +359,26 @@ function elgg_action_exist($action) {
function actions_init()
{
register_action('security/refreshtoken', TRUE);
-
+
elgg_view_register_simplecache('js/languages/en');
-
+
register_plugin_hook('action', 'all', 'ajax_action_hook');
register_plugin_hook('forward', 'all', 'ajax_forward_hook');
}
/**
* Checks whether the request was requested via ajax
- *
+ *
* @return bool whether page was requested via ajax
*/
function elgg_is_xhr() {
- return isset($_SERVER['HTTP_X_REQUESTED_WITH'])
- && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest';
+ return isset($_SERVER['HTTP_X_REQUESTED_WITH'])
+ && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest';
}
/**
* Catch calls to forward() in ajax request and force an exit.
- *
+ *
* Forces response is json of the following form:
* <pre>
* {
@@ -392,18 +392,18 @@ function elgg_is_xhr() {
* }
* </pre>
* where "system_messages" is all message registers at the point of forwarding
- *
+ *
* @param string $hook
- * @param string $type
+ * @param string $type
* @param string $reason
* @param array $params
- *
+ *
*/
function ajax_forward_hook($hook, $type, $reason, $params) {
if (elgg_is_xhr()) {
//grab any data echo'd in the action
$output = ob_get_clean();
-
+
//Avoid double-encoding in case data is json
$json = json_decode($output);
if (isset($json)) {
@@ -411,16 +411,16 @@ function ajax_forward_hook($hook, $type, $reason, $params) {
} else {
$params['output'] = $output;
}
-
+
//Grab any system messages so we can inject them via ajax too
$params['system_messages'] = system_messages(NULL, "");
-
+
if (isset($params['system_messages']['errors'])) {
$params['status'] = -1;
} else {
$params['status'] = 0;
}
-
+
header("Content-type: application/json");
echo json_encode($params);
exit;