33
2
mirror of https://github.com/joomla-extensions/jedchecker.git synced 2024-11-27 15:26:36 +00:00

Minor fixes: Joomla! code style / typo / missed fields

This commit is contained in:
Denis Ryabov 2021-04-04 13:25:35 +03:00
parent 21faa210dc
commit 8cac461cb9
7 changed files with 39 additions and 28 deletions

View File

@ -10,7 +10,7 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die ('Restricted access');
defined('_JEXEC') or die('Restricted access');
/**
* Class JedcheckerController

View File

@ -26,11 +26,11 @@ class JedcheckerControllerPolice extends JControllerLegacy
/**
* Runs all the rules on the given directory
*
* @return bool
* @return boolean
*/
public function check()
{
$rule = JFactory::getApplication()->input->get('rule', null);
$rule = JFactory::getApplication()->input->get('rule');
JLoader::discover('jedcheckerRules', JPATH_COMPONENT_ADMINISTRATOR . '/libraries/rules/');
@ -57,7 +57,7 @@ class JedcheckerControllerPolice extends JControllerLegacy
/**
* Run each rule and echo the result
*
* @param string $class - the class anme
* @param string $class - the class name
* @param string $folder - the folder where the component is located
*
* @return void

View File

@ -25,8 +25,13 @@ use Joomla\Archive\Archive;
*/
class JedcheckerControllerUploads extends JControllerlegacy
{
/** @var string */
public $path;
/** @var string */
public $pathArchive;
/** @var string */
public $pathUnzipped;
/**
@ -44,7 +49,7 @@ class JedcheckerControllerUploads extends JControllerlegacy
/**
* basic upload
*
* @return bool
* @return boolean
*/
public function upload()
{
@ -57,7 +62,7 @@ class JedcheckerControllerUploads extends JControllerlegacy
// Gets the uploaded file from the sent form
$file = $input->files->get('extension', null, 'raw');
if ( $file['tmp_name'] )
if ($file['tmp_name'])
{
$path = $this->pathArchive;
@ -82,7 +87,6 @@ class JedcheckerControllerUploads extends JControllerlegacy
$filepath = $path . '/' . strtolower($file['name']);
$object_file = new JObject($file);
$object_file->filepath = $filepath;
$file = (array) $object_file;
@ -91,7 +95,7 @@ class JedcheckerControllerUploads extends JControllerlegacy
if (!JFile::upload($file['tmp_name'], $file['filepath'], false, true))
{
// Error in upload - redirect back with an error notice
JFactory::getApplication()->enqueueMessage(JText::_('COM_JEDCHECKER_ERROR_UNABLE_TO_UPLOAD_FILE'), 'error');
$appl->enqueueMessage(JText::_('COM_JEDCHECKER_ERROR_UNABLE_TO_UPLOAD_FILE'), 'error');
$appl->redirect('index.php?option=com_jedchecker&view=uploads');
return false;
@ -100,12 +104,12 @@ class JedcheckerControllerUploads extends JControllerlegacy
// Unzip uploaded files
$unzip_result = $this->unzip();
$this->setRedirect( 'index.php?option=com_jedchecker&view=uploads' );
$this->setRedirect('index.php?option=com_jedchecker&view=uploads');
return true;
} else {
}
else
{
$this->setRedirect('index.php?option=com_jedchecker&view=uploads');
}
@ -115,7 +119,7 @@ class JedcheckerControllerUploads extends JControllerlegacy
/**
* unzip the file
*
* @return bool
* @return boolean
*/
public function unzip()
{
@ -167,7 +171,7 @@ class JedcheckerControllerUploads extends JControllerlegacy
$message = 'COM_JEDCHECKER_UNZIP_FAILED';
}
//$appl->redirect('index.php?option=com_jedchecker&view=uploads', JText::_($message));
// $appl->redirect('index.php?option=com_jedchecker&view=uploads', JText::_($message));
$message = 'COM_JEDCHECKER_UNZIP_FAILED';
return $message;
@ -190,9 +194,10 @@ class JedcheckerControllerUploads extends JControllerlegacy
{
$extension = pathinfo($file->getFilename(), PATHINFO_EXTENSION);
if ($extension == 'zip')
if ($extension === 'zip')
{
$unzip = $file->getPath() . '/' . $file->getBasename('.' . $extension);
try
{
$archive = new Archive;
@ -223,10 +228,11 @@ class JedcheckerControllerUploads extends JControllerlegacy
/**
* clear tmp folders
*
*/
* @return void
*/
public function clear()
{
if ( file_exists($this->path) )
if (file_exists($this->path))
{
$result = JFolder::delete($this->path);
@ -238,9 +244,8 @@ class JedcheckerControllerUploads extends JControllerlegacy
$message = 'COM_JEDCHECKER_DELETE_SUCCESS';
//JFactory::getApplication()->redirect('index.php?option=com_jedchecker&view=uploads', JText::_($message));
$this->setRedirect( 'index.php?option=com_jedchecker&view=uploads' );
// JFactory::getApplication()->redirect('index.php?option=com_jedchecker&view=uploads', JText::_($message));
$this->setRedirect('index.php?option=com_jedchecker&view=uploads');
}
}
}

View File

@ -18,14 +18,14 @@ if (!JFactory::getUser()->authorise('core.manage', 'com_jedchecker'))
throw new Exception(JText::_('JERROR_ALERTNOAUTHOR'));
}
// We'll need jfile and JFolder all through the compoenent so let us load them here
// We'll need JFile and JFolder all through the component so let us load them here
jimport('joomla.filesystem.folder');
jimport('joomla.filesystem.file');
$input = JFactory::getApplication()->input;
$view = $input->getCmd('view', '');
if ($view == '' && $input->getCmd('task', '') == '')
if ($view === '' && $input->getCmd('task', '') === '')
{
$input->set('view', 'uploads');
}

View File

@ -25,8 +25,8 @@ class JEDcheckerReport extends JObject
/**
* Contains the report data.
*
* @see reset
* @var array
* @see reset
*/
protected $data;
@ -262,7 +262,7 @@ class JEDcheckerReport extends JObject
{
$item->location = str_replace($this->basedir, '', $item->location);
if ($item->location == '')
if ($item->location === '')
{
$item->location = '/';
}

View File

@ -20,6 +20,8 @@ class Com_JedcheckerInstallerScript
{
protected $extension = 'com_jedchecker';
protected $parent;
/**
* Function executed before the the installation
*

View File

@ -20,6 +20,9 @@ jimport('joomla.application.component.viewlegacy');
*/
class JedcheckerViewUploads extends JViewLegacy
{
/** @var string */
protected $path;
/**
* Display method
*
@ -29,7 +32,7 @@ class JedcheckerViewUploads extends JViewLegacy
*/
public function display($tpl = null)
{
$this->path = JFactory::getConfig()->get('tmp_path') . '/jed_checker';
$this->path = JFactory::getConfig()->get('tmp_path') . '/jed_checker';
$this->setToolbar();
$this->jsOptions['url'] = JUri::base();
@ -69,7 +72,8 @@ class JedcheckerViewUploads extends JViewLegacy
}
JToolbarHelper::title('JED checker');
if ( file_exists($this->path) )
if (file_exists($this->path))
{
JToolbarHelper::custom('uploads.clear', 'delete', 'delete', JText::_('COM_JEDCHECKER_TOOLBAR_CLEAR'), false);
}
@ -85,7 +89,7 @@ class JedcheckerViewUploads extends JViewLegacy
*
* @param string $type - action
*
* @return bool
* @return boolean
*/
private function filesExist($type)
{
@ -102,7 +106,7 @@ class JedcheckerViewUploads extends JViewLegacy
{
$local = JFactory::getConfig()->get('tmp_path') . '/jed_checker/local.txt';
if ($type == 'unzipped' && JFile::exists($local))
if ($type === 'unzipped' && JFile::exists($local))
{
return true;
}