-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Expand file tree
/
Copy pathLoginHelper.php
More file actions
84 lines (71 loc) · 2.07 KB
/
Copy pathLoginHelper.php
File metadata and controls
84 lines (71 loc) · 2.07 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
<?php
/**
* @package Joomla.Administrator
* @subpackage mod_login
*
* @copyright (C) 2010 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Module\Login\Administrator\Helper;
use Joomla\CMS\Application\CMSApplicationInterface;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\LanguageHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Uri\Uri;
// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects
/**
* Helper for mod_login
*
* @since 1.6
*/
class LoginHelper
{
/**
* Get an HTML select list of the available languages.
*
* @param CMSApplicationInterface $app The application
*
* @return string
*
* @since 5.1.0
*/
public function getLanguages(CMSApplicationInterface $app)
{
$languages = LanguageHelper::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 ($app->getLanguage()->isRtl()) {
foreach ($languages as &$language) {
$language['text'] .= '‎';
}
}
array_unshift($languages, HTMLHelper::_('select.option', '', Text::_('JDEFAULTLANGUAGE')));
return HTMLHelper::_('select.genericlist', $languages, 'lang', 'class="form-select"', 'value', 'text', null);
}
/**
* Get the redirect URI after login.
*
* @return string
*
* @since 5.1.0
*/
public function getReturnUriString()
{
$uri = Uri::getInstance();
$return = 'index.php' . $uri->toString(['query']);
if ($return !== 'index.php?option=com_login') {
return base64_encode($return);
}
return base64_encode('index.php');
}
}