Fixing stylesheet in order to preview the all page

skala
Julio Montoya 13 years ago
parent ed6da65ffa
commit 7e552e7ec9
  1. 30
      main/admin/settings.lib.php
  2. 7
      main/admin/settings.php
  3. 2
      main/admin/style_preview.php
  4. 6
      main/css/base_chamilo.css
  5. 93
      main/inc/lib/banner.lib.php
  6. 87
      main/inc/lib/display.lib.php
  7. 120
      main/inc/lib/template.lib.php
  8. 2
      main/template/default/layout/header.tpl
  9. 2
      main/template/default/layout/main.tpl
  10. 4
      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">
function load_preview(selectobj){
var style_dir = selectobj.options[selectobj.selectedIndex].value;
parent.preview.location='style_preview.php?style=' + style_dir;
function load_preview(){
$('#stylesheets_id').submit();
}
</script>
<?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)" >';
$list_of_styles = array();
@ -245,12 +241,17 @@ function handle_stylesheets() {
continue;
}
$dirpath = api_get_path(SYS_PATH).'main/css/'.$style_dir;
if (is_dir($dirpath)) {
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 {
$selected = '';
if (!isset($_POST['style']) && ($currentstyle == $style_dir || ($style_dir == 'chamilo' && !$currentstyle))) {
$selected = 'selected="true"';
} else {
$selected = '';
}
}
$show_name = ucwords(str_replace('_', ' ', $style_dir));
@ -269,6 +270,7 @@ function handle_stylesheets() {
}
@closedir($handle);
}
//Sort styles in alphabetical order
asort($list_of_names);
foreach($list_of_names as $style_dir=>$item) {
@ -452,16 +454,8 @@ function store_stylesheets() {
// Insert the stylesheet.
$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);
*/
api_set_setting('stylesheets', $style, null, 'stylesheets', $_configuration['access_url']);
}

@ -57,6 +57,11 @@ if (isset($_POST['submit_stylesheets'])) {
exit;
}
if (isset($_POST['style'])) {
Display::$preview_style = $_POST['style'];
}
// Database table definitions.
$table_settings_current = Database :: get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
@ -763,4 +768,4 @@ if (!empty($_GET['category'])) {
}
/* FOOTER */
Display :: display_footer();
Display :: display_footer();

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

@ -2526,11 +2526,7 @@ span.form_required {
-moz-border-radius: 0;
border-radius: 0;
}
/* Subnav */
.subnav {
width: 100%;

@ -110,64 +110,45 @@ function get_tabs() {
return $navigation;
}
function show_header_1($language_file, $nameTools) {
global $noPHP_SELF;
$_course = api_get_course_info();
function show_header_1($language_file, $nameTools, $theme) {
global $noPHP_SELF;
$_course = api_get_course_info();
echo '<div id="header1">';
$logo = api_get_path(SYS_CODE_PATH).'css/'.api_get_visual_theme().'/images/header-logo.png';
$site_name = api_get_setting('siteName');
if (file_exists($logo)) {
$site_name = api_get_setting('Institution').' - '.$site_name;
echo '<div id="logo">';
$image_url = api_get_path(WEB_CSS_PATH).api_get_visual_theme().'/images/header-logo.png';
$logo = Display::img($image_url, $site_name, array('title'=>$site_name));
echo Display::url($logo, api_get_path(WEB_PATH).'index.php');
echo '</div>';
} else {
echo '<a href="'.api_get_path(WEB_PATH).'index.php" target="_top">'.$site_name.'</a>';
$iurl = api_get_setting('InstitutionUrl');
$iname = api_get_setting('Institution');
if (!empty($iname)) {
echo '-&nbsp;<a href="'.$iurl.'" target="_top">'.$iname.'</a>';
}
// External link section a.k.a Department - Department URL
if (isset($_course['extLink']) && $_course['extLink']['name'] != '') {
echo '<span class="extLinkSeparator"> - </span>';
if ($_course['extLink']['url'] != '') {
echo '<a class="extLink" href="'.$_course['extLink']['url'].'" target="_top">';
echo $_course['extLink']['name'];
echo '</a>';
} else {
echo $_course['extLink']['name'];
}
}
}
$logo = api_get_path(SYS_CODE_PATH).'css/'.$theme.'/images/header-logo.png';
$site_name = api_get_setting('siteName');
if (file_exists($logo)) {
$site_name = api_get_setting('Institution').' - '.$site_name;
echo '<div id="logo">';
$image_url = api_get_path(WEB_CSS_PATH).$theme.'/images/header-logo.png';
$logo = Display::img($image_url, $site_name, array('title'=>$site_name));
echo Display::url($logo, api_get_path(WEB_PATH).'index.php');
echo '</div>';
} else {
echo '<a href="'.api_get_path(WEB_PATH).'index.php" target="_top">'.$site_name.'</a>';
$iurl = api_get_setting('InstitutionUrl');
$iname = api_get_setting('Institution');
if (!empty($iname)) {
echo '-&nbsp;<a href="'.$iurl.'" target="_top">'.$iname.'</a>';
}
// External link section a.k.a Department - Department URL
if (isset($_course['extLink']) && $_course['extLink']['name'] != '') {
echo '<span class="extLinkSeparator"> - </span>';
if ($_course['extLink']['url'] != '') {
echo '<a class="extLink" href="'.$_course['extLink']['url'].'" target="_top">';
echo $_course['extLink']['name'];
echo '</a>';
} else {
echo $_course['extLink']['name'];
}
}
}
/* Course title section */
/* Course title section */
if (!empty($_cid) and $_cid != -1 and isset($_course)) {
//Put the name of the course in the header
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 id="my_courses">';
echo '</div>';
} elseif (isset($nameTools) && $language_file != 'course_home') {
//Put the name of the user-tools in the header
@ -178,16 +159,12 @@ function show_header_1($language_file, $nameTools) {
} else {
echo '<div id="my_courses">'.$nameTools.'</div>';
}
} else {
//echo '<div id="my_courses"></div>';
}
echo '<div id="plugin-header">';
api_plugin('header');
echo '</div>';
//Don't let the header disappear if there's nothing on the left
//echo '<div class="clear">&nbsp;</div>';
echo '</div>';
}

@ -26,12 +26,59 @@ define('MAX_LENGTH_BREADCRUMB', 100);
*/
class Display {
/* The main template*/
static $global_template;
static $preview_style = null;
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.
*
@ -375,43 +422,7 @@ class Display {
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).

@ -1,5 +1,11 @@
<?php
/* For licensing terms, see /license.txt */
/*
* @author Julio Montoya <gugli100@gmail.com>
*
**/
/* @todo order class */
// Load Smarty library
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 {
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 $show_header;
var $show_footer;
@ -122,7 +130,7 @@ class Template extends Smarty {
* Sets the header visibility
* @param bool true if we show the header
*/
function set_header($status) {
function set_header($status) {
$this->show_header = $status;
$this->assign('show_header', $status);
@ -191,14 +199,53 @@ class Template extends Smarty {
'site_name' => api_get_setting('siteName'),
'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() {
$help = $this->help;
$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,
$_cid, $interbreadcrumb, $charset, $language_file, $noPHP_SELF;
@ -244,29 +291,10 @@ class Template extends Smarty {
}
$this->assign('title_string', $title_string);
$platform_theme = api_get_setting('stylesheets');
$my_style = api_get_visual_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);
//Setting the theme
$this->set_theme();
//Extra JS files
$js_files = array(
@ -279,8 +307,7 @@ class Template extends Smarty {
'bootstrap/bootstrap-dropdown.js'
);
if (api_get_setting('allow_global_chat') == 'true') {
if (api_get_setting('allow_global_chat') == 'true') {
if (!api_is_anonymous()) {
$js_files[] = 'chat/js/chat.js';
}
@ -309,7 +336,7 @@ class Template extends Smarty {
);
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') {
@ -317,15 +344,15 @@ class Template extends Smarty {
}
$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);
}
global $this_section;
$this->assign('css_file_to_string', $css_file_to_string);
$this->assign('js_file_to_string', $js_file_to_string);
$this->assign('text_direction', api_get_text_direction());
$this->assign('style_print', $style_print);
$this->assign('text_direction', api_get_text_direction());
$this->assign('section_name', 'section-'.$this_section);
$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 = '';
if (api_get_setting('enable_help_link') == 'true') {
if (!empty($help)) {
@ -381,17 +403,7 @@ class Template extends Smarty {
}
$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();
show_header_2();
$header2 = ob_get_contents();
@ -400,7 +412,7 @@ class Template extends Smarty {
$header3 = show_header_3();
$header4 = show_header_4($interbreadcrumb, $language_file, $nameTools);
$this->assign('header1', $header1);
$this->assign('header2', $header2);
$this->assign('header3', $header3);
$this->assign('header4', $header4);
@ -447,12 +459,12 @@ class Template extends Smarty {
$this->assign('execution_stats', $stats);
}
function show_header() {
$tpl = $this->get_template('layout/show_header.tpl');
function show_header_template() {
$tpl = $this->get_template('layout/show_header.tpl');
$this->display($tpl);
}
function show_footer() {
function show_footer_template() {
$tpl = $this->get_template('layout/show_footer.tpl');
$this->display($tpl);
}

@ -60,7 +60,7 @@
<li><a href="{$_p.web_main}social/invitations.php">{"PendingInvitations"|get_lang}</a></li>
</ul>
</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>
{/if}
</div>

@ -2,7 +2,7 @@
{include file="default/layout/main_pre_content.tpl"}
{block name="body"}{/block}
{block name="body"}{/block}
{include file="default/layout/main_post_content.tpl"}

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

Loading…
Cancel
Save