_isEnabled = true; } /** * Whether we are servicing an ajax request. * We can't simply use $GLOBALS['is_ajax_request'] * here since it may have not been initialised yet. * * @access private * @var bool */ private $_isAjax; /** * Set the ajax flag to indicate whether * we are servicing an ajax request * * @param bool $isAjax Whether we are servicing an ajax request * * @return void */ public function setAjax($isAjax) { $this->_isAjax = !!$isAjax; } /** * Disables the rendering of the footer * * @return void */ public function disable() { $this->_isEnabled = false; } /** * Renders the bookmark content * * @access public * @return string */ public static function getBookmarkContent() { $output = ''; $cfgBookmark = PMA_Bookmark_getParams(); if ($cfgBookmark) { $tpl_bookmark_actions = '' . __('Collapse') . ' ' . '' . __('Expand') . ' ' . '' . __('Requery') . ' ' . '' . __('Edit') . ' ' . '' . __('Delete') . ' ' . '' . __('Database') . ': %s'; $bookmarks = PMA_Bookmark_getList(); $output .= '
'; $count_bookmarks = count($bookmarks); if ($count_bookmarks > 0) { $bookmarks_message = sprintf( _ngettext( 'Total %d bookmark', 'Total %d bookmarks', $count_bookmarks ), $count_bookmarks ); $private_message = sprintf( '%1$s', __('private') ); $shared_message = sprintf( '%1$s', __('shared') ); $output .= sprintf( /* l10n: First parameter will be replaced with the translation for Total and the number of bookmarks, second one with the translation for private and the third one, with the translation for shared */ __('%1$s, %2$s and %3$s bookmarks included'), $bookmarks_message, $private_message, $shared_message ); } else { $output .= __('No bookmarks'); } unset($count_bookmarks, $private_message, $shared_message); $output .= '
'; foreach ($bookmarks as $val) { $output .= ''; } } return $output; } /** * Returns the list of JS scripts required by console * * @return array list of scripts */ public function getScripts() { return array('console.js'); } /** * Gets the history * * @param string $tpl_query_actions the template for query actions * * @return string $output the generated HTML for history * * @access private * */ private function _getHistory($tpl_query_actions) { $output = ''; $_sql_history = PMA_getHistory($GLOBALS['cfg']['Server']['user']); if (! empty($_sql_history)) { foreach (array_reverse($_sql_history) as $record) { $isSelect = preg_match( '@^SELECT[[:space:]]+@i', $record['sqlquery'] ); $output .= ''; } } return $output; } /** * Renders the console * * @access public * @return string */ public function getDisplay() { $output = ''; if ((! $this->_isAjax) && $this->_isEnabled) { $cfgBookmark = PMA_Bookmark_getParams(); $output .= '
'; // The templates, use sprintf() to output them // There're white space at the end of every , // for double-click selection $tpl_query_actions = '' . __('Collapse') . ' ' . '' . __('Expand') . ' ' . '' . __('Requery') . ' ' . '' . __('Edit') . ' ' . '' . __('Explain') . ' ' . '' . __('Profiling') . ' ' . ($cfgBookmark ? '' . __('Bookmark') . ' ' : '') . '' . __('Query failed') . ' ' . '' . __('Database') . ': %s ' . '' . __( 'Queried time' ) . ': %s '; // Console toolbar $output .= ''; // Toolbar end // Console messages $output .= '
'; $output .= '
' . '
' . '' . __('Press Ctrl+Enter to execute query') . '' . '' . __('Press Enter to execute query') . '' . '
'; $output .= $this->_getHistory($tpl_query_actions); $output .= '
'; // .console_message_container $output .= '
' . '' . '
'; $output .= '
'; // Messages end // Dark the console while other cards cover it $output .= '
'; // Debug SQL card $output .= '
'; $output .= '
' . '
' . '' . __('ascending') . '' . '
' . '
' . '' . __('descending') . '' . '
' . '
' . '' . __('Order:') . '' . '
' . '
' . '' . __('Debug SQL') . '' . '
' . '
' . '' . __('Count') . '' . '
' . '
' . '' . __('Execution order') . '' . '
' . '
' . '' . __('Time taken') . '' . '
' . '
' . '' . __('Order by:') . '' . '
' . '
' . '' . __('Group queries') . '' . '
' . '
' . '' . __('Ungroup queries') . '' . '
' . '
'; // Toolbar $output .= '
'; $output .= '
'; $output .= '
'; $output .= '
'; // Content $output .= '
' . '
' . '' . __('Collapse') . ' ' . '' . __('Expand') . ' ' . '' . __('Show trace') . ' ' . '' . __('Hide trace') . ' ' . '' . __('Count:') . ' ' . '' . __('Time taken:') . ' ' . '
' . '
'; // Template $output .= '
'; // Debug SQL card // Bookmarks card: if ($cfgBookmark) { $output .= '
'; $output .= '
' . '
' . __('Bookmarks') . '
'; $output .= '
' . __('Refresh') . '
'; $output .= '
' . __('Add') . '
'; $output .= '
'; $output .= $this->getBookmarkContent(); $output .= '
'; $output .= '
'; $output .= '
'; $output .= '
' . '
' . __('Add bookmark') . '
'; $output .= '
' . '
' . ' ' . ' ' . '' . '' . '
' // .options . '
' . '
'; $output .= '
'; $output .= '
'; // Add bookmark card $output .= '
'; // Bookmarks card } // Options card: $output .= '
'; $output .= '
' . '
' . __('Options') . '
'; $output .= '
' . __('Set default') . '
'; $output .= '
' . '
' . '
' . '
' . '
' . '
' . '
'; $output .= '
'; // Options card $output .= '
' // Templates for console message actions . '
' . sprintf($tpl_query_actions, '', '') . '
' . '
'; $output .= '
'; // #console and #pma_console_container ends } return $output; } }