Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/phpmyadmin/phpmyadmin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBimal Yashodha <kb.yashodha@gmail.com>2014-07-01 16:21:45 +0400
committerBimal Yashodha <kb.yashodha@gmail.com>2014-07-01 16:21:45 +0400
commitadf0d2e4b71193db010ca1a1aefc1a7eb16cf7db (patch)
tree245cedb225c5d572bced080136e88c713050016e
parentb092ad5b57194a8f5a56c7ae9a202f00d0f2d74b (diff)
Remove old relational schema edit/export page and related code
Signed-off-by: Bimal Yashodha <kb.yashodha@gmail.com>
-rw-r--r--db_operations.php5
-rw-r--r--libraries/designer.lib.php3
-rw-r--r--libraries/operations.lib.php23
-rw-r--r--libraries/pmd_common.php16
-rw-r--r--libraries/schema/User_Schema.class.php1010
-rw-r--r--pmd_general.php2
-rw-r--r--schema_edit.php129
-rw-r--r--schema_export.php66
-rw-r--r--test/classes/schema/User_Schema_test.php172
-rw-r--r--test/libraries/PMA_designer_test.php6
-rw-r--r--test/libraries/PMA_operations_test.php14
11 files changed, 57 insertions, 1389 deletions
diff --git a/db_operations.php b/db_operations.php
index eec625bd5f..b80fe3ce44 100644
--- a/db_operations.php
+++ b/db_operations.php
@@ -290,11 +290,6 @@ if ($cfgRelation['pdfwork'] && $num_tables > 0) {
false,
PMA_DatabaseInterface::QUERY_STORE
);
-
- /*
- * Export Relational Schema View
- */
- $response->addHTML(PMA_getHtmlForExportRelationalSchemaView($url_query));
} // end if
?>
diff --git a/libraries/designer.lib.php b/libraries/designer.lib.php
index 08d3a18c6f..ad6689721a 100644
--- a/libraries/designer.lib.php
+++ b/libraries/designer.lib.php
@@ -153,8 +153,7 @@ function PMA_getHtmlForSchemaExport($db, $page)
. '</select>'
. '<label>' . __('Select Export Relational Type') . '</label><br />';
- $htmlString .= '<input type="hidden" name="do" value="process_export" />'
- . '<input type="hidden" name="chpage" value="' . htmlspecialchars($page) . '" />'
+ $htmlString .= '<input type="hidden" name="chpage" value="' . htmlspecialchars($page) . '" />'
. '<input type="checkbox" name="show_grid" id="show_grid_opt" />'
. '<label for="show_grid_opt">' . __('Show grid') . '</label><br />'
. '<input type="checkbox" name="show_color"'
diff --git a/libraries/operations.lib.php b/libraries/operations.lib.php
index 648de79ffb..9db2b35272 100644
--- a/libraries/operations.lib.php
+++ b/libraries/operations.lib.php
@@ -259,29 +259,6 @@ function PMA_getHtmlForChangeDatabaseCharset($db, $table)
}
/**
- * Get HTML snippet for export relational schema view
- *
- * @param string $url_query Query string for link
- *
- * @return string $html_output
- */
-function PMA_getHtmlForExportRelationalSchemaView($url_query)
-{
- $html_output = '<div class="operations_full_width">'
- . '<fieldset><a href="schema_edit.php?' . $url_query . '">';
- if (PMA_Util::showIcons('ActionLinksMode')) {
- $html_output .= PMA_Util::getImage(
- 'b_edit.png'
- );
- }
- $html_output .= __('Edit or export relational schema')
- . '</a></fieldset>'
- . '</div>';
-
- return $html_output;
-}
-
-/**
* Run the Procedure definitions and function definitions
*
* to avoid selecting alternatively the current and new db
diff --git a/libraries/pmd_common.php b/libraries/pmd_common.php
index 62724cc07b..ba0cb3c47d 100644
--- a/libraries/pmd_common.php
+++ b/libraries/pmd_common.php
@@ -361,20 +361,20 @@ function PMA_getFirstPage($db)
* Creates a new page and returns its auto-incrementing id
*
* @param string $pageName name of the page
+ * @param string $db name of the database
*
* @return int|null
*/
-function PMA_createNewPage($pageName)
+function PMA_createNewPage($pageName, $db)
{
$cfgRelation = PMA_getRelationsParam();
if ($cfgRelation['pdfwork']) {
- $_POST['newpage'] = $pageName;
- // temporarlily using schema code for creating a page
- include_once 'libraries/schema/User_Schema.class.php';
- $user_schema = new PMA_User_Schema();
- $user_schema->setAction("createpage");
- $user_schema->processUserChoice();
- return $user_schema->pageNumber;
+ $pageNumber = PMA_REL_createPage(
+ $pageName,
+ $cfgRelation,
+ $db
+ );
+ return $pageNumber;
}
return null;
}
diff --git a/libraries/schema/User_Schema.class.php b/libraries/schema/User_Schema.class.php
deleted file mode 100644
index 9abff8ab24..0000000000
--- a/libraries/schema/User_Schema.class.php
+++ /dev/null
@@ -1,1010 +0,0 @@
-<?php
-/* vim: set expandtab sw=4 ts=4 sts=4: */
-/**
- * Schema support library
- *
- * @package PhpMyAdmin-schema
- */
-if (! defined('PHPMYADMIN')) {
- exit;
-}
-
-require_once 'libraries/schema/Export_Relation_Schema.class.php';
-
-/**
- * This Class interacts with the user to gather the information
- * about their tables for which they want to export the relational schema
- * export options are shown to user from they can choose
- *
- * @package PhpMyAdmin-schema
- */
-
-class PMA_User_Schema
-{
-
- public $chosenPage;
- public $autoLayoutForeign;
- public $autoLayoutInternal;
- public $pageNumber;
- public $c_table_rows;
- public $action;
-
- /**
- * Sets action to be performed with schema.
- *
- * @param string $value action name
- *
- * @return void
- */
- public function setAction($value)
- {
- $this->action = $value;
- }
-
- /**
- * This function will process the user defined pages
- * and tables which will be exported as Relational schema
- * you can set the table positions on the paper via scratchboard
- * for table positions, put the x,y co-ordinates
- *
- * $this->action tells what the Schema is supposed to do
- * create and select a page, generate schema etc
- *
- * @access public
- * @return void
- */
- public function processUserChoice()
- {
- global $db, $cfgRelation;
-
- if (isset($this->action)) {
- switch ($this->action) {
- case 'selectpage':
- $this->chosenPage = $_REQUEST['chpage'];
- if ('1' == $_REQUEST['action_choose']) {
- $this->deleteCoordinates(
- $db,
- $cfgRelation,
- $this->chosenPage
- );
- $this->deletePages(
- $db,
- $cfgRelation,
- $this->chosenPage
- );
- $this->chosenPage = 0;
- }
- break;
- case 'createpage':
- $this->pageNumber = PMA_REL_createPage(
- $_POST['newpage'],
- $cfgRelation,
- $db
- );
- $this->autoLayoutForeign = isset($_POST['auto_layout_foreign'])
- ? "1"
- : null;
- $this->autoLayoutInternal = isset($_POST['auto_layout_internal'])
- ? "1"
- : null;
- $this->saveTablePositions(
- $db,
- $this->pageNumber,
- $cfgRelation
- );
- break;
- case 'edcoord':
- $this->chosenPage = $_POST['chpage'];
- $this->c_table_rows = $_POST['c_table_rows'];
- $this->_editCoordinates($db, $cfgRelation);
- break;
- case 'delete_old_references':
- $this->_deleteTableRows(
- $_POST['delrow'],
- $cfgRelation,
- $db,
- $_POST['chpage']
- );
- break;
- case 'process_export':
- $this->_processExportSchema();
- break;
-
- } // end switch
- } // end if (isset($do))
-
- }
-
- /**
- * shows/displays the HTML FORM to create the page
- *
- * @param string $db name of the selected database
- *
- * @return void
- * @access public
- */
- public function showCreatePageDialog($db)
- {
- $htmlString = '<form method="post" action="schema_edit.php"'
- . ' name="frm_create_page">'
- . '<fieldset>'
- . '<legend>'
- . __('Create a page')
- . '</legend>'
- . PMA_URL_getHiddenInputs($db)
- . '<input type="hidden" name="do" value="createpage" />'
- . '<table>'
- . '<tr>'
- . '<td><label for="id_newpage">' . __('Page name') . '</label></td>'
- . '<td>'
- . '<input type="text" name="newpage" id="id_newpage"'
- . ' size="20" maxlength="50" />'
- . '</td>'
- . '</tr>'
- . '<tr>'
- . __('Automatic layout based on') . '</td>'
- . '<td>'
- . '<input type="checkbox" name="auto_layout_internal"'
- . ' id="id_auto_layout_internal" /><label for="id_auto_layout_internal">'
- . __('Internal relations') . '</label><br />';
-
- /*
- * Check to see whether INNODB and PBXT storage engines
- * are Available in MYSQL PACKAGE
- * If available, then provide AutoLayout for Foreign Keys in Schema View
- */
-
- if (PMA_StorageEngine::isValid('InnoDB')
- || PMA_StorageEngine::isValid('PBXT')
- ) {
- $htmlString .= '<input type="checkbox" name="auto_layout_foreign"'
- . ' id="id_auto_layout_foreign" />'
- . '<label for="id_auto_layout_foreign">'
- . __('FOREIGN KEY') . '</label><br />';
- }
-
- $htmlString .= '</td></tr>'
- . '</table>'
- . '</fieldset>'
- . '<fieldset class="tblFooters">'
- . '<input type="submit" value="' . __('Go') . '" />'
- . '</fieldset>'
- . '</form>';
-
- echo $htmlString;
- }
-
- /**
- * shows/displays the created page names in a drop down list
- * User can select any page number and edit it using dashboard etc
- *
- * @return void
- * @access public
- */
- public function selectPage()
- {
- global $db,$table,$cfgRelation;
- $page_query = 'SELECT * FROM '
- . PMA_Util::backquote($GLOBALS['cfgRelation']['db']) . '.'
- . PMA_Util::backquote($cfgRelation['pdf_pages'])
- . ' WHERE db_name = \'' . PMA_Util::sqlAddSlashes($db) . '\'';
- $page_rs = PMA_queryAsControlUser(
- $page_query, false, PMA_DatabaseInterface::QUERY_STORE
- );
-
- if ($page_rs && $GLOBALS['dbi']->numRows($page_rs) > 0) {
- ?>
- <form method="get" action="schema_edit.php" name="frm_select_page">
- <fieldset>
- <legend>
- <?php echo __('Please choose a page to edit') . "\n"; ?>
- </legend>
- <?php echo PMA_URL_getHiddenInputs($db, $table); ?>
- <input type="hidden" name="do" value="selectpage" />
- <select name="chpage" id="chpage" class="autosubmit">
- <option value="0"><?php echo __('Select page'); ?></option>
- <?php
- while ($curr_page = $GLOBALS['dbi']->fetchAssoc($page_rs)) {
- echo "\n" . ' '
- . '<option value="' . $curr_page['page_nr'] . '"';
- if (isset($this->chosenPage)
- && $this->chosenPage == $curr_page['page_nr']
- ) {
- echo ' selected="selected"';
- }
- echo '>' . $curr_page['page_nr'] . ': '
- . htmlspecialchars($curr_page['page_descr']) . '</option>';
- } // end while
- echo "\n";
- ?>
- </select>
- <?php
- $choices = array(
- '0' => __('Edit'),
- '1' => __('Delete')
- );
- echo PMA_Util::getRadioFields(
- 'action_choose', $choices, '0', false
- );
- unset($choices);
- ?>
- </fieldset>
- <fieldset class="tblFooters">
- <input type="submit" value="<?php echo __('Go'); ?>" /><br />
- </fieldset>
- </form>
- <?php
- } // end IF
- echo "\n";
- } // end function
-
- /**
- * A dashboard is displayed to AutoLayout the position of tables
- * users can drag n drop the tables and change their positions
- *
- * @return void
- * @access public
- */
- public function showTableDashBoard()
- {
- global $db, $cfgRelation, $table, $with_field_names;
- /*
- * We will need an array of all tables in this db
- */
- $selectboxall = array('--');
- $alltab_rs = $GLOBALS['dbi']->query(
- 'SHOW TABLES FROM ' . PMA_Util::backquote($db) . ';',
- null,
- PMA_DatabaseInterface::QUERY_STORE
- );
- while ($val = @$GLOBALS['dbi']->fetchRow($alltab_rs)) {
- $selectboxall[] = $val[0];
- }
-
- $tabExist = array();
-
- /*
- * Now if we already have chosen a page number then we should
- * show the tables involved
- */
- if (isset($this->chosenPage) && $this->chosenPage > 0) {
- echo "\n";
- echo "<h2>" . __('Select Tables') . "</h2>";
- $page_query = 'SELECT * FROM '
- . PMA_Util::backquote($GLOBALS['cfgRelation']['db'])
- . '.' . PMA_Util::backquote($cfgRelation['table_coords'])
- . ' WHERE db_name = \'' . PMA_Util::sqlAddSlashes($db) . '\''
- . ' AND pdf_page_number = \''
- . PMA_Util::sqlAddSlashes($this->chosenPage) . '\'';
- $page_rs = PMA_queryAsControlUser($page_query, false);
- $array_sh_page = array();
- while ($temp_sh_page = @$GLOBALS['dbi']->fetchAssoc($page_rs)) {
- $array_sh_page[] = $temp_sh_page;
- }
- /*
- * Display WYSIWYG parts
- */
-
- if (! isset($_POST['with_field_names'])
- && ! isset($_POST['showwysiwyg'])
- ) {
- $with_field_names = true;
- } elseif (isset($_POST['with_field_names'])) {
- $with_field_names = true;
- }
- $this->_displayScratchboardTables($array_sh_page);
-
- echo '<form method="post" action="schema_edit.php" name="edcoord">';
-
- echo PMA_URL_getHiddenInputs($db, $table);
- echo '<input type="hidden" name="chpage" '
- . 'value="' . htmlspecialchars($this->chosenPage) . '" />';
- echo '<input type="hidden" name="do" value="edcoord" />';
- echo '<table>';
- echo '<tr>';
- echo '<th>' . __('Table') . '</th>';
- echo '<th>' . __('Delete') . '</th>';
- echo '<th>X</th>';
- echo '<th>Y</th>';
- echo '</tr>';
-
- /*
- * Add one more empty row
- */
- $array_sh_page[] = array(
- 'table_name' => '',
- 'x' => '0',
- 'y' => '0',
- );
-
- $i = 0;
- $odd_row = true;
- foreach ($array_sh_page as $sh_page) {
- $_mtab = $sh_page['table_name'];
- if (! empty($_mtab)) {
- $tabExist[$_mtab] = false;
- }
-
- echo '<tr class="noclick ';
- if ($odd_row) {
- echo 'odd';
- } else {
- echo 'even';
- }
- echo '">';
- $odd_row = ! $odd_row;
-
- echo '<td>';
- echo '<select name="c_table_' . $i . '[name]">';
-
- foreach ($selectboxall as $value) {
- echo '<option value="' . htmlspecialchars($value) . '"';
- if (! empty($_mtab) && $value == $_mtab) {
- echo ' selected="selected"';
- $tabExist[$_mtab] = true;
- }
- echo '>' . htmlspecialchars($value) . '</option>';
- }
- echo '</select>';
- echo '</td>';
-
- echo '<td>';
- echo '<input type="checkbox" id="id_c_table_' . $i . '" '
- . 'name="c_table_' . $i . '[delete]" value="y" />';
- echo '<label for="id_c_table_' . $i . '">'
- . __('Delete') . '</label>';
- echo '</td>';
-
- echo '<td>';
- echo '<input type="text" class="position-change" data-axis="left" '
- . 'data-number="' . $i . '" id="c_table_' . $i . '_x" '
- . 'name="c_table_' . $i . '[x]" value="'
- . $sh_page['x'] . '" />';
- echo '</td>';
-
- echo '<td>';
- echo '<input type="text" class="position-change" data-axis="top" '
- . 'data-number="' . $i . '" id="c_table_' . $i . '_y" '
- . 'name="c_table_' . $i . '[y]" value="'
- . $sh_page['y'] . '" />';
- echo '</td>';
- echo '</tr>';
- $i++;
- }
-
- echo '</table>';
-
- echo '<input type="hidden" name="c_table_rows" value="' . $i . '" />';
- echo '<input type="hidden" id="showwysiwyg" name="showwysiwyg" value="'
- . ((isset($showwysiwyg) && $showwysiwyg == '1') ? '1' : '0')
- . '" />';
- echo '<input type="checkbox" id="id_with_field_names" '
- . 'name="with_field_names" '
- . (isset($with_field_names) ? 'checked="checked"' : '') . ' />';
- echo '<label for="id_with_field_names">'
- . __('Column names') . '</label><br />';
- echo '<input type="submit" value="' . __('Save') . '" />';
- echo '</form>' . "\n\n";
- } // end if
-
- if (isset($tabExist)) {
- $this->_deleteTables($db, $this->chosenPage, $tabExist);
- }
- }
-
- /**
- * show Export relational schema generation options
- * user can select export type of his own choice
- * and the attributes related to it
- *
- * @return void
- * @access public
- */
-
- public function displaySchemaGenerationOptions()
- {
- global $cfg, $db, $test_rs, $chpage;
-
- $htmlString = '<form method="post" action="schema_export.php"'
- . ' class="disableAjax">'
- . '<fieldset>'
- . '<legend>'
- . PMA_URL_getHiddenInputs($db);
-
- if (PMA_Util::showIcons('ActionLinksMode')) {
- $htmlString .= PMA_Util::getImage('b_views.png');
- }
-
- /*
- * TODO: This list should be generated dynamically based on list of
- * available plugins.
- */
- $htmlString .= __('Display relational schema')
- . ':'
- . '</legend>'
- . '<select name="export_type" id="export_type">';
- if (file_exists(TCPDF_INC)) {
- $htmlString .= '<option value="pdf" selected="selected">PDF</option>';
- }
- $htmlString .=
- '<option value="svg">SVG</option>'
- . '<option value="dia">DIA</option>'
- . '<option value="eps">EPS</option>'
- . '</select>'
- . '<label>' . __('Select Export Relational Type') . '</label><br />';
- if (isset($test_rs)) {
- $htmlString .= '<label for="pdf_page_number_opt">'
- . __('Page number:')
- . '</label>'
- . '<select name="pdf_page_number" id="pdf_page_number_opt">';
-
- while ($pages = @$GLOBALS['dbi']->fetchAssoc($test_rs)) {
- $htmlString .= '<option value="' . $pages['page_nr'] . '">'
- . $pages['page_nr'] . ': '
- . htmlspecialchars($pages['page_descr'])
- . '</option>' . "\n";
- } // end while
- $GLOBALS['dbi']->freeResult($test_rs);
- unset($test_rs);
-
- $htmlString .= '</select><br />';
- } else {
- $htmlString .= '<input type="hidden" name="pdf_page_number"'
- . ' value="' . htmlspecialchars($this->chosenPage) . '" />';
- }
- $htmlString .= '<input type="hidden" name="do" value="process_export" />'
- . '<input type="hidden" name="chpage" value="' . $chpage . '" />'
- . '<input type="checkbox" name="show_grid" id="show_grid_opt" />'
- . '<label for="show_grid_opt">' . __('Show grid') . '</label><br />'
- . '<input type="checkbox" name="show_color"'
- . ' id="show_color_opt" checked="checked" />'
- . '<label for="show_color_opt">' . __('Show color') . '</label>'
- . '<br />'
- . '<input type="checkbox" name="show_table_dimension"'
- . ' id="show_table_dim_opt" />'
- . '<label for="show_table_dim_opt">'
- . __('Show dimension of tables')
- . '</label><br />'
- . '<input type="checkbox" name="all_tables_same_width"'
- . ' id="all_tables_same_width" />'
- . '<label for="all_tables_same_width">'
- . __('Same width for all tables')
- . '</label><br />'
- . '<input type="checkbox" name="with_doc"'
- . ' id="with_doc" checked="checked" />'
- . '<label for="with_doc">' . __('Data Dictionary') . '</label><br />'
- . '<input type="checkbox" name="show_keys" id="show_keys" />'
- . '<label for="show_keys">' . __('Only show keys') . '</label><br />'
- . '<select name="orientation" id="orientation_opt" class="paper-change">'
- . '<option value="L">' . __('Landscape') . '</option>'
- . '<option value="P">' . __('Portrait') . '</option>'
- . '</select>'
- . '<label for="orientation_opt">' . __('Orientation') . '</label>'
- . '<br />'
- . '<select name="paper" id="paper_opt" class="paper-change">';
-
- foreach ($cfg['PDFPageSizes'] as $val) {
- $htmlString .= '<option value="' . $val . '"';
- if ($val == $cfg['PDFDefaultPageSize']) {
- $htmlString .= ' selected="selected"';
- }
- $htmlString .= ' >' . $val . '</option>' . "\n";
- }
-
- $htmlString .= '</select>'
- . '<label for="paper_opt">' . __('Paper size') . '</label>'
- . '</fieldset>'
- . '<fieldset class="tblFooters">'
- . '<input type="submit" value="' . __('Go') . '" />'
- . '</fieldset>'
- . '</form>';
-
- echo $htmlString;
- }
-
- /**
- * Check if there are tables that need to be deleted in dashboard,
- * if there are, ask the user for allowance
- *
- * @param string $db name of database selected
- * @param integer $chpage selected page
- * @param array $tabExist array of booleans
- *
- * @return void
- * @access private
- */
- private function _deleteTables($db, $chpage, $tabExist)
- {
- $_strtrans = '';
- $_strname = '';
- $shoot = false;
- if (empty($tabExist) || ! is_array($tabExist)) {
- return;
- }
- foreach ($tabExist as $key => $value) {
- if (! $value) {
- $_strtrans .= '<input type="hidden" name="delrow[]" value="'
- . htmlspecialchars($key) . '" />' . "\n";
- $_strname .= '<li>' . htmlspecialchars($key) . '</li>' . "\n";
- $shoot = true;
- }
- }
- if (! $shoot) {
- return;
- }
- echo '<br /><form action="schema_edit.php" method="post">' . "\n"
- . PMA_URL_getHiddenInputs($db)
- . '<input type="hidden" name="do" value="delete_old_references" />'
- . "\n"
- . '<input type="hidden" name="chpage" value="'
- . htmlspecialchars($chpage) . '" />' . "\n"
- . __(
- 'The current page has references to tables that no longer exist.'
- . ' Would you like to delete those references?'
- )
- . '<ul>' . "\n"
- . $_strname
- . '</ul>' . "\n"
- . $_strtrans
- . '<input type="submit" value="' . __('Go') . '" />' . "\n"
- . '</form>';
- }
-
- /**
- * Check if there are tables that need to be deleted in dashboard,
- * if there are, ask the user for allowance
- *
- * @param array $array_sh_page array of tables on page
- *
- * @return void
- * @access private
- */
- private function _displayScratchboardTables($array_sh_page)
- {
- global $with_field_names, $db;
-
- echo '<form method="post" action="schema_edit.php" name="dragdrop">';
- echo '<input type="button" name="dragdrop" id="toggle-dragdrop" '
- . 'value="' . __('Toggle scratchboard') . '" />';
- echo '<input type="button" name="dragdropreset" id="reset-dragdrop" '
- . 'value="' . __('Reset') . '" />';
- echo '</form>';
- echo '<div id="pdflayout" class="pdflayout" style="visibility: hidden;">';
-
- $i = 0;
-
- foreach ($array_sh_page as $temp_sh_page) {
- $drag_x = $temp_sh_page['x'];
- $drag_y = $temp_sh_page['y'];
-
- echo '<div id="table_' . $i . '" '
- . 'data-number="' . $i . '" '
- . 'data-x="' . $drag_x . '" '
- . 'data-y="' . $drag_y . '" '
- . 'class="pdflayout_table"'
- . '>'
- . '<u>'
- . htmlspecialchars($temp_sh_page['table_name'])
- . '</u>';
-
- if (isset($with_field_names)) {
- $fields = $GLOBALS['dbi']->getColumns(
- $db, $temp_sh_page['table_name']
- );
- // if the table has been dropped from outside phpMyAdmin,
- // we can no longer obtain its columns list
- if ($fields) {
- foreach ($fields as $row) {
- echo '<br />' . htmlspecialchars($row['Field']) . "\n";
- }
- }
- }
- echo '</div>' . "\n";
- $i++;
- }
-
- echo '</div>';
- }
-
- /**
- * delete the table rows with table co-ordinates
- *
- * @param int $delrow delete selected table from list of tables
- * @param array $cfgRelation relation settings
- * @param string $db database name
- * @param integer $chpage selected page for adding relations etc
- *
- * @return void
- * @access private
- */
- private function _deleteTableRows($delrow,$cfgRelation,$db,$chpage)
- {
- foreach ($delrow as $current_row) {
- $del_query = 'DELETE FROM '
- . PMA_Util::backquote($GLOBALS['cfgRelation']['db']) . '.'
- . PMA_Util::backquote($cfgRelation['table_coords']) . ' ' . "\n"
- . ' WHERE db_name = \''
- . PMA_Util::sqlAddSlashes($db) . '\'' . "\n"
- . ' AND table_name = \''
- . PMA_Util::sqlAddSlashes($current_row) . '\'' . "\n"
- . ' AND pdf_page_number = \''
- . PMA_Util::sqlAddSlashes($chpage) . '\'';
- PMA_queryAsControlUser($del_query, false);
- }
- }
-
- /**
- * get all the export options and verify
- * call and include the appropriate Schema Class depending on $export_type
- *
- * @return void
- * @access private
- */
- private function _processExportSchema()
- {
- /**
- * Settings for relation stuff
- */
- include_once './libraries/transformations.lib.php';
- include_once './libraries/Index.class.php';
- /**
- * default is PDF, otherwise validate it's only letters a-z
- */
- global $db,$export_type;
-
- if (! isset($export_type) || ! preg_match('/^[a-zA-Z]+$/', $export_type)) {
- $export_type = 'pdf';
- }
- $GLOBALS['dbi']->selectDb($db);
-
- $path = PMA_securePath(ucfirst($export_type));
- $filename = 'libraries/schema/' . $path . '_Relation_Schema.class.php';
- if (!file_exists($filename)) {
- PMA_Export_Relation_Schema::dieSchema(
- $_POST['chpage'],
- $export_type,
- __('File doesn\'t exist')
- );
- }
- $GLOBALS['skip_import'] = false;
- include $filename;
- if ( $GLOBALS['skip_import']) {
- PMA_Export_Relation_Schema::dieSchema(
- $_POST['chpage'],
- $export_type,
- __('Plugin is disabled')
- );
- }
- $class_name = 'PMA_' . $path . '_Relation_Schema';
- $obj_schema = new $class_name();
- $obj_schema->showOutput();
- }
-
- /**
- * delete X and Y coordinates
- *
- * @param string $db The database name
- * @param array $cfgRelation relation settings
- * @param integer $choosePage selected page for adding relations etc
- *
- * @return void
- * @access private
- */
- public function deleteCoordinates($db, $cfgRelation, $choosePage)
- {
- $query = 'DELETE FROM '
- . PMA_Util::backquote($GLOBALS['cfgRelation']['db']) . '.'
- . PMA_Util::backquote($cfgRelation['table_coords'])
- . ' WHERE db_name = \'' . PMA_Util::sqlAddSlashes($db) . '\''
- . ' AND pdf_page_number = \''
- . PMA_Util::sqlAddSlashes($choosePage) . '\'';
- PMA_queryAsControlUser($query, false);
- }
-
- /**
- * delete pages
- *
- * @param string $db The database name
- * @param array $cfgRelation relation settings
- * @param integer $choosePage selected page for adding relations etc
- *
- * @return void
- * @access private
- */
- public function deletePages($db, $cfgRelation, $choosePage)
- {
- $query = 'DELETE FROM '
- . PMA_Util::backquote($GLOBALS['cfgRelation']['db']) . '.'
- . PMA_Util::backquote($cfgRelation['pdf_pages'])
- . ' WHERE db_name = \'' . PMA_Util::sqlAddSlashes($db) . '\''
- . ' AND page_nr = \'' . PMA_Util::sqlAddSlashes($choosePage) . '\'';
- PMA_queryAsControlUser($query, false);
- }
-
- /**
- * process internal and foreign key relations
- *
- * @param string $db The database name
- * @param integer $pageNumber document number/Id
- * @param array $cfgRelation relation settings
- *
- * @return void
- * @access private
- */
- public function processRelations($db, $pageNumber, $cfgRelation)
- {
- /*
- * A u t o m a t i c l a y o u t
- *
- * There are 2 kinds of relations in PMA
- * 1) Internal Relations 2) Foreign Key Relations
- */
- if (isset($this->autoLayoutInternal) || isset($this->autoLayoutForeign)) {
- $all_tables = array();
- }
-
- if (isset($this->autoLayoutForeign)) {
- /*
- * get the tables list
- * who support FOREIGN KEY, it's not
- * important that we group together InnoDB tables
- * and PBXT tables, as this logic is just to put
- * the tables on the layout, not to determine relations
- */
- $tables = $GLOBALS['dbi']->getTablesFull($db);
- $foreignkey_tables = array();
- foreach ($tables as $table_name => $table_properties) {
- if (PMA_Util::isForeignKeySupported($table_properties['ENGINE'])) {
- $foreignkey_tables[] = $table_name;
- }
- }
- $all_tables = $foreignkey_tables;
- /*
- * could be improved by finding the tables which have the
- * most references keys and placing them at the beginning
- * of the array (so that they are all center of schema)
- */
- unset($tables, $foreignkey_tables);
- }
-
- if (isset($this->autoLayoutInternal)) {
- /*
- * get the tables list who support Internal Relations;
- * This type of relations will be created when
- * you setup the PMA tables correctly
- */
- $master_tables = 'SELECT COUNT(master_table), master_table'
- . ' FROM ' . PMA_Util::backquote($GLOBALS['cfgRelation']['db']) . '.'
- . PMA_Util::backquote($cfgRelation['relation'])
- . ' WHERE master_db = \'' . PMA_Util::sqlAddSlashes($db) . '\''
- . ' GROUP BY master_table'
- . ' ORDER BY COUNT(master_table) DESC';
- $master_tables_rs = PMA_queryAsControlUser(
- $master_tables, false, PMA_DatabaseInterface::QUERY_STORE
- );
- if ($master_tables_rs
- && $GLOBALS['dbi']->numRows($master_tables_rs) > 0
- ) {
- /* first put all the master tables at beginning
- * of the list, so they are near the center of
- * the schema
- */
- while (list(, $master_table)
- = $GLOBALS['dbi']->fetchRow($master_tables_rs)
- ) {
- $all_tables[] = $master_table;
- }
-
- /* Now for each master, add its foreigns into an array
- * of foreign tables, if not already there
- * (a foreign might be foreign for more than
- * one table, and might be a master itself)
- */
-
- $foreign_tables = array();
- foreach ($all_tables as $master_table) {
- $foreigners = PMA_getForeigners($db, $master_table);
- foreach ($foreigners as $foreigner) {
- if (! in_array(
- $foreigner['foreign_table'], $foreign_tables
- )) {
- $foreign_tables[] = $foreigner['foreign_table'];
- }
- }
- }
-
- /*
- * Now merge the master and foreign arrays/tables
- */
- foreach ($foreign_tables as $foreign_table) {
- if (! in_array($foreign_table, $all_tables)) {
- $all_tables[] = $foreign_table;
- }
- }
- }
- }
-
- $tables = $GLOBALS['dbi']->getTablesFull($db);
- $foreignkey_tables = array();
- foreach ($tables as $table_name => $table_properties) {
-// if (PMA_Util::isForeignKeySupported($table_properties['ENGINE'])) {
-// }
- $foreignkey_tables[] = $table_name;
- }
- $all_tables = $foreignkey_tables;
-
- if (isset($this->autoLayoutInternal) || isset($this->autoLayoutForeign)) {
- $this->addRelationCoordinates(
- $all_tables, $pageNumber, $db, $cfgRelation
- );
- }
-
-
- $this->chosenPage = $pageNumber;
- }
-
- /**
- * Saves positions of all tables in the current view
- *
- * @param string $db database name
- * @param int $pageNumber document number/Id
- * @param array $cfgRelation relation settings
- *
- * @return void
- */
- public function saveTablePositions($db, $pageNumber, $cfgRelation)
- {
- $all_tables = array();
- $results = $GLOBALS['dbi']->getTablesFull($db);
- $tables = array();
- foreach ($results as $table_name => $table_properties) {
- $tables[] = $table_name;
- }
- $all_tables = $tables;
-
- $this->addRelationCoordinates(
- $all_tables, $pageNumber, $db, $cfgRelation
- );
- $this->chosenPage = $pageNumber;
- }
-
- /**
- * Add X and Y coordinates for a table
- *
- * @param array $all_tables A list of all tables involved
- * @param integer $pageNumber document number/Id
- * @param string $db The database name
- * @param array $cfgRelation relation settings
- *
- * @return void
- * @access private
- */
- public function addRelationCoordinates(
- $all_tables, $pageNumber, $db, $cfgRelation
- ) {
- /*
- * Now generate the coordinates for the schema
- * in a clockwise spiral and add to co-ordinates table
- */
- $pos_x = 300;
- $pos_y = 300;
- $delta = 110;
- $delta_mult = 1.10;
- $direction = "right";
- foreach ($all_tables as $current_table) {
- /*
- * save current table's coordinates
- */
- $insert_query = 'INSERT INTO '
- . PMA_Util::backquote($GLOBALS['cfgRelation']['db']) . '.'
- . PMA_Util::backquote($cfgRelation['table_coords']) . ' '
- . '(db_name, table_name, pdf_page_number, x, y) '
- . 'VALUES (\'' . PMA_Util::sqlAddSlashes($db) . '\', \''
- . PMA_Util::sqlAddSlashes($current_table) . '\',' . $pageNumber
- . ',' . $pos_x . ',' . $pos_y . ')';
- PMA_queryAsControlUser($insert_query, false);
-
- /*
- * compute for the next table
- */
- switch ($direction) {
- case 'right':
- $pos_x += $delta;
- $direction = "down";
- $delta *= $delta_mult;
- break;
- case 'down':
- $pos_y += $delta;
- $direction = "left";
- $delta *= $delta_mult;
- break;
- case 'left':
- $pos_x -= $delta;
- $direction = "up";
- $delta *= $delta_mult;
- break;
- case 'up':
- $pos_y -= $delta;
- $direction = "right";
- $delta *= $delta_mult;
- break;
- }
- }
- }
-
- /**
- * update X and Y coordinates for a table
- *
- * @param string $db The database name
- * @param array $cfgRelation relation settings
- *
- * @return void
- * @access private
- */
- private function _editCoordinates($db, $cfgRelation)
- {
- for ($i = 0; $i < $this->c_table_rows; $i++) {
- $arrvalue = $_POST['c_table_' . $i];
-
- if (! isset($arrvalue['x']) || $arrvalue['x'] == '') {
- $arrvalue['x'] = 0;
- }
- if (! isset($arrvalue['y']) || $arrvalue['y'] == '') {
- $arrvalue['y'] = 0;
- }
- if (isset($arrvalue['name']) && $arrvalue['name'] != '--') {
- $test_query = 'SELECT * FROM '
- . PMA_Util::backquote($GLOBALS['cfgRelation']['db']) . '.'
- . PMA_Util::backquote($cfgRelation['table_coords'])
- . ' WHERE db_name = \'' . PMA_Util::sqlAddSlashes($db) . '\''
- . ' AND table_name = \''
- . PMA_Util::sqlAddSlashes($arrvalue['name']) . '\''
- . ' AND pdf_page_number = \''
- . PMA_Util::sqlAddSlashes($this->chosenPage) . '\'';
- $test_rs = PMA_queryAsControlUser(
- $test_query, false, PMA_DatabaseInterface::QUERY_STORE
- );
- //echo $test_query;
- if ($test_rs && $GLOBALS['dbi']->numRows($test_rs) > 0) {
- if (isset($arrvalue['delete']) && $arrvalue['delete'] == 'y') {
- $ch_query = 'DELETE FROM '
- . PMA_Util::backquote($GLOBALS['cfgRelation']['db'])
- . '.'
- . PMA_Util::backquote($cfgRelation['table_coords'])
- . ' WHERE db_name = \''
- . PMA_Util::sqlAddSlashes($db) . '\''
- . ' AND table_name = \''
- . PMA_Util::sqlAddSlashes($arrvalue['name']) . '\''
- . ' AND pdf_page_number = \''
- . PMA_Util::sqlAddSlashes($this->chosenPage) . '\'';
- } else {
- $ch_query = 'UPDATE '
- . PMA_Util::backquote($GLOBALS['cfgRelation']['db'])
- . '.' . PMA_Util::backquote($cfgRelation['table_coords'])
- . ' '
- . 'SET x = ' . $arrvalue['x'] . ', y= ' . $arrvalue['y']
- . ' WHERE db_name = \''
- . PMA_Util::sqlAddSlashes($db) . '\''
- . ' AND table_name = \''
- . PMA_Util::sqlAddSlashes($arrvalue['name']) . '\''
- . ' AND pdf_page_number = \''
- . PMA_Util::sqlAddSlashes($this->chosenPage) . '\'';
- }
- } else {
- $ch_query = 'INSERT INTO '
- . PMA_Util::backquote($GLOBALS['cfgRelation']['db'])
- . '.' . PMA_Util::backquote($cfgRelation['table_coords'])
- . ' '
- . '(db_name, table_name, pdf_page_number, x, y) '
- . 'VALUES (\'' . PMA_Util::sqlAddSlashes($db) . '\', \''
- . PMA_Util::sqlAddSlashes($arrvalue['name']) . '\', \''
- . PMA_Util::sqlAddSlashes($this->chosenPage) . '\','
- . $arrvalue['x'] . ',' . $arrvalue['y'] . ')';
- }
- //echo $ch_query;
- PMA_queryAsControlUser($ch_query, false);
- } // end if
- } // end for
- }
-}
-?>
diff --git a/pmd_general.php b/pmd_general.php
index e5f9836751..61f2621f8f 100644
--- a/pmd_general.php
+++ b/pmd_general.php
@@ -51,7 +51,7 @@ if (isset($_REQUEST['operation'])) {
if ($_REQUEST['save_page'] == 'same') {
$page = $_REQUEST['selected_page'];
} elseif ($_REQUEST['save_page'] == 'new') {
- $page = PMA_createNewPage($_REQUEST['selected_value']);
+ $page = PMA_createNewPage($_REQUEST['selected_value'], $GLOBALS['db']);
$response->addJSON('id', $page);
}
if (PMA_saveTablePositions($page)) {
diff --git a/schema_edit.php b/schema_edit.php
deleted file mode 100644
index 210756a1c1..0000000000
--- a/schema_edit.php
+++ /dev/null
@@ -1,129 +0,0 @@
-<?php
-/* vim: set expandtab sw=4 ts=4 sts=4: */
-/**
- * PDF schema editor
- *
- * @package PhpMyAdmin
- */
-
-/**
- * Gets some core libraries
- */
-
-require_once 'libraries/common.inc.php';
-require_once 'libraries/db_common.inc.php';
-require 'libraries/StorageEngine.class.php';
-
-$active_page = 'db_operations.php';
-require_once 'libraries/db_common.inc.php';
-$url_query .= '&amp;goto=schema_edit.php';
-require_once 'libraries/db_info.inc.php';
-
-/**
- * get all variables needed for exporting relational schema
- * in $cfgRelation
- */
-$cfgRelation = PMA_getRelationsParam();
-
-/**
- * Now in ./libraries/relation.lib.php we check for all tables
- * that we need, but if we don't find them we are quiet about it
- * so people can't work without relational variables.
- * This page is absolutely useless if you didn't set up your tables
- * correctly, so it is a good place to see which tables we can and
- * complain ;-)
- */
-if (! $cfgRelation['relwork']) {
- echo sprintf(__('<b>%s</b> table not found or not set in %s'), 'relation', 'config.inc.php') . '<br />' . "\n"
- . PMA_Util::showDocu('config', 'cfg_Servers_relation') . "\n";
- exit;
-}
-
-if (! $cfgRelation['displaywork']) {
- echo sprintf(__('<b>%s</b> table not found or not set in %s'), 'table_info', 'config.inc.php') . '<br />' . "\n"
- . PMA_Util::showDocu('config', 'cfg_Servers_table_info') . "\n";
- exit;
-}
-
-if (! isset($cfgRelation['table_coords'])) {
- echo sprintf(__('<b>%s</b> table not found or not set in %s'), 'table_coords', 'config.inc.php') . '<br />' . "\n"
- . PMA_Util::showDocu('config', 'cfg_Servers_table_coords') . "\n";
- exit;
-}
-if (! isset($cfgRelation['pdf_pages'])) {
- echo sprintf(__('<b>%s</b> table not found or not set in %s'), 'pdf_page', 'config.inc.php') . '<br />' . "\n"
- . PMA_Util::showDocu('config', 'cfg_Servers_pdf_pages') . "\n";
- exit;
-}
-
-if ($cfgRelation['pdfwork']) {
-
- /**
- * User object created for presenting the HTML options
- * so, user can interact with it and perform export of relations schema
- */
-
- include_once 'libraries/schema/User_Schema.class.php';
- $user_schema = new PMA_User_Schema();
-
- /**
- * This function will process the user defined pages
- * and tables which will be exported as Relational schema
- * you can set the table positions on the paper via scratchboard
- * for table positions, put the x,y co-ordinates
- *
- * @param string $do It tells what the Schema is supposed to do
- * create and select a page, generate schema etc
- */
- if (isset($_REQUEST['do'])) {
- $user_schema->setAction($_REQUEST['do']);
- $user_schema->processUserChoice();
- }
-
- /**
- * Show some possibility to select a page for the export of relation schema
- * Lists all pages created before and can select and edit from them
- */
-
- $user_schema->selectPage();
-
- /**
- * Create a new page where relations will be drawn
- */
-
- $user_schema->showCreatePageDialog($db);
-
- /**
- * After selection of page or creating a page
- * It will show you the list of tables
- * A dashboard will also be shown where you can position the tables
- */
-
- $user_schema->showTableDashBoard();
-
- if (isset($_REQUEST['do'])
- && ($_REQUEST['do'] == 'edcoord'
- || ($_REQUEST['do']== 'selectpage' && isset($user_schema->chosenPage)
- && $user_schema->chosenPage != 0)
- || ($_REQUEST['do'] == 'createpage' && isset($user_schema->chosenPage)
- && $user_schema->chosenPage != 0))
- ) {
-
- /**
- * show Export schema generation options
- */
- $user_schema->displaySchemaGenerationOptions();
-
- if ((isset($showwysiwyg) && $showwysiwyg == '1')) {
- ?>
- <script type="text/javascript">
- //<![CDATA[
- ToggleDragDrop('pdflayout');
- //]]>
- </script>
- <?php
- }
- } // end if
-} // end if ($cfgRelation['pdfwork'])
-
-?>
diff --git a/schema_export.php b/schema_export.php
index 3af6e5af2a..aa15bede30 100644
--- a/schema_export.php
+++ b/schema_export.php
@@ -21,7 +21,7 @@ $cfgRelation = PMA_getRelationsParam();
require_once 'libraries/transformations.lib.php';
require_once 'libraries/Index.class.php';
require_once 'libraries/pmd_common.php';
-require_once 'libraries/schema/User_Schema.class.php';
+require_once 'libraries/schema/Export_Relation_Schema.class.php';
/**
* get all the export options and verify
@@ -33,7 +33,6 @@ $post_params = array(
'all_tables_same_width',
'chpage',
'db',
- 'do',
'export_type',
'orientation',
'paper',
@@ -51,28 +50,55 @@ foreach ($post_params as $one_post_param) {
}
}
-$user_schema = new PMA_User_Schema();
+$temp_page = PMA_createNewPage("_temp" . rand(), $GLOBALS['db']);
+try {
+ PMA_saveTablePositions($temp_page);
+ $_POST['pdf_page_number'] = $temp_page;
+ PMA_processExportSchema();
+ PMA_deletePage($temp_page);
+} catch (Exception $e) {
+ PMA_deletePage($temp_page); // delete temp page even if an exception occured
+ throw $e;
+}
/**
- * This function will process the user defined pages
- * and tables which will be exported as Relational schema
- * you can set the table positions on the paper via scratchboard
- * for table positions, put the x,y co-ordinates
+ * get all the export options and verify
+ * call and include the appropriate Schema Class depending on $export_type
*
- * @param string $do It tells what the Schema is supposed to do
- * create and select a page, generate schema etc
+ * @return void
*/
-if (isset($_REQUEST['do'])) {
- $temp_page = PMA_createNewPage("_temp" . rand());
- try {
- PMA_saveTablePositions($temp_page);
- $_POST['pdf_page_number'] = $temp_page;
- $user_schema->setAction($_REQUEST['do']);
- $user_schema->processUserChoice();
- PMA_deletePage($temp_page);
- } catch (Exception $e) {
- PMA_deletePage($temp_page); // delete temp page even if an exception occured
- throw $e;
+function PMA_processExportSchema()
+{
+ /**
+ * default is PDF, otherwise validate it's only letters a-z
+ */
+ global $db,$export_type;
+
+ if (! isset($export_type) || ! preg_match('/^[a-zA-Z]+$/', $export_type)) {
+ $export_type = 'pdf';
+ }
+ $GLOBALS['dbi']->selectDb($db);
+
+ $path = PMA_securePath(ucfirst($export_type));
+ $filename = 'libraries/schema/' . $path . '_Relation_Schema.class.php';
+ if (!file_exists($filename)) {
+ PMA_Export_Relation_Schema::dieSchema(
+ $_POST['chpage'],
+ $export_type,
+ __('File doesn\'t exist')
+ );
+ }
+ $GLOBALS['skip_import'] = false;
+ include $filename;
+ if ( $GLOBALS['skip_import']) {
+ PMA_Export_Relation_Schema::dieSchema(
+ $_POST['chpage'],
+ $export_type,
+ __('Plugin is disabled')
+ );
}
+ $class_name = 'PMA_' . $path . '_Relation_Schema';
+ $obj_schema = new $class_name();
+ $obj_schema->showOutput();
}
?>
diff --git a/test/classes/schema/User_Schema_test.php b/test/classes/schema/User_Schema_test.php
deleted file mode 100644
index df13967293..0000000000
--- a/test/classes/schema/User_Schema_test.php
+++ /dev/null
@@ -1,172 +0,0 @@
-<?php
-/**
- * Tests for User_Schema class
- *
- * @package PhpMyAdmin-test
- */
-
-/*
- * Include to test.
- */
-require_once 'libraries/Util.class.php';
-require_once 'libraries/relation.lib.php';
-require_once 'libraries/url_generating.lib.php';
-require_once 'libraries/sqlparser.lib.php';
-require_once 'libraries/php-gettext/gettext.inc';
-require_once 'libraries/Index.class.php';
-require_once 'libraries/database_interface.inc.php';
-require_once 'libraries/schema/User_Schema.class.php';
-
-/**
- * Tests for User_Schema class
- *
- * @package PhpMyAdmin-test
- */
-class PMA_User_Schema_Test extends PHPUnit_Framework_TestCase
-{
- /**
- * @access protected
- */
- protected $object;
-
- /**
- * Sets up the fixture, for example, opens a network connection.
- * This method is called before a test is executed.
- *
- * @access protected
- * @return void
- */
- protected function setUp()
- {
- $_POST['pdf_page_number'] = 33;
- $_POST['show_grid'] = true;
- $_POST['show_color'] = 'on';
- $_POST['show_keys'] = true;
- $_POST['orientation'] = 'orientation';
- $_POST['show_table_dimension'] = 'on';
- $_POST['all_tables_same_width'] = 'on';
- $_POST['paper'] = 'paper';
- $_POST['export_type'] = 'Xml';
- $_POST['with_doc'] = 'on';
- $GLOBALS['server'] = 1;
- $GLOBALS['cfg']['ServerDefault'] = 1;
- $GLOBALS['cfg']['Server']['table_coords'] = "table_name";
- $GLOBALS['cfgRelation']['db'] = "PMA";
- $GLOBALS['cfgRelation']['table_coords'] = "table_name";
- $GLOBALS['cfgRelation']['pdf_pages'] = "pdf_pages";
- $GLOBALS['cfgRelation']['relation'] = "relation";
-
- $dbi = $this->getMockBuilder('PMA_DatabaseInterface')
- ->disableOriginalConstructor()
- ->getMock();
-
- $dbi->expects($this->any())
- ->method('insertId')
- ->will($this->returnValue(10));
-
- $databases = array();
- $database_name = 'PMA';
- $databases[$database_name]['SCHEMA_TABLES'] = 1;
- $databases[$database_name]['SCHEMA_TABLE_ROWS'] = 3;
- $databases[$database_name]['SCHEMA_DATA_LENGTH'] = 5;
- $databases[$database_name]['SCHEMA_MAX_DATA_LENGTH'] = 10;
- $databases[$database_name]['SCHEMA_INDEX_LENGTH'] = 10;
- $databases[$database_name]['SCHEMA_LENGTH'] = 10;
- $databases[$database_name]['ENGINE'] = "InnerDB";
-
- $dbi->expects($this->any())->method('getTablesFull')
- ->will($this->returnValue($databases));
-
- $GLOBALS['dbi'] = $dbi;
-
- $this->object = new PMA_User_Schema();
- }
-
- /**
- * Tears down the fixture, for example, closes a network connection.
- * This method is called after a test is executed.
- *
- * @access protected
- * @return void
- */
- protected function tearDown()
- {
- unset($this->object);
- }
-
- /**
- * Test for setAction & processUserChoice
- *
- * @return void
- *
- * @group medium
- */
- public function testSetActionAndProcessUserChoice()
- {
- //action: selectpage
- $_REQUEST['chpage'] = 10;
- $_REQUEST['action_choose'] = '2';
- $this->object->setAction("selectpage");
- $this->object->processUserChoice();
- $this->assertEquals(
- "selectpage",
- $this->object->action
- );
- $this->assertEquals(
- 10,
- $this->object->chosenPage
- );
-
- $_REQUEST['action_choose'] = '1';
- $this->object->processUserChoice();
- //deleteCoordinates successfully
- $this->assertEquals(
- 0,
- $this->object->chosenPage
- );
-
- //action: createpage
- $_POST['newpage'] = "3";
- $_POST['auto_layout_foreign'] = true;
- $_POST['auto_layout_internal'] = true;
- $_POST['delrow'] = array("row1", "row2");
- $_POST['chpage'] = "chpage";
- $this->object->setAction("delete_old_references");
- $this->object->processUserChoice();
- $this->object->setAction("createpage");
- $this->object->processUserChoice();
- $this->assertEquals(
- 10,
- $this->object->pageNumber
- );
- $this->assertEquals(
- "1",
- $this->object->autoLayoutForeign
- );
- $this->assertEquals(
- "1",
- $this->object->autoLayoutInternal
- );
-
- //action: edcoord
- $_POST['chpage'] = "3";
- $_POST['c_table_rows'] = 1;
- $_POST['c_table_0'] = array(
- 'x' => 'x0',
- 'y' => 'y0',
- 'name' => 'name0',
- 'delete' => 'delete0',
- 'x' => 'x0',
- );
- $this->object->setAction("edcoord");
- $this->object->processUserChoice();
- $this->assertEquals(
- '3',
- $this->object->chosenPage
- );
- $this->assertEquals(
- 1,
- $this->object->c_table_rows
- );
- }
-}
diff --git a/test/libraries/PMA_designer_test.php b/test/libraries/PMA_designer_test.php
index 67ff982e80..4ad3ad3c25 100644
--- a/test/libraries/PMA_designer_test.php
+++ b/test/libraries/PMA_designer_test.php
@@ -190,11 +190,7 @@ class PMA_DesginerTest extends PHPUnit_Framework_TestCase
$result
);
- // hidden fields
- $this->assertContains(
- '<input type="hidden" name="do" value="process_export" />',
- $result
- );
+ // hidden field
$this->assertContains(
'<input type="hidden" name="chpage" value="' . $page . '" />',
$result
diff --git a/test/libraries/PMA_operations_test.php b/test/libraries/PMA_operations_test.php
index a9b30d1873..0f49a5568f 100644
--- a/test/libraries/PMA_operations_test.php
+++ b/test/libraries/PMA_operations_test.php
@@ -119,20 +119,6 @@ class PMA_Operations_Test extends PHPUnit_Framework_TestCase
}
/**
- * Test for PMA_getHtmlForExportRelationalSchemaView
- *
- * @return void
- */
- public function testGetHtmlForExportRelationalSchemaView()
- {
-
- $this->assertRegExp(
- '/.*schema_edit.php.*Edit or export relational schema<.*/',
- PMA_getHtmlForExportRelationalSchemaView("id=001&name=pma")
- );
- }
-
- /**
* Test for PMA_getHtmlForOrderTheTable
*
* @return void