|
|
@ -143,7 +143,6 @@ function handle_plugins() { |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
echo '<tr>'; |
|
|
|
echo '<tr>'; |
|
|
|
} |
|
|
|
} |
|
|
|
//echo '<tr>'; |
|
|
|
|
|
|
|
echo '<td>'; |
|
|
|
echo '<td>'; |
|
|
|
//Checkbox |
|
|
|
//Checkbox |
|
|
|
if (in_array($plugin, $installed_plugins)) { |
|
|
|
if (in_array($plugin, $installed_plugins)) { |
|
|
@ -177,7 +176,6 @@ function handle_plugins() { |
|
|
|
echo '<button class="save" type="submit" name="submit_plugins">'.get_lang('EnablePlugins').'</button>'; |
|
|
|
echo '<button class="save" type="submit" name="submit_plugins">'.get_lang('EnablePlugins').'</button>'; |
|
|
|
echo '</div>'; |
|
|
|
echo '</div>'; |
|
|
|
echo '</form>'; |
|
|
|
echo '</form>'; |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -187,6 +185,7 @@ function handle_plugins() { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
function handle_stylesheets() { |
|
|
|
function handle_stylesheets() { |
|
|
|
global $_configuration; |
|
|
|
global $_configuration; |
|
|
|
|
|
|
|
|
|
|
|
// Current style. |
|
|
|
// Current style. |
|
|
|
$currentstyle = api_get_setting('stylesheets'); |
|
|
|
$currentstyle = api_get_setting('stylesheets'); |
|
|
|
|
|
|
|
|
|
|
@ -197,20 +196,21 @@ function handle_stylesheets() { |
|
|
|
$url_info = api_get_access_url($_configuration['access_url']); |
|
|
|
$url_info = api_get_access_url($_configuration['access_url']); |
|
|
|
if ($style_info[0]['access_url_changeable'] == 1 && $url_info['active'] == 1) { |
|
|
|
if ($style_info[0]['access_url_changeable'] == 1 && $url_info['active'] == 1) { |
|
|
|
$is_style_changeable = true; |
|
|
|
$is_style_changeable = true; |
|
|
|
echo '<div class="actions" id="stylesheetuploadlink">'; |
|
|
|
/*echo '<div class="actions" id="stylesheetuploadlink">'; |
|
|
|
Display::display_icon('upload_stylesheets.png',get_lang('UploadNewStylesheet'),'',ICON_SIZE_MEDIUM); |
|
|
|
Display::display_icon('upload_stylesheets.png',get_lang('UploadNewStylesheet'),'', ICON_SIZE_MEDIUM); |
|
|
|
echo '<a href="" onclick="javascript: document.getElementById(\'newstylesheetform\').style.display = \'block\'; document.getElementById(\'stylesheetuploadlink\').style.display = \'none\'; return false; ">'.get_lang('UploadNewStylesheet').'</a>'; |
|
|
|
echo '<a href="" onclick="javascript: document.getElementById(\'newstylesheetform\').style.display = \'block\'; document.getElementById(\'stylesheetuploadlink\').style.display = \'none\'; return false; ">'.get_lang('UploadNewStylesheet').'</a>'; |
|
|
|
echo '</div>'; |
|
|
|
echo '</div>';*/ |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
$is_style_changeable = true; |
|
|
|
$is_style_changeable = true; |
|
|
|
echo '<div class="actions" id="stylesheetuploadlink">'; |
|
|
|
/*echo '<div class="actions" id="stylesheetuploadlink">'; |
|
|
|
Display::display_icon('upload_stylesheets.png',get_lang('UploadNewStylesheet'),'',ICON_SIZE_MEDIUM); |
|
|
|
Display::display_icon('upload_stylesheets.png',get_lang('UploadNewStylesheet'),'', ICON_SIZE_MEDIUM); |
|
|
|
echo '<a href="" onclick="javascript: document.getElementById(\'newstylesheetform\').style.display = \'block\'; document.getElementById(\'stylesheetuploadlink\').style.display = \'none\'; return false; ">'.get_lang('UploadNewStylesheet').'</a>'; |
|
|
|
echo '<a href="" onclick="javascript: document.getElementById(\'newstylesheetform\').style.display = \'block\'; document.getElementById(\'stylesheetuploadlink\').style.display = \'none\'; return false; ">'.get_lang('UploadNewStylesheet').'</a>'; |
|
|
|
echo '</div>'; |
|
|
|
echo '</div>';*/ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$form = new FormValidator('stylesheet_upload', 'post', 'settings.php?category=Stylesheets&showuploadform=true'); |
|
|
|
$form = new FormValidator('stylesheet_upload', 'post', 'settings.php?category=Stylesheets#tabs-2'); |
|
|
|
|
|
|
|
//$form->addElement('header', get_lang('UploadNewStylesheet')); |
|
|
|
$form->addElement('text', 'name_stylesheet', get_lang('NameStylesheet'), array('size' => '40', 'maxlength' => '40')); |
|
|
|
$form->addElement('text', 'name_stylesheet', get_lang('NameStylesheet'), array('size' => '40', 'maxlength' => '40')); |
|
|
|
$form->addRule('name_stylesheet', get_lang('ThisFieldIsRequired'), 'required'); |
|
|
|
$form->addRule('name_stylesheet', get_lang('ThisFieldIsRequired'), 'required'); |
|
|
|
$form->addElement('file', 'new_stylesheet', get_lang('UploadNewStylesheet')); |
|
|
|
$form->addElement('file', 'new_stylesheet', get_lang('UploadNewStylesheet')); |
|
|
@ -218,54 +218,49 @@ function handle_stylesheets() { |
|
|
|
|
|
|
|
|
|
|
|
$form->addRule('new_stylesheet', get_lang('InvalidExtension').' ('.implode(',', $allowed_file_types).')', 'filetype', $allowed_file_types); |
|
|
|
$form->addRule('new_stylesheet', get_lang('InvalidExtension').' ('.implode(',', $allowed_file_types).')', 'filetype', $allowed_file_types); |
|
|
|
$form->addRule('new_stylesheet', get_lang('ThisFieldIsRequired'), 'required'); |
|
|
|
$form->addRule('new_stylesheet', get_lang('ThisFieldIsRequired'), 'required'); |
|
|
|
$form->addElement('style_submit_button', 'stylesheet_upload', get_lang('Ok'), array('class'=>'save')); |
|
|
|
$form->addElement('style_submit_button', 'stylesheet_upload', get_lang('Upload'), array('class'=>'save')); |
|
|
|
if ($form->validate() && is_writable(api_get_path(SYS_CODE_PATH).'css/')) { |
|
|
|
|
|
|
|
$values = $form->exportValues(); |
|
|
|
|
|
|
|
$picture_element = $form->getElement('new_stylesheet'); |
|
|
|
|
|
|
|
$picture = $picture_element->getValue(); |
|
|
|
|
|
|
|
$result = upload_stylesheet($values, $picture); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Add event to the system log. |
|
|
|
$show_upload_form = false; |
|
|
|
$user_id = api_get_user_id(); |
|
|
|
|
|
|
|
$category = $_GET['category']; |
|
|
|
|
|
|
|
event_system(LOG_CONFIGURATION_SETTINGS_CHANGE, LOG_CONFIGURATION_SETTINGS_CATEGORY, $category, api_get_utc_datetime(), $user_id); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($result) { |
|
|
|
if (!is_writable(api_get_path(SYS_CODE_PATH).'css/')) { |
|
|
|
Display::display_confirmation_message(get_lang('StylesheetAdded')); |
|
|
|
Display::display_error_message(api_get_path(SYS_CODE_PATH).'css/'.get_lang('IsNotWritable')); |
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
if (!is_writable(api_get_path(SYS_CODE_PATH).'css/')) { |
|
|
|
// Uploading a new stylesheet. |
|
|
|
Display::display_error_message(api_get_path(SYS_CODE_PATH).'css/'.get_lang('IsNotWritable')); |
|
|
|
if ($_configuration['access_url'] == 1) { |
|
|
|
|
|
|
|
//$form->display(); |
|
|
|
|
|
|
|
$show_upload_form = true; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
if (!empty($_GET['showuploadform']) && $_GET['showuploadform'] == 'true') { |
|
|
|
if ($is_style_changeable) { |
|
|
|
echo '<div id="newstylesheetform">'; |
|
|
|
//$form->display(); |
|
|
|
} else { |
|
|
|
$show_upload_form = true; |
|
|
|
echo '<div id="newstylesheetform" style="display: none;">'; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
// Uploading a new stylesheet. |
|
|
|
|
|
|
|
if ($_configuration['access_url'] == 1) { |
|
|
|
|
|
|
|
$form->display(); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
if ($is_style_changeable) { |
|
|
|
|
|
|
|
$form->display(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
echo '</div>'; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
?> |
|
|
|
if (isset($_POST['stylesheet_upload'])) { |
|
|
|
<script type="text/javascript"> |
|
|
|
if ($form->validate()) { |
|
|
|
function load_preview(){ |
|
|
|
$values = $form->exportValues(); |
|
|
|
$('#stylesheets_id').submit(); |
|
|
|
$picture_element = $form->getElement('new_stylesheet'); |
|
|
|
|
|
|
|
$picture = $picture_element->getValue(); |
|
|
|
|
|
|
|
$result = upload_stylesheet($values, $picture); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Add event to the system log. |
|
|
|
|
|
|
|
$user_id = api_get_user_id(); |
|
|
|
|
|
|
|
$category = $_GET['category']; |
|
|
|
|
|
|
|
event_system(LOG_CONFIGURATION_SETTINGS_CHANGE, LOG_CONFIGURATION_SETTINGS_CATEGORY, $category, api_get_utc_datetime(), $user_id); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($result) { |
|
|
|
|
|
|
|
Display::display_confirmation_message(get_lang('StylesheetAdded')); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
</script> |
|
|
|
|
|
|
|
<?php |
|
|
|
$form_change = new FormValidator('stylesheet_upload', 'post', api_get_self().'?category=Stylesheets', null, array('id' => 'stylesheets_id')); |
|
|
|
echo '<form id="stylesheets_id" name="stylesheets" class="form-search" method="post" action="'.api_get_self().'?category='.Security::remove_XSS($_GET['category']).'">'; |
|
|
|
//$form_change->addElement('header', get_lang('ChangeStylesheet')); |
|
|
|
echo '<br /><select name="style" onchange="load_preview(this)" >'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$list_of_styles = array(); |
|
|
|
$list_of_styles = array(); |
|
|
|
$list_of_names = array(); |
|
|
|
$list_of_names = array(); |
|
|
|
|
|
|
|
$selected = null; |
|
|
|
|
|
|
|
|
|
|
|
if ($handle = @opendir(api_get_path(SYS_PATH).'main/css/')) { |
|
|
|
if ($handle = @opendir(api_get_path(SYS_PATH).'main/css/')) { |
|
|
|
$counter = 1; |
|
|
|
$counter = 1; |
|
|
@ -277,11 +272,11 @@ function handle_stylesheets() { |
|
|
|
|
|
|
|
|
|
|
|
if (is_dir($dirpath)) { |
|
|
|
if (is_dir($dirpath)) { |
|
|
|
if ($style_dir != '.' && $style_dir != '..') { |
|
|
|
if ($style_dir != '.' && $style_dir != '..') { |
|
|
|
if (isset($_POST['style']) && $_POST['style'] == $style_dir) { |
|
|
|
if (isset($_POST['style']) && 'preview' && isset($_POST['style']) && $_POST['style'] == $style_dir) { |
|
|
|
$selected = 'selected="true"'; |
|
|
|
$selected = $style_dir; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
if (!isset($_POST['style']) && ($currentstyle == $style_dir || ($style_dir == 'chamilo' && !$currentstyle))) { |
|
|
|
if (!isset($_POST['style']) && ($currentstyle == $style_dir || ($style_dir == 'chamilo' && !$currentstyle))) { |
|
|
|
$selected = 'selected="true"'; |
|
|
|
$selected = $style_dir; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
$selected = ''; |
|
|
|
$selected = ''; |
|
|
|
} |
|
|
|
} |
|
|
@ -289,14 +284,13 @@ function handle_stylesheets() { |
|
|
|
$show_name = ucwords(str_replace('_', ' ', $style_dir)); |
|
|
|
$show_name = ucwords(str_replace('_', ' ', $style_dir)); |
|
|
|
|
|
|
|
|
|
|
|
if ($is_style_changeable) { |
|
|
|
if ($is_style_changeable) { |
|
|
|
$list_of_styles[$style_dir] = "<option value=\"".$style_dir."\" ".$selected." /> $show_name </option>"; |
|
|
|
$list_of_styles[$style_dir] = "<option value=\"".$style_dir."\" ".$selected." /> $show_name </option>"; |
|
|
|
$list_of_names[$style_dir] = $show_name; |
|
|
|
$list_of_names[$style_dir] = $show_name; |
|
|
|
//echo "<input type=\"radio\" name=\"style\" value=\"".$style_dir."\" ".$selected." onClick=\"parent.preview.location='style_preview.php?style=".$style_dir."';\"/>"; |
|
|
|
//echo "<input type=\"radio\" name=\"style\" value=\"".$style_dir."\" ".$selected." onClick=\"parent.preview.location='style_preview.php?style=".$style_dir."';\"/>"; |
|
|
|
//echo '<a href="style_preview.php?style='.$style_dir.'" target="preview">'.$show_name.'</a>'; |
|
|
|
//echo '<a href="style_preview.php?style='.$style_dir.'" target="preview">'.$show_name.'</a>'; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
echo '<a href="style_preview.php?style='.$style_dir.'" target="preview">'.$show_name.'</a>'; |
|
|
|
//echo '<a href="style_preview.php?style='.$style_dir.'" target="preview">'.$show_name.'</a>'; |
|
|
|
} |
|
|
|
} |
|
|
|
echo '<br />'; |
|
|
|
|
|
|
|
$counter++; |
|
|
|
$counter++; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -306,14 +300,39 @@ function handle_stylesheets() { |
|
|
|
|
|
|
|
|
|
|
|
//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) { |
|
|
|
$select_list = array(); |
|
|
|
echo $list_of_styles[$style_dir]; |
|
|
|
foreach ($list_of_names as $style_dir=>$item) { |
|
|
|
|
|
|
|
$select_list[$style_dir] = strip_tags($list_of_styles[$style_dir]); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$form_change->addElement('select', 'style', get_lang('NameStylesheet'), $select_list); |
|
|
|
|
|
|
|
$form_change->setDefaults('style', $selected); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($form_change->validate()) { |
|
|
|
|
|
|
|
// Submit stylesheets. |
|
|
|
|
|
|
|
if (isset($_POST['save'])) { |
|
|
|
|
|
|
|
store_stylesheets(); |
|
|
|
|
|
|
|
echo Display::display_normal_message(get_lang('Saved')); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//echo '</select><br />'; |
|
|
|
if ($is_style_changeable) { |
|
|
|
echo '</select> '; |
|
|
|
$group[] = $form_change->createElement('button', 'save', get_lang('SaveSettings'), array('class' => 'btn btn-primary')); |
|
|
|
if ($is_style_changeable){ |
|
|
|
$group[] = $form_change->createElement('button', 'preview', get_lang('Preview'), array('class' => 'btn')); |
|
|
|
echo '<button class="btn save" type="submit" name="submit_stylesheets"> '.get_lang('SaveSettings').' </button></form>'; |
|
|
|
$form_change->addGroup($group); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($show_upload_form) { |
|
|
|
|
|
|
|
echo '<script> |
|
|
|
|
|
|
|
$(function() { |
|
|
|
|
|
|
|
$( "#tabs" ).tabs(); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
</script>'; |
|
|
|
|
|
|
|
echo Display::tabs(array(get_lang('Update'), get_lang('UploadNewStylesheet')), array($form_change->return_form(), $form->return_form())); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
$form_change->display(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
$form_change->freeze(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -454,11 +473,9 @@ function store_regions() { |
|
|
|
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University |
|
|
|
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
function store_plugins() { |
|
|
|
function store_plugins() { |
|
|
|
|
|
|
|
|
|
|
|
$plugin_obj = new AppPlugin(); |
|
|
|
$plugin_obj = new AppPlugin(); |
|
|
|
|
|
|
|
|
|
|
|
// Get a list of all current 'Plugins' settings |
|
|
|
// Get a list of all current 'Plugins' settings |
|
|
|
|
|
|
|
|
|
|
|
$plugin_list = $plugin_obj->read_plugins_from_path(); |
|
|
|
$plugin_list = $plugin_obj->read_plugins_from_path(); |
|
|
|
|
|
|
|
|
|
|
|
$installed_plugins = array(); |
|
|
|
$installed_plugins = array(); |
|
|
@ -486,14 +503,12 @@ function store_plugins() { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
function store_stylesheets() { |
|
|
|
function store_stylesheets() { |
|
|
|
global $_configuration; |
|
|
|
global $_configuration; |
|
|
|
|
|
|
|
|
|
|
|
// Insert the stylesheet. |
|
|
|
// Insert the stylesheet. |
|
|
|
$style = Database::escape_string($_POST['style']); |
|
|
|
$style = Database::escape_string($_POST['style']); |
|
|
|
|
|
|
|
|
|
|
|
if (is_style($style)) { |
|
|
|
if (is_style($style)) { |
|
|
|
api_set_setting('stylesheets', $style, null, 'stylesheets', $_configuration['access_url']); |
|
|
|
api_set_setting('stylesheets', $style, null, 'stylesheets', $_configuration['access_url']); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|