Skip to content

Commit

Permalink
oop: some coding style for plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
amarin15 committed Aug 16, 2012
1 parent 37e771f commit 34a0dac
Show file tree
Hide file tree
Showing 11 changed files with 73 additions and 43 deletions.
16 changes: 8 additions & 8 deletions libraries/plugins/AuthenticationPlugin.class.php
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
*
* @package PhpMyAdmin
*/
interface UploadInterface {
interface UploadInterface
{
/**
* Gets the specific upload ID Key
*
Expand Down
53 changes: 34 additions & 19 deletions libraries/plugins/export/ExportSql.class.php
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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

0 comments on commit 34a0dac

Please sign in to comment.