Fixed api_get_home_path() to add trailing slash when not multiple urls + using .txt extension for footer/header

skala
Yannick Warnier 15 years ago
parent 98755f6505
commit 95a33be630
  1. 22
      main/admin/settings.php
  2. 26
      main/inc/lib/main_api.lib.php

@ -198,15 +198,15 @@ if (!empty($_GET['category']) && !in_array($_GET['category'], array('Plugins', '
break;
case 'textarea':
if ($row['variable'] == 'header_extra_content') {
$file = api_get_path(SYS_PATH).api_get_home_path().'header_extra_content';
$value = '';
if (file_exists($file)) {
$value = file_get_contents($file);
}
$form->addElement('textarea', $row['variable'], array(get_lang($row['title']), get_lang($row['comment'])) , array('rows'=>'10','cols'=>'50'), $hideme);
$file = api_get_path(SYS_PATH).api_get_home_path().'header_extra_content.txt';
$value = '';
if (file_exists($file)) {
$value = file_get_contents($file);
}
$form->addElement('textarea', $row['variable'], array(get_lang($row['title']), get_lang($row['comment'])) , array('rows'=>'10','cols'=>'50'), $hideme);
$default_values[$row['variable']] = $value;
} elseif ($row['variable'] == 'footer_extra_content') {
$file = api_get_path(SYS_PATH).api_get_home_path().'footer_extra_content';
$file = api_get_path(SYS_PATH).api_get_home_path().'footer_extra_content.txt';
$value = '';
if (file_exists($file)) {
$value = file_get_contents($file);
@ -422,12 +422,12 @@ if (!empty($_GET['category']) && !in_array($_GET['category'], array('Plugins', '
switch ($key) {
case 'header_extra_content':
file_put_contents(api_get_path(SYS_PATH).api_get_home_path().'/header_extra_content', $value);
$value = api_get_home_path().'/header_extra_content';
file_put_contents(api_get_path(SYS_PATH).api_get_home_path().'/header_extra_content.txt', $value);
$value = api_get_home_path().'/header_extra_content.txt';
break;
case 'footer_extra_content':
file_put_contents(api_get_path(SYS_PATH).api_get_home_path().'/footer_extra_content', $value);
$value = api_get_home_path().'/footer_extra_content';
file_put_contents(api_get_path(SYS_PATH).api_get_home_path().'/footer_extra_content.txt', $value);
$value = api_get_home_path().'/footer_extra_content.txt';
break;
// URL validation for some settings.
case 'InstitutionUrl':

@ -1792,18 +1792,22 @@ function api_get_coachs_from_course($session_id=0,$course_code='') {
function api_get_setting($variable, $key = null) {
global $_setting;
if ($variable == 'header_extra_content') {
$filename = api_get_path(SYS_PATH).api_get_home_path().'header_extra_content';
if (file_exists($filename)) {
$value = file_get_contents($filename);
return $value ;
}
$filename = api_get_path(SYS_PATH).api_get_home_path().'header_extra_content.txt';
if (file_exists($filename)) {
$value = file_get_contents($filename);
return $value ;
} else {
return '';
}
}
if ($variable == 'footer_extra_content') {
$filename = api_get_path(SYS_PATH).api_get_home_path().'header_extra_content';
if (file_exists($filename)) {
$value = file_get_contents($filename);
return $value ;
}
$filename = api_get_path(SYS_PATH).api_get_home_path().'footer_extra_content.txt';
if (file_exists($filename)) {
$value = file_get_contents($filename);
return $value ;
} else {
return '';
}
}
return is_null($key) ? ((isset($_setting[$variable]) && $_setting[$variable] != '') ? $_setting[$variable] : null) : $_setting[$variable][$key];
}
@ -5308,7 +5312,7 @@ function api_get_unique_id() {
function api_get_home_path() {
$home = 'home';
$home = 'home/';
if (api_get_multiple_access_url()) {
$access_url_id = api_get_current_access_url_id();
$url_info = api_get_access_url($access_url_id);

Loading…
Cancel
Save