123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152 |
- <?php
- namespace PhpMyAdmin;
- use PhpMyAdmin\Bookmark;
- use PhpMyAdmin\Relation;
- use PhpMyAdmin\Template;
- use PhpMyAdmin\Util;
- class Console
- {
-
- private $_isEnabled;
-
- private $_isAjax;
-
- private $relation;
-
- public function __construct()
- {
- $this->_isEnabled = true;
- $this->relation = new Relation();
- }
-
- public function setAjax($isAjax)
- {
- $this->_isAjax = (boolean) $isAjax;
- }
-
- public function disable()
- {
- $this->_isEnabled = false;
- }
-
- public static function getBookmarkContent()
- {
- $cfgBookmark = Bookmark::getParams($GLOBALS['cfg']['Server']['user']);
- if ($cfgBookmark) {
- $bookmarks = Bookmark::getList(
- $GLOBALS['dbi'],
- $GLOBALS['cfg']['Server']['user']
- );
- $count_bookmarks = count($bookmarks);
- if ($count_bookmarks > 0) {
- $welcomeMessage = sprintf(
- _ngettext(
- 'Showing %1$d bookmark (both private and shared)',
- 'Showing %1$d bookmarks (both private and shared)',
- $count_bookmarks
- ),
- $count_bookmarks
- );
- } else {
- $welcomeMessage = __('No bookmarks');
- }
- unset($count_bookmarks, $private_message, $shared_message);
- return Template::get('console/bookmark_content')
- ->render(
- array(
- 'welcome_message' => $welcomeMessage,
- 'bookmarks' => $bookmarks,
- )
- );
- }
- return '';
- }
-
- public function getScripts()
- {
- return array('console.js');
- }
-
- public function getDisplay()
- {
- if ((! $this->_isAjax) && $this->_isEnabled) {
- $cfgBookmark = Bookmark::getParams(
- $GLOBALS['cfg']['Server']['user']
- );
- $image = Util::getImage('console', __('SQL Query Console'));
- $_sql_history = $this->relation->getHistory(
- $GLOBALS['cfg']['Server']['user']
- );
- $bookmarkContent = static::getBookmarkContent();
- return Template::get('console/display')->render([
- 'cfg_bookmark' => $cfgBookmark,
- 'image' => $image,
- 'sql_history' => $_sql_history,
- 'bookmark_content' => $bookmarkContent,
- ]);
- }
- return '';
- }
- }
|