PMA\libraries\navigation\Navigation::getItemUnhideDialog PHP Метод

getItemUnhideDialog() публичный Метод

Returns HTML for the dialog to show hidden navigation items.
public getItemUnhideDialog ( string $dbName, string $itemType = null, string $tableName = null ) : string
$dbName string database name
$itemType string type of the items to include
$tableName string table name
Результат string HTML for the dialog to show hidden navigation items
    public function getItemUnhideDialog($dbName, $itemType = null, $tableName = null)
    {
        $html = '<form method="post" action="navigation.php" class="ajax">';
        $html .= '<fieldset>';
        $html .= URL::getHiddenInputs($dbName, $tableName);
        $navTable = Util::backquote($GLOBALS['cfgRelation']['db']) . "." . Util::backquote($GLOBALS['cfgRelation']['navigationhiding']);
        $sqlQuery = "SELECT `item_name`, `item_type` FROM " . $navTable . " WHERE `username`='" . $GLOBALS['dbi']->escapeString($GLOBALS['cfg']['Server']['user']) . "'" . " AND `db_name`='" . $GLOBALS['dbi']->escapeString($dbName) . "'" . " AND `table_name`='" . (!empty($tableName) ? $GLOBALS['dbi']->escapeString($tableName) : '') . "'";
        $result = PMA_queryAsControlUser($sqlQuery, false);
        $hidden = array();
        if ($result) {
            while ($row = $GLOBALS['dbi']->fetchArray($result)) {
                $type = $row['item_type'];
                if (!isset($hidden[$type])) {
                    $hidden[$type] = array();
                }
                $hidden[$type][] = $row['item_name'];
            }
        }
        $GLOBALS['dbi']->freeResult($result);
        $typeMap = array('group' => __('Groups:'), 'event' => __('Events:'), 'function' => __('Functions:'), 'procedure' => __('Procedures:'), 'table' => __('Tables:'), 'view' => __('Views:'));
        if (empty($tableName)) {
            $first = true;
            foreach ($typeMap as $t => $lable) {
                if ((empty($itemType) || $itemType == $t) && isset($hidden[$t])) {
                    $html .= (!$first ? '<br/>' : '') . '<strong>' . $lable . '</strong>';
                    $html .= '<table width="100%"><tbody>';
                    $odd = true;
                    foreach ($hidden[$t] as $hiddenItem) {
                        $params = array('unhideNavItem' => true, 'itemType' => $t, 'itemName' => $hiddenItem, 'dbName' => $dbName);
                        $html .= '<tr class="' . ($odd ? 'odd' : 'even') . '">';
                        $html .= '<td>' . htmlspecialchars($hiddenItem) . '</td>';
                        $html .= '<td style="width:80px"><a href="navigation.php' . URL::getCommon($params) . '"' . ' class="unhideNavItem ajax">' . Util::getIcon('show.png', __('Show')) . '</a></td>';
                        $odd = !$odd;
                    }
                    $html .= '</tbody></table>';
                    $first = false;
                }
            }
        }
        $html .= '</fieldset>';
        $html .= '</form>';
        return $html;
    }

Usage Example

if (!$response->isAjax()) {
    $response->addHTML(PMA\libraries\Message::error(__('Fatal error: The navigation can only be accessed via AJAX')));
    exit;
}
if (isset($_REQUEST['getNaviSettings']) && $_REQUEST['getNaviSettings']) {
    $response->addJSON('message', PageSettings::getNaviSettings());
    exit;
}
$cfgRelation = PMA_getRelationsParam();
if ($cfgRelation['navwork']) {
    if (isset($_REQUEST['hideNavItem'])) {
        if (!empty($_REQUEST['itemName']) && !empty($_REQUEST['itemType']) && !empty($_REQUEST['dbName'])) {
            $navigation->hideNavigationItem($_REQUEST['itemName'], $_REQUEST['itemType'], $_REQUEST['dbName'], !empty($_REQUEST['tableName']) ? $_REQUEST['tableName'] : null);
        }
        exit;
    }
    if (isset($_REQUEST['unhideNavItem'])) {
        if (!empty($_REQUEST['itemName']) && !empty($_REQUEST['itemType']) && !empty($_REQUEST['dbName'])) {
            $navigation->unhideNavigationItem($_REQUEST['itemName'], $_REQUEST['itemType'], $_REQUEST['dbName'], !empty($_REQUEST['tableName']) ? $_REQUEST['tableName'] : null);
        }
        exit;
    }
    if (isset($_REQUEST['showUnhideDialog'])) {
        if (!empty($_REQUEST['dbName'])) {
            $response->addJSON('message', $navigation->getItemUnhideDialog($_REQUEST['dbName']));
        }
        exit;
    }
}
// Do the magic
$response->addJSON('message', $navigation->getDisplay());
All Usage Examples Of PMA\libraries\navigation\Navigation::getItemUnhideDialog