Skip to content

Commit

Permalink
Added new {menulanguages} tag.
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-milette committed Sep 3, 2024
1 parent ea42b9e commit 937a54f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# Change Log
All notable changes to this project will be documented in this file.

## [2.5.2] 2024-08-28 (dev)
## [2.5.2] 2024-09-03 (dev)
### Added
- New {menulanguages} tag.
- New {infoform} tag.
- New {keyboard}...{/keyboard} tag.
- New {menuwishlist} tag.
Expand Down
25 changes: 25 additions & 0 deletions classes/text_filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -1059,6 +1059,31 @@ private function generatortags(&$text) {
$replace['/\{menuthemes\}/i'] = $menu;
}

// Tag: {menulanguages}.
// Description: Language switcher for custom menu. Not available after POST.
// Parameters: None.
if (stripos($text, '{menulanguages}') !== false) {
$menu = '';
if (empty($_POST)) {
$url = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http")
. "://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}";
$url .= (strpos($url, '?') ? '&' : '?');

// Get list of available languages
$availablelanguages = get_string_manager()->get_list_of_translations();
if (count($availablelanguages)) {
foreach ($availablelanguages as $langcode => $langname) {
// Create a link for each language
$menu .= '-' . $langname . '|' . $url . 'lang=' . $langcode . PHP_EOL;
}
if (!empty($menu)) {
$menu = get_string('language') . '||' . get_string('languageselector') . PHP_EOL . $menu;
}
}
}
$replace['/\{menulanguages\}/i'] = $menu;
}

// Tag: {menuwishlist}.
// Description: Displays a list of wishlisted courses for the Primary (Custom) menu with an option to add or remove
// the current course from the wishlist. The list will be sorted alphabetically. If there are no courses in the
Expand Down

0 comments on commit 937a54f

Please sign in to comment.