ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\Init\Provider\StartUpMetaBarProvider Class Reference
+ Inheritance diagram for ILIAS\Init\Provider\StartUpMetaBarProvider:
+ Collaboration diagram for ILIAS\Init\Provider\StartUpMetaBarProvider:

Public Member Functions

 getMetaBarItems ()
 @inheritDoc More...
 
- Public Member Functions inherited from ILIAS\GlobalScreen\Scope\MetaBar\Provider\AbstractStaticMetaBarProvider
 __construct (Container $dic)
 @inheritDoc More...
 
- Public Member Functions inherited from ILIAS\GlobalScreen\Provider\AbstractProvider
 __construct (protected Container $dic)
 
 getFullyQualifiedClassName ()
 
 getProviderNameForPresentation ()
 
 getFullyQualifiedClassName ()
 
 getProviderNameForPresentation ()
 
 getMetaBarItems ()
 
- Public Member Functions inherited from ILIAS\GlobalScreen\Scope\MetaBar\Provider\MetaBarProviderInterface
 getProviderNameForPresentation ()
 

Private Member Functions

 isUserLoggedIn ()
 
 isUserOnLoginPage (UriInterface $uri)
 
 appendUrlParameterString (string $existing_url, string $addition)
 
 getBaseURL (UriInterface $uri)
 

Additional Inherited Members

- Protected Member Functions inherited from ILIAS\GlobalScreen\Provider\AbstractProvider
 globalScreen ()
 
- Protected Attributes inherited from ILIAS\GlobalScreen\Scope\MetaBar\Provider\AbstractStaticMetaBarProvider
Container $dic
 
IdentificationProviderInterface $if
 
MetaBarItemFactory $meta_bar
 

Detailed Description

Definition at line 28 of file StartUpMetaBarProvider.php.

Member Function Documentation

◆ appendUrlParameterString()

ILIAS\Init\Provider\StartUpMetaBarProvider::appendUrlParameterString ( string  $existing_url,
string  $addition 
)
private

Definition at line 134 of file StartUpMetaBarProvider.php.

134 : string
135 {
136 $url = (\is_int(strpos($existing_url, '?')))
137 ? $existing_url . '&' . $addition
138 : $existing_url . '?' . $addition;
139
140 $url = str_replace('?&', '?', $url);
141
142 return $url;
143 }
$url
Definition: shib_logout.php:68

References $url.

Referenced by ILIAS\Init\Provider\StartUpMetaBarProvider\getMetaBarItems().

+ Here is the caller graph for this function:

◆ getBaseURL()

ILIAS\Init\Provider\StartUpMetaBarProvider::getBaseURL ( UriInterface  $uri)
private

Definition at line 145 of file StartUpMetaBarProvider.php.

145 : string
146 {
147 $base = substr($uri->__toString(), strrpos($uri->__toString(), '/') + 1);
148
149 return rtrim(preg_replace('/([&?])lang=[a-z]{2}([&$])/', '$1', $base), '?&');
150 }

Referenced by ILIAS\Init\Provider\StartUpMetaBarProvider\getMetaBarItems().

+ Here is the caller graph for this function:

◆ getMetaBarItems()

ILIAS\Init\Provider\StartUpMetaBarProvider::getMetaBarItems ( )

@inheritDoc

Implements ILIAS\GlobalScreen\Scope\MetaBar\Provider\StaticMetaBarProvider.

Definition at line 33 of file StartUpMetaBarProvider.php.

33 : array
34 {
35 $factory = $this->dic->ui()->factory();
36 $request = $this->dic->http()->request();
37 $languages = $this->dic->language()->getInstalledLanguages();
38
39 $if = function (string $id): IdentificationInterface {
40 return $this->if->identifier($id);
41 };
42
43 $txt = function (string $id): string {
44 return $this->dic->language()->txt($id);
45 };
46
47 // Login-Button
48 // Only visible, if not on login-page but not logged in
49 $target_str = '';
50 if (isset($request->getQueryParams()['ref_id']) && $ref_id = $request->getQueryParams()['ref_id']) {
51 $type = \ilObject::_lookupType((int) $ref_id, true);
52 if ($type !== 'root') { // see bug #30710
53 $target_str = 'target=' . \ilObject::_lookupType((int) $ref_id, true) . '_' . (int) $ref_id . '&';
54 }
55 } elseif (isset($request->getQueryParams()['target']) && $target = $request->getQueryParams()['target']) {
56 $target = rawurlencode($target); // see #32789
57 $target_str = 'target=' . $target . '&';
58 }
59
60 $login_glyph = $factory->symbol()->glyph()->login();
61
62 $current_language = $this->dic->user()->getCurrentLanguage() ?: $this->dic->language()->getLangKey();
63
64 $login = $this->meta_bar
65 ->topLinkItem($if('login'))
66 ->withAction(
67 'login.php?' . $target_str . 'client_id=' . rawurlencode(
69 ) . '&cmd=force_login&lang=' . $current_language
70 )
71 ->withSymbol($login_glyph)
72 ->withPosition(3)
73 ->withTitle($txt('log_in'))
74 ->withAvailableCallable(function () {
75 return !$this->isUserLoggedIn();
76 })
77 ->withVisibilityCallable(function () use ($request) {
78 return !$this->isUserOnLoginPage($request->getUri());
79 });
80
81 // Language-Selection
82 $language_selection = $this->meta_bar
83 ->topParentItem($if('language_selection'))
84 ->withSymbol($factory->symbol()->glyph()->language())
85 ->withPosition(1)
86 ->withAvailableCallable(function () {
87 return !$this->isUserLoggedIn();
88 })
89 ->withVisibilityCallable(function () use ($languages) {
90 return \count($languages) > 1;
91 })
92 ->withTitle($txt('language'));
93
94 $base = $this->getBaseURL($request->getUri());
95 $dataFactory = new DataFactory();
96
97 foreach ($languages as $lang_key) {
98 $link = $this->appendUrlParameterString($base, 'lang=' . $lang_key);
99 $language_name = $this->dic->language()->_lookupEntry($lang_key, 'meta', 'meta_l_' . $lang_key);
100
101 $language_icon = $factory
102 ->symbol()
103 ->icon()
104 ->standard('none', $language_name)
105 ->withAbbreviation($lang_key);
106
107 $s = $this->meta_bar
108 ->linkItem($if($lang_key))
109 ->withSymbol($language_icon)
110 ->withAction($link)
111 ->withContentLanguage($dataFactory->languageTag($lang_key))
112 ->withLanguageForTargetedResource($dataFactory->languageTag($lang_key))
113 ->withTitle($language_name);
114
115 $language_selection->appendChild($s);
116 }
117
118 return [
119 $login,
120 $language_selection,
121 ];
122 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
appendUrlParameterString(string $existing_url, string $addition)
static _lookupType(int $id, bool $reference=false)
const CLIENT_ID
Definition: constants.php:41
$txt
Definition: error.php:31
$ref_id
Definition: ltiauth.php:66
withSymbol(Symbol $symbol)
@inheritDoc
withVisibilityCallable(callable $is_visible)

References $id, ILIAS\GlobalScreen\Scope\MetaBar\Provider\AbstractStaticMetaBarProvider\$if, $ref_id, $txt, ilObject\_lookupType(), ILIAS\Init\Provider\StartUpMetaBarProvider\appendUrlParameterString(), CLIENT_ID, ILIAS\Init\Provider\StartUpMetaBarProvider\getBaseURL(), ILIAS\Repository\int(), ILIAS\Init\Provider\StartUpMetaBarProvider\isUserLoggedIn(), ILIAS\Init\Provider\StartUpMetaBarProvider\isUserOnLoginPage(), ILIAS\GlobalScreen\Scope\MainMenu\Factory\withSymbol(), ILIAS\GlobalScreen\Scope\Footer\Factory\withTitle(), and ILIAS\GlobalScreen\Scope\withVisibilityCallable().

+ Here is the call graph for this function:

◆ isUserLoggedIn()

ILIAS\Init\Provider\StartUpMetaBarProvider::isUserLoggedIn ( )
private

Definition at line 124 of file StartUpMetaBarProvider.php.

124 : bool
125 {
126 return (!$this->dic->user()->isAnonymous() && $this->dic->user()->getId() !== 0);
127 }

Referenced by ILIAS\Init\Provider\StartUpMetaBarProvider\getMetaBarItems().

+ Here is the caller graph for this function:

◆ isUserOnLoginPage()

ILIAS\Init\Provider\StartUpMetaBarProvider::isUserOnLoginPage ( UriInterface  $uri)
private

Definition at line 129 of file StartUpMetaBarProvider.php.

129 : bool
130 {
131 return preg_match('%^.*(?:/login\.php|/)$%', $uri->getPath()) === 1;
132 }

Referenced by ILIAS\Init\Provider\StartUpMetaBarProvider\getMetaBarItems().

+ Here is the caller graph for this function:

The documentation for this class was generated from the following file: