ILIAS  release_8 Revision v8.24
ILIAS\Init\Provider\StartUpMetaBarProvider Class Reference

Class StartUpMetaBarProvider. More...

+ 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 (Container $dic)
 @inheritDoc More...
 
 getFullyQualifiedClassName ()
 @inheritDoc More...
 
 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
 
- Protected Attributes inherited from ILIAS\GlobalScreen\Provider\AbstractProvider
Container $dic
 

Detailed Description

Member Function Documentation

◆ appendUrlParameterString()

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

Definition at line 106 of file StartUpMetaBarProvider.php.

106 : string
107 {
108 $url = (is_int(strpos($existing_url, "?")))
109 ? $existing_url . "&" . $addition
110 : $existing_url . "?" . $addition;
111
112 $url = str_replace("?&", "?", $url);
113
114 return $url;
115 }
$url

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 117 of file StartUpMetaBarProvider.php.

117 : string
118 {
119 $base = substr($uri->__toString(), strrpos($uri->__toString(), "/") + 1);
120 return preg_replace("/&*lang=[a-z]{2}&*/", "", $base);
121 }
$base
Definition: index.php:4

References $base.

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 19 of file StartUpMetaBarProvider.php.

19 : array
20 {
21 $factory = $this->dic->ui()->factory();
22 $request = $this->dic->http()->request();
23 $languages = $this->dic->language()->getInstalledLanguages();
24
25 $if = function (string $id): IdentificationInterface {
26 return $this->if->identifier($id);
27 };
28
29 $txt = function (string $id): string {
30 return $this->dic->language()->txt($id);
31 };
32
33 // Login-Button
34 // Only visible, if not on login-page but not logged in
35 $target_str = '';
36 if (isset($request->getQueryParams()['ref_id']) && $ref_id = $request->getQueryParams()['ref_id']) {
38 if ($type != "root") { // see bug #30710
39 $target_str = 'target=' . \ilObject::_lookupType((int) $ref_id, true) . '_' . (int) $ref_id . '&';
40 }
41 } elseif (isset($request->getQueryParams()['target']) && $target = $request->getQueryParams()['target']) {
42 $target = rawurlencode($target); // see #32789
43 $target_str = 'target=' . $target . '&';
44 }
45
46 $login_glyph = $factory->symbol()->glyph()->login();
47 $login = $this->meta_bar->topLinkItem($if('login'))
48 ->withAction("login.php?" . $target_str . "client_id=" . rawurlencode(CLIENT_ID) . "&cmd=force_login&lang=" . $this->dic->user()->getCurrentLanguage())
49 ->withSymbol($login_glyph)
50 ->withPosition(2)
51 ->withTitle($txt('log_in'))
52 ->withAvailableCallable(function () {
53 return !$this->isUserLoggedIn();
54 })
55 ->withVisibilityCallable(function () use ($request) {
56 return !$this->isUserOnLoginPage($request->getUri());
57 });
58
59 // Language-Selection
60 $language_selection = $this->meta_bar->topParentItem($if('language_selection'))
61 ->withSymbol($factory->symbol()->glyph()->language())
62 ->withPosition(1)
63 ->withAvailableCallable(function () {
64 return !$this->isUserLoggedIn();
65 })
66 ->withVisibilityCallable(function () use ($languages) {
67 return count($languages) > 1;
68 })
69 ->withTitle($txt('language'));
70
71 $base = $this->getBaseURL($request->getUri());
72
73 foreach ($languages as $lang_key) {
74 $link = $this->appendUrlParameterString($base, "lang=" . $lang_key);
75 $language_name = $this->dic->language()->_lookupEntry($lang_key, "meta", "meta_l_" . $lang_key);
76
77 $language_icon = $factory->symbol()->icon()->standard("none", $language_name)
78 ->withAbbreviation($lang_key);
79
80 $s = $this->meta_bar->linkItem($if($lang_key))
81 ->withSymbol($language_icon)
82 ->withAction($link)
83 ->withTitle($language_name);
84
85 $language_selection->appendChild($s);
86 }
87
88 return [
89 $login,
90 $language_selection,
91 ];
92 }
$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:13
$ref_id
Definition: ltiauth.php:67
$factory
Definition: metadata.php:75
withSymbol(Symbol $symbol)
@inheritDoc
$type

References $base, $factory, $id, ILIAS\GlobalScreen\Scope\MetaBar\Provider\AbstractStaticMetaBarProvider\$if, $ref_id, $txt, $type, 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(), and ILIAS\GlobalScreen\Scope\MainMenu\Factory\withSymbol().

+ Here is the call graph for this function:

◆ isUserLoggedIn()

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

Definition at line 94 of file StartUpMetaBarProvider.php.

94 : bool
95 {
96 return (!$this->dic->user()->isAnonymous() && $this->dic->user()->getId() != 0);
97 }

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 99 of file StartUpMetaBarProvider.php.

99 : bool
100 {
101 $b = preg_match("%^.*/login.php$%", $uri->getPath()) === 1;
102
103 return $b;
104 }

References Vendor\Package\$b.

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: