[svn r14307] Added user theme selection in user's profile (includes creating api_get_themes() in main_api and corresponding select list in FormValidator). Implements part of FS#2204

skala
Yannick Warnier 18 years ago
parent e46199593f
commit 52d58d47e0
  1. 4
      main/admin/settings.php
  2. 13
      main/auth/profile.php
  3. 10
      main/inc/header.inc.php
  4. 46
      main/inc/lib/formvalidator/Element/select_theme.php
  5. 1
      main/inc/lib/formvalidator/FormValidator.class.php
  6. 35
      main/inc/lib/main_api.lib.php
  7. 1
      main/inc/local.inc.php

@ -1,10 +1,10 @@
<?php
// $Id: settings.php 13767 2007-11-25 05:24:37Z yannoo $
// $Id: settings.php 14307 2008-02-18 17:12:29Z yannoo $
/*
==============================================================================
Dokeos - elearning and course management software
Copyright (c) 2004-2005 Dokeos S.A.
Copyright (c) 2004-2008 Dokeos S.A.
Copyright (c) 2003 Ghent University
Copyright (c) Patrick Cool, Ghent University
Copyright (c) Roan Embrechts, Vrije Universiteit Brussel

@ -1,5 +1,5 @@
<?php
// $Id: profile.php 14305 2008-02-17 21:21:42Z yannoo $
// $Id: profile.php 14307 2008-02-18 17:12:29Z yannoo $
/*
==============================================================================
Dokeos - elearning and course management software
@ -158,7 +158,7 @@ if (api_get_setting('registration', 'email') == 'true')
$form->addRule('email', get_lang('EmailWrong'), 'email');
// OPENID URL
if(api_get_setting('openid_authentication')=='true')
if(is_profile_editable() && api_get_setting('openid_authentication')=='true')
{
$form->addElement('text', 'openid', get_lang('OpenIDURL'), array('size' => 40));
if (api_get_setting('profile', 'openid') !== 'true')
@ -247,6 +247,15 @@ if (is_profile_editable() && api_get_setting('profile', 'password') == 'true')
if (CHECK_PASS_EASY_TO_FIND)
$form->addRule('password1', get_lang('PassTooEasy').': '.api_generate_password(), 'callback', 'api_check_password');
}
if (is_profile_editable() && api_get_setting('user_selected_theme') == 'true')
{
$form->addElement('select_theme', 'theme', get_lang('Theme'));
if (api_get_setting('profile', 'theme') !== 'true')
$form->freeze('theme');
$form->applyFilter('theme', 'trim');
//if (api_get_setting('registration', 'openid') == 'true')
// $form->addRule('openid', get_lang('ThisFieldIsRequired'), 'required');
}
// SUBMIT
if (is_profile_editable())

@ -74,6 +74,16 @@ echo get_setting('siteName');
/*<![CDATA[*/
<?php
$my_style = api_get_setting('stylesheets');
if(api_get_setting('user_selected_theme') == 'true')
{
$useri = api_get_user_info();
$theme = $useri['theme'];
error_log('Theme is now: '.$theme.' while $my_style is now: '.$my_style,0);
if(!empty($theme) && $theme != $my_style)
{
$my_style = $theme;
}
}
$my_code_path = api_get_path(WEB_CODE_PATH);
if(empty($my_style)){$my_style = 'default';}
echo '@import "'.$my_code_path.'css/'.$my_style.'/default.css";'."\n";

@ -0,0 +1,46 @@
<?php
// $Id: $
/*
==============================================================================
Dokeos - elearning and course management software
Copyright (c) 2004-2008 Dokeos S.A.
Copyright (c) Bart Mollet, Hogeschool Gent
For a full list of contributors, see "credits.txt".
The full license can be read in "license.txt".
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
See the GNU General Public License for more details.
Contact address: Dokeos, 44 rue des palais, B-1030 Brussels, Belgium
Mail: info@dokeos.com
==============================================================================
*/
require_once ('HTML/QuickForm/select.php');
/**
* A dropdownlist with all themes to use with QuickForm
*/
class HTML_QuickForm_Select_Theme extends HTML_QuickForm_select
{
/**
* Class constructor
*/
function HTML_QuickForm_Select_Theme($elementName=null, $elementLabel=null, $options=null, $attributes=null)
{
parent::HTML_QuickForm_Select($elementName, $elementLabel, $options, $attributes);
// Get all languages
$themes = api_get_themes();
$this->_options = array();
$this->_values = array();
foreach ($themes as $theme)
{
$this->addOption($theme,$theme);
}
}
}
?>

@ -57,6 +57,7 @@ class FormValidator extends HTML_QuickForm
$this->registerElementType('datepicker', $dir.'Element/datepicker.php', 'HTML_QuickForm_datepicker');
$this->registerElementType('receivers', $dir.'Element/receivers.php', 'HTML_QuickForm_receivers');
$this->registerElementType('select_language', $dir.'Element/select_language.php', 'HTML_QuickForm_Select_Language');
$this->registerElementType('select_theme', $dir.'Element/select_theme.php', 'HTML_QuickForm_Select_Theme');
$this->registerRule('date', null, 'HTML_QuickForm_Rule_Date', $dir.'Rule/Date.php');
$this->registerRule('date_compare', null, 'HTML_QuickForm_Rule_DateCompare', $dir.'Rule/DateCompare.php');
$this->registerRule('html',null,'HTML_QuickForm_Rule_HTML',$dir.'Rule/HTML.php');

@ -444,6 +444,7 @@ function api_get_user_info($user_id = '')
$user_info['status'] = $result_array['status'];
$user_info['auth_source'] = $result_array['auth_source'];
$user_info['username'] = $result_array['username'];
$user_info['theme'] = $result_array['theme'];
return $user_info;
}
return false;
@ -1818,6 +1819,40 @@ function api_get_languages()
return $language_list;
}
/**
* Returns a list of CSS themes currently available in the CSS folder
* @return array List of themes directories from the css folder
*/
function api_get_themes()
{
$cssdir = api_get_path(SYS_PATH).'main/css/';
$list = array();
if (is_dir($cssdir))
{
$themes = scandir($cssdir);
if($themes !== false)
{
sort($themes);
foreach($themes as $theme)
{
if(substr($theme,0,1)=='.')
{
//ignore
continue;
}
else
{
if(is_dir($cssdir.$theme))
{
$list[] = $theme;
}
}
}
}
}
return $list;
}
/*
==============================================================================
WYSIWYG HTML AREA

@ -527,6 +527,7 @@ $admin_table = Database::get_main_table(TABLE_MAIN_ADMIN);
$_user ['user_id'] = $uData ['user_id'];
$_user ['language'] = $uData ['language'];
$_user ['auth_source'] = $uData ['auth_source'];
$_user ['theme'] = $uData ['theme'];
$is_platformAdmin = (bool) (! is_null( $uData['is_admin']));
$is_allowedCreateCourse = (bool) ($uData ['status'] == 1);

Loading…
Cancel
Save