From f354e74c34eb6c14f175de89647655de1332409b Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Sat, 17 Mar 2012 19:31:25 +0530 Subject: [PATCH 1/2] Coding style improvements - mostly fixing doc comments --- libraries/Error.class.php | 32 +-- libraries/Error_Handler.class.php | 80 +++++--- libraries/File.class.php | 269 ++++++++++++++------------ libraries/db_info.inc.php | 22 ++- libraries/db_structure.lib.php | 17 +- libraries/db_table_exists.lib.php | 9 +- libraries/display_export.lib.php | 2 +- libraries/display_select_lang.lib.php | 5 +- libraries/file_listing.php | 6 +- 9 files changed, 249 insertions(+), 193 deletions(-) diff --git a/libraries/Error.class.php b/libraries/Error.class.php index e972f67412..31d4550ab6 100644 --- a/libraries/Error.class.php +++ b/libraries/Error.class.php @@ -93,10 +93,10 @@ class PMA_Error extends PMA_Message /** * Constructor * - * @param integer $errno - * @param string $errstr - * @param string $errfile - * @param integer $errline + * @param integer $errno error number + * @param string $errstr error message + * @param string $errfile file + * @param integer $errline line */ public function __construct($errno, $errstr, $errfile, $errline) { @@ -116,7 +116,9 @@ class PMA_Error extends PMA_Message /** * sets PMA_Error::$_backtrace * - * @param array $backtrace + * @param array $backtrace backtrace + * + * @return nothing */ public function setBacktrace($backtrace) { @@ -126,7 +128,9 @@ class PMA_Error extends PMA_Message /** * sets PMA_Error::$_line * - * @param integer $line + * @param integer $line the line + * + * @return nothing */ public function setLine($line) { @@ -136,7 +140,9 @@ class PMA_Error extends PMA_Message /** * sets PMA_Error::$_file * - * @param string $file + * @param string $file the file + * + * @return nothing */ public function setFile($file) { @@ -147,8 +153,7 @@ class PMA_Error extends PMA_Message /** * returns unique PMA_Error::$_hash, if not exists it will be created * - * @param string $file - * @return string PMA_Error::$_hash + * @return string PMA_Error::$_hash */ public function getHash() { @@ -243,6 +248,7 @@ class PMA_Error extends PMA_Message /** * Display HTML backtrace * + * @return nothing */ public function displayBacktrace() { @@ -274,6 +280,8 @@ class PMA_Error extends PMA_Message * * @param string $arg * @param string $function + * + * @return nothing */ protected function displayArg($arg, $function) { @@ -296,6 +304,7 @@ class PMA_Error extends PMA_Message /** * Displays the error in HTML * + * @return nothing */ public function display() { @@ -333,9 +342,10 @@ class PMA_Error extends PMA_Message * prevent path disclusore in error message, * and make users feel save to submit error reports * - * @static - * @param string $dest path to be shorten + * @param string $dest path to be shorten + * * @return string shortened path + * @static */ static function relPath($dest) { diff --git a/libraries/Error_Handler.class.php b/libraries/Error_Handler.class.php index b6b9bf0d80..0a647f1f3b 100644 --- a/libraries/Error_Handler.class.php +++ b/libraries/Error_Handler.class.php @@ -92,10 +92,12 @@ class PMA_Error_Handler * Do not use the context parameter as we want to avoid storing the * complete $GLOBALS inside $_SESSION['errors'] * - * @param integer $errno - * @param string $errstr - * @param string $errfile - * @param integer $errline + * @param integer $errno error number + * @param string $errstr error string + * @param string $errfile error file + * @param integer $errline error line + * + * @return nothing */ public function handleError($errno, $errstr, $errfile, $errline) { @@ -106,37 +108,39 @@ class PMA_Error_Handler $this->_errors[$error->getHash()] = $error; switch ($error->getNumber()) { - case E_USER_NOTICE: - case E_USER_WARNING: - case E_STRICT: - case E_DEPRECATED: - case E_NOTICE: - case E_WARNING: - case E_CORE_WARNING: - case E_COMPILE_WARNING: - case E_USER_ERROR: - case E_RECOVERABLE_ERROR: - // just collect the error - // display is called from outside - break; - case E_ERROR: - case E_PARSE: - case E_CORE_ERROR: - case E_COMPILE_ERROR: - default: - // FATAL error, dislay it and exit - $this->_dispFatalError($error); - exit; - break; + case E_USER_NOTICE: + case E_USER_WARNING: + case E_STRICT: + case E_DEPRECATED: + case E_NOTICE: + case E_WARNING: + case E_CORE_WARNING: + case E_COMPILE_WARNING: + case E_USER_ERROR: + case E_RECOVERABLE_ERROR: + // just collect the error + // display is called from outside + break; + case E_ERROR: + case E_PARSE: + case E_CORE_ERROR: + case E_COMPILE_ERROR: + default: + // FATAL error, dislay it and exit + $this->_dispFatalError($error); + exit; + break; } } /** * log error to configured log facility * - * @todo finish! - * @param PMA_Error $error + * @param PMA_Error $error the error + * * @return bool + * + * @todo finish! */ protected function _logError($error) { @@ -146,10 +150,12 @@ class PMA_Error_Handler /** * trigger a custom error * - * @param string $errorInfo - * @param integer $errorNumber + * @param string $errorInfo error message + * @param integer $errorNumber error number * @param string $file * @param integer $line + * + * @return nothing */ public function triggerError($errorInfo, $errorNumber = null, $file = null, $line = null) { @@ -160,7 +166,9 @@ class PMA_Error_Handler /** * display fatal error and exit * - * @param PMA_Error $error + * @param PMA_Error $error the error + * + * @return nothing */ protected function _dispFatalError($error) { @@ -175,6 +183,7 @@ class PMA_Error_Handler /** * display the whole error page with all errors * + * @return nothing */ public function dispErrorPage() { @@ -188,6 +197,7 @@ class PMA_Error_Handler /** * display user errors not displayed * + * @return nothing */ public function dispUserErrors() { @@ -201,7 +211,9 @@ class PMA_Error_Handler /** * display HTML header * - * @param PMA_error $error + * @param PMA_error $error the error + * + * @return nothing */ protected function _dispPageStart($error = null) { @@ -217,6 +229,7 @@ class PMA_Error_Handler /** * display HTML footer * + * @return nothing */ protected function _dispPageEnd() { @@ -226,6 +239,7 @@ class PMA_Error_Handler /** * display all errors regardless already displayed or user errors * + * @return nothing */ public function dispAllErrors() { @@ -237,6 +251,7 @@ class PMA_Error_Handler /** * display errors not displayed * + * @return nothing */ public function dispErrors() { @@ -258,6 +273,7 @@ class PMA_Error_Handler /** * look in session for saved errors * + * @return nothing */ protected function _checkSavedErrors() { diff --git a/libraries/File.class.php b/libraries/File.class.php index 11a1a04167..70dbda2e8c 100644 --- a/libraries/File.class.php +++ b/libraries/File.class.php @@ -72,8 +72,9 @@ class PMA_File /** * constructor * - * @access public - * @param string $name file name + * @param string $name file name + * + * @access public */ function __construct($name = false) { @@ -123,9 +124,10 @@ class PMA_File * checks or sets the temp flag for this file * file objects with temp flags are deleted with object destruction * - * @access public - * @param boolean sets the temp flag + * @param boolean $is_temp sets the temp flag + * * @return boolean PMA_File::$_is_temp + * @access public */ function isTemp($is_temp = null) { @@ -139,8 +141,10 @@ class PMA_File /** * accessor * + * @param string $name file name + * + * @return nothing * @access public - * @param string $name file name */ function setName($name) { @@ -148,8 +152,10 @@ class PMA_File } /** - * @access public + * * @return string binary file content + * + * @access public */ function getContent($as_binary = true, $offset = 0, $length = null) { @@ -203,9 +209,11 @@ class PMA_File } /** - * @access public - * @param string name of file uploaded + * + * @param string $name name of file uploaded + * * @return boolean success + * @access public */ function setUploadedFile($name) { @@ -221,10 +229,11 @@ class PMA_File } /** - * @access public - * @param string $key the md5 hash of the column name - * @param string $rownumber + * @param string $key the md5 hash of the column name + * @param string $rownumber + * * @return boolean success + * @access public */ function setUploadedFromTblChangeRequest($key, $rownumber) { @@ -235,34 +244,34 @@ class PMA_File // check for file upload errors switch ($file['error']) { - // we do not use the PHP constants here cause not all constants - // are defined in all versions of PHP - but the correct constants names - // are given as comment - case 0: //UPLOAD_ERR_OK: - return $this->setUploadedFile($file['tmp_name']); - break; - case 4: //UPLOAD_ERR_NO_FILE: - break; - case 1: //UPLOAD_ERR_INI_SIZE: - $this->_error_message = __('The uploaded file exceeds the upload_max_filesize directive in php.ini.'); - break; - case 2: //UPLOAD_ERR_FORM_SIZE: - $this->_error_message = __('The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.'); - break; - case 3: //UPLOAD_ERR_PARTIAL: - $this->_error_message = __('The uploaded file was only partially uploaded.'); - break; - case 6: //UPLOAD_ERR_NO_TMP_DIR: - $this->_error_message = __('Missing a temporary folder.'); - break; - case 7: //UPLOAD_ERR_CANT_WRITE: - $this->_error_message = __('Failed to write file to disk.'); - break; - case 8: //UPLOAD_ERR_EXTENSION: - $this->_error_message = __('File upload stopped by extension.'); - break; - default: - $this->_error_message = __('Unknown error in file upload.'); + // we do not use the PHP constants here cause not all constants + // are defined in all versions of PHP - but the correct constants names + // are given as comment + case 0: //UPLOAD_ERR_OK: + return $this->setUploadedFile($file['tmp_name']); + break; + case 4: //UPLOAD_ERR_NO_FILE: + break; + case 1: //UPLOAD_ERR_INI_SIZE: + $this->_error_message = __('The uploaded file exceeds the upload_max_filesize directive in php.ini.'); + break; + case 2: //UPLOAD_ERR_FORM_SIZE: + $this->_error_message = __('The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.'); + break; + case 3: //UPLOAD_ERR_PARTIAL: + $this->_error_message = __('The uploaded file was only partially uploaded.'); + break; + case 6: //UPLOAD_ERR_NO_TMP_DIR: + $this->_error_message = __('Missing a temporary folder.'); + break; + case 7: //UPLOAD_ERR_CANT_WRITE: + $this->_error_message = __('Failed to write file to disk.'); + break; + case 8: //UPLOAD_ERR_EXTENSION: + $this->_error_message = __('File upload stopped by extension.'); + break; + default: + $this->_error_message = __('Unknown error in file upload.'); } // end switch return false; @@ -287,12 +296,13 @@ class PMA_File * $file['error'] = [value] * * + * @param array $file the array + * @param string $rownumber + * @param string $key + * + * @return array * @access public * @static - * @param array $file the array - * @param string $rownumber - * @param string $key - * @return array */ function fetchUploadedFromTblChangeRequestMultiple($file, $rownumber, $key) { @@ -310,15 +320,17 @@ class PMA_File /** * sets the name if the file to the one selected in the tbl_change form * - * @access public - * @param string $key the md5 hash of the column name - * @param string $rownumber + * @param string $key the md5 hash of the column name + * @param string $rownumber + * * @return boolean success + * @access public */ function setSelectedFromTblChangeRequest($key, $rownumber = null) { if (! empty($_REQUEST['fields_uploadlocal']['multi_edit'][$rownumber][$key]) - && is_string($_REQUEST['fields_uploadlocal']['multi_edit'][$rownumber][$key])) { + && is_string($_REQUEST['fields_uploadlocal']['multi_edit'][$rownumber][$key]) + ) { // ... whether with multiple rows ... return $this->setLocalSelectedFile($_REQUEST['fields_uploadlocal']['multi_edit'][$rownumber][$key]); } else { @@ -348,10 +360,11 @@ class PMA_File * checks the superglobals provided if the tbl_change form is submitted * and uses the submitted/selected file * - * @access public - * @param string $key the md5 hash of the column name - * @param string $rownumber + * @param string $key the md5 hash of the column name + * @param string $rownumber + * * @return boolean success + * @access public */ function checkTblChangeForm($key, $rownumber) { @@ -371,9 +384,10 @@ class PMA_File /** * - * @access public - * @param string $name + * @param string $name + * * @return boolean success + * @access public */ function setLocalSelectedFile($name) { @@ -528,47 +542,47 @@ class PMA_File } switch ($this->getCompression()) { - case false: - return false; - case 'application/bzip2': - if ($GLOBALS['cfg']['BZipDump'] && @function_exists('bzopen')) { - $this->_handle = @bzopen($this->getName(), 'r'); - } else { - $this->_error_message = sprintf(__('You attempted to load file with unsupported compression (%s). Either support for it is not implemented or disabled by your configuration.'), $this->getCompression()); - return false; - } - break; - case 'application/gzip': - if ($GLOBALS['cfg']['GZipDump'] && @function_exists('gzopen')) { - $this->_handle = @gzopen($this->getName(), 'r'); - } else { - $this->_error_message = sprintf(__('You attempted to load file with unsupported compression (%s). Either support for it is not implemented or disabled by your configuration.'), $this->getCompression()); - return false; - } - break; - case 'application/zip': - if ($GLOBALS['cfg']['ZipDump'] && @function_exists('zip_open')) { - include_once './libraries/zip_extension.lib.php'; - $result = PMA_getZipContents($this->getName()); - if (! empty($result['error'])) { - $this->_error_message = PMA_Message::rawError($result['error']); - return false; - } else { - $this->content_uncompressed = $result['data']; - } - unset($result); - } else { - $this->_error_message = sprintf(__('You attempted to load file with unsupported compression (%s). Either support for it is not implemented or disabled by your configuration.'), $this->getCompression()); - return false; - } - break; - case 'none': - $this->_handle = @fopen($this->getName(), 'r'); - break; - default: + case false: + return false; + case 'application/bzip2': + if ($GLOBALS['cfg']['BZipDump'] && @function_exists('bzopen')) { + $this->_handle = @bzopen($this->getName(), 'r'); + } else { $this->_error_message = sprintf(__('You attempted to load file with unsupported compression (%s). Either support for it is not implemented or disabled by your configuration.'), $this->getCompression()); return false; - break; + } + break; + case 'application/gzip': + if ($GLOBALS['cfg']['GZipDump'] && @function_exists('gzopen')) { + $this->_handle = @gzopen($this->getName(), 'r'); + } else { + $this->_error_message = sprintf(__('You attempted to load file with unsupported compression (%s). Either support for it is not implemented or disabled by your configuration.'), $this->getCompression()); + return false; + } + break; + case 'application/zip': + if ($GLOBALS['cfg']['ZipDump'] && @function_exists('zip_open')) { + include_once './libraries/zip_extension.lib.php'; + $result = PMA_getZipContents($this->getName()); + if (! empty($result['error'])) { + $this->_error_message = PMA_Message::rawError($result['error']); + return false; + } else { + $this->content_uncompressed = $result['data']; + } + unset($result); + } else { + $this->_error_message = sprintf(__('You attempted to load file with unsupported compression (%s). Either support for it is not implemented or disabled by your configuration.'), $this->getCompression()); + return false; + } + break; + case 'none': + $this->_handle = @fopen($this->getName(), 'r'); + break; + default: + $this->_error_message = sprintf(__('You attempted to load file with unsupported compression (%s). Either support for it is not implemented or disabled by your configuration.'), $this->getCompression()); + return false; + break; } return true; @@ -601,6 +615,7 @@ class PMA_File * advances the file pointer in the file handle by $length bytes/chars * * @param integer $length numbers of chars/bytes to skip + * * @return boolean * @todo this function is unused */ @@ -615,9 +630,11 @@ class PMA_File /** * http://bugs.php.net/bug.php?id=29532 * bzip reads a maximum of 8192 bytes on windows systems - * @todo this function is unused + * * @param int $max_size + * * @return bool|string + * @todo this function is unused */ function getNextChunk($max_size = null) { @@ -630,41 +647,41 @@ class PMA_File // $result = $this->handler->getNextChunk($size); $result = ''; switch ($this->getCompression()) { - case 'application/bzip2': - $result = ''; - while (strlen($result) < $size - 8192 && ! feof($this->getHandle())) { - $result .= bzread($this->getHandle(), $size); - } - break; - case 'application/gzip': - $result = gzread($this->getHandle(), $size); - break; - case 'application/zip': - /* - * if getNextChunk() is used some day, - * replace this code by code similar to the one - * in open() - * - include_once './libraries/unzip.lib.php'; - $import_handle = new SimpleUnzip(); - $import_handle->ReadFile($this->getName()); - if ($import_handle->Count() == 0) { - $this->_error_message = __('No files found inside ZIP archive!'); - return false; - } elseif ($import_handle->GetError(0) != 0) { - $this->_error_message = __('Error in ZIP archive:') - . ' ' . $import_handle->GetErrorMsg(0); - return false; - } else { - $result = $import_handle->GetData(0); - } - */ - break; - case 'none': - $result = fread($this->getHandle(), $size); - break; - default: + case 'application/bzip2': + $result = ''; + while (strlen($result) < $size - 8192 && ! feof($this->getHandle())) { + $result .= bzread($this->getHandle(), $size); + } + break; + case 'application/gzip': + $result = gzread($this->getHandle(), $size); + break; + case 'application/zip': + /* + * if getNextChunk() is used some day, + * replace this code by code similar to the one + * in open() + * + include_once './libraries/unzip.lib.php'; + $import_handle = new SimpleUnzip(); + $import_handle->ReadFile($this->getName()); + if ($import_handle->Count() == 0) { + $this->_error_message = __('No files found inside ZIP archive!'); return false; + } elseif ($import_handle->GetError(0) != 0) { + $this->_error_message = __('Error in ZIP archive:') + . ' ' . $import_handle->GetErrorMsg(0); + return false; + } else { + $result = $import_handle->GetData(0); + } + */ + break; + case 'none': + $result = fread($this->getHandle(), $size); + break; + default: + return false; } if ($GLOBALS['charset_conversion']) { diff --git a/libraries/db_info.inc.php b/libraries/db_info.inc.php index c296f71122..c152385430 100644 --- a/libraries/db_info.inc.php +++ b/libraries/db_info.inc.php @@ -35,9 +35,11 @@ $pos = $_SESSION['tmp_user_values']['table_limit_offset']; /** * fills given tooltip arrays * - * @param array $tooltip_truename tooltip data - * @param array $tooltip_aliasname tooltip data - * @param array $table tabledata + * @param array &$tooltip_truename tooltip data + * @param array &$tooltip_aliasname tooltip data + * @param array $table tabledata + * + * @return nothing */ function PMA_fillTooltip(&$tooltip_truename, &$tooltip_aliasname, $table) { @@ -62,7 +64,8 @@ function PMA_fillTooltip(&$tooltip_truename, &$tooltip_aliasname, $table) } if ($GLOBALS['cfg']['ShowTooltipAliasTB'] - && $GLOBALS['cfg']['ShowTooltipAliasTB'] !== 'nested') { + && $GLOBALS['cfg']['ShowTooltipAliasTB'] !== 'nested' + ) { $tooltip_truename[$table['Name']] = $table['Comment']; $tooltip_aliasname[$table['Name']] = $table['Name']; } else { @@ -137,13 +140,15 @@ if (true === $cfg['SkipLockedTables']) { if (isset($sot_cache)) { $db_info_result = PMA_DBI_query( 'SHOW TABLES FROM ' . PMA_backquote($db) . $tbl_group_sql . ';', - null, PMA_DBI_QUERY_STORE); + null, PMA_DBI_QUERY_STORE + ); if ($db_info_result && PMA_DBI_num_rows($db_info_result) > 0) { while ($tmp = PMA_DBI_fetch_row($db_info_result)) { if (! isset($sot_cache[$tmp[0]])) { $sts_result = PMA_DBI_query( 'SHOW TABLE STATUS FROM ' . PMA_backquote($db) - . ' LIKE \'' . PMA_sqlAddSlashes($tmp[0], true) . '\';'); + . ' LIKE \'' . PMA_sqlAddSlashes($tmp[0], true) . '\';' + ); $sts_tmp = PMA_DBI_fetch_assoc($sts_result); PMA_DBI_free_result($sts_result); unset($sts_result); @@ -152,8 +157,9 @@ if (true === $cfg['SkipLockedTables']) { $sts_tmp['Type'] =& $sts_tmp['Engine']; } - if (!empty($tbl_group) && $cfg['ShowTooltipAliasTB'] - && !preg_match('@' . preg_quote($tbl_group, '@') . '@i', $sts_tmp['Comment'])) { + if (! empty($tbl_group) && $cfg['ShowTooltipAliasTB'] + && !preg_match('@' . preg_quote($tbl_group, '@') . '@i', $sts_tmp['Comment']) + ) { continue; } diff --git a/libraries/db_structure.lib.php b/libraries/db_structure.lib.php index c70b6bf88f..5a93187289 100644 --- a/libraries/db_structure.lib.php +++ b/libraries/db_structure.lib.php @@ -31,9 +31,9 @@ function PMA_TableHeader($db_is_information_schema = false, $replication = false .'' . "\n" .' ' . PMA_SortableTableHeader(__('Table'), 'table') . '' . "\n"; if ($replication) { - echo ' ' . "\n" - .' ' . __('Replication') . "\n" - .' '; + echo ' ' . "\n" + .' ' . __('Replication') . "\n" + .' '; } echo ' ' . "\n" .' ' . __('Action') . "\n" @@ -65,17 +65,18 @@ function PMA_TableHeader($db_is_information_schema = false, $replication = false /** * Creates a clickable column header for table information * - * @param string $title title to use for the link - * @param string $sort corresponds to sortable data name mapped in libraries/db_info.inc.php - * @param string $initial_sort_order - * @return string link to be displayed in the table header + * @param string $title title to use for the link + * @param string $sort corresponds to sortable data name mapped in libraries/db_info.inc.php + * @param string $initial_sort_order initial sort order + * + * @return string link to be displayed in the table header */ function PMA_SortableTableHeader($title, $sort, $initial_sort_order = 'ASC') { // Set some defaults $requested_sort = 'table'; $requested_sort_order = $future_sort_order = $initial_sort_order; - + // If the user requested a sort if (isset($_REQUEST['sort'])) { $requested_sort = $_REQUEST['sort']; diff --git a/libraries/db_table_exists.lib.php b/libraries/db_table_exists.lib.php index b2f3446de2..34e6e904f1 100644 --- a/libraries/db_table_exists.lib.php +++ b/libraries/db_table_exists.lib.php @@ -32,7 +32,8 @@ if (empty($is_db)) { } PMA_sendHeaderLocation( $cfg['PmaAbsoluteUri'] . 'main.php' - . PMA_generate_common_url($url_params, '&')); + . PMA_generate_common_url($url_params, '&') + ); } exit; } @@ -47,7 +48,8 @@ if (empty($is_table) && !defined('PMA_SUBMIT_MULT') && ! defined('TABLE_MAY_BE_A if (! $is_table) { $_result = PMA_DBI_try_query( 'SHOW TABLES LIKE \'' . PMA_sqlAddSlashes($table, true) . '\';', - null, PMA_DBI_QUERY_STORE); + null, PMA_DBI_QUERY_STORE + ); $is_table = @PMA_DBI_num_rows($_result); PMA_DBI_free_result($_result); } @@ -67,7 +69,8 @@ if (empty($is_table) && !defined('PMA_SUBMIT_MULT') && ! defined('TABLE_MAY_BE_A */ $_result = PMA_DBI_try_query( 'SELECT COUNT(*) FROM ' . PMA_backquote($table) . ';', - null, PMA_DBI_QUERY_STORE); + null, PMA_DBI_QUERY_STORE + ); $is_table = ($_result && @PMA_DBI_num_rows($_result)); PMA_DBI_free_result($_result); } diff --git a/libraries/display_export.lib.php b/libraries/display_export.lib.php index f62a9108ba..fb6eb1841e 100644 --- a/libraries/display_export.lib.php +++ b/libraries/display_export.lib.php @@ -37,7 +37,7 @@ $export_list = PMA_getPlugins('./libraries/export/', array('export_type' => $exp /* Fail if we didn't find any plugin */ if (empty($export_list)) { - PMA_Message::error( __('Could not load export plugins, please check your installation!'))->display(); + PMA_Message::error(__('Could not load export plugins, please check your installation!'))->display(); include './libraries/footer.inc.php'; } ?> diff --git a/libraries/display_select_lang.lib.php b/libraries/display_select_lang.lib.php index f112fdcfd6..bf551f6ee6 100644 --- a/libraries/display_select_lang.lib.php +++ b/libraries/display_select_lang.lib.php @@ -12,8 +12,9 @@ if (! defined('PHPMYADMIN')) { /** * Sorts available languages by their true english names * - * @param array the array to be sorted - * @param mixed a required parameter + * @param array &$a the array to be sorted + * @param mixed &$b a required parameter + * * @return the sorted array * @access private */ diff --git a/libraries/file_listing.php b/libraries/file_listing.php index 733f20f741..91c62a55a6 100644 --- a/libraries/file_listing.php +++ b/libraries/file_listing.php @@ -12,6 +12,7 @@ * * @param string $dir directory to list * @param string $expression regular expression to match files + * * @return array sorted file list on success, false on failure */ function PMA_getDirContent($dir, $expression = '') @@ -22,8 +23,8 @@ function PMA_getDirContent($dir, $expression = '') $dir .= '/'; } while ($file = @readdir($handle)) { - // for PHP < 5.2.4, is_file() gives a warning when using open_basedir - // and verifying '..' or '.' + // for PHP < 5.2.4, is_file() gives a warning when using open_basedir + // and verifying '..' or '.' if ('.' != $file && '..' != $file && is_file($dir . $file) && ($expression == '' || preg_match($expression, $file))) { $result[] = $file; } @@ -42,6 +43,7 @@ function PMA_getDirContent($dir, $expression = '') * @param string $dir directory to list * @param string $extensions regullar expression to match files * @param string $active currently active choice + * * @return array sorted file list on success, false on failure */ function PMA_getFileSelectOptions($dir, $extensions = '', $active = '') From 0c5b25bf9cc434eca2eae5ae6861d69d010a58aa Mon Sep 17 00:00:00 2001 From: Madhura Jayaratne Date: Sat, 17 Mar 2012 19:36:10 +0530 Subject: [PATCH 2/2] Coding style improvements - proper indentation --- libraries/header.inc.php | 168 ++++++++++++++++++++------------------- 1 file changed, 87 insertions(+), 81 deletions(-) diff --git a/libraries/header.inc.php b/libraries/header.inc.php index 3dd65ff50a..5d6c1f0c3a 100644 --- a/libraries/header.inc.php +++ b/libraries/header.inc.php @@ -108,106 +108,112 @@ if (isset($GLOBALS['is_ajax_request']) && !$GLOBALS['is_ajax_request']) { */ if (PMA_DISPLAY_HEADING && $GLOBALS['server'] > 0) { - $server_info = (!empty($GLOBALS['cfg']['Server']['verbose']) - ? $GLOBALS['cfg']['Server']['verbose'] - : $GLOBALS['cfg']['Server']['host'] . (empty($GLOBALS['cfg']['Server']['port']) - ? '' - : ':' . $GLOBALS['cfg']['Server']['port'] - ) - ); + $server_info = ! empty($GLOBALS['cfg']['Server']['verbose']) + ? $GLOBALS['cfg']['Server']['verbose'] + : $GLOBALS['cfg']['Server']['host']; + $server_info .= empty($GLOBALS['cfg']['Server']['port']) + ? '' + : ':' . $GLOBALS['cfg']['Server']['port']; + $separator = " ยป\n"; $item = ''; - if ($GLOBALS['cfg']['NavigationBarIconic'] !== true) { - $item .= '%4$s: '; - } - $item .= '%3$s' . "\n"; - echo "
\n"; - echo "
\n"; - if ($GLOBALS['cfg']['NavigationBarIconic']) { - echo PMA_getImage('s_host.png', '', array('class' => 'item')) . "\n"; - } - printf($item, - $GLOBALS['cfg']['DefaultTabServer'], - PMA_generate_common_url(), - htmlspecialchars($server_info), - __('Server')); + if ($GLOBALS['cfg']['NavigationBarIconic'] !== true) { + $item .= '%4$s: '; + } + $item .= '%3$s' . "\n"; + echo "
\n"; + echo "
\n"; + if ($GLOBALS['cfg']['NavigationBarIconic']) { + echo PMA_getImage('s_host.png', '', array('class' => 'item')) . "\n"; + } + printf( + $item, + $GLOBALS['cfg']['DefaultTabServer'], + PMA_generate_common_url(), + htmlspecialchars($server_info), + __('Server') + ); - if (strlen($GLOBALS['db'])) { + if (strlen($GLOBALS['db'])) { + + echo $separator; + if ($GLOBALS['cfg']['NavigationBarIconic']) { + echo PMA_getImage('s_db.png', '', array('class' => 'item')) . "\n"; + } + printf( + $item, + $GLOBALS['cfg']['DefaultTabDatabase'], + PMA_generate_common_url($GLOBALS['db']), + htmlspecialchars($GLOBALS['db']), + __('Database') + ); + // if the table is being dropped, $_REQUEST['purge'] is set to '1' + // so do not display the table name in upper div + if (strlen($GLOBALS['table']) && ! (isset($_REQUEST['purge']) && $_REQUEST['purge'] == '1')) { + include_once './libraries/tbl_info.inc.php'; echo $separator; if ($GLOBALS['cfg']['NavigationBarIconic']) { - echo PMA_getImage('s_db.png', '', array('class' => 'item')) . "\n"; + $icon = isset($GLOBALS['tbl_is_view']) && $GLOBALS['tbl_is_view'] ? 'b_views.png' : 's_tbl.png'; + echo PMA_getImage($icon, '', array('class' => 'item')) . "\n"; } - printf($item, - $GLOBALS['cfg']['DefaultTabDatabase'], - PMA_generate_common_url($GLOBALS['db']), - htmlspecialchars($GLOBALS['db']), - __('Database')); - // if the table is being dropped, $_REQUEST['purge'] is set to '1' - // so do not display the table name in upper div - if (strlen($GLOBALS['table']) && ! (isset($_REQUEST['purge']) && $_REQUEST['purge'] == '1')) { - include_once './libraries/tbl_info.inc.php'; + printf( + $item, + $GLOBALS['cfg']['DefaultTabTable'], + PMA_generate_common_url($GLOBALS['db'], $GLOBALS['table']), + str_replace(' ', ' ', htmlspecialchars($GLOBALS['table'])), + (isset($GLOBALS['tbl_is_view']) && $GLOBALS['tbl_is_view'] ? __('View') : __('Table')) + ); - echo $separator; - if ($GLOBALS['cfg']['NavigationBarIconic']) { - $icon = isset($GLOBALS['tbl_is_view']) && $GLOBALS['tbl_is_view'] ? 'b_views.png' : 's_tbl.png'; - echo PMA_getImage($icon, '', array('class' => 'item')) . "\n"; + /** + * Displays table comment + */ + if (!empty($show_comment) && ! isset($GLOBALS['avoid_show_comment'])) { + if (strstr($show_comment, '; InnoDB free')) { + $show_comment = preg_replace('@; InnoDB free:.*?$@', '', $show_comment); } - printf($item, - $GLOBALS['cfg']['DefaultTabTable'], - PMA_generate_common_url($GLOBALS['db'], $GLOBALS['table']), - str_replace(' ', ' ', htmlspecialchars($GLOBALS['table'])), - (isset($GLOBALS['tbl_is_view']) && $GLOBALS['tbl_is_view'] ? __('View') : __('Table'))); + echo '' + .'"' . htmlspecialchars($show_comment) + .'"' . "\n"; + } // end if + // add recently used table and reload the navigation + if ($GLOBALS['cfg']['LeftRecentTable'] > 0) { + PMA_addRecentTable($GLOBALS['db'], $GLOBALS['table']); + } + } else { + // no table selected, display database comment if present + /** + * Settings for relations stuff + */ + include_once './libraries/relation.lib.php'; + $cfgRelation = PMA_getRelationsParam(); + + // Get additional information about tables for tooltip is done + // in libraries/db_info.inc.php only once + if ($cfgRelation['commwork']) { + $comment = PMA_getDbComment($GLOBALS['db']); /** * Displays table comment */ - if (!empty($show_comment) && ! isset($GLOBALS['avoid_show_comment'])) { - if (strstr($show_comment, '; InnoDB free')) { - $show_comment = preg_replace('@; InnoDB free:.*?$@', '', $show_comment); - } - echo '' - .'"' . htmlspecialchars($show_comment) - .'"' . "\n"; + if (! empty($comment)) { + echo '"' + . htmlspecialchars($comment) + . '"' . "\n"; } // end if - - // add recently used table and reload the navigation - if ($GLOBALS['cfg']['LeftRecentTable'] > 0) { - PMA_addRecentTable($GLOBALS['db'], $GLOBALS['table']); - } - } else { - // no table selected, display database comment if present - /** - * Settings for relations stuff - */ - include_once './libraries/relation.lib.php'; - $cfgRelation = PMA_getRelationsParam(); - - // Get additional information about tables for tooltip is done - // in libraries/db_info.inc.php only once - if ($cfgRelation['commwork']) { - $comment = PMA_getDbComment($GLOBALS['db']); - /** - * Displays table comment - */ - if (! empty($comment)) { - echo '"' - . htmlspecialchars($comment) - . '"' . "\n"; - } // end if - } } } } - echo '
'; - echo '
'; } - /** - * Sets a variable to remember headers have been sent - */ - $GLOBALS['is_header_sent'] = true; + echo '
'; + echo '
'; + } + /** + * Sets a variable to remember headers have been sent + */ + $GLOBALS['is_header_sent'] = true; //end if (!$GLOBALS['is_ajax_request']) } else { if (empty($GLOBALS['is_header_sent'])) {