/** * Function to get html for displaying last version number * * @param array $sql_result sql result * @param int $last_version last version * @param array $url_params url parameters * @param string $url_query url query * @param string $pmaThemeImage path to theme's image folder * @param string $text_dir text direction * * @return string */ function PMA_getHtmlForTableVersionDetails($sql_result, $last_version, $url_params, $url_query, $pmaThemeImage, $text_dir) { $tracking_active = false; $html = '<form method="post" action="tbl_tracking.php" name="versionsForm"' . ' id="versionsForm" class="ajax">'; $html .= PMA_URL_getHiddenInputs($GLOBALS['db'], $GLOBALS['table']); $html .= '<table id="versions" class="data">'; $html .= '<thead>'; $html .= '<tr>'; $html .= '<th></th>'; $html .= '<th>' . __('Version') . '</th>'; $html .= '<th>' . __('Created') . '</th>'; $html .= '<th>' . __('Updated') . '</th>'; $html .= '<th>' . __('Status') . '</th>'; $html .= '<th>' . __('Action') . '</th>'; $html .= '<th>' . __('Show') . '</th>'; $html .= '</tr>'; $html .= '</thead>'; $html .= '<tbody>'; $style = 'odd'; $GLOBALS['dbi']->dataSeek($sql_result, 0); $delete = PMA_Util::getIcon('b_drop.png', __('Delete version')); $report = PMA_Util::getIcon('b_report.png', __('Tracking report')); $structure = PMA_Util::getIcon('b_props.png', __('Structure snapshot')); while ($version = $GLOBALS['dbi']->fetchArray($sql_result)) { if ($version['version'] == $last_version) { if ($version['tracking_active'] == 1) { $tracking_active = true; } else { $tracking_active = false; } } $delete_link = 'tbl_tracking.php' . $url_query . '&version=' . htmlspecialchars($version['version']) . '&submit_delete_version=true'; $checkbox_id = 'selected_versions_' . htmlspecialchars($version['version']); $html .= '<tr class="' . $style . '">'; $html .= '<td class="center">'; $html .= '<input type="checkbox" name="selected_versions[]"' . ' class="checkall" id="' . $checkbox_id . '"' . ' value="' . htmlspecialchars($version['version']) . '"/>'; $html .= '</td>'; $html .= '<th class="floatright">'; $html .= '<label for="' . $checkbox_id . '">' . htmlspecialchars($version['version']) . '</label>'; $html .= '</th>'; $html .= '<td>' . htmlspecialchars($version['date_created']) . '</td>'; $html .= '<td>' . htmlspecialchars($version['date_updated']) . '</td>'; $html .= '<td>' . PMA_getVersionStatus($version) . '</td>'; $html .= '<td><a class="delete_version_anchor ajax"' . ' href="' . $delete_link . '" >' . $delete . '</a></td>'; $html .= '<td><a href="tbl_tracking.php'; $html .= PMA_URL_getCommon($url_params + array('report' => 'true', 'version' => $version['version'])); $html .= '">' . $report . '</a>'; $html .= ' '; $html .= '<a href="tbl_tracking.php'; $html .= PMA_URL_getCommon($url_params + array('snapshot' => 'true', 'version' => $version['version'])); $html .= '">' . $structure . '</a>'; $html .= '</td>'; $html .= '</tr>'; if ($style == 'even') { $style = 'odd'; } else { $style = 'even'; } } $html .= '</tbody>'; $html .= '</table>'; $html .= PMA_Util::getWithSelected($pmaThemeImage, $text_dir, "versionsForm"); $html .= PMA_Util::getButtonOrImage('submit_mult', 'mult_submit', 'submit_mult_delete_version', __('Delete version'), 'b_drop.png', 'delete_version'); $html .= '</form>'; if ($tracking_active) { $html .= PMA_getHtmlForActivateDeactivateTracking('deactivate', $url_query, $last_version); } else { $html .= PMA_getHtmlForActivateDeactivateTracking('activate', $url_query, $last_version); } return $html; }
/** * Tests for PMA_getHtmlForActivateDeactivateTracking() method. * * @return void * @test */ public function testPMAGetHtmlForActivateDeactivateTracking() { $url_query = "url_query"; $last_version = "10"; $html = PMA_getHtmlForActivateDeactivateTracking('activate', $url_query, $last_version); $this->assertContains($url_query, $html); $item = sprintf(__('Activate tracking for %s'), htmlspecialchars($GLOBALS['db'] . '.' . $GLOBALS['table'])); $this->assertContains($item, $html); $this->assertContains($last_version, $html); $this->assertContains(__('Activate now'), $html); $html = PMA_getHtmlForActivateDeactivateTracking('deactivate', $url_query, $last_version); $this->assertContains($url_query, $html); $item = sprintf(__('Deactivate tracking for %s'), htmlspecialchars($GLOBALS['db'] . '.' . $GLOBALS['table'])); $this->assertContains($item, $html); $this->assertContains($last_version, $html); $this->assertContains(__('Deactivate now'), $html); }
/** * Function to get html for displaying last version number * * @param array $sql_result sql result * @param int $last_version last version * @param array $url_params url parameters * @param string $url_query url query * * @return string */ function PMA_getHtmlForTableVersionDetails($sql_result, $last_version, $url_params, $url_query) { $tracking_active = false; $html = '<table id="versions" class="data">'; $html .= '<thead>'; $html .= '<tr>'; $html .= '<th>' . __('Database') . '</th>'; $html .= '<th>' . __('Table') . '</th>'; $html .= '<th>' . __('Version') . '</th>'; $html .= '<th>' . __('Created') . '</th>'; $html .= '<th>' . __('Updated') . '</th>'; $html .= '<th>' . __('Status') . '</th>'; $html .= '<th>' . __('Show') . '</th>'; $html .= '</tr>'; $html .= '</thead>'; $html .= '<tbody>'; $style = 'odd'; $GLOBALS['dbi']->dataSeek($sql_result, 0); while ($version = $GLOBALS['dbi']->fetchArray($sql_result)) { if ($version['version'] == $last_version) { if ($version['tracking_active'] == 1) { $tracking_active = true; } else { $tracking_active = false; } } $html .= '<tr class="noclick ' . $style . '">'; $html .= '<td>' . htmlspecialchars($version['db_name']) . '</td>'; $html .= '<td>' . htmlspecialchars($version['table_name']) . '</td>'; $html .= '<td>' . htmlspecialchars($version['version']) . '</td>'; $html .= '<td>' . htmlspecialchars($version['date_created']) . '</td>'; $html .= '<td>' . htmlspecialchars($version['date_updated']) . '</td>'; $html .= '<td>' . PMA_getVersionStatus($version) . '</td>'; $html .= '<td><a href="tbl_tracking.php'; $html .= PMA_URL_getCommon($url_params + array('report' => 'true', 'version' => $version['version'])); $html .= '">' . __('Tracking report') . '</a>'; $html .= ' | '; $html .= '<a href="tbl_tracking.php'; $html .= PMA_URL_getCommon($url_params + array('snapshot' => 'true', 'version' => $version['version'])); $html .= '">' . __('Structure snapshot') . '</a>'; $html .= '</td>'; $html .= '</tr>'; if ($style == 'even') { $style = 'odd'; } else { $style = 'even'; } } $html .= '</tbody>'; $html .= '</table>'; if ($tracking_active) { $html .= PMA_getHtmlForActivateDeactivateTracking('deactivate', $url_query, $last_version); } else { $html .= PMA_getHtmlForActivateDeactivateTracking('activate', $url_query, $last_version); } return $html; }