Lock page when changes are done in the SQL editor
[phpmyadmin.git] / libraries / Console.php
blobf066d6fb3ecfdb30b7811861902230582c4cbc1d
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Used to render the console of PMA's pages
6 * @package PhpMyAdmin
7 */
8 namespace PMA\libraries;
10 use PMA\libraries\Template;
11 use PMA\libraries\Bookmark;
13 if (! defined('PHPMYADMIN')) {
14 exit;
17 /**
18 * Class used to output the console
20 * @package PhpMyAdmin
22 class Console
24 /**
25 * Whether to display anything
27 * @access private
28 * @var bool
30 private $_isEnabled;
32 /**
33 * Creates a new class instance
35 public function __construct()
37 $this->_isEnabled = true;
40 /**
41 * Whether we are servicing an ajax request.
43 * @access private
44 * @var bool
46 private $_isAjax;
48 /**
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
54 * @return void
56 public function setAjax($isAjax)
58 $this->_isAjax = (boolean) $isAjax;
61 /**
62 * Disables the rendering of the footer
64 * @return void
66 public function disable()
68 $this->_isEnabled = false;
71 /**
72 * Renders the bookmark content
74 * @access public
75 * @return string
77 public static function getBookmarkContent()
79 $cfgBookmark = Bookmark::getParams();
80 if ($cfgBookmark) {
81 $bookmarks = Bookmark::getList();
82 $count_bookmarks = count($bookmarks);
83 if ($count_bookmarks > 0) {
84 $welcomeMessage = sprintf(
85 _ngettext(
86 'Showing %1$d bookmark (both private and shared)',
87 'Showing %1$d bookmarks (both private and shared)',
88 $count_bookmarks
90 $count_bookmarks
92 } else {
93 $welcomeMessage = __('No bookmarks');
95 unset($count_bookmarks, $private_message, $shared_message);
96 return Template::get('console/bookmark_content')
97 ->render(
98 array(
99 'welcomeMessage' => $welcomeMessage,
100 'bookmarks' => $bookmarks,
104 return '';
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
120 * @access public
121 * @return string
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')
133 ->render(
134 array(
135 'cfgBookmark' => $cfgBookmark,
136 'image' => $image,
137 '_sql_history' => $_sql_history,
138 'bookmarkContent' => $bookmarkContent,
142 return '';