Merge branch 'theme-ofaj' of https://github.com/aragonc/chamilo-lms into aragonc-theme-ofaj

remotes/angel/1.11.x
Yannick Warnier 9 years ago
commit 7ccb6f5ece
  1. 162
      main/inc/lib/banner.lib.php
  2. 3
      main/inc/lib/template.lib.php
  3. 2
      main/social/home.php
  4. 4
      main/template/default/layout/menu.tpl

@ -384,6 +384,8 @@ function return_navigation_array()
// Custom tabs
$customTabs = getCustomTabs();
if (!empty($customTabs)) {
foreach ($customTabs as $tab) {
if (api_get_setting($tab['variable'], $tab['subkey']) == 'true' &&
@ -401,6 +403,7 @@ function return_navigation_array()
}
}
return array(
'menu_navigation' => $menu_navigation,
'navigation' => $navigation,
@ -408,7 +411,159 @@ function return_navigation_array()
);
}
function return_menu()
function menuArray()
{
$mainNavigation = return_navigation_array();
unset($mainNavigation['possible_tabs']);
unset($mainNavigation['menu_navigation']);
//$navigation = $navigation['navigation'];
// Get active language
$lang = api_get_setting('platformLanguage');
if (!empty($_SESSION['user_language_choice'])) {
$lang = $_SESSION['user_language_choice'];
} elseif (!empty($_SESSION['_user']['language'])) {
$lang = $_SESSION['_user']['language'];
}
// Preparing home folder for multiple urls
if (api_get_multiple_access_url()) {
$access_url_id = api_get_current_access_url_id();
if ($access_url_id != -1) {
// If not a dead URL
$urlInfo = api_get_access_url($access_url_id);
$url = api_remove_trailing_slash(preg_replace('/https?:\/\//i', '', $urlInfo['url']));
$cleanUrl = api_replace_dangerous_char($url);
$cleanUrl = str_replace('/', '-', $cleanUrl);
$cleanUrl .= '/';
$homepath = api_get_path(SYS_APP_PATH).'home/'.$cleanUrl; //homep for Home Path
//we create the new dir for the new sites
if (!is_dir($homepath)) {
mkdir($homepath, api_get_permissions_for_new_directories());
}
}
} else {
$homepath = api_get_path(SYS_APP_PATH).'home/';
}
$ext = '.html';
$menuTabs = 'home_tabs';
$menuTabsLoggedIn = 'home_tabs_logged_in';
$pageContent = '';
// Get the extra page content, containing the links to add to the tabs
if (is_file($homepath.$menuTabs.'_'.$lang.$ext) && is_readable($homepath.$menuTabs.'_'.$lang.$ext)) {
$pageContent = @(string) file_get_contents($homepath . $menuTabs . '_' . $lang . $ext);
} elseif (is_file($homepath.$menuTabs.$lang.$ext) && is_readable($homepath.$menuTabs.$lang.$ext)) {
$pageContent = @(string) file_get_contents($homepath . $menuTabs . $lang . $ext);
} else {
//$errorMsg = get_lang('HomePageFilesNotReadable');
}
// Sanitize page content
$pageContent = api_to_system_encoding($pageContent, api_detect_encoding(strip_tags($pageContent)));
$open = str_replace('{rel_path}',api_get_path(REL_PATH), $pageContent);
$open = api_to_system_encoding($open, api_detect_encoding(strip_tags($open)));
// Get the extra page content, containing the links to add to the tabs
// that are only for users already logged in
$openMenuTabsLoggedIn = '';
if (api_get_user_id() && !api_is_anonymous()) {
if (is_file($homepath . $menuTabsLoggedIn . '_' . $lang . $ext) && is_readable($homepath . $menuTabsLoggedIn . '_' . $lang . $ext)) {
$pageContent = @(string) file_get_contents($homepath . $menuTabsLoggedIn . '_' . $lang . $ext);
$pageContent = str_replace('::private', '', $pageContent);
} elseif (is_file($homepath . $menuTabsLoggedIn . $lang . $ext) && is_readable($homepath . $menuTabsLoggedIn . $lang . $ext)) {
$pageContent = @(string) file_get_contents($homepath . $menuTabsLoggedIn . $lang . $ext);
$pageContent = str_replace('::private', '', $pageContent);
} else {
//$errorMsg = get_lang('HomePageFilesNotReadable');
}
$pageContent = api_to_system_encoding($pageContent, api_detect_encoding(strip_tags($pageContent)));
$openMenuTabsLoggedIn = str_replace('{rel_path}',api_get_path(REL_PATH), $pageContent);
$openMenuTabsLoggedIn = api_to_system_encoding($openMenuTabsLoggedIn, api_detect_encoding(strip_tags($openMenuTabsLoggedIn)));
}
if (!empty($open) OR !empty($openMenuTabsLoggedIn)) {
if (strpos($open.$openMenuTabsLoggedIn, 'show_menu') === false) {
if (api_is_anonymous()) {
$mainNavigation['navigation'][SECTION_CAMPUS] = null;
}
} else {
if (api_get_user_id() && !api_is_anonymous()) {
$list = split("\n", $openMenuTabsLoggedIn);
foreach ($list as $link) {
$matches = array();
$match = preg_match('$href="([^"]*)" target="([^"]*)">([^<]*)</a>$', $link, $matches);
if ($match) {
$mainNavigation['navigation'][$matches[3]] = array(
'url' => $matches[1],
'target' => $matches[2],
'title' => $matches[3],
'key' => 'page-' . str_replace(' ', '-', strtolower($matches[3]))
);
}
}
} else {
$list = split("\n", $open);
foreach ($list as $link) {
$matches = array();
$match = preg_match('$href="([^"]*)" target="([^"]*)">([^<]*)</a>$', $link, $matches);
if ($match) {
$mainNavigation['navigation'][$matches[3]] = array(
'url' => $matches[1],
'target' => $matches[2],
'title' => $matches[3],
'key' => 'page-' . str_replace(' ', '-', strtolower($matches[3]))
);
}
}
}
}
}
if (count($mainNavigation['navigation']) > 0) {
//$pre_lis = '';
$activeSection = '';
foreach ($mainNavigation['navigation'] as $section => $navigation_info) {
$key = (!empty($navigation_info['key'])?'tab-'.$navigation_info['key']:'');
if (isset($GLOBALS['this_section'])) {
$tempSection = $section;
if ($section == 'social') {
$tempSection = 'social-network';
}
if ($tempSection == $GLOBALS['this_section']) {
$activeSection = $section;
}
// If we're on the index page and a specific extra link has been
// loaded
if ($GLOBALS['this_section'] == SECTION_CAMPUS) {
if (!empty($_GET['include'])) {
$name = str_replace(' ', '-', strtolower($navigation_info['title'])) . '_' . $lang . $ext;
if ($_GET['include'] == $name) {
$activeSection = $section;
}
}
}
} else {
$current = '';
}
$mainNavigation['navigation'][$section]['current'] = '';
}
if (!empty($activeSection)) {
$mainNavigation['navigation'][$activeSection]['current'] = 'active';
}
}
unset($mainNavigation['navigation']['myprofile']);
return $mainNavigation['navigation'];
}
/* function return_menu()
{
$navigation = return_navigation_array();
$navigation = $navigation['navigation'];
@ -494,8 +649,10 @@ function return_menu()
}
}
if (count($navigation) > 0 || !empty($lis)) {
$pre_lis = '';
foreach ($navigation as $section => $navigation_info) {
$key = (!empty($navigation_info['key'])?'tab-'.$navigation_info['key']:'');
if (isset($GLOBALS['this_section'])) {
@ -507,6 +664,7 @@ function return_menu()
$pre_lis .= '<li'.$current.'><a href="'.$navigation_info['url'].'" target="_self">'.$navigation_info['title'].'</a></li>';
}
}
$lis = $pre_lis.$lis;
}
@ -514,8 +672,10 @@ function return_menu()
if (!empty($lis)) {
$menu .= $lis;
}
return $menu;
}
*/
function return_breadcrumb($interbreadcrumb, $language_file, $nameTools)
{

@ -951,8 +951,9 @@ class Template
$this->assign('portal_name', $portal_name);
//Menu
$menu = return_menu();
$menu = menuArray();
$this->assign('menu', $menu);
// Setting notifications

@ -77,6 +77,7 @@ if (api_get_setting('profile', 'picture') == 'true') {
//Block Menu
$social_menu_block = SocialManager::show_social_menu('home');
$social_search_block = Display::panel(
UserManager::get_search_form(''),
get_lang("SearchUsers")
@ -208,6 +209,7 @@ if (count($sessionList) > 0) {
$social_group_block = Display::panelCollapse(get_lang('Group'), $social_group_block, 'sm-groups', null, 'grups-acordion', 'groups-collapse');
$tpl = new Template(get_lang('SocialNetwork'));
SocialManager::setSocialUserBlock($tpl, api_get_user_id(), 'home');
$tpl->assign('social_menu_block', $social_menu_block);

@ -12,7 +12,9 @@
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="menuone">
<ul class="nav navbar-nav">
{{ menu }}
{% for item in menu %}
<li class="{{ item.current }}"><a href="{{ item.url }}">{{ item.title }}</a></li>
{% endfor %}
</ul>
{% if _u.logged == 1 %}
<ul class="nav navbar-nav navbar-right">

Loading…
Cancel
Save