Improving settings save button

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

@ -106,7 +106,6 @@ function handle_plugins() {
$all_plugins = $plugin_obj->read_plugins_from_path(); $all_plugins = $plugin_obj->read_plugins_from_path();
$installed_plugins = $plugin_obj->get_installed_plugins(); $installed_plugins = $plugin_obj->get_installed_plugins();
//Plugins NOT installed //Plugins NOT installed
echo Display::page_subheader(get_lang('Plugins')); echo Display::page_subheader(get_lang('Plugins'));
echo '<form name="plugins" method="post" action="'.api_get_self().'?category='.Security::remove_XSS($_GET['category']).'">'; 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'); 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 * Updates the gradebook score custom values using the scoredisplay class of the
* gradebook module * gradebook module
@ -1040,23 +1052,11 @@ function generate_settings_form($settings, $settings_by_access_list) {
$form ->addElement('hidden', 'search_field', Security::remove_XSS($_GET['search_field'])); $form ->addElement('hidden', 'search_field', Security::remove_XSS($_GET['search_field']));
$default_values = array(); $default_values = array();
$count_settings = count($settings);
$i = 0;
foreach ($settings as $row) { foreach ($settings as $row) {
if (in_array($row['variable'], array_keys($settings_to_avoid))) { continue; } 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 ( $_configuration['multiple_access_urls']) {
if (api_is_global_platform_admin()) { if (api_is_global_platform_admin()) {
if ($row['access_url_locked'] == 0) { if ($row['access_url_locked'] == 0) {
@ -1221,11 +1221,11 @@ function generate_settings_form($settings, $settings_by_access_list) {
case 'link': case 'link':
$form->addElement('static', null, array(get_lang($row['title']), get_lang($row['comment'])), get_lang('CurrentValue').' : '.$row['selected_value'], $hideme); $form->addElement('static', null, array(get_lang($row['title']), get_lang($row['comment'])), get_lang('CurrentValue').' : '.$row['selected_value'], $hideme);
break; break;
case 'select':
/* /*
* 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. * 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. * The functions being called must be added to the file settings.lib.php.
*/ */
case 'select':
$form->addElement('select', $row['variable'], array(get_lang($row['title']), get_lang($row['comment'])), call_user_func('select_'.$row['variable']), $hideme); $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']; $default_values[$row['variable']] = $row['selected_value'];
break; break;
@ -1233,7 +1233,8 @@ function generate_settings_form($settings, $settings_by_access_list) {
break; break;
} }
if ($row['variable'] == 'pdf_export_watermark_enable') { switch ($row['variable']) {
case 'pdf_export_watermark_enable':
$url = PDF::get_watermark($course_code); $url = PDF::get_watermark($course_code);
$form->addElement('file', 'pdf_export_watermark_path', get_lang('AddWaterMark')); $form->addElement('file', 'pdf_export_watermark_path', get_lang('AddWaterMark'));
if ($url != false) { if ($url != false) {
@ -1242,25 +1243,27 @@ function generate_settings_form($settings, $settings_by_access_list) {
} }
$allowed_picture_types = array ('jpg', 'jpeg', 'png', 'gif'); $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); $form->addRule('pdf_export_watermark_path', get_lang('OnlyImagesAllowed').' ('.implode(',', $allowed_picture_types).')', 'filetype', $allowed_picture_types);
} break;
case 'timezone_value':
if ($row['variable'] == 'timezone_value') {
$timezone = $row['selected_value']; $timezone = $row['selected_value'];
if (empty($timezone)) { if (empty($timezone)) {
$timezone = _api_get_timezone(); $timezone = _api_get_timezone();
} }
$form->addElement('html', sprintf(get_lang('LocalTimeUsingPortalTimezoneXIsY'), $timezone, api_get_local_time())); $form->addElement('html', sprintf(get_lang('LocalTimeUsingPortalTimezoneXIsY'), $timezone, api_get_local_time()));
break;
} }
} } // end for
if (!empty($settings)) { 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>');
$form->setDefaults($default_values); $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;
} }
/** /**

@ -3831,3 +3831,24 @@ footer {
text-decoration: none; text-decoration: none;
font-weight: normal; 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(); 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 settings
Twig_Autoloader::register(); 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_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')); $this->twig->addFilter('display_page_subheader', new Twig_Filter_Function('Display::page_subheader_and_translate'));
/* /*
$lexer = new Twig_Lexer($this->twig, array( $lexer = new Twig_Lexer($this->twig, array(
//'tag_comment' => array('{*', '*}'), //'tag_comment' => array('{*', '*}'),
@ -87,6 +85,7 @@ class Template {
//Page title //Page title
$this->title = $title; $this->title = $title;
$this->show_learnpath = $show_learnpath; $this->show_learnpath = $show_learnpath;
$this->hide_global_chat = $hide_global_chat;
//Setting system variables //Setting system variables
$this->set_system_parameters(); $this->set_system_parameters();
@ -418,12 +417,10 @@ class Template {
if (api_get_setting('allow_global_chat') == 'true') { if (api_get_setting('allow_global_chat') == 'true') {
if (!api_is_anonymous()) { if (!api_is_anonymous()) {
//Do not include the global chat in LP //Do not include the global chat in LP
if ($this->show_learnpath == false) { if ($this->show_learnpath == false && $this->show_footer == true && $this->hide_global_chat == false) {
if ($this->show_footer == true) {
$js_files[] = 'chat/js/chat.js'; $js_files[] = 'chat/js/chat.js';
} }
} }
}
} }
if (api_get_setting('accessibility_font_resize') == 'true') { if (api_get_setting('accessibility_font_resize') == 'true') {

@ -27,7 +27,7 @@
{{ css_style_print }} {{ css_style_print }}
/*]]>*/ /*]]>*/
</style> </style>
<script type="text/javascript"> <script>
//<![CDATA[ //<![CDATA[
// This is a patch for the "__flash__removeCallback" bug, see FS#4378. // This is a patch for the "__flash__removeCallback" bug, see FS#4378.
{% raw %} {% raw %}
@ -58,9 +58,7 @@ var disconnect_lang = '{{"ChatDisconnected"|get_lang}}';
{{ css_file_to_string}} {{ css_file_to_string}}
{{ extra_headers}} {{ extra_headers}}
<script type="text/javascript"> <script>
function get_url_params(q, attribute) { function get_url_params(q, attribute) {
var vars; var vars;
var hash; var hash;
@ -76,6 +74,7 @@ function get_url_params(q, attribute) {
} }
$(document).scroll(function() { $(document).scroll(function() {
// Top bar scroll effect // Top bar scroll effect
if ($('body').width() > 959) { if ($('body').width() > 959) {
if ($('.subnav').length) { if ($('.subnav').length) {
@ -95,6 +94,7 @@ $(document).scroll(function() {
} }
} }
//Admin -> Settings toolbar
if ($('.new_actions').length) { if ($('.new_actions').length) {
if (!$('.new_actions').attr('data-top')) { if (!$('.new_actions').attr('data-top')) {
@ -109,22 +109,54 @@ $(document).scroll(function() {
} }
$('.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()) { if ($('.new_actions').attr('data-top') - $('.new_actions').outerHeight() <= $(this).scrollTop()) {
$('.new_actions').addClass('new_actions-fixed'); $('.new_actions').addClass('new_actions-fixed');
} else { } else {
$('.new_actions').removeClass('new_actions-fixed'); $('.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 //Removes the yellow input in Chrome
if (navigator.userAgent.toLowerCase().indexOf("chrome") >= 0) { if (navigator.userAgent.toLowerCase().indexOf("chrome") >= 0) {
@ -144,6 +176,7 @@ $(document).ready(function() {
$("button").addClass('btn'); $("button").addClass('btn');
} }
//Dropdown effect //Dropdown effect
$('.dropdown-toggle').dropdown(); $('.dropdown-toggle').dropdown();
@ -197,7 +230,6 @@ $(document).ready(function() {
$('#navigation a').stop().animate({ $('#navigation a').stop().animate({
'marginLeft':'50px' 'marginLeft':'50px'
},1000); },1000);
$('#navigation > li').hover( $('#navigation > li').hover(
function () { function () {
$('a',$(this)).stop().animate({ $('a',$(this)).stop().animate({

Loading…
Cancel
Save