diff --git a/src/messenger/webim/libs/common/response.php b/src/messenger/webim/libs/common/response.php index e77917e2..a9c03a90 100644 --- a/src/messenger/webim/libs/common/response.php +++ b/src/messenger/webim/libs/common/response.php @@ -239,4 +239,30 @@ function add_params($servlet, $params) return $servlet; } +/** + * Builds JSONP response to the Mibew widget + * + * @param array $response Response data. It can contain following items: + * - 'load': associative array, specify files which must be loaded. Array keys + * are file aliases and values are URLs. One can use file alias to specify + * dependences (described below). + * - 'handlers': array, handlers which must be called (described below). + * - 'dependences': array, specify dependences between handlers and loaded + * files. Array keys are handlers names and values are arrays of file aliases + * from load item. Handler function will call only after all specified files + * loaded. + * - 'data': associative array, arbitrary structure which will be passed to all + * functions, specified in 'handlers' item. + * @return string JSONP response that ready to send to the widget + */ +function build_widget_response($response) { + $result = $response + array( + 'load' => array(), + 'handlers' => array(), + 'dependences' => array(), + 'data' => array() + ); + return "mibewOnResponse(" . json_encode($result) . ");"; +} + ?> \ No newline at end of file diff --git a/src/messenger/webim/libs/request.php b/src/messenger/webim/libs/request.php deleted file mode 100644 index af8d582b..00000000 --- a/src/messenger/webim/libs/request.php +++ /dev/null @@ -1,27 +0,0 @@ - (isset($response['load'])?$response['load']:array()), - 'handlers' => (isset($response['handlers'])?$response['handlers']:array()), - 'dependences' => (isset($response['dependences'])?$response['dependences']:array()), - 'data' => (isset($response['data'])?$response['data']:array())); - return "mibewOnResponse(" . json_encode($result) . ");"; -} - -?> \ No newline at end of file diff --git a/src/messenger/webim/request.php b/src/messenger/webim/request.php index 2338ba58..be3c4907 100644 --- a/src/messenger/webim/request.php +++ b/src/messenger/webim/request.php @@ -19,7 +19,6 @@ require_once('libs/init.php'); require_once('libs/invitation.php'); require_once('libs/operator.php'); require_once('libs/track.php'); -require_once('libs/request.php'); $invited = FALSE; $operator = array(); @@ -81,7 +80,7 @@ if ($invited !== FALSE) { } start_js_output(); -echo build_js_response($response); +echo build_widget_response($response); exit; ?> \ No newline at end of file