예제 #1
0
 /**
  * Sends a JSON response to the browser
  *
  * @return void
  */
 private function _ajaxResponse()
 {
     if (!isset($this->_JSON['message'])) {
         $this->_JSON['message'] = $this->_getDisplay();
     } else {
         if ($this->_JSON['message'] instanceof PMA_Message) {
             $this->_JSON['message'] = $this->_JSON['message']->getDisplay();
         }
     }
     if ($this->_isSuccess) {
         $this->_JSON['success'] = true;
     } else {
         $this->_JSON['success'] = false;
         $this->_JSON['error'] = $this->_JSON['message'];
         unset($this->_JSON['message']);
     }
     if ($this->_isAjaxPage && $this->_isSuccess) {
         $this->addJSON('_title', $this->getHeader()->getTitleTag());
         $menuHash = $this->getHeader()->getMenu()->getHash();
         $this->addJSON('_menuHash', $menuHash);
         $hashes = array();
         if (isset($_REQUEST['menuHashes'])) {
             $hashes = explode('-', $_REQUEST['menuHashes']);
         }
         if (!in_array($menuHash, $hashes)) {
             $this->addJSON('_menu', $this->getHeader()->getMenu()->getDisplay());
         }
         $this->addJSON('_scripts', $this->getHeader()->getScripts()->getFiles());
         $this->addJSON('_selflink', $this->getFooter()->getSelfUrl('unencoded'));
         $this->addJSON('_displayMessage', $this->getHeader()->getMessage());
         $errors = $this->_footer->getErrorMessages();
         if (strlen($errors)) {
             $this->addJSON('_errors', $errors);
         }
         if (empty($GLOBALS['error_message'])) {
             // set current db, table and sql query in the querywindow
             $query = '';
             $maxChars = $GLOBALS['cfg']['MaxCharactersInDisplayedSQL'];
             if (isset($GLOBALS['sql_query']) && strlen($GLOBALS['sql_query']) < $maxChars) {
                 $query = PMA_escapeJsString($GLOBALS['sql_query']);
             }
             $this->addJSON('_reloadQuerywindow', array('db' => PMA_ifSetOr($GLOBALS['db'], ''), 'table' => PMA_ifSetOr($GLOBALS['table'], ''), 'sql_query' => $query));
             if (!empty($GLOBALS['focus_querywindow'])) {
                 $this->addJSON('_focusQuerywindow', $query);
             }
             if (!empty($GLOBALS['reload'])) {
                 $this->addJSON('_reloadNavigation', 1);
             }
             $this->addJSON('_params', $this->getHeader()->getJsParams());
         }
     }
     // Set the Content-Type header to JSON so that jQuery parses the
     // response correctly.
     if (!defined('TESTSUITE')) {
         header('Cache-Control: no-cache');
         header('Content-Type: application/json');
     }
     echo json_encode($this->_JSON);
 }
예제 #2
0
 /**
  * Sends a JSON response to the browser
  *
  * @return void
  */
 private function _ajaxResponse()
 {
     if (!isset($this->_JSON['message'])) {
         $this->_JSON['message'] = $this->_getDisplay();
     } else {
         if ($this->_JSON['message'] instanceof PMA_Message) {
             $this->_JSON['message'] = $this->_JSON['message']->getDisplay();
         }
     }
     if ($this->_isSuccess) {
         $this->_JSON['success'] = true;
     } else {
         $this->_JSON['success'] = false;
         $this->_JSON['error'] = $this->_JSON['message'];
         unset($this->_JSON['message']);
     }
     if ($this->_isSuccess) {
         // Note: the old judge sentence is:
         // $this->_isAjaxPage && $this->_isSuccess
         // Removal the first, because console need log all queries, if caused any
         // bug, contact Edward Cheng
         $this->addJSON('_title', $this->getHeader()->getTitleTag());
         if (isset($GLOBALS['dbi'])) {
             $menuHash = $this->getHeader()->getMenu()->getHash();
             $this->addJSON('_menuHash', $menuHash);
             $hashes = array();
             if (isset($_REQUEST['menuHashes'])) {
                 $hashes = explode('-', $_REQUEST['menuHashes']);
             }
             if (!in_array($menuHash, $hashes)) {
                 $this->addJSON('_menu', $this->getHeader()->getMenu()->getDisplay());
             }
         }
         $this->addJSON('_scripts', $this->getHeader()->getScripts()->getFiles());
         $this->addJSON('_selflink', $this->getFooter()->getSelfUrl('unencoded'));
         $this->addJSON('_displayMessage', $this->getHeader()->getMessage());
         $debug = $this->_footer->getDebugMessage();
         if (empty($_REQUEST['no_debug']) && mb_strlen($debug)) {
             $this->addJSON('_debug', $debug);
         }
         $errors = $this->_footer->getErrorMessages();
         if (mb_strlen($errors)) {
             $this->addJSON('_errors', $errors);
         }
         $promptPhpErrors = $GLOBALS['error_handler']->hasErrorsForPrompt();
         $this->addJSON('_promptPhpErrors', $promptPhpErrors);
         if (empty($GLOBALS['error_message'])) {
             // set current db, table and sql query in the querywindow
             // (this is for the bottom console)
             $query = '';
             $maxChars = $GLOBALS['cfg']['MaxCharactersInDisplayedSQL'];
             if (isset($GLOBALS['sql_query']) && mb_strlen($GLOBALS['sql_query']) < $maxChars) {
                 $query = $GLOBALS['sql_query'];
             }
             $this->addJSON('_reloadQuerywindow', array('db' => PMA_ifSetOr($GLOBALS['db'], ''), 'table' => PMA_ifSetOr($GLOBALS['table'], ''), 'sql_query' => $query));
             if (!empty($GLOBALS['focus_querywindow'])) {
                 $this->addJSON('_focusQuerywindow', $query);
             }
             if (!empty($GLOBALS['reload'])) {
                 $this->addJSON('_reloadNavigation', 1);
             }
             $this->addJSON('_params', $this->getHeader()->getJsParams());
         }
     }
     // Set the Content-Type header to JSON so that jQuery parses the
     // response correctly.
     if (!defined('TESTSUITE')) {
         header('Cache-Control: no-cache');
         header('Content-Type: application/json');
     }
     echo json_encode($this->_JSON);
 }