Skip to content

Commit

Permalink
add check for intl and moderise code and remove deprecated calls
Browse files Browse the repository at this point in the history
  • Loading branch information
Phil E. Taylor committed Apr 30, 2021
1 parent 6f98135 commit 157e0bf
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 32 deletions.
65 changes: 33 additions & 32 deletions administrator/components/com_admin/src/Model/SysinfoModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,23 @@ class SysinfoModel extends BaseDatabaseModel
* @var array
* @since 1.6
*/
protected $php_settings = array();
protected $php_settings = [];

/**
* Config values
*
* @var array
* @since 1.6
*/
protected $config = array();
protected $config = [];

/**
* Some system values
*
* @var array
* @since 1.6
*/
protected $info = array();
protected $info = [];

/**
* PHP info
Expand All @@ -74,8 +74,8 @@ class SysinfoModel extends BaseDatabaseModel
*
* @since 3.5
*/
protected $privateSettings = array(
'phpInfoArray' => array(
protected $privateSettings = [
'phpInfoArray' => [
'CONTEXT_DOCUMENT_ROOT',
'Cookie',
'DOCUMENT_ROOT',
Expand Down Expand Up @@ -111,8 +111,8 @@ class SysinfoModel extends BaseDatabaseModel
'upload_tmp_dir',
'User/Group',
'open_basedir',
),
'other' => array(
],
'other' => [
'db',
'dbprefix',
'fromname',
Expand All @@ -137,8 +137,8 @@ class SysinfoModel extends BaseDatabaseModel
'smtphost',
'tmp_path',
'open_basedir',
)
);
]
];

/**
* System values that can be "safely" shared
Expand All @@ -155,7 +155,7 @@ class SysinfoModel extends BaseDatabaseModel
* @var array
* @since 1.6
*/
protected $directories = array();
protected $directories = [];

/**
* The current editor.
Expand Down Expand Up @@ -188,12 +188,12 @@ protected function cleanPrivateData($dataArray, $dataType = 'other')

foreach ($dataArray as $section => $values)
{
if (is_array($values))
if (\is_array($values))
{
$dataArray[$section] = $this->cleanPrivateData($values, $dataType);
}

if (in_array($section, $privateSettings, true))
if (\in_array($section, $privateSettings, true))
{
$dataArray[$section] = $this->cleanSectionPrivateData($values);
}
Expand All @@ -213,7 +213,7 @@ protected function cleanPrivateData($dataArray, $dataType = 'other')
*/
protected function cleanSectionPrivateData($sectionValues)
{
if (!is_array($sectionValues))
if (!\is_array($sectionValues))
{
if (strstr($sectionValues, JPATH_ROOT))
{
Expand Down Expand Up @@ -245,7 +245,7 @@ public function &getPhpSettings()
return $this->php_settings;
}

$this->php_settings = array(
$this->php_settings = [
'memory_limit' => ini_get('memory_limit'),
'upload_max_filesize' => ini_get('upload_max_filesize'),
'post_max_size' => ini_get('post_max_size'),
Expand All @@ -262,8 +262,9 @@ public function &getPhpSettings()
'zip' => function_exists('zip_open') && function_exists('zip_read'),
'mbstring' => extension_loaded('mbstring'),
'iconv' => function_exists('iconv'),
'intl' => function_exists('transliterator_transliterate'),
'max_input_vars' => ini_get('max_input_vars'),
);
];

return $this->php_settings;
}
Expand All @@ -284,11 +285,11 @@ public function &getConfig()

$registry = new Registry(new \JConfig);
$this->config = $registry->toArray();
$hidden = array(
$hidden = [
'host', 'user', 'password', 'ftp_user', 'ftp_pass',
'smtpuser', 'smtppass', 'redis_server_auth', 'session_redis_server_auth',
'proxy_user', 'proxy_pass', 'secret'
);
];

foreach ($hidden as $key)
{
Expand All @@ -314,7 +315,7 @@ public function &getInfo()

$db = $this->getDbo();

$this->info = array(
$this->info = [
'php' => php_uname(),
'dbserver' => $db->getServerType(),
'dbversion' => $db->getVersion(),
Expand All @@ -327,7 +328,7 @@ public function &getInfo()
'sapi_name' => PHP_SAPI,
'version' => (new Version)->getLongVersion(),
'useragent' => $_SERVER['HTTP_USER_AGENT'] ?? '',
);
];

return $this->info;
}
Expand All @@ -341,7 +342,7 @@ public function &getInfo()
*/
public function phpinfoEnabled()
{
return !in_array('phpinfo', explode(',', ini_get('disable_functions')));
return !\in_array('phpinfo', explode(',', ini_get('disable_functions')));
}

/**
Expand All @@ -365,7 +366,7 @@ public function getSafeData($dataType, $public = true)

if (!method_exists($this, $methodName))
{
return array();
return [];
}

$data = $this->$methodName($public);
Expand Down Expand Up @@ -445,8 +446,8 @@ public function getPhpInfoArray()
*/
public function getExtensions()
{
$installed = array();
$db = Factory::getDbo();
$installed = [];
$db = Factory::getApplication()->getContainer()->get('DatabaseDriver');
$query = $db->getQuery(true)
->select('*')
->from($db->quoteName('#__extensions'));
Expand Down Expand Up @@ -485,24 +486,24 @@ public function getExtensions()
continue;
}

$installed[$extension->name] = array(
$installed[$extension->name] = [
'name' => $extension->name,
'type' => $extension->type,
'state' => $extension->enabled ? Text::_('JENABLED') : Text::_('JDISABLED'),
'author' => 'unknown',
'version' => 'unknown',
'creationDate' => 'unknown',
'authorUrl' => 'unknown',
);
];

$manifest = new Registry($extension->manifest_cache);

$extraData = array(
$extraData = [
'author' => $manifest->get('author', ''),
'version' => $manifest->get('version', ''),
'creationDate' => $manifest->get('creationDate', ''),
'authorUrl' => $manifest->get('authorUrl', '')
);
];

$installed[$extension->name] = array_merge($installed[$extension->name], $extraData);
}
Expand All @@ -526,7 +527,7 @@ public function getDirectory($public = false)
return $this->directories;
}

$this->directories = array();
$this->directories = [];

$registry = Factory::getApplication()->getConfig();
$cparams = ComponentHelper::getParams('com_media');
Expand Down Expand Up @@ -681,7 +682,7 @@ public function getDirectory($public = false)
*/
private function addDirectory($name, $path, $message = '')
{
$this->directories[$name] = array('writable' => is_writable($path), 'message' => $message,);
$this->directories[$name] = ['writable' => is_writable($path), 'message' => $message,];
}

/**
Expand Down Expand Up @@ -720,8 +721,8 @@ protected function parsePhpInfo($html)
$html = preg_replace('/<th[^>]*>([^<]+)<\/th>/', '<info>\1</info>', $html);
$html = preg_replace('/<td[^>]*>([^<]+)<\/td>/', '<info>\1</info>', $html);
$t = preg_split('/(<h2[^>]*>[^<]+<\/h2>)/', $html, -1, PREG_SPLIT_DELIM_CAPTURE);
$r = array();
$count = count($t);
$r = [];
$count = \count($t);
$p1 = '<info>([^<]+)<\/info>';
$p2 = '/' . $p1 . '\s*' . $p1 . '\s*' . $p1 . '/';
$p3 = '/' . $p1 . '\s*' . $p1 . '/';
Expand All @@ -738,7 +739,7 @@ protected function parsePhpInfo($html)
// 3cols
if (preg_match($p2, $val, $matchs))
{
$r[$name][trim($matchs[1])] = array(trim($matchs[2]), trim($matchs[3]),);
$r[$name][trim($matchs[1])] = [trim($matchs[2]), trim($matchs[3]),];
}
// 2cols
elseif (preg_match($p3, $val, $matchs))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,14 @@
<?php echo HTMLHelper::_('phpsetting.set', $this->phpSettings['iconv']); ?>
</td>
</tr>
<tr>
<th scope="row">
<?php echo Text::_('COM_ADMIN_INTL_AVAILABLE'); ?>
</th>
<td>
<?php echo HTMLHelper::_('phpsetting.set', $this->phpSettings['intl']); ?>
</td>
</tr>
<tr>
<th scope="row">
<?php echo Text::_('COM_ADMIN_MAX_INPUT_VARS'); ?>
Expand Down
1 change: 1 addition & 0 deletions administrator/language/en-GB/com_admin.ini
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ COM_ADMIN_HELP_USERS_USER_MANAGER_EDIT="Users: New/Edit"
COM_ADMIN_HELP_USERS_USER_NOTES="Users: User Notes"
COM_ADMIN_HELP_USERS_USER_NOTES_EDIT="Users: User Notes - New/Edit"
COM_ADMIN_ICONV_AVAILABLE="Iconv Available"
COM_ADMIN_INTL_AVAILABLE="Intl Available"
COM_ADMIN_JOOMLA_VERSION="Joomla! Version"
COM_ADMIN_LICENSE="License"
COM_ADMIN_LOG_DIRECTORY="(Log folder)"
Expand Down

0 comments on commit 157e0bf

Please sign in to comment.