Example #1
0
function sendTo()
{
    global $system;
    $args = func_get_args();
    // If this is a dialog box, and it is not 'Save and add Another'
    // then need to return JSON response and exit
    if ((isset($_GET['dialog']) || isset($_POST['dialog'])) && !isset($_GET['saveAnother']) && !isset($_POST['saveAnother'])) {
        $flash = Flash::Instance();
        $flash->save();
        // Close dialog and refresh page or redirect?
        if (isset($_GET['refresh']) || isset($_POST['refresh'])) {
            echo returnJSONResponse(TRUE, array(''));
        } else {
            $link = array('modules' => $args[2], 'controller' => $args[0], 'action' => $args[1], 'other' => $args[3]);
            echo returnJSONResponse(TRUE, array('redirect' => '/?' . setParamsString($link)));
        }
        exit;
    }
    if (isset($_GET['ajax']) || isset($_POST['ajax'])) {
        $args[3]['ajax'] = '';
    }
    if (isset($_GET['dialog']) || isset($_POST['dialog'])) {
        $args[3]['dialog'] = '';
    }
    $redirector = $system->injector->instantiate('Redirection');
    $redirector->Redirect($args);
}
Example #2
0
 protected function returnJSONResponse($status, $extra = array())
 {
     /*
      * header('Content-type: application/json');
      * $response = array();
      * $response['status']=$status;
      * if(is_array($extra) && !empty($extra)) {
      * $response+=$extra;
      * }
      * audit(print_r($this->_data,true).print_r($response,true));
      * return json_encode($response);
      */
     returnJSONResponse($status, $extra);
 }