Feature #1807 - Introduction of a new function api_get_visual_theme(), elimination of repetitive code and other related changes.

skala
Ivan Tcholakov 16 years ago
parent 66a288fd5c
commit ebdec2d305
  1. 2
      main/admin/settings.lib.php
  2. 23
      main/chat/chat.php
  3. 24
      main/chat/header_frame.inc.php
  4. 39
      main/document/footerpage.php
  5. 39
      main/help/help.php
  6. 45
      main/inc/header.inc.php
  7. 58
      main/inc/lib/main_api.lib.php
  8. 41
      main/inc/reduced_header.inc.php
  9. 5
      main/install/index.php
  10. 2
      main/newscorm/openoffice_text.class.php
  11. 2
      main/newscorm/openoffice_text_document.class.php

@ -295,7 +295,7 @@ function handle_stylesheets()
$dirpath = api_get_path(SYS_PATH).'main/css/'.$style_dir;
if (is_dir($dirpath)) {
if ($style_dir != '.' && $style_dir != '..') {
if ($currentstyle == $style_dir OR ($style_dir == 'dokeos_classic' AND !$currentstyle)) {
if ($currentstyle == $style_dir OR ($style_dir == 'chamilo' AND !$currentstyle)) {
$selected = 'selected="true"';
} else {
$selected = '';

@ -26,26 +26,10 @@ header('Content-Type: text/html; charset='.api_get_system_encoding());
/*
* Choose CSS style (platform's, user's, or course's)
*/
$platform_theme = api_get_setting('stylesheets'); // plataform's css
$my_style = $platform_theme;
if (api_get_setting('user_selected_theme') == 'true') {
$useri = api_get_user_info();
$user_theme = $useri['theme'];
if (!empty($user_theme) && $user_theme != $my_style) {
$my_style = $user_theme; // user's css
}
}
$my_style = api_get_visual_theme();
$mycourseid = api_get_course_id();
if (!empty($mycourseid) && $mycourseid != -1) {
if (api_get_setting('allow_course_theme') == 'true') {
$mycoursetheme = api_get_course_setting('course_theme');
if (!empty($mycoursetheme) && $mycoursetheme != -1) {
if (!empty($mycoursetheme) && $mycoursetheme != $my_style) {
$my_style = $mycoursetheme; // course's css
}
}
}
$open_chat_window = api_get_course_setting('allow_open_chat_window');
}
@ -102,9 +86,8 @@ if ($_SESSION['_gid'] OR $_GET['group_id']) {
if (empty($open_chat_window)) {
Display::display_header($tool_name, 'Chat');
Display::display_header($tool_name, 'Chat');
}
echo '<iframe src="chat_whoisonline.php?cidReq='.$cidreq.'" name="chat_whoisonline" scrolling="auto" style="height:320px; width:19%; border: 0px none; float:left"></iframe>';
echo '<iframe src="chat_chat.php?origin='.Security::remove_XSS($_GET['origin']).'&target='.Security::remove_XSS($_GET['target']).'&amp;cidReq='.$cidreq.'" name="chat_chat" scrolling="auto" height="240" style="width:80%; border: 0px none; float:right"></iframe>';
@ -112,7 +95,7 @@ echo '<iframe src="chat_message.php?cidReq='.$cidreq.'" name="chat_message" scro
echo '<iframe src="chat_hidden.php?cidReq='.$cidreq.'" name="chat_hidden" height="0" style="border: 0px none"></iframe>';
if (empty($open_chat_window)) {
Display::display_footer();
Display::display_footer();
}
echo '</html>';

@ -25,29 +25,7 @@ if (FRAME == 'hidden') {
/*
* Choose CSS style (platform's, user's, or course's)
*/
$platform_theme = api_get_setting('stylesheets'); // plataform's css
$my_style = $platform_theme;
if (api_get_setting('user_selected_theme') == 'true') {
$useri = api_get_user_info();
$user_theme = $useri['theme'];
if (!empty($user_theme) && $user_theme != $my_style) {
$my_style = $user_theme; // user's css
}
}
$mycourseid = api_get_course_id();
if (!empty($mycourseid) && $mycourseid != -1) {
if (api_get_setting('allow_course_theme') == 'true') {
$mycoursetheme = api_get_course_setting('course_theme');
if (!empty($mycoursetheme) && $mycoursetheme != -1) {
if (!empty($mycoursetheme) && $mycoursetheme != $my_style) {
$my_style = $mycoursetheme; // course's css
}
}
}
}
$my_style = api_get_visual_theme();
if (empty($mycourseid)) {
// If it is not set $mycourse id we reload the chat_message window in order to hide the textarea to submit a message.

@ -8,44 +8,7 @@
require_once '../inc/global.inc.php';
$platform_theme = api_get_setting('stylesheets'); // plataform's css
$my_style = $platform_theme;
if (api_get_setting('user_selected_theme') == 'true') {
$useri = api_get_user_info();
$user_theme = $useri['theme'];
if (!empty($user_theme) && $user_theme != $my_style) {
$my_style = $user_theme; // user's css
}
}
$mycourseid = api_get_course_id();
if (!empty($mycourseid) && $mycourseid != -1) {
if (api_get_setting('allow_course_theme') == 'true') {
$mycoursetheme=api_get_course_setting('course_theme');
if (!empty($mycoursetheme) && $mycoursetheme != -1) {
if (!empty($mycoursetheme) && $mycoursetheme != $my_style) {
$my_style = $mycoursetheme; // course's css
}
}
$mycourselptheme = api_get_course_setting('allow_learning_path_theme');
if (!empty($mycourselptheme) && $mycourselptheme != -1 && $mycourselptheme == 1) {
global $lp_theme_css; // it comes from the lp_controller.php
global $lp_theme_config; // it comes from the lp_controller.php
if (!$lp_theme_config) {
if ($lp_theme_css != '') {
$theme = $lp_theme_css;
if (!empty($theme) && $theme != $my_style) {
$my_style = $theme; // LP's css
}
}
}
}
}
}
$my_style = api_get_visual_theme();
?><!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

@ -20,44 +20,7 @@ header('Content-Type: text/html; charset='. api_get_system_encoding());
* Choose CSS style platform's, user's, course's, or Learning path CSS
*/
$platform_theme = api_get_setting('stylesheets'); // plataform's css
$my_style = $platform_theme;
if (api_get_setting('user_selected_theme') == 'true') {
$useri = api_get_user_info();
$user_theme = $useri['theme'];
if (!empty($user_theme) && $user_theme != $my_style) {
$my_style = $user_theme; // user's css
}
}
$mycourseid = api_get_course_id();
if (!empty($mycourseid) && $mycourseid != -1) {
if (api_get_setting('allow_course_theme') == 'true') {
$mycoursetheme = api_get_course_setting('course_theme');
if (!empty($mycoursetheme) && $mycoursetheme != -1) {
if(!empty($mycoursetheme) && $mycoursetheme != $my_style) {
$my_style = $mycoursetheme; // course's css
}
}
$mycourselptheme = api_get_course_setting('allow_learning_path_theme');
if (!empty($mycourselptheme) && $mycourselptheme != -1 && $mycourselptheme == 1) {
global $lp_theme_css; // it comes from the lp_controller.php
global $lp_theme_config; // it comes from the lp_controller.php
if (!empty($lp_theme_css)) {
$theme = $lp_theme_css;
if (!empty($theme) && $theme != $my_style) {
$my_style = $theme; // LP's css
}
}
}
}
}
if ($lp_theme_log) {
$my_style = $platform_theme;
}
$my_style = api_get_visual_theme();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

@ -12,7 +12,7 @@
/*
* HTTP HEADER
*/
// Server mode indicator.
if (api_is_platform_admin()) {
if (api_get_setting('server_type') == 'test') {
@ -69,44 +69,8 @@ echo api_get_setting('siteName');
/*<![CDATA[*/
<?php
$platform_theme = api_get_setting('stylesheets'); // plataform's css
$my_style = $platform_theme;
if (api_get_setting('user_selected_theme') == 'true') {
$useri = api_get_user_info();
$user_theme = $useri['theme'];
if (!empty($user_theme) && $user_theme != $my_style) {
$my_style = $user_theme; // user's css
}
}
$mycourseid = api_get_course_id();
if (!empty($mycourseid) && $mycourseid != -1) {
if (api_get_setting('allow_course_theme') == 'true') {
$mycoursetheme=api_get_course_setting('course_theme');
if (!empty($mycoursetheme) && $mycoursetheme != -1) {
if (!empty($mycoursetheme) && $mycoursetheme != $my_style) {
$my_style = $mycoursetheme; // course's css
}
}
$mycourselptheme = api_get_course_setting('allow_learning_path_theme');
if (!empty($mycourselptheme) && $mycourselptheme != -1 && $mycourselptheme == 1) {
global $lp_theme_css; // it comes from the lp_controller.php
global $lp_theme_config; // it comes from the lp_controller.php
if (!$lp_theme_config) {
if ($lp_theme_css != '') {
$theme = $lp_theme_css;
if (!empty($theme) && $theme != $my_style) {
$my_style = $theme; // LP's css
}
}
}
}
}
}
$platform_theme = api_get_setting('stylesheets');
$my_style = api_get_visual_theme();
global $show_learn_path;
@ -116,9 +80,6 @@ if ($show_learn_path) {
$htmlHeadXtra[] = '<script src="dtree.js" type="text/javascript"></script>'; //will be moved
}
if (empty($my_style)) {
$my_style = 'dokeos_classic';
}
echo '@import "'.api_get_path(WEB_CSS_PATH).$my_style.'/default.css";'."\n";
echo '@import "'.api_get_path(WEB_CSS_PATH).$my_style.'/course.css";'."\n";

@ -2646,6 +2646,64 @@ function api_get_language_id($language) {
return $row['id'];
}
/**
* Returns the name of the visual theme to be applied on the current page.
* The rethurned name depends on platform, course or user -wide settings.
* @return string The visual theme's name, it is the name of a folder inside .../chamilo/main/css/
*/
function api_get_visual_theme() {
static $visual_theme;
if (!isset($visual_theme)) {
$platform_theme = api_get_setting('stylesheets'); // Plataform's theme.
$visual_theme = $platform_theme;
if (api_get_setting('user_selected_theme') == 'true') {
$user_info = api_get_user_info();
$user_theme = $user_info['theme'];
if (!empty($user_theme)) {
$visual_theme = $user_theme; // User's theme.
}
}
$course_id = api_get_course_id();
if (!empty($course_id) && $course_id != -1) {
if (api_get_setting('allow_course_theme') == 'true') {
$course_theme = api_get_course_setting('course_theme');
if (!empty($course_theme) && $course_theme != -1) {
if (!empty($course_theme)) {
$visual_theme = $course_theme; // Course's theme.
}
}
$allow_lp_theme = api_get_course_setting('allow_learning_path_theme');
if ($allow_lp_theme == 1) {
global $lp_theme_css, $lp_theme_config; // These variables come from the file lp_controller.php.
if (!$lp_theme_config) {
if (!empty($lp_theme_css)) {
$visual_theme = $lp_theme_css; // LP's theme.
}
}
}
}
}
if (empty($visual_theme)) {
$visual_theme = 'chamilo';
}
global $lp_theme_log;
if ($lp_theme_log) {
$visual_theme = $platform_theme;
}
}
return $visual_theme;
}
/**
* Returns a list of CSS themes currently available in the CSS folder
* @return array List of themes directories from the css folder

@ -53,45 +53,8 @@ echo api_get_setting('siteName');
* Choose CSS style platform's, user's, course's, or Learning path CSS
*/
$platform_theme = api_get_setting('stylesheets'); // plataform's css
$my_style = $platform_theme;
if (api_get_setting('user_selected_theme') == 'true') {
$useri = api_get_user_info();
$user_theme = $useri['theme'];
if (!empty($user_theme) && $user_theme != $my_style) {
$my_style = $user_theme; // user's css
}
}
$mycourseid = api_get_course_id();
if (!empty($mycourseid) && $mycourseid != -1) {
if (api_get_setting('allow_course_theme') == 'true') {
$mycoursetheme=api_get_course_setting('course_theme');
if (!empty($mycoursetheme) && $mycoursetheme != -1) {
if (!empty($mycoursetheme) && $mycoursetheme != $my_style) {
$my_style = $mycoursetheme; // course's css
}
}
$mycourselptheme=api_get_course_setting('allow_learning_path_theme');
if (!empty($mycourselptheme) && $mycourselptheme != -1 && $mycourselptheme == 1) {
global $lp_theme_css; // it comes from the lp_controller.php
global $lp_theme_config; // it comes from the lp_controller.php
if (!empty($lp_theme_css))
{
$theme=$lp_theme_css;
if (!empty($theme) && $theme != $my_style) {
$my_style = $theme; // LP's css
}
}
}
}
}
if (!empty($lp_theme_log)) {
$my_style = $platform_theme;
}
$platform_theme = api_get_setting('stylesheets');
$my_style = api_get_visual_theme();
// Sets the css reference it is call from lp_nav.php, lp_toc.php, lp_message, lp_log.php
if (!empty($scorm_css_header)) {

@ -51,7 +51,8 @@ $_setting = array(
'platform_charset' => 'UTF-8',
'server_type' => 'production', // 'production' | 'test'
'permissions_for_new_directories' => '0770',
'permissions_for_new_files' => '0660'
'permissions_for_new_files' => '0660',
'stylesheets' => 'chamilo'
);
// Determination of the language during the installation procedure.
@ -306,7 +307,7 @@ if ($encryptPassForm == '1') {
<title>&mdash; <?php echo get_lang('ChamiloInstallation').' &mdash; '.get_lang('Version_').' '.$new_version; ?></title>
<style type="text/css" media="screen, projection">
/*<![CDATA[*/
@import "../css/chamilo/default.css";
@import "../css/<?php echo api_get_visual_theme(); ?>/default.css";
/*]]>*/
</style>
<script type="text/javascript" src="../inc/lib/javascript/jquery.js"></script>

@ -76,7 +76,7 @@ class OpenofficeText extends OpenofficeDocument {
// dokeos styles
$my_style = api_get_setting('stylesheets');
if(empty($my_style)){$my_style = 'dokeos_classic';}
if(empty($my_style)){$my_style = 'chamilo';}
$style_to_import = "<style type=\"text/css\">\r\n";
$style_to_import .= '@import "'.api_get_path(WEB_CODE_PATH).'css/'.$my_style.'/default.css";'."\n";
$style_to_import .= '@import "'.api_get_path(WEB_CODE_PATH).'css/'.$my_style.'/course.css";'."\n";

@ -73,7 +73,7 @@ class OpenOfficeTextDocument extends OpenofficeDocument {
// dokeos styles
$my_style = api_get_setting('stylesheets');
if(empty($my_style)){$my_style = 'dokeos_classic';}
if(empty($my_style)){$my_style = 'chamilo';}
$style_to_import = "<style type=\"text/css\">\r\n";
$style_to_import .= '@import "'.api_get_path(WEB_CODE_PATH).'css/'.$my_style.'/default.css";'."\n";
$style_to_import .= '@import "'.api_get_path(WEB_CODE_PATH).'css/'.$my_style.'/course.css";'."\n";

Loading…
Cancel
Save