';
if ($this->_tableType == 'recent') {
$html .= '
'
. __('Recent') . '';
} else {
$html .= ''
. __('Favorites') . '';
}
$html .= $this->getHtmlList();
$html .= '
';
return $html;
}
/**
* Add recently used or favorite tables.
*
* @param string $db database name where the table is located
* @param string $table table name
*
* @return true|Message True if success, Message if not
*/
public function add($db, $table)
{
// If table does not exist, do not add._getPmaTable()
if (! $GLOBALS['dbi']->getColumns($db, $table)) {
return true;
}
$table_arr = array();
$table_arr['db'] = $db;
$table_arr['table'] = $table;
// add only if this is new table
if (! isset($this->_tables[0]) || $this->_tables[0] != $table_arr) {
array_unshift($this->_tables, $table_arr);
$this->_tables = array_merge(array_unique($this->_tables, SORT_REGULAR));
$this->trim();
if ($this->_getPmaTable()) {
return $this->saveToDb();
}
}
return true;
}
/**
* Removes recent/favorite tables that don't exist.
*
* @param string $db database
* @param string $table table
*
* @return boolean|Message True if invalid and removed, False if not invalid,
* Message if error while removing
*/
public function removeIfInvalid($db, $table)
{
foreach ($this->_tables as $tbl) {
if ($tbl['db'] == $db && $tbl['table'] == $table) {
// TODO Figure out a better way to find the existence of a table
if (! $GLOBALS['dbi']->getColumns($tbl['db'], $tbl['table'])) {
return $this->remove($tbl['db'], $tbl['table']);
}
}
}
return false;
}
/**
* Remove favorite tables.
*
* @param string $db database name where the table is located
* @param string $table table name
*
* @return true|Message True if success, Message if not
*/
public function remove($db, $table)
{
$table_arr = array();
$table_arr['db'] = $db;
$table_arr['table'] = $table;
foreach ($this->_tables as $key => $value) {
if ($value['db'] == $db && $value['table'] == $table) {
unset($this->_tables[$key]);
}
}
if ($this->_getPmaTable()) {
return $this->saveToDb();
}
return true;
}
/**
* Generate Html for sync Favorite tables anchor. (from localStorage to pmadb)
*
* @return string
*/
public function getHtmlSyncFavoriteTables()
{
$retval = '';
$server_id = $GLOBALS['server'];
if ($server_id == 0) {
return '';
}
$cfgRelation = $this->relation->getRelationsParam();
// Not to show this once list is synchronized.
if ($cfgRelation['favoritework'] && ! isset($_SESSION['tmpval']['favorites_synced'][$server_id])) {
$params = array('ajax_request' => true, 'favorite_table' => true,
'sync_favorite_tables' => true);
$url = 'db_structure.php' . Url::getCommon($params);
$retval = '