[Phpmyadmin-git] [SCM] phpMyAdmin branch, master, updated. RELEASE_3_4_3_2-16254-gadbdb71

Madhura Jayaratne madhuracj at users.sourceforge.net
Mon Aug 22 08:00:24 CEST 2011


The branch, master has been updated
       via  adbdb71e60b788ac10d134a5e0a099d35ca91ff1 (commit)
       via  ea30c016c85cb4a34b5c49109dd18a745447fb54 (commit)
       via  c726d423fef601ed7b8222e46e3dbcfc698d0d5c (commit)
       via  05e78b2778830b29b3919fd742658d8d82851e7b (commit)
      from  e82d3c7136425fbe51ed26f8bf95cf932740ddd8 (commit)


- Log -----------------------------------------------------------------
commit adbdb71e60b788ac10d134a5e0a099d35ca91ff1
Author: Madhura Jayaratne <madhura.cj at gmail.com>
Date:   Mon Aug 22 07:42:24 2011 +0530

    Coding style improvements

commit ea30c016c85cb4a34b5c49109dd18a745447fb54
Author: Madhura Jayaratne <madhura.cj at gmail.com>
Date:   Mon Aug 22 07:30:29 2011 +0530

    Opening braces should be on a new line

commit c726d423fef601ed7b8222e46e3dbcfc698d0d5c
Author: Madhura Jayaratne <madhura.cj at gmail.com>
Date:   Mon Aug 22 07:28:37 2011 +0530

    Fix doc blocks

commit 05e78b2778830b29b3919fd742658d8d82851e7b
Author: Madhura Jayaratne <madhura.cj at gmail.com>
Date:   Mon Aug 22 06:46:39 2011 +0530

    Proper coding style for multi line if statements

-----------------------------------------------------------------------

Summary of changes:
 libraries/common.lib.php |  510 ++++++++++++++++++++++++++--------------------
 1 files changed, 284 insertions(+), 226 deletions(-)

diff --git a/libraries/common.lib.php b/libraries/common.lib.php
index f232b98..4b286d3 100644
--- a/libraries/common.lib.php
+++ b/libraries/common.lib.php
@@ -76,7 +76,8 @@ function PMA_pow($base, $exp, $use_function = false)
  * @param string  $icon       name of icon file
  * @param string  $alternate  alternate text
  * @param boolean $force_text whether to force alternate text to be displayed
- * @param boolean $noSprite   If true, the image source will be not replaced with a CSS Sprite
+ * @param boolean $noSprite   If true, the image source will be not replaced
+ *                            with a CSS Sprite
  *
  * @return html img tag
  */
@@ -153,13 +154,13 @@ function PMA_generateHiddenMaxFileSize($max_size)
  * Add slashes before "'" and "\" characters so a value containing them can
  * be used in a sql comparison.
  *
- * @param string  $a_string the string to slash
- * @param bool    $is_like  whether the string will be used in a 'LIKE' clause
- *                          (it then requires two more escaped sequences) or not
- * @param bool    $crlf     whether to treat cr/lfs as escape-worthy entities
- *                          (converts \n to \\n, \r to \\r)
- * @param bool    $php_code whether this function is used as part of the
- *                          "Create PHP code" dialog
+ * @param string $a_string the string to slash
+ * @param bool   $is_like  whether the string will be used in a 'LIKE' clause
+ *                         (it then requires two more escaped sequences) or not
+ * @param bool   $crlf     whether to treat cr/lfs as escape-worthy entities
+ *                         (converts \n to \\n, \r to \\r)
+ * @param bool   $php_code whether this function is used as part of the
+ *                         "Create PHP code" dialog
  *
  * @return  string   the slashed string
  *
@@ -177,7 +178,7 @@ function PMA_sqlAddSlashes($a_string = '', $is_like = false, $crlf = false, $php
         $a_string = strtr(
             $a_string,
             array("\n" => '\n', "\r" => '\r', "\t" => '\t')
-            );
+        );
     }
 
     if ($php_code) {
@@ -210,7 +211,7 @@ function PMA_escape_mysql_wildcards($name)
  * removes slashes before "_" and "%" characters
  * Note: This function does not unescape backslashes!
  *
- * @param string   $name  the string to escape
+ * @param string $name the string to escape
  *
  * @return  string   the escaped string
  *
@@ -245,15 +246,17 @@ function PMA_unQuote($quoted_string, $quote = null)
 
     foreach ($quotes as $quote) {
         if (substr($quoted_string, 0, 1) === $quote
-         && substr($quoted_string, -1, 1) === $quote) {
-             $unquoted_string = substr($quoted_string, 1, -1);
-             // replace escaped quotes
-             $unquoted_string = str_replace(
+            && substr($quoted_string, -1, 1) === $quote
+        ) {
+            $unquoted_string = substr($quoted_string, 1, -1);
+            // replace escaped quotes
+            $unquoted_string = str_replace(
                 $quote . $quote,
                 $quote,
-                $unquoted_string);
-             return $unquoted_string;
-         }
+                $unquoted_string
+            );
+            return $unquoted_string;
+        }
     }
 
     return $quoted_string;
@@ -262,7 +265,6 @@ function PMA_unQuote($quoted_string, $quote = null)
 /**
  * format sql strings
  *
- * @todo    move into PMA_Sql
  * @param mixed  $parsed_sql   pre-parsed SQL structure
  * @param string $unparsed_sql raw SQL string
  *
@@ -272,7 +274,7 @@ function PMA_unQuote($quoted_string, $quote = null)
  * @global  boolean  whether the current statement is a multiple one or not
  *
  * @access  public
- *
+ * @todo    move into PMA_Sql
  */
 function PMA_formatSql($parsed_sql, $unparsed_sql = '')
 {
@@ -419,7 +421,7 @@ function PMA_showMySQLDocu($chapter, $link, $big_icon = false, $anchor = '', $ju
 /**
  * Displays a link to the phpMyAdmin documentation
  *
- * @param string  $anchor  anchor in documentation
+ * @param string $anchor anchor in documentation
  *
  * @return  string  the html link
  *
@@ -437,7 +439,7 @@ function PMA_showDocu($anchor)
 /**
  * Displays a link to the PHP documentation
  *
- * @param string  $target  anchor in documentation
+ * @param string $target anchor in documentation
  *
  * @return string  the html link
  *
@@ -457,9 +459,9 @@ function PMA_showPHPDocu($target)
 /**
  * returns HTML for a footnote marker and add the messsage to the footnotes
  *
- * @param string  $message the error message
- * @param bool    $bbcode
- * @param string  $type
+ * @param string $message the error message
+ * @param bool   $bbcode
+ * @param string $type    message types
  *
  * @return  string html code for a footnote marker
  *
@@ -500,11 +502,11 @@ function PMA_showHint($message, $bbcode = false, $type = 'notice')
 /**
  * Displays a MySQL error message in the right frame.
  *
- * @param string  $error_message   the error message
- * @param string  $the_query       the sql query that failed
- * @param bool    $is_modify_link  whether to show a "modify" link or not
- * @param string  $back_url        the "back" link url (full path is not required)
- * @param bool    $exit            EXIT the page?
+ * @param string $error_message  the error message
+ * @param string $the_query      the sql query that failed
+ * @param bool   $is_modify_link whether to show a "modify" link or not
+ * @param string $back_url       the "back" link url (full path is not required)
+ * @param bool   $exit           EXIT the page?
  *
  * @global  string    the curent table
  * @global  string    the current db
@@ -512,14 +514,14 @@ function PMA_showHint($message, $bbcode = false, $type = 'notice')
  * @access  public
  */
 function PMA_mysqlDie($error_message = '', $the_query = '',
-                        $is_modify_link = true, $back_url = '', $exit = true)
+$is_modify_link = true, $back_url = '', $exit = true)
 {
     global $table, $db;
 
     /**
      * start http output, display html headers
      */
-    require_once './libraries/header.inc.php';
+    include_once './libraries/header.inc.php';
 
     $error_msg_output = '';
 
@@ -641,7 +643,7 @@ function PMA_mysqlDie($error_message = '', $the_query = '',
         /**
          * display footer and exit
          */
-        require './libraries/footer.inc.php';
+        include './libraries/footer.inc.php';
     } else {
         echo $error_msg_output;
     }
@@ -650,10 +652,10 @@ function PMA_mysqlDie($error_message = '', $the_query = '',
 /**
  * returns array with tables of given db with extended information and grouped
  *
- * @param string   $db     name of db
- * @param string   $tables name of tables
- * @param integer  $limit_offset   list offset
- * @param int|bool $limit_count    max tables to return
+ * @param string   $db           name of db
+ * @param string   $tables       name of tables
+ * @param integer  $limit_offset list offset
+ * @param int|bool $limit_count  max tables to return
  *
  * @return  array    (recursive) grouped table list
  */
@@ -782,10 +784,10 @@ function PMA_getTableList($db, $tables = null, $limit_offset = 0, $limit_count =
  *
  * </code>
  *
- * @param mixed    $a_name    the database, table or field name to "backquote"
- *                              or array of it
- * @param boolean  $do_it     a flag to bypass this function (used by dump
- *                              functions)
+ * @param mixed   $a_name the database, table or field name to "backquote"
+ *                        or array of it
+ * @param boolean $do_it  a flag to bypass this function (used by dump
+ *                        functions)
  *
  * @return  mixed    the "backquoted" database, table or field name
  *
@@ -829,9 +831,8 @@ function PMA_whichCrlf()
     // Win case
     if (PMA_USR_OS == 'Win') {
         $the_crlf = "\r\n";
-    }
-    // Others
-    else {
+    } else {
+        // Others
         $the_crlf = "\n";
     }
 
@@ -880,10 +881,10 @@ if (typeof(window.parent) != 'undefined'
  * displays the message and the query
  * usually the message is the result of the query executed
  *
- * @param string  $message    the message to display
- * @param string  $sql_query  the query to display
- * @param string  $type       the type (level) of the message
- * @param boolean $is_view    is this a message after a VIEW operation?
+ * @param string  $message   the message to display
+ * @param string  $sql_query the query to display
+ * @param string  $type      the type (level) of the message
+ * @param boolean $is_view   is this a message after a VIEW operation?
  *
  * @return  string
  *
@@ -1005,8 +1006,9 @@ function PMA_showMessage($message, $sql_query = null, $type = 'notice', $is_view
 
             // Same as below (append LIMIT), append the remembered ORDER BY
             if ($GLOBALS['cfg']['RememberSorting']
-             && isset($analyzed_display_query[0]['queryflags']['select_from'])
-             && isset($GLOBALS['sql_order_to_append'])) {
+                && isset($analyzed_display_query[0]['queryflags']['select_from'])
+                && isset($GLOBALS['sql_order_to_append'])
+            ) {
                 $query_base = $analyzed_display_query[0]['section_before_limit']
                     . "\n" . $GLOBALS['sql_order_to_append']
                     . $analyzed_display_query[0]['section_after_limit'];
@@ -1158,10 +1160,10 @@ function PMA_showMessage($message, $sql_query = null, $type = 'notice', $is_view
         ) {
             $validate_params = $url_params;
             if (!empty($GLOBALS['validatequery'])) {
-                $validate_message = __('Skip Validate SQL') ;
+                $validate_message = __('Skip Validate SQL');
             } else {
                 $validate_params['validatequery'] = 1;
-                $validate_message = __('Validate SQL') ;
+                $validate_message = __('Validate SQL');
             }
 
             $validate_link = 'import.php' . PMA_generate_common_url($validate_params);
@@ -1271,7 +1273,8 @@ function PMA_profilingSupported()
 /**
  * Displays a form with the Profiling checkbox
  *
- * @param string  $sql_query
+ * @param string $sql_query sql query
+ *
  * @access  public
  */
 function PMA_profilingCheckbox($sql_query)
@@ -1290,9 +1293,9 @@ function PMA_profilingCheckbox($sql_query)
 /**
  * Formats $value to byte view
  *
- * @param double $value  the value to format
- * @param int    $limes  the sensitiveness
- * @param int    $comma  the number of decimals to retain
+ * @param double $value the value to format
+ * @param int    $limes the sensitiveness
+ * @param int    $comma the number of decimals to retain
  *
  * @return   array    the formatted value and its unit
  *
@@ -1346,7 +1349,7 @@ function PMA_formatByteDown($value, $limes = 6, $comma = 0)
 /**
  * Changes thousands and decimal separators to locale specific values.
  *
- * @param $value
+ * @param string $value the value
  *
  * @return string
  */
@@ -1360,7 +1363,8 @@ function PMA_localizeNumber($value)
             /* l10n: Decimal separator */
             __('.'),
             ),
-        $value);
+        $value
+    );
 }
 
 /**
@@ -1376,13 +1380,14 @@ function PMA_localizeNumber($value)
  * echo PMA_formatNumber(0.003, 3, 3);      //       0.003
  * echo PMA_formatNumber(0.00003, 3, 2);    //       0.03 m
  * echo PMA_formatNumber(0, 6);             //       0
- *
  * </code>
- * @param double   $value            the value to format
- * @param integer  $digits_left      number of digits left of the comma
- * @param integer  $digits_right     number of digits right of the comma
- * @param boolean  $only_down        do not reformat numbers below 1
- * @param boolean  $noTrailingZero   removes trailing zeros right of the comma (default: true)
+ *
+ * @param double  $value          the value to format
+ * @param integer $digits_left    number of digits left of the comma
+ * @param integer $digits_right   number of digits right of the comma
+ * @param boolean $only_down      do not reformat numbers below 1
+ * @param boolean $noTrailingZero removes trailing zeros right of the comma
+ *                                (default: true)
  *
  * @return  string   the formatted value and its unit
  *
@@ -1390,7 +1395,9 @@ function PMA_localizeNumber($value)
  */
 function PMA_formatNumber($value, $digits_left = 3, $digits_right = 0, $only_down = false, $noTrailingZero = true)
 {
-    if ($value==0) return '0';
+    if ($value==0) {
+        return '0';
+    }
 
     $originalValue = $value;
     //number_format is not multibyte safe, str_replace is safe
@@ -1449,7 +1456,9 @@ function PMA_formatNumber($value, $digits_left = 3, $digits_right = 0, $only_dow
         $d-= floor(($digits_left - $cur_digits)/3);
     }
 
-    if ($d<0 && $only_down) $d=0;
+    if ($d<0 && $only_down) {
+        $d=0;
+    }
 
     $value = round($value / (PMA_pow(1000, $d, 'pow') / $dh)) /$dh;
     $unit = $units[$d];
@@ -1458,7 +1467,7 @@ function PMA_formatNumber($value, $digits_left = 3, $digits_right = 0, $only_dow
     if ($noTrailingZero) {
         $value = PMA_localizeNumber(
             preg_replace('/(?<=\d)(?=(\d{3})+(?!\d))/', ',', $value)
-            );
+        );
     } else {
         //number_format is not multibyte safe, str_replace is safe
         $value = PMA_localizeNumber(number_format($value, $digits_right));
@@ -1474,7 +1483,7 @@ function PMA_formatNumber($value, $digits_left = 3, $digits_right = 0, $only_dow
 /**
  * Returns the number of bytes when a formatted size is given
  *
- * @param string  $formatted_size  the size expression (for example 8MB)
+ * @param string $formatted_size the size expression (for example 8MB)
  *
  * @return  integer  The numerical part of the expression (for example 8)
  */
@@ -1495,8 +1504,8 @@ function PMA_extractValueFromFormattedSize($formatted_size)
 /**
  * Writes localised date
  *
- * @param string $timestamp  the current timestamp
- * @param string $format     format
+ * @param string $timestamp the current timestamp
+ * @param string $format    format
  *
  * @return  string   the formatted date
  *
@@ -1565,8 +1574,8 @@ function PMA_localisedDate($timestamp = -1, $format = '')
  * returns a tab for tabbed navigation.
  * If the variables $link and $args ar left empty, an inactive tab is created
  *
- * @param array   $tab    array with all options
- * @param array   $url_params
+ * @param array $tab        array with all options
+ * @param array $url_params
  *
  * @return  string  html code for one tab, a link if valid otherwise a span
  *
@@ -1593,7 +1602,8 @@ function PMA_generate_html_tab($tab, $url_params = array(), $base_dir='')
     // determine additionnal style-class
     if (empty($tab['class'])) {
         if (! empty($tab['active'])
-         || PMA_isValid($GLOBALS['active_page'], 'identical', $tab['link'])) {
+            || PMA_isValid($GLOBALS['active_page'], 'identical', $tab['link'])
+        ) {
             $tab['class'] = 'active';
         } elseif (is_null($tab['active']) && empty($GLOBALS['active_page'])
           && basename($GLOBALS['PMA_PHP_SELF']) == $tab['link']
@@ -1630,19 +1640,21 @@ function PMA_generate_html_tab($tab, $url_params = array(), $base_dir='')
 
     // display icon, even if iconic is disabled but the link-text is missing
     if (($GLOBALS['cfg']['MainPageIconic'] || empty($tab['text']))
-        && isset($tab['icon'])) {
+        && isset($tab['icon'])
+    ) {
         // avoid generating an alt tag, because it only illustrates
         // the text that follows and if browser does not display
         // images, the text is duplicated
         $image = '<img class="icon %1$s" src="' . $base_dir . 'themes/dot.gif"'
             .' width="16" height="16" alt="" />%2$s';
         $tab['text'] = sprintf($image, htmlentities($tab['icon']), $tab['text']);
-    }
-    // check to not display an empty link-text
-    elseif (empty($tab['text'])) {
+    } elseif (empty($tab['text'])) {
+        // check to not display an empty link-text
         $tab['text'] = '?';
-        trigger_error('empty linktext in function ' . __FUNCTION__ . '()',
-            E_USER_NOTICE);
+        trigger_error(
+            'empty linktext in function ' . __FUNCTION__ . '()',
+            E_USER_NOTICE
+        );
     }
 
     //Set the id for the tab, if set in the params
@@ -1666,8 +1678,8 @@ function PMA_generate_html_tab($tab, $url_params = array(), $base_dir='')
 /**
  * returns html-code for a tab navigation
  *
- * @param array   $tabs   one element per tab
- * @param string  $url_params
+ * @param array  $tabs       one element per tab
+ * @param string $url_params
  *
  * @return  string  html-code for tab-navigation
  */
@@ -1695,14 +1707,14 @@ function PMA_generate_html_tabs($tabs, $url_params, $base_dir='')
  * Displays a link, or a button if the link's URL is too large, to
  * accommodate some browsers' limitations
  *
- * @param string  $url the URL
- * @param string  $message the link message
- * @param mixed   $tag_params  string: js confirmation
- *                              array: additional tag params (f.e. style="")
- * @param boolean $new_form    we set this to false when we are already in
- *                              a  form, to avoid generating nested forms
- * @param boolean $strip_img
- * @param string  $target
+ * @param string  $url        the URL
+ * @param string  $message    the link message
+ * @param mixed   $tag_params string: js confirmation
+ *                            array: additional tag params (f.e. style="")
+ * @param boolean $new_form   we set this to false when we are already in
+ *                            a  form, to avoid generating nested forms
+ * @param boolean $strip_img  whether to strip the image
+ * @param string  $target     target
  *
  * @return string  the results to be echoed or saved in an array
  */
@@ -1752,9 +1764,9 @@ function PMA_linkOrButton($url, $message, $tag_params = array(),
     if ($url_length <= $GLOBALS['cfg']['LinkLengthLimit']) {
         if ($suhosin_get_MaxValueLength = ini_get('suhosin.get.max_value_length')) {
             $query_parts = PMA_splitURLQuery($url);
-            foreach($query_parts as $query_pair) {
+            foreach ($query_parts as $query_pair) {
                 list($eachvar, $eachval) = explode('=', $query_pair);
-                if(strlen($eachval) > $suhosin_get_MaxValueLength) {
+                if (strlen($eachval) > $suhosin_get_MaxValueLength) {
                     $in_suhosin_limits = false;
                     break;
                 }
@@ -1822,10 +1834,12 @@ function PMA_linkOrButton($url, $message, $tag_params = array(),
 /**
  * Splits a URL string by parameter
  *
- * @param string  $url the URL
+ * @param string $url the URL
+ *
  * @return array  the parameter/value pairs, for example [0] db=sakila
  */
-function PMA_splitURLQuery($url) {
+function PMA_splitURLQuery($url)
+{
     // decode encoded url separators
     $separator   = PMA_get_arg_separator();
     // on most places separator is still hard coded ...
@@ -1844,7 +1858,7 @@ function PMA_splitURLQuery($url) {
 /**
  * Returns a given timespan value in a readable format.
  *
- * @param int  $seconds  the timespan
+ * @param int $seconds the timespan
  *
  * @return string  the formatted value
  */
@@ -1872,11 +1886,11 @@ function PMA_timespanFormat($seconds)
  * Fulfills todo-item
  * http://sf.net/tracker/?func=detail&aid=544361&group_id=23067&atid=377411
  *
- * @todo    add a multibyte safe function PMA_STR_split()
- * @param string  $string     The string
- * @param string  $Separator  The Separator (defaults to "<br />\n")
+ * @param string $string    The string
+ * @param string $Separator The Separator (defaults to "<br />\n")
  *
  * @access  public
+ * @todo    add a multibyte safe function PMA_STR_split()
  *
  * @return  string      The flipped string
  */
@@ -1920,16 +1934,17 @@ function PMA_flipstring($string, $Separator = "<br />\n")
  * Not sure we could use a strMissingParameter message here,
  * would have to check if the error message file is always available
  *
- * @todo    use PMA_fatalError() if $die === true?
- * @param array  $params  The names of the parameters needed by the calling script.
- * @param bool   $die Stop the execution?
- *                  (Set this manually to false in the calling script
- *                   until you know all needed parameters to check).
- * @param bool   $request Whether to include this list in checking for special params.
+ * @param array $params  The names of the parameters needed by the calling script.
+ * @param bool  $die     Stop the execution?
+ *                       (Set this manually to false in the calling script
+ *                       until you know all needed parameters to check).
+ * @param bool  $request Whether to include this list in checking for special params.
+ *
  * @global  string  path to current script
  * @global  boolean flag whether any special variable was required
  *
  * @access  public
+ * @todo    use PMA_fatalError() if $die === true?
  */
 function PMA_checkParameters($params, $die = true, $request = true)
 {
@@ -1961,7 +1976,7 @@ function PMA_checkParameters($params, $die = true, $request = true)
         /**
          * display html meta tags
          */
-        require_once './libraries/header_meta_style.inc.php';
+        include_once './libraries/header_meta_style.inc.php';
         echo '</head><body><p>' . $error_message . '</p></body></html>';
         if ($die) {
             exit();
@@ -1972,17 +1987,17 @@ function PMA_checkParameters($params, $die = true, $request = true)
 /**
  * Function to generate unique condition for specified row.
  *
- * @param resource    $handle         current query result
- * @param integer     $fields_cnt     number of fields
- * @param array       $fields_meta    meta information about fields
- * @param array       $row            current row
- * @param boolean     $force_unique   generate condition only on pk or unique
+ * @param resource $handle       current query result
+ * @param integer  $fields_cnt   number of fields
+ * @param array    $fields_meta  meta information about fields
+ * @param array    $row          current row
+ * @param boolean  $force_unique generate condition only on pk or unique
  *
  * @access  public
  *
  * @return  array     the calculated condition and whether condition is unique
  */
-function PMA_getUniqueCondition($handle, $fields_cnt, $fields_meta, $row, $force_unique=false)
+function PMA_getUniqueCondition($handle, $fields_cnt, $fields_meta, $row, $force_unique = false)
 {
     $primary_key          = '';
     $unique_key           = '';
@@ -2123,12 +2138,12 @@ function PMA_getUniqueCondition($handle, $fields_cnt, $fields_meta, $row, $force
 /**
  * Generate a button or image tag
  *
- * @param string  $button_name    name of button element
- * @param string  $button_class   class of button element
- * @param string  $image_name     name of image element
- * @param string  $text           text to display
- * @param string  $image          image to display
- * @param string  $value
+ * @param string $button_name  name of button element
+ * @param string $button_class class of button element
+ * @param string $image_name   name of image element
+ * @param string $text         text to display
+ * @param string $image        image to display
+ * @param string $value        value
  *
  * @access  public
  */
@@ -2167,17 +2182,18 @@ function PMA_buttonOrImage($button_name, $button_class, $image_name, $text,
 /**
  * Generate a pagination selector for browsing resultsets
  *
- * @param int     $rows         Number of rows in the pagination set
- * @param int     $pageNow      current page number
- * @param int     $nbTotalPage  number of total pages
- * @param int     $showAll      If the number of pages is lower than this
- *                               variable, no pages will be omitted in pagination
- * @param int     $sliceStart   How many rows at the beginning should always be shown?
- * @param int     $sliceEnd     How many rows at the end should always be shown?
- * @param int     $percent      Percentage of calculation page offsets to hop to a next page
- * @param int     $range        Near the current page, how many pages should
- *                               be considered "nearby" and displayed as well?
- * @param string  $prompt       The prompt to display (sometimes empty)
+ * @param int    $rows        Number of rows in the pagination set
+ * @param int    $pageNow     current page number
+ * @param int    $nbTotalPage number of total pages
+ * @param int    $showAll     If the number of pages is lower than this
+ *                            variable, no pages will be omitted in pagination
+ * @param int    $sliceStart  How many rows at the beginning should always be shown?
+ * @param int    $sliceEnd    How many rows at the end should always be shown?
+ * @param int    $percent     Percentage of calculation page offsets to hop to a
+ *                            next page
+ * @param int    $range       Near the current page, how many pages should
+ *                            be considered "nearby" and displayed as well?
+ * @param string $prompt      The prompt to display (sometimes empty)
  *
  * @return string
  *
@@ -2254,7 +2270,7 @@ function PMA_pageselector($rows, $pageNow = 1, $nbTotalPage = 1,
         } else {
             $selected = '';
         }
-        $gotopage .= '                <option ' . $selected 
+        $gotopage .= '                <option ' . $selected
             . ' value="' . (($i - 1) * $rows) . '">' . $i . '</option>' . "\n";
     }
 
@@ -2267,15 +2283,16 @@ function PMA_pageselector($rows, $pageNow = 1, $nbTotalPage = 1,
 /**
  * Generate navigation for a list
  *
- * @todo    use $pos from $_url_params
- * @param int    $count        number of elements in the list
- * @param int    $pos          current position in the list
- * @param array  $_url_params  url parameters
- * @param string $script       script name for form target
- * @param string $frame        target frame
- * @param int    $max_count    maximum number of elements to display from the list
+ * @param int    $count       number of elements in the list
+ * @param int    $pos         current position in the list
+ * @param array  $_url_params url parameters
+ * @param string $script      script name for form target
+ * @param string $frame       target frame
+ * @param int    $max_count   maximum number of elements to display from the list
  *
  * @access  public
+ *
+ * @todo    use $pos from $_url_params
  */
 function PMA_listNavigator($count, $pos, $_url_params, $script, $frame, $max_count)
 {
@@ -2312,9 +2329,10 @@ function PMA_listNavigator($count, $pos, $_url_params, $script, $frame, $max_cou
         echo "\n", '<form action="./', basename($script), '" method="post" target="', $frame, '">', "\n";
         echo PMA_generate_common_hidden_inputs($_url_params);
         echo PMA_pageselector(
-                $max_count,
-                floor(($pos + 1) / $max_count) + 1,
-                ceil($count / $max_count));
+            $max_count,
+            floor(($pos + 1) / $max_count) + 1,
+            ceil($count / $max_count)
+        );
         echo '</form>';
 
         if ($pos + $max_count < $count) {
@@ -2357,7 +2375,7 @@ function PMA_listNavigator($count, $pos, $_url_params, $script, $frame, $max_cou
  *
  * </code>
  *
- * @param string  $dir with wildcard for user
+ * @param string $dir with wildcard for user
  *
  * @return  string  per user directory
  */
@@ -2374,7 +2392,7 @@ function PMA_userDir($dir)
 /**
  * returns html code for db link to default db page
  *
- * @param string  $database
+ * @param string $database database
  *
  * @return  string  html link to default db page
  */
@@ -2398,10 +2416,10 @@ function PMA_getDbLink($database = null)
  * Displays a lightbulb hint explaining a known external bug
  * that affects a functionality
  *
- * @param string  $functionality localized message explaining the func.
- * @param string  $component  'mysql' (eventually, 'php')
- * @param string  $minimum_version of this component
- * @param string  $bugref  bug reference for this component
+ * @param string $functionality   localized message explaining the func.
+ * @param string $component       'mysql' (eventually, 'php')
+ * @param string $minimum_version of this component
+ * @param string $bugref          bug reference for this component
  */
 function PMA_externalBug($functionality, $component, $minimum_version, $bugref)
 {
@@ -2417,6 +2435,8 @@ function PMA_externalBug($functionality, $component, $minimum_version, $bugref)
  * @param string  $label           label for checkbox
  * @param boolean $checked         is it initially checked?
  * @param boolean $onclick         should it submit the form on click?
+ *
+ * @return the HTML for the checkbox
  */
 function PMA_display_html_checkbox($html_field_name, $label, $checked, $onclick)
 {
@@ -2433,6 +2453,8 @@ function PMA_display_html_checkbox($html_field_name, $label, $checked, $onclick)
  * @param boolean $line_break      whether to add an HTML line break after a choice
  * @param boolean $escape_label    whether to use htmlspecialchars() on label
  * @param string  $class           enclose each choice with a div of this class
+ *
+ * @return the HTML for the tadio buttons
  */
 function PMA_display_html_radio($html_field_name, $choices, $checked_choice = '', $line_break = true, $escape_label = true, $class='')
 {
@@ -2460,11 +2482,12 @@ function PMA_display_html_radio($html_field_name, $choices, $checked_choice = ''
 /**
  * Generates and returns an HTML dropdown
  *
- * @param string  $select_name
- * @param array   $choices        choices values
- * @param string  $active_choice  the choice to select by default
- * @param string  $id             id of the select element; can be different in case
- *                                  the dropdown is present more than once on the page
+ * @param string $select_name   name for the select element
+ * @param array  $choices       choices values
+ * @param string $active_choice the choice to select by default
+ * @param string $id            id of the select element; can be different in case
+ *                              the dropdown is present more than once on the page
+ *
  * @return string
  *
  * @todo    support titles
@@ -2489,8 +2512,8 @@ function PMA_generate_html_dropdown($select_name, $choices, $active_choice, $id)
  * controlling the slider; you have to generate the </div> yourself
  * after the sliding section.
  *
- * @param string  $id the id of the <div> on which to apply the effect
- * @param string  $message the message to show as a link
+ * @param string $id      the id of the <div> on which to apply the effect
+ * @param string $message the message to show as a link
  */
 function PMA_generate_slider_effect($id, $message)
 {
@@ -2511,13 +2534,14 @@ function PMA_generate_slider_effect($id, $message)
 }
 
 /**
- * Creates an AJAX sliding toggle button (or and equivalent form when AJAX is disabled)
+ * Creates an AJAX sliding toggle button
+ * (or and equivalent form when AJAX is disabled)
  *
- * @param string   $action        The URL for the request to be executed
- * @param string   $select_name   The name for the dropdown box
- * @param array    $options       An array of options (see rte_footer.lib.php)
- * @param string   $callback      A JS snippet to execute when the request is
- *                                   successfully processed
+ * @param string $action      The URL for the request to be executed
+ * @param string $select_name The name for the dropdown box
+ * @param array  $options     An array of options (see rte_footer.lib.php)
+ * @param string $callback    A JS snippet to execute when the request is
+ *                            successfully processed
  *
  * @return   string   HTML code for the toggle button
  */
@@ -2602,8 +2626,8 @@ function PMA_clearUserCache()
 /**
  * Verifies if something is cached in the session
  *
- * @param string   $var
- * @param int|true $server
+ * @param string   $var    variable name
+ * @param int|true $server server
  *
  * @return boolean
  */
@@ -2618,8 +2642,8 @@ function PMA_cacheExists($var, $server = 0)
 /**
  * Gets cached information from the session
  *
- * @param string   $var
- * @param int|true $server
+ * @param string   $var    varibale name
+ * @param int|true $server server
  *
  * @return mixed
  */
@@ -2638,9 +2662,9 @@ function PMA_cacheGet($var, $server = 0)
 /**
  * Caches information in the session
  *
- * @param string   $var
- * @param mixed    $val
- * @param int|true $server
+ * @param string   $var    variable name
+ * @param mixed    $val    value
+ * @param int|true $server server
  *
  * @return mixed
  */
@@ -2655,8 +2679,8 @@ function PMA_cacheSet($var, $val = null, $server = 0)
 /**
  * Removes cached information from the session
  *
- * @param string   $var
- * @param int|true $server
+ * @param string   $var    variable name
+ * @param int|true $server server
  */
 function PMA_cacheUnset($var, $server = 0)
 {
@@ -2671,7 +2695,7 @@ function PMA_cacheUnset($var, $server = 0)
  * in MySQL a BIT field can be from 1 to 64 bits so we need this
  * function because in PHP, decbin() supports only 32 bits
  *
- * @param numeric $value coming from a BIT field
+ * @param numeric $value  coming from a BIT field
  * @param integer $length
  *
  * @return  string  the printable value
@@ -2689,7 +2713,7 @@ function PMA_printable_bit_value($value, $length)
 /**
  * Verifies whether the value contains a non-printable character
  *
- * @param string $value
+ * @param string $value value
  *
  * @return  boolean
  */
@@ -2702,7 +2726,7 @@ function PMA_contains_nonprintable_ascii($value)
  * Converts a BIT type default value
  * for example, b'010' becomes 010
  *
- * @param string $bit_default_value
+ * @param string $bit_default_value value
  *
  * @return  string the converted value
  */
@@ -2714,7 +2738,7 @@ function PMA_convert_bit_default_value($bit_default_value)
 /**
  * Extracts the various parts from a field type spec
  *
- * @param string $fieldspec
+ * @param string $fieldspec Field specification
  *
  * @return  array associative array containing type, spec_in_brackets
  *          and possibly enum_set_values (another array)
@@ -2760,8 +2784,8 @@ function PMA_extractFieldSpec($fieldspec)
                         $enum_set_values[] = $working;
                         $in_string = false;
 
-                    // Otherwise, this is a 'double quote', and can be added to the working string
                     } elseif ($next == "'") {
+                        // Otherwise, this is a 'double quote', and can be added to the working string
                         $working .= "'";
                         // Skip the next char; we already know what it is
                         $index++;
@@ -2830,7 +2854,7 @@ function PMA_extractFieldSpec($fieldspec)
 /**
  * Verifies if this table's engine supports foreign keys
  *
- * @param string $engine
+ * @param string $engine engine
  *
  * @return  boolean
  */
@@ -2847,7 +2871,7 @@ function PMA_foreignkey_supported($engine)
 /**
  * Replaces some characters by a displayable equivalent
  *
- * @param string $content
+ * @param string $content content
  *
  * @return  string the content with characters replaced
  */
@@ -2864,11 +2888,13 @@ function PMA_replace_binary_contents($content)
 /**
  * Converts GIS data to Well Known Text format
  *
- * @param  $data     GIS data
- * @param  $includeSRID  Add SRID to the WKT
+ * @param binary $data        GIS data
+ * @param bool   $includeSRID Add SRID to the WKT
+ *
  * @return GIS data in Well Know Text format
  */
-function PMA_asWKT($data, $includeSRID = false) {
+function PMA_asWKT($data, $includeSRID = false)
+{
     // Convert to WKT format
     $hex = bin2hex($data);
     $wktsql     = "SELECT ASTEXT(x'" . $hex . "')";
@@ -2889,7 +2915,7 @@ function PMA_asWKT($data, $includeSRID = false) {
 /**
  * If the string starts with a \r\n pair (0x0d0a) add an extra \n
  *
- * @param string $string
+ * @param string $string string
  *
  * @return  string with the chars replaced
  */
@@ -2907,8 +2933,8 @@ function PMA_duplicateFirstNewline($string)
  * Get the action word corresponding to a script name
  * in order to display it as a title in navigation panel
  *
- * @param string $target  a valid value for $cfg['LeftDefaultTabTable'], $cfg['DefaultTabTable']
- *                        or $cfg['DefaultTabDatabase']
+ * @param string $target a valid value for $cfg['LeftDefaultTabTable'],
+ *                       $cfg['DefaultTabTable'] or $cfg['DefaultTabDatabase']
  *
  * @return array
  */
@@ -2934,9 +2960,10 @@ function PMA_getTitleForTarget($target)
 /**
  * Formats user string, expading @VARIABLES@, accepting strftime format string.
  *
- * @param string    $string  Text where to do expansion.
- * @param function  $escape  Function to call for escaping variable values.
- * @param array     $updates Array with overrides for default parameters (obtained from GLOBALS).
+ * @param string   $string  Text where to do expansion.
+ * @param function $escape  Function to call for escaping variable values.
+ * @param array    $updates Array with overrides for default parameters
+ *                 (obtained from GLOBALS).
  *
  * @return string
  */
@@ -3005,9 +3032,14 @@ function PMA_expandUserString($string, $escape = null, $updates = array())
  * function that generates a json output for an ajax request and ends script
  * execution
  *
- * @param PMA_Message|string  $message     message string containing the html of the message
- * @param bool                $success success whether the ajax request was successfull
- * @param array               $extra_data  extra_data  optional - any other data as part of the json request
+ * @param PMA_Message|string $message    message string containing the
+ *                                       html of the message
+ * @param bool               $success    success whether the ajax request
+ *                                       was successfull
+ * @param array              $extra_data extra data  optional -
+ *                                       any other data as part of the json request
+ *
+ * @return nothing
  */
 function PMA_ajaxResponse($message, $success = true, $extra_data = array())
 {
@@ -3016,17 +3048,14 @@ function PMA_ajaxResponse($message, $success = true, $extra_data = array())
         $response['success'] = true;
         if ($message instanceof PMA_Message) {
             $response['message'] = $message->getDisplay();
-        }
-        else {
+        } else {
             $response['message'] = $message;
         }
-    }
-    else {
+    } else {
         $response['success'] = false;
         if ($message instanceof PMA_Message) {
             $response['error'] = $message->getDisplay();
-        }
-        else {
+        } else {
             $response['error'] = $message;
         }
     }
@@ -3052,9 +3081,11 @@ function PMA_ajaxResponse($message, $success = true, $extra_data = array())
 }
 
 /**
- * Display the form used to browse anywhere on the local server for the file to import
+ * Display the form used to browse anywhere on the local server for a file to import
+ *
+ * @param string $max_upload_size maximum upload size
  *
- * @param $max_upload_size
+ * @return nothing
  */
 function PMA_browseUploadFile($max_upload_size)
 {
@@ -3070,8 +3101,10 @@ function PMA_browseUploadFile($max_upload_size)
 /**
  * Display the form used to select a file to import from the server upload directory
  *
- * @param $import_list
- * @param $uploaddir
+ * @param array  $import_list array of import types
+ * @param string $uploaddir   upload directory
+ *
+ * @return nothing
  */
 function PMA_selectUploadFile($import_list, $uploaddir)
 {
@@ -3133,8 +3166,8 @@ function PMA_buildActionTitles()
  * $cfg['ColumnTypes'] and either returns an array (useful for quickly checking
  * if a datatype is supported) or an HTML snippet that creates a drop-down list.
  *
- * @param bool    $html       Whether to generate an html snippet or an array
- * @param string  $selected   The value to mark as selected in HTML mode
+ * @param bool   $html     Whether to generate an html snippet or an array
+ * @param string $selected The value to mark as selected in HTML mode
  *
  * @return  mixed   An HTML snippet or an array of datatypes.
  *
@@ -3197,13 +3230,21 @@ function PMA_getSupportedDatatypes($html = false, $selected = '')
  *
  * @return   array   list of datatypes
  */
-
-function PMA_unsupportedDatatypes() {
+function PMA_unsupportedDatatypes()
+{
     $no_support_types = array();
     return $no_support_types;
 }
 
-function PMA_getGISDatatypes($upper_case = false) {
+/**
+ * Return GIS data types
+ *
+ * @param bool $upper_case whether to return values in upper case
+ *
+ * @return array GIS data types
+ */
+function PMA_getGISDatatypes($upper_case = false)
+{
     $gis_data_types = array('geometry',
                             'point',
                             'linestring',
@@ -3226,8 +3267,11 @@ function PMA_getGISDatatypes($upper_case = false) {
  * Generates GIS data based on the string passed.
  *
  * @param string $gis_string GIS string
+ *
+ * @return GIS data enclosed in 'GeomFromText' function
  */
-function PMA_createGISData($gis_string) {
+function PMA_createGISData($gis_string)
+{
     $gis_string =  trim($gis_string);
     $geom_types = '(POINT|MULTIPOINT|LINESTRING|MULTILINESTRING|POLYGON|MULTIPOLYGON|GEOMETRYCOLLECTION)';
     if (preg_match("/^'" . $geom_types . "\(.*\)',[0-9]*$/i", $gis_string)) {
@@ -3253,8 +3297,8 @@ function PMA_createGISData($gis_string) {
  * @return array names and details of the functions that can be applied on
  *               geometry data typess.
  */
-function PMA_getGISFunctions($geom_type = null, $binary = true, $display = false) {
-
+function PMA_getGISFunctions($geom_type = null, $binary = true, $display = false)
+{
     $funcs = array();
     if ($display) {
         $funcs[] = array('display' => ' ');
@@ -3352,9 +3396,9 @@ function PMA_getGISFunctions($geom_type = null, $binary = true, $display = false
 /**
  * Creates a dropdown box with MySQL functions for a particular column.
  *
- * @param array    $field          Data about the column for which
- *                                    to generate the dropdown
- * @param bool     $insert_mode    Whether the operation is 'insert'
+ * @param array $field       Data about the column for which
+ *                           to generate the dropdown
+ * @param bool  $insert_mode Whether the operation is 'insert'
  *
  * @global   array    $cfg            PMA configuration
  * @global   array    $analyzed_sql   Analyzed SQL query
@@ -3458,12 +3502,11 @@ function PMA_getFunctionsForField($field, $insert_mode)
  *            // 'CREATE ROUTINE' privilege or, if not, checks if the
  *            // user has this privilege on database 'mydb'.
  *
- *
- * @param string   $priv   The privilege to check
- * @param mixed    $db     null, to only check global privileges
- *                           string, db name where to also check for privileges
- * @param mixed    $tbl    null, to only check global privileges
- *                           string, db name where to also check for privileges
+ * @param string $priv The privilege to check
+ * @param mixed  $db   null, to only check global privileges
+ *                     string, db name where to also check for privileges
+ * @param mixed  $tbl  null, to only check global privileges
+ *                     string, db name where to also check for privileges
  *
  * @return bool
  */
@@ -3485,21 +3528,31 @@ function PMA_currentUserHasPrivilege($priv, $db = null, $tbl = null)
     $query = "SELECT `PRIVILEGE_TYPE` FROM `INFORMATION_SCHEMA`.`%s` "
            . "WHERE GRANTEE='%s' AND PRIVILEGE_TYPE='%s'";
     // Check global privileges first.
-    if (PMA_DBI_fetch_value(sprintf($query,
-                                    'USER_PRIVILEGES',
-                                    $username,
-                                    $priv))) {
+    if (PMA_DBI_fetch_value(
+        sprintf(
+            $query,
+            'USER_PRIVILEGES',
+            $username,
+            $priv
+        )
+    )
+    ) {
         return true;
     }
     // If a database name was provided and user does not have the
     // required global privilege, try database-wise permissions.
     if ($db !== null) {
         $query .= " AND TABLE_SCHEMA='%s'";
-        if (PMA_DBI_fetch_value(sprintf($query,
-                                        'SCHEMA_PRIVILEGES',
-                                        $username,
-                                        $priv,
-                                        PMA_sqlAddSlashes($db)))) {
+        if (PMA_DBI_fetch_value(
+            sprintf(
+                $query,
+                'SCHEMA_PRIVILEGES',
+                $username,
+                $priv,
+                PMA_sqlAddSlashes($db)
+            )
+        )
+        ) {
             return true;
         }
     } else {
@@ -3511,12 +3564,17 @@ function PMA_currentUserHasPrivilege($priv, $db = null, $tbl = null)
     // find any valid privileges, try table-wise privileges.
     if ($tbl !== null) {
         $query .= " AND TABLE_NAME='%s'";
-        if ($retval = PMA_DBI_fetch_value(sprintf($query,
-                                                  'TABLE_PRIVILEGES',
-                                                  $username,
-                                                  $priv,
-                                                  PMA_sqlAddSlashes($db),
-                                                  PMA_sqlAddSlashes($tbl)))) {
+        if ($retval = PMA_DBI_fetch_value(
+            sprintf(
+                $query,
+                'TABLE_PRIVILEGES',
+                $username,
+                $priv,
+                PMA_sqlAddSlashes($db),
+                PMA_sqlAddSlashes($tbl)
+            )
+        )
+        ) {
             return true;
         }
     }


hooks/post-receive
-- 
phpMyAdmin




More information about the Git mailing list