Skip to content

Commit

Permalink
Merge pull request ILIAS-eLearning#33 from studer-raimann/feature/6-0…
Browse files Browse the repository at this point in the history
…/plr-startup-pages

implemented language-selection
  • Loading branch information
nhaagen authored Aug 23, 2019
2 parents 737d912 + 82efe52 commit 9896d67
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 77 deletions.
44 changes: 43 additions & 1 deletion Services/Init/classes/Provider/StartUpModificationProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,51 @@ public function getMetaBarModification(CalledContexts $screen_context_stack) : ?
return $this->factory->metabar()->withModification(function (?MetaBar $current) : ?MetaBar {

$factory = $this->dic->ui()->factory();

// Login
$login_glyph = $factory->symbol()->glyph()->user();
$login_button = $factory->button()->bulky($login_glyph, 'login', "login.php");

// Language-Selection
$language_glyph = $factory->symbol()->glyph()->settings();
$language_selection = $factory->mainControls()->slate()->combined('language_selection', $language_glyph);
$missing_icon = $factory->symbol()->icon()->custom("./src/UI/examples/Layout/Page/Standard/question.svg", 'missing icon');

$base = $this->getBaseURL();

foreach ($this->dic->language()->getInstalledLanguages() as $lang_key) {
$link = $this->appendUrlParameterString($base, "lang=" . $lang_key);
$link = str_replace("?&", "?", $link);

$language_name = $this->dic->language()->_lookupEntry($lang_key, "meta", "meta_l_" . $lang_key);
$language_button = $factory->button()->bulky($missing_icon, $language_name, $link);

$language_selection = $language_selection->withAdditionalEntry($language_button);
}

$metabar = $factory->mainControls()->metaBar();
$metabar = $metabar->withAdditionalEntry('language_selection', $language_selection);
$metabar = $metabar->withAdditionalEntry('login', $login_button);

return $metabar->withAdditionalEntry('login', $factory->button()->bulky($factory->symbol()->glyph()->reset(), 'login', "login.php"));
return $metabar;
})->withLowPriority();
}


private function appendUrlParameterString(string $existing_url, string $addition) : string
{
$url = (is_int(strpos($existing_url, "?")))
? $existing_url . "&" . $addition
: $existing_url . "?" . $addition;

return $url;
}


private function getBaseURL() : string
{
$base = substr($_SERVER["REQUEST_URI"], strrpos($_SERVER["REQUEST_URI"], "/") + 1);

return preg_replace("/&*lang=[a-z]{2}&*/", "", $base);
}
}
34 changes: 1 addition & 33 deletions Services/Init/classes/class.ilStartUpGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -1942,12 +1942,10 @@ public static function initStartUpTemplate($a_tmpl, $a_show_back = false, $a_sho
* @var $ilSetting ilSetting
* @var $ilAccess ilAccessHandler
*/
global $lng, $ilCtrl, $ilSetting, $ilAccess;
global $lng, $ilAccess;
$tpl = new ilInitGlobalTemplate("tpl.main.html", true, true);

$tpl->addBlockfile('CONTENT', 'content', 'tpl.startup_screen.html', 'Services/Init');
$tpl->setVariable('HEADER_ICON', ilUtil::getImagePath('HeaderIcon.svg'));
$tpl->setVariable("HEADER_ICON_RESPONSIVE", ilUtil::getImagePath("HeaderIconResponsive.svg"));

if($a_show_back)
{
Expand Down Expand Up @@ -1987,40 +1985,10 @@ public static function initStartUpTemplate($a_tmpl, $a_show_back = false, $a_sho
$template_dir = 'Services/Init';
}

//Header Title
include_once("./Modules/SystemFolder/classes/class.ilObjSystemFolder.php");
$header_top_title = ilObjSystemFolder::_getHeaderTitle();
if (trim($header_top_title) != "" && $tpl->blockExists("header_top_title"))
{
$tpl->setCurrentBlock("header_top_title");
$tpl->setVariable("TXT_HEADER_TITLE", $header_top_title);
$tpl->parseCurrentBlock();
}

// language selection
$selection = self::getLanguageSelection();
if($selection)
{
$tpl->setCurrentBlock("lang_select");
$tpl->setVariable("TXT_LANGSELECT", $lng->txt("language"));
$tpl->setVariable("LANG_SELECT", $selection);
$tpl->parseCurrentBlock();
}

$tpl->addBlockFile('STARTUP_CONTENT', 'startup_content', $template_file, $template_dir);
return $tpl;
}

/**
* language selection list
* @return string ilGroupedList
*/
protected static function getLanguageSelection()
{
include_once("./Services/MainMenu/classes/class.ilMainMenuGUI.php");
return ilMainMenuGUI::getLanguageSelection(true);
}

/**
* @param string $page_editor_html
* @return string
Expand Down
43 changes: 0 additions & 43 deletions Services/MainMenu/classes/class.ilMainMenuGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,43 +210,6 @@ public function getLoginTargetPar()
}


/**
* @param bool $a_in_topbar
*
* @return string
* @deprecated
*/
public static function getLanguageSelection($a_in_topbar = false) : string
{
global $DIC;

$lng = $DIC->language();

$gr_list = new ilGroupedListGUI();
$gr_list->setAsDropDown(true);

$languages = $lng->getInstalledLanguages();
if (sizeof($languages) > 1) // #11237
{
foreach ($languages as $lang_key) {
$base = substr($_SERVER["REQUEST_URI"], strrpos($_SERVER["REQUEST_URI"], "/") + 1);
$base = preg_replace("/&*lang=[a-z]{2}&*/", "", $base);
$link = ilUtil::appendUrlParameterString(
$base,
"lang=" . $lang_key
);
$link = str_replace("?&", "?", $link);

$gr_list->addEntry($lng->_lookupEntry($lang_key, "meta", "meta_l_" . $lang_key), $link);
}

return $gr_list->getHTML();
}

return "";
}


/**
* Set all template variables (images, scripts, target frames, ...)
*/
Expand Down Expand Up @@ -330,12 +293,6 @@ private function setTemplateVars()
$this->tpl->parseCurrentBlock();
}

// language selection
$selection = self::getLanguageSelection();
if ($selection) {
$this->tpl->setVariable("TXT_LANGSELECT", $lng->txt("language"));
$this->tpl->setVariable("LANG_SELECT", $selection);
}

$this->tpl->setCurrentBlock("userisanonymous");
$this->tpl->setVariable("TXT_NOT_LOGGED_IN", $lng->txt("not_logged_in"));
Expand Down

0 comments on commit 9896d67

Please sign in to comment.