From bd8326a077bc1ab2b37eeede2a9043a19bb9d596 Mon Sep 17 00:00:00 2001 From: Alex Marin Date: Tue, 1 May 2012 17:23:36 +0300 Subject: [PATCH] Export htmlword coding style: wrap long lines --- libraries/export/htmlword.php | 242 ++++++++++++++++++++++++++-------- 1 file changed, 186 insertions(+), 56 deletions(-) diff --git a/libraries/export/htmlword.php b/libraries/export/htmlword.php index 30b6b37b52..6a8bdf9df8 100644 --- a/libraries/export/htmlword.php +++ b/libraries/export/htmlword.php @@ -21,17 +21,47 @@ if (isset($plugin_list)) { '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'), - /* 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'), + 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' + ), + + /* 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' + ), + ), 'options_text' => __('Options'), - ); + ); } else { /** @@ -61,10 +91,12 @@ if (isset($plugin_list)) { xmlns:x="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-html40"> - + - + ' ); @@ -81,7 +113,9 @@ if (isset($plugin_list)) { */ function PMA_exportDBHeader($db) { - return PMA_exportOutputHandler('

' . __('Database') . ' ' . htmlspecialchars($db) . '

'); + return PMA_exportOutputHandler( + '

' . __('Database') . ' ' . htmlspecialchars($db) . '

' + ); } /** @@ -129,10 +163,16 @@ if (isset($plugin_list)) { { global $what; - if (! PMA_exportOutputHandler('

' . __('Dumping data for table') . ' ' . htmlspecialchars($table) . '

')) { + if (! PMA_exportOutputHandler( + '

' + . __('Dumping data for table') . ' ' . htmlspecialchars($table) + . '

' + )) { return false; } - if (! PMA_exportOutputHandler('')) { + if (! PMA_exportOutputHandler( + '
' + )) { return false; } @@ -144,7 +184,11 @@ if (isset($plugin_list)) { if (isset($GLOBALS['htmlword_columns'])) { $schema_insert = ''; for ($i = 0; $i < $fields_cnt; $i++) { - $schema_insert .= ''; + $schema_insert .= ''; } // end for $schema_insert .= ''; if (! PMA_exportOutputHandler($schema_insert)) { @@ -163,7 +207,9 @@ if (isset($plugin_list)) { } else { $value = ''; } - $schema_insert .= ''; + $schema_insert .= ''; } // end for $schema_insert .= ''; if (! PMA_exportOutputHandler($schema_insert)) { @@ -195,10 +241,18 @@ if (isset($plugin_list)) { $columns_cnt = 4; $schema_insert .= ''; - $schema_insert .= ''; - $schema_insert .= ''; - $schema_insert .= ''; - $schema_insert .= ''; + $schema_insert .= ''; + $schema_insert .= ''; + $schema_insert .= ''; + $schema_insert .= ''; $schema_insert .= ''; /** @@ -230,22 +284,34 @@ if (isset($plugin_list)) { * @param string $crlf the end of line sequence * @param string $error_url the url to go back in case of error * @param bool $do_relation whether to include relation comments - * @param bool $do_comments whether to include the pmadb-style column comments - * as comments in the structure; this is deprecated - * but the parameter is left here because export.php - * calls PMA_exportStructure() also for other export - * types which use this parameter + * @param bool $do_comments whether to include the pmadb-style column + * comments as comments in the structure; + * this is deprecated but the parameter is + * left here because export.php calls + * PMA_exportStructure() also for other + * export types which use this parameter * @param bool $do_mime whether to include mime comments * @param bool $show_dates whether to include creation/update/check dates - * @param bool $add_semicolon whether to add semicolon and end-of-line at the end + * @param bool $add_semicolon whether to add semicolon and end-of-line + * at the end * @param bool $view whether we're handling a view * * @return string resulting schema * * @access public */ - function PMA_getTableDef($db, $table, $crlf, $error_url, $do_relation, $do_comments, $do_mime, $show_dates = false, $add_semicolon = true, $view = false) - { + function PMA_getTableDef( + $db, + $table, + $crlf, + $error_url, + $do_relation, + $do_comments, + $do_mime, + $show_dates = false, + $add_semicolon = true, + $view = false + ) { global $cfgRelation; $schema_insert = ''; @@ -287,19 +353,33 @@ if (isset($plugin_list)) { } $schema_insert .= ''; - $schema_insert .= ''; - $schema_insert .= ''; - $schema_insert .= ''; - $schema_insert .= ''; + $schema_insert .= ''; + $schema_insert .= ''; + $schema_insert .= ''; + $schema_insert .= ''; if ($do_relation && $have_rel) { - $schema_insert .= ''; + $schema_insert .= ''; } if ($do_comments) { - $schema_insert .= ''; + $schema_insert .= ''; $comments = PMA_getComments($db, $table); } if ($do_mime && $cfgRelation['mimework']) { - $schema_insert .= ''; + $schema_insert .= ''; $mime_map = PMA_getMIME($db, $table, true); } $schema_insert .= ''; @@ -320,13 +400,28 @@ if (isset($plugin_list)) { $field_name = $column['Field']; if ($do_relation && $have_rel) { - $schema_insert .= ''; + $schema_insert .= ''; } if ($do_comments && $cfgRelation['commwork']) { - $schema_insert .= ''; + $schema_insert .= ''; } if ($do_mime && $cfgRelation['mimework']) { - $schema_insert .= ''; + $schema_insert .= ''; } $schema_insert .= ''; @@ -360,10 +455,18 @@ if (isset($plugin_list)) { foreach ($triggers as $trigger) { $dump .= ''; - $dump .= ''; - $dump .= ''; - $dump .= ''; - $dump .= ''; + $dump .= ''; + $dump .= ''; + $dump .= ''; + $dump .= ''; $dump .= ''; } @@ -372,6 +475,7 @@ if (isset($plugin_list)) { } /** + * Outputs table's structure * * @param string $db database name @@ -379,43 +483,69 @@ if (isset($plugin_list)) { * @param string $crlf the end of line sequence * @param string $error_url the url to go back in case of error * @param bool $do_relation whether to include relation comments - * @param bool $do_comments whether to include the pmadb-style column comments - * as comments in the structure; this is deprecated - * but the parameter is left here because export.php - * calls PMA_exportStructure() also for other export - * types which use this parameter + * @param bool $do_comments whether to include the pmadb-style column + * comments as comments in the structure; + * this is deprecated but the parameter is + * left here because export.php calls + * PMA_exportStructure() also for other + * export types which use this parameter * @param bool $do_mime whether to include mime comments * @param bool $dates whether to include creation/update/check dates - * @param string $export_mode 'create_table', 'triggers', 'create_view', 'stand_in' + * @param string $export_mode 'create_table', 'triggers', 'create_view', + * 'stand_in' * @param string $export_type 'server', 'database', 'table' * * @return bool Whether it succeeded * * @access public */ - function PMA_exportStructure($db, $table, $crlf, $error_url, $do_relation = false, $do_comments = false, $do_mime = false, $dates = false, $export_mode, $export_type) - { + function PMA_exportStructure( + $db, + $table, + $crlf, + $error_url, + $do_relation = false, + $do_comments = false, + $do_mime = false, + $dates = false, + $export_mode, + $export_type + ) { $dump = ''; switch($export_mode) { case 'create_table': - $dump .= '

' . __('Table structure for table') . ' ' . htmlspecialchars($table) . '

'; - $dump .= PMA_getTableDef($db, $table, $crlf, $error_url, $do_relation, $do_comments, $do_mime, $dates); + $dump .= '

' + . __('Table structure for table') . ' ' . htmlspecialchars($table) + . '

'; + $dump .= PMA_getTableDef( + $db, $table, $crlf, $error_url, $do_relation, $do_comments, $do_mime, + $dates + ); break; case 'triggers': $dump = ''; $triggers = PMA_DBI_get_triggers($db, $table); if ($triggers) { - $dump .= '

' . __('Triggers') . ' ' . htmlspecialchars($table) . '

'; + $dump .= '

' + . __('Triggers') . ' ' . htmlspecialchars($table) + . '

'; $dump .= PMA_getTriggers($db, $table); } break; case 'create_view': - $dump .= '

' . __('Structure for view') . ' ' . htmlspecialchars($table) . '

'; - $dump .= PMA_getTableDef($db, $table, $crlf, $error_url, $do_relation, $do_comments, $do_mime, $dates, true, true); + $dump .= '

' + . __('Structure for view') . ' ' . htmlspecialchars($table) + . '

'; + $dump .= PMA_getTableDef( + $db, $table, $crlf, $error_url, $do_relation, $do_comments, $do_mime, + $dates, true, true + ); break; case 'stand_in': - $dump .= '

' . __('Stand-in structure for view') . ' ' . htmlspecialchars($table) . '

'; + $dump .= '

' + . __('Stand-in structure for view') . ' ' . htmlspecialchars($table) + . '

'; // export a stand-in definition to resolve view dependencies $dump .= PMA_getTableDefStandIn($db, $table, $crlf); } // end switch
' . htmlspecialchars($value) . '' + . htmlspecialchars($value) + . '
' . (isset($res_rel[$field_name]) ? htmlspecialchars($res_rel[$field_name]['foreign_table'] . ' (' . $res_rel[$field_name]['foreign_field'] . ')') : '') . '' + . (isset($res_rel[$field_name]) + ? htmlspecialchars( + $res_rel[$field_name]['foreign_table'] + . ' (' . $res_rel[$field_name]['foreign_field'] + . ')' + ) + : '') . '' . (isset($comments[$field_name]) ? htmlspecialchars($comments[$field_name]) : '') . '' + . (isset($comments[$field_name]) + ? htmlspecialchars($comments[$field_name]) + : '') . '' . (isset($mime_map[$field_name]) ? htmlspecialchars(str_replace('_', '/', $mime_map[$field_name]['mimetype'])) : '') . '' + . (isset($mime_map[$field_name]) ? + htmlspecialchars( + str_replace('_', '/', $mime_map[$field_name]['mimetype']) + ) + : '') . '