Skip to content

Commit

Permalink
Merge remote-tracking branch 'alex/plugins-and-OOP'
Browse files Browse the repository at this point in the history
  • Loading branch information
nijel committed Aug 20, 2012
2 parents 56937ad + cccd569 commit b6848d9
Show file tree
Hide file tree
Showing 16 changed files with 111 additions and 209 deletions.
1 change: 1 addition & 0 deletions js/get_image.js.php
Expand Up @@ -135,3 +135,4 @@ function PMA_getImage(image, alternate, attributes) {

return retval;
};
//
19 changes: 16 additions & 3 deletions libraries/CommonFunctions.class.php
Expand Up @@ -3462,6 +3462,10 @@ public function getTitleForTarget($target)
*
* @param string $string Text where to do expansion.
* @param function $escape Function to call for escaping variable values.
* Can also be an array of:
* - the escape method name
* - the class that contains the method
* - location of the class (for inclusion)
* @param array $updates Array with overrides for default parameters
* (obtained from GLOBALS).
*
Expand Down Expand Up @@ -3509,10 +3513,19 @@ public function expandUserString($string, $escape = null, $updates = array())

/* Optional escaping */
if (! is_null($escape)) {
if (is_array($escape)) {
require_once $escape[2];
$escape_class = new $escape[1];
$escape_method = $escape[0];
}
foreach ($replace as $key => $val) {
$replace[$key] = ($escape == 'backquote')
? $this->$escape($val)
: $escape($val);
if (is_array($escape)) {
$replace[$key] = $escape_class->$escape_method($val);
} else {
$replace[$key] = ($escape == 'backquote')
? $this->$escape($val)
: $escape($val);
}
}
}

Expand Down
16 changes: 8 additions & 8 deletions libraries/plugins/AuthenticationPlugin.class.php
Expand Up @@ -21,30 +21,30 @@
abstract class AuthenticationPlugin extends PluginObserver
{
/**
* Displays authentication form
*
*
* @return void
* @return boolean
*/
abstract public function auth();

/**
* Gets advanced authentication settings
*
*
* @return void
* @return boolean
*/
abstract public function authCheck();

/**
* Set the user and password after last checkings if required
*
*
* @return void
* @return boolean
*/
abstract public function authSetUser();

/**
* User is not allowed to login to MySQL -> authentication failed
*
*
* @return void
* @return boolean
*/
abstract public function authFails();
}
Expand Down
4 changes: 3 additions & 1 deletion libraries/plugins/PluginObserver.class.php
Expand Up @@ -54,7 +54,9 @@ public function __construct($pluginManager)
*/
public function update (SplSubject $subject)
{
throw new Exception('PluginObserver::update must be overridden in child classes.');
throw new Exception(
'PluginObserver::update must be overridden in child classes.'
);
}


Expand Down
3 changes: 2 additions & 1 deletion libraries/plugins/TransformationsInterface.int.php
Expand Up @@ -15,7 +15,8 @@
*
* @package PhpMyAdmin
*/
interface TransformationsInterface {
interface TransformationsInterface
{
/**
* Gets the transformation description
*
Expand Down
2 changes: 1 addition & 1 deletion libraries/plugins/TransformationsPlugin.class.php
Expand Up @@ -26,7 +26,7 @@ abstract class TransformationsPlugin extends PluginObserver
/**
* Does the actual work of each specific transformations plugin.
*
* @param array $options transformation options
* @param array $options transformation options
*
* @return void
*/
Expand Down
3 changes: 2 additions & 1 deletion libraries/plugins/UploadInterface.int.php
Expand Up @@ -15,7 +15,8 @@
*
* @package PhpMyAdmin
*/
interface UploadInterface {
interface UploadInterface
{
/**
* Gets the specific upload ID Key
*
Expand Down
24 changes: 20 additions & 4 deletions libraries/plugins/export/ExportLatex.class.php
Expand Up @@ -311,7 +311,11 @@ public function exportData($db, $table, $crlf, $error_url, $sql_query)
$buffer .= ' \\caption{'
. $common_functions->expandUserString(
$GLOBALS['latex_data_caption'],
get_class($this) . '->texEscape',
array(
'texEscape',
get_class($this),
'libraries/plugins/export/' . get_class($this) . ".class.php"
),
array('table' => $table, 'database' => $db)
)
. '} \\label{'
Expand Down Expand Up @@ -343,7 +347,11 @@ public function exportData($db, $table, $crlf, $error_url, $sql_query)
'\\caption{'
. $common_functions->expandUserString(
$GLOBALS['latex_data_continued_caption'],
get_class($this) . '->texEscape',
array(
'texEscape',
get_class($this),
'libraries/plugins/export/' . get_class($this) . ".class.php"
),
array('table' => $table, 'database' => $db)
)
. '} \\\\ '
Expand Down Expand Up @@ -513,7 +521,11 @@ public function exportStructure(
$buffer .= ' \\caption{'
. $common_functions->expandUserString(
$GLOBALS['latex_structure_caption'],
get_class($this) . '->texEscape',
array(
'texEscape',
get_class($this),
'libraries/plugins/export/' . get_class($this) . ".class.php"
),
array('table' => $table, 'database' => $db)
)
. '} \\label{'
Expand All @@ -531,7 +543,11 @@ public function exportStructure(
$buffer .= ' \\caption{'
. $common_functions->expandUserString(
$GLOBALS['latex_structure_continued_caption'],
get_class($this) . '->texEscape',
array(
'texEscape',
get_class($this),
'libraries/plugins/export/' . get_class($this) . ".class.php"
),
array('table' => $table, 'database' => $db)
)
. '} \\\\ ' . $crlf;
Expand Down
53 changes: 34 additions & 19 deletions libraries/plugins/export/ExportSql.class.php
Expand Up @@ -1451,7 +1451,8 @@ public function exportStructure(
}

$formatted_table_name = (isset($GLOBALS['sql_backquotes']))
? $common_functions->backquote_compat($table, $compat) : '\'' . $table . '\'';
? $common_functions->backquote_compat($table, $compat)
: '\'' . $table . '\'';
$dump = $this->_possibleCRLF()
. $this->_exportComment(str_repeat('-', 56))
. $this->_possibleCRLF()
Expand Down Expand Up @@ -1672,12 +1673,20 @@ public function exportData($db, $table, $crlf, $error_url, $sql_query)
) {
$fields = implode(', ', $field_set);
$schema_insert = $sql_command . $insert_delayed .' INTO '
. $common_functions->backquote_compat($table, $compat, $sql_backquotes)
. $common_functions->backquote_compat(
$table,
$compat,
$sql_backquotes
)
// avoid EOL blank
. ' (' . $fields . ') VALUES';
} else {
$schema_insert = $sql_command . $insert_delayed .' INTO '
. $common_functions->backquote_compat($table, $compat, $sql_backquotes)
. $common_functions->backquote_compat(
$table,
$compat,
$sql_backquotes
)
. ' VALUES';
}
}
Expand Down Expand Up @@ -1715,12 +1724,16 @@ public function exportData($db, $table, $crlf, $error_url, $sql_query)
// We need to SET IDENTITY_INSERT ON for MSSQL
if (isset($GLOBALS['sql_compatibility'])
&& $GLOBALS['sql_compatibility'] == 'MSSQL'
&& $current_row == 0) {
if (! PMA_exportOutputHandler('SET IDENTITY_INSERT '
. $common_functions->backquote_compat(
$table,
$compat)
. ' ON ;'.$crlf)) {
&& $current_row == 0
) {
if (! PMA_exportOutputHandler(
'SET IDENTITY_INSERT '
. $common_functions->backquote_compat(
$table,
$compat
)
. ' ON ;'.$crlf
)) {
return false;
}
}
Expand Down Expand Up @@ -1851,23 +1864,25 @@ public function exportData($db, $table, $crlf, $error_url, $sql_query)
}
}

// We need to SET IDENTITY_INSERT OFF for MSSQL
// We need to SET IDENTITY_INSERT OFF for MSSQL
if (isset($GLOBALS['sql_compatibility'])
&& $GLOBALS['sql_compatibility'] == 'MSSQL'
&& $current_row > 0)
if (! PMA_exportOutputHandler(
$crlf . 'SET IDENTITY_INSERT '
&& $GLOBALS['sql_compatibility'] == 'MSSQL'
&& $current_row > 0
)
if (! PMA_exportOutputHandler(
$crlf . 'SET IDENTITY_INSERT '
. $common_functions->backquote_compat(
$table,
$compat)
$table,
$compat
)
. ' OFF;' . $crlf
)) {
return false;
}
return false;
}

} // end if ($result != false)
PMA_DBI_free_result($result);

return true;
} // end of the 'exportData()' function
}
}
10 changes: 7 additions & 3 deletions libraries/plugins/import/ImportLdi.class.php
Expand Up @@ -145,10 +145,12 @@ public function doImport()
$sql .= ' FIELDS TERMINATED BY \'' . $ldi_terminated . '\'';
}
if (strlen($ldi_enclosed) > 0) {
$sql .= ' ENCLOSED BY \'' . $common_functions->sqlAddSlashes($ldi_enclosed) . '\'';
$sql .= ' ENCLOSED BY \''
. $common_functions->sqlAddSlashes($ldi_enclosed) . '\'';
}
if (strlen($ldi_escaped) > 0) {
$sql .= ' ESCAPED BY \'' . $common_functions->sqlAddSlashes($ldi_escaped) . '\'';
$sql .= ' ESCAPED BY \''
. $common_functions->sqlAddSlashes($ldi_escaped) . '\'';
}
if (strlen($ldi_new_line) > 0) {
if ($ldi_new_line == 'auto') {
Expand All @@ -172,7 +174,9 @@ public function doImport()
$sql .= ', ';
}
/* Trim also `, if user already included backquoted fields */
$sql .= $common_functions->backquote(trim($tmp[$i], " \t\r\n\0\x0B`"));
$sql .= $common_functions->backquote(
trim($tmp[$i], " \t\r\n\0\x0B`")
);
} // end for
$sql .= ')';
}
Expand Down
13 changes: 7 additions & 6 deletions libraries/plugins/import/ImportOds.class.php
Expand Up @@ -69,10 +69,11 @@ protected function setProperties()
$leaf = new BoolPropertyItem();
$leaf->setName("col_names");
$leaf->setText(
__('The first line of the file contains the table column names'
. ' <i>(if this is unchecked, the first line will become part'
. ' of the data)</i>'
)
__(
'The first line of the file contains the table column names'
. ' <i>(if this is unchecked, the first line will become part'
. ' of the data)</i>'
)
);
$generalOptions->addProperty($leaf);
$leaf = new BoolPropertyItem();
Expand All @@ -82,9 +83,9 @@ protected function setProperties()
$leaf = new BoolPropertyItem();
$leaf->setName("recognize_percentages");
$leaf->setText(
__(
__(
'Import percentages as proper decimals <i>(ex. 12.00% to .12)</i>'
)
)
);
$generalOptions->addProperty($leaf);
$leaf = new BoolPropertyItem();
Expand Down
4 changes: 3 additions & 1 deletion libraries/plugins/import/ImportXml.class.php
Expand Up @@ -219,7 +219,9 @@ public function doImport()
*/
$attrs = $val2->attributes();
$create[] = "USE "
. PMA_CommonFunctions::getInstance()->backquote($attrs["name"]);
. PMA_CommonFunctions::getInstance()->backquote(
$attrs["name"]
);

foreach ($val2 as $val3) {
/**
Expand Down
Expand Up @@ -130,7 +130,10 @@ public function applyTransformation($buffer, $options = array(), $meta = '')
$timestamp -= $options[0] * 60 * 60;
$source = $buffer;
if ($options[2] == 'local') {
$text = PMA_CommonFunctions::getInstance()->localisedDate($timestamp, $options[1]);
$text = PMA_CommonFunctions::getInstance()->localisedDate(
$timestamp,
$options[1]
);
} elseif ($options[2] == 'utc') {
$text = gmdate($options[1], $timestamp);
} else {
Expand Down
Expand Up @@ -52,7 +52,8 @@ public function applyTransformation($buffer, $options = array(), $meta = '')
'string' => '<a href="'
. PMA_linkURL((isset($options[0]) ? $options[0] : '') . $append_part)
. '" title="' . (isset($options[1]) ? $options[1] : '')
. '" target="_new">' . (isset($options[1]) ? $options[1] : $buffer) . '</a>'
. '" target="_new">' . (isset($options[1]) ? $options[1] : $buffer)
. '</a>'
);

$buffer = PMA_transformation_global_html_replace(
Expand Down
Expand Up @@ -15,7 +15,6 @@
/**
* Defines possible options and getters and setters for them.
*
* @todo modify descriptions if needed, when the plug-in properties are integrated
* @package PhpMyAdmin
*/
class ImportPluginProperties extends PluginPropertyItem
Expand Down Expand Up @@ -67,7 +66,7 @@ class ImportPluginProperties extends PluginPropertyItem
*
* @return string
*/
public function getItemType()
public function getItemType()
{
return "import";
}
Expand Down

0 comments on commit b6848d9

Please sign in to comment.