Returns class instance.
public static getInstance ( string $type ) : |
||
$type | string | the table type |
리턴 |
/** * Add or remove favorite tables * * @return void */ public function addRemoveFavoriteTablesAction() { $fav_instance = RecentFavoriteTable::getInstance('favorite'); if (isset($_REQUEST['favorite_tables'])) { $favorite_tables = json_decode($_REQUEST['favorite_tables'], true); } else { $favorite_tables = array(); } // Required to keep each user's preferences separate. $user = sha1($GLOBALS['cfg']['Server']['user']); // Request for Synchronization of favorite tables. if (isset($_REQUEST['sync_favorite_tables'])) { $this->synchronizeFavoriteTables($fav_instance, $user, $favorite_tables); return; } $changes = true; $titles = Util::buildActionTitles(); $favorite_table = $_REQUEST['favorite_table']; $already_favorite = $this->checkFavoriteTable($favorite_table); if (isset($_REQUEST['remove_favorite'])) { if ($already_favorite) { // If already in favorite list, remove it. $fav_instance->remove($this->db, $favorite_table); $already_favorite = false; // for favorite_anchor template } } elseif (isset($_REQUEST['add_favorite'])) { if (!$already_favorite) { $nbTables = count($fav_instance->getTables()); if ($nbTables == $GLOBALS['cfg']['NumFavoriteTables']) { $changes = false; } else { // Otherwise add to favorite list. $fav_instance->add($this->db, $favorite_table); $already_favorite = true; // for favorite_anchor template } } } $favorite_tables[$user] = $fav_instance->getTables(); $this->response->addJSON('changes', $changes); if (!$changes) { $this->response->addJSON('message', Template::get('components/error_message')->render(array('msg' => __("Favorite List is full!")))); return; } $this->response->addJSON(array('user' => $user, 'favorite_tables' => json_encode($favorite_tables), 'list' => $fav_instance->getHtmlList(), 'anchor' => Template::get('database/structure/favorite_anchor')->render(array('db' => $this->db, 'current_table' => array('TABLE_NAME' => $favorite_table), 'titles' => $titles, 'already_favorite' => $already_favorite)))); }
$server_info .= ' ('; } } if ($GLOBALS['cfg']['ShowServerInfo'] || empty($cfg['Server']['verbose'])) { $server_info .= $GLOBALS['dbi']->getHostInfo(); } if (!empty($cfg['Server']['verbose']) && $GLOBALS['cfg']['ShowServerInfo']) { $server_info .= ')'; } $mysql_cur_user_and_host = $GLOBALS['dbi']->fetchValue('SELECT USER();'); // should we add the port info here? $short_server_info = !empty($GLOBALS['cfg']['Server']['verbose']) ? $GLOBALS['cfg']['Server']['verbose'] : $GLOBALS['cfg']['Server']['host']; } echo '<div id="maincontainer">', "\n"; // Anchor for favorite tables synchronization. echo RecentFavoriteTable::getInstance('favorite')->getHtmlSyncFavoriteTables(); echo '<div id="main_pane_left">'; if ($server > 0 || count($cfg['Servers']) > 1) { if ($cfg['DBG']['demo']) { echo '<div class="group">'; echo '<h2>', __('phpMyAdmin Demo Server'), '</h2>'; echo '<p style="margin: 0.5em 1em 0.5em 1em">'; printf(__('You are using the demo server. You can do anything here, but ' . 'please do not change root, debian-sys-maint and pma users. ' . 'More information is available at %s.'), '<a href="http://demo.phpmyadmin.net/">demo.phpmyadmin.net</a>'); echo '</p>'; echo '</div>'; } echo '<div class="group">'; echo '<h2>', __('General settings'), '</h2>'; echo '<ul>'; /** * Displays the MySQL servers choice form
/** * Creates PMA tables in the given db, updates if already exists. * * @param string $db database * @param boolean $create whether to create tables if they don't exist. * * @return void */ function PMA_fixPMATables($db, $create = true) { $tablesToFeatures = array('pma__bookmark' => 'bookmarktable', 'pma__relation' => 'relation', 'pma__table_info' => 'table_info', 'pma__table_coords' => 'table_coords', 'pma__pdf_pages' => 'pdf_pages', 'pma__column_info' => 'column_info', 'pma__history' => 'history', 'pma__recent' => 'recent', 'pma__favorite' => 'favorite', 'pma__table_uiprefs' => 'table_uiprefs', 'pma__tracking' => 'tracking', 'pma__userconfig' => 'userconfig', 'pma__users' => 'users', 'pma__usergroups' => 'usergroups', 'pma__navigationhiding' => 'navigationhiding', 'pma__savedsearches' => 'savedsearches', 'pma__central_columns' => 'central_columns', 'pma__designer_settings' => 'designer_settings', 'pma__export_templates' => 'export_templates'); $existingTables = $GLOBALS['dbi']->getTables($db, $GLOBALS['controllink']); $createQueries = null; $foundOne = false; foreach ($tablesToFeatures as $table => $feature) { if (!in_array($table, $existingTables)) { if ($create) { if ($createQueries == null) { // first create $createQueries = PMA_getDefaultPMATableNames(); $GLOBALS['dbi']->selectDb($db); } $GLOBALS['dbi']->tryQuery($createQueries[$table]); if ($error = $GLOBALS['dbi']->getError()) { $GLOBALS['message'] = $error; return; } $foundOne = true; $GLOBALS['cfg']['Server'][$feature] = $table; } } else { $foundOne = true; $GLOBALS['cfg']['Server'][$feature] = $table; } } if (!$foundOne) { return; } $GLOBALS['cfg']['Server']['pmadb'] = $db; $_SESSION['relation'][$GLOBALS['server']] = PMA_checkRelationsParam(); $cfgRelation = PMA_getRelationsParam(); if ($cfgRelation['recentwork'] || $cfgRelation['favoritework']) { // Since configuration storage is updated, we need to // re-initialize the favorite and recent tables stored in the // session from the current configuration storage. if ($cfgRelation['favoritework']) { $fav_tables = RecentFavoriteTable::getInstance('favorite'); $_SESSION['tmpval']['favorite_tables'][$GLOBALS['server']] = $fav_tables->getFromDb(); } if ($cfgRelation['recentwork']) { $recent_tables = RecentFavoriteTable::getInstance('recent'); $_SESSION['tmpval']['recent_tables'][$GLOBALS['server']] = $recent_tables->getFromDb(); } // Reload navi panel to update the recent/favorite lists. $GLOBALS['reload'] = true; } }
/** * Function to check if a table is already in favorite list. * * @param string $current_table current table * * @return true|false */ protected function checkFavoriteTable($current_table) { // ensure $_SESSION['tmpval']['favorite_tables'] is initialized RecentFavoriteTable::getInstance('favorite'); foreach ($_SESSION['tmpval']['favorite_tables'][$GLOBALS['server']] as $value) { if ($value['db'] == $this->db && $value['table'] == $current_table) { return true; } } return false; }
/** * Add recently used table and reload the navigation. * * @param string $db Database name where the table is located. * @param string $table The table name * * @return string */ private function _addRecentTable($db, $table) { $retval = ''; if ($this->_menuEnabled && mb_strlen($table) && $GLOBALS['cfg']['NumRecentTables'] > 0) { $tmp_result = RecentFavoriteTable::getInstance('recent')->add($db, $table); if ($tmp_result === true) { $retval = RecentFavoriteTable::getHtmlUpdateRecentTables(); } else { $error = $tmp_result; $retval = $error->getDisplay(); } } return $retval; }
/** * Display quick warp links, contain Recents and Favorites * * @return string HTML code */ private function _quickWarp() { $retval = '<div class="pma_quick_warp">'; if ($GLOBALS['cfg']['NumRecentTables'] > 0) { $retval .= RecentFavoriteTable::getInstance('recent')->getHtml(); } if ($GLOBALS['cfg']['NumFavoriteTables'] > 0) { $retval .= RecentFavoriteTable::getInstance('favorite')->getHtml(); } $retval .= '<div class="clearfloat"></div>'; $retval .= '</div>'; return $retval; }
<?php /* vim: set expandtab sw=4 ts=4 sts=4: */ /** * Browse recent and favourite tables chosen from navigation * * @package PhpMyAdmin */ use PMA\libraries\RecentFavoriteTable; require_once 'libraries/common.inc.php'; RecentFavoriteTable::getInstance('recent')->removeIfInvalid($_REQUEST['db'], $_REQUEST['table']); RecentFavoriteTable::getInstance('favorite')->removeIfInvalid($_REQUEST['db'], $_REQUEST['table']); require 'sql.php';