Fixing stylesheet in order to preview the all page

skala
Julio Montoya 14 years ago
parent ed6da65ffa
commit 7e552e7ec9
  1. 28
      main/admin/settings.lib.php
  2. 5
      main/admin/settings.php
  3. 2
      main/admin/style_preview.php
  4. 4
      main/css/base_chamilo.css
  5. 31
      main/inc/lib/banner.lib.php
  6. 83
      main/inc/lib/display.lib.php
  7. 102
      main/inc/lib/template.lib.php
  8. 2
      main/template/default/layout/header.tpl
  9. 2
      main/template/default/layout/main_pre_content.tpl

@ -221,18 +221,14 @@ function handle_stylesheets() {
} }
} }
// Preview of the stylesheet.
echo '<div><iframe src="style_preview.php" width="100%" height="300" name="preview"></iframe></div>';
?> ?>
<script type="text/javascript"> <script type="text/javascript">
function load_preview(selectobj){ function load_preview(){
var style_dir = selectobj.options[selectobj.selectedIndex].value; $('#stylesheets_id').submit();
parent.preview.location='style_preview.php?style=' + style_dir;
} }
</script> </script>
<?php <?php
echo '<form name="stylesheets" method="post" action="'.api_get_self().'?category='.Security::remove_XSS($_GET['category']).'">'; echo '<form id="stylesheets_id" name="stylesheets" method="post" action="'.api_get_self().'?category='.Security::remove_XSS($_GET['category']).'">';
echo '<br /><select name="style" onChange="load_preview(this)" >'; echo '<br /><select name="style" onChange="load_preview(this)" >';
$list_of_styles = array(); $list_of_styles = array();
@ -245,13 +241,18 @@ function handle_stylesheets() {
continue; continue;
} }
$dirpath = api_get_path(SYS_PATH).'main/css/'.$style_dir; $dirpath = api_get_path(SYS_PATH).'main/css/'.$style_dir;
if (is_dir($dirpath)) { if (is_dir($dirpath)) {
if ($style_dir != '.' && $style_dir != '..') { if ($style_dir != '.' && $style_dir != '..') {
if ($currentstyle == $style_dir || ($style_dir == 'chamilo' && !$currentstyle)) { if (isset($_POST['style']) && $_POST['style'] == $style_dir) {
$selected = 'selected="true"';
} else {
if (!isset($_POST['style']) && ($currentstyle == $style_dir || ($style_dir == 'chamilo' && !$currentstyle))) {
$selected = 'selected="true"'; $selected = 'selected="true"';
} else { } else {
$selected = ''; $selected = '';
} }
}
$show_name = ucwords(str_replace('_', ' ', $style_dir)); $show_name = ucwords(str_replace('_', ' ', $style_dir));
if ($is_style_changeable) { if ($is_style_changeable) {
@ -269,6 +270,7 @@ function handle_stylesheets() {
} }
@closedir($handle); @closedir($handle);
} }
//Sort styles in alphabetical order //Sort styles in alphabetical order
asort($list_of_names); asort($list_of_names);
foreach($list_of_names as $style_dir=>$item) { foreach($list_of_names as $style_dir=>$item) {
@ -452,16 +454,8 @@ function store_stylesheets() {
// Insert the stylesheet. // Insert the stylesheet.
$style = Database::escape_string($_POST['style']); $style = Database::escape_string($_POST['style']);
if (is_style($style)) {
/*
$sql = 'UPDATE '.$table_settings_current.' SET
selected_value = "'.$style.'"
WHERE variable = "stylesheets"
AND category = "stylesheets"';
Database::query($sql);
*/
if (is_style($style)) {
api_set_setting('stylesheets', $style, null, 'stylesheets', $_configuration['access_url']); api_set_setting('stylesheets', $style, null, 'stylesheets', $_configuration['access_url']);
} }

@ -57,6 +57,11 @@ if (isset($_POST['submit_stylesheets'])) {
exit; exit;
} }
if (isset($_POST['style'])) {
Display::$preview_style = $_POST['style'];
}
// Database table definitions. // Database table definitions.
$table_settings_current = Database :: get_main_table(TABLE_MAIN_SETTINGS_CURRENT); $table_settings_current = Database :: get_main_table(TABLE_MAIN_SETTINGS_CURRENT);

@ -1,6 +1,6 @@
<?php <?php
/* For licensing terms, see /chamilo_license.txt */ /* For licensing terms, see /chamilo_license.txt */
exit;
$language_file = array('create_course', 'courses', 'admin'); $language_file = array('create_course', 'courses', 'admin');
require_once '../inc/global.inc.php'; require_once '../inc/global.inc.php';

@ -2527,10 +2527,6 @@ span.form_required {
border-radius: 0; border-radius: 0;
} }
/* Subnav */ /* Subnav */
.subnav { .subnav {
width: 100%; width: 100%;

@ -110,16 +110,17 @@ function get_tabs() {
return $navigation; return $navigation;
} }
function show_header_1($language_file, $nameTools) { function show_header_1($language_file, $nameTools, $theme) {
global $noPHP_SELF; global $noPHP_SELF;
$_course = api_get_course_info(); $_course = api_get_course_info();
echo '<div id="header1">'; echo '<div id="header1">';
$logo = api_get_path(SYS_CODE_PATH).'css/'.api_get_visual_theme().'/images/header-logo.png'; $logo = api_get_path(SYS_CODE_PATH).'css/'.$theme.'/images/header-logo.png';
$site_name = api_get_setting('siteName'); $site_name = api_get_setting('siteName');
if (file_exists($logo)) { if (file_exists($logo)) {
$site_name = api_get_setting('Institution').' - '.$site_name; $site_name = api_get_setting('Institution').' - '.$site_name;
echo '<div id="logo">'; echo '<div id="logo">';
$image_url = api_get_path(WEB_CSS_PATH).api_get_visual_theme().'/images/header-logo.png'; $image_url = api_get_path(WEB_CSS_PATH).$theme.'/images/header-logo.png';
$logo = Display::img($image_url, $site_name, array('title'=>$site_name)); $logo = Display::img($image_url, $site_name, array('title'=>$site_name));
echo Display::url($logo, api_get_path(WEB_PATH).'index.php'); echo Display::url($logo, api_get_path(WEB_PATH).'index.php');
echo '</div>'; echo '</div>';
@ -145,29 +146,9 @@ function show_header_1($language_file, $nameTools) {
} }
/* Course title section */ /* Course title section */
if (!empty($_cid) and $_cid != -1 and isset($_course)) { if (!empty($_cid) and $_cid != -1 and isset($_course)) {
//Put the name of the course in the header //Put the name of the course in the header
echo '<div id="my_courses">'; echo '<div id="my_courses">';
/* <div id="my_courses"><a href="<?php echo api_get_path(WEB_COURSE_PATH).$_course['path']; ?>/index.php" target="_top">&nbsp;
echo $_course['name'].' ';
if (api_get_setting('display_coursecode_in_courselist') == 'true') {
echo $_course['official_code'];
}
if (api_get_setting('use_session_mode') == 'true' && isset($_SESSION['session_name'])) {
echo '&nbsp;('.$_SESSION['session_name'].')&nbsp;';
}
if (api_get_setting('display_coursecode_in_courselist') == 'true' && api_get_setting('display_teacher_in_courselist') == 'true') {
echo ' - ';
}
if (api_get_setting('display_teacher_in_courselist') == 'true') {
//This is still necessary? There is the course teacher in the footer
echo stripslashes($_course['titular']);
}
echo '</a>';*/
echo '</div>'; echo '</div>';
} elseif (isset($nameTools) && $language_file != 'course_home') { } elseif (isset($nameTools) && $language_file != 'course_home') {
//Put the name of the user-tools in the header //Put the name of the user-tools in the header
@ -178,16 +159,12 @@ function show_header_1($language_file, $nameTools) {
} else { } else {
echo '<div id="my_courses">'.$nameTools.'</div>'; echo '<div id="my_courses">'.$nameTools.'</div>';
} }
} else {
//echo '<div id="my_courses"></div>';
} }
echo '<div id="plugin-header">'; echo '<div id="plugin-header">';
api_plugin('header'); api_plugin('header');
echo '</div>'; echo '</div>';
//Don't let the header disappear if there's nothing on the left
//echo '<div class="clear">&nbsp;</div>';
echo '</div>'; echo '</div>';
} }

@ -26,12 +26,59 @@ define('MAX_LENGTH_BREADCRUMB', 100);
*/ */
class Display { class Display {
/* The main template*/
static $global_template; static $global_template;
static $preview_style = null;
private function __construct() { private function __construct() {
}
/**
* Displays the page header
* @param string The name of the page (will be showed in the page title)
* @param string Optional help file name
*/
public static function display_header($tool_name ='', $help = null) {
$nameTools = $tool_name;
global $_plugins, $lp_theme_css, $mycoursetheme, $user_theme, $platform_theme;
global $httpHeadXtra, $htmlHeadXtra, $htmlIncHeadXtra, $_course, $_user, $text_dir, $plugins, $_user, $_cid, $interbreadcrumb, $charset, $language_file, $noPHP_SELF;
global $menu_navigation;
global $htmlCSSXtra;
require_once api_get_path(LIBRARY_PATH).'template.lib.php';
self::$global_template = new Template($tool_name);
if (!empty(self::$preview_style)) {
self::$global_template->preview_theme = self::$preview_style;
self::$global_template->set_theme();
}
echo self::$global_template->show_header_template();
} }
/**
* Displays the reduced page header (without banner)
*/
public static function display_reduced_header () {
global $_plugins, $lp_theme_css, $mycoursetheme, $user_theme, $platform_theme;
global $httpHeadXtra, $htmlHeadXtra, $htmlIncHeadXtra, $_course, $_user, $text_dir, $plugins, $_user, $_cid, $interbreadcrumb, $charset, $language_file, $noPHP_SELF, $language_interface;
global $menu_navigation;
//require api_get_path(INCLUDE_PATH).'reduced_header.inc.php';
self::$global_template = new Template($tool_name, false);
self::$global_template->show_header = false;
echo self::$global_template ->show_header_template();
}
/**
* Display the page footer
*/
public static function display_footer () {
global $_plugins, $global_tpl;
echo self::$global_template ->show_footer_template();
}
/** /**
* Displays the tool introduction of a tool. * Displays the tool introduction of a tool.
* *
@ -375,43 +422,7 @@ class Display {
return '<a href="'.api_get_path(WEB_PATH).'index.php">'.$name.'</a>'; return '<a href="'.api_get_path(WEB_PATH).'index.php">'.$name.'</a>';
} }
/**
* Displays the page header
* @param string The name of the page (will be showed in the page title)
* @param string Optional help file name
*/
public static function display_header($tool_name ='', $help = null) {
$nameTools = $tool_name;
global $_plugins, $lp_theme_css, $mycoursetheme, $user_theme, $platform_theme;
global $httpHeadXtra, $htmlHeadXtra, $htmlIncHeadXtra, $_course, $_user, $text_dir, $plugins, $_user, $_cid, $interbreadcrumb, $charset, $language_file, $noPHP_SELF;
global $menu_navigation;
global $htmlCSSXtra;
require_once api_get_path(LIBRARY_PATH).'template.lib.php';
self::$global_template = new Template($tool_name);
echo self::$global_template ->show_header();
}
/**
* Displays the reduced page header (without banner)
*/
public static function display_reduced_header () {
global $_plugins, $lp_theme_css, $mycoursetheme, $user_theme, $platform_theme;
global $httpHeadXtra, $htmlHeadXtra, $htmlIncHeadXtra, $_course, $_user, $text_dir, $plugins, $_user, $_cid, $interbreadcrumb, $charset, $language_file, $noPHP_SELF, $language_interface;
global $menu_navigation;
//require api_get_path(INCLUDE_PATH).'reduced_header.inc.php';
self::$global_template = new Template($tool_name);
self::$global_template->show_header = false;
echo self::$global_template ->show_header();
}
/**
* Display the page footer
*/
public static function display_footer () {
global $_plugins, $global_tpl;
echo self::$global_template ->show_footer();
}
/** /**
* Prints an <option>-list with all letters (A-Z). * Prints an <option>-list with all letters (A-Z).

@ -1,5 +1,11 @@
<?php <?php
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
/*
* @author Julio Montoya <gugli100@gmail.com>
*
**/
/* @todo order class */
// Load Smarty library // Load Smarty library
require_once api_get_path(LIBRARY_PATH).'smarty/Smarty.class.php'; require_once api_get_path(LIBRARY_PATH).'smarty/Smarty.class.php';
@ -8,6 +14,8 @@ require_once api_get_path(LIBRARY_PATH).'banner.lib.php';
class Template extends Smarty { class Template extends Smarty {
var $style = 'default'; //see the template folder var $style = 'default'; //see the template folder
var $preview_theme = null;
var $theme; // the chamilo theme public_admin, chamilo, chamilo_red, etc
var $title = null; var $title = null;
var $show_header; var $show_header;
var $show_footer; var $show_footer;
@ -192,13 +200,52 @@ class Template extends Smarty {
'institution' => api_get_setting('Institution'), 'institution' => api_get_setting('Institution'),
); );
$this->assign('_s', $_s); $this->assign('_s', $_s);
}
function set_theme() {
//$platform_theme = api_get_setting('stylesheets');
$this->theme = api_get_visual_theme();
if (!empty($this->preview_theme)) {
$this->theme = $this->preview_theme;
}
//Base CSS
$style_html = '@import "'.api_get_path(WEB_CSS_PATH).'base.css";';
//Default theme CSS
$style_html .= '@import "'.api_get_path(WEB_CSS_PATH).$this->theme.'/default.css";';
//Course theme CSS
$style_html .= '@import "'.api_get_path(WEB_CSS_PATH).$this->theme.'/course.css";';
if ($navigator_info['name']=='Internet Explorer' && $navigator_info['version']=='6') {
$style_html .= 'img, div { behavior: url('.api_get_path(WEB_LIBRARY_PATH).'javascript/iepngfix/iepngfix.htc) } ';
} }
$this->assign('css_style', $style_html);
$style_print = '@import "'.api_get_path(WEB_CSS_PATH).$this->theme.'/print.css";';
$this->assign('css_style_print', $style_print);
$this->assign('style_print', $style_print);
// Header 1
ob_start();
show_header_1($language_file, $nameTools, $this->theme);
$header1 = ob_get_contents();
ob_clean();
$this->assign('header1', $header1);
}
private function set_header_parameters() { private function set_header_parameters() {
$help = $this->help; $help = $this->help;
$nameTools = $this->title; $nameTools = $this->title;
global $_plugins, $lp_theme_css, $mycoursetheme, $user_theme, $platform_theme; global $_plugins, $lp_theme_css, $mycoursetheme, $user_theme;
global $httpHeadXtra, $htmlHeadXtra, $_course, $_user, $text_dir, $plugins, $_user, global $httpHeadXtra, $htmlHeadXtra, $_course, $_user, $text_dir, $plugins, $_user,
$_cid, $interbreadcrumb, $charset, $language_file, $noPHP_SELF; $_cid, $interbreadcrumb, $charset, $language_file, $noPHP_SELF;
@ -245,27 +292,8 @@ class Template extends Smarty {
$this->assign('title_string', $title_string); $this->assign('title_string', $title_string);
$platform_theme = api_get_setting('stylesheets'); //Setting the theme
$my_style = api_get_visual_theme(); $this->set_theme();
$style = '';
//Base CSS
$style = '@import "'.api_get_path(WEB_CSS_PATH).'base.css";';
//Default theme CSS
$style .= '@import "'.api_get_path(WEB_CSS_PATH).$my_style.'/default.css";';
//Course theme CSS
$style .= '@import "'.api_get_path(WEB_CSS_PATH).$my_style.'/course.css";';
if ($navigator_info['name']=='Internet Explorer' && $navigator_info['version']=='6') {
$style .= 'img, div { behavior: url('.api_get_path(WEB_LIBRARY_PATH).'javascript/iepngfix/iepngfix.htc) } ';
}
$this->assign('css_style', $style);
$style_print = '@import "'.api_get_path(WEB_CSS_PATH).$my_style.'/print.css";';
$this->assign('css_style_print', $style_print);
//Extra JS files //Extra JS files
@ -280,7 +308,6 @@ class Template extends Smarty {
); );
if (api_get_setting('allow_global_chat') == 'true') { if (api_get_setting('allow_global_chat') == 'true') {
if (!api_is_anonymous()) { if (!api_is_anonymous()) {
$js_files[] = 'chat/js/chat.js'; $js_files[] = 'chat/js/chat.js';
} }
@ -309,7 +336,7 @@ class Template extends Smarty {
); );
if ($show_learn_path) { if ($show_learn_path) {
$css_files[] = api_get_path(WEB_CSS_PATH).$my_style.'/learnpath.css'; $css_files[] = api_get_path(WEB_CSS_PATH).$this->theme.'/learnpath.css';
} }
if (api_get_setting('allow_global_chat') == 'true') { if (api_get_setting('allow_global_chat') == 'true') {
@ -317,15 +344,15 @@ class Template extends Smarty {
} }
$css_file_to_string = ''; $css_file_to_string = '';
foreach($css_files as $css_file) { foreach ($css_files as $css_file) {
$css_file_to_string .= api_get_css($css_file); $css_file_to_string .= api_get_css($css_file);
} }
global $this_section; global $this_section;
$this->assign('css_file_to_string', $css_file_to_string); $this->assign('css_file_to_string', $css_file_to_string);
$this->assign('js_file_to_string', $js_file_to_string); $this->assign('js_file_to_string', $js_file_to_string);
$this->assign('text_direction', api_get_text_direction()); $this->assign('text_direction', api_get_text_direction());
$this->assign('style_print', $style_print);
$this->assign('section_name', 'section-'.$this_section); $this->assign('section_name', 'section-'.$this_section);
$extra_headers = ''; $extra_headers = '';
@ -352,13 +379,8 @@ class Template extends Smarty {
} }
} }
} }
$this->assign('favico', $favico);
/*global $my_session_id;
$session_id = api_get_session_id();
$session_name = api_get_session_name($my_session_id);
*/
$this->assign('favico', $favico);
$help_content = ''; $help_content = '';
if (api_get_setting('enable_help_link') == 'true') { if (api_get_setting('enable_help_link') == 'true') {
if (!empty($help)) { if (!empty($help)) {
@ -382,16 +404,6 @@ class Template extends Smarty {
$this->assign('bug_notification_link', $bug_notification_link); $this->assign('bug_notification_link', $bug_notification_link);
if (isset($database_connection)) {
// connect to the main database.
Database::select_db($_configuration['main_database'], $database_connection);
}
ob_start();
show_header_1($language_file, $nameTools);
$header1 = ob_get_contents();
ob_clean();
ob_start(); ob_start();
show_header_2(); show_header_2();
$header2 = ob_get_contents(); $header2 = ob_get_contents();
@ -400,7 +412,7 @@ class Template extends Smarty {
$header3 = show_header_3(); $header3 = show_header_3();
$header4 = show_header_4($interbreadcrumb, $language_file, $nameTools); $header4 = show_header_4($interbreadcrumb, $language_file, $nameTools);
$this->assign('header1', $header1);
$this->assign('header2', $header2); $this->assign('header2', $header2);
$this->assign('header3', $header3); $this->assign('header3', $header3);
$this->assign('header4', $header4); $this->assign('header4', $header4);
@ -447,12 +459,12 @@ class Template extends Smarty {
$this->assign('execution_stats', $stats); $this->assign('execution_stats', $stats);
} }
function show_header() { function show_header_template() {
$tpl = $this->get_template('layout/show_header.tpl'); $tpl = $this->get_template('layout/show_header.tpl');
$this->display($tpl); $this->display($tpl);
} }
function show_footer() { function show_footer_template() {
$tpl = $this->get_template('layout/show_footer.tpl'); $tpl = $this->get_template('layout/show_footer.tpl');
$this->display($tpl); $this->display($tpl);
} }

@ -60,7 +60,7 @@
<li><a href="{$_p.web_main}social/invitations.php">{"PendingInvitations"|get_lang}</a></li> <li><a href="{$_p.web_main}social/invitations.php">{"PendingInvitations"|get_lang}</a></li>
</ul> </ul>
</li> </li>
<li><a href="{$_p.web}index.php?logout=logout">Logout</a></li> <li><a href="{$_p.web}index.php?logout=logout">{"Logout"|get_lang}</a></li>
</ul> </ul>
{/if} {/if}
</div> </div>

@ -4,7 +4,7 @@
{$help_content} {$help_content}
{$bug_notification_link} {$bug_notification_link}
</ul> </ul>
{block name="header"}{/block} {include file="default/layout/header.tpl"}
<div id="main"> <div id="main">
{* breadcrumb *} {* breadcrumb *}

Loading…
Cancel
Save