/** * Get HTML 'li' having a link of maintain action * * @param boolean $is_myisam_or_aria whether MYISAM | ARIA or not * @param boolean $is_innodb whether innodb or not * @param array $url_params array of URL parameters * @param boolean $is_berkeleydb whether berkeleydb or not * * @return string $html_output */ function PMA_getListofMaintainActionLink($is_myisam_or_aria, $is_innodb, $url_params, $is_berkeleydb) { $html_output = ''; // analyze table if ($is_innodb || $is_myisam_or_aria || $is_berkeleydb) { $params = array('sql_query' => 'ANALYZE TABLE ' . PMA\libraries\Util::backquote($GLOBALS['table']), 'table_maintenance' => 'Go'); $html_output .= PMA_getMaintainActionlink(__('Analyze table'), $params, $url_params, 'ANALYZE_TABLE'); } // check table if ($is_myisam_or_aria || $is_innodb) { $params = array('sql_query' => 'CHECK TABLE ' . PMA\libraries\Util::backquote($GLOBALS['table']), 'table_maintenance' => 'Go'); $html_output .= PMA_getMaintainActionlink(__('Check table'), $params, $url_params, 'CHECK_TABLE'); } // checksum table $params = array('sql_query' => 'CHECKSUM TABLE ' . Util::backquote($GLOBALS['table']), 'table_maintenance' => 'Go'); $html_output .= PMA_getMaintainActionlink(__('Checksum table'), $params, $url_params, 'CHECKSUM_TABLE'); // defragment table if ($is_innodb) { $params = array('sql_query' => 'ALTER TABLE ' . PMA\libraries\Util::backquote($GLOBALS['table']) . ' ENGINE = InnoDB;'); $html_output .= PMA_getMaintainActionlink(__('Defragment table'), $params, $url_params, 'InnoDB_File_Defragmenting'); } // flush table $params = array('sql_query' => 'FLUSH TABLE ' . PMA\libraries\Util::backquote($GLOBALS['table']), 'message_to_show' => sprintf(__('Table %s has been flushed.'), htmlspecialchars($GLOBALS['table'])), 'reload' => 1); $html_output .= PMA_getMaintainActionlink(__('Flush the table (FLUSH)'), $params, $url_params, 'FLUSH'); // optimize table if ($is_myisam_or_aria || $is_innodb || $is_berkeleydb) { $params = array('sql_query' => 'OPTIMIZE TABLE ' . PMA\libraries\Util::backquote($GLOBALS['table']), 'table_maintenance' => 'Go'); $html_output .= PMA_getMaintainActionlink(__('Optimize table'), $params, $url_params, 'OPTIMIZE_TABLE'); } // repair table if ($is_myisam_or_aria) { $params = array('sql_query' => 'REPAIR TABLE ' . PMA\libraries\Util::backquote($GLOBALS['table']), 'table_maintenance' => 'Go'); $html_output .= PMA_getMaintainActionlink(__('Repair table'), $params, $url_params, 'REPAIR_TABLE'); } return $html_output; }
/** * Test for PMA_getMaintainActionlink * * @return void */ public function testGetMaintainActionlink() { $this->assertRegExp('/.*href="sql.php.*post.*/', PMA_getMaintainActionlink("post", array("name" => 'foo', "value" => 'bar'), array(), 'doclink')); }
/** * Get HTML 'li' having a link of maintain action * * @param Table $pma_table Table object * @param array $url_params Array of URL parameters * * @return string $html_output */ function PMA_getListofMaintainActionLink($pma_table, $url_params) { $html_output = ''; // analyze table if ($pma_table->isEngine(array('MYISAM', 'ARIA', 'INNODB', 'BERKELEYDB'))) { $params = array('sql_query' => 'ANALYZE TABLE ' . Util::backquote($GLOBALS['table']), 'table_maintenance' => 'Go'); $html_output .= PMA_getMaintainActionlink(__('Analyze table'), $params, $url_params, 'ANALYZE_TABLE'); } // check table if ($pma_table->isEngine(array('MYISAM', 'ARIA', 'INNODB'))) { $params = array('sql_query' => 'CHECK TABLE ' . Util::backquote($GLOBALS['table']), 'table_maintenance' => 'Go'); $html_output .= PMA_getMaintainActionlink(__('Check table'), $params, $url_params, 'CHECK_TABLE'); } // checksum table $params = array('sql_query' => 'CHECKSUM TABLE ' . Util::backquote($GLOBALS['table']), 'table_maintenance' => 'Go'); $html_output .= PMA_getMaintainActionlink(__('Checksum table'), $params, $url_params, 'CHECKSUM_TABLE'); // defragment table if ($pma_table->isEngine(array('INNODB'))) { $params = array('sql_query' => 'ALTER TABLE ' . Util::backquote($GLOBALS['table']) . ' ENGINE = InnoDB;'); $html_output .= PMA_getMaintainActionlink(__('Defragment table'), $params, $url_params, 'InnoDB_File_Defragmenting'); } // flush table $params = array('sql_query' => 'FLUSH TABLE ' . Util::backquote($GLOBALS['table']), 'message_to_show' => sprintf(__('Table %s has been flushed.'), htmlspecialchars($GLOBALS['table'])), 'reload' => 1); $html_output .= PMA_getMaintainActionlink(__('Flush the table (FLUSH)'), $params, $url_params, 'FLUSH'); // optimize table if ($pma_table->isEngine(array('MYISAM', 'ARIA', 'INNODB', 'BERKELEYDB'))) { $params = array('sql_query' => 'OPTIMIZE TABLE ' . Util::backquote($GLOBALS['table']), 'table_maintenance' => 'Go'); $html_output .= PMA_getMaintainActionlink(__('Optimize table'), $params, $url_params, 'OPTIMIZE_TABLE'); } // repair table if ($pma_table->isEngine(array('MYISAM', 'ARIA'))) { $params = array('sql_query' => 'REPAIR TABLE ' . Util::backquote($GLOBALS['table']), 'table_maintenance' => 'Go'); $html_output .= PMA_getMaintainActionlink(__('Repair table'), $params, $url_params, 'REPAIR_TABLE'); } return $html_output; }
/** * Get HTML 'li' having a link of maintain action * * @param boolean $is_myisam_or_aria whether MYISAM | ARIA or not * @param boolean $is_innodb whether innodb or not * @param array $url_params array of URL parameters * @param boolean $is_berkeleydb whether berkeleydb or not * * @return string $html_output */ function PMA_getListofMaintainActionLink($is_myisam_or_aria, $is_innodb, $url_params, $is_berkeleydb) { $html_output = ''; if ($is_myisam_or_aria || $is_innodb || $is_berkeleydb) { if ($is_myisam_or_aria || $is_innodb) { $params = array('sql_query' => 'CHECK TABLE ' . PMA_Util::backquote($GLOBALS['table']), 'table_maintenance' => 'Go'); $html_output .= PMA_getMaintainActionlink(__('Check table'), $params, $url_params, 'CHECK_TABLE'); } if ($is_innodb) { $params = array('sql_query' => 'ALTER TABLE ' . PMA_Util::backquote($GLOBALS['table']) . ' ENGINE = InnoDB;'); $html_output .= PMA_getMaintainActionlink(__('Defragment table'), $params, $url_params, 'InnoDB_File_Defragmenting', 'Table_types'); } if ($is_innodb || $is_myisam_or_aria || $is_berkeleydb) { $params = array('sql_query' => 'ANALYZE TABLE ' . PMA_Util::backquote($GLOBALS['table']), 'table_maintenance' => 'Go'); $html_output .= PMA_getMaintainActionlink(__('Analyze table'), $params, $url_params, 'ANALYZE_TABLE'); } if ($is_myisam_or_aria && !PMA_DRIZZLE) { $params = array('sql_query' => 'REPAIR TABLE ' . PMA_Util::backquote($GLOBALS['table']), 'table_maintenance' => 'Go'); $html_output .= PMA_getMaintainActionlink(__('Repair table'), $params, $url_params, 'REPAIR_TABLE'); } if (($is_myisam_or_aria || $is_innodb || $is_berkeleydb) && !PMA_DRIZZLE) { $params = array('sql_query' => 'OPTIMIZE TABLE ' . PMA_Util::backquote($GLOBALS['table']), 'table_maintenance' => 'Go'); $html_output .= PMA_getMaintainActionlink(__('Optimize table'), $params, $url_params, 'OPTIMIZE_TABLE'); } } // end MYISAM or BERKELEYDB case $params = array('sql_query' => 'FLUSH TABLE ' . PMA_Util::backquote($GLOBALS['table']), 'message_to_show' => sprintf(__('Table %s has been flushed.'), htmlspecialchars($GLOBALS['table'])), 'reload' => 1); $html_output .= PMA_getMaintainActionlink(__('Flush the table (FLUSH)'), $params, $url_params, 'FLUSH'); return $html_output; }