Add template variable home_include when including static HTML page through main menu. Add parameter to return_home_page(). Add SECTION_INCLUDE constant - refs #11338

pull/2495/head
Yannick Warnier 8 years ago
parent 4507d6b92b
commit d6c5d52a48
  1. 16
      index.php
  2. 1
      main/inc/lib/api.lib.php
  3. 12
      main/inc/lib/userportal.lib.php

@ -20,7 +20,11 @@ if ($allow) {
}
// The section (for the tabs).
$this_section = SECTION_CAMPUS;
$this_section = SECTION_CAMPUS; //rewritten below if including HTML file
$includeFile = !empty($_GET['include']);
if ($includeFile) {
$this_section = SECTION_INCLUDE;
}
$header_title = null;
if (!api_is_anonymous()) {
$header_title = ' ';
@ -143,7 +147,15 @@ if (api_get_configuration_value('show_hot_sessions') === true) {
}
$controller->tpl->assign('hot_courses', $hotCourses);
$controller->tpl->assign('announcements_block', $announcements_block);
$controller->tpl->assign('home_welcome', $controller->return_home_page());
if ($includeFile) {
// If we are including a static page, then home_welcome is empty
$controller->tpl->assign('home_welcome', '');
$controller->tpl->assign('home_include', $controller->return_home_page($includeFile));
} else {
// If we are including the real homepage, then home_include is empty
$controller->tpl->assign('home_welcome', $controller->return_home_page(false));
$controller->tpl->assign('home_include', '');
}
$controller->tpl->assign('navigation_links', $controller->return_navigation_links());
$controller->tpl->assign('notice_block', $controller->return_notice());
//$controller->tpl->assign('main_navigation_block', $controller->return_navigation_links());

@ -164,6 +164,7 @@ define('SECTION_SOCIAL', 'social-network');
define('SECTION_DASHBOARD', 'dashboard');
define('SECTION_REPORTS', 'reports');
define('SECTION_GLOBAL', 'global');
define('SECTION_INCLUDE', 'include');
// CONSTANT name for local authentication source
define('PLATFORM_AUTH_SOURCE', 'platform');

@ -267,17 +267,19 @@ class IndexManager
/**
* Includes a created page.
*
* @param bool $getIncludedFile Whether to include a file as provided in URL GET or simply the homepage
* @return string
*/
public function return_home_page()
public function return_home_page($getIncludedFile = false)
{
$userId = api_get_user_id();
// Including the page for the news
$html = '';
if (!empty($_GET['include']) && preg_match('/^[a-zA-Z0-9_-]*\.html$/', $_GET['include'])) {
$open = @(string) file_get_contents($this->home.$_GET['include']);
$html = api_to_system_encoding($open, api_detect_encoding(strip_tags($open)));
if ($getIncludedFile === true) {
if (!empty($_GET['include']) && preg_match('/^[a-zA-Z0-9_-]*\.html$/', $_GET['include'])) {
$open = @(string)file_get_contents($this->home.$_GET['include']);
$html = api_to_system_encoding($open, api_detect_encoding(strip_tags($open)));
}
} else {
// Hiding home top when user not connected.
$hideTop = api_get_setting('hide_home_top_when_connected');

Loading…
Cancel
Save