From ef3010ddf007c2d1fc25ca59f4e9aeb49eef1448 Mon Sep 17 00:00:00 2001 From: Alex Marin Date: Tue, 1 May 2012 21:14:16 +0300 Subject: [PATCH] Export plugins coding style: consistent plugin options definitions --- libraries/export/codegen.php | 38 ++++++++------- libraries/export/csv.php | 10 ++-- libraries/export/excel.php | 78 +++++++++++++++--------------- libraries/export/htmlword.php | 82 ++++++++++++++++---------------- libraries/export/json.php | 28 ++++++----- libraries/export/latex.php | 31 ++++++------ libraries/export/mediawiki.php | 86 +++++++++++++++++----------------- libraries/export/ods.php | 48 ++++++++++--------- libraries/export/odt.php | 4 +- libraries/export/pdf.php | 50 ++++++++++---------- libraries/export/php_array.php | 26 +++++----- libraries/export/sql.php | 5 +- libraries/export/texytext.php | 80 ++++++++++++++++--------------- libraries/export/xml.php | 28 ++++++----- libraries/export/yaml.php | 28 ++++++----- 15 files changed, 324 insertions(+), 298 deletions(-) diff --git a/libraries/export/codegen.php b/libraries/export/codegen.php index 402876a128..bbd97ff177 100644 --- a/libraries/export/codegen.php +++ b/libraries/export/codegen.php @@ -38,25 +38,27 @@ if (isset($plugin_list)) { 'text' => 'CodeGen', 'extension' => 'cs', 'mime_type' => 'text/cs', - 'options' => array( - array( - 'type' => 'begin_group', - 'name' => 'general_opts' - ), - array( - 'type' => 'hidden', - 'name' => 'structure_or_data' - ), - array('type' => 'select', - 'name' => 'format', - 'text' => __('Format:'), - 'values' => $CG_FORMATS - ), - array( - 'type' => 'end_group' - ) + 'options' => array(), + 'options_text' => __('Options') + ); + + $plugin_list['codegen']['options'][] = array( + array( + 'type' => 'begin_group', + 'name' => 'general_opts' ), - 'options_text' => __('Options'), + array( + 'type' => 'hidden', + 'name' => 'structure_or_data' + ), + array('type' => 'select', + 'name' => 'format', + 'text' => __('Format:'), + 'values' => $CG_FORMATS + ), + array( + 'type' => 'end_group' + ) ); } else { diff --git a/libraries/export/csv.php b/libraries/export/csv.php index 60f2259cf8..9749833a5f 100644 --- a/libraries/export/csv.php +++ b/libraries/export/csv.php @@ -19,7 +19,11 @@ if (isset($plugin_list)) { 'text' => __('CSV'), 'extension' => 'csv', 'mime_type' => 'text/comma-separated-values', - 'options' => array( + 'options' => array(), + 'options_text' => __('Options') + ); + + $plugin_list['csv']['options'][] = array( array( 'type' => 'begin_group', 'name' => 'general_opts' @@ -57,9 +61,7 @@ if (isset($plugin_list)) { array('type' => 'hidden', 'name' => 'structure_or_data' ), - array('type' => 'end_group'), - ), - 'options_text' => __('Options') + array('type' => 'end_group') ); } else { diff --git a/libraries/export/excel.php b/libraries/export/excel.php index f1558f3b67..2652c4d12e 100644 --- a/libraries/export/excel.php +++ b/libraries/export/excel.php @@ -18,45 +18,47 @@ if (isset($plugin_list)) { 'text' => __('CSV for MS Excel'), 'extension' => 'csv', 'mime_type' => 'text/comma-separated-values', - 'options' => array( - array( - 'type' => 'begin_group', - 'name' => 'general_opts' - ), - array( - 'type' => 'text', - 'name' => 'null', - 'text' => __('Replace NULL with:') - ), - array( - 'type' => 'bool', - 'name' => 'removeCRLF', - 'text' => __( - 'Remove carriage return/line feed characters within columns' - ) - ), - array( - 'type' => 'bool', - 'name' => 'columns', - 'text' => __('Put columns names in the first row') - ), - array( - 'type' => 'select', - 'name' => 'edition', - 'values' => array( - 'win' => 'Windows', - 'mac_excel2003' => 'Excel 2003 / Macintosh', - 'mac_excel2008' => 'Excel 2008 / Macintosh'), - 'text' => __('Excel edition:')), - array( - 'type' => 'hidden', - 'name' => 'structure_or_data' - ), - array( - 'type' => 'end_group' - ), + 'options' => array(), + 'options_text' => __('Options') + ); + + $plugin_list['excel']['options'][] = array( + array( + 'type' => 'begin_group', + 'name' => 'general_opts' ), - 'options_text' => __('Options'), + array( + 'type' => 'text', + 'name' => 'null', + 'text' => __('Replace NULL with:') + ), + array( + 'type' => 'bool', + 'name' => 'removeCRLF', + 'text' => __( + 'Remove carriage return/line feed characters within columns' + ) + ), + array( + 'type' => 'bool', + 'name' => 'columns', + 'text' => __('Put columns names in the first row') + ), + array( + 'type' => 'select', + 'name' => 'edition', + 'values' => array( + 'win' => 'Windows', + 'mac_excel2003' => 'Excel 2003 / Macintosh', + 'mac_excel2008' => 'Excel 2008 / Macintosh'), + 'text' => __('Excel edition:')), + array( + 'type' => 'hidden', + 'name' => 'structure_or_data' + ), + array( + 'type' => 'end_group' + ) ); } else { /* Everything rest is coded in csv plugin */ diff --git a/libraries/export/htmlword.php b/libraries/export/htmlword.php index 6a8bdf9df8..704daf6b62 100644 --- a/libraries/export/htmlword.php +++ b/libraries/export/htmlword.php @@ -19,48 +19,50 @@ if (isset($plugin_list)) { 'extension' => 'doc', 'mime_type' => 'application/vnd.ms-word', 'force_file' => true, - 'options' => array( - /* what to dump (structure/data/both) */ - array( - 'type' => 'begin_group', - 'name' => 'dump_what', - 'text' => __('Dump table') - ), - array( - 'type' => 'radio', - 'name' => 'structure_or_data', - 'values' => array( - 'structure' => __('structure'), - 'data' => __('data'), - 'structure_and_data' => __('structure and data') - ) - ), - array( - 'type' => 'end_group' - ), + 'options' => array(), + 'options_text' => __('Options') + ); - /* data options */ - array( - 'type' => 'begin_group', - 'name' => 'data', - 'text' => __('Data dump options'), - 'force' => 'structure' - ), - array( - 'type' => 'text', - 'name' => 'null', - 'text' => __('Replace NULL with:') - ), - array( - 'type' => 'bool', - 'name' => 'columns', - 'text' => __('Put columns names in the first row') - ), - array( - 'type' => 'end_group' - ), + $plugin_list['htmlword']['options'][] = array( + /* what to dump (structure/data/both) */ + array( + 'type' => 'begin_group', + 'name' => 'dump_what', + 'text' => __('Dump table') ), - 'options_text' => __('Options'), + array( + 'type' => 'radio', + 'name' => 'structure_or_data', + 'values' => array( + 'structure' => __('structure'), + 'data' => __('data'), + 'structure_and_data' => __('structure and data') + ) + ), + array( + 'type' => 'end_group' + ), + + /* data options */ + array( + 'type' => 'begin_group', + 'name' => 'data', + 'text' => __('Data dump options'), + 'force' => 'structure' + ), + array( + 'type' => 'text', + 'name' => 'null', + 'text' => __('Replace NULL with:') + ), + array( + 'type' => 'bool', + 'name' => 'columns', + 'text' => __('Put columns names in the first row') + ), + array( + 'type' => 'end_group' + ) ); } else { diff --git a/libraries/export/json.php b/libraries/export/json.php index 2c18d748f2..c50cf79c3e 100644 --- a/libraries/export/json.php +++ b/libraries/export/json.php @@ -18,20 +18,22 @@ if (isset($plugin_list)) { 'text' => 'JSON', 'extension' => 'json', 'mime_type' => 'text/plain', - 'options' => array( - array( - 'type' => 'begin_group', - 'name' => 'general_opts' - ), - array( - 'type' => 'hidden', - 'name' => 'structure_or_data', - ), - array( - 'type' => 'end_group' - ) + 'options' => array(), + 'options_text' => __('Options') + ); + + $plugin_list['json']['options'][] = array( + array( + 'type' => 'begin_group', + 'name' => 'general_opts' ), - 'options_text' => __('Options'), + array( + 'type' => 'hidden', + 'name' => 'structure_or_data', + ), + array( + 'type' => 'end_group' + ) ); } else { diff --git a/libraries/export/latex.php b/libraries/export/latex.php index 50cad1b584..6be5bd757c 100644 --- a/libraries/export/latex.php +++ b/libraries/export/latex.php @@ -27,23 +27,24 @@ if (isset($plugin_list)) { 'text' => __('LaTeX'), 'extension' => 'tex', 'mime_type' => 'application/x-tex', - 'options' => array( - array( - 'type' => 'begin_group', - 'name' => 'general_opts' - ), - array( - 'type' => 'bool', - 'name' => 'caption', - 'text' => __('Include table caption') - ), - array( - 'type' => 'end_group' - ) - ), - 'options_text' => __('Options'), + 'options' => array(), + 'options_text' => __('Options') ); + $plugin_list['latex']['options'][] = array( + array( + 'type' => 'begin_group', + 'name' => 'general_opts' + ), + array( + 'type' => 'bool', + 'name' => 'caption', + 'text' => __('Include table caption') + ), + array( + 'type' => 'end_group' + ) + ); /* what to dump (structure/data/both) */ $plugin_list['latex']['options'][] = array( 'type' => 'begin_group', diff --git a/libraries/export/mediawiki.php b/libraries/export/mediawiki.php index 7493def537..de6f3b540d 100644 --- a/libraries/export/mediawiki.php +++ b/libraries/export/mediawiki.php @@ -15,53 +15,55 @@ if (isset($plugin_list)) { 'text' => __('MediaWiki Table'), 'extension' => 'mediawiki', 'mime_type' => 'text/plain', - 'options' => array( - ), - 'options_text' => __('Options'), - ); + 'options' => array(), + 'options_text' => __('Options') + ); - // general options - $plugin_list['mediawiki']['options'][] = array( - 'type' => 'begin_group', - 'name' => 'general_opts'); + // general options + $plugin_list['mediawiki']['options'][] = array( + 'type' => 'begin_group', + 'name' => 'general_opts' + ); - // what to dump (structure/data/both) - $plugin_list['mediawiki']['options'][] = array( - 'type' => 'begin_subgroup', - 'subgroup_header' => array( - 'type' => 'message_only', - 'text' => __('Dump table') - )); - $plugin_list['mediawiki']['options'][] = array( - 'type' => 'radio', - 'name' => 'structure_or_data', - 'values' => array( - 'structure' => __('structure'), - 'data' => __('data'), - 'structure_and_data' => __('structure and data') - )); - $plugin_list['mediawiki']['options'][] = array( - 'type' => 'end_subgroup' - ); + // what to dump (structure/data/both) + $plugin_list['mediawiki']['options'][] = array( + 'type' => 'begin_subgroup', + 'subgroup_header' => array( + 'type' => 'message_only', + 'text' => __('Dump table') + ) + ); + $plugin_list['mediawiki']['options'][] = array( + 'type' => 'radio', + 'name' => 'structure_or_data', + 'values' => array( + 'structure' => __('structure'), + 'data' => __('data'), + 'structure_and_data' => __('structure and data') + ) + ); + $plugin_list['mediawiki']['options'][] = array( + 'type' => 'end_subgroup' + ); - // export table name - $plugin_list['mediawiki']['options'][] = array( - 'type' => 'bool', - 'name' => 'caption', - 'text' => __('Export table names') - ); + // export table name + $plugin_list['mediawiki']['options'][] = array( + 'type' => 'bool', + 'name' => 'caption', + 'text' => __('Export table names') + ); - // export table headers - $plugin_list['mediawiki']['options'][] = array( - 'type' => 'bool', - 'name' => 'headers', - 'text' => __('Export table headers') - ); + // export table headers + $plugin_list['mediawiki']['options'][] = array( + 'type' => 'bool', + 'name' => 'headers', + 'text' => __('Export table headers') + ); - // end general options - $plugin_list['mediawiki']['options'][] = array( - 'type' => 'end_group' - ); + // end general options + $plugin_list['mediawiki']['options'][] = array( + 'type' => 'end_group' + ); } else { /** diff --git a/libraries/export/ods.php b/libraries/export/ods.php index c42be00cd2..ede3b24c86 100644 --- a/libraries/export/ods.php +++ b/libraries/export/ods.php @@ -19,30 +19,32 @@ if (isset($plugin_list)) { 'extension' => 'ods', 'mime_type' => 'application/vnd.oasis.opendocument.spreadsheet', 'force_file' => true, - 'options' => array( - array( - 'type' => 'begin_group', - 'name' => 'general_opts' - ), - array( - 'type' => 'text', - 'name' => 'null', - 'text' => __('Replace NULL with:') - ), - array( - 'type' => 'bool', - 'name' => 'columns', - 'text' => __('Put columns names in the first row') - ), - array( - 'type' => 'hidden', - 'name' => 'structure_or_data' - ), - array( - 'type' => 'end_group' - ), + 'options' => array(), + 'options_text' => __('Options') + ); + + $plugin_list['ods']['options'][] = array( + array( + 'type' => 'begin_group', + 'name' => 'general_opts' ), - 'options_text' => __('Options'), + array( + 'type' => 'text', + 'name' => 'null', + 'text' => __('Replace NULL with:') + ), + array( + 'type' => 'bool', + 'name' => 'columns', + 'text' => __('Put columns names in the first row') + ), + array( + 'type' => 'hidden', + 'name' => 'structure_or_data' + ), + array( + 'type' => 'end_group' + ) ); } else { diff --git a/libraries/export/odt.php b/libraries/export/odt.php index bd17590a41..8502136c86 100644 --- a/libraries/export/odt.php +++ b/libraries/export/odt.php @@ -25,8 +25,8 @@ if (isset($plugin_list)) { 'extension' => 'odt', 'mime_type' => 'application/vnd.oasis.opendocument.text', 'force_file' => true, - 'options' => array(), /* Filled later */ - 'options_text' => __('Options'), + 'options' => array(), + 'options_text' => __('Options') ); /* what to dump (structure/data/both) */ diff --git a/libraries/export/pdf.php b/libraries/export/pdf.php index 139612f4e0..13c0012bd1 100644 --- a/libraries/export/pdf.php +++ b/libraries/export/pdf.php @@ -19,32 +19,34 @@ if (isset($plugin_list)) { 'extension' => 'pdf', 'mime_type' => 'application/pdf', 'force_file' => true, - 'options' => array( - array( - 'type' => 'begin_group', - 'name' => 'general_opts' - ), - array( - 'type' => 'message_only', - 'name' => 'explanation', - 'text' => __( - '(Generates a report containing the data of a single table)' - ) - ), - array( - 'type' => 'text', - 'name' => 'report_title', - 'text' => __('Report title:') - ), - array( - 'type' => 'hidden', - 'name' => 'structure_or_data' - ), - array( - 'type' => 'end_group' + 'options' => array(), + 'options_text' => __('Options') + ); + + $plugin_list['pdf']['options'][] = array( + array( + 'type' => 'begin_group', + 'name' => 'general_opts' + ), + array( + 'type' => 'message_only', + 'name' => 'explanation', + 'text' => __( + '(Generates a report containing the data of a single table)' ) ), - 'options_text' => __('Options'), + array( + 'type' => 'text', + 'name' => 'report_title', + 'text' => __('Report title:') + ), + array( + 'type' => 'hidden', + 'name' => 'structure_or_data' + ), + array( + 'type' => 'end_group' + ) ); } else { diff --git a/libraries/export/php_array.php b/libraries/export/php_array.php index 174f4513cd..0e5629649e 100644 --- a/libraries/export/php_array.php +++ b/libraries/export/php_array.php @@ -18,18 +18,22 @@ if (isset($plugin_list)) { 'text' => __('PHP array'), 'extension' => 'php', 'mime_type' => 'text/plain', - 'options' => array( - array( - 'type' => 'begin_group', - 'name' => 'general_opts' - ), - array( - 'type' => 'hidden', - 'name' => 'structure_or_data', - ), - array('type' => 'end_group') + 'options' => array(), + 'options_text' => __('Options') + ); + + $plugin_list['php_array']['options'][] = array( + array( + 'type' => 'begin_group', + 'name' => 'general_opts' ), - 'options_text' => __('Options'), + array( + 'type' => 'hidden', + 'name' => 'structure_or_data', + ), + array( + 'type' => 'end_group' + ) ); } else { diff --git a/libraries/export/sql.php b/libraries/export/sql.php index 08397c0cf9..6f31f3e2ae 100644 --- a/libraries/export/sql.php +++ b/libraries/export/sql.php @@ -27,7 +27,8 @@ if (isset($plugin_list)) { 'text' => __('SQL'), 'extension' => 'sql', 'mime_type' => 'text/x-sql', - 'options' => array() + 'options' => array(), + 'options_text' => __('Options') ); $plugin_list['sql']['options'][] = array( @@ -103,8 +104,6 @@ if (isset($plugin_list)) { ) ); - $plugin_list['sql']['options_text'] = __('Options'); - /* compatibility maximization */ $compats = PMA_DBI_getCompatibilities(); if (count($compats) > 0) { diff --git a/libraries/export/texytext.php b/libraries/export/texytext.php index 3dc0cd3807..36f05d4349 100644 --- a/libraries/export/texytext.php +++ b/libraries/export/texytext.php @@ -18,46 +18,48 @@ if (isset($plugin_list)) { 'text' => __('Texy! text'), 'extension' => 'txt', 'mime_type' => 'text/plain', - 'options' => array( - /* what to dump (structure/data/both) */ - array( - 'type' => 'begin_group', - 'text' => __('Dump table'), - 'name' => 'general_opts' - ), - array( - 'type' => 'radio', - 'name' => 'structure_or_data', - 'values' => array( - 'structure' => __('structure'), - 'data' => __('data'), - 'structure_and_data' => __('structure and data') - ) - ), - array( - 'type' => 'end_group' - ), - array( - 'type' => 'begin_group', - 'name' => 'data', - 'text' => __('Data dump options'), - 'force' => 'structure' - ), - array( - 'type' => 'text', - 'name' => 'null', - 'text' => __('Replace NULL by') - ), - array( - 'type' => 'bool', - 'name' => 'columns', - 'text' => __('Put columns names in the first row') - ), - array( - 'type' => 'end_group' - ), + 'options' => array(), + 'options_text' => __('Options') + ); + + $plugin_list['texytext']['options'][] = array( + /* what to dump (structure/data/both) */ + array( + 'type' => 'begin_group', + 'text' => __('Dump table'), + 'name' => 'general_opts' ), - 'options_text' => __('Options'), + array( + 'type' => 'radio', + 'name' => 'structure_or_data', + 'values' => array( + 'structure' => __('structure'), + 'data' => __('data'), + 'structure_and_data' => __('structure and data') + ) + ), + array( + 'type' => 'end_group' + ), + array( + 'type' => 'begin_group', + 'name' => 'data', + 'text' => __('Data dump options'), + 'force' => 'structure' + ), + array( + 'type' => 'text', + 'name' => 'null', + 'text' => __('Replace NULL by') + ), + array( + 'type' => 'bool', + 'name' => 'columns', + 'text' => __('Put columns names in the first row') + ), + array( + 'type' => 'end_group' + ) ); } else { diff --git a/libraries/export/xml.php b/libraries/export/xml.php index aefc2617ca..8878c35e1d 100644 --- a/libraries/export/xml.php +++ b/libraries/export/xml.php @@ -19,22 +19,24 @@ if (isset($plugin_list)) { 'text' => __('XML'), 'extension' => 'xml', 'mime_type' => 'text/xml', - 'options' => array( - array( - 'type' => 'begin_group', - 'name' => 'general_opts' - ), - array( - 'type' => 'hidden', - 'name' => 'structure_or_data' - ), - array( - 'type' => 'end_group' - ) - ), + 'options' => array(), 'options_text' => __('Options') ); + $plugin_list['xml']['options'][] = array( + array( + 'type' => 'begin_group', + 'name' => 'general_opts' + ), + array( + 'type' => 'hidden', + 'name' => 'structure_or_data' + ), + array( + 'type' => 'end_group' + ) + ); + /* Export structure */ $plugin_list['xml']['options'][] = array( 'type' => 'begin_group', diff --git a/libraries/export/yaml.php b/libraries/export/yaml.php index 6882afa021..7a6b74bd49 100644 --- a/libraries/export/yaml.php +++ b/libraries/export/yaml.php @@ -19,20 +19,22 @@ if (isset($plugin_list)) { 'extension' => 'yml', 'mime_type' => 'text/yaml', 'force_file' => true, - 'options' => array( - array( - 'type' => 'begin_group', - 'name' => 'general_opts' - ), - array( - 'type' => 'hidden', - 'name' => 'structure_or_data', - ), - array( - 'type' => 'end_group' - ) + 'options' => array(), + 'options_text' => __('Options') + ); + + $plugin_list['yaml']['options'][] = array( + array( + 'type' => 'begin_group', + 'name' => 'general_opts' ), - 'options_text' => __('Options'), + array( + 'type' => 'hidden', + 'name' => 'structure_or_data', + ), + array( + 'type' => 'end_group' + ) ); } else {