Feature #272 - The banner: Adding code for managing possible encoding differencies between the system and the stored in files html-snippets. Minor changes in "Configure homepage".

skala
Ivan Tcholakov 16 years ago
parent c6e0f2bb91
commit d6a7843861
  1. 46
      main/admin/configure_homepage.php
  2. 25
      main/inc/banner.inc.php

@ -230,8 +230,8 @@ if (!empty($action)) {
} else {
// We update all the news file
$_languages = api_get_languages();
foreach ($_languages["name"] as $key => $value) {
$english_name = $_languages["folder"][$key];
foreach ($_languages['name'] as $key => $value) {
$english_name = $_languages['folder'][$key];
if (file_exists($homep.$newsf.'_'.$english_name.$ext)) {
if (is_writable($homep.$newsf.'_'.$english_name.$ext)) {
$fp = fopen($homep.$newsf.'_'.$english_name.$ext, 'w');
@ -384,7 +384,7 @@ if (!empty($action)) {
// link and re-writing the array to the file
$link_index = intval($_GET['link_index']);
$menuf = ($action == 'delete_tabs')? $menutabs : $menuf;
$home_menu = file($homep.$menuf.'_'.$lang.$ext);
$home_menu = @file($homep.$menuf.'_'.$lang.$ext);
if (empty($home_menu)) {
$home_menu = array();
}
@ -414,9 +414,9 @@ if (!empty($action)) {
// This request is only the preparation for the update of the home_top
$home_top = '';
if (is_file($homep.$topf.'_'.$lang.$ext) && is_readable($homep.$topf.'_'.$lang.$ext)) {
$home_top = file_get_contents($homep.$topf.'_'.$lang.$ext);
$home_top = @(string)file_get_contents($homep.$topf.'_'.$lang.$ext);
} elseif (is_file($homep.$topf.$lang.$ext) && is_readable($homep.$topf.$lang.$ext)) {
$home_top = file_get_contents($homep.$topf.$lang.$ext);
$home_top = @(string)file_get_contents($homep.$topf.$lang.$ext);
} else {
$errorMsg = get_lang('HomePageFilesNotReadable');
}
@ -426,9 +426,9 @@ if (!empty($action)) {
// This request is only the preparation for the update of the home_notice
$home_notice = '';
if (is_file($homep.$noticef.'_'.$lang.$ext) && is_readable($homep.$noticef.'_'.$lang.$ext)) {
$home_notice = file($homep.$noticef.'_'.$lang.$ext);
$home_notice = @file($homep.$noticef.'_'.$lang.$ext);
} elseif (is_file($homep.$noticef.$lang.$ext) && is_readable($homep.$noticef.$lang.$ext)) {
$home_notice = file($homep.$noticef.$lang.$ext);
$home_notice = @file($homep.$noticef.$lang.$ext);
} else {
$errorMsg = get_lang('HomePageFilesNotReadable');
}
@ -444,9 +444,9 @@ if (!empty($action)) {
// This request is the preparation for the update of the home_news page
$home_news = '';
if (is_file($homep.$newsf.'_'.$lang.$ext) && is_readable($homep.$newsf.'_'.$lang.$ext)) {
$home_news = file_get_contents($homep.$newsf.'_'.$lang.$ext);
$home_news = @(string)file_get_contents($homep.$newsf.'_'.$lang.$ext);
} elseif (is_file($homep.$newsf.$lang.$ext) && is_readable($homep.$newsf.$lang.$ext)) {
$home_news = file_get_contents($homep.$newsf.$lang.$ext);
$home_news = @(string)file_get_contents($homep.$newsf.$lang.$ext);
} else {
$errorMsg = get_lang('HomePageFilesNotReadable');
}
@ -457,9 +457,9 @@ if (!empty($action)) {
$home_menu = '';
$menuf = ($action == 'edit_tabs')? $menutabs : $menuf;
if (is_file($homep.$menuf.'_'.$lang.$ext) && is_readable($homep.$menuf.'_'.$lang.$ext)) {
$home_menu = file($homep.$menuf.'_'.$lang.$ext);
$home_menu = @file($homep.$menuf.'_'.$lang.$ext);
} elseif(is_file($homep.$menuf.$lang.$ext) && is_readable($homep.$menuf.$lang.$ext)) {
$home_menu = file($homep.$menuf.$lang.$ext);
$home_menu = @file($homep.$menuf.$lang.$ext);
} else {
$errorMsg = get_lang('HomePageFilesNotReadable');
}
@ -476,9 +476,9 @@ if (!empty($action)) {
// This request is the preparation for the addition of an item in home_menu
$home_menu = '';
if (is_file($homep.$menutabs.'_'.$lang.$ext) && is_readable($homep.$menutabs.'_'.$lang.$ext)) {
$home_menu = file($homep.$menutabs.'_'.$lang.$ext);
$home_menu = @file($homep.$menutabs.'_'.$lang.$ext);
} elseif (is_file($homep.$menutabs.$lang.$ext) && is_readable($homep.$menutabs.$lang.$ext)) {
$home_menu = file($homep.$menutabs.$lang.$ext);
$home_menu = @file($homep.$menutabs.$lang.$ext);
} else {
$errorMsg = get_lang('HomePageFilesNotReadable');
}
@ -497,9 +497,9 @@ if (!empty($action)) {
$home_menu = '';
$menuf = ($action == 'edit_tabs')? $menutabs : $menuf;
if (is_file($homep.$menuf.'_'.$lang.$ext) && is_readable($homep.$menuf.'_'.$lang.$ext)) {
$home_menu = file($homep.$menuf.'_'.$lang.$ext);
$home_menu = @file($homep.$menuf.'_'.$lang.$ext);
} elseif(is_file($homep.$menuf.$lang.$ext) && is_readable($homep.$menuf.$lang.$ext)) {
$home_menu = file($homep.$menuf.$lang.$ext);
$home_menu = @file($homep.$menuf.$lang.$ext);
} else {
$errorMsg = get_lang('HomePageFilesNotReadable');
}
@ -544,7 +544,7 @@ if (!empty($action)) {
if (!strstr($filename, '/') && strstr($filename, '.html')) {
// Get oonly the contents of the link file
$link_html = file(api_get_path(SYS_PATH).'home/'.$filename);
$link_html = @file(api_get_path(SYS_PATH).'home/'.$filename);
$link_html = implode('', $link_html);
$link_url = '';
} else {
@ -686,7 +686,7 @@ switch ($action) {
$open = $home_top;
} else {
$name = $newsf;
$open = @file_get_contents($homep.$newsf.'_'.$lang.$ext);
$open = @(string)file_get_contents($homep.$newsf.'_'.$lang.$ext);
}
$open = api_to_system_encoding($open, api_detect_encoding(strip_tags($open)));
@ -751,9 +751,9 @@ switch ($action) {
<?php
//print home_top contents
if (file_exists($homep.$topf.'_'.$lang.$ext)) {
$home_top_temp = file_get_contents($homep.$topf.'_'.$lang.$ext);
$home_top_temp = @(string)file_get_contents($homep.$topf.'_'.$lang.$ext);
} else {
$home_top_temp = file_get_contents($homep.$topf.$ext);
$home_top_temp = @(string)file_get_contents($homep.$topf.$ext);
}
$open = str_replace('{rel_path}', api_get_path(REL_PATH), $home_top_temp);
$open = api_to_system_encoding($open, api_detect_encoding(strip_tags($open)));
@ -852,9 +852,9 @@ switch ($action) {
<?php
$home_menu = '';
if (file_exists($homep.$menuf.'_'.$lang.$ext)) {
$home_menu = file($homep.$menuf.'_'.$lang.$ext);
$home_menu = @file($homep.$menuf.'_'.$lang.$ext);
} else {
$home_menu = file ($homep.$menuf.$ext);
$home_menu = @file($homep.$menuf.$ext);
}
if (empty($home_menu)) {
$home_menu = array();
@ -888,9 +888,9 @@ switch ($action) {
<?php
$home_notice = '';
if (file_exists($homep.$noticef.'_'.$lang.$ext)) {
$home_notice = @file_get_contents($homep.$noticef.'_'.$lang.$ext);
$home_notice = @(string)file_get_contents($homep.$noticef.'_'.$lang.$ext);
} else {
$home_notice = @file_get_contents($homep.$noticef.$ext);
$home_notice = @(string)file_get_contents($homep.$noticef.$ext);
}
$home_notice = api_to_system_encoding($home_notice, api_detect_encoding(strip_tags($home_notice)));
echo $home_notice;

@ -19,7 +19,7 @@ $session_name = api_get_session_name($my_session_id);
<div id="header1">
<div id="top_corner"></div>
<div id="institution">
<a href="<?php echo api_get_path(WEB_PATH);?>index.php" target="_top"><?php echo api_get_setting('siteName') ?></a>
<a href="<?php echo api_get_path(WEB_PATH); ?>index.php" target="_top"><?php echo api_get_setting('siteName'); ?></a>
<?php
$iurl = api_get_setting('InstitutionUrl');
$iname = api_get_setting('Institution');
@ -294,28 +294,39 @@ if ($_configuration['multiple_access_urls']) {
$ext = '.html';
$menutabs = 'home_tabs';
if (is_file($homep.$menutabs.'_'.$lang.$ext) && is_readable($homep.$menutabs.'_'.$lang.$ext)) {
$home_top = file_get_contents($homep.$menutabs.'_'.$lang.$ext);
$home_top = @(string)file_get_contents($homep.$menutabs.'_'.$lang.$ext);
} elseif (is_file($homep.$menutabs.$lang.$ext) && is_readable($homep.$menutabs.$lang.$ext)) {
$home_top = file_get_contents($homep.$menutabs.$lang.$ext);
$home_top = @(string)file_get_contents($homep.$menutabs.$lang.$ext);
} else {
$errorMsg = get_lang('HomePageFilesNotReadable');
}
$home_top = api_to_system_encoding($home_top, api_detect_encoding(strip_tags($home_top)));
if (api_get_self() != '/main/admin/configure_homepage.php') {
if (file_exists($homep.$menutabs.'_'.$lang.$ext)) {
$home_top_temp = file_get_contents($homep.$menutabs.'_'.$lang.$ext);
$home_top_temp = @(string)file_get_contents($homep.$menutabs.'_'.$lang.$ext);
} else if (file_exists($homep.$menutabs.$ext)) {
$home_top_temp = file_get_contents($homep.$menutabs.$ext);
$home_top_temp = @(string)file_get_contents($homep.$menutabs.$ext);
}
$open = str_replace('{rel_path}',api_get_path(REL_PATH), $home_top_temp);
$open = api_to_system_encoding($open, api_detect_encoding(strip_tags($open)));
echo $open;
} else {
$home_menu = '';
if (file_exists($homep.$menutabs.'_'.$lang.$ext)) {
$home_menu = file($homep.$menutabs.'_'.$lang.$ext);
$home_menu = @file($homep.$menutabs.'_'.$lang.$ext);
} else {
$home_menu = file($homep.$menutabs.$ext);
$home_menu = @file($homep.$menutabs.$ext);
}
if (empty($home_menu)) {
$home_menu = array();
}
if (!empty($home_menu)) {
$home_menu = implode("\n", $home_menu);
$home_menu = api_to_system_encoding($home_menu, api_detect_encoding(strip_tags($home_menu)));
$home_menu = explode("\n", $home_menu);
}
foreach ($home_menu as $key => $enreg) {
$enreg = trim($enreg);
if (!empty($enreg)) {

Loading…
Cancel
Save