- Fixed errors/violations noticed by PHPMD and PHPCS

- Removed parameter perform_sql from public method controllers/system/extensions/CLI_Manager->installExtension
- Added new public method controllers/system/extensions/CLI_Manager->installExtensionNoSQL
- Improved code quality in controllers/system/extensions/Manager->toggleExtension
- controllers/system/extensions/Manager->uploadExtension better check of
  HTTP POST parameter notPerformSql
- application/views/system/extensions/manager.php renamed checkbox
  performSql to notPerformSql
- application/views/system/extensions/tableWidget.php removed PHP close
  tag at the end of the file
- Improved code quality in application/widgets/TableWidget.php
- Removed private method _getColumnsNames from application/widgets/TableWidget.php
- Improved code quality in application/libraries/ExtensionsLib.php
- Added new private methods _getExtensionsPath and _getUploadPath to application/libraries/ExtensionsLib.php
- Changed application/libraries/ExtensionsLib->_toggleExtension to public method toggleExtension
- Removed private properties UPLOAD_PATH and EXTENSIONS_PATH from application/libraries/ExtensionsLib
- Added use imports in application/libraries/ExtensionsLib
- application/libraries/ExtensionsLib->installExtension changed parameters default values
This commit is contained in:
Paolo
2022-03-04 12:26:37 +01:00
parent 8bbc68ca75
commit 15f9762d01
6 changed files with 235 additions and 240 deletions
+39 -56
View File
@@ -213,51 +213,49 @@ class TableWidget extends Widget
*/
private function _checkParameters($args)
{
// If no options are given to this widget...
// If no options are given to this widget then ends the execution
if (!is_array($args) || (is_array($args) && count($args) == 0))
{
show_error('Second parameter of the widget call must be a NOT empty associative array');
}
else // ...otherwise
// The unique id parameter is mandatory
if (!isset($args[TableWidgetLib::TABLE_UNIQUE_ID]))
{
// The unique id parameter is mandatory
if (!isset($args[TableWidgetLib::TABLE_UNIQUE_ID]))
{
show_error('The parameter "'.TableWidgetLib::TABLE_UNIQUE_ID.'" must be specified');
}
show_error('The parameter "'.TableWidgetLib::TABLE_UNIQUE_ID.'" must be specified');
}
// The query parameter is mandatory
if (!isset($args[TableWidgetLib::QUERY]))
{
show_error('The parameter "'.TableWidgetLib::QUERY.'" must be specified');
}
// The query parameter is mandatory
if (!isset($args[TableWidgetLib::QUERY]))
{
show_error('The parameter "'.TableWidgetLib::QUERY.'" must be specified');
}
// The dataset representation parameter is mandatory
if (!isset($args[TableWidgetLib::DATASET_REPRESENTATION]))
{
show_error('The parameter "'.TableWidgetLib::DATASET_REPRESENTATION.'" must be specified');
}
// The dataset representation parameter is mandatory
if (!isset($args[TableWidgetLib::DATASET_REPRESENTATION]))
{
show_error('The parameter "'.TableWidgetLib::DATASET_REPRESENTATION.'" must be specified');
}
// Checks if the dataset representation parameter is valid
if (isset($args[TableWidgetLib::DATASET_REPRESENTATION])
&& $args[TableWidgetLib::DATASET_REPRESENTATION] != TableWidgetLib::DATASET_REP_TABLESORTER
&& $args[TableWidgetLib::DATASET_REPRESENTATION] != TableWidgetLib::DATASET_REP_PIVOTUI
&& $args[TableWidgetLib::DATASET_REPRESENTATION] != TableWidgetLib::DATASET_REP_TABULATOR)
{
show_error(
'The parameter "'.TableWidgetLib::DATASET_REPRESENTATION.
'" must be IN ("'
.TableWidgetLib::DATASET_REP_TABLESORTER.'", "'
.TableWidgetLib::DATASET_REP_PIVOTUI.'", "'
.TableWidgetLib::DATASET_REP_TABULATOR.'")'
);
}
// Checks if the dataset representation parameter is valid
if (isset($args[TableWidgetLib::DATASET_REPRESENTATION])
&& $args[TableWidgetLib::DATASET_REPRESENTATION] != TableWidgetLib::DATASET_REP_TABLESORTER
&& $args[TableWidgetLib::DATASET_REPRESENTATION] != TableWidgetLib::DATASET_REP_PIVOTUI
&& $args[TableWidgetLib::DATASET_REPRESENTATION] != TableWidgetLib::DATASET_REP_TABULATOR)
{
show_error(
'The parameter "'.TableWidgetLib::DATASET_REPRESENTATION.
'" must be IN ("'
.TableWidgetLib::DATASET_REP_TABLESORTER.'", "'
.TableWidgetLib::DATASET_REP_PIVOTUI.'", "'
.TableWidgetLib::DATASET_REP_TABULATOR.'")'
);
}
// If given the session timeout parameter must be a number
if (isset($args[TableWidgetLib::SESSION_TIMEOUT]) && !is_numeric($args[TableWidgetLib::SESSION_TIMEOUT]))
{
show_error('The parameter "'.TableWidgetLib::SESSION_TIMEOUT.'" must be a number');
}
// If given the session timeout parameter must be a number
if (isset($args[TableWidgetLib::SESSION_TIMEOUT]) && !is_numeric($args[TableWidgetLib::SESSION_TIMEOUT]))
{
show_error('The parameter "'.TableWidgetLib::SESSION_TIMEOUT.'" must be a number');
}
}
@@ -330,8 +328,10 @@ class TableWidget extends Widget
TableWidgetLib::SESSION_DATASET => $dataset->retval, // the entire dataset
TableWidgetLib::SESSION_DATASET_RELOAD => false, // if the dataset must be reloaded, not needed the first time
TableWidgetLib::SESSION_DATASET_REPRESENTATION => $this->_datasetRepresentation, // the choosen dataset representation
TableWidgetLib::SESSION_DATASET_REP_OPTIONS => $this->_datasetRepresentationOptions, // the choosen dataset representation options
TableWidgetLib::SESSION_DATASET_REP_FIELDS_DEFS => $this->_datasetRepFieldsDefs // the choosen dataset representation record fields definition
// The choosen dataset representation options
TableWidgetLib::SESSION_DATASET_REP_OPTIONS => $this->_datasetRepresentationOptions,
// The choosen dataset representation record fields definition
TableWidgetLib::SESSION_DATASET_REP_FIELDS_DEFS => $this->_datasetRepFieldsDefs
)
);
}
@@ -424,24 +424,6 @@ class TableWidget extends Widget
return !isset($class) ? '' : $class;
}
/**
* Utility method that retrieves the name of the columns present in a table JSON definition
*/
private function _getColumnsNames($columns)
{
$columnsNames = array();
foreach ($columns as $key => $obj)
{
if (isset($obj->name))
{
$columnsNames[] = $obj->name;
}
}
return $columnsNames;
}
/**
* Loads a view using the given viewName and eventually other parameters
*/
@@ -451,3 +433,4 @@ class TableWidget extends Widget
$ci->load->view($viewName, $parameters);
}
}