From 6c6f9b405e1c480e7c1011192705431182b1a017 Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Thu, 10 May 2012 00:28:59 +0530 Subject: [PATCH 1/2] Fix documentation comments --- libraries/Theme.class.php | 88 ++++++++++++++++++---------- libraries/string.lib.php | 16 ++--- libraries/string_mb.lib.php | 22 +++---- libraries/string_native.lib.php | 22 +++---- libraries/string_type_ctype.lib.php | 28 ++++----- libraries/string_type_native.lib.php | 36 ++++++------ libraries/sysinfo.lib.php | 7 ++- 7 files changed, 123 insertions(+), 96 deletions(-) diff --git a/libraries/Theme.class.php b/libraries/Theme.class.php index 89e2f2105d..96176b7522 100644 --- a/libraries/Theme.class.php +++ b/libraries/Theme.class.php @@ -12,9 +12,11 @@ if (! defined('PHPMYADMIN')) { /** * handles theme * - * @todo add the possibility to make a theme depend on another theme and by default on original + * @todo add the possibility to make a theme depend on another theme + * and by default on original * @todo make all components optional - get missing components from 'parent' theme - * @todo make css optionally replacing 'parent' css or extending it (by appending at the end) + * @todo make css optionally replacing 'parent' css or extending it + * (by appending at the end) * @todo add an optional global css file - which will be used for both frames * * @package PhpMyAdmin @@ -72,8 +74,10 @@ class PMA_Theme var $filesize_info = 0; /** + * Loads theme information + * + * @return boolean whether loading them info was successful or not * * @access public - * @return boolean whether loading them info was successful or not */ function loadInfo() { @@ -109,11 +113,11 @@ class PMA_Theme * returns theme object loaded from given folder * or false if theme is invalid * - * @static - * @access public - * @param string $folder path to theme + * @param string $folder path to theme * - * @return object PMA_Theme + * @return object PMA_Theme + * @static + * @access public */ static public function load($folder) { @@ -146,7 +150,10 @@ class PMA_Theme return true; } else { trigger_error( - sprintf(__('No valid image path for theme %s found!'), $this->getName()), + sprintf( + __('No valid image path for theme %s found!'), + $this->getName() + ), E_USER_ERROR ); return false; @@ -178,8 +185,10 @@ class PMA_Theme /** * set path to theme * - * @access public - * @param string $path path to theme + * @param string $path path to theme + * + * @return void + * @access public */ function setPath($path) { @@ -189,8 +198,10 @@ class PMA_Theme /** * sets version * - * @access public - * @param string new version + * @param string $version version to set + * + * @return void + * @access public */ function setVersion($version) { @@ -200,8 +211,8 @@ class PMA_Theme /** * returns version * + * @return string version * @access public - * @return string version */ function getVersion() { @@ -212,10 +223,10 @@ class PMA_Theme * checks theme version agaisnt $version * returns true if theme version is equal or higher to $version * - * @access public - * @param string $version version to compare to + * @param string $version version to compare to * - * @return boolean + * @return boolean true if theme version is equal or higher to $version + * @access public */ function checkVersion($version) { @@ -225,8 +236,10 @@ class PMA_Theme /** * sets name * - * @access public - * @param string $name new name + * @param string $name name to set + * + * @return void + * @access public */ function setName($name) { @@ -247,8 +260,10 @@ class PMA_Theme /** * sets id * - * @access public - * @param string $id new id + * @param string $id new id + * + * @return void + * @access public */ function setId($id) { @@ -258,8 +273,8 @@ class PMA_Theme /** * returns id * - * @access public - * @return string id + * @return string id + * @access public */ function getId() { @@ -267,8 +282,12 @@ class PMA_Theme } /** - * @access public - * @param string path to images for this theme + * Sets path to images for the theme + * + * @param string $path path to images for this theme + * + * @return void + * @access public */ function setImgPath($path) { @@ -276,7 +295,9 @@ class PMA_Theme } /** - * @access public + * Returns the path to images for the theme + * + * @access public * @return string image path for this theme */ function getImgPath() @@ -287,10 +308,10 @@ class PMA_Theme /** * load css (send to stdout, normally the browser) * - * @access public - * @param string $type left, right or print + * @param string &$type left, right or print * * @return bool + * @access public */ function loadCss(&$type) { @@ -322,8 +343,10 @@ class PMA_Theme if ($type != 'print') { $_sprites_data_file = $this->getPath() . '/sprites.lib.php'; $_sprites_css_file = './themes/sprites.css.php'; - if ( (file_exists($_sprites_data_file) && is_readable($_sprites_data_file)) - && (file_exists($_sprites_css_file) && is_readable($_sprites_css_file)) + if (file_exists($_sprites_data_file) + && is_readable($_sprites_data_file) + && file_exists($_sprites_css_file) + && is_readable($_sprites_css_file) ) { include $_sprites_data_file; include $_sprites_css_file; @@ -336,7 +359,8 @@ class PMA_Theme /** * prints out the preview for this theme * - * @access public + * @return void + * @access public */ function printPreview() { @@ -371,7 +395,9 @@ class PMA_Theme */ function getCssIEClearFilter() { - return PMA_USR_BROWSER_AGENT == 'IE' && PMA_USR_BROWSER_VER >= 6 && PMA_USR_BROWSER_VER <= 8 + return PMA_USR_BROWSER_AGENT == 'IE' + && PMA_USR_BROWSER_VER >= 6 + && PMA_USR_BROWSER_VER <= 8 ? 'filter: none' : ''; } diff --git a/libraries/string.lib.php b/libraries/string.lib.php index b62eb7e860..604501689f 100644 --- a/libraries/string.lib.php +++ b/libraries/string.lib.php @@ -38,9 +38,9 @@ if (@extension_loaded('ctype')) { /** * Checks if a given character position in the string is escaped or not * - * @param string string to check for - * @param integer the character to check for - * @param integer starting position in the string + * @param string $string string to check for + * @param integer $pos the character to check for + * @param integer $start starting position in the string * * @return boolean whether the character is escaped or not */ @@ -70,9 +70,9 @@ function PMA_STR_charIsEscaped($string, $pos, $start = 0) /** * Checks if a number is in a range * - * @param integer number to check for - * @param integer lower bound - * @param integer upper bound + * @param integer $num number to check for + * @param integer $lower lower bound + * @param integer $upper upper bound * * @return boolean whether the number is in the range or not */ @@ -84,8 +84,8 @@ function PMA_STR_numberInRangeInclusive($num, $lower, $upper) /** * Checks if a character is an SQL identifier * - * @param string character to check for - * @param boolean whether the dot character is valid or not + * @param string $c character to check for + * @param boolean $dot_is_valid whether the dot character is valid or not * * @return boolean whether the character is an SQL identifier or not */ diff --git a/libraries/string_mb.lib.php b/libraries/string_mb.lib.php index 98ece6d562..452debf1e5 100644 --- a/libraries/string_mb.lib.php +++ b/libraries/string_mb.lib.php @@ -19,9 +19,9 @@ if (! defined('PHPMYADMIN')) { /** * Returns length of string depending on current charset. * - * @param string string to count + * @param string $string string to count * - * @return int string length + * @return int string length */ function PMA_strlen($string) { @@ -31,11 +31,11 @@ function PMA_strlen($string) /** * Returns substring from string, works depending on current charset. * - * @param string $string string to count - * @param int $start start of substring - * @param int $length length of substring + * @param string $string string to count + * @param int $start start of substring + * @param int $length length of substring * - * @return string + * @return string the sub string */ function PMA_substr($string, $start, $length = 2147483647) { @@ -45,9 +45,9 @@ function PMA_substr($string, $start, $length = 2147483647) /** * Returns postion of $needle in $haystack or false if not found * - * @param string $haystack - * @param string $needle - * @param int $offset + * @param string $haystack the string being checked + * @param string $needle the string to find in haystack + * @param int $offset the search offset * * @return integer position of $needle in $haystack or false */ @@ -59,9 +59,9 @@ function PMA_strpos($haystack, $needle, $offset = 0) /** * Make a string lowercase * - * @param string $string + * @param string $string the string being lowercased * - * @return string + * @return string the lower case string */ function PMA_strtolower($string) { diff --git a/libraries/string_native.lib.php b/libraries/string_native.lib.php index f1db1b8d67..4154959efc 100644 --- a/libraries/string_native.lib.php +++ b/libraries/string_native.lib.php @@ -19,9 +19,9 @@ if (! defined('PHPMYADMIN')) { /** * Returns length of string depending on current charset. * - * @param string string to count + * @param string $string string to count * - * @return int string length + * @return int string length */ function PMA_strlen($string) { @@ -31,11 +31,11 @@ function PMA_strlen($string) /** * Returns substring from string, works depending on current charset. * - * @param string $string string to count - * @param int $start start of substring - * @param int $length length of substring + * @param string $string string to count + * @param int $start start of substring + * @param int $length length of substring * - * @return string + * @return string the sub string */ function PMA_substr($string, $start, $length = 2147483647) { @@ -45,9 +45,9 @@ function PMA_substr($string, $start, $length = 2147483647) /** * Returns postion of $needle in $haystack or false if not found * - * @param string $haystack - * @param string $needle - * @param int $offset + * @param string $haystack the string being checked + * @param string $needle the string to find in haystack + * @param int $offset the search offset * * @return integer position of $needle in $haystack or false */ @@ -59,9 +59,9 @@ function PMA_strpos($haystack, $needle, $offset = 0) /** * Make a string lowercase * - * @param string $string + * @param string $string the string being lowercased * - * @return string + * @return string the lower case string */ function PMA_strtolower($string) { diff --git a/libraries/string_type_ctype.lib.php b/libraries/string_type_ctype.lib.php index 95dfd2a003..12469baf3a 100644 --- a/libraries/string_type_ctype.lib.php +++ b/libraries/string_type_ctype.lib.php @@ -19,9 +19,9 @@ if (! defined('PHPMYADMIN')) { /** * Checks if a character is an alphanumeric one * - * @param string character to check for + * @param string $c character to check for * - * @return boolean whether the character is an alphanumeric one or not + * @return boolean whether the character is an alphanumeric one or not */ function PMA_STR_isAlnum($c) { @@ -31,9 +31,9 @@ function PMA_STR_isAlnum($c) /** * Checks if a character is an alphabetic one * - * @param string character to check for + * @param string $c character to check for * - * @return boolean whether the character is an alphabetic one or not + * @return boolean whether the character is an alphabetic one or not */ function PMA_STR_isAlpha($c) { @@ -43,9 +43,9 @@ function PMA_STR_isAlpha($c) /** * Checks if a character is a digit * - * @param string character to check for + * @param string $c character to check for * - * @return boolean whether the character is a digit or not + * @return boolean whether the character is a digit or not */ function PMA_STR_isDigit($c) { @@ -55,9 +55,9 @@ function PMA_STR_isDigit($c) /** * Checks if a character is an upper alphabetic one * - * @param string character to check for + * @param string $c character to check for * - * @return boolean whether the character is an upper alphabetic one or not + * @return boolean whether the character is an upper alphabetic one or not */ function PMA_STR_isUpper($c) { @@ -68,9 +68,9 @@ function PMA_STR_isUpper($c) /** * Checks if a character is a lower alphabetic one * - * @param string character to check for + * @param string $c character to check for * - * @return boolean whether the character is a lower alphabetic one or not + * @return boolean whether the character is a lower alphabetic one or not */ function PMA_STR_isLower($c) { @@ -80,9 +80,9 @@ function PMA_STR_isLower($c) /** * Checks if a character is a space one * - * @param string character to check for + * @param string $c character to check for * - * @return boolean whether the character is a space one or not + * @return boolean whether the character is a space one or not */ function PMA_STR_isSpace($c) { @@ -92,9 +92,9 @@ function PMA_STR_isSpace($c) /** * Checks if a character is an hexadecimal digit * - * @param string character to check for + * @param string $c character to check for * - * @return boolean whether the character is an hexadecimal digit or not + * @return boolean whether the character is an hexadecimal digit or not */ function PMA_STR_isHexDigit($c) { diff --git a/libraries/string_type_native.lib.php b/libraries/string_type_native.lib.php index 808ae20db1..4267a1923d 100644 --- a/libraries/string_type_native.lib.php +++ b/libraries/string_type_native.lib.php @@ -19,9 +19,9 @@ if (! defined('PHPMYADMIN')) { /** * Checks if a character is an alphanumeric one * - * @param string character to check for + * @param string $c character to check for * - * @return boolean whether the character is an alphanumeric one or not + * @return boolean whether the character is an alphanumeric one or not */ function PMA_STR_isAlnum($c) { @@ -31,9 +31,9 @@ function PMA_STR_isAlnum($c) /** * Checks if a character is an alphabetic one * - * @param string character to check for + * @param string $c character to check for * - * @return boolean whether the character is an alphabetic one or not + * @return boolean whether the character is an alphabetic one or not */ function PMA_STR_isAlpha($c) { @@ -43,9 +43,9 @@ function PMA_STR_isAlpha($c) /** * Checks if a character is a digit * - * @param string character to check for + * @param string $c character to check for * - * @return boolean whether the character is a digit or not + * @return boolean whether the character is a digit or not */ function PMA_STR_isDigit($c) { @@ -59,9 +59,9 @@ function PMA_STR_isDigit($c) /** * Checks if a character is an upper alphabetic one * - * @param string character to check for + * @param string $c character to check for * - * @return boolean whether the character is an upper alphabetic one or not + * @return boolean whether the character is an upper alphabetic one or not */ function PMA_STR_isUpper($c) { @@ -75,9 +75,9 @@ function PMA_STR_isUpper($c) /** * Checks if a character is a lower alphabetic one * - * @param string character to check for + * @param string $c character to check for * - * @return boolean whether the character is a lower alphabetic one or not + * @return boolean whether the character is a lower alphabetic one or not */ function PMA_STR_isLower($c) { @@ -91,9 +91,9 @@ function PMA_STR_isLower($c) /** * Checks if a character is a space one * - * @param string character to check for + * @param string $c character to check for * - * @return boolean whether the character is a space one or not + * @return boolean whether the character is a space one or not */ function PMA_STR_isSpace($c) { @@ -104,16 +104,16 @@ function PMA_STR_isSpace($c) $ord_c = ord($c); return ($ord_c == $ord_space - || $ord_c == $ord_NOBR - || PMA_STR_numberInRangeInclusive($ord_c, $ord_tab, $ord_CR)); + || $ord_c == $ord_NOBR + || PMA_STR_numberInRangeInclusive($ord_c, $ord_tab, $ord_CR)); } // end of the "PMA_STR_isSpace()" function /** * Checks if a character is an hexadecimal digit * - * @param string character to check for + * @param string $c character to check for * - * @return boolean whether the character is an hexadecimal digit or not + * @return boolean whether the character is an hexadecimal digit or not */ function PMA_STR_isHexDigit($c) { @@ -126,8 +126,8 @@ function PMA_STR_isHexDigit($c) $ord_c = ord($c); return (PMA_STR_numberInRangeInclusive($ord_c, $ord_zero, $ord_nine) - || PMA_STR_numberInRangeInclusive($ord_c, $ord_Aupper, $ord_Fupper) - || PMA_STR_numberInRangeInclusive($ord_c, $ord_Alower, $ord_Flower)); + || PMA_STR_numberInRangeInclusive($ord_c, $ord_Aupper, $ord_Fupper) + || PMA_STR_numberInRangeInclusive($ord_c, $ord_Alower, $ord_Flower)); } // end of the "PMA_STR_isHexDigit()" function ?> diff --git a/libraries/sysinfo.lib.php b/libraries/sysinfo.lib.php index a0538c63c7..fcb6487298 100644 --- a/libraries/sysinfo.lib.php +++ b/libraries/sysinfo.lib.php @@ -1,10 +1,11 @@ Date: Thu, 10 May 2012 00:31:15 +0530 Subject: [PATCH 2/2] Coding style improvements --- libraries/tbl_common.inc.php | 4 +- libraries/tbl_info.inc.php | 11 ++- libraries/tbl_properties.inc.php | 140 ++++++++++++++++----------- libraries/tbl_replace_fields.inc.php | 9 +- libraries/tbl_select.lib.php | 99 ++++++++++++------- 5 files changed, 168 insertions(+), 95 deletions(-) diff --git a/libraries/tbl_common.inc.php b/libraries/tbl_common.inc.php index 8a7db62744..d903dc9125 100644 --- a/libraries/tbl_common.inc.php +++ b/libraries/tbl_common.inc.php @@ -1,6 +1,7 @@ $db,)); +$err_url_0 = $cfg['DefaultTabDatabase'] + . PMA_generate_common_url(array('db' => $db,)); $err_url = $cfg['DefaultTabTable'] . PMA_generate_common_url($url_params); diff --git a/libraries/tbl_info.inc.php b/libraries/tbl_info.inc.php index cea1bc0f6f..fb01dcdcae 100644 --- a/libraries/tbl_info.inc.php +++ b/libraries/tbl_info.inc.php @@ -43,7 +43,12 @@ $GLOBALS['showtable'] = array(); // we force reading of the current table status // if $reread_info is true (for example, coming from tbl_operations.php // and we just changed the table's storage engine) -$GLOBALS['showtable'] = PMA_Table::sGetStatusInfo($GLOBALS['db'], $GLOBALS['table'], null, (isset($reread_info) && $reread_info ? true : false)); +$GLOBALS['showtable'] = PMA_Table::sGetStatusInfo( + $GLOBALS['db'], + $GLOBALS['table'], + null, + (isset($reread_info) && $reread_info ? true : false) +); // need this test because when we are creating a table, we get 0 rows // from the SHOW TABLE query @@ -98,7 +103,9 @@ if ($showtable) { } } // we need explicit DEFAULT value here (different from '0') - $pack_keys = (! isset($pack_keys) || strlen($pack_keys) == 0) ? 'DEFAULT' : $pack_keys; + $pack_keys = (! isset($pack_keys) || strlen($pack_keys) == 0) + ? 'DEFAULT' + : $pack_keys; unset($create_options, $each_create_option); } // end if ?> diff --git a/libraries/tbl_properties.inc.php b/libraries/tbl_properties.inc.php index 1c90c2ba50..efe3555297 100644 --- a/libraries/tbl_properties.inc.php +++ b/libraries/tbl_properties.inc.php @@ -1,9 +1,9 @@ If you ever need to put a backslash ("\") or a single quote ("\'") amongst those values, precede it with a backslash (for example \'\\\\xyz\' or \'a\\\'b\').')); + . PMA_showMySQLDocu('SQL-Syntax', 'data-types'); +$header_cells[] = __('Length/Values') + . PMA_showHint(__('If column type is "enum" or "set", please enter the values using this format: \'a\',\'b\',\'c\'...
If you ever need to put a backslash ("\") or a single quote ("\'") amongst those values, precede it with a backslash (for example \'\\\\xyz\' or \'a\\\'b\').')); $header_cells[] = __('Default') . PMA_showHint(__('For default values, please enter just a single value, without backslash escaping or quotes, using this format: a')); $header_cells[] = __('Collation'); $header_cells[] = __('Attributes'); @@ -153,26 +154,46 @@ for ($i = 0; $i < $num_fields; $i++) { // An error happened with previous inputs, so we will restore the data // to embed it once again in this form. - $row['Field'] = (isset($_REQUEST['field_name'][$i]) ? $_REQUEST['field_name'][$i] : false); - $row['Type'] = (isset($_REQUEST['field_type'][$i]) ? $_REQUEST['field_type'][$i] : false); - $row['Collation'] = (isset($_REQUEST['field_collation'][$i]) ? $_REQUEST['field_collation'][$i] : ''); - $row['Null'] = (isset($_REQUEST['field_null'][$i]) ? $_REQUEST['field_null'][$i] : ''); + $row['Field'] = isset($_REQUEST['field_name'][$i]) + ? $_REQUEST['field_name'][$i] + : false; + $row['Type'] = isset($_REQUEST['field_type'][$i]) + ? $_REQUEST['field_type'][$i] + : false; + $row['Collation'] = isset($_REQUEST['field_collation'][$i]) + ? $_REQUEST['field_collation'][$i] + : ''; + $row['Null'] = isset($_REQUEST['field_null'][$i]) + ? $_REQUEST['field_null'][$i] + : ''; - if (isset($_REQUEST['field_key'][$i]) && $_REQUEST['field_key'][$i] == 'primary_' . $i) { + if (isset($_REQUEST['field_key'][$i]) + && $_REQUEST['field_key'][$i] == 'primary_' . $i + ) { $row['Key'] = 'PRI'; - } elseif (isset($_REQUEST['field_key'][$i]) && $_REQUEST['field_key'][$i] == 'index_' . $i) { + } elseif (isset($_REQUEST['field_key'][$i]) + && $_REQUEST['field_key'][$i] == 'index_' . $i + ) { $row['Key'] = 'MUL'; - } elseif (isset($_REQUEST['field_key'][$i]) && $_REQUEST['field_key'][$i] == 'unique_' . $i) { + } elseif (isset($_REQUEST['field_key'][$i]) + && $_REQUEST['field_key'][$i] == 'unique_' . $i + ) { $row['Key'] = 'UNI'; - } elseif (isset($_REQUEST['field_key'][$i]) && $_REQUEST['field_key'][$i] == 'fulltext_' . $i) { + } elseif (isset($_REQUEST['field_key'][$i]) + && $_REQUEST['field_key'][$i] == 'fulltext_' . $i + ) { $row['Key'] = 'FULLTEXT'; } else { $row['Key'] = ''; } // put None in the drop-down for Default, when someone adds a field - $row['DefaultType'] = (isset($_REQUEST['field_default_type'][$i]) ? $_REQUEST['field_default_type'][$i] : 'NONE'); - $row['DefaultValue'] = (isset($_REQUEST['field_default_value'][$i]) ? $_REQUEST['field_default_value'][$i] : ''); + $row['DefaultType'] = isset($_REQUEST['field_default_type'][$i]) + ? $_REQUEST['field_default_type'][$i] + : 'NONE'; + $row['DefaultValue'] = isset($_REQUEST['field_default_value'][$i]) + ? $_REQUEST['field_default_value'][$i] + : ''; switch ($row['DefaultType']) { case 'NONE' : @@ -221,12 +242,12 @@ for ($i = 0; $i < $num_fields; $i++) { if (isset($_REQUEST['field_transformation'][$i])) { $mime_map[$row['Field']]['transformation'] - = $_REQUEST['field_transformation'][$i]; + = $_REQUEST['field_transformation'][$i]; } if (isset($_REQUEST['field_transformation_options'][$i])) { $mime_map[$row['Field']]['transformation_options'] - = $_REQUEST['field_transformation_options'][$i]; + = $_REQUEST['field_transformation_options'][$i]; } } elseif (isset($fields_meta[$i])) { @@ -340,7 +361,8 @@ for ($i = 0; $i < $num_fields; $i++) { . '"' . ' type="text" name="field_length[' . $i . ']" size="' . $length_values_input_size . '"' . ' value="' . htmlspecialchars( $length_to_display - ) . '"' + ) + . '"' . ' class="textfield" />' . '

'; @@ -370,8 +392,8 @@ for ($i = 0; $i < $num_fields; $i++) { // for a TIMESTAMP, do not show the string "CURRENT_TIMESTAMP" as a default value if ($type_upper == 'TIMESTAMP' - && ! empty($default_current_timestamp) - && isset($row['Default']) + && ! empty($default_current_timestamp) + && isset($row['Default']) ) { $row['Default'] = ''; } @@ -433,10 +455,8 @@ for ($i = 0; $i < $num_fields; $i++) { if (PMA_MYSQL_INT_VERSION < 50025 && isset($row['Field']) && isset($analyzed_sql[0]['create_table_fields'][$row['Field']]['type']) - && $analyzed_sql[0]['create_table_fields'][$row['Field']]['type'] - == 'TIMESTAMP' - && $analyzed_sql[0]['create_table_fields'][$row['Field']] - ['timestamp_not_null'] == true + && $analyzed_sql[0]['create_table_fields'][$row['Field']]['type'] == 'TIMESTAMP' + && $analyzed_sql[0]['create_table_fields'][$row['Field']]['timestamp_not_null'] == true ) { $row['Null'] = ''; } @@ -444,16 +464,14 @@ for ($i = 0; $i < $num_fields; $i++) { // MySQL 4.1.2+ TIMESTAMP options // (if on_update_current_timestamp is set, then it's TRUE) if (isset($row['Field']) - && isset($analyzed_sql[0]['create_table_fields'][$row['Field']] - ['on_update_current_timestamp']) + && isset($analyzed_sql[0]['create_table_fields'][$row['Field']]['on_update_current_timestamp']) ) { $attribute = 'on update CURRENT_TIMESTAMP'; } if ((isset($row['Field']) - && isset($analyzed_sql[0]['create_table_fields'][$row['Field']] - ['default_current_timestamp'])) + && isset($analyzed_sql[0]['create_table_fields'][$row['Field']]['default_current_timestamp'])) || (isset($submit_default_current_timestamp) - && $submit_default_current_timestamp) + && $submit_default_current_timestamp) ) { $default_current_timestamp = true; } else { @@ -480,7 +498,8 @@ for ($i = 0; $i < $num_fields; $i++) { if (! empty($row['Null']) && $row['Null'] != 'NO' - && $row['Null'] != 'NOT NULL') { + && $row['Null'] != 'NOT NULL' + ) { $content_cells[$i][$ci] .= ' checked="checked"'; } @@ -575,10 +594,12 @@ for ($i = 0; $i < $num_fields; $i++) { . (($current_index == $mi || $current_index == $mi + 1) ? ' disabled="disabled"' : '') - .'>' . sprintf( + .'>' + . sprintf( __('after %s'), PMA_backquote($move_columns[$mi]->name) - ) . ''; + ) + . ''; } $content_cells[$i][$ci] .= ''; @@ -588,7 +609,8 @@ for ($i = 0; $i < $num_fields; $i++) { // column MIME-types if ($cfgRelation['mimework'] && $cfg['BrowseMIME'] - && $cfgRelation['commwork']) { + && $cfgRelation['commwork'] + ) { $content_cells[$i][$ci] = ''; $ci++; + $val = isset($row['Field']) + && isset($mime_map[$row['Field']]['transformation_options']) + ? htmlspecialchars($mime_map[$row['Field']]['transformation_options']) + : ''; $content_cells[$i][$ci] = ''; //$ci++; } @@ -686,19 +713,24 @@ if ($action == 'tbl_create.php') { - '); ?> - ' + ); ?> + ', 1)" /> - + diff --git a/libraries/tbl_replace_fields.inc.php b/libraries/tbl_replace_fields.inc.php index ba06124030..5549c33456 100644 --- a/libraries/tbl_replace_fields.inc.php +++ b/libraries/tbl_replace_fields.inc.php @@ -80,7 +80,9 @@ if (false !== $possibly_uploaded_val) { } elseif ($type == 'bit') { $val = preg_replace('/[^01]/', '0', $val); $val = "b'" . PMA_sqlAddSlashes($val) . "'"; - } elseif (! (($type == 'datetime' || $type == 'timestamp') && $val == 'CURRENT_TIMESTAMP')) { + } elseif (! ($type == 'datetime' || $type == 'timestamp') + || $val != 'CURRENT_TIMESTAMP' + ) { $val = "'" . PMA_sqlAddSlashes($val) . "'"; } @@ -92,7 +94,10 @@ if (false !== $possibly_uploaded_val) { } // The Null checkbox was unchecked for this field - if (empty($val) && ! empty($me_fields_null_prev[$key]) && ! isset($me_fields_null[$key])) { + if (empty($val) + && ! empty($me_fields_null_prev[$key]) + && ! isset($me_fields_null[$key]) + ) { $val = "''"; } } // end else (field value in the form) diff --git a/libraries/tbl_select.lib.php b/libraries/tbl_select.lib.php index 67fe27434f..d25d53333e 100644 --- a/libraries/tbl_select.lib.php +++ b/libraries/tbl_select.lib.php @@ -59,12 +59,19 @@ function PMA_tbl_getFields($db, $table) } $fields_null[] = $row['Null']; $fields_type[] = $type; - $fields_collation[] = ! empty($row['Collation']) && $row['Collation'] != 'NULL' + $fields_collation[] + = ! empty($row['Collation']) && $row['Collation'] != 'NULL' ? $row['Collation'] : ''; } // end while - return array($fields_list, $fields_type, $fields_collation, $fields_null, $geom_column_present); + return array( + $fields_list, + $fields_type, + $fields_collation, + $fields_null, + $geom_column_present + ); } /** @@ -121,28 +128,33 @@ function PMA_tbl_getSubTabs() * 1) Browsing foreign data for a field. * 2) Creating elements for search criteria input on fields. * - * @param array $foreigners Array of foreign keys - * @param array $foreignData Foreign keys data - * @param string $field Column name - * @param string $tbl_fields_type Column type - * @param int $i Column index - * @param string $db Selected database - * @param string $table Selected table - * @param array $titles Selected title - * @param int $foreignMaxLimit Max limit of displaying foreign elements - * @param array $fields Array of search criteria inputs - * @param bool $in_fbs Whether we are in 'function based search' - * @param bool $in_zoom_search_edit Whether we are in zoom search edit + * @param array $foreigners Array of foreign keys + * @param array $foreignData Foreign keys data + * @param string $field Column name + * @param string $tbl_fields_type Column type + * @param int $i Column index + * @param string $db Selected database + * @param string $table Selected table + * @param array $titles Selected title + * @param int $foreignMaxLimit Max limit of displaying foreign elements + * @param array $fields Array of search criteria inputs + * @param bool $in_fbs Whether we are in 'function based search' + * @param bool $in_zoom_search_edit Whether we are in zoom search edit * * @return string HTML content for viewing foreing data and elements * for search criteria input. */ -function PMA_getForeignFields_Values($foreigners, $foreignData, $field, $tbl_fields_type, $i, $db, $table, $titles, $foreignMaxLimit, $fields, $in_fbs = false, $in_zoom_search_edit = false) -{ +function PMA_getForeignFields_Values($foreigners, $foreignData, $field, + $tbl_fields_type, $i, $db, $table, $titles, $foreignMaxLimit, $fields, + $in_fbs = false, $in_zoom_search_edit = false +) { $str = ''; - if ($foreigners && isset($foreigners[$field]) && is_array($foreignData['disp_row'])) { + if ($foreigners + && isset($foreigners[$field]) + && is_array($foreignData['disp_row']) + ) { // f o r e i g n k e y s - $str .= ''; // go back to first row // here, the 4th parameter is empty because there is no current // value of data for the dropdown (the search page initial values @@ -151,18 +163,23 @@ function PMA_getForeignFields_Values($foreigners, $foreignData, $field, $tbl_fie $foreignData['disp_row'], $foreignData['foreign_field'], $foreignData['foreign_display'], '', $foreignMaxLimit ); - $str .= '' . "\n"; + $str .= ''; } elseif ($foreignData['foreign_link'] == true) { if (isset($fields[$i]) && is_string($fields[$i])) { - $str .= '' ; + $str .= ''; } else { - $str .= '' ; + $str .= ''; } $str .= <<' . "\n"; + . ' size="40" class="textfield" id="field_' . $i . '" />'; if ($in_fbs) { $edit_url = 'gis_data_editor.php?' . PMA_generate_common_url(); $edit_str = PMA_getIcon('b_edit.png', __('Edit/Insert')); $str .= ''; - $str .= PMA_linkOrButton($edit_url, $edit_str, array(), false, false, '_blank'); + $str .= PMA_linkOrButton( + $edit_url, $edit_str, array(), false, false, '_blank' + ); $str .= ''; } @@ -192,16 +211,19 @@ EOT; // Set in search mode --> input (skipped here, so the 'else' // section would handle it) - $value = explode(', ', str_replace("'", '', substr($tbl_fields_type[$i], 5, -1))); + $value = explode( + ', ', + str_replace("'", '', substr($tbl_fields_type[$i], 5, -1)) + ); $cnt_value = count($value); if ((strncasecmp($tbl_fields_type[$i], 'enum', 4) && ! $in_zoom_search_edit) || (strncasecmp($tbl_fields_type[$i], 'set', 3) && $in_zoom_search_edit) ) { - $str .= ''; } else { $str .= '' . "\n"; + $str .= ''; } else { // o t h e r c a s e s @@ -234,11 +256,11 @@ EOT; if (isset($fields[$i]) && is_string($fields[$i])) { $str .= '' . "\n"; + . $i .'" value = "' . $fields[$i] . '"/>'; } else { $str .= '' . "\n"; + . $i .'" />'; } } return $str; @@ -258,8 +280,9 @@ EOT; * @return string HTML content for viewing foreing data and elements * for search criteria input. */ -function PMA_tbl_search_getWhereClause($fields, $names, $types, $collations, $func_type, $unaryFlag, $geom_func = null) -{ +function PMA_tbl_search_getWhereClause($fields, $names, $types, $collations, + $func_type, $unaryFlag, $geom_func = null +) { /** * @todo move this to a more apropriate place */ @@ -334,7 +357,8 @@ function PMA_tbl_search_getWhereClause($fields, $names, $types, $collations, $fu $enum_where .= ', \'' . PMA_sqlAddslashes($fields[$e]) . '\''; } - $w = $backquoted_name . ' ' . $func_type . ' ' . $parens_open . $enum_where . $parens_close; + $w = $backquoted_name . ' ' . $func_type . ' ' . $parens_open + . $enum_where . $parens_close; } } elseif ($fields != '') { @@ -373,13 +397,16 @@ function PMA_tbl_search_getWhereClause($fields, $names, $types, $collations, $fu } if ($func_type == 'BETWEEN' || $func_type == 'NOT BETWEEN') { - $w = $backquoted_name . ' ' . $func_type . ' ' . (isset($values[0]) ? $values[0] : '') + $w = $backquoted_name . ' ' . $func_type . ' ' + . (isset($values[0]) ? $values[0] : '') . ' AND ' . (isset($values[1]) ? $values[1] : ''); } else { - $w = $backquoted_name . ' ' . $func_type . ' (' . implode(',', $values) . ')'; + $w = $backquoted_name . ' ' . $func_type + . ' (' . implode(',', $values) . ')'; } } else { - $w = $backquoted_name . ' ' . $func_type . ' ' . $quot . PMA_sqlAddslashes($fields) . $quot;; + $w = $backquoted_name . ' ' . $func_type . ' ' + . $quot . PMA_sqlAddslashes($fields) . $quot;; } } // end if