Skip to content

Commit

Permalink
Port database/structure/favorite_anchor to Twig
Browse files Browse the repository at this point in the history
Signed-off-by: Maurício Meneghini Fauth <mauriciofauth@gmail.com>
  • Loading branch information
MauricioFauth committed Oct 12, 2017
1 parent 7f47703 commit 47af251
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,12 @@ public function addRemoveFavoriteTablesAction()
);
return;
}
// Check if current table is already in favorite list.
$favParams = array('db' => $this->db,
'ajax_request' => true,
'favorite_table' => $favorite_table,
(($already_favorite ? 'remove' : 'add') . '_favorite') => true
);
$this->response->addJSON(
array(
'user' => $user,
Expand All @@ -282,12 +288,11 @@ public function addRemoveFavoriteTablesAction()
'anchor' => Template::get('database/structure/favorite_anchor')
->render(
array(
'db' => $this->db,
'current_table' => array(
'TABLE_NAME' => $favorite_table
),
'table_name_hash' => md5($favorite_table),
'db_table_name_hash' => md5($this->db . "." . $favorite_table),
'fav_params' => $favParams,
'already_favorite' => $already_favorite,
'titles' => $titles,
'already_favorite' => $already_favorite
)
)
)
Expand Down
15 changes: 0 additions & 15 deletions templates/database/structure/favorite_anchor.phtml

This file was deleted.

7 changes: 7 additions & 0 deletions templates/database/structure/favorite_anchor.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<a id="{{ table_name_hash }}_favorite_anchor"
class="ajax favorite_table_anchor"
href="db_structure.php{{ Url_getCommon(fav_params) }}"
title="{{ already_favorite ? 'Remove from Favorites'|trans : 'Add to Favorites'|trans }}"
data-favtargets="{{ db_table_name_hash }}" >
{{ already_favorite ? titles['Favorite'] : titles['NoFavorite'] }}
</a>
15 changes: 12 additions & 3 deletions templates/database/structure/structure_table_row.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,21 @@
?>
<?php if ($GLOBALS['cfg']['NumFavoriteTables'] > 0): ?>
<td class="center print_ignore">
<?php
// Check if current table is already in favorite list.
$favParams = array('db' => $db,
'ajax_request' => true,
'favorite_table' => $current_table['TABLE_NAME'],
(($already_favorite ? 'remove' : 'add') . '_favorite') => true
);
?>
<?= PhpMyAdmin\Template::get('database/structure/favorite_anchor')->render(
array(
'db' => $db,
'current_table' => $current_table,
'table_name_hash' => md5($current_table['TABLE_NAME']),
'db_table_name_hash' => md5($db . "." . $current_table['TABLE_NAME']),
'fav_params' => $favParams,
'already_favorite' => $already_favorite,
'titles' => $titles,
'already_favorite' => $already_favorite
)
); ?>
</td>
Expand Down

0 comments on commit 47af251

Please sign in to comment.