/** * Initialises the class * * @param string $name An identifier for the new node * @param int $type Type of node, may be one of CONTAINER or OBJECT * @param bool $is_group Whether this object has been created * while grouping nodes * * @return Node_Table */ public function __construct($name, $type = Node::OBJECT, $is_group = false) { parent::__construct($name, $type, $is_group); $this->icon = array(); $this->_addIcon(PMA_Util::getScriptNameForOption($GLOBALS['cfg']['NavigationTreeDefaultTabTable'], 'table')); $this->_addIcon(PMA_Util::getScriptNameForOption($GLOBALS['cfg']['NavigationTreeDefaultTabTable2'], 'table')); $title = PMA_Util::getTitleForTarget($GLOBALS['cfg']['DefaultTabTable']); $this->title = $title; $script_name = PMA_Util::getScriptNameForOption($GLOBALS['cfg']['DefaultTabTable'], 'table'); $this->links = array('text' => $script_name . '?server=' . $GLOBALS['server'] . '&db=%2$s&table=%1$s' . '&pos=0&token=' . $_SESSION[' PMA_token '], 'icon' => array(PMA_Util::getScriptNameForOption($GLOBALS['cfg']['NavigationTreeDefaultTabTable'], 'table') . '?server=' . $GLOBALS['server'] . '&db=%2$s&table=%1$s&token=' . $_SESSION[' PMA_token '], PMA_Util::getScriptNameForOption($GLOBALS['cfg']['NavigationTreeDefaultTabTable2'], 'table') . '?server=' . $GLOBALS['server'] . '&db=%2$s&table=%1$s&token=' . $_SESSION[' PMA_token ']), 'title' => $this->title); $this->classes = 'table'; }
/** * Returns, as an array, a list of parameters * used on the client side * * @return array */ public function getJsParams() { $db = !empty($GLOBALS['db']) ? $GLOBALS['db'] : ''; $table = !empty($GLOBALS['table']) ? $GLOBALS['table'] : ''; $pftext = !empty($_SESSION['tmpval']['pftext']) ? $_SESSION['tmpval']['pftext'] : ''; // not sure when this happens, but it happens if (!isset($GLOBALS['collation_connection'])) { $GLOBALS['collation_connection'] = 'utf8_general_ci'; } return array('common_query' => PMA_URL_getCommon(array(), 'text'), 'opendb_url' => $GLOBALS['cfg']['DefaultTabDatabase'], 'safari_browser' => PMA_USR_BROWSER_AGENT == 'SAFARI' ? 1 : 0, 'collation_connection' => $GLOBALS['collation_connection'], 'lang' => $GLOBALS['lang'], 'server' => $GLOBALS['server'], 'table' => $table, 'db' => $db, 'token' => $_SESSION[' PMA_token '], 'text_dir' => $GLOBALS['text_dir'], 'show_databases_navigation_as_tree' => $GLOBALS['cfg']['ShowDatabasesNavigationAsTree'], 'pma_absolute_uri' => $GLOBALS['cfg']['PmaAbsoluteUri'], 'pma_text_default_tab' => PMA_Util::getTitleForTarget($GLOBALS['cfg']['DefaultTabTable']), 'pma_text_left_default_tab' => PMA_Util::getTitleForTarget($GLOBALS['cfg']['NavigationTreeDefaultTabTable']), 'pma_text_left_default_tab2' => PMA_Util::getTitleForTarget($GLOBALS['cfg']['NavigationTreeDefaultTabTable2']), 'LimitChars' => $GLOBALS['cfg']['LimitChars'], 'pftext' => $pftext, 'confirm' => $GLOBALS['cfg']['Confirm'], 'LoginCookieValidity' => $GLOBALS['cfg']['LoginCookieValidity'], 'logged_in' => isset($GLOBALS['userlink']) ? true : false); }
/** * Provide a line with links to the relevant database and table * * @param string $url_dbname url database name that urlencode() string * @param string $dbname database name * @param string $tablename table name * * @return string HTML snippet */ function PMA_getLinkToDbAndTable($url_dbname, $dbname, $tablename) { $html_output = '[ ' . __('Database') . ' <a href="' . PMA_Util::getScriptNameForOption($GLOBALS['cfg']['DefaultTabDatabase'], 'database') . PMA_URL_getCommon(array('db' => $url_dbname, 'reload' => 1)) . '">' . htmlspecialchars($dbname) . ': ' . PMA_Util::getTitleForTarget($GLOBALS['cfg']['DefaultTabDatabase']) . "</a> ]\n"; if (mb_strlen($tablename)) { $html_output .= ' [ ' . __('Table') . ' <a href="' . PMA_Util::getScriptNameForOption($GLOBALS['cfg']['DefaultTabTable'], 'table') . PMA_URL_getCommon(array('db' => $url_dbname, 'table' => $tablename, 'reload' => 1)) . '">' . htmlspecialchars($tablename) . ': ' . PMA_Util::getTitleForTarget($GLOBALS['cfg']['DefaultTabTable']) . "</a> ]\n"; } return $html_output; }
/** * Provide a line with links to the relevant database and table * * @param string $url_dbname url database name that urlencode() string * @param string $dbname database name * @param string $tablename table name * * @return string HTML snippet */ function PMA_getLinkToDbAndTable($url_dbname, $dbname, $tablename) { $html_output = '[ ' . __('Database') . ' <a href="' . $GLOBALS['cfg']['DefaultTabDatabase'] . '?' . $GLOBALS['url_query'] . '&db=' . $url_dbname . '&reload=1">' . htmlspecialchars($dbname) . ': ' . PMA_Util::getTitleForTarget($GLOBALS['cfg']['DefaultTabDatabase']) . "</a> ]\n"; if (strlen($tablename)) { $html_output .= ' [ ' . __('Table') . ' <a href="' . $GLOBALS['cfg']['DefaultTabTable'] . '?' . $GLOBALS['url_query'] . '&db=' . $url_dbname . '&table=' . htmlspecialchars(urlencode($tablename)) . '&reload=1">' . htmlspecialchars($tablename) . ': ' . PMA_Util::getTitleForTarget($GLOBALS['cfg']['DefaultTabTable']) . "</a> ]\n"; } return $html_output; }
/** * Test for PMA_getLinkToDbAndTable * * @return void */ public function testPMAGetLinkToDbAndTable() { $url_dbname = "url_dbname"; $dbname = "dbname"; $tablename = "tablename"; $html = PMA_getLinkToDbAndTable($url_dbname, $dbname, $tablename); //$dbname $this->assertContains(__('Database'), $html); $this->assertContains(PMA_Util::getScriptNameForOption($GLOBALS['cfg']['DefaultTabDatabase'], 'database'), $html); $item = PMA_URL_getCommon(array('db' => $url_dbname, 'reload' => 1)); $this->assertContains($item, $html); $this->assertContains(htmlspecialchars($dbname), $html); //$tablename $this->assertContains(__('Table'), $html); $this->assertContains(PMA_Util::getScriptNameForOption($GLOBALS['cfg']['DefaultTabTable'], 'table'), $html); $item = PMA_URL_getCommon(array('db' => $url_dbname, 'table' => $tablename, 'reload' => 1)); $this->assertContains($item, $html); $this->assertContains(htmlspecialchars($tablename), $html); $item = PMA_Util::getTitleForTarget($GLOBALS['cfg']['DefaultTabTable']); $this->assertContains($item, $html); }
/** * Returns, as an array, a list of parameters * used on the client side * * @return array */ public function getJsParams() { $db = !empty($GLOBALS['db']) ? $GLOBALS['db'] : ''; $table = !empty($GLOBALS['table']) ? $GLOBALS['table'] : ''; return array('common_query' => PMA_generate_common_url('', '', '&'), 'opendb_url' => $GLOBALS['cfg']['DefaultTabDatabase'], 'safari_browser' => PMA_USR_BROWSER_AGENT == 'SAFARI' ? 1 : 0, 'querywindow_height' => $GLOBALS['cfg']['QueryWindowHeight'], 'querywindow_width' => $GLOBALS['cfg']['QueryWindowWidth'], 'collation_connection' => $GLOBALS['collation_connection'], 'lang' => $GLOBALS['lang'], 'server' => $GLOBALS['server'], 'table' => $table, 'db' => $db, 'token' => $_SESSION[' PMA_token '], 'text_dir' => $GLOBALS['text_dir'], 'pma_absolute_uri' => $GLOBALS['cfg']['PmaAbsoluteUri'], 'pma_text_default_tab' => PMA_Util::getTitleForTarget($GLOBALS['cfg']['DefaultTabTable']), 'pma_text_left_default_tab' => PMA_Util::getTitleForTarget($GLOBALS['cfg']['NavigationTreeDefaultTabTable']), 'confirm' => $GLOBALS['cfg']['Confirm']); }
/** * display unordered list of tables * calls itself recursively if table in given list * is a list itself * * @param array $tables array of tables/tablegroups * @param boolean $visible whether the list is visible or not * @param string $tab_group_full full tab group name * @param string $table_db db of this table * * @return void * * @global integer the element counter * @global string html code for '-' image * @global string html code for '+' image * @global string html code for self link */ function PMA_displayTableList( $tables, $visible = false, $tab_group_full = '', $table_db = '' ) { if (! is_array($tables) || count($tables) === 0) { return; } global $element_counter, $img_minus, $img_plus, $href_left; $sep = $GLOBALS['cfg']['LeftFrameTableSeparator']; if ($visible) { echo '<ul id="subel' . $element_counter . '">'; } else { echo '<ul id="subel' . $element_counter . '" style="display: none">'; } foreach ($tables as $group => $table) { // only allow grouping if the group has more than 1 table if (isset($table['is' . $sep . 'group']) && $table['tab' . $sep . 'count'] > 1 ) { $common_url_query = $GLOBALS['common_url_query'] . '&tbl_group=' . urlencode($tab_group_full . $group); $element_counter++; echo '<li>' . "\n"; if ($visible && ((isset($_REQUEST['tbl_group']) && (strpos($_REQUEST['tbl_group'], $group) === 0 || strpos($_REQUEST['tbl_group'], $sep . $group) !== false)) || strpos($GLOBALS['table'], $group) === 0) ) { printf( $href_left, $element_counter, $GLOBALS['common_url_query'] . '&tbl_group=' . $tab_group_full ); printf($img_minus, $element_counter); } else { printf($href_left, $element_counter, $common_url_query); printf($img_plus, $element_counter); } echo '</a>'; ?> <a href="index.php?<?php echo $common_url_query; ?>" target="_parent" onclick=" if (! toggle('<?php echo $element_counter; ?>', true)) window.parent.goTo('navigation.php?<?php echo $common_url_query; ?>'); window.parent.goTo('<?php echo $GLOBALS['cfg']['DefaultTabDatabase'] . '?' . $common_url_query; ?>', 'main'); return false;"> <?php if ($GLOBALS['text_dir'] === 'rtl') { echo ' <bdo dir="ltr">(' . $table['tab' . $sep . 'count'] . ')</bdo> '; } echo htmlspecialchars(substr($group, 0, strlen($group) - strlen($sep))); if ($GLOBALS['text_dir'] === 'ltr') { echo ' <bdo dir="ltr">(' . $table['tab' . $sep . 'count'] . ')</bdo> '; } ?> </a> <?php unset($table['is' . $sep . 'group']); unset($table['tab' . $sep . 'group']); unset($table['tab' . $sep . 'count']); if ($visible && ((isset($_REQUEST['tbl_group']) && (strpos($_REQUEST['tbl_group'], $group) === 0 || strpos($_REQUEST['tbl_group'], $sep . $group) !== false)) || strpos($GLOBALS['table'], $group) === 0) ) { PMA_displayTableList( $table, true, $tab_group_full . $group, $table_db ); } else { PMA_displayTableList($table, false, '', $table_db); } echo '</li>' . "\n"; } elseif (is_array($table)) { // the table was not grouped because it is the only one with its prefix while (isset($table['is' . $sep . 'group'])) { // get the array with the actual table information foreach ($table as $value) { if (is_array($value)) { $table = $value; } } } $link_title = PMA_Util::getTitleForTarget( $GLOBALS['cfg']['LeftDefaultTabTable'] ); // quick access icon next to each table name echo '<li>' . "\n"; echo '<a target="frame_content" class="tableicon" title="' . htmlspecialchars($link_title) . ': ' . htmlspecialchars($table['Comment']) .' (' . PMA_Util::formatNumber($table['Rows'], 0) . ' ' . __('Rows') . ')"' .' id="quick_' . htmlspecialchars($table_db . '.' . $table['Name']) . '"' .' href="' . $GLOBALS['cfg']['LeftDefaultTabTable'] . '?' . $GLOBALS['common_url_query'] .'&table=' . urlencode($table['Name']) .'&goto=' . $GLOBALS['cfg']['LeftDefaultTabTable'] . '" >'; $attr = array( 'id' => 'icon_' . htmlspecialchars($table_db . '.' . $table['Name']) ); if (PMA_Table::isView($table_db, $table['Name'])) { echo PMA_Util::getImage( 's_views.png', htmlspecialchars($link_title), $attr ); } else { echo PMA_Util::getImage( 'b_browse.png', htmlspecialchars($link_title), $attr ); } echo '</a>'; // link for the table name itself $href = $GLOBALS['cfg']['DefaultTabTable'] . '?' .$GLOBALS['common_url_query'] . '&table=' .urlencode($table['Name']) . '&pos=0'; echo '<a target="frame_content" href="' . $href . '" title="' . htmlspecialchars( PMA_Util::getTitleForTarget( $GLOBALS['cfg']['DefaultTabTable'] ) . ': ' . $table['Comment'] .' (' . PMA_Util::formatNumber( $table['Rows'], 0 ) . ' ' . __('Rows') . ')' ) .'" id="' . htmlspecialchars($table_db . '.' . $table['Name']) . '">' // preserve spaces in table name . str_replace(' ', ' ', htmlspecialchars($table['disp_name'])) . '</a>'; echo '</li>' . "\n"; } } echo '</ul>'; }
/** * Test for * * @param string $target Target * @param array $result Expected value * * @return void * * @dataProvider dataProvider */ function testGetTitleForTarget($target, $result) { $this->assertEquals($result, PMA_Util::getTitleForTarget($target)); }
?> '; var text_dir = '<?php echo PMA_escapeJsString($GLOBALS['text_dir']); ?> '; var pma_absolute_uri = '<?php echo PMA_escapeJsString($GLOBALS['cfg']['PmaAbsoluteUri']); ?> '; var pma_text_default_tab = '<?php echo PMA_escapeJsString(PMA_Util::getTitleForTarget($GLOBALS['cfg']['DefaultTabTable'])); ?> '; var pma_text_left_default_tab = '<?php echo PMA_escapeJsString(PMA_Util::getTitleForTarget($GLOBALS['cfg']['LeftDefaultTabTable'])); ?> '; // for content and navigation frames var frame_content = 0; var frame_navigation = 0; function getFrames() { <?php if ($GLOBALS['text_dir'] === 'ltr') { ?> frame_content = window.frames[1]; frame_navigation = window.frames[0]; <?php
* DB search optimisation * * @package PhpMyAdmin */ require_once 'libraries/common.inc.php'; require_once 'libraries/Util.class.php'; $db = $_GET['db']; $table_term = $_GET['table']; $common_url_query = PMA_generate_common_url($GLOBALS['db']); $tables_full = PMA_Util::getTableList($db); $tables_response = array(); foreach ($tables_full as $key => $table) { if (strpos($key, $table_term) !== false) { $link = '<li class="ajax_table"><a class="tableicon" title="' . htmlspecialchars($link_title) . ': ' . htmlspecialchars($table['Comment']) . ' (' . PMA_Util::formatNumber($table['Rows'], 0) . ' ' . __('Rows') . ')"' . ' id="quick_' . htmlspecialchars($table_db . '.' . $table['Name']) . '"' . ' href="' . $GLOBALS['cfg']['LeftDefaultTabTable'] . '?' . $common_url_query . '&table=' . urlencode($table['Name']) . '&goto=' . $GLOBALS['cfg']['LeftDefaultTabTable'] . '" >'; $attr = array('id' => 'icon_' . htmlspecialchars($table_db . '.' . $table['Name'])); if (PMA_Table::isView($table_db, $table['Name'])) { $link .= PMA_Util::getImage('s_views.png', htmlspecialchars($link_title), $attr); } else { $link .= PMA_Util::getImage('b_browse.png', htmlspecialchars($link_title), $attr); } $link .= '</a>'; // link for the table name itself $href = $GLOBALS['cfg']['DefaultTabTable'] . '?' . $common_url_query . '&table=' . urlencode($table['Name']) . '&pos=0'; $link .= '<a href="' . $href . '" title="' . htmlspecialchars(PMA_Util::getTitleForTarget($GLOBALS['cfg']['DefaultTabTable']) . ': ' . $table['Comment'] . ' (' . PMA_Util::formatNumber($table['Rows'], 0) . ' ' . __('Rows') . ')') . '" id="' . htmlspecialchars($table_db . '.' . $table['Name']) . '">' . str_replace(' ', ' ', htmlspecialchars($table['disp_name'])) . '</a>'; $link .= '</li>' . "\n"; $table['line'] = $link; $tables_response[] = $table; } } $response = PMA_Response::getInstance(); $response->addJSON('tables', $tables_response);