_isEnabled = true; $this->_scripts = new PMA_Scripts(); } /** * 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 == true); } /** * 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 $key => $val) { $output .= ''; } } return $output; } /** * Renders the console * * @access public * @return string */ public function getDisplay() { $output = ''; if ((! $this->_isAjax) && $this->_isEnabled) { $cfgBookmark = PMA_Bookmark_getParams(); if ($GLOBALS['cfg']['CodemirrorEnable']) { $this->_scripts->addFile('codemirror/lib/codemirror.js'); $this->_scripts->addFile('codemirror/mode/sql/sql.js'); $this->_scripts->addFile('codemirror/addon/runmode/runmode.js'); $this->_scripts->addFile('codemirror/addon/hint/show-hint.js'); $this->_scripts->addFile('codemirror/addon/hint/sql-hint.js'); } $this->_scripts->addFile('console.js'); $output .= $this->_scripts->getDisplay(); $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') . '
'; // History support $_sql_history = PMA_getHistory($GLOBALS['cfg']['Server']['user']); if ($_sql_history) { foreach (array_reverse($_sql_history) as $record) { $isSelect = preg_match( '@^SELECT[[:space:]]+@i', $record['sqlquery'] ); $output .= ''; } } $output .= '
'; // .console_message_container $output .= '
' . '' . '
'; $output .= '
'; // Messages end // Dark the console while other cards cover it $output .= '
'; // 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; } }