Remove old relational schema edit/export page and related code

Signed-off-by: Bimal Yashodha <kb.yashodha@gmail.com>
This commit is contained in:
Bimal Yashodha 2014-07-01 17:51:45 +05:30
parent b092ad5b57
commit adf0d2e4b7
11 changed files with 57 additions and 1389 deletions

View File

@ -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
?>

View File

@ -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"'

View File

@ -258,29 +258,6 @@ function PMA_getHtmlForChangeDatabaseCharset($db, $table)
return $html_output;
}
/**
* 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
*

View File

@ -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;
}

File diff suppressed because it is too large Load Diff

View File

@ -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)) {

View File

@ -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'])
?>

View File

@ -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();
}
?>

View File

@ -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
);
}
}

View File

@ -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

View File

@ -118,20 +118,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
*