Improving settings save button

skala
Julio Montoya 13 years ago
parent 2001dd110d
commit e1d616365c
  1. 97
      main/admin/settings.lib.php
  2. 4
      main/admin/settings.php
  3. 21
      main/css/base.css
  4. 11
      main/inc/lib/template.lib.php
  5. 60
      main/template/default/layout/head.tpl

@ -106,7 +106,6 @@ function handle_plugins() {
$all_plugins = $plugin_obj->read_plugins_from_path();
$installed_plugins = $plugin_obj->get_installed_plugins();
//Plugins NOT installed
echo Display::page_subheader(get_lang('Plugins'));
echo '<form name="plugins" method="post" action="'.api_get_self().'?category='.Security::remove_XSS($_GET['category']).'">';
@ -1008,6 +1007,19 @@ function select_gradebook_number_decimals() {
return array('0', '1', '2');
}
function select_gradebook_default_grade_model_id() {
$grade_model = new GradeModel();
$models = $grade_model->get_all();
$options = array();
$options[-1] = get_lang('None');
if (!empty($models)) {
foreach ($models as $model) {
$options[$model['id']] = $model['name'];
}
}
return $options;
}
/**
* Updates the gradebook score custom values using the scoredisplay class of the
* gradebook module
@ -1039,24 +1051,12 @@ function generate_settings_form($settings, $settings_by_access_list) {
$form = new FormValidator('settings', 'post', 'settings.php?category='.Security::remove_XSS($_GET['category']));
$form ->addElement('hidden', 'search_field', Security::remove_XSS($_GET['search_field']));
$default_values = array();
$count_settings = count($settings);
$default_values = array();
foreach ($settings as $row) {
if (in_array($row['variable'], array_keys($settings_to_avoid))) { continue; }
$i = 0;
foreach ($settings as $row) {
if (in_array($row['variable'], array_keys($settings_to_avoid))) { continue; }
$anchor_name = $row['variable'].(!empty($row['subkey']) ? '_'.$row['subkey'] : '');
$form->addElement('html',"\n<a name=\"$anchor_name\"></a>\n");
($count_settings % 10) < 5 ? $b = $count_settings - 10 : $b = $count_settings;
if ($i % 10 == 0 and $i < $b AND $i != 0) {
$form->addElement('html', '<div align="right">');
$form->addElement('style_submit_button', null, get_lang('SaveSettings'), 'class="save"');
$form->addElement('html', '</div>');
}
$i++;
if ( $_configuration['multiple_access_urls']) {
if (api_is_global_platform_admin()) {
if ($row['access_url_locked'] == 0) {
@ -1220,47 +1220,50 @@ function generate_settings_form($settings, $settings_by_access_list) {
break;
case 'link':
$form->addElement('static', null, array(get_lang($row['title']), get_lang($row['comment'])), get_lang('CurrentValue').' : '.$row['selected_value'], $hideme);
break;
/*
* To populate its list of options, the select type dynamically calls a function that must be called select_ + the name of the variable being displayed.
* The functions being called must be added to the file settings.lib.php.
*/
break;
case 'select':
/*
* To populate the list of options, the select type dynamically calls a function that must be called select_ + the name of the variable being displayed.
* The functions being called must be added to the file settings.lib.php.
*/
$form->addElement('select', $row['variable'], array(get_lang($row['title']), get_lang($row['comment'])), call_user_func('select_'.$row['variable']), $hideme);
$default_values[$row['variable']] = $row['selected_value'];
break;
case 'custom':
break;
}
if ($row['variable'] == 'pdf_export_watermark_enable') {
$url = PDF::get_watermark($course_code);
$form->addElement('file', 'pdf_export_watermark_path', get_lang('AddWaterMark'));
if ($url != false) {
$delete_url = '<a href="?delete_watermark">'.Display::return_icon('delete.png',get_lang('DelImage')).'</a>';
$form->addElement('html', '<a href="'.$url.'">'.$url.' '.$delete_url.'</a>');
}
$allowed_picture_types = array ('jpg', 'jpeg', 'png', 'gif');
$form->addRule('pdf_export_watermark_path', get_lang('OnlyImagesAllowed').' ('.implode(',', $allowed_picture_types).')', 'filetype', $allowed_picture_types);
}
if ($row['variable'] == 'timezone_value') {
$timezone = $row['selected_value'];
if (empty($timezone)) {
$timezone = _api_get_timezone();
}
$form->addElement('html', sprintf(get_lang('LocalTimeUsingPortalTimezoneXIsY'), $timezone, api_get_local_time()));
}
}
switch ($row['variable']) {
case 'pdf_export_watermark_enable':
$url = PDF::get_watermark($course_code);
$form->addElement('file', 'pdf_export_watermark_path', get_lang('AddWaterMark'));
if ($url != false) {
$delete_url = '<a href="?delete_watermark">'.Display::return_icon('delete.png',get_lang('DelImage')).'</a>';
$form->addElement('html', '<a href="'.$url.'">'.$url.' '.$delete_url.'</a>');
}
$allowed_picture_types = array ('jpg', 'jpeg', 'png', 'gif');
$form->addRule('pdf_export_watermark_path', get_lang('OnlyImagesAllowed').' ('.implode(',', $allowed_picture_types).')', 'filetype', $allowed_picture_types);
break;
case 'timezone_value':
$timezone = $row['selected_value'];
if (empty($timezone)) {
$timezone = _api_get_timezone();
}
$form->addElement('html', sprintf(get_lang('LocalTimeUsingPortalTimezoneXIsY'), $timezone, api_get_local_time()));
break;
}
} // end for
if (!empty($settings)) {
$form->addElement('html', '<div style="text-align: right; clear: both;">');
$form->addElement('style_submit_button', null, get_lang('SaveSettings'), 'class="save"');
$form->addElement('html', '</div>');
if (!empty($settings)) {
$form->setDefaults($default_values);
}
return $form;
$form->addElement('html', '<div class="bottom_actions">');
$form->addElement('style_submit_button', null, get_lang('SaveSettings'), 'class="save"');
$form->addElement('html', '</div>');
return $form;
}
/**

@ -180,8 +180,8 @@ if (!empty($_GET['category']) && !in_array($_GET['category'], array('Plugins', '
// Treat gradebook values in separate function.
//if (strpos($key, 'gradebook_score_display_custom_values') === false) {
if (!is_array($value)) {
$old_value = api_get_setting($key);
switch ($key) {
$old_value = api_get_setting($key);
switch ($key) {
case 'header_extra_content':
file_put_contents(api_get_path(SYS_PATH).api_get_home_path().'/header_extra_content.txt', $value);
$value = api_get_home_path().'/header_extra_content.txt';

@ -3831,3 +3831,24 @@ footer {
text-decoration: none;
font-weight: normal;
}
.bottom_actions {
background:#efefef;
border:1px solid #ccc;
padding:10px;
vertical-align:middle;
display: block;
width: 100%;
}
.bottom_actions_fixed {
position: fixed;
z-index: 9001;
bottom: 0;
left: 0px;
}

@ -29,7 +29,7 @@ class Template {
var $params = array();
function __construct($title = '', $show_header = true, $show_footer = true, $show_learnpath = false) {
function __construct($title = '', $show_header = true, $show_footer = true, $show_learnpath = false, $hide_global_chat = false) {
//Twig settings
Twig_Autoloader::register();
@ -73,8 +73,6 @@ class Template {
$this->twig->addFilter('display_page_header', new Twig_Filter_Function('Display::page_header_and_translate'));
$this->twig->addFilter('display_page_subheader', new Twig_Filter_Function('Display::page_subheader_and_translate'));
/*
$lexer = new Twig_Lexer($this->twig, array(
//'tag_comment' => array('{*', '*}'),
@ -87,6 +85,7 @@ class Template {
//Page title
$this->title = $title;
$this->show_learnpath = $show_learnpath;
$this->hide_global_chat = $hide_global_chat;
//Setting system variables
$this->set_system_parameters();
@ -418,10 +417,8 @@ class Template {
if (api_get_setting('allow_global_chat') == 'true') {
if (!api_is_anonymous()) {
//Do not include the global chat in LP
if ($this->show_learnpath == false) {
if ($this->show_footer == true) {
$js_files[] = 'chat/js/chat.js';
}
if ($this->show_learnpath == false && $this->show_footer == true && $this->hide_global_chat == false) {
$js_files[] = 'chat/js/chat.js';
}
}
}

@ -27,7 +27,7 @@
{{ css_style_print }}
/*]]>*/
</style>
<script type="text/javascript">
<script>
//<![CDATA[
// This is a patch for the "__flash__removeCallback" bug, see FS#4378.
{% raw %}
@ -58,9 +58,7 @@ var disconnect_lang = '{{"ChatDisconnected"|get_lang}}';
{{ css_file_to_string}}
{{ extra_headers}}
<script type="text/javascript">
<script>
function get_url_params(q, attribute) {
var vars;
var hash;
@ -76,6 +74,7 @@ function get_url_params(q, attribute) {
}
$(document).scroll(function() {
// Top bar scroll effect
if ($('body').width() > 959) {
if ($('.subnav').length) {
@ -95,6 +94,7 @@ $(document).scroll(function() {
}
}
//Admin -> Settings toolbar
if ($('.new_actions').length) {
if (!$('.new_actions').attr('data-top')) {
@ -108,23 +108,55 @@ $(document).scroll(function() {
more_top = 50;
}
$('.new_actions').attr('data-top', offset.top + more_top);
$('.new_actions').attr('data-top', offset.top + more_top);
}
if ($('.new_actions').attr('data-top') - $('.new_actions').outerHeight() <= $(this).scrollTop()) {
$('.new_actions').addClass('new_actions-fixed');
$('.new_actions').addClass('new_actions-fixed');
} else {
$('.new_actions').removeClass('new_actions-fixed');
}
}
//Bottom actions
if ($('.bottom_actions').length) {
if (!$('.bottom_actions').attr('data-top')) {
// If already fixed, then do nothing
if ($('.bottom_actions').hasClass('bottom_actions_fixed')) return;
// Remember top position
var offset = $('.bottom_actions').offset();
$('.bottom_actions').attr('data-top', offset.top);
}
if ($('.bottom_actions').attr('data-top') > $('body').outerHeight()) {
if ( ($('.bottom_actions').attr('data-top') - $('body').outerHeight() - $('.bottom_actions').outerHeight()) >= $(this).scrollTop()) {
$('.bottom_actions').addClass('bottom_actions_fixed');
} else {
$('.bottom_actions').removeClass('bottom_actions_fixed');
}
} else {
if ( ($('.bottom_actions').attr('data-top') - $('.bottom_actions').outerHeight()) <= $(this).scrollTop()) {
$('.bottom_actions').addClass('bottom_actions_fixed');
} else {
$('.bottom_actions').removeClass('bottom_actions_fixed');
}
}
}
});
$(document).ready(function() {
function isScrolledIntoView(elem) {
var docViewTop = $(window).scrollTop();
var docViewBottom = docViewTop + $(window).height();
var elemTop = $(elem).offset().top;
var elemBottom = elemTop + $(elem).height();
return ((elemBottom <= docViewBottom) && (elemTop >= docViewTop));
}
$(function() {
//Removes the yellow input in Chrome
if (navigator.userAgent.toLowerCase().indexOf("chrome") >= 0) {
@ -142,7 +174,8 @@ $(document).ready(function() {
//Fixes buttons to the new btn class
if (!$('#button').hasClass('btn')) {
$("button").addClass('btn');
}
}
//Dropdown effect
$('.dropdown-toggle').dropdown();
@ -196,8 +229,7 @@ $(document).ready(function() {
//old jquery.menu.js
$('#navigation a').stop().animate({
'marginLeft':'50px'
},1000);
},1000);
$('#navigation > li').hover(
function () {
$('a',$(this)).stop().animate({

Loading…
Cancel
Save