diff --git a/administrator/components/com_jedchecker/controller.php b/administrator/components/com_jedchecker/controller.php index 3d61ac6..809c44f 100644 --- a/administrator/components/com_jedchecker/controller.php +++ b/administrator/components/com_jedchecker/controller.php @@ -12,11 +12,13 @@ defined('_JEXEC') or die('Restricted access'); +use Joomla\CMS\MVC\Controller\BaseController; + /** * Class JedcheckerController * * @since 1.0 */ -class JedcheckerController extends JControllerLegacy +class JedcheckerController extends BaseController { } diff --git a/administrator/components/com_jedchecker/controllers/police.raw.php b/administrator/components/com_jedchecker/controllers/police.raw.php index fc57db5..a8f31ad 100644 --- a/administrator/components/com_jedchecker/controllers/police.raw.php +++ b/administrator/components/com_jedchecker/controllers/police.raw.php @@ -11,17 +11,18 @@ defined('_JEXEC') or die('Restricted access'); - -jimport('joomla.filesystem'); -jimport('joomla.filesystem.folder'); -jimport('joomla.filesystem.archive'); +use Joomla\CMS\Factory; +use Joomla\CMS\Filesystem\File; +use Joomla\CMS\Filesystem\Folder; +use Joomla\CMS\Filesystem\Path; +use Joomla\CMS\MVC\Controller\BaseController; /** * Class jedcheckerControllerPolice * * @since 1.0 */ -class JedcheckerControllerPolice extends JControllerLegacy +class JedcheckerControllerPolice extends BaseController { /** * Runs all the rules on the given directory @@ -30,11 +31,11 @@ class JedcheckerControllerPolice extends JControllerLegacy */ public function check() { - $rule = JFactory::getApplication()->input->get('rule'); + $rule = Factory::getApplication()->input->get('rule'); 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); // Stop if the class does not exist @@ -65,7 +66,7 @@ class JedcheckerControllerPolice extends JControllerLegacy protected function police($class, $folder) { // Prepare rule properties - $properties = array('basedir' => JPath::clean($folder)); + $properties = array('basedir' => Path::clean($folder)); // Create instance of the rule $police = new $class($properties); @@ -89,8 +90,8 @@ class JedcheckerControllerPolice extends JControllerLegacy $folders = array(); // Add the folders in the "jed_checked/unzipped" folder - $path = JFactory::getConfig()->get('tmp_path') . '/jed_checker/unzipped'; - $tmp_folders = JFolder::folders($path); + $path = Factory::getConfig()->get('tmp_path') . '/jed_checker/unzipped'; + $tmp_folders = Folder::folders($path); if (!empty($tmp_folders)) { @@ -101,9 +102,9 @@ class JedcheckerControllerPolice extends JControllerLegacy } // 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); @@ -119,11 +120,11 @@ class JedcheckerControllerPolice extends JControllerLegacy if (!empty($line)) { - if (JFolder::exists(JPATH_ROOT . '/' . $line)) + if (Folder::exists(JPATH_ROOT . '/' . $line)) { $folders[] = JPATH_ROOT . '/' . $line; } - elseif (JFolder::exists($line)) + elseif (Folder::exists($line)) { $folders[] = $line; } diff --git a/administrator/components/com_jedchecker/controllers/uploads.php b/administrator/components/com_jedchecker/controllers/uploads.php index 8cb7474..7a1c979 100644 --- a/administrator/components/com_jedchecker/controllers/uploads.php +++ b/administrator/components/com_jedchecker/controllers/uploads.php @@ -12,18 +12,20 @@ defined('_JEXEC') or die('Restricted access'); -jimport('joomla.filesystem'); -jimport('joomla.filesystem.folder'); -jimport('joomla.filesystem.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 * * @since 1.0 */ -class JedcheckerControllerUploads extends JControllerLegacy +class JedcheckerControllerUploads extends BaseController { /** @var string */ public $path; @@ -40,7 +42,7 @@ class JedcheckerControllerUploads extends JControllerLegacy */ 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->pathUnzipped = $this->path . '/unzipped'; parent::__construct(); @@ -53,11 +55,11 @@ class JedcheckerControllerUploads extends JControllerLegacy */ public function upload() { - $appl = JFactory::getApplication(); + $appl = Factory::getApplication(); $input = $appl->input; // 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 $file = $input->files->get('extension', null, 'raw'); @@ -67,18 +69,18 @@ class JedcheckerControllerUploads extends JControllerLegacy $path = $this->pathArchive; // If the archive folder doesn't exist - create it! - if (!JFolder::exists($path)) + if (!Folder::exists($path)) { - JFolder::create($path); + Folder::create($path); } else { // Let us remove all previous uploads - $archiveFiles = JFolder::files($path); + $archiveFiles = Folder::files($path); foreach ($archiveFiles as $archive) { - if (!JFile::delete($this->pathArchive . '/' . $archive)) + if (!File::delete($this->pathArchive . '/' . $archive)) { echo 'could not delete' . $archive; } @@ -88,10 +90,10 @@ class JedcheckerControllerUploads extends JControllerLegacy $file['filepath'] = $path . '/' . strtolower($file['name']); // 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 - $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'); return false; @@ -119,28 +121,28 @@ class JedcheckerControllerUploads extends JControllerLegacy */ public function unzip() { - $appl = JFactory::getApplication(); + $appl = Factory::getApplication(); // 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 (!JFolder::exists($this->pathUnzipped)) + if (!Folder::exists($this->pathUnzipped)) { - JFolder::create($this->pathUnzipped); + Folder::create($this->pathUnzipped); } else { // Let us remove all previous unzipped files - $folders = JFolder::folders($this->pathUnzipped); + $folders = Folder::folders($this->pathUnzipped); 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]; $destination = $this->pathUnzipped . DIRECTORY_SEPARATOR . $file[0]; @@ -150,7 +152,7 @@ class JedcheckerControllerUploads extends JControllerLegacy $archive = new Archive; $result = $archive->extract($origin, $destination); } - catch (\Exception $e) + catch (Exception $e) { $result = false; } @@ -160,14 +162,14 @@ class JedcheckerControllerUploads extends JControllerLegacy // Scan unzipped folders if we find zip file -> unzip them as well $this->unzipAll($this->pathUnzipped . '/' . $file[0]); $message = 'COM_JEDCHECKER_UNZIP_SUCCESS'; - $appl->enqueueMessage(JText::_($message)); + $appl->enqueueMessage(Text::_($message)); } else { $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'; return $message; @@ -197,7 +199,7 @@ class JedcheckerControllerUploads extends JControllerLegacy $archive = new Archive; $result = $archive->extract($file->getPathname(), $unzip); } - catch (\Exception $e) + catch (Exception $e) { $result = false; } @@ -205,7 +207,7 @@ class JedcheckerControllerUploads extends JControllerLegacy // Delete the archive once we extract it if ($result) { - JFile::delete($file->getPathname()); + File::delete($file->getPathname()); // Now check the new extracted folder for archive files $this->unzipAll($unzip); @@ -228,7 +230,7 @@ class JedcheckerControllerUploads extends JControllerLegacy { if (file_exists($this->path)) { - $result = JFolder::delete($this->path); + $result = Folder::delete($this->path); if (!$result) { @@ -238,7 +240,7 @@ class JedcheckerControllerUploads extends JControllerLegacy $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'); } } diff --git a/administrator/components/com_jedchecker/jedchecker.php b/administrator/components/com_jedchecker/jedchecker.php index bf7db9c..f177630 100644 --- a/administrator/components/com_jedchecker/jedchecker.php +++ b/administrator/components/com_jedchecker/jedchecker.php @@ -11,18 +11,17 @@ */ 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 -jimport('joomla.filesystem.folder'); -jimport('joomla.filesystem.file'); - -$input = JFactory::getApplication()->input; +$input = Factory::getApplication()->input; $view = $input->getCmd('view', ''); if ($view === '' && $input->getCmd('task', '') === '') @@ -30,6 +29,6 @@ if ($view === '' && $input->getCmd('task', '') === '') $input->set('view', 'uploads'); } -$controller = JControllerLegacy::getInstance('jedchecker'); +$controller = BaseController::getInstance('jedchecker'); $controller->execute($input->getCmd('task', '')); $controller->redirect(); diff --git a/administrator/components/com_jedchecker/libraries/helper.php b/administrator/components/com_jedchecker/libraries/helper.php index b4a50f1..d4df50e 100644 --- a/administrator/components/com_jedchecker/libraries/helper.php +++ b/administrator/components/com_jedchecker/libraries/helper.php @@ -9,6 +9,8 @@ defined('_JEXEC') or die('Restricted access'); +use Joomla\CMS\Filesystem\Folder; +use Joomla\CMS\Filter\InputFilter; /** * class JedcheckerHelper @@ -34,7 +36,7 @@ abstract class JEDCheckerHelper public static function findManifests($basedir) { // Find all XML files of the extension - $files = JFolder::files($basedir, '\.xml$', true, true); + $files = Folder::files($basedir, '\.xml$', true, true); $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) { diff --git a/administrator/components/com_jedchecker/libraries/rules/encoding.php b/administrator/components/com_jedchecker/libraries/rules/encoding.php index 68c5501..d8b46bd 100644 --- a/administrator/components/com_jedchecker/libraries/rules/encoding.php +++ b/administrator/components/com_jedchecker/libraries/rules/encoding.php @@ -12,6 +12,9 @@ defined('_JEXEC') or die('Restricted access'); +use Joomla\CMS\Filesystem\Folder; +use Joomla\CMS\Language\Text; + // Include the rule base class require_once JPATH_COMPONENT_ADMINISTRATOR . '/models/rule.php'; @@ -81,7 +84,7 @@ class JedcheckerRulesEncoding extends JEDcheckerRule $this->encodingsRegex = '/' . implode('|', $encodings) . '/i'; // 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 foreach ($files as $file) @@ -121,7 +124,7 @@ class JedcheckerRulesEncoding extends JEDcheckerRule if (preg_match($this->encodingsRegex, $line)) { $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]); } } diff --git a/administrator/components/com_jedchecker/libraries/rules/errorreporting.php b/administrator/components/com_jedchecker/libraries/rules/errorreporting.php index f3f9f0f..c73f799 100644 --- a/administrator/components/com_jedchecker/libraries/rules/errorreporting.php +++ b/administrator/components/com_jedchecker/libraries/rules/errorreporting.php @@ -11,6 +11,9 @@ defined('_JEXEC') or die('Restricted access'); +use Joomla\CMS\Filesystem\Folder; +use Joomla\CMS\Language\Text; + // Include the rule base class require_once JPATH_COMPONENT_ADMINISTRATOR . '/models/rule.php'; @@ -82,7 +85,7 @@ class JedcheckerRulesErrorreporting extends JEDcheckerRule $this->errorreportingRegex = '/' . implode('|', $codes) . '/i'; // 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 foreach ($files as $file) @@ -122,7 +125,7 @@ class JedcheckerRulesErrorreporting extends JEDcheckerRule if (preg_match($this->errorreportingRegex, $line)) { $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]); } } diff --git a/administrator/components/com_jedchecker/libraries/rules/framework.php b/administrator/components/com_jedchecker/libraries/rules/framework.php index 002184c..a60d12a 100644 --- a/administrator/components/com_jedchecker/libraries/rules/framework.php +++ b/administrator/components/com_jedchecker/libraries/rules/framework.php @@ -11,6 +11,9 @@ defined('_JEXEC') or die('Restricted access'); +use Joomla\CMS\Filesystem\Folder; +use Joomla\CMS\Language\Text; + // Include the rule base class require_once JPATH_COMPONENT_ADMINISTRATOR . '/models/rule.php'; @@ -83,15 +86,15 @@ class JedcheckerRulesFramework extends JEDcheckerRule $regexLeftoverFolders = '^' . $this->regexLeftoverFolders . '$'; // Get matched files and folder (w/o default exclusion list) - $folders = JFolder::folders($this->basedir, $regexLeftoverFolders, true, true, array(), array()); - $files = JFolder::files($this->basedir, $regexLeftoverFolders, true, true, array(), array()); + $folders = Folder::folders($this->basedir, $regexLeftoverFolders, true, true, array(), array()); + $files = Folder::files($this->basedir, $regexLeftoverFolders, true, true, array(), array()); if ($folders !== false) { // Warn on leftover folders found 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 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) { @@ -154,14 +157,14 @@ class JedcheckerRulesFramework extends JEDcheckerRule // Check BOM 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; } // Report spaces/tabs/EOLs at the beginning of file 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; } @@ -176,7 +179,7 @@ class JedcheckerRulesFramework extends JEDcheckerRule if (preg_match('/<\?\s/', $content, $match, PREG_OFFSET_CAPTURE)) { $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; } @@ -230,7 +233,7 @@ class JedcheckerRulesFramework extends JEDcheckerRule if (preg_match('/' . $regex . '/i', $line)) { $origLine = str_ireplace($singleTest, '' . $singleTest . '', htmlspecialchars($origLine)); - $error_message = JText::_('COM_JEDCHECKER_ERROR_FRAMEWORK_' . strtoupper($testObject->group)) . ':
' . $origLine . ''; + $error_message = Text::_('COM_JEDCHECKER_ERROR_FRAMEWORK_' . strtoupper($testObject->group)) . ':
' . $origLine . ''; switch ($testObject->kind) { diff --git a/administrator/components/com_jedchecker/libraries/rules/gpl.php b/administrator/components/com_jedchecker/libraries/rules/gpl.php index 6768abc..7b069dd 100644 --- a/administrator/components/com_jedchecker/libraries/rules/gpl.php +++ b/administrator/components/com_jedchecker/libraries/rules/gpl.php @@ -11,6 +11,8 @@ defined('_JEXEC') or die('Restricted access'); +use Joomla\CMS\Filesystem\Folder; +use Joomla\CMS\Language\Text; // Include the rule base class require_once JPATH_COMPONENT_ADMINISTRATOR . '/models/rule.php'; @@ -80,7 +82,7 @@ class JedcheckerRulesGpl extends JEDcheckerRule $this->init(); // 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 foreach ($files as $file) @@ -89,7 +91,7 @@ class JedcheckerRulesGpl extends JEDcheckerRule if (!$this->find($file)) { // 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; $this->report->addPassed( $file, - JText::_('COM_JEDCHECKER_PH1_LICENSE_FOUND'), + Text::_('COM_JEDCHECKER_PH1_LICENSE_FOUND'), $lineno, $match[0][0] ); @@ -227,7 +229,7 @@ class JedcheckerRulesGpl extends JEDcheckerRule $lineno = substr_count($content, "\n", 0, $match[0][1]) + 1; $this->report->addWarning( $file, - JText::_('COM_JEDCHECKER_GPL_COMPATIBLE_LICENSE_WAS_FOUND'), + Text::_('COM_JEDCHECKER_GPL_COMPATIBLE_LICENSE_WAS_FOUND'), $lineno, $match[0][0] ); diff --git a/administrator/components/com_jedchecker/libraries/rules/jamss.php b/administrator/components/com_jedchecker/libraries/rules/jamss.php index cb19ce7..d0e39c7 100644 --- a/administrator/components/com_jedchecker/libraries/rules/jamss.php +++ b/administrator/components/com_jedchecker/libraries/rules/jamss.php @@ -12,6 +12,9 @@ defined('_JEXEC') or die('Restricted access'); +use Joomla\CMS\Filesystem\Folder; +use Joomla\CMS\Language\Text; + // Include the rule base class require_once JPATH_COMPONENT_ADMINISTRATOR . '/models/rule.php'; @@ -67,7 +70,7 @@ class JedcheckerRulesJamss extends JEDcheckerRule */ public function check() { - $files = JFolder::files($this->basedir, '', true, true); + $files = Folder::files($this->basedir, '', true, true); $this->init_jamss(); @@ -328,12 +331,12 @@ class JedcheckerRulesJamss extends JEDcheckerRule { 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))) { - $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; } @@ -413,7 +416,7 @@ class JedcheckerRulesJamss extends JEDcheckerRule // Then it has some additional comments $this->jamssWarning( $path, - JText::_('COM_JEDCHECKER_ERROR_JAMSS_PATTERN') . "#$pattern[2] - $pattern[1]", + Text::_('COM_JEDCHECKER_ERROR_JAMSS_PATTERN') . "#$pattern[2] - $pattern[1]", $pattern[3], $first_code, $first_line @@ -424,7 +427,7 @@ class JedcheckerRulesJamss extends JEDcheckerRule // It's a string, no comments available $this->jamssWarning( $path, - JText::_('COM_JEDCHECKER_ERROR_JAMSS_STRING') . $pattern, + Text::_('COM_JEDCHECKER_ERROR_JAMSS_STRING') . $pattern, '', $first_code, $first_line diff --git a/administrator/components/com_jedchecker/libraries/rules/jexec.php b/administrator/components/com_jedchecker/libraries/rules/jexec.php index 00e9fe2..44edc5f 100644 --- a/administrator/components/com_jedchecker/libraries/rules/jexec.php +++ b/administrator/components/com_jedchecker/libraries/rules/jexec.php @@ -12,6 +12,8 @@ defined('_JEXEC') or die('Restricted access'); +use Joomla\CMS\Language\Text; + // Include the rule base class require_once JPATH_COMPONENT_ADMINISTRATOR . '/models/rule.php'; @@ -95,7 +97,7 @@ class JedcheckerRulesJexec extends JEDcheckerRule if (!$this->find($file)) { // 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')); } } } diff --git a/administrator/components/com_jedchecker/libraries/rules/language.php b/administrator/components/com_jedchecker/libraries/rules/language.php index 09a0b8e..5437f04 100644 --- a/administrator/components/com_jedchecker/libraries/rules/language.php +++ b/administrator/components/com_jedchecker/libraries/rules/language.php @@ -9,6 +9,8 @@ defined('_JEXEC') or die('Restricted access'); +use Joomla\CMS\Filesystem\Folder; +use Joomla\CMS\Language\Text; // Include the rule base class require_once JPATH_COMPONENT_ADMINISTRATOR . '/models/rule.php'; @@ -66,7 +68,7 @@ class JedcheckerRulesLanguage extends JEDcheckerRule public function check() { // 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 foreach ($files as $file) @@ -99,7 +101,7 @@ class JedcheckerRulesLanguage extends JEDcheckerRule } // Check JText usage - $files = JFolder::files($this->basedir, '\.php$', true, true); + $files = Folder::files($this->basedir, '\.php$', true, true); foreach ($files as $file) { @@ -127,7 +129,7 @@ class JedcheckerRulesLanguage extends JEDcheckerRule // Check EOL format is \n (not \r or \n\r) 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); @@ -151,7 +153,7 @@ class JedcheckerRulesLanguage extends JEDcheckerRule // Check for BOM sequence 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 $line = substr($line, 3); @@ -166,14 +168,14 @@ class JedcheckerRulesLanguage extends JEDcheckerRule // Report incorrect comment character 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; } // Check for "=" character in the line 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; } @@ -186,47 +188,47 @@ class JedcheckerRulesLanguage extends JEDcheckerRule // Check for empty 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; } // Check for spaces in the key name 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; } // Check for invalid characters (see https://www.php.net/manual/en/function.parse-ini-file.php) 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; } // 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)) { - $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; } // Check key contains ASCII characters only 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 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 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 { @@ -253,7 +255,7 @@ class JedcheckerRulesLanguage extends JEDcheckerRule // The value doesn't match INI format 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; } @@ -263,7 +265,7 @@ class JedcheckerRulesLanguage extends JEDcheckerRule // Check for empty 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; } @@ -272,26 +274,26 @@ class JedcheckerRulesLanguage extends JEDcheckerRule 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 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; } 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); continue; } 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); 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) if (strpos($value, '"_QQ_"') !== false) { - $this->report->addCompat($file, JText::sprintf('COM_JEDCHECKER_LANG_QQDEPRECATED', '
"_QQ_"
', '\\"
'), $startLineno, $line);
+ $this->report->addCompat($file, Text::sprintf('COM_JEDCHECKER_LANG_QQDEPRECATED', '"_QQ_"
', '\\"
'), $startLineno, $line);
}
// Convert "_QQ_" to escaped quotes for further analysis
@@ -311,13 +313,13 @@ class JedcheckerRulesLanguage extends JEDcheckerRule
// Check for unescaped quote
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)
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")
@@ -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 ($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)
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]))
{
$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]);
}
}
diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlfiles.php b/administrator/components/com_jedchecker/libraries/rules/xmlfiles.php
index 5125de8..71d0e73 100644
--- a/administrator/components/com_jedchecker/libraries/rules/xmlfiles.php
+++ b/administrator/components/com_jedchecker/libraries/rules/xmlfiles.php
@@ -9,6 +9,7 @@
defined('_JEXEC') or die('Restricted access');
+use Joomla\CMS\Language\Text;
// Include the rule base class
require_once JPATH_COMPONENT_ADMINISTRATOR . '/models/rule.php';
@@ -304,7 +305,7 @@ class JedcheckerRulesXMLFiles extends JEDcheckerRule
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))
{
- $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 . '/';
}
- $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 '';
}
@@ -380,7 +381,7 @@ class JedcheckerRulesXMLFiles extends JEDcheckerRule
$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;
}
- $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))
{
- $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);
}
}
}
diff --git a/administrator/components/com_jedchecker/libraries/rules/xmlinfo.php b/administrator/components/com_jedchecker/libraries/rules/xmlinfo.php
index f719f32..1cb0570 100644
--- a/administrator/components/com_jedchecker/libraries/rules/xmlinfo.php
+++ b/administrator/components/com_jedchecker/libraries/rules/xmlinfo.php
@@ -12,6 +12,8 @@
defined('_JEXEC') or die('Restricted access');
+use Joomla\CMS\Factory;
+use Joomla\CMS\Language\Text;
// Include the rule base class
require_once JPATH_COMPONENT_ADMINISTRATOR . '/models/rule.php';
@@ -109,7 +111,7 @@ class JedcheckerRulesXMLinfo extends JEDcheckerRule
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'
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')
@@ -151,12 +153,12 @@ class JedcheckerRulesXMLinfo extends JEDcheckerRule
$this->loadExtensionLanguage($xml, dirname($file));
// Get the real extension's name now that the language has been loaded
- $lang = JFactory::getLanguage();
+ $lang = Factory::getLanguage();
$extensionName = $lang->_((string) $xml->name);
- $info[] = JText::sprintf('COM_JEDCHECKER_INFO_XML_NAME_XML', $extensionName);
- $info[] = JText::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_NAME_XML', $extensionName);
+ $info[] = Text::sprintf('COM_JEDCHECKER_INFO_XML_VERSION_XML', (string) $xml->version);
+ $info[] = Text::sprintf('COM_JEDCHECKER_INFO_XML_CREATIONDATE_XML', (string) $xml->creationDate);
$this->report->addInfo($file, implode('- +
- +
- +
- +