Permalink
Browse files

Refactor table_tracking main tamplates

Signed-off-by: Leonardo Strozzi <laps15@inf.ufpr.br>
  • Loading branch information...
laps15 committed Jul 6, 2018
1 parent c55b2e1 commit bcad25a84af4b2d28b7903208b2bd0399f55a73a
@@ -101,7 +101,7 @@ public function getHtmlForDataDefinitionAndManipulationStatements(
array $selected,
$type = 'both'
) {
return $this->template->render('table/tracking/create_version', [
return $this->template->render('create_tracking_version', [
'url_query' => $urlQuery,
'last_version' => $lastVersion,
'db' => $db,
@@ -156,129 +156,62 @@ public function getListOfVersionsOfTable()
}
/**
* Function to get html for displaying last version number
* Function to get html for main page parts that do not use $_REQUEST
*
* @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 $urlQuery url query
* @param array $urlParams url parameters
* @param string $pmaThemeImage path to theme's image folder
* @param string $text_dir text direction
* @param string $textDir text direction
* @param int $lastVersion last tracking version
*
* @return string
*/
public function getHtmlForTableVersionDetails(
$sql_result,
$last_version,
array $url_params,
$url_query,
public function getHtmlForMainPage(
$urlQuery,
$urlParams,
$pmaThemeImage,
$text_dir
$textDir,
$lastVersion = null
) {
$tracking_active = false;
$html = '<form method="post" action="tbl_tracking.php" name="versionsForm"'
. ' id="versionsForm" class="ajax">';
$html .= 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>';
$GLOBALS['dbi']->dataSeek($sql_result, 0);
$delete = Util::getIcon('b_drop', __('Delete version'));
$report = Util::getIcon('b_report', __('Tracking report'));
$structure = Util::getIcon('b_props', __('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 . '&amp;version='
. htmlspecialchars($version['version'])
. '&amp;submit_delete_version=true';
$checkbox_id = 'selected_versions_' . htmlspecialchars($version['version']);
$html .= '<tr>';
$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>' . $this->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 .= Url::getCommon(
$url_params + [
'report' => 'true', 'version' => $version['version']
]
);
$html .= '">' . $report . '</a>';
$html .= '&nbsp;&nbsp;';
$html .= '<a href="tbl_tracking.php';
$html .= Url::getCommon(
$url_params + [
'snapshot' => 'true', 'version' => $version['version']
]
$selectableTablesSqlResult = $this->getSqlResultForSelectableTables();
$selectableTablesEntries = array();
while (($entry = $GLOBALS['dbi']->fetchArray($selectableTablesSqlResult))) {
$entry['is_tracked'] = Tracker::isTracked(
$entry['db_name'],
$entry['table_name']
);
$html .= '">' . $structure . '</a>';
$html .= '</td>';
$html .= '</tr>';
$selectableTablesEntries[] = $entry;
}
$selectableTablesNumRows = $GLOBALS['dbi']->numRows($selectableTablesSqlResult);
$html .= '</tbody>';
$html .= '</table>';
$html .= $this->template->render('select_all', [
'pma_theme_image' => $pmaThemeImage,
'text_dir' => $text_dir,
'form_name' => 'versionsForm',
]);
$html .= Util::getButtonOrImage(
'submit_mult',
'mult_submit',
__('Delete version'),
'b_drop',
'delete_version'
);
$html .= '</form>';
if ($tracking_active) {
$html .= $this->getHtmlForActivateDeactivateTracking(
'deactivate',
$url_query,
$last_version
);
} else {
$html .= $this->getHtmlForActivateDeactivateTracking(
'activate',
$url_query,
$last_version
);
$versionSqlResult = $this->getListOfVersionsOfTable();
if ($lastVersion === null) {
$lastVersion = $this->getTableLastVersionNumber($versionSqlResult);
}
$GLOBALS['dbi']->dataSeek($versionSqlResult, 0);
$versions = array();
while ($version = $GLOBALS['dbi']->fetchArray($versionSqlResult)) {
$versions[] = $version;
}
return $html;
$type = $GLOBALS['dbi']->getTable($GLOBALS['db'], $GLOBALS['table'])
->isView() ? 'view' : 'table';
return $this->template->render('table/tracking/main', [
'url_query' => $urlQuery,
'url_params' => $urlParams,
'db' => $GLOBALS['db'],
'table' => $GLOBALS['table'],
'selectable_tables_num_rows' => $selectableTablesNumRows,
'selectable_tables_entries' => $selectableTablesEntries,
'selected_table' => isset($_REQUEST['table']) ? $_REQUEST['table'] : null,
'last_version' => $lastVersion,
'versions' => $versions,
'type' => $type,
'default_statements' => $GLOBALS['cfg']['Server']['tracking_default_statements'],
'pmaThemeImage' => $pmaThemeImage,
'text_dir' => $textDir
]);
}
/**
@@ -314,36 +247,6 @@ public function getSqlResultForSelectableTables()
return $relation->queryAsControlUser($sql_query);
}
/**
* Function to get html for selectable table rows
*
* @param array $selectableTablesSqlResult sql results for selectable rows
* @param string $urlQuery url query
*
* @return string
*/
public function getHtmlForSelectableTables(
$selectableTablesSqlResult,
$urlQuery
) {
$entries = [];
while ($entry = $GLOBALS['dbi']->fetchArray($selectableTablesSqlResult)) {
$entry['is_tracked'] = Tracker::isTracked(
$entry['db_name'],
$entry['table_name']
);
$entries[] = $entry;
}
return $this->template->render('table/tracking/selectable_tables', [
'url_query' => $urlQuery,
'db' => $GLOBALS['db'],
'table' => $GLOBALS['table'],
'entries' => $entries,
'selected_table' => isset($_REQUEST['table']) ? $_REQUEST['table'] : null,
]);
}
/**
* Function to get html for tracking report and tracking report export
*
View
@@ -94,7 +94,7 @@
$tracking->exportAsFileDownload($entries);
}
$html = '<br />';
$html = '<br/>';
/**
* Actions
@@ -184,42 +184,14 @@
/*
* List selectable tables
* Main page
*/
$selectable_tables_sql_result = $tracking->getSqlResultForSelectableTables();
if ($GLOBALS['dbi']->numRows($selectable_tables_sql_result) > 0) {
$html .= $tracking->getHtmlForSelectableTables(
$selectable_tables_sql_result,
$url_query
);
}
$html .= '<br />';
/*
* List versions of current table
*/
$sql_result = $tracking->getListOfVersionsOfTable();
$last_version = $tracking->getTableLastVersionNumber($sql_result);
if ($last_version > 0) {
$html .= $tracking->getHtmlForTableVersionDetails(
$sql_result,
$last_version,
$url_params,
$url_query,
$pmaThemeImage,
$text_dir
);
}
$type = $GLOBALS['dbi']->getTable($GLOBALS['db'], $GLOBALS['table'])
->isView() ? 'view' : 'table';
$html .= $tracking->getHtmlForDataDefinitionAndManipulationStatements(
'tbl_tracking.php' . $url_query,
$last_version,
$GLOBALS['db'],
[$GLOBALS['table']],
$type
);
$html .= $tracking->getHtmlForMainPage(
$url_query,
$url_params,
$pmaThemeImage,
$text_dir
);
$html .= '<br class="clearfloat"/>';

This file was deleted.

Oops, something went wrong.
Oops, something went wrong.

0 comments on commit bcad25a

Please sign in to comment.