2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * Used to render the console of PMA's pages
8 namespace PMA\libraries
;
10 use PMA\libraries\Template
;
11 use PMA\libraries\Bookmark
;
13 if (! defined('PHPMYADMIN')) {
18 * Class used to output the console
25 * Whether to display anything
33 * Creates a new class instance
35 public function __construct()
37 $this->_isEnabled
= true;
41 * Whether we are servicing an ajax request.
49 * Set the ajax flag to indicate whether
50 * we are servicing an ajax request
52 * @param bool $isAjax Whether we are servicing an ajax request
56 public function setAjax($isAjax)
58 $this->_isAjax
= (boolean
) $isAjax;
62 * Disables the rendering of the footer
66 public function disable()
68 $this->_isEnabled
= false;
72 * Renders the bookmark content
77 public static function getBookmarkContent()
79 $cfgBookmark = Bookmark
::getParams();
81 $bookmarks = Bookmark
::getList();
82 $count_bookmarks = count($bookmarks);
83 if ($count_bookmarks > 0) {
84 $welcomeMessage = sprintf(
86 'Showing %1$d bookmark (both private and shared)',
87 'Showing %1$d bookmarks (both private and shared)',
93 $welcomeMessage = __('No bookmarks');
95 unset($count_bookmarks, $private_message, $shared_message);
96 return Template
::get('console/bookmark_content')
99 'welcomeMessage' => $welcomeMessage,
100 'bookmarks' => $bookmarks,
108 * Returns the list of JS scripts required by console
110 * @return array list of scripts
112 public function getScripts()
114 return array('console.js');
118 * Renders the console
123 public function getDisplay()
125 if ((! $this->_isAjax
) && $this->_isEnabled
) {
126 $cfgBookmark = Bookmark
::getParams();
128 $image = Util
::getImage('console.png', __('SQL Query Console'));
129 $_sql_history = PMA_getHistory($GLOBALS['cfg']['Server']['user']);
130 $bookmarkContent = static::getBookmarkContent();
132 return Template
::get('console/display')
135 'cfgBookmark' => $cfgBookmark,
137 '_sql_history' => $_sql_history,
138 'bookmarkContent' => $bookmarkContent,