[Phpmyadmin-git] [SCM] phpMyAdmin branch, master, updated. RELEASE_3_4_3_1-14450-g45aac8d
Dieter Adriaenssens
ruleant at users.sourceforge.net
Thu Aug 11 21:37:53 CEST 2011
The branch, master has been updated
via 45aac8dbf4e87b12ba3c2809c49ce250161afabf (commit)
from b48b13d20fb89b511348bef723bac05755d12fee (commit)
- Log -----------------------------------------------------------------
commit 45aac8dbf4e87b12ba3c2809c49ce250161afabf
Author: Dieter Adriaenssens <ruleant at users.sourceforge.net>
Date: Thu Aug 11 21:37:36 2011 +0200
coding style
-----------------------------------------------------------------------
Summary of changes:
import.php | 2 +-
libraries/advisor.class.php | 70 ++++++++++++++++++++++++----------------
libraries/engines/pbxt.lib.php | 2 +-
libraries/export/xml.php | 26 ++++++++-------
libraries/import.lib.php | 7 +---
libraries/import/xml.php | 3 +-
libraries/sqlparser.lib.php | 2 +-
libraries/sqlvalidator.lib.php | 2 +-
sql.php | 8 ++---
9 files changed, 66 insertions(+), 56 deletions(-)
diff --git a/import.php b/import.php
index b9b7d15..56732ae 100644
--- a/import.php
+++ b/import.php
@@ -237,7 +237,7 @@ if (!empty($local_import_file) && !empty($cfg['UploadDir'])) {
$local_import_file = PMA_securePath($local_import_file);
$import_file = PMA_userDir($cfg['UploadDir']) . $local_import_file;
-} elseif (empty($import_file) || !is_uploaded_file($import_file)) {
+} elseif (empty($import_file) || !is_uploaded_file($import_file)) {
$import_file = 'none';
}
diff --git a/libraries/advisor.class.php b/libraries/advisor.class.php
index 11e0119..75c8a8d 100644
--- a/libraries/advisor.class.php
+++ b/libraries/advisor.class.php
@@ -43,11 +43,11 @@ class Advisor
'errors' => array()
);
- foreach($this->parseResult['rules'] as $rule) {
+ foreach ($this->parseResult['rules'] as $rule) {
$this->variables['value'] = 0;
$precond = true;
- if(isset($rule['precondition'])) {
+ if (isset($rule['precondition'])) {
try {
$precond = $this->ruleExprEvaluate($rule['precondition']);
} catch (Exception $e) {
@@ -56,9 +56,9 @@ class Advisor
}
}
- if(! $precond)
+ if (! $precond) {
$this->addRule('unchecked', $rule);
- else {
+ } else {
try {
$value = $this->ruleExprEvaluate($rule['formula']);
} catch(Exception $e) {
@@ -87,7 +87,7 @@ class Advisor
function splitJustification($rule)
{
$jst = preg_split('/\s*\|\s*/', $rule['justification'], 2);
- if(count($jst) > 1) {
+ if (count($jst) > 1) {
$jst[0] = preg_replace('/%( |,|\.|$)/','%%\1',$jst[0]);
return array($jst[0], $jst[1]);
}
@@ -95,12 +95,13 @@ class Advisor
}
// Adds a rule to the result list
- function addRule($type, $rule) {
+ function addRule($type, $rule)
+ {
switch($type) {
case 'notfired':
case 'fired':
$jst = Advisor::splitJustification($rule);
- if(count($jst) > 1) {
+ if (count($jst) > 1) {
try {
/* Translate */
$jst[0] = _gettext($jst[0]);
@@ -133,14 +134,15 @@ class Advisor
// Runs a code expression, replacing variable names with their respective values
// ignoreUntil: if > 0, it doesn't replace any variables until that string position, but still evaluates the whole expr
- function ruleExprEvaluate($expr, $ignoreUntil = 0) {
- if($ignoreUntil > 0) {
+ function ruleExprEvaluate($expr, $ignoreUntil = 0)
+ {
+ if ($ignoreUntil > 0) {
$exprIgnore = substr($expr,0,$ignoreUntil);
$expr = substr($expr,$ignoreUntil);
}
$expr = preg_replace('/fired\s*\(\s*(\'|")(.*)\1\s*\)/Uie','1',$expr); //isset($this->runResult[\'fired\']
$expr = preg_replace('/\b(\w+)\b/e','isset($this->variables[\'\1\']) ? (!is_numeric($this->variables[\'\1\']) ? \'"\'.$this->variables[\'\1\'].\'"\' : $this->variables[\'\1\']) : \'\1\'', $expr);
- if($ignoreUntil > 0){
+ if ($ignoreUntil > 0) {
$expr = $exprIgnore . $expr;
}
$value = 0;
@@ -149,12 +151,15 @@ class Advisor
eval('$value = '.$expr.';');
$err = ob_get_contents();
ob_end_clean();
- if($err) throw new Exception(strip_tags($err) . '<br />Executed code: $value = '.$expr.';');
+ if ($err) {
+ throw new Exception(strip_tags($err) . '<br />Executed code: $value = '.$expr.';');
+ }
return $value;
}
// Reads the rule file into an array, throwing errors messages on syntax errors
- function parseRulesFile() {
+ function parseRulesFile()
+ {
$file = file('libraries/advisory_rules.txt');
$errors = array();
$rules = array();
@@ -166,15 +171,17 @@ class Advisor
for ($i = 0; $i<$numLines; $i++) {
$line = $file[$i];
- if($line[0] == '#' || $line[0] == "\n") continue;
+ if ($line[0] == '#' || $line[0] == "\n") {
+ continue;
+ }
// Reading new rule
- if(substr($line, 0, 4) == 'rule') {
- if($ruleLine > 0) {
+ if (substr($line, 0, 4) == 'rule') {
+ if ($ruleLine > 0) {
$errors[] = 'Invalid rule declaration on line '.($i+1). ', expected line '.$ruleSyntax[$ruleLine++].' of previous rule' ;
continue;
}
- if(preg_match("/rule\s'(.*)'( \[(.*)\])?$/",$line,$match)) {
+ if (preg_match("/rule\s'(.*)'( \[(.*)\])?$/",$line,$match)) {
$ruleLine = 1;
$j++;
$rules[$j] = array( 'name' => $match[1]);
@@ -184,19 +191,27 @@ class Advisor
}
continue;
} else {
- if($ruleLine == -1) $errors[] = 'Unexpected characters on line '.($i+1);
+ if ($ruleLine == -1) {
+ $errors[] = 'Unexpected characters on line '.($i+1);
+ }
}
// Reading rule lines
- if($ruleLine > 0) {
- if(!isset($line[0])) continue; // Empty lines are ok
+ if ($ruleLine > 0) {
+ if (!isset($line[0])) {
+ continue; // Empty lines are ok
+ }
// Non tabbed lines are not
- if($line[0] != "\t") { $errors[] = 'Unexpected character on line '.($i+1).'. Expected tab, but found \''.$line[0].'\''; continue; }
+ if ($line[0] != "\t") {
+ $errors[] = 'Unexpected character on line '.($i+1).'
+ . Expected tab, but found \''.$line[0].'\'';
+ continue;
+ }
$rules[$j][$ruleSyntax[$ruleLine++]] = chop(substr($line,1));
}
// Rule complete
- if($ruleLine == $numRules) {
+ if ($ruleLine == $numRules) {
$ruleLine = -1;
}
}
@@ -210,23 +225,22 @@ function PMA_bytime($num, $precision)
$per = '';
if ($num >= 1) { # per second
$per = "per second";
- }
- elseif ($num*60 >= 1) { # per minute
+ } elseif ($num*60 >= 1) { # per minute
$num = $num*60;
$per = "per minute";
- }
- elseif ($num*60*60 >=1 ) { # per hour
+ } elseif ($num*60*60 >=1 ) { # per hour
$num = $num*60*60;
$per = "per hour";
- }
- else {
+ } else {
$num = $num*60*60*24;
$per = "per day";
}
$num = round($num, $precision);
- if($num == 0) $num = '<'.pow(10,-$precision);
+ if ($num == 0) {
+ $num = '<'.pow(10,-$precision);
+ }
return "$num $per";
}
diff --git a/libraries/engines/pbxt.lib.php b/libraries/engines/pbxt.lib.php
index 0ebd2ca..dc3c47d 100644
--- a/libraries/engines/pbxt.lib.php
+++ b/libraries/engines/pbxt.lib.php
@@ -91,7 +91,7 @@ class PMA_StorageEngine_pbxt extends PMA_StorageEngine
*/
function resolveTypeSize($formatted_size)
{
- if (preg_match('/^[0-9]+[a-zA-Z]+$/', $formatted_size)){
+ if (preg_match('/^[0-9]+[a-zA-Z]+$/', $formatted_size)) {
$value = PMA_extractValueFromFormattedSize($formatted_size);
} else {
$value = $formatted_size;
diff --git a/libraries/export/xml.php b/libraries/export/xml.php
index 3e4bda2..a1f7d8f 100644
--- a/libraries/export/xml.php
+++ b/libraries/export/xml.php
@@ -85,7 +85,8 @@ if (isset($plugin_list)) {
*
* @access public
*/
- function PMA_exportFooter() {
+ function PMA_exportFooter()
+ {
$foot = '</pma_xml_export>';
return PMA_exportOutputHandler($foot);
@@ -98,7 +99,8 @@ if (isset($plugin_list)) {
*
* @access public
*/
- function PMA_exportHeader() {
+ function PMA_exportHeader()
+ {
global $crlf;
global $cfg;
global $db;
@@ -268,7 +270,8 @@ if (isset($plugin_list)) {
*
* @access public
*/
- function PMA_exportDBHeader($db) {
+ function PMA_exportDBHeader($db)
+ {
global $crlf;
if (isset($GLOBALS['xml_export_contents']) && $GLOBALS['xml_export_contents']) {
@@ -278,9 +281,7 @@ if (isset($plugin_list)) {
. ' <database name="' . htmlspecialchars($db) . '">' . $crlf;
return PMA_exportOutputHandler($head);
- }
- else
- {
+ } else {
return true;
}
}
@@ -293,14 +294,13 @@ if (isset($plugin_list)) {
*
* @access public
*/
- function PMA_exportDBFooter($db) {
+ function PMA_exportDBFooter($db)
+ {
global $crlf;
if (isset($GLOBALS['xml_export_contents']) && $GLOBALS['xml_export_contents']) {
return PMA_exportOutputHandler(' </database>' . $crlf);
- }
- else
- {
+ } else {
return true;
}
}
@@ -313,7 +313,8 @@ if (isset($plugin_list)) {
*
* @access public
*/
- function PMA_exportDBCreate($db) {
+ function PMA_exportDBCreate($db)
+ {
return true;
}
@@ -329,7 +330,8 @@ if (isset($plugin_list)) {
*
* @access public
*/
- function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
+ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
+ {
if (isset($GLOBALS['xml_export_contents']) && $GLOBALS['xml_export_contents']) {
$result = PMA_DBI_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED);
diff --git a/libraries/import.lib.php b/libraries/import.lib.php
index f457789..eda224f 100644
--- a/libraries/import.lib.php
+++ b/libraries/import.lib.php
@@ -811,9 +811,7 @@ function PMA_analyzeTable(&$table)
}
return array($types, $sizes);
- }
- else
- {
+ } else {
/**
* TODO: Handle this better
*/
@@ -1089,8 +1087,7 @@ function PMA_buildSQL($db_name, &$tables, &$analyses = null, &$additional_sql =
unset($params);
$num_tables = count($tables);
- for ($i = 0; $i < $num_tables; ++$i)
- {
+ for ($i = 0; $i < $num_tables; ++$i) {
$params = array('db' => (string)$db_name, 'table' => (string)$tables[$i][TBL_NAME]);
$tbl_url = 'sql.php' . PMA_generate_common_url($params);
$tbl_struct_url = 'tbl_structure.php' . PMA_generate_common_url($params);
diff --git a/libraries/import/xml.php b/libraries/import/xml.php
index b51e6d8..ea0bddb 100644
--- a/libraries/import/xml.php
+++ b/libraries/import/xml.php
@@ -200,8 +200,7 @@ if (@count($xml->children())) {
foreach ($v1 as $k2 => $v2) {
$row_attr = $v2->attributes();
- if (! array_search((string)$row_attr['name'], $tempRow))
- {
+ if (! array_search((string)$row_attr['name'], $tempRow)) {
$tempRow[] = (string)$row_attr['name'];
}
$tempCells[] = (string)$v2;
diff --git a/libraries/sqlparser.lib.php b/libraries/sqlparser.lib.php
index bde23e3..703d08a 100644
--- a/libraries/sqlparser.lib.php
+++ b/libraries/sqlparser.lib.php
@@ -1388,7 +1388,7 @@ if (! defined('PMA_MINIMUM_COMMON')) {
// however, if we are on AS, we must keep the $previous_was_identifier
if (($arr[$i]['type'] == 'alpha_reservedWord')
- && ($upper_data == 'AS')) {
+ && ($upper_data == 'AS')) {
$previous_was_identifier = true;
}
diff --git a/libraries/sqlvalidator.lib.php b/libraries/sqlvalidator.lib.php
index dd3b8ad..68934dd 100644
--- a/libraries/sqlvalidator.lib.php
+++ b/libraries/sqlvalidator.lib.php
@@ -38,7 +38,7 @@ if (! defined('PHPMYADMIN')) {
* I'm not sure if PEAR was available before this point
* For now we actually use a configuration flag
*/
-if ($cfg['SQLValidator']['use'] == true) {
+if ($cfg['SQLValidator']['use'] == true) {
require_once './libraries/sqlvalidator.class.php';
} // if ($cfg['SQLValidator']['use'] == true)
diff --git a/sql.php b/sql.php
index fef6eb1..1070bda 100644
--- a/sql.php
+++ b/sql.php
@@ -22,7 +22,7 @@ if (isset($_SESSION['profiling'])) {
/* Files required for chart exporting */
$GLOBALS['js_include'][] = 'highcharts/exporting.js';
/* < IE 9 doesn't support canvas natively */
- if(PMA_USR_BROWSER_AGENT == 'IE' && PMA_USR_BROWSER_VER < 9) {
+ if (PMA_USR_BROWSER_AGENT == 'IE' && PMA_USR_BROWSER_VER < 9) {
$GLOBALS['js_include'][] = 'canvg/flashcanvas.js';
}
$GLOBALS['js_include'][] = 'canvg/canvg.js';
@@ -96,8 +96,7 @@ if (isset($_REQUEST['get_relational_values']) && $_REQUEST['get_relational_value
$dropdown = '<span class="curr_value">' . htmlspecialchars($_REQUEST['curr_value']) . '</span> <a href="browse_foreigners.php' . PMA_generate_common_url($_url_params) . '"'
. ' target="_blank" class="browse_foreign" '
.'>' . __('Browse foreign values') . '</a>';
- }
- else {
+ } else {
$dropdown = PMA_foreignDropdown($foreignData['disp_row'], $foreignData['foreign_field'], $foreignData['foreign_display'], $curr_value, $cfg['ForeignKeyMaxLimit']);
$dropdown = '<select>' . $dropdown . '</select>';
}
@@ -788,8 +787,7 @@ else {
require './libraries/server_common.inc.php';
require './libraries/server_links.inc.php';
}
- }
- else {
+ } else {
require_once './libraries/header.inc.php';
//we don't need to buffer the output in PMA_showMessage here.
//set a global variable and check against it in the function
hooks/post-receive
--
phpMyAdmin
More information about the Git
mailing list