/**
  * Test for PMA_getHtmlForActionLinks
  *
  * @return void
  */
 public function testPMAGetHtmlForActionLinks()
 {
     $current_table = array('TABLE_ROWS' => 3, 'TABLE_NAME' => 'name1', 'TABLE_COMMENT' => 'This is a test comment');
     $table_is_view = false;
     $tbl_url_query = 'tbl_url_query';
     $titles = array('Browse' => 'Browse1', 'NoBrowse' => 'NoBrowse1', 'Search' => 'Search1', 'NoSearch' => 'NoSearch1', 'Empty' => 'Empty1', 'NoEmpty' => 'NoEmpty1');
     $truename = 'truename';
     $db_is_system_schema = null;
     $url_query = 'url_query';
     //$table_is_view = true;
     list($browse_table, $search_table, $browse_table_label, $empty_table, $tracking_icon) = PMA_getHtmlForActionLinks($current_table, $table_is_view, $tbl_url_query, $titles, $truename, $db_is_system_schema, $url_query);
     //$browse_table
     $this->assertContains($titles['Browse'], $browse_table);
     //$search_table
     $this->assertContains($titles['Search'], $search_table);
     $this->assertContains($tbl_url_query, $search_table);
     //$browse_table_label
     $this->assertContains($tbl_url_query, $browse_table_label);
     //$empty_table
     $this->assertContains($tbl_url_query, $empty_table);
     $this->assertContains(urlencode('TRUNCATE ' . PMA_Util::backquote($current_table['TABLE_NAME'])), $empty_table);
     $this->assertContains($titles['Empty'], $empty_table);
     //$table_is_view = false;
     $current_table = array('TABLE_ROWS' => 0, 'TABLE_NAME' => 'name1', 'TABLE_COMMENT' => 'This is a test comment');
     $table_is_view = false;
     list($browse_table, $search_table, $browse_table_label, $empty_table, $tracking_icon) = PMA_getHtmlForActionLinks($current_table, $table_is_view, $tbl_url_query, $titles, $truename, $db_is_system_schema, $url_query);
     //$browse_table
     $this->assertContains($titles['NoBrowse'], $browse_table);
     //$search_table
     $this->assertContains($titles['NoSearch'], $search_table);
     //$browse_table_label
     $this->assertContains($tbl_url_query, $browse_table_label);
     $this->assertContains($titles['NoEmpty'], $empty_table);
 }
Esempio n. 2
0
    $i++;
    $row_count++;
    if ($table_is_view) {
        $hidden_fields[] = '<input type="hidden" name="views[]" value="' . htmlspecialchars($current_table['TABLE_NAME']) . '" />';
    }
    /*
     * Always activate links for Browse, Search and Empty, even if
     * the icons are greyed, because
     * 1. for views, we don't know the number of rows at this point
     * 2. for tables, another source could have populated them since the
     *    page was generated
     *
     * I could have used the PHP ternary conditional operator but I find
     * the code easier to read without this operator.
     */
    list($browse_table, $search_table, $browse_table_label, $empty_table, $tracking_icon) = PMA_getHtmlForActionLinks($current_table, $table_is_view, $tbl_url_query, $titles, $truename, $db_is_information_schema, $url_query);
    if (!$db_is_information_schema) {
        list($drop_query, $drop_message) = PMA_getTableDropQueryAndMessage($table_is_view, $current_table);
    }
    if ($num_columns > 0 && $num_tables > $num_columns && $row_count % $num_columns == 0) {
        $row_count = 1;
        $odd_row = true;
        $response->addHTML('</tr></tbody></table>');
        $response->addHTML(PMA_tableHeader(false, $server_slave_status));
    }
    list($do, $ignored) = PMA_getServerSlaveStatus($server_slave_status, $truename);
    list($html_output, $odd_row) = PMA_getHtmlForStructureTableRow($i, $odd_row, $table_is_view, $current_table, $browse_table_label, $tracking_icon, $server_slave_status, $browse_table, $tbl_url_query, $search_table, $db_is_information_schema, $titles, $empty_table, $drop_query, $drop_message, $collation, $formatted_size, $unit, $overhead, isset($create_time) ? $create_time : '', isset($update_time) ? $update_time : '', isset($check_time) ? $check_time : '', $is_show_stats, $ignored, $do, $colspan_for_structure);
    $response->addHTML($html_output);
}
// end foreach
// Show Summary