helper.php
2.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<?php
/**
* @package Joomla.Administrator
* @subpackage mod_login
*
* @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Helper for mod_login
*
* @since 1.6
*/
abstract class ModLoginHelper
{
/**
* Get an HTML select list of the available languages.
*
* @return string
*/
public static function getLanguageList()
{
$languages = JLanguageHelper::createLanguageList(null, JPATH_ADMINISTRATOR, false, true);
if (count($languages) <= 1)
{
return '';
}
usort(
$languages,
function ($a, $b)
{
return strcmp($a['value'], $b['value']);
}
);
// Fix wrongly set parentheses in RTL languages
if (JFactory::getLanguage()->isRtl())
{
foreach ($languages as &$language)
{
$language['text'] = $language['text'] . '‎';
}
}
array_unshift($languages, JHtml::_('select.option', '', JText::_('JDEFAULTLANGUAGE')));
return JHtml::_('select.genericlist', $languages, 'lang', 'class="advancedSelect" tabindex="4"', 'value', 'text', null);
}
/**
* Get the redirect URI after login.
*
* @return string
*/
public static function getReturnUri()
{
$uri = JUri::getInstance();
$return = 'index.php' . $uri->toString(array('query'));
if ($return != 'index.php?option=com_login')
{
return base64_encode($return);
}
else
{
return base64_encode('index.php');
}
}
/**
* Creates a list of two factor authentication methods used in com_users
* on user view
*
* @return array
*
* @deprecated 4.0 Use JAuthenticationHelper::getTwoFactorMethods() instead.
*/
public static function getTwoFactorMethods()
{
try
{
JLog::add(
sprintf('%s() is deprecated, use JAuthenticationHelper::getTwoFactorMethods() instead.', __METHOD__),
JLog::WARNING,
'deprecated'
);
}
catch (RuntimeException $exception)
{
// Informational log only
}
return JAuthenticationHelper::getTwoFactorMethods();
}
}