mirror of
https://github.com/joomla-extensions/jedchecker.git
synced 2024-12-11 13:52:26 +00:00
Merge pull request #222 from dryabov/patch-80
Switch to namespaced classes for Joomla 5 Native mode.
This commit is contained in:
commit
292a6cbea0
@ -12,11 +12,13 @@
|
|||||||
|
|
||||||
defined('_JEXEC') or die('Restricted access');
|
defined('_JEXEC') or die('Restricted access');
|
||||||
|
|
||||||
|
use Joomla\CMS\MVC\Controller\BaseController;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class JedcheckerController
|
* Class JedcheckerController
|
||||||
*
|
*
|
||||||
* @since 1.0
|
* @since 1.0
|
||||||
*/
|
*/
|
||||||
class JedcheckerController extends JControllerLegacy
|
class JedcheckerController extends BaseController
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -11,17 +11,18 @@
|
|||||||
|
|
||||||
defined('_JEXEC') or die('Restricted access');
|
defined('_JEXEC') or die('Restricted access');
|
||||||
|
|
||||||
|
use Joomla\CMS\Factory;
|
||||||
jimport('joomla.filesystem');
|
use Joomla\CMS\Filesystem\File;
|
||||||
jimport('joomla.filesystem.folder');
|
use Joomla\CMS\Filesystem\Folder;
|
||||||
jimport('joomla.filesystem.archive');
|
use Joomla\CMS\Filesystem\Path;
|
||||||
|
use Joomla\CMS\MVC\Controller\BaseController;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class jedcheckerControllerPolice
|
* Class jedcheckerControllerPolice
|
||||||
*
|
*
|
||||||
* @since 1.0
|
* @since 1.0
|
||||||
*/
|
*/
|
||||||
class JedcheckerControllerPolice extends JControllerLegacy
|
class JedcheckerControllerPolice extends BaseController
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Runs all the rules on the given directory
|
* Runs all the rules on the given directory
|
||||||
@ -30,11 +31,11 @@ class JedcheckerControllerPolice extends JControllerLegacy
|
|||||||
*/
|
*/
|
||||||
public function check()
|
public function check()
|
||||||
{
|
{
|
||||||
$rule = JFactory::getApplication()->input->get('rule');
|
$rule = Factory::getApplication()->input->get('rule');
|
||||||
|
|
||||||
JLoader::discover('jedcheckerRules', JPATH_COMPONENT_ADMINISTRATOR . '/libraries/rules/');
|
JLoader::discover('jedcheckerRules', JPATH_COMPONENT_ADMINISTRATOR . '/libraries/rules/');
|
||||||
|
|
||||||
$path = JFactory::getConfig()->get('tmp_path') . '/jed_checker/unzipped';
|
$path = Factory::getConfig()->get('tmp_path') . '/jed_checker/unzipped';
|
||||||
$class = 'jedcheckerRules' . ucfirst($rule);
|
$class = 'jedcheckerRules' . ucfirst($rule);
|
||||||
|
|
||||||
// Stop if the class does not exist
|
// Stop if the class does not exist
|
||||||
@ -65,7 +66,7 @@ class JedcheckerControllerPolice extends JControllerLegacy
|
|||||||
protected function police($class, $folder)
|
protected function police($class, $folder)
|
||||||
{
|
{
|
||||||
// Prepare rule properties
|
// Prepare rule properties
|
||||||
$properties = array('basedir' => JPath::clean($folder));
|
$properties = array('basedir' => Path::clean($folder));
|
||||||
|
|
||||||
// Create instance of the rule
|
// Create instance of the rule
|
||||||
$police = new $class($properties);
|
$police = new $class($properties);
|
||||||
@ -89,8 +90,8 @@ class JedcheckerControllerPolice extends JControllerLegacy
|
|||||||
$folders = array();
|
$folders = array();
|
||||||
|
|
||||||
// Add the folders in the "jed_checked/unzipped" folder
|
// Add the folders in the "jed_checked/unzipped" folder
|
||||||
$path = JFactory::getConfig()->get('tmp_path') . '/jed_checker/unzipped';
|
$path = Factory::getConfig()->get('tmp_path') . '/jed_checker/unzipped';
|
||||||
$tmp_folders = JFolder::folders($path);
|
$tmp_folders = Folder::folders($path);
|
||||||
|
|
||||||
if (!empty($tmp_folders))
|
if (!empty($tmp_folders))
|
||||||
{
|
{
|
||||||
@ -101,9 +102,9 @@ class JedcheckerControllerPolice extends JControllerLegacy
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Parse the local.txt file and parse it
|
// Parse the local.txt file and parse it
|
||||||
$local = JFactory::getConfig()->get('tmp_path') . '/jed_checker/local.txt';
|
$local = Factory::getConfig()->get('tmp_path') . '/jed_checker/local.txt';
|
||||||
|
|
||||||
if (JFile::exists($local))
|
if (File::exists($local))
|
||||||
{
|
{
|
||||||
$content = file_get_contents($local);
|
$content = file_get_contents($local);
|
||||||
|
|
||||||
@ -119,11 +120,11 @@ class JedcheckerControllerPolice extends JControllerLegacy
|
|||||||
|
|
||||||
if (!empty($line))
|
if (!empty($line))
|
||||||
{
|
{
|
||||||
if (JFolder::exists(JPATH_ROOT . '/' . $line))
|
if (Folder::exists(JPATH_ROOT . '/' . $line))
|
||||||
{
|
{
|
||||||
$folders[] = JPATH_ROOT . '/' . $line;
|
$folders[] = JPATH_ROOT . '/' . $line;
|
||||||
}
|
}
|
||||||
elseif (JFolder::exists($line))
|
elseif (Folder::exists($line))
|
||||||
{
|
{
|
||||||
$folders[] = $line;
|
$folders[] = $line;
|
||||||
}
|
}
|
||||||
|
@ -12,18 +12,20 @@
|
|||||||
|
|
||||||
defined('_JEXEC') or die('Restricted access');
|
defined('_JEXEC') or die('Restricted access');
|
||||||
|
|
||||||
jimport('joomla.filesystem');
|
|
||||||
jimport('joomla.filesystem.folder');
|
|
||||||
jimport('joomla.filesystem.archive');
|
|
||||||
|
|
||||||
use Joomla\Archive\Archive;
|
use Joomla\Archive\Archive;
|
||||||
|
use Joomla\CMS\Factory;
|
||||||
|
use Joomla\CMS\Filesystem\File;
|
||||||
|
use Joomla\CMS\Filesystem\Folder;
|
||||||
|
use Joomla\CMS\Language\Text;
|
||||||
|
use Joomla\CMS\MVC\Controller\BaseController;
|
||||||
|
use Joomla\CMS\Session\Session;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class JedcheckerControllerUploads
|
* Class JedcheckerControllerUploads
|
||||||
*
|
*
|
||||||
* @since 1.0
|
* @since 1.0
|
||||||
*/
|
*/
|
||||||
class JedcheckerControllerUploads extends JControllerLegacy
|
class JedcheckerControllerUploads extends BaseController
|
||||||
{
|
{
|
||||||
/** @var string */
|
/** @var string */
|
||||||
public $path;
|
public $path;
|
||||||
@ -40,7 +42,7 @@ class JedcheckerControllerUploads extends JControllerLegacy
|
|||||||
*/
|
*/
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->path = JFactory::getConfig()->get('tmp_path') . '/jed_checker';
|
$this->path = Factory::getConfig()->get('tmp_path') . '/jed_checker';
|
||||||
$this->pathArchive = $this->path . '/archives';
|
$this->pathArchive = $this->path . '/archives';
|
||||||
$this->pathUnzipped = $this->path . '/unzipped';
|
$this->pathUnzipped = $this->path . '/unzipped';
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
@ -53,11 +55,11 @@ class JedcheckerControllerUploads extends JControllerLegacy
|
|||||||
*/
|
*/
|
||||||
public function upload()
|
public function upload()
|
||||||
{
|
{
|
||||||
$appl = JFactory::getApplication();
|
$appl = Factory::getApplication();
|
||||||
$input = $appl->input;
|
$input = $appl->input;
|
||||||
|
|
||||||
// Check the sent token by the form
|
// Check the sent token by the form
|
||||||
JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
|
Session::checkToken() or jexit(Text::_('JINVALID_TOKEN'));
|
||||||
|
|
||||||
// Gets the uploaded file from the sent form
|
// Gets the uploaded file from the sent form
|
||||||
$file = $input->files->get('extension', null, 'raw');
|
$file = $input->files->get('extension', null, 'raw');
|
||||||
@ -67,18 +69,18 @@ class JedcheckerControllerUploads extends JControllerLegacy
|
|||||||
$path = $this->pathArchive;
|
$path = $this->pathArchive;
|
||||||
|
|
||||||
// If the archive folder doesn't exist - create it!
|
// If the archive folder doesn't exist - create it!
|
||||||
if (!JFolder::exists($path))
|
if (!Folder::exists($path))
|
||||||
{
|
{
|
||||||
JFolder::create($path);
|
Folder::create($path);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Let us remove all previous uploads
|
// Let us remove all previous uploads
|
||||||
$archiveFiles = JFolder::files($path);
|
$archiveFiles = Folder::files($path);
|
||||||
|
|
||||||
foreach ($archiveFiles as $archive)
|
foreach ($archiveFiles as $archive)
|
||||||
{
|
{
|
||||||
if (!JFile::delete($this->pathArchive . '/' . $archive))
|
if (!File::delete($this->pathArchive . '/' . $archive))
|
||||||
{
|
{
|
||||||
echo 'could not delete' . $archive;
|
echo 'could not delete' . $archive;
|
||||||
}
|
}
|
||||||
@ -88,10 +90,10 @@ class JedcheckerControllerUploads extends JControllerLegacy
|
|||||||
$file['filepath'] = $path . '/' . strtolower($file['name']);
|
$file['filepath'] = $path . '/' . strtolower($file['name']);
|
||||||
|
|
||||||
// Let us try to upload
|
// Let us try to upload
|
||||||
if (!JFile::upload($file['tmp_name'], $file['filepath'], false, true))
|
if (!File::upload($file['tmp_name'], $file['filepath'], false, true))
|
||||||
{
|
{
|
||||||
// Error in upload - redirect back with an error notice
|
// Error in upload - redirect back with an error notice
|
||||||
$appl->enqueueMessage(JText::_('COM_JEDCHECKER_ERROR_UNABLE_TO_UPLOAD_FILE'), 'error');
|
$appl->enqueueMessage(Text::_('COM_JEDCHECKER_ERROR_UNABLE_TO_UPLOAD_FILE'), 'error');
|
||||||
$appl->redirect('index.php?option=com_jedchecker&view=uploads');
|
$appl->redirect('index.php?option=com_jedchecker&view=uploads');
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -119,28 +121,28 @@ class JedcheckerControllerUploads extends JControllerLegacy
|
|||||||
*/
|
*/
|
||||||
public function unzip()
|
public function unzip()
|
||||||
{
|
{
|
||||||
$appl = JFactory::getApplication();
|
$appl = Factory::getApplication();
|
||||||
|
|
||||||
// Form check token
|
// Form check token
|
||||||
JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
|
Session::checkToken() or jexit(Text::_('JINVALID_TOKEN'));
|
||||||
|
|
||||||
// If folder doesn't exist - create it!
|
// If folder doesn't exist - create it!
|
||||||
if (!JFolder::exists($this->pathUnzipped))
|
if (!Folder::exists($this->pathUnzipped))
|
||||||
{
|
{
|
||||||
JFolder::create($this->pathUnzipped);
|
Folder::create($this->pathUnzipped);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Let us remove all previous unzipped files
|
// Let us remove all previous unzipped files
|
||||||
$folders = JFolder::folders($this->pathUnzipped);
|
$folders = Folder::folders($this->pathUnzipped);
|
||||||
|
|
||||||
foreach ($folders as $folder)
|
foreach ($folders as $folder)
|
||||||
{
|
{
|
||||||
JFolder::delete($this->pathUnzipped . '/' . $folder);
|
Folder::delete($this->pathUnzipped . '/' . $folder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$file = JFolder::files($this->pathArchive);
|
$file = Folder::files($this->pathArchive);
|
||||||
|
|
||||||
$origin = $this->pathArchive . DIRECTORY_SEPARATOR . $file[0];
|
$origin = $this->pathArchive . DIRECTORY_SEPARATOR . $file[0];
|
||||||
$destination = $this->pathUnzipped . DIRECTORY_SEPARATOR . $file[0];
|
$destination = $this->pathUnzipped . DIRECTORY_SEPARATOR . $file[0];
|
||||||
@ -150,7 +152,7 @@ class JedcheckerControllerUploads extends JControllerLegacy
|
|||||||
$archive = new Archive;
|
$archive = new Archive;
|
||||||
$result = $archive->extract($origin, $destination);
|
$result = $archive->extract($origin, $destination);
|
||||||
}
|
}
|
||||||
catch (\Exception $e)
|
catch (Exception $e)
|
||||||
{
|
{
|
||||||
$result = false;
|
$result = false;
|
||||||
}
|
}
|
||||||
@ -160,14 +162,14 @@ class JedcheckerControllerUploads extends JControllerLegacy
|
|||||||
// Scan unzipped folders if we find zip file -> unzip them as well
|
// Scan unzipped folders if we find zip file -> unzip them as well
|
||||||
$this->unzipAll($this->pathUnzipped . '/' . $file[0]);
|
$this->unzipAll($this->pathUnzipped . '/' . $file[0]);
|
||||||
$message = 'COM_JEDCHECKER_UNZIP_SUCCESS';
|
$message = 'COM_JEDCHECKER_UNZIP_SUCCESS';
|
||||||
$appl->enqueueMessage(JText::_($message));
|
$appl->enqueueMessage(Text::_($message));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$message = 'COM_JEDCHECKER_UNZIP_FAILED';
|
$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', Text::_($message));
|
||||||
$message = 'COM_JEDCHECKER_UNZIP_FAILED';
|
$message = 'COM_JEDCHECKER_UNZIP_FAILED';
|
||||||
|
|
||||||
return $message;
|
return $message;
|
||||||
@ -197,7 +199,7 @@ class JedcheckerControllerUploads extends JControllerLegacy
|
|||||||
$archive = new Archive;
|
$archive = new Archive;
|
||||||
$result = $archive->extract($file->getPathname(), $unzip);
|
$result = $archive->extract($file->getPathname(), $unzip);
|
||||||
}
|
}
|
||||||
catch (\Exception $e)
|
catch (Exception $e)
|
||||||
{
|
{
|
||||||
$result = false;
|
$result = false;
|
||||||
}
|
}
|
||||||
@ -205,7 +207,7 @@ class JedcheckerControllerUploads extends JControllerLegacy
|
|||||||
// Delete the archive once we extract it
|
// Delete the archive once we extract it
|
||||||
if ($result)
|
if ($result)
|
||||||
{
|
{
|
||||||
JFile::delete($file->getPathname());
|
File::delete($file->getPathname());
|
||||||
|
|
||||||
// Now check the new extracted folder for archive files
|
// Now check the new extracted folder for archive files
|
||||||
$this->unzipAll($unzip);
|
$this->unzipAll($unzip);
|
||||||
@ -228,7 +230,7 @@ class JedcheckerControllerUploads extends JControllerLegacy
|
|||||||
{
|
{
|
||||||
if (file_exists($this->path))
|
if (file_exists($this->path))
|
||||||
{
|
{
|
||||||
$result = JFolder::delete($this->path);
|
$result = Folder::delete($this->path);
|
||||||
|
|
||||||
if (!$result)
|
if (!$result)
|
||||||
{
|
{
|
||||||
@ -238,7 +240,7 @@ class JedcheckerControllerUploads extends JControllerLegacy
|
|||||||
|
|
||||||
$message = 'COM_JEDCHECKER_DELETE_SUCCESS';
|
$message = 'COM_JEDCHECKER_DELETE_SUCCESS';
|
||||||
|
|
||||||
// JFactory::getApplication()->redirect('index.php?option=com_jedchecker&view=uploads', JText::_($message));
|
// Factory::getApplication()->redirect('index.php?option=com_jedchecker&view=uploads', Text::_($message));
|
||||||
$this->setRedirect('index.php?option=com_jedchecker&view=uploads');
|
$this->setRedirect('index.php?option=com_jedchecker&view=uploads');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,18 +11,17 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
defined('_JEXEC') or die('Restricted access');
|
defined('_JEXEC') or die('Restricted access');
|
||||||
jimport('joomla.application.component.controllerlegacy');
|
|
||||||
|
|
||||||
if (!JFactory::getUser()->authorise('core.manage', 'com_jedchecker'))
|
use Joomla\CMS\Factory;
|
||||||
|
use Joomla\CMS\Language\Text;
|
||||||
|
use Joomla\CMS\MVC\Controller\BaseController;
|
||||||
|
|
||||||
|
if (!Factory::getUser()->authorise('core.manage', 'com_jedchecker'))
|
||||||
{
|
{
|
||||||
throw new Exception(JText::_('JERROR_ALERTNOAUTHOR'));
|
throw new Exception(Text::_('JERROR_ALERTNOAUTHOR'));
|
||||||
}
|
}
|
||||||
|
|
||||||
// We'll need JFile and JFolder all through the component so let us load them here
|
$input = Factory::getApplication()->input;
|
||||||
jimport('joomla.filesystem.folder');
|
|
||||||
jimport('joomla.filesystem.file');
|
|
||||||
|
|
||||||
$input = JFactory::getApplication()->input;
|
|
||||||
$view = $input->getCmd('view', '');
|
$view = $input->getCmd('view', '');
|
||||||
|
|
||||||
if ($view === '' && $input->getCmd('task', '') === '')
|
if ($view === '' && $input->getCmd('task', '') === '')
|
||||||
@ -30,6 +29,6 @@ if ($view === '' && $input->getCmd('task', '') === '')
|
|||||||
$input->set('view', 'uploads');
|
$input->set('view', 'uploads');
|
||||||
}
|
}
|
||||||
|
|
||||||
$controller = JControllerLegacy::getInstance('jedchecker');
|
$controller = BaseController::getInstance('jedchecker');
|
||||||
$controller->execute($input->getCmd('task', ''));
|
$controller->execute($input->getCmd('task', ''));
|
||||||
$controller->redirect();
|
$controller->redirect();
|
||||||
|
@ -9,6 +9,8 @@
|
|||||||
|
|
||||||
defined('_JEXEC') or die('Restricted access');
|
defined('_JEXEC') or die('Restricted access');
|
||||||
|
|
||||||
|
use Joomla\CMS\Filesystem\Folder;
|
||||||
|
use Joomla\CMS\Filter\InputFilter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* class JedcheckerHelper
|
* class JedcheckerHelper
|
||||||
@ -34,7 +36,7 @@ abstract class JEDCheckerHelper
|
|||||||
public static function findManifests($basedir)
|
public static function findManifests($basedir)
|
||||||
{
|
{
|
||||||
// Find all XML files of the extension
|
// Find all XML files of the extension
|
||||||
$files = JFolder::files($basedir, '\.xml$', true, true);
|
$files = Folder::files($basedir, '\.xml$', true, true);
|
||||||
|
|
||||||
$excludeList = array();
|
$excludeList = array();
|
||||||
|
|
||||||
@ -134,7 +136,7 @@ abstract class JEDCheckerHelper
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$extension = strtolower(JFilterInput::getInstance()->clean($extension, 'cmd'));
|
$extension = strtolower(InputFilter::getInstance()->clean($extension, 'cmd'));
|
||||||
|
|
||||||
if ($type === 'component' && strpos($extension, 'com_') !== 0)
|
if ($type === 'component' && strpos($extension, 'com_') !== 0)
|
||||||
{
|
{
|
||||||
|
@ -12,6 +12,9 @@
|
|||||||
|
|
||||||
defined('_JEXEC') or die('Restricted access');
|
defined('_JEXEC') or die('Restricted access');
|
||||||
|
|
||||||
|
use Joomla\CMS\Filesystem\Folder;
|
||||||
|
use Joomla\CMS\Language\Text;
|
||||||
|
|
||||||
// Include the rule base class
|
// Include the rule base class
|
||||||
require_once JPATH_COMPONENT_ADMINISTRATOR . '/models/rule.php';
|
require_once JPATH_COMPONENT_ADMINISTRATOR . '/models/rule.php';
|
||||||
|
|
||||||
@ -81,7 +84,7 @@ class JedcheckerRulesEncoding extends JEDcheckerRule
|
|||||||
$this->encodingsRegex = '/' . implode('|', $encodings) . '/i';
|
$this->encodingsRegex = '/' . implode('|', $encodings) . '/i';
|
||||||
|
|
||||||
// Find all php files of the extension
|
// Find all php files of the extension
|
||||||
$files = JFolder::files($this->basedir, '\.php$', true, true);
|
$files = Folder::files($this->basedir, '\.php$', true, true);
|
||||||
|
|
||||||
// Iterate through all files
|
// Iterate through all files
|
||||||
foreach ($files as $file)
|
foreach ($files as $file)
|
||||||
@ -121,7 +124,7 @@ class JedcheckerRulesEncoding extends JEDcheckerRule
|
|||||||
if (preg_match($this->encodingsRegex, $line))
|
if (preg_match($this->encodingsRegex, $line))
|
||||||
{
|
{
|
||||||
$found = true;
|
$found = true;
|
||||||
$this->report->addWarning($file, JText::_('COM_JEDCHECKER_ERROR_ENCODING'), $i + 1, $origContent[$i]);
|
$this->report->addWarning($file, Text::_('COM_JEDCHECKER_ERROR_ENCODING'), $i + 1, $origContent[$i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,6 +11,9 @@
|
|||||||
|
|
||||||
defined('_JEXEC') or die('Restricted access');
|
defined('_JEXEC') or die('Restricted access');
|
||||||
|
|
||||||
|
use Joomla\CMS\Filesystem\Folder;
|
||||||
|
use Joomla\CMS\Language\Text;
|
||||||
|
|
||||||
// Include the rule base class
|
// Include the rule base class
|
||||||
require_once JPATH_COMPONENT_ADMINISTRATOR . '/models/rule.php';
|
require_once JPATH_COMPONENT_ADMINISTRATOR . '/models/rule.php';
|
||||||
|
|
||||||
@ -82,7 +85,7 @@ class JedcheckerRulesErrorreporting extends JEDcheckerRule
|
|||||||
$this->errorreportingRegex = '/' . implode('|', $codes) . '/i';
|
$this->errorreportingRegex = '/' . implode('|', $codes) . '/i';
|
||||||
|
|
||||||
// Find all php files of the extension
|
// Find all php files of the extension
|
||||||
$files = JFolder::files($this->basedir, '\.php$', true, true);
|
$files = Folder::files($this->basedir, '\.php$', true, true);
|
||||||
|
|
||||||
// Iterate through all files
|
// Iterate through all files
|
||||||
foreach ($files as $file)
|
foreach ($files as $file)
|
||||||
@ -122,7 +125,7 @@ class JedcheckerRulesErrorreporting extends JEDcheckerRule
|
|||||||
if (preg_match($this->errorreportingRegex, $line))
|
if (preg_match($this->errorreportingRegex, $line))
|
||||||
{
|
{
|
||||||
$found = true;
|
$found = true;
|
||||||
$this->report->addWarning($file, JText::_('COM_JEDCHECKER_ERROR_ERRORREPORTING'), $i + 1, $origContent[$i]);
|
$this->report->addWarning($file, Text::_('COM_JEDCHECKER_ERROR_ERRORREPORTING'), $i + 1, $origContent[$i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,6 +11,9 @@
|
|||||||
|
|
||||||
defined('_JEXEC') or die('Restricted access');
|
defined('_JEXEC') or die('Restricted access');
|
||||||
|
|
||||||
|
use Joomla\CMS\Filesystem\Folder;
|
||||||
|
use Joomla\CMS\Language\Text;
|
||||||
|
|
||||||
// Include the rule base class
|
// Include the rule base class
|
||||||
require_once JPATH_COMPONENT_ADMINISTRATOR . '/models/rule.php';
|
require_once JPATH_COMPONENT_ADMINISTRATOR . '/models/rule.php';
|
||||||
|
|
||||||
@ -83,15 +86,15 @@ class JedcheckerRulesFramework extends JEDcheckerRule
|
|||||||
$regexLeftoverFolders = '^' . $this->regexLeftoverFolders . '$';
|
$regexLeftoverFolders = '^' . $this->regexLeftoverFolders . '$';
|
||||||
|
|
||||||
// Get matched files and folder (w/o default exclusion list)
|
// Get matched files and folder (w/o default exclusion list)
|
||||||
$folders = JFolder::folders($this->basedir, $regexLeftoverFolders, true, true, array(), array());
|
$folders = Folder::folders($this->basedir, $regexLeftoverFolders, true, true, array(), array());
|
||||||
$files = JFolder::files($this->basedir, $regexLeftoverFolders, true, true, array(), array());
|
$files = Folder::files($this->basedir, $regexLeftoverFolders, true, true, array(), array());
|
||||||
|
|
||||||
if ($folders !== false)
|
if ($folders !== false)
|
||||||
{
|
{
|
||||||
// Warn on leftover folders found
|
// Warn on leftover folders found
|
||||||
foreach ($folders as $folder)
|
foreach ($folders as $folder)
|
||||||
{
|
{
|
||||||
$this->report->addWarning($folder, JText::_("COM_JEDCHECKER_ERROR_FRAMEWORK_LEFTOVER_FOLDER"));
|
$this->report->addWarning($folder, Text::_("COM_JEDCHECKER_ERROR_FRAMEWORK_LEFTOVER_FOLDER"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,11 +103,11 @@ class JedcheckerRulesFramework extends JEDcheckerRule
|
|||||||
// Warn on leftover files found
|
// Warn on leftover files found
|
||||||
foreach ($files as $file)
|
foreach ($files as $file)
|
||||||
{
|
{
|
||||||
$this->report->addWarning($file, JText::_("COM_JEDCHECKER_ERROR_FRAMEWORK_LEFTOVER_FILE"));
|
$this->report->addWarning($file, Text::_("COM_JEDCHECKER_ERROR_FRAMEWORK_LEFTOVER_FILE"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$files = JFolder::files($this->basedir, '\.php$', true, true);
|
$files = Folder::files($this->basedir, '\.php$', true, true);
|
||||||
|
|
||||||
foreach ($files as $file)
|
foreach ($files as $file)
|
||||||
{
|
{
|
||||||
@ -154,14 +157,14 @@ class JedcheckerRulesFramework extends JEDcheckerRule
|
|||||||
// Check BOM
|
// Check BOM
|
||||||
if (strncmp($content, "\xEF\xBB\xBF", 3) === 0)
|
if (strncmp($content, "\xEF\xBB\xBF", 3) === 0)
|
||||||
{
|
{
|
||||||
$this->report->addError($file, JText::_('COM_JEDCHECKER_ERROR_FRAMEWORK_BOM_FOUND'));
|
$this->report->addError($file, Text::_('COM_JEDCHECKER_ERROR_FRAMEWORK_BOM_FOUND'));
|
||||||
$result = true;
|
$result = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Report spaces/tabs/EOLs at the beginning of file
|
// Report spaces/tabs/EOLs at the beginning of file
|
||||||
if (strpos(" \t\n\r\v\f", $content[0]) !== false)
|
if (strpos(" \t\n\r\v\f", $content[0]) !== false)
|
||||||
{
|
{
|
||||||
$this->report->addNotice($file, JText::_('COM_JEDCHECKER_ERROR_FRAMEWORK_LEADING_SPACES'));
|
$this->report->addNotice($file, Text::_('COM_JEDCHECKER_ERROR_FRAMEWORK_LEADING_SPACES'));
|
||||||
$result = true;
|
$result = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -176,7 +179,7 @@ class JedcheckerRulesFramework extends JEDcheckerRule
|
|||||||
if (preg_match('/<\?\s/', $content, $match, PREG_OFFSET_CAPTURE))
|
if (preg_match('/<\?\s/', $content, $match, PREG_OFFSET_CAPTURE))
|
||||||
{
|
{
|
||||||
$lineno = substr_count($content, "\n", 0, $match[0][1]);
|
$lineno = substr_count($content, "\n", 0, $match[0][1]);
|
||||||
$this->report->addError($file, JText::_('COM_JEDCHECKER_ERROR_FRAMEWORK_SHORT_PHP_TAG'), $lineno + 1, $origContent[$lineno]);
|
$this->report->addError($file, Text::_('COM_JEDCHECKER_ERROR_FRAMEWORK_SHORT_PHP_TAG'), $lineno + 1, $origContent[$lineno]);
|
||||||
$result = true;
|
$result = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -230,7 +233,7 @@ class JedcheckerRulesFramework extends JEDcheckerRule
|
|||||||
if (preg_match('/' . $regex . '/i', $line))
|
if (preg_match('/' . $regex . '/i', $line))
|
||||||
{
|
{
|
||||||
$origLine = str_ireplace($singleTest, '<b>' . $singleTest . '</b>', htmlspecialchars($origLine));
|
$origLine = str_ireplace($singleTest, '<b>' . $singleTest . '</b>', htmlspecialchars($origLine));
|
||||||
$error_message = JText::_('COM_JEDCHECKER_ERROR_FRAMEWORK_' . strtoupper($testObject->group)) . ':<pre>' . $origLine . '</pre>';
|
$error_message = Text::_('COM_JEDCHECKER_ERROR_FRAMEWORK_' . strtoupper($testObject->group)) . ':<pre>' . $origLine . '</pre>';
|
||||||
|
|
||||||
switch ($testObject->kind)
|
switch ($testObject->kind)
|
||||||
{
|
{
|
||||||
|
@ -11,6 +11,8 @@
|
|||||||
|
|
||||||
defined('_JEXEC') or die('Restricted access');
|
defined('_JEXEC') or die('Restricted access');
|
||||||
|
|
||||||
|
use Joomla\CMS\Filesystem\Folder;
|
||||||
|
use Joomla\CMS\Language\Text;
|
||||||
|
|
||||||
// Include the rule base class
|
// Include the rule base class
|
||||||
require_once JPATH_COMPONENT_ADMINISTRATOR . '/models/rule.php';
|
require_once JPATH_COMPONENT_ADMINISTRATOR . '/models/rule.php';
|
||||||
@ -80,7 +82,7 @@ class JedcheckerRulesGpl extends JEDcheckerRule
|
|||||||
$this->init();
|
$this->init();
|
||||||
|
|
||||||
// Find all php files of the extension
|
// Find all php files of the extension
|
||||||
$files = JFolder::files($this->basedir, '\.php$', true, true);
|
$files = Folder::files($this->basedir, '\.php$', true, true);
|
||||||
|
|
||||||
// Iterate through all files
|
// Iterate through all files
|
||||||
foreach ($files as $file)
|
foreach ($files as $file)
|
||||||
@ -89,7 +91,7 @@ class JedcheckerRulesGpl extends JEDcheckerRule
|
|||||||
if (!$this->find($file))
|
if (!$this->find($file))
|
||||||
{
|
{
|
||||||
// Add as error to the report if it was not found
|
// Add as error to the report if it was not found
|
||||||
$this->report->addError($file, JText::_('COM_JEDCHECKER_ERROR_GPL_NOT_FOUND'));
|
$this->report->addError($file, Text::_('COM_JEDCHECKER_ERROR_GPL_NOT_FOUND'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -214,7 +216,7 @@ class JedcheckerRulesGpl extends JEDcheckerRule
|
|||||||
$lineno = substr_count($content, "\n", 0, $match[0][1]) + 1;
|
$lineno = substr_count($content, "\n", 0, $match[0][1]) + 1;
|
||||||
$this->report->addPassed(
|
$this->report->addPassed(
|
||||||
$file,
|
$file,
|
||||||
JText::_('COM_JEDCHECKER_PH1_LICENSE_FOUND'),
|
Text::_('COM_JEDCHECKER_PH1_LICENSE_FOUND'),
|
||||||
$lineno,
|
$lineno,
|
||||||
$match[0][0]
|
$match[0][0]
|
||||||
);
|
);
|
||||||
@ -227,7 +229,7 @@ class JedcheckerRulesGpl extends JEDcheckerRule
|
|||||||
$lineno = substr_count($content, "\n", 0, $match[0][1]) + 1;
|
$lineno = substr_count($content, "\n", 0, $match[0][1]) + 1;
|
||||||
$this->report->addWarning(
|
$this->report->addWarning(
|
||||||
$file,
|
$file,
|
||||||
JText::_('COM_JEDCHECKER_GPL_COMPATIBLE_LICENSE_WAS_FOUND'),
|
Text::_('COM_JEDCHECKER_GPL_COMPATIBLE_LICENSE_WAS_FOUND'),
|
||||||
$lineno,
|
$lineno,
|
||||||
$match[0][0]
|
$match[0][0]
|
||||||
);
|
);
|
||||||
|
@ -12,6 +12,9 @@
|
|||||||
|
|
||||||
defined('_JEXEC') or die('Restricted access');
|
defined('_JEXEC') or die('Restricted access');
|
||||||
|
|
||||||
|
use Joomla\CMS\Filesystem\Folder;
|
||||||
|
use Joomla\CMS\Language\Text;
|
||||||
|
|
||||||
// Include the rule base class
|
// Include the rule base class
|
||||||
require_once JPATH_COMPONENT_ADMINISTRATOR . '/models/rule.php';
|
require_once JPATH_COMPONENT_ADMINISTRATOR . '/models/rule.php';
|
||||||
|
|
||||||
@ -67,7 +70,7 @@ class JedcheckerRulesJamss extends JEDcheckerRule
|
|||||||
*/
|
*/
|
||||||
public function check()
|
public function check()
|
||||||
{
|
{
|
||||||
$files = JFolder::files($this->basedir, '', true, true);
|
$files = Folder::files($this->basedir, '', true, true);
|
||||||
|
|
||||||
$this->init_jamss();
|
$this->init_jamss();
|
||||||
|
|
||||||
@ -328,12 +331,12 @@ class JedcheckerRulesJamss extends JEDcheckerRule
|
|||||||
{
|
{
|
||||||
if ($malic_file_descr = array_search(pathinfo($path, PATHINFO_BASENAME), $jamssFileNames))
|
if ($malic_file_descr = array_search(pathinfo($path, PATHINFO_BASENAME), $jamssFileNames))
|
||||||
{
|
{
|
||||||
$this->jamssWarning($path, JText::_('COM_JEDCHECKER_ERROR_JAMSS_SUSPICIOUS_FILENAME'), $malic_file_descr, '', 0);
|
$this->jamssWarning($path, Text::_('COM_JEDCHECKER_ERROR_JAMSS_SUSPICIOUS_FILENAME'), $malic_file_descr, '', 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!($content = file_get_contents($path)))
|
if (!($content = file_get_contents($path)))
|
||||||
{
|
{
|
||||||
$this->report->addError($path, JText::_('COM_JEDCHECKER_ERROR_JAMSS_CANNOT_OPEN') . $malic_file_descr, 0);
|
$this->report->addError($path, Text::_('COM_JEDCHECKER_ERROR_JAMSS_CANNOT_OPEN') . $malic_file_descr, 0);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -413,7 +416,7 @@ class JedcheckerRulesJamss extends JEDcheckerRule
|
|||||||
// Then it has some additional comments
|
// Then it has some additional comments
|
||||||
$this->jamssWarning(
|
$this->jamssWarning(
|
||||||
$path,
|
$path,
|
||||||
JText::_('COM_JEDCHECKER_ERROR_JAMSS_PATTERN') . "#$pattern[2] - $pattern[1]",
|
Text::_('COM_JEDCHECKER_ERROR_JAMSS_PATTERN') . "#$pattern[2] - $pattern[1]",
|
||||||
$pattern[3],
|
$pattern[3],
|
||||||
$first_code,
|
$first_code,
|
||||||
$first_line
|
$first_line
|
||||||
@ -424,7 +427,7 @@ class JedcheckerRulesJamss extends JEDcheckerRule
|
|||||||
// It's a string, no comments available
|
// It's a string, no comments available
|
||||||
$this->jamssWarning(
|
$this->jamssWarning(
|
||||||
$path,
|
$path,
|
||||||
JText::_('COM_JEDCHECKER_ERROR_JAMSS_STRING') . $pattern,
|
Text::_('COM_JEDCHECKER_ERROR_JAMSS_STRING') . $pattern,
|
||||||
'',
|
'',
|
||||||
$first_code,
|
$first_code,
|
||||||
$first_line
|
$first_line
|
||||||
|
@ -12,6 +12,8 @@
|
|||||||
|
|
||||||
defined('_JEXEC') or die('Restricted access');
|
defined('_JEXEC') or die('Restricted access');
|
||||||
|
|
||||||
|
use Joomla\CMS\Language\Text;
|
||||||
|
|
||||||
// Include the rule base class
|
// Include the rule base class
|
||||||
require_once JPATH_COMPONENT_ADMINISTRATOR . '/models/rule.php';
|
require_once JPATH_COMPONENT_ADMINISTRATOR . '/models/rule.php';
|
||||||
|
|
||||||
@ -95,7 +97,7 @@ class JedcheckerRulesJexec extends JEDcheckerRule
|
|||||||
if (!$this->find($file))
|
if (!$this->find($file))
|
||||||
{
|
{
|
||||||
// Add as error to the report if it was not found
|
// Add as error to the report if it was not found
|
||||||
$this->report->addError($file, JText::_('COM_JEDCHECKER_ERROR_JEXEC_NOT_FOUND'));
|
$this->report->addError($file, Text::_('COM_JEDCHECKER_ERROR_JEXEC_NOT_FOUND'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,8 @@
|
|||||||
|
|
||||||
defined('_JEXEC') or die('Restricted access');
|
defined('_JEXEC') or die('Restricted access');
|
||||||
|
|
||||||
|
use Joomla\CMS\Filesystem\Folder;
|
||||||
|
use Joomla\CMS\Language\Text;
|
||||||
|
|
||||||
// Include the rule base class
|
// Include the rule base class
|
||||||
require_once JPATH_COMPONENT_ADMINISTRATOR . '/models/rule.php';
|
require_once JPATH_COMPONENT_ADMINISTRATOR . '/models/rule.php';
|
||||||
@ -66,7 +68,7 @@ class JedcheckerRulesLanguage extends JEDcheckerRule
|
|||||||
public function check()
|
public function check()
|
||||||
{
|
{
|
||||||
// Find all INI files of the extension
|
// Find all INI files of the extension
|
||||||
$files = JFolder::files($this->basedir, '\.ini$', true, true);
|
$files = Folder::files($this->basedir, '\.ini$', true, true);
|
||||||
|
|
||||||
// Iterate through all the ini files
|
// Iterate through all the ini files
|
||||||
foreach ($files as $file)
|
foreach ($files as $file)
|
||||||
@ -99,7 +101,7 @@ class JedcheckerRulesLanguage extends JEDcheckerRule
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check JText usage
|
// Check JText usage
|
||||||
$files = JFolder::files($this->basedir, '\.php$', true, true);
|
$files = Folder::files($this->basedir, '\.php$', true, true);
|
||||||
|
|
||||||
foreach ($files as $file)
|
foreach ($files as $file)
|
||||||
{
|
{
|
||||||
@ -127,7 +129,7 @@ class JedcheckerRulesLanguage extends JEDcheckerRule
|
|||||||
// Check EOL format is \n (not \r or \n\r)
|
// Check EOL format is \n (not \r or \n\r)
|
||||||
if (strpos($content, "\r") !== false)
|
if (strpos($content, "\r") !== false)
|
||||||
{
|
{
|
||||||
$this->report->addNotice($file, JText::_('COM_JEDCHECKER_LANG_INCORRECT_EOL', false, false));
|
$this->report->addNotice($file, Text::_('COM_JEDCHECKER_LANG_INCORRECT_EOL', false, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
$lines = file($file);
|
$lines = file($file);
|
||||||
@ -151,7 +153,7 @@ class JedcheckerRulesLanguage extends JEDcheckerRule
|
|||||||
// Check for BOM sequence
|
// Check for BOM sequence
|
||||||
if ($lineno === 0 && strncmp($line, "\xEF\xBB\xBF", 3) === 0)
|
if ($lineno === 0 && strncmp($line, "\xEF\xBB\xBF", 3) === 0)
|
||||||
{
|
{
|
||||||
$this->report->addWarning($file, JText::_('COM_JEDCHECKER_LANG_BOM_FOUND'), $startLineno);
|
$this->report->addWarning($file, Text::_('COM_JEDCHECKER_LANG_BOM_FOUND'), $startLineno);
|
||||||
|
|
||||||
// Remove BOM for further checks
|
// Remove BOM for further checks
|
||||||
$line = substr($line, 3);
|
$line = substr($line, 3);
|
||||||
@ -166,14 +168,14 @@ class JedcheckerRulesLanguage extends JEDcheckerRule
|
|||||||
// Report incorrect comment character
|
// Report incorrect comment character
|
||||||
if ($line[0] === '#')
|
if ($line[0] === '#')
|
||||||
{
|
{
|
||||||
$this->report->addError($file, JText::_('COM_JEDCHECKER_LANG_INCORRECT_COMMENT'), $startLineno, $line);
|
$this->report->addError($file, Text::_('COM_JEDCHECKER_LANG_INCORRECT_COMMENT'), $startLineno, $line);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for "=" character in the line
|
// Check for "=" character in the line
|
||||||
if (strpos($line, '=') === false)
|
if (strpos($line, '=') === false)
|
||||||
{
|
{
|
||||||
$this->report->addError($file, JText::_('COM_JEDCHECKER_LANG_WRONG_LINE'), $startLineno, $line);
|
$this->report->addError($file, Text::_('COM_JEDCHECKER_LANG_WRONG_LINE'), $startLineno, $line);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,47 +188,47 @@ class JedcheckerRulesLanguage extends JEDcheckerRule
|
|||||||
// Check for empty key
|
// Check for empty key
|
||||||
if ($key === '')
|
if ($key === '')
|
||||||
{
|
{
|
||||||
$this->report->addError($file, JText::_('COM_JEDCHECKER_LANG_KEY_EMPTY'), $startLineno, $line);
|
$this->report->addError($file, Text::_('COM_JEDCHECKER_LANG_KEY_EMPTY'), $startLineno, $line);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for spaces in the key name
|
// Check for spaces in the key name
|
||||||
if (preg_match('/\s/', $key))
|
if (preg_match('/\s/', $key))
|
||||||
{
|
{
|
||||||
$this->report->addError($file, JText::_('COM_JEDCHECKER_LANG_KEY_WHITESPACE'), $startLineno, $line);
|
$this->report->addError($file, Text::_('COM_JEDCHECKER_LANG_KEY_WHITESPACE'), $startLineno, $line);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for invalid characters (see https://www.php.net/manual/en/function.parse-ini-file.php)
|
// Check for invalid characters (see https://www.php.net/manual/en/function.parse-ini-file.php)
|
||||||
if (strpbrk($key, '{}|&~![()^"') !== false)
|
if (strpbrk($key, '{}|&~![()^"') !== false)
|
||||||
{
|
{
|
||||||
$this->report->addError($file, JText::_('COM_JEDCHECKER_LANG_KEY_INVALID_CHARACTER'), $startLineno, $line);
|
$this->report->addError($file, Text::_('COM_JEDCHECKER_LANG_KEY_INVALID_CHARACTER'), $startLineno, $line);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for invalid key names (see https://www.php.net/manual/en/function.parse-ini-file.php)
|
// Check for invalid key names (see https://www.php.net/manual/en/function.parse-ini-file.php)
|
||||||
if (in_array($key, array('null', 'yes', 'no', 'true', 'false', 'on', 'off', 'none'), true))
|
if (in_array($key, array('null', 'yes', 'no', 'true', 'false', 'on', 'off', 'none'), true))
|
||||||
{
|
{
|
||||||
$this->report->addError($file, JText::_('COM_JEDCHECKER_LANG_KEY_RESERVED'), $startLineno, $line);
|
$this->report->addError($file, Text::_('COM_JEDCHECKER_LANG_KEY_RESERVED'), $startLineno, $line);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check key contains ASCII characters only
|
// Check key contains ASCII characters only
|
||||||
if (preg_match('/[\x00-\x1F\x80-\xFF]/', $key))
|
if (preg_match('/[\x00-\x1F\x80-\xFF]/', $key))
|
||||||
{
|
{
|
||||||
$this->report->addWarning($file, JText::_('COM_JEDCHECKER_LANG_KEY_NOT_ASCII'), $startLineno, $line);
|
$this->report->addWarning($file, Text::_('COM_JEDCHECKER_LANG_KEY_NOT_ASCII'), $startLineno, $line);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check key is uppercase
|
// Check key is uppercase
|
||||||
if ($key !== strtoupper($key))
|
if ($key !== strtoupper($key))
|
||||||
{
|
{
|
||||||
$this->report->addWarning($file, JText::_('COM_JEDCHECKER_LANG_KEY_NOT_UPPERCASE'), $startLineno, $line);
|
$this->report->addWarning($file, Text::_('COM_JEDCHECKER_LANG_KEY_NOT_UPPERCASE'), $startLineno, $line);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for duplicated keys
|
// Check for duplicated keys
|
||||||
if (isset($keys[$key]))
|
if (isset($keys[$key]))
|
||||||
{
|
{
|
||||||
$this->report->addWarning($file, JText::sprintf('COM_JEDCHECKER_LANG_KEY_DUPLICATED', $keys[$key]), $startLineno, $line);
|
$this->report->addWarning($file, Text::sprintf('COM_JEDCHECKER_LANG_KEY_DUPLICATED', $keys[$key]), $startLineno, $line);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -253,7 +255,7 @@ class JedcheckerRulesLanguage extends JEDcheckerRule
|
|||||||
// The value doesn't match INI format
|
// The value doesn't match INI format
|
||||||
if (!isset($matches[0]))
|
if (!isset($matches[0]))
|
||||||
{
|
{
|
||||||
$this->report->addWarning($file, JText::_('COM_JEDCHECKER_LANG_TRANSLATION_ERROR'), $startLineno, $line);
|
$this->report->addWarning($file, Text::_('COM_JEDCHECKER_LANG_TRANSLATION_ERROR'), $startLineno, $line);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -263,7 +265,7 @@ class JedcheckerRulesLanguage extends JEDcheckerRule
|
|||||||
// Check for empty value
|
// Check for empty value
|
||||||
if ($value === '""')
|
if ($value === '""')
|
||||||
{
|
{
|
||||||
$this->report->addNotice($file, JText::_('COM_JEDCHECKER_LANG_TRANSLATION_EMPTY'), $startLineno, $line);
|
$this->report->addNotice($file, Text::_('COM_JEDCHECKER_LANG_TRANSLATION_EMPTY'), $startLineno, $line);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -272,26 +274,26 @@ class JedcheckerRulesLanguage extends JEDcheckerRule
|
|||||||
|
|
||||||
if (!$validUTF8)
|
if (!$validUTF8)
|
||||||
{
|
{
|
||||||
$this->report->addWarning($file, JText::_('COM_JEDCHECKER_LANG_INVALID_UTF8'), $startLineno, $line);
|
$this->report->addWarning($file, Text::_('COM_JEDCHECKER_LANG_INVALID_UTF8'), $startLineno, $line);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for unquoted values
|
// Check for unquoted values
|
||||||
if (strlen($value) < 2 || ($value[0] !== '"' && substr($value, -1) !== '"'))
|
if (strlen($value) < 2 || ($value[0] !== '"' && substr($value, -1) !== '"'))
|
||||||
{
|
{
|
||||||
$this->report->addWarning($file, JText::_('COM_JEDCHECKER_LANG_TRANSLATION_QUOTES'), $startLineno, $line);
|
$this->report->addWarning($file, Text::_('COM_JEDCHECKER_LANG_TRANSLATION_QUOTES'), $startLineno, $line);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($value[0] !== '"')
|
if ($value[0] !== '"')
|
||||||
{
|
{
|
||||||
$msg = JText::_('COM_JEDCHECKER_LANG_TRANSLATION_QUOTES') . ' ' . JText::_('COM_JEDCHECKER_LANG_TRANSLATION_MISSED_LEFT_QUOTE');
|
$msg = Text::_('COM_JEDCHECKER_LANG_TRANSLATION_QUOTES') . ' ' . Text::_('COM_JEDCHECKER_LANG_TRANSLATION_MISSED_LEFT_QUOTE');
|
||||||
$this->report->addWarning($file, $msg, $startLineno, $line);
|
$this->report->addWarning($file, $msg, $startLineno, $line);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (substr($value, -1) !== '"')
|
if (substr($value, -1) !== '"')
|
||||||
{
|
{
|
||||||
$msg = JText::_('COM_JEDCHECKER_LANG_TRANSLATION_QUOTES') . ' ' . JText::_('COM_JEDCHECKER_LANG_TRANSLATION_MISSED_RIGHT_QUOTE');
|
$msg = Text::_('COM_JEDCHECKER_LANG_TRANSLATION_QUOTES') . ' ' . Text::_('COM_JEDCHECKER_LANG_TRANSLATION_MISSED_RIGHT_QUOTE');
|
||||||
$this->report->addWarning($file, $msg, $startLineno, $line);
|
$this->report->addWarning($file, $msg, $startLineno, $line);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -302,7 +304,7 @@ class JedcheckerRulesLanguage extends JEDcheckerRule
|
|||||||
// Check for legacy "_QQ_" code (deprecated since Joomla! 3.9 in favour of escaped double quote \"; removed in Joomla! 4)
|
// Check for legacy "_QQ_" code (deprecated since Joomla! 3.9 in favour of escaped double quote \"; removed in Joomla! 4)
|
||||||
if (strpos($value, '"_QQ_"') !== false)
|
if (strpos($value, '"_QQ_"') !== false)
|
||||||
{
|
{
|
||||||
$this->report->addCompat($file, JText::sprintf('COM_JEDCHECKER_LANG_QQDEPRECATED', '<code>"_QQ_"</code>', '<code>\\"</code>'), $startLineno, $line);
|
$this->report->addCompat($file, Text::sprintf('COM_JEDCHECKER_LANG_QQDEPRECATED', '<code>"_QQ_"</code>', '<code>\\"</code>'), $startLineno, $line);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Convert "_QQ_" to escaped quotes for further analysis
|
// Convert "_QQ_" to escaped quotes for further analysis
|
||||||
@ -311,13 +313,13 @@ class JedcheckerRulesLanguage extends JEDcheckerRule
|
|||||||
// Check for unescaped quote
|
// Check for unescaped quote
|
||||||
if (preg_match('/[^\\\\]"/', $value))
|
if (preg_match('/[^\\\\]"/', $value))
|
||||||
{
|
{
|
||||||
$this->report->addWarning($file, JText::_('COM_JEDCHECKER_LANG_UNESCAPED_QUOTE'), $startLineno, $line);
|
$this->report->addWarning($file, Text::_('COM_JEDCHECKER_LANG_UNESCAPED_QUOTE'), $startLineno, $line);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for value interpolation (see https://www.php.net/manual/en/function.parse-ini-file.php for details)
|
// Check for value interpolation (see https://www.php.net/manual/en/function.parse-ini-file.php for details)
|
||||||
if (strpos($value, '${') !== false)
|
if (strpos($value, '${') !== false)
|
||||||
{
|
{
|
||||||
$this->report->addWarning($file, JText::_('COM_JEDCHECKER_LANG_VARIABLE_REF'), $startLineno, $line);
|
$this->report->addWarning($file, Text::_('COM_JEDCHECKER_LANG_VARIABLE_REF'), $startLineno, $line);
|
||||||
}
|
}
|
||||||
|
|
||||||
// The code below detects incorrect format of numbered placeholders (e.g. "%1s" instead of "%1$s")
|
// The code below detects incorrect format of numbered placeholders (e.g. "%1s" instead of "%1$s")
|
||||||
@ -340,7 +342,7 @@ class JedcheckerRulesLanguage extends JEDcheckerRule
|
|||||||
// If placeholder numbers form a sequence, the maximal value is equal to the number of elements
|
// If placeholder numbers form a sequence, the maximal value is equal to the number of elements
|
||||||
if ($maxNumber === $count)
|
if ($maxNumber === $count)
|
||||||
{
|
{
|
||||||
$this->report->addWarning($file, JText::_('COM_JEDCHECKER_LANG_INCORRECT_ARGNUM'), $startLineno, $line);
|
$this->report->addWarning($file, Text::_('COM_JEDCHECKER_LANG_INCORRECT_ARGNUM'), $startLineno, $line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -350,7 +352,7 @@ class JedcheckerRulesLanguage extends JEDcheckerRule
|
|||||||
// Check spaces around (but allow trailing space after colon)
|
// Check spaces around (but allow trailing space after colon)
|
||||||
if (preg_match('/^\s|[^:]\s+$/', $value))
|
if (preg_match('/^\s|[^:]\s+$/', $value))
|
||||||
{
|
{
|
||||||
$this->report->addNotice($file, JText::_('COM_JEDCHECKER_LANG_SPACES_AROUND'), $startLineno, $line);
|
$this->report->addNotice($file, Text::_('COM_JEDCHECKER_LANG_SPACES_AROUND'), $startLineno, $line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -406,7 +408,7 @@ class JedcheckerRulesLanguage extends JEDcheckerRule
|
|||||||
if (!isset($this->langKeys[$key]))
|
if (!isset($this->langKeys[$key]))
|
||||||
{
|
{
|
||||||
$lineno = substr_count($content, "\n", 0, $match[1]);
|
$lineno = substr_count($content, "\n", 0, $match[1]);
|
||||||
$this->report->addNotice($file, JText::sprintf('COM_JEDCHECKER_LANG_UNKNOWN_KEY_IN_CODE', htmlspecialchars($key)), $lineno + 1, $lines[$lineno]);
|
$this->report->addNotice($file, Text::sprintf('COM_JEDCHECKER_LANG_UNKNOWN_KEY_IN_CODE', htmlspecialchars($key)), $lineno + 1, $lines[$lineno]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
defined('_JEXEC') or die('Restricted access');
|
defined('_JEXEC') or die('Restricted access');
|
||||||
|
|
||||||
|
use Joomla\CMS\Language\Text;
|
||||||
|
|
||||||
// Include the rule base class
|
// Include the rule base class
|
||||||
require_once JPATH_COMPONENT_ADMINISTRATOR . '/models/rule.php';
|
require_once JPATH_COMPONENT_ADMINISTRATOR . '/models/rule.php';
|
||||||
@ -304,7 +305,7 @@ class JedcheckerRulesXMLFiles extends JEDcheckerRule
|
|||||||
|
|
||||||
if (!is_dir($folder))
|
if (!is_dir($folder))
|
||||||
{
|
{
|
||||||
$this->errors[] = JText::sprintf('COM_JEDCHECKER_XML_FILES_FOLDER_NOT_FOUND', $attrPath);
|
$this->errors[] = Text::sprintf('COM_JEDCHECKER_XML_FILES_FOLDER_NOT_FOUND', $attrPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -319,7 +320,7 @@ class JedcheckerRulesXMLFiles extends JEDcheckerRule
|
|||||||
|
|
||||||
if (!is_dir($this->basedir . $admindir . $folder) && !is_dir($this->basedir . $sitedir . $folder))
|
if (!is_dir($this->basedir . $admindir . $folder) && !is_dir($this->basedir . $sitedir . $folder))
|
||||||
{
|
{
|
||||||
$this->errors[] = JText::sprintf('COM_JEDCHECKER_XML_FILES_FOLDER_NOT_FOUND', $folder);
|
$this->errors[] = Text::sprintf('COM_JEDCHECKER_XML_FILES_FOLDER_NOT_FOUND', $folder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -358,7 +359,7 @@ class JedcheckerRulesXMLFiles extends JEDcheckerRule
|
|||||||
return $folder . '/';
|
return $folder . '/';
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->warnings[] = JText::sprintf('COM_JEDCHECKER_XML_FILES_FOLDER_NOT_FOUND', $folder);
|
$this->warnings[] = Text::sprintf('COM_JEDCHECKER_XML_FILES_FOLDER_NOT_FOUND', $folder);
|
||||||
|
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
@ -380,7 +381,7 @@ class JedcheckerRulesXMLFiles extends JEDcheckerRule
|
|||||||
$path[] = $p->getName();
|
$path[] = $p->getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->warnings[] = JText::sprintf('COM_JEDCHECKER_XML_FILES_EMPTY_LIST', implode('/', $path));
|
$this->warnings[] = Text::sprintf('COM_JEDCHECKER_XML_FILES_EMPTY_LIST', implode('/', $path));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -409,7 +410,7 @@ class JedcheckerRulesXMLFiles extends JEDcheckerRule
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->errors[] = JText::sprintf('COM_JEDCHECKER_XML_FILES_FILE_NOT_FOUND', $dir . $file);
|
$this->errors[] = Text::sprintf('COM_JEDCHECKER_XML_FILES_FILE_NOT_FOUND', $dir . $file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -427,7 +428,7 @@ class JedcheckerRulesXMLFiles extends JEDcheckerRule
|
|||||||
{
|
{
|
||||||
if (!is_dir($this->basedir . $dir . $folder))
|
if (!is_dir($this->basedir . $dir . $folder))
|
||||||
{
|
{
|
||||||
$this->errors[] = JText::sprintf('COM_JEDCHECKER_XML_FILES_FOLDER_NOT_FOUND', $dir . $folder);
|
$this->errors[] = Text::sprintf('COM_JEDCHECKER_XML_FILES_FOLDER_NOT_FOUND', $dir . $folder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,8 @@
|
|||||||
|
|
||||||
defined('_JEXEC') or die('Restricted access');
|
defined('_JEXEC') or die('Restricted access');
|
||||||
|
|
||||||
|
use Joomla\CMS\Factory;
|
||||||
|
use Joomla\CMS\Language\Text;
|
||||||
|
|
||||||
// Include the rule base class
|
// Include the rule base class
|
||||||
require_once JPATH_COMPONENT_ADMINISTRATOR . '/models/rule.php';
|
require_once JPATH_COMPONENT_ADMINISTRATOR . '/models/rule.php';
|
||||||
@ -109,7 +111,7 @@ class JedcheckerRulesXMLinfo extends JEDcheckerRule
|
|||||||
|
|
||||||
if (!$manifestFound)
|
if (!$manifestFound)
|
||||||
{
|
{
|
||||||
$this->report->addError('', JText::_('COM_JEDCHECKER_INFO_XML_NO_MANIFEST'));
|
$this->report->addError('', Text::_('COM_JEDCHECKER_INFO_XML_NO_MANIFEST'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -136,7 +138,7 @@ class JedcheckerRulesXMLinfo extends JEDcheckerRule
|
|||||||
// 1.5 uses 'install', 1.6+ uses 'extension'
|
// 1.5 uses 'install', 1.6+ uses 'extension'
|
||||||
if ($xml->getName() === 'install')
|
if ($xml->getName() === 'install')
|
||||||
{
|
{
|
||||||
$this->report->addWarning($file, JText::sprintf('COM_JEDCHECKER_INFO_XML_MANIFEST_OUTDATED'));
|
$this->report->addWarning($file, Text::sprintf('COM_JEDCHECKER_INFO_XML_MANIFEST_OUTDATED'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($xml->getName() !== 'extension')
|
if ($xml->getName() !== 'extension')
|
||||||
@ -151,12 +153,12 @@ class JedcheckerRulesXMLinfo extends JEDcheckerRule
|
|||||||
$this->loadExtensionLanguage($xml, dirname($file));
|
$this->loadExtensionLanguage($xml, dirname($file));
|
||||||
|
|
||||||
// Get the real extension's name now that the language has been loaded
|
// Get the real extension's name now that the language has been loaded
|
||||||
$lang = JFactory::getLanguage();
|
$lang = Factory::getLanguage();
|
||||||
$extensionName = $lang->_((string) $xml->name);
|
$extensionName = $lang->_((string) $xml->name);
|
||||||
|
|
||||||
$info[] = JText::sprintf('COM_JEDCHECKER_INFO_XML_NAME_XML', $extensionName);
|
$info[] = Text::sprintf('COM_JEDCHECKER_INFO_XML_NAME_XML', $extensionName);
|
||||||
$info[] = JText::sprintf('COM_JEDCHECKER_INFO_XML_VERSION_XML', (string) $xml->version);
|
$info[] = Text::sprintf('COM_JEDCHECKER_INFO_XML_VERSION_XML', (string) $xml->version);
|
||||||
$info[] = JText::sprintf('COM_JEDCHECKER_INFO_XML_CREATIONDATE_XML', (string) $xml->creationDate);
|
$info[] = Text::sprintf('COM_JEDCHECKER_INFO_XML_CREATIONDATE_XML', (string) $xml->creationDate);
|
||||||
|
|
||||||
$this->report->addInfo($file, implode('<br />', $info));
|
$this->report->addInfo($file, implode('<br />', $info));
|
||||||
|
|
||||||
@ -165,7 +167,7 @@ class JedcheckerRulesXMLinfo extends JEDcheckerRule
|
|||||||
// JED allows components, modules, plugins, and packages (as a container) only
|
// JED allows components, modules, plugins, and packages (as a container) only
|
||||||
if (!in_array($type, $this->jedTypes, true))
|
if (!in_array($type, $this->jedTypes, true))
|
||||||
{
|
{
|
||||||
$this->report->addError($file, JText::sprintf('COM_JEDCHECKER_MANIFEST_TYPE_NOT_ACCEPTED', $type));
|
$this->report->addError($file, Text::sprintf('COM_JEDCHECKER_MANIFEST_TYPE_NOT_ACCEPTED', $type));
|
||||||
}
|
}
|
||||||
|
|
||||||
// NM3 - Listing name contains “module” or “plugin”
|
// NM3 - Listing name contains “module” or “plugin”
|
||||||
@ -173,20 +175,20 @@ class JedcheckerRulesXMLinfo extends JEDcheckerRule
|
|||||||
if (preg_match('/\b(?:module|plugin|component|template|extension|free)\b/i', $extensionName, $match))
|
if (preg_match('/\b(?:module|plugin|component|template|extension|free)\b/i', $extensionName, $match))
|
||||||
{
|
{
|
||||||
$this->report->addIssue(JEDcheckerReport::LEVEL_ERROR, 'NM3', $file,
|
$this->report->addIssue(JEDcheckerReport::LEVEL_ERROR, 'NM3', $file,
|
||||||
JText::sprintf('COM_JEDCHECKER_INFO_XML_NAME_RESERVED_KEYWORDS', $extensionName, strtolower($match[0])));
|
Text::sprintf('COM_JEDCHECKER_INFO_XML_NAME_RESERVED_KEYWORDS', $extensionName, strtolower($match[0])));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extension name shouldn't start with extension type prefix
|
// Extension name shouldn't start with extension type prefix
|
||||||
if (preg_match('/^\s*(?:mod|com|plg|tpl|pkg)_/i', $extensionName))
|
if (preg_match('/^\s*(?:mod|com|plg|tpl|pkg)_/i', $extensionName))
|
||||||
{
|
{
|
||||||
$this->report->addError($file, JText::sprintf('COM_JEDCHECKER_INFO_XML_NAME_PREFIXED', $extensionName));
|
$this->report->addError($file, Text::sprintf('COM_JEDCHECKER_INFO_XML_NAME_PREFIXED', $extensionName));
|
||||||
}
|
}
|
||||||
|
|
||||||
// NM5 - Version in name/title
|
// NM5 - Version in name/title
|
||||||
if (preg_match('/(?:\bversion\b|\d\.\d)/i', $extensionName))
|
if (preg_match('/(?:\bversion\b|\d\.\d)/i', $extensionName))
|
||||||
{
|
{
|
||||||
$this->report->addIssue(JEDcheckerReport::LEVEL_ERROR, 'NM5', $file,
|
$this->report->addIssue(JEDcheckerReport::LEVEL_ERROR, 'NM5', $file,
|
||||||
JText::sprintf('COM_JEDCHECKER_INFO_XML_NAME_VERSION', $extensionName));
|
Text::sprintf('COM_JEDCHECKER_INFO_XML_NAME_VERSION', $extensionName));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for "Joomla" in the name
|
// Check for "Joomla" in the name
|
||||||
@ -194,7 +196,7 @@ class JedcheckerRulesXMLinfo extends JEDcheckerRule
|
|||||||
{
|
{
|
||||||
// An extension name can't start with the word "Joomla"
|
// An extension name can't start with the word "Joomla"
|
||||||
$this->report->addIssue(JEDcheckerReport::LEVEL_ERROR, 'TM2', $file,
|
$this->report->addIssue(JEDcheckerReport::LEVEL_ERROR, 'TM2', $file,
|
||||||
JText::sprintf('COM_JEDCHECKER_INFO_XML_NAME_JOOMLA', $extensionName));
|
Text::sprintf('COM_JEDCHECKER_INFO_XML_NAME_JOOMLA', $extensionName));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -204,14 +206,14 @@ class JedcheckerRulesXMLinfo extends JEDcheckerRule
|
|||||||
{
|
{
|
||||||
// Extensions that use "Joomla" or a derivative of Joomla in the extension name need to be licensed by OSM
|
// Extensions that use "Joomla" or a derivative of Joomla in the extension name need to be licensed by OSM
|
||||||
$this->report->addIssue(JEDcheckerReport::LEVEL_WARNING, 'TM2', $file,
|
$this->report->addIssue(JEDcheckerReport::LEVEL_WARNING, 'TM2', $file,
|
||||||
JText::sprintf('COM_JEDCHECKER_INFO_XML_NAME_JOOMLA_DERIVATIVE', $extensionName, 'https://tm.joomla.org/approved-domains.html'));
|
Text::sprintf('COM_JEDCHECKER_INFO_XML_NAME_JOOMLA_DERIVATIVE', $extensionName, 'https://tm.joomla.org/approved-domains.html'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check extension name consists of ASCII characters only
|
// Check extension name consists of ASCII characters only
|
||||||
if (preg_match('/[^\x20-\x7E]/', $extensionName))
|
if (preg_match('/[^\x20-\x7E]/', $extensionName))
|
||||||
{
|
{
|
||||||
$this->report->addError($file, JText::sprintf('COM_JEDCHECKER_INFO_XML_NAME_NON_ASCII', $extensionName));
|
$this->report->addError($file, Text::sprintf('COM_JEDCHECKER_INFO_XML_NAME_NON_ASCII', $extensionName));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Extension name shouldn't be too long
|
// Extension name shouldn't be too long
|
||||||
@ -219,11 +221,11 @@ class JedcheckerRulesXMLinfo extends JEDcheckerRule
|
|||||||
|
|
||||||
if ($nameLen > 80)
|
if ($nameLen > 80)
|
||||||
{
|
{
|
||||||
$this->report->addError($file, JText::sprintf('COM_JEDCHECKER_INFO_XML_NAME_TOO_LONG', $extensionName));
|
$this->report->addError($file, Text::sprintf('COM_JEDCHECKER_INFO_XML_NAME_TOO_LONG', $extensionName));
|
||||||
}
|
}
|
||||||
elseif ($nameLen > 40)
|
elseif ($nameLen > 40)
|
||||||
{
|
{
|
||||||
$this->report->addWarning($file, JText::sprintf('COM_JEDCHECKER_INFO_XML_NAME_TOO_LONG', $extensionName));
|
$this->report->addWarning($file, Text::sprintf('COM_JEDCHECKER_INFO_XML_NAME_TOO_LONG', $extensionName));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -241,7 +243,7 @@ class JedcheckerRulesXMLinfo extends JEDcheckerRule
|
|||||||
// Do name the Component's admin menu the same as the extension name
|
// Do name the Component's admin menu the same as the extension name
|
||||||
if ($extensionName !== $menuName)
|
if ($extensionName !== $menuName)
|
||||||
{
|
{
|
||||||
$this->report->addWarning($file, JText::sprintf('COM_JEDCHECKER_INFO_XML_NAME_ADMIN_MENU', $menuName, $extensionName));
|
$this->report->addWarning($file, Text::sprintf('COM_JEDCHECKER_INFO_XML_NAME_ADMIN_MENU', $menuName, $extensionName));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -256,7 +258,7 @@ class JedcheckerRulesXMLinfo extends JEDcheckerRule
|
|||||||
&& !(isset($this->pluginsGroupMap[$extensionNameGroup]) && $this->pluginsGroupMap[$extensionNameGroup] === $group)
|
&& !(isset($this->pluginsGroupMap[$extensionNameGroup]) && $this->pluginsGroupMap[$extensionNameGroup] === $group)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
$this->report->addWarning($file, JText::sprintf('COM_JEDCHECKER_INFO_XML_NAME_PLUGIN_FORMAT', $extensionName));
|
$this->report->addWarning($file, Text::sprintf('COM_JEDCHECKER_INFO_XML_NAME_PLUGIN_FORMAT', $extensionName));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -287,7 +289,7 @@ class JedcheckerRulesXMLinfo extends JEDcheckerRule
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Load the language of the extension (if any)
|
// Load the language of the extension (if any)
|
||||||
$lang = JFactory::getLanguage();
|
$lang = Factory::getLanguage();
|
||||||
|
|
||||||
// Populate list of directories to look for
|
// Populate list of directories to look for
|
||||||
$lookupLangDirs = array();
|
$lookupLangDirs = array();
|
||||||
@ -373,7 +375,7 @@ class JedcheckerRulesXMLinfo extends JEDcheckerRule
|
|||||||
{
|
{
|
||||||
// Extensions that use "Joomla" or a derivative of Joomla in the domain name need to be licensed by OSM
|
// Extensions that use "Joomla" or a derivative of Joomla in the domain name need to be licensed by OSM
|
||||||
$this->report->addIssue(JEDcheckerReport::LEVEL_ERROR, 'TM1', $file,
|
$this->report->addIssue(JEDcheckerReport::LEVEL_ERROR, 'TM1', $file,
|
||||||
JText::sprintf('COM_JEDCHECKER_INFO_XML_URL_JOOMLA_DERIVATIVE', $url, 'https://tm.joomla.org/approved-domains.html'));
|
Text::sprintf('COM_JEDCHECKER_INFO_XML_URL_JOOMLA_DERIVATIVE', $url, 'https://tm.joomla.org/approved-domains.html'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,8 @@
|
|||||||
|
|
||||||
defined('_JEXEC') or die('Restricted access');
|
defined('_JEXEC') or die('Restricted access');
|
||||||
|
|
||||||
|
use Joomla\CMS\Language\Text;
|
||||||
|
|
||||||
// Include the rule base class
|
// Include the rule base class
|
||||||
require_once JPATH_COMPONENT_ADMINISTRATOR . '/models/rule.php';
|
require_once JPATH_COMPONENT_ADMINISTRATOR . '/models/rule.php';
|
||||||
|
|
||||||
@ -96,7 +98,7 @@ class JedcheckerRulesXMLlicense extends JEDcheckerRule
|
|||||||
// Check if there's a license tag
|
// Check if there's a license tag
|
||||||
if (!isset($xml->license))
|
if (!isset($xml->license))
|
||||||
{
|
{
|
||||||
$this->report->addError($file, JText::_('COM_JEDCHECKER_ERROR_XML_LICENSE_NOT_FOUND'));
|
$this->report->addError($file, Text::_('COM_JEDCHECKER_ERROR_XML_LICENSE_NOT_FOUND'));
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -105,7 +107,7 @@ class JedcheckerRulesXMLlicense extends JEDcheckerRule
|
|||||||
if (stripos($xml->license, 'gpl') === false
|
if (stripos($xml->license, 'gpl') === false
|
||||||
&& stripos($xml->license, 'general public license') === false)
|
&& stripos($xml->license, 'general public license') === false)
|
||||||
{
|
{
|
||||||
$this->report->addCompat($file, JText::_('COM_JEDCHECKER_ERROR_XML_LICENSE_NOT_GPL'));
|
$this->report->addCompat($file, Text::_('COM_JEDCHECKER_ERROR_XML_LICENSE_NOT_GPL'));
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
defined('_JEXEC') or die('Restricted access');
|
defined('_JEXEC') or die('Restricted access');
|
||||||
|
|
||||||
|
use Joomla\CMS\Language\Text;
|
||||||
|
|
||||||
// Include the rule base class
|
// Include the rule base class
|
||||||
require_once JPATH_COMPONENT_ADMINISTRATOR . '/models/rule.php';
|
require_once JPATH_COMPONENT_ADMINISTRATOR . '/models/rule.php';
|
||||||
@ -143,7 +144,7 @@ class JedcheckerRulesXMLManifest extends JEDcheckerRule
|
|||||||
|
|
||||||
if (!in_array($type, $this->joomlaTypes, true))
|
if (!in_array($type, $this->joomlaTypes, true))
|
||||||
{
|
{
|
||||||
$this->report->addError($file, JText::sprintf('COM_JEDCHECKER_MANIFEST_UNKNOWN_TYPE', $type));
|
$this->report->addError($file, Text::sprintf('COM_JEDCHECKER_MANIFEST_UNKNOWN_TYPE', $type));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -159,7 +160,7 @@ class JedcheckerRulesXMLManifest extends JEDcheckerRule
|
|||||||
// Warn if method="upgrade" attribute is not found
|
// Warn if method="upgrade" attribute is not found
|
||||||
if ((string) $xml['method'] !== 'upgrade')
|
if ((string) $xml['method'] !== 'upgrade')
|
||||||
{
|
{
|
||||||
$this->report->addWarning($file, JText::_('COM_JEDCHECKER_MANIFEST_MISSED_METHOD_UPGRADE'));
|
$this->report->addWarning($file, Text::_('COM_JEDCHECKER_MANIFEST_MISSED_METHOD_UPGRADE'));
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ($type)
|
switch ($type)
|
||||||
@ -172,11 +173,11 @@ class JedcheckerRulesXMLManifest extends JEDcheckerRule
|
|||||||
|
|
||||||
if (!isset($xml['client']))
|
if (!isset($xml['client']))
|
||||||
{
|
{
|
||||||
$this->report->addError($file, JText::sprintf('COM_JEDCHECKER_MANIFEST_MISSED_ATTRIBUTE', $xml->getName(), 'client'));
|
$this->report->addError($file, Text::sprintf('COM_JEDCHECKER_MANIFEST_MISSED_ATTRIBUTE', $xml->getName(), 'client'));
|
||||||
}
|
}
|
||||||
elseif ($client !== 'site' && $client !== 'administrator')
|
elseif ($client !== 'site' && $client !== 'administrator')
|
||||||
{
|
{
|
||||||
$this->report->addError($file, JText::sprintf('COM_JEDCHECKER_MANIFEST_UNKNOWN_ATTRIBUTE_VALUE', $xml->getName(), 'client', $client));
|
$this->report->addError($file, Text::sprintf('COM_JEDCHECKER_MANIFEST_UNKNOWN_ATTRIBUTE_VALUE', $xml->getName(), 'client', $client));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($type === 'module')
|
if ($type === 'module')
|
||||||
@ -186,7 +187,7 @@ class JedcheckerRulesXMLManifest extends JEDcheckerRule
|
|||||||
|
|
||||||
if (count($elements) >= 2)
|
if (count($elements) >= 2)
|
||||||
{
|
{
|
||||||
$this->report->addWarning($file, JText::sprintf('COM_JEDCHECKER_MANIFEST_MULTIPLE_ATTRIBUTES', 'module'));
|
$this->report->addWarning($file, Text::sprintf('COM_JEDCHECKER_MANIFEST_MULTIPLE_ATTRIBUTES', 'module'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($xml->element))
|
if (isset($xml->element))
|
||||||
@ -195,14 +196,14 @@ class JedcheckerRulesXMLManifest extends JEDcheckerRule
|
|||||||
|
|
||||||
if (count($elements) && $elements[0] !== $element)
|
if (count($elements) && $elements[0] !== $element)
|
||||||
{
|
{
|
||||||
$this->report->addWarning($file, JText::_('COM_JEDCHECKER_MANIFEST_MODULE_ELEMENT_MISMATCH'));
|
$this->report->addWarning($file, Text::_('COM_JEDCHECKER_MANIFEST_MODULE_ELEMENT_MISMATCH'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (count($elements) === 0)
|
if (count($elements) === 0)
|
||||||
{
|
{
|
||||||
$this->report->addError($file, JText::sprintf('COM_JEDCHECKER_MANIFEST_MISSED_ELEMENT_ATTRIBUTE', 'module'));
|
$this->report->addError($file, Text::sprintf('COM_JEDCHECKER_MANIFEST_MISSED_ELEMENT_ATTRIBUTE', 'module'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -215,12 +216,12 @@ class JedcheckerRulesXMLManifest extends JEDcheckerRule
|
|||||||
|
|
||||||
if (count($elements) >= 2)
|
if (count($elements) >= 2)
|
||||||
{
|
{
|
||||||
$this->report->addWarning($file, JText::sprintf('COM_JEDCHECKER_MANIFEST_MULTIPLE_ATTRIBUTES', 'plugin'));
|
$this->report->addWarning($file, Text::sprintf('COM_JEDCHECKER_MANIFEST_MULTIPLE_ATTRIBUTES', 'plugin'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count($elements) === 0)
|
if (count($elements) === 0)
|
||||||
{
|
{
|
||||||
$this->report->addError($file, JText::sprintf('COM_JEDCHECKER_MANIFEST_MISSED_ELEMENT_ATTRIBUTE', 'plugin'));
|
$this->report->addError($file, Text::sprintf('COM_JEDCHECKER_MANIFEST_MISSED_ELEMENT_ATTRIBUTE', 'plugin'));
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -231,12 +232,12 @@ class JedcheckerRulesXMLManifest extends JEDcheckerRule
|
|||||||
{
|
{
|
||||||
if (!isset($item['type']))
|
if (!isset($item['type']))
|
||||||
{
|
{
|
||||||
$this->report->addError($file, JText::sprintf('COM_JEDCHECKER_MANIFEST_MISSED_ATTRIBUTE', $item->getName(), 'type'));
|
$this->report->addError($file, Text::sprintf('COM_JEDCHECKER_MANIFEST_MISSED_ATTRIBUTE', $item->getName(), 'type'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset($item['id']))
|
if (!isset($item['id']))
|
||||||
{
|
{
|
||||||
$this->report->addError($file, JText::sprintf('COM_JEDCHECKER_MANIFEST_MISSED_ATTRIBUTE', $item->getName(), 'id'));
|
$this->report->addError($file, Text::sprintf('COM_JEDCHECKER_MANIFEST_MISSED_ATTRIBUTE', $item->getName(), 'id'));
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ((string) $item['type'])
|
switch ((string) $item['type'])
|
||||||
@ -244,7 +245,7 @@ class JedcheckerRulesXMLManifest extends JEDcheckerRule
|
|||||||
case 'plugin':
|
case 'plugin':
|
||||||
if (!isset($item['group']))
|
if (!isset($item['group']))
|
||||||
{
|
{
|
||||||
$this->report->addError($file, JText::sprintf('COM_JEDCHECKER_MANIFEST_MISSED_ATTRIBUTE', $item->getName(), 'group'));
|
$this->report->addError($file, Text::sprintf('COM_JEDCHECKER_MANIFEST_MISSED_ATTRIBUTE', $item->getName(), 'group'));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -255,11 +256,11 @@ class JedcheckerRulesXMLManifest extends JEDcheckerRule
|
|||||||
|
|
||||||
if (!isset($item['client']))
|
if (!isset($item['client']))
|
||||||
{
|
{
|
||||||
$this->report->addError($file, JText::sprintf('COM_JEDCHECKER_MANIFEST_MISSED_ATTRIBUTE', $item->getName(), 'client'));
|
$this->report->addError($file, Text::sprintf('COM_JEDCHECKER_MANIFEST_MISSED_ATTRIBUTE', $item->getName(), 'client'));
|
||||||
}
|
}
|
||||||
elseif ($client !== 'site' && $client !== 'administrator')
|
elseif ($client !== 'site' && $client !== 'administrator')
|
||||||
{
|
{
|
||||||
$this->report->addError($file, JText::sprintf('COM_JEDCHECKER_MANIFEST_UNKNOWN_ATTRIBUTE_VALUE', $item->getName(), 'client', $client));
|
$this->report->addError($file, Text::sprintf('COM_JEDCHECKER_MANIFEST_UNKNOWN_ATTRIBUTE_VALUE', $item->getName(), 'client', $client));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -269,7 +270,7 @@ class JedcheckerRulesXMLManifest extends JEDcheckerRule
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
$this->report->addError($file, JText::sprintf('COM_JEDCHECKER_MANIFEST_UNKNOWN_TYPE', $item['type']));
|
$this->report->addError($file, Text::sprintf('COM_JEDCHECKER_MANIFEST_UNKNOWN_TYPE', $item['type']));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -322,7 +323,7 @@ class JedcheckerRulesXMLManifest extends JEDcheckerRule
|
|||||||
// No known attributes for this node
|
// No known attributes for this node
|
||||||
foreach ($node->attributes() as $attr)
|
foreach ($node->attributes() as $attr)
|
||||||
{
|
{
|
||||||
$this->notices[] = JText::sprintf('COM_JEDCHECKER_MANIFEST_UNKNOWN_ATTRIBUTE', $name, (string) $attr->getName());
|
$this->notices[] = Text::sprintf('COM_JEDCHECKER_MANIFEST_UNKNOWN_ATTRIBUTE', $name, (string) $attr->getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elseif ($DTDattributes[0] !== '*') // Skip node with arbitrary attributes (e.g. "field")
|
elseif ($DTDattributes[0] !== '*') // Skip node with arbitrary attributes (e.g. "field")
|
||||||
@ -334,7 +335,7 @@ class JedcheckerRulesXMLManifest extends JEDcheckerRule
|
|||||||
if (!in_array($attrName, $DTDattributes, true))
|
if (!in_array($attrName, $DTDattributes, true))
|
||||||
{
|
{
|
||||||
// The node has unknown attribute
|
// The node has unknown attribute
|
||||||
$this->notices[] = JText::sprintf('COM_JEDCHECKER_MANIFEST_UNKNOWN_ATTRIBUTE', $name, $attrName);
|
$this->notices[] = Text::sprintf('COM_JEDCHECKER_MANIFEST_UNKNOWN_ATTRIBUTE', $name, $attrName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -350,7 +351,7 @@ class JedcheckerRulesXMLManifest extends JEDcheckerRule
|
|||||||
// No known children for this node
|
// No known children for this node
|
||||||
if ($node->count() > 0)
|
if ($node->count() > 0)
|
||||||
{
|
{
|
||||||
$this->notices[] = JText::sprintf('COM_JEDCHECKER_MANIFEST_UNKNOWN_CHILDREN', $name);
|
$this->notices[] = Text::sprintf('COM_JEDCHECKER_MANIFEST_UNKNOWN_CHILDREN', $name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elseif (!isset($DTDchildRules['*'])) // Skip node with arbitrary children
|
elseif (!isset($DTDchildRules['*'])) // Skip node with arbitrary children
|
||||||
@ -377,12 +378,12 @@ class JedcheckerRulesXMLManifest extends JEDcheckerRule
|
|||||||
if ($count === 0)
|
if ($count === 0)
|
||||||
{
|
{
|
||||||
// The node doesn't contain required child element
|
// The node doesn't contain required child element
|
||||||
$this->errors[] = JText::sprintf('COM_JEDCHECKER_MANIFEST_MISSED_REQUIRED', $name, $child);
|
$this->errors[] = Text::sprintf('COM_JEDCHECKER_MANIFEST_MISSED_REQUIRED', $name, $child);
|
||||||
}
|
}
|
||||||
elseif ($count > 1)
|
elseif ($count > 1)
|
||||||
{
|
{
|
||||||
// The node contains multiple child elements when single only is expected
|
// The node contains multiple child elements when single only is expected
|
||||||
$this->errors[] = JText::sprintf('COM_JEDCHECKER_MANIFEST_MULTIPLE_FOUND', $name, $child);
|
$this->errors[] = Text::sprintf('COM_JEDCHECKER_MANIFEST_MULTIPLE_FOUND', $name, $child);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -391,12 +392,12 @@ class JedcheckerRulesXMLManifest extends JEDcheckerRule
|
|||||||
if ($count === 0)
|
if ($count === 0)
|
||||||
{
|
{
|
||||||
// The node doesn't contain optional child element
|
// The node doesn't contain optional child element
|
||||||
$this->notices[] = JText::sprintf('COM_JEDCHECKER_MANIFEST_MISSED_OPTIONAL', $name, $child);
|
$this->notices[] = Text::sprintf('COM_JEDCHECKER_MANIFEST_MISSED_OPTIONAL', $name, $child);
|
||||||
}
|
}
|
||||||
elseif ($count > 1)
|
elseif ($count > 1)
|
||||||
{
|
{
|
||||||
// The node contains multiple child elements when single only is expected
|
// The node contains multiple child elements when single only is expected
|
||||||
$this->warnings[] = JText::sprintf('COM_JEDCHECKER_MANIFEST_MULTIPLE_FOUND', $name, $child);
|
$this->warnings[] = Text::sprintf('COM_JEDCHECKER_MANIFEST_MULTIPLE_FOUND', $name, $child);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -420,14 +421,14 @@ class JedcheckerRulesXMLManifest extends JEDcheckerRule
|
|||||||
if (!isset($DTDchildToRule[$child]))
|
if (!isset($DTDchildToRule[$child]))
|
||||||
{
|
{
|
||||||
// The node contains unknown child element
|
// The node contains unknown child element
|
||||||
$this->notices[] = JText::sprintf('COM_JEDCHECKER_MANIFEST_UNKNOWN_CHILD', $name, $child);
|
$this->notices[] = Text::sprintf('COM_JEDCHECKER_MANIFEST_UNKNOWN_CHILD', $name, $child);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ($DTDchildRules[$DTDchildToRule[$child]] === '?' && $node->$child->count() > 1)
|
if ($DTDchildRules[$DTDchildToRule[$child]] === '?' && $node->$child->count() > 1)
|
||||||
{
|
{
|
||||||
// The node contains multiple child elements when single only is expected
|
// The node contains multiple child elements when single only is expected
|
||||||
$this->errors[] = JText::sprintf('COM_JEDCHECKER_MANIFEST_MULTIPLE_FOUND', $name, $child);
|
$this->errors[] = Text::sprintf('COM_JEDCHECKER_MANIFEST_MULTIPLE_FOUND', $name, $child);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -437,7 +438,7 @@ class JedcheckerRulesXMLManifest extends JEDcheckerRule
|
|||||||
{
|
{
|
||||||
if ($child->count() === 0 && $child->attributes()->count() === 0 && (string) $child === '')
|
if ($child->count() === 0 && $child->attributes()->count() === 0 && (string) $child === '')
|
||||||
{
|
{
|
||||||
$this->notices[] = JText::sprintf('COM_JEDCHECKER_MANIFEST_EMPTY_CHILD', $child->getName());
|
$this->notices[] = Text::sprintf('COM_JEDCHECKER_MANIFEST_EMPTY_CHILD', $child->getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -481,7 +482,7 @@ class JedcheckerRulesXMLManifest extends JEDcheckerRule
|
|||||||
|
|
||||||
if (in_array($attrName, $skipAttrs, true))
|
if (in_array($attrName, $skipAttrs, true))
|
||||||
{
|
{
|
||||||
$this->warnings[] = JText::sprintf('COM_JEDCHECKER_MANIFEST_MENU_UNUSED_ATTRIBUTE', $attrName);
|
$this->warnings[] = Text::sprintf('COM_JEDCHECKER_MANIFEST_MENU_UNUSED_ATTRIBUTE', $attrName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,8 @@
|
|||||||
|
|
||||||
defined('_JEXEC') or die('Restricted access');
|
defined('_JEXEC') or die('Restricted access');
|
||||||
|
|
||||||
|
use Joomla\CMS\Language\Text;
|
||||||
|
|
||||||
// Include the rule base class
|
// Include the rule base class
|
||||||
require_once JPATH_COMPONENT_ADMINISTRATOR . '/models/rule.php';
|
require_once JPATH_COMPONENT_ADMINISTRATOR . '/models/rule.php';
|
||||||
|
|
||||||
@ -193,7 +195,7 @@ class JedcheckerRulesXMLUpdateServer extends JEDcheckerRule
|
|||||||
// Check if there is an updateservers tag
|
// Check if there is an updateservers tag
|
||||||
if (!isset($xml->updateservers))
|
if (!isset($xml->updateservers))
|
||||||
{
|
{
|
||||||
$this->report->addError($file, JText::_('COM_JEDCHECKER_ERROR_XML_UPDATE_SERVER_NOT_FOUND'));
|
$this->report->addError($file, Text::_('COM_JEDCHECKER_ERROR_XML_UPDATE_SERVER_NOT_FOUND'));
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -201,7 +203,7 @@ class JedcheckerRulesXMLUpdateServer extends JEDcheckerRule
|
|||||||
// Check if server tag(s) exist
|
// Check if server tag(s) exist
|
||||||
if (!isset($xml->updateservers->server))
|
if (!isset($xml->updateservers->server))
|
||||||
{
|
{
|
||||||
$this->report->addError($file, JText::_('COM_JEDCHECKER_ERROR_XML_UPDATE_SERVER_NOT_FOUND'));
|
$this->report->addError($file, Text::_('COM_JEDCHECKER_ERROR_XML_UPDATE_SERVER_NOT_FOUND'));
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -212,13 +214,13 @@ class JedcheckerRulesXMLUpdateServer extends JEDcheckerRule
|
|||||||
{
|
{
|
||||||
if (stripos($server, 'http') === false)
|
if (stripos($server, 'http') === false)
|
||||||
{
|
{
|
||||||
$this->report->addError($file, JText::_('COM_JEDCHECKER_ERROR_XML_UPDATE_SERVER_LINK_NOT_FOUND'));
|
$this->report->addError($file, Text::_('COM_JEDCHECKER_ERROR_XML_UPDATE_SERVER_LINK_NOT_FOUND'));
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->report->addPassed($file, JText::sprintf('COM_JEDCHECKER_INFO_XML_UPDATE_SERVER_LINK', (string) $server));
|
$this->report->addPassed($file, Text::sprintf('COM_JEDCHECKER_INFO_XML_UPDATE_SERVER_LINK', (string) $server));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,6 +12,9 @@
|
|||||||
|
|
||||||
defined('_JEXEC') or die('Restricted access');
|
defined('_JEXEC') or die('Restricted access');
|
||||||
|
|
||||||
|
use Joomla\CMS\Language\Text;
|
||||||
|
use Joomla\CMS\Object\CMSObject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class JEDcheckerReport
|
* Class JEDcheckerReport
|
||||||
*
|
*
|
||||||
@ -20,7 +23,7 @@ defined('_JEXEC') or die('Restricted access');
|
|||||||
*
|
*
|
||||||
* @since 1.0
|
* @since 1.0
|
||||||
*/
|
*/
|
||||||
class JEDcheckerReport extends JObject
|
class JEDcheckerReport extends CMSObject
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Rule's issue levels
|
* Rule's issue levels
|
||||||
@ -107,12 +110,12 @@ class JEDcheckerReport extends JObject
|
|||||||
{
|
{
|
||||||
// Initialize language strings
|
// Initialize language strings
|
||||||
$this->issueLangTitles = array(
|
$this->issueLangTitles = array(
|
||||||
self::LEVEL_ERROR => JText::_('COM_JEDCHECKER_LEVEL_ERROR'),
|
self::LEVEL_ERROR => Text::_('COM_JEDCHECKER_LEVEL_ERROR'),
|
||||||
self::LEVEL_WARNING => JText::_('COM_JEDCHECKER_LEVEL_WARNING'),
|
self::LEVEL_WARNING => Text::_('COM_JEDCHECKER_LEVEL_WARNING'),
|
||||||
self::LEVEL_COMPAT => JText::_('COM_JEDCHECKER_LEVEL_COMPATIBILITY'),
|
self::LEVEL_COMPAT => Text::_('COM_JEDCHECKER_LEVEL_COMPATIBILITY'),
|
||||||
self::LEVEL_NOTICE => JText::_('COM_JEDCHECKER_LEVEL_NOTICE'),
|
self::LEVEL_NOTICE => Text::_('COM_JEDCHECKER_LEVEL_NOTICE'),
|
||||||
self::LEVEL_INFO => JText::_('COM_JEDCHECKER_LEVEL_INFO'),
|
self::LEVEL_INFO => Text::_('COM_JEDCHECKER_LEVEL_INFO'),
|
||||||
self::LEVEL_PASSED => JText::_('COM_JEDCHECKER_LEVEL_PASSED'),
|
self::LEVEL_PASSED => Text::_('COM_JEDCHECKER_LEVEL_PASSED'),
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->data = array();
|
$this->data = array();
|
||||||
@ -269,7 +272,7 @@ class JEDcheckerReport extends JObject
|
|||||||
{
|
{
|
||||||
// No errors or compatibility issues found
|
// No errors or compatibility issues found
|
||||||
$html[] = '<div class="alert alert-success">';
|
$html[] = '<div class="alert alert-success">';
|
||||||
$html[] = JText::_('COM_JEDCHECKER_EVERYTHING_SEEMS_TO_BE_FINE_WITH_THAT_RULE');
|
$html[] = Text::_('COM_JEDCHECKER_EVERYTHING_SEEMS_TO_BE_FINE_WITH_THAT_RULE');
|
||||||
$html[] = '</div>';
|
$html[] = '</div>';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -343,7 +346,7 @@ class JEDcheckerReport extends JObject
|
|||||||
// Add line information if given
|
// Add line information if given
|
||||||
if ($item->line !== null)
|
if ($item->line !== null)
|
||||||
{
|
{
|
||||||
$html[] = ' ' . JText::_('COM_JEDCHECKER_IN_LINE') . ': <strong>' . $item->line . '</strong>';
|
$html[] = ' ' . Text::_('COM_JEDCHECKER_IN_LINE') . ': <strong>' . $item->line . '</strong>';
|
||||||
}
|
}
|
||||||
|
|
||||||
$html[] = '<br />';
|
$html[] = '<br />';
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
defined('_JEXEC') or die('Restricted access');
|
defined('_JEXEC') or die('Restricted access');
|
||||||
|
|
||||||
use Joomla\Registry\Registry;
|
use Joomla\Registry\Registry;
|
||||||
|
use Joomla\CMS\Object\CMSObject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* class JEDcheckerRule
|
* class JEDcheckerRule
|
||||||
@ -22,7 +22,7 @@ use Joomla\Registry\Registry;
|
|||||||
*
|
*
|
||||||
* @since 1.0
|
* @since 1.0
|
||||||
*/
|
*/
|
||||||
class JEDcheckerRule extends JObject
|
class JEDcheckerRule extends CMSObject
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* The formal ID of this rule. For example: SE1.
|
* The formal ID of this rule. For example: SE1.
|
||||||
|
@ -11,24 +11,28 @@
|
|||||||
|
|
||||||
defined('_JEXEC') or die('Restricted access');
|
defined('_JEXEC') or die('Restricted access');
|
||||||
|
|
||||||
|
use Joomla\CMS\HTML\HTMLHelper;
|
||||||
|
use Joomla\CMS\Language\Text;
|
||||||
|
use Joomla\CMS\Router\Route;
|
||||||
|
|
||||||
// Load Bootstrap
|
// Load Bootstrap
|
||||||
if (version_compare(JVERSION, '4.0', '>='))
|
if (version_compare(JVERSION, '4.0', '>='))
|
||||||
{
|
{
|
||||||
JHtml::_('bootstrap.collapse');
|
HTMLHelper::_('bootstrap.collapse');
|
||||||
JHtml::_('bootstrap.tab');
|
HTMLHelper::_('bootstrap.tab');
|
||||||
|
|
||||||
// Tooltips are used by JAMSS reports
|
// Tooltips are used by JAMSS reports
|
||||||
JHtml::_('bootstrap.tooltip');
|
HTMLHelper::_('bootstrap.tooltip');
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
JHtml::_('behavior.core');
|
HTMLHelper::_('behavior.core');
|
||||||
JHtml::_('stylesheet', 'com_jedchecker/j4-style.css', array('version' => 'auto', 'relative' => true));
|
HTMLHelper::_('stylesheet', 'com_jedchecker/j4-style.css', array('version' => 'auto', 'relative' => true));
|
||||||
JHtml::_('script', 'com_jedchecker/bootstrap.bundle.min.js', array('version' => 'auto', 'relative' => true), array('defer' => true));
|
HTMLHelper::_('script', 'com_jedchecker/bootstrap.bundle.min.js', array('version' => 'auto', 'relative' => true), array('defer' => true));
|
||||||
}
|
}
|
||||||
|
|
||||||
JHtml::_('stylesheet', 'com_jedchecker/style.css', array('version' => 'auto', 'relative' => true));
|
HTMLHelper::_('stylesheet', 'com_jedchecker/style.css', array('version' => 'auto', 'relative' => true));
|
||||||
JHtml::_('script', 'com_jedchecker/script.js', array('version' => 'auto', 'relative' => true), array('defer' => true));
|
HTMLHelper::_('script', 'com_jedchecker/script.js', array('version' => 'auto', 'relative' => true), array('defer' => true));
|
||||||
?>
|
?>
|
||||||
<script id="jed-rules-json" type="application/json"><?php echo json_encode($this->jsOptions); ?></script>
|
<script id="jed-rules-json" type="application/json"><?php echo json_encode($this->jsOptions); ?></script>
|
||||||
<div id="jedchecker">
|
<div id="jedchecker">
|
||||||
@ -36,36 +40,36 @@ JHtml::_('script', 'com_jedchecker/script.js', array('version' => 'auto', 'relat
|
|||||||
<div class="col-12 col-md-8">
|
<div class="col-12 col-md-8">
|
||||||
<div class="card bg-light">
|
<div class="card bg-light">
|
||||||
<div class="card-header" data-bs-toggle="collapse" data-bs-target="#jedchecker-welcome" role="button">
|
<div class="card-header" data-bs-toggle="collapse" data-bs-target="#jedchecker-welcome" role="button">
|
||||||
<?php echo JText::_('COM_JEDCHECKER'); ?>
|
<?php echo Text::_('COM_JEDCHECKER'); ?>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body show" id="jedchecker-welcome">
|
<div class="card-body show" id="jedchecker-welcome">
|
||||||
<p class="card-text">
|
<p class="card-text">
|
||||||
<?php echo JText::sprintf('COM_JEDCHECKER_CONGRATS', 'https://extensions.joomla.org/community/terms-of-service/'); ?>
|
<?php echo Text::sprintf('COM_JEDCHECKER_CONGRATS', 'https://extensions.joomla.org/community/terms-of-service/'); ?>
|
||||||
</p>
|
</p>
|
||||||
<p class="card-text">
|
<p class="card-text">
|
||||||
<?php echo JText::sprintf('COM_JEDCHECKER_CODE_STANDARDS', 'https://developer.joomla.org/coding-standards.html'); ?>
|
<?php echo Text::sprintf('COM_JEDCHECKER_CODE_STANDARDS', 'https://developer.joomla.org/coding-standards.html'); ?>
|
||||||
</p>
|
</p>
|
||||||
<p class="card-text">
|
<p class="card-text">
|
||||||
<?php echo JText::_('COM_JEDCHECKER_HOW_TO_USE'); ?>
|
<?php echo Text::_('COM_JEDCHECKER_HOW_TO_USE'); ?>
|
||||||
</p>
|
</p>
|
||||||
<ol class="card-text">
|
<ol class="card-text">
|
||||||
<li><?php echo JText::_('COM_JEDCHECKER_STEP1'); ?></li>
|
<li><?php echo Text::_('COM_JEDCHECKER_STEP1'); ?></li>
|
||||||
<li><?php echo JText::_('COM_JEDCHECKER_STEP2'); ?></li>
|
<li><?php echo Text::_('COM_JEDCHECKER_STEP2'); ?></li>
|
||||||
</ol>
|
</ol>
|
||||||
<form action="<?php echo JRoute::_('index.php?option=com_jedchecker&view=uploads'); ?>"
|
<form action="<?php echo Route::_('index.php?option=com_jedchecker&view=uploads'); ?>"
|
||||||
method="post" class="needs-validation" name="adminForm" id="adminForm" enctype="multipart/form-data">
|
method="post" class="needs-validation" name="adminForm" id="adminForm" enctype="multipart/form-data">
|
||||||
<div class="input-group">
|
<div class="input-group">
|
||||||
<input type="file" class="form-control" name="extension" id="extension" required
|
<input type="file" class="form-control" name="extension" id="extension" required
|
||||||
accept=".bz2,.bzip2,.gz,.gzip,.tar,.tbz2,.tgz,.zip"
|
accept=".bz2,.bzip2,.gz,.gzip,.tar,.tbz2,.tgz,.zip"
|
||||||
aria-describedby="extension-upload" aria-label="<?php echo JText::_('COM_JEDCHECKER_UPLOAD_FILE'); ?>">
|
aria-describedby="extension-upload" aria-label="<?php echo Text::_('COM_JEDCHECKER_UPLOAD_FILE'); ?>">
|
||||||
<button class="btn btn-success" type="button" id="extension-upload">
|
<button class="btn btn-success" type="button" id="extension-upload">
|
||||||
<span class="icon-upload "></span> <?php echo JText::_('JSUBMIT'); ?>
|
<span class="icon-upload "></span> <?php echo Text::_('JSUBMIT'); ?>
|
||||||
</button>
|
</button>
|
||||||
<div class="invalid-feedback"><?php echo JText::_('COM_JEDCHECKER_EMPTY_UPLOAD_FIELD'); ?></div>
|
<div class="invalid-feedback"><?php echo Text::_('COM_JEDCHECKER_EMPTY_UPLOAD_FIELD'); ?></div>
|
||||||
</div>
|
</div>
|
||||||
<div id="jed_uploading_spinner" class="text-center text-info mt-3 hidden"><span class="spinner spinner-border"></span></div>
|
<div id="jed_uploading_spinner" class="text-center text-info mt-3 hidden"><span class="spinner spinner-border"></span></div>
|
||||||
<input type="hidden" name="task" value=""/>
|
<input type="hidden" name="task" value=""/>
|
||||||
<?php echo JHtml::_('form.token'); ?>
|
<?php echo HTMLHelper::_('form.token'); ?>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -74,13 +78,13 @@ JHtml::_('script', 'com_jedchecker/script.js', array('version' => 'auto', 'relat
|
|||||||
<div class="col-6 col-md-4">
|
<div class="col-6 col-md-4">
|
||||||
<div class="card bg-info">
|
<div class="card bg-info">
|
||||||
<div class="card-header text-white bg-info" data-bs-toggle="collapse" data-bs-target="#jedchecker-contributors" role="button">
|
<div class="card-header text-white bg-info" data-bs-toggle="collapse" data-bs-target="#jedchecker-contributors" role="button">
|
||||||
<?php echo JText::_('COM_JEDCHECKER_WALL_OF_HONOR'); ?>
|
<?php echo Text::_('COM_JEDCHECKER_WALL_OF_HONOR'); ?>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body show" id="jedchecker-contributors">
|
<div class="card-body show" id="jedchecker-contributors">
|
||||||
<h5 class="card-title text-white"><?php echo JText::_('COM_JEDCHECKER_PEOPLE_THAT_HAVE_HELPED_WITH_THE_DEVELOPMENT'); ?></h5>
|
<h5 class="card-title text-white"><?php echo Text::_('COM_JEDCHECKER_PEOPLE_THAT_HAVE_HELPED_WITH_THE_DEVELOPMENT'); ?></h5>
|
||||||
<p class="card-text">
|
<p class="card-text">
|
||||||
<a href="https://github.com/joomla-extensions/jedchecker/graphs/contributors" target="_blank" class="btn btn-light">
|
<a href="https://github.com/joomla-extensions/jedchecker/graphs/contributors" target="_blank" class="btn btn-light">
|
||||||
<?php echo JText::_('COM_JEDCHECKER_CONTRIBUTORS'); ?></a>
|
<?php echo Text::_('COM_JEDCHECKER_CONTRIBUTORS'); ?></a>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -88,7 +92,7 @@ JHtml::_('script', 'com_jedchecker/script.js', array('version' => 'auto', 'relat
|
|||||||
|
|
||||||
<div class="col-12 col-md-3 jedchecker-results hidden">
|
<div class="col-12 col-md-3 jedchecker-results hidden">
|
||||||
<div class="card bg-light">
|
<div class="card bg-light">
|
||||||
<div class="card-header"><?php echo JText::_('COM_JEDCHECKER_RESULTS'); ?></div>
|
<div class="card-header"><?php echo Text::_('COM_JEDCHECKER_RESULTS'); ?></div>
|
||||||
<div role="tablist" class="list-group list-group-flush">
|
<div role="tablist" class="list-group list-group-flush">
|
||||||
<?php
|
<?php
|
||||||
foreach ($this->jsOptions['rules'] as $i => $rulename)
|
foreach ($this->jsOptions['rules'] as $i => $rulename)
|
||||||
@ -98,7 +102,7 @@ JHtml::_('script', 'com_jedchecker/script.js', array('version' => 'auto', 'relat
|
|||||||
?>
|
?>
|
||||||
<a role="tab" id="jed-<?php echo $rulename; ?>" data-bs-toggle="tab" href="#jedtab-<?php echo $rulename; ?>"
|
<a role="tab" id="jed-<?php echo $rulename; ?>" data-bs-toggle="tab" href="#jedtab-<?php echo $rulename; ?>"
|
||||||
class="list-group-item list-group-item-action d-flex justify-content-between<?php echo $i === 0 ? ' active' : ''; ?>">
|
class="list-group-item list-group-item-action d-flex justify-content-between<?php echo $i === 0 ? ' active' : ''; ?>">
|
||||||
<?php echo JText::_($rule->get('title')); ?>
|
<?php echo Text::_($rule->get('title')); ?>
|
||||||
<span class="text-nowrap ps-1">
|
<span class="text-nowrap ps-1">
|
||||||
<span class="badge bg-danger rounded-pill border-error"></span>
|
<span class="badge bg-danger rounded-pill border-error"></span>
|
||||||
<span class="badge bg-warning rounded-pill"></span>
|
<span class="badge bg-warning rounded-pill"></span>
|
||||||
@ -115,8 +119,8 @@ JHtml::_('script', 'com_jedchecker/script.js', array('version' => 'auto', 'relat
|
|||||||
<div class="card-text" id="police-check-result"></div>
|
<div class="card-text" id="police-check-result"></div>
|
||||||
<div class="card-footer">
|
<div class="card-footer">
|
||||||
<small class="text-muted">
|
<small class="text-muted">
|
||||||
<?php echo JText::sprintf('COM_JEDCHECKER_LEAVE_A_REVIEW_JED', 'https://extensions.joomla.org/extensions/tools/development-tools/21336'); ?>
|
<?php echo Text::sprintf('COM_JEDCHECKER_LEAVE_A_REVIEW_JED', 'https://extensions.joomla.org/extensions/tools/development-tools/21336'); ?>
|
||||||
<?php echo JText::sprintf('COM_JEDCHECKER_DEVELOPED_BY', 'https://github.com/joomla-extensions/jedchecker'); ?> :)
|
<?php echo Text::sprintf('COM_JEDCHECKER_DEVELOPED_BY', 'https://github.com/joomla-extensions/jedchecker'); ?> :)
|
||||||
</small>
|
</small>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -133,11 +137,11 @@ JHtml::_('script', 'com_jedchecker/script.js', array('version' => 'auto', 'relat
|
|||||||
<div role="tabpanel" class="tab-pane fade<?php echo $i === 0 ? ' show active' : ''; ?>" id="jedtab-<?php echo $rulename; ?>">
|
<div role="tabpanel" class="tab-pane fade<?php echo $i === 0 ? ' show active' : ''; ?>" id="jedtab-<?php echo $rulename; ?>">
|
||||||
<div class="card bg-light">
|
<div class="card bg-light">
|
||||||
<div class="card-header" id="heading<?php echo $rule->get('id'); ?>">
|
<div class="card-header" id="heading<?php echo $rule->get('id'); ?>">
|
||||||
<?php echo JText::_($rule->get('title')); ?>
|
<?php echo Text::_($rule->get('title')); ?>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<p class="card-text">
|
<p class="card-text">
|
||||||
<?php echo JText::_($rule->get('description')); ?>
|
<?php echo Text::_($rule->get('description')); ?>
|
||||||
</p>
|
</p>
|
||||||
<div class="card-text police-check-result" id="police-check-result-<?php echo $rulename; ?>">
|
<div class="card-text police-check-result" id="police-check-result-<?php echo $rulename; ?>">
|
||||||
<div class="text-center text-info"><span class="spinner-border"></span></div>
|
<div class="text-center text-info"><span class="spinner-border"></span></div>
|
||||||
|
@ -11,14 +11,20 @@
|
|||||||
|
|
||||||
defined('_JEXEC') or die('Restricted access');
|
defined('_JEXEC') or die('Restricted access');
|
||||||
|
|
||||||
jimport('joomla.application.component.viewlegacy');
|
use Joomla\CMS\Factory;
|
||||||
|
use Joomla\CMS\Filesystem\File;
|
||||||
|
use Joomla\CMS\Filesystem\Folder;
|
||||||
|
use Joomla\CMS\Language\Text;
|
||||||
|
use Joomla\CMS\MVC\View\HtmlView;
|
||||||
|
use Joomla\CMS\Toolbar\ToolbarHelper;
|
||||||
|
use Joomla\CMS\Uri\Uri;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class JedcheckerViewUploads
|
* Class JedcheckerViewUploads
|
||||||
*
|
*
|
||||||
* @since 1.0
|
* @since 1.0
|
||||||
*/
|
*/
|
||||||
class JedcheckerViewUploads extends JViewLegacy
|
class JedcheckerViewUploads extends HtmlView
|
||||||
{
|
{
|
||||||
/** @var string */
|
/** @var string */
|
||||||
protected $path;
|
protected $path;
|
||||||
@ -35,13 +41,13 @@ class JedcheckerViewUploads extends JViewLegacy
|
|||||||
*/
|
*/
|
||||||
public function display($tpl = null)
|
public function display($tpl = null)
|
||||||
{
|
{
|
||||||
$this->path = JFactory::getConfig()->get('tmp_path') . '/jed_checker';
|
$this->path = Factory::getConfig()->get('tmp_path') . '/jed_checker';
|
||||||
|
|
||||||
// Load translation for "JED Checker" title from sys.ini file
|
// Load translation for "JED Checker" title from sys.ini file
|
||||||
JFactory::getLanguage()->load('com_jedchecker.sys', JPATH_ADMINISTRATOR);
|
Factory::getLanguage()->load('com_jedchecker.sys', JPATH_ADMINISTRATOR);
|
||||||
|
|
||||||
$this->setToolbar();
|
$this->setToolbar();
|
||||||
$this->jsOptions['url'] = JUri::base();
|
$this->jsOptions['url'] = Uri::base();
|
||||||
$this->jsOptions['rules'] = $this->getRules();
|
$this->jsOptions['rules'] = $this->getRules();
|
||||||
parent::display($tpl);
|
parent::display($tpl);
|
||||||
}
|
}
|
||||||
@ -54,7 +60,7 @@ class JedcheckerViewUploads extends JViewLegacy
|
|||||||
public function getRules()
|
public function getRules()
|
||||||
{
|
{
|
||||||
$rules = array();
|
$rules = array();
|
||||||
$files = JFolder::files(JPATH_COMPONENT_ADMINISTRATOR . '/libraries/rules', '\.php$', false, false);
|
$files = Folder::files(JPATH_COMPONENT_ADMINISTRATOR . '/libraries/rules', '\.php$', false, false);
|
||||||
|
|
||||||
JLoader::discover('jedcheckerRules', JPATH_COMPONENT_ADMINISTRATOR . '/libraries/rules/');
|
JLoader::discover('jedcheckerRules', JPATH_COMPONENT_ADMINISTRATOR . '/libraries/rules/');
|
||||||
|
|
||||||
@ -84,19 +90,19 @@ class JedcheckerViewUploads extends JViewLegacy
|
|||||||
{
|
{
|
||||||
if ($this->filesExist('unzipped'))
|
if ($this->filesExist('unzipped'))
|
||||||
{
|
{
|
||||||
JToolbarHelper::custom('check', 'search', 'search', JText::_('COM_JEDCHECKER_TOOLBAR_CHECK'), false);
|
ToolbarHelper::custom('check', 'search', 'search', Text::_('COM_JEDCHECKER_TOOLBAR_CHECK'), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
JToolbarHelper::title(JText::_('COM_JEDCHECKER'));
|
ToolbarHelper::title(Text::_('COM_JEDCHECKER'));
|
||||||
|
|
||||||
if (file_exists($this->path))
|
if (file_exists($this->path))
|
||||||
{
|
{
|
||||||
JToolbarHelper::custom('uploads.clear', 'delete', 'delete', JText::_('COM_JEDCHECKER_TOOLBAR_CLEAR'), false);
|
ToolbarHelper::custom('uploads.clear', 'delete', 'delete', Text::_('COM_JEDCHECKER_TOOLBAR_CLEAR'), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (JFactory::getUser()->authorise('core.admin', 'com_jedchecker'))
|
if (Factory::getUser()->authorise('core.admin', 'com_jedchecker'))
|
||||||
{
|
{
|
||||||
JToolbarHelper::preferences('com_jedchecker');
|
ToolbarHelper::preferences('com_jedchecker');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,20 +115,20 @@ class JedcheckerViewUploads extends JViewLegacy
|
|||||||
*/
|
*/
|
||||||
private function filesExist($type)
|
private function filesExist($type)
|
||||||
{
|
{
|
||||||
$path = JFactory::getConfig()->get('tmp_path') . '/jed_checker/' . $type;
|
$path = Factory::getConfig()->get('tmp_path') . '/jed_checker/' . $type;
|
||||||
|
|
||||||
if (JFolder::exists($path))
|
if (Folder::exists($path))
|
||||||
{
|
{
|
||||||
if (JFolder::folders($path) || JFolder::files($path))
|
if (Folder::folders($path) || Folder::files($path))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$local = JFactory::getConfig()->get('tmp_path') . '/jed_checker/local.txt';
|
$local = Factory::getConfig()->get('tmp_path') . '/jed_checker/local.txt';
|
||||||
|
|
||||||
if ($type === 'unzipped' && JFile::exists($local))
|
if ($type === 'unzipped' && File::exists($local))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
34
script.php
34
script.php
@ -11,6 +11,12 @@
|
|||||||
|
|
||||||
defined('_JEXEC') or die('Restricted access');
|
defined('_JEXEC') or die('Restricted access');
|
||||||
|
|
||||||
|
use Joomla\CMS\Factory;
|
||||||
|
use Joomla\CMS\Filesystem\File;
|
||||||
|
use Joomla\CMS\Installer\Adapter\ComponentAdapter;
|
||||||
|
use Joomla\CMS\Language\Text;
|
||||||
|
use Joomla\CMS\Log\Log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Com_JedcheckerInstallerScript
|
* Class Com_JedcheckerInstallerScript
|
||||||
*
|
*
|
||||||
@ -20,14 +26,14 @@ class Com_JedcheckerInstallerScript
|
|||||||
{
|
{
|
||||||
protected $extension = 'com_jedchecker';
|
protected $extension = 'com_jedchecker';
|
||||||
protected $min_php = '5.6.0';
|
protected $min_php = '5.6.0';
|
||||||
protected $min_joomla = '3.7.0';
|
protected $min_joomla = '3.8.0';
|
||||||
protected $parent;
|
protected $parent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function executed before the the installation
|
* Function executed before the the installation
|
||||||
*
|
*
|
||||||
* @param string $type - the installation type
|
* @param string $type - the installation type
|
||||||
* @param JInstallerComponent $parent - the parent class
|
* @param ComponentAdapter $parent - the parent class
|
||||||
*/
|
*/
|
||||||
public function preflight($type, $parent)
|
public function preflight($type, $parent)
|
||||||
{
|
{
|
||||||
@ -37,8 +43,8 @@ class Com_JedcheckerInstallerScript
|
|||||||
{
|
{
|
||||||
$this->loadLanguage();
|
$this->loadLanguage();
|
||||||
|
|
||||||
$msg = JText::sprintf('COM_JEDCHECKER_PHP_VERSION_INCOMPATIBLE', PHP_VERSION, $this->min_php);
|
$msg = Text::sprintf('COM_JEDCHECKER_PHP_VERSION_INCOMPATIBLE', PHP_VERSION, $this->min_php);
|
||||||
JLog::add($msg, JLog::WARNING, 'jerror');
|
Log::add($msg, Log::WARNING, 'jerror');
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -47,8 +53,8 @@ class Com_JedcheckerInstallerScript
|
|||||||
{
|
{
|
||||||
$this->loadLanguage();
|
$this->loadLanguage();
|
||||||
|
|
||||||
$msg = JText::sprintf('COM_JEDCHECKER_JOOMLA_VERSION_INCOMPATIBLE', JVERSION, $this->min_joomla);
|
$msg = Text::sprintf('COM_JEDCHECKER_JOOMLA_VERSION_INCOMPATIBLE', JVERSION, $this->min_joomla);
|
||||||
JLog::add($msg, JLog::WARNING, 'jerror');
|
Log::add($msg, Log::WARNING, 'jerror');
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -57,7 +63,7 @@ class Com_JedcheckerInstallerScript
|
|||||||
/**
|
/**
|
||||||
* Update cleans out any old rules.
|
* Update cleans out any old rules.
|
||||||
*
|
*
|
||||||
* @param JInstallerComponent $parent Is the class calling this method.
|
* @param ComponentAdapter $parent Is the class calling this method.
|
||||||
*
|
*
|
||||||
* @return bool|null If this returns false, Joomla will abort the update and undo everything already done.
|
* @return bool|null If this returns false, Joomla will abort the update and undo everything already done.
|
||||||
*/
|
*/
|
||||||
@ -76,13 +82,13 @@ class Com_JedcheckerInstallerScript
|
|||||||
// Remove the rule's php file
|
// Remove the rule's php file
|
||||||
if (file_exists($rulePhpFile))
|
if (file_exists($rulePhpFile))
|
||||||
{
|
{
|
||||||
if (JFile::delete($rulePhpFile))
|
if (File::delete($rulePhpFile))
|
||||||
{
|
{
|
||||||
$msg = JText::sprintf('COM_JEDCHECKER_OLD_RULE_X_PHP_FILE_REMOVED', $rule);
|
$msg = Text::sprintf('COM_JEDCHECKER_OLD_RULE_X_PHP_FILE_REMOVED', $rule);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$msg = JText::sprintf('COM_JEDCHECKER_OLD_RULE_X_PHP_FILE_NOT_REMOVED', $rule);
|
$msg = Text::sprintf('COM_JEDCHECKER_OLD_RULE_X_PHP_FILE_NOT_REMOVED', $rule);
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "<p>$msg</p>";
|
echo "<p>$msg</p>";
|
||||||
@ -91,13 +97,13 @@ class Com_JedcheckerInstallerScript
|
|||||||
// Remove the rule's ini file
|
// Remove the rule's ini file
|
||||||
if (file_exists($ruleIniFile))
|
if (file_exists($ruleIniFile))
|
||||||
{
|
{
|
||||||
if (JFile::delete($ruleIniFile))
|
if (File::delete($ruleIniFile))
|
||||||
{
|
{
|
||||||
$msg = JText::sprintf('COM_JEDCHECKER_OLD_RULE_X_INI_FILE_REMOVED', $rule);
|
$msg = Text::sprintf('COM_JEDCHECKER_OLD_RULE_X_INI_FILE_REMOVED', $rule);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$msg = JText::sprintf('COM_JEDCHECKER_OLD_RULE_X_INI_FILE_NOT_REMOVED', $rule);
|
$msg = Text::sprintf('COM_JEDCHECKER_OLD_RULE_X_INI_FILE_NOT_REMOVED', $rule);
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "<p>$msg</p>";
|
echo "<p>$msg</p>";
|
||||||
@ -113,7 +119,7 @@ class Com_JedcheckerInstallerScript
|
|||||||
public function loadLanguage()
|
public function loadLanguage()
|
||||||
{
|
{
|
||||||
$extension = $this->extension;
|
$extension = $this->extension;
|
||||||
$jlang = JFactory::getLanguage();
|
$jlang = Factory::getLanguage();
|
||||||
$path = $this->parent->getParent()->getPath('source') . '/administrator/components/' . $extension;
|
$path = $this->parent->getParent()->getPath('source') . '/administrator/components/' . $extension;
|
||||||
$jlang->load($extension, $path, 'en-GB', true);
|
$jlang->load($extension, $path, 'en-GB', true);
|
||||||
$jlang->load($extension, $path, $jlang->getDefault(), true);
|
$jlang->load($extension, $path, $jlang->getDefault(), true);
|
||||||
|
Loading…
Reference in New Issue
Block a user