2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * This class is responsible for instantiating
5 * the various components of the navigation panel
7 * @package PhpMyAdmin-navigation
9 if (! defined('PHPMYADMIN')) {
13 require_once 'libraries/navigation/NodeFactory.class.php';
14 require_once 'libraries/navigation/NavigationHeader.class.php';
15 require_once 'libraries/navigation/NavigationTree.class.php';
18 * The navigation panel - displays server, db and table selection tree
20 * @package PhpMyAdmin-Navigation
25 * Renders the navigation tree, or part of it
27 * @return string The navigation tree
29 public function getDisplay()
33 if (! PMA_Response
::getInstance()->isAjax()) {
34 $header = new PMA_NavigationHeader();
35 $retval = $header->getDisplay();
37 $tree = new PMA_NavigationTree();
38 if (! PMA_Response
::getInstance()->isAjax()
39 ||
! empty($_REQUEST['full'])
40 ||
! empty($_REQUEST['reload'])
42 if ($GLOBALS['cfg']['ShowDatabasesNavigationAsTree']) {
43 // provide database tree in navigation
44 $navRender = $tree->renderState();
46 // provide legacy pre-4.0 navigation
47 $navRender = $tree->renderDbSelect();
50 $navRender = $tree->renderPath();
53 $retval .= PMA_Message
::error(
54 __('An error has occurred while loading the navigation display')
57 $retval .= $navRender;
60 if (! PMA_Response
::getInstance()->isAjax()) {
61 // closes the tags that were opened by the navigation header
62 $retval .= '</div>'; // pma_navigation_tree
63 $retval .= '<div id="pma_navi_settings_container">';
64 if (!defined('PMA_DISABLE_NAVI_SETTINGS')) {
65 $retval .= PMA_PageSettings
::getNaviSettings();
67 $retval .= '</div>'; //pma_navi_settings_container
68 $retval .= '</div>'; // pma_navigation_content
69 $retval .= $this->_getDropHandler();
70 $retval .= '</div>'; // pma_navigation
77 * Add an item of navigation tree to the hidden items list in PMA database.
79 * @param string $itemName name of the navigation tree item
80 * @param string $itemType type of the navigation tree item
81 * @param string $dbName database name
82 * @param string $tableName table name if applicable
86 public function hideNavigationItem(
87 $itemName, $itemType, $dbName, $tableName = null
89 $navTable = PMA_Util
::backquote($GLOBALS['cfgRelation']['db'])
90 . "." . PMA_Util
::backquote($GLOBALS['cfgRelation']['navigationhiding']);
91 $sqlQuery = "INSERT INTO " . $navTable
92 . "(`username`, `item_name`, `item_type`, `db_name`, `table_name`)"
94 . "'" . PMA_Util
::sqlAddSlashes($GLOBALS['cfg']['Server']['user']) . "',"
95 . "'" . PMA_Util
::sqlAddSlashes($itemName) . "',"
96 . "'" . PMA_Util
::sqlAddSlashes($itemType) . "',"
97 . "'" . PMA_Util
::sqlAddSlashes($dbName) . "',"
98 . "'" . (! empty($tableName)? PMA_Util
::sqlAddSlashes($tableName) : "" )
100 PMA_queryAsControlUser($sqlQuery, false);
104 * Inserts Drag and Drop Import handler
106 * @return string html code for drop handler
108 private function _getDropHandler()
111 $retval .= '<div class="pma_drop_handler">'
112 . __('Drop files here')
114 $retval .= '<div class="pma_sql_import_status">';
115 $retval .= '<h2>SQL upload ( ';
116 $retval .= '<span class="pma_import_count">0</span> ';
117 $retval .= ') <span class="close">x</span>';
118 $retval .= '<span class="minimize">-</span></h2>';
119 $retval .= '<div></div>';
125 * Remove a hidden item of navigation tree from the
126 * list of hidden items in PMA database.
128 * @param string $itemName name of the navigation tree item
129 * @param string $itemType type of the navigation tree item
130 * @param string $dbName database name
131 * @param string $tableName table name if applicable
135 public function unhideNavigationItem(
136 $itemName, $itemType, $dbName, $tableName = null
138 $navTable = PMA_Util
::backquote($GLOBALS['cfgRelation']['db'])
139 . "." . PMA_Util
::backquote($GLOBALS['cfgRelation']['navigationhiding']);
140 $sqlQuery = "DELETE FROM " . $navTable
143 . PMA_Util
::sqlAddSlashes($GLOBALS['cfg']['Server']['user']) . "'"
144 . " AND `item_name`='" . PMA_Util
::sqlAddSlashes($itemName) . "'"
145 . " AND `item_type`='" . PMA_Util
::sqlAddSlashes($itemType) . "'"
146 . " AND `db_name`='" . PMA_Util
::sqlAddSlashes($dbName) . "'"
147 . (! empty($tableName)
148 ?
" AND `table_name`='" . PMA_Util
::sqlAddSlashes($tableName) . "'"
151 PMA_queryAsControlUser($sqlQuery, false);
155 * Returns HTML for the dialog to show hidden navigation items.
157 * @param string $dbName database name
158 * @param string $itemType type of the items to include
159 * @param string $tableName table name
161 * @return string HTML for the dialog to show hidden navigation items
163 public function getItemUnhideDialog($dbName, $itemType = null, $tableName = null)
165 $html = '<form method="post" action="navigation.php" class="ajax">';
166 $html .= '<fieldset>';
167 $html .= PMA_URL_getHiddenInputs($dbName, $tableName);
169 $navTable = PMA_Util
::backquote($GLOBALS['cfgRelation']['db'])
170 . "." . PMA_Util
::backquote($GLOBALS['cfgRelation']['navigationhiding']);
171 $sqlQuery = "SELECT `item_name`, `item_type` FROM " . $navTable
172 . " WHERE `username`='"
173 . PMA_Util
::sqlAddSlashes($GLOBALS['cfg']['Server']['user']) . "'"
174 . " AND `db_name`='" . PMA_Util
::sqlAddSlashes($dbName) . "'"
175 . " AND `table_name`='"
176 . (! empty($tableName) ? PMA_Util
::sqlAddSlashes($tableName) : '') . "'";
177 $result = PMA_queryAsControlUser($sqlQuery, false);
181 while ($row = $GLOBALS['dbi']->fetchArray($result)) {
182 $type = $row['item_type'];
183 if (! isset($hidden[$type])) {
184 $hidden[$type] = array();
186 $hidden[$type][] = $row['item_name'];
189 $GLOBALS['dbi']->freeResult($result);
192 'group' => __('Groups:'),
193 'event' => __('Events:'),
194 'function' => __('Functions:'),
195 'procedure' => __('Procedures:'),
196 'table' => __('Tables:'),
197 'view' => __('Views:'),
199 if (empty($tableName)) {
201 foreach ($typeMap as $t => $lable) {
202 if ((empty($itemType) ||
$itemType == $t)
203 && isset($hidden[$t])
205 $html .= (! $first ?
'<br/>' : '')
206 . '<strong>' . $lable . '</strong>';
207 $html .= '<table width="100%"><tbody>';
209 foreach ($hidden[$t] as $hiddenItem) {
210 $html .= '<tr class="' . ($odd ?
'odd' : 'even') . '">';
211 $html .= '<td>' . htmlspecialchars($hiddenItem) . '</td>';
212 $html .= '<td style="width:80px"><a href="navigation.php'
213 . PMA_URL_getCommon()
214 . '&unhideNavItem=true'
215 . '&itemType=' . urlencode($t)
216 . '&itemName=' . urlencode($hiddenItem)
217 . '&dbName=' . urlencode($dbName) . '"'
218 . ' class="unhideNavItem ajax">'
219 . PMA_Util
::getIcon('lightbulb.png', __('Show'))
223 $html .= '</tbody></table>';
229 $html .= '</fieldset>';