Admin can now save content before the <head> tag is closed. Useful to add tracking information

skala
Julio Montoya 14 years ago
parent ee95ae4984
commit 7efd8fb0cc
  1. 32
      main/admin/settings.php
  2. 2
      main/css/base_chamilo.css
  3. 6
      main/inc/header.inc.php
  4. 30
      main/inc/lib/main_api.lib.php
  5. 30
      main/inc/lib/template.lib.php
  6. 15
      main/inc/lib/userportal.lib.php
  7. 8
      main/inc/reduced_header.inc.php
  8. 5
      main/template/default/layout/head.tpl

@ -153,7 +153,7 @@ if (!empty($_GET['category']) && !in_array($_GET['category'], array('Plugins', '
}
switch ($row['type']) {
case 'textfield':
case 'textfield':
if ($row['variable'] == 'account_valid_duration') {
$form->addElement('text', $row['variable'], get_lang($row['comment']), array('maxlength' => '5'));
$form->applyFilter($row['variable'], 'html_filter');
@ -192,9 +192,19 @@ if (!empty($_GET['category']) && !in_array($_GET['category'], array('Plugins', '
$default_values[$row['variable']] = $row['selected_value'];
}
break;
case 'textarea':
$form->addElement('textarea', $row['variable'], get_lang($row['comment']) , array('rows'=>'10','cols'=>'50'), $hideme);
$default_values[$row['variable']] = $row['selected_value'];
case 'textarea':
if ($row['variable'] == 'header_extra_content') {
$file = api_get_path(SYS_PATH).api_get_home_path().'header_extra_content';
$value = '';
if (file_exists($file)) {
$value = file_get_contents($file);
}
$form->addElement('textarea', $row['variable'], get_lang($row['comment']) , array('rows'=>'10','cols'=>'50'), $hideme);
$default_values[$row['variable']] = $value;
} else {
$form->addElement('textarea', $row['variable'], get_lang($row['comment']) , array('rows'=>'10','cols'=>'50'), $hideme);
$default_values[$row['variable']] = $row['selected_value'];
}
break;
case 'radio':
$values = get_settings_options($row['variable']);
@ -330,7 +340,7 @@ if (!empty($_GET['category']) && !in_array($_GET['category'], array('Plugins', '
if ($row['variable'] == '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'));
if ($url != false) {
$delete_url = '<a href="?delete_watermark">'.Display::return_icon('delete.png',get_lang('DelImage')).'</a>';
@ -342,6 +352,8 @@ if (!empty($_GET['category']) && !in_array($_GET['category'], array('Plugins', '
if ($row['variable'] == 'timezone_value') {
$form->addElement('html', sprintf(get_lang('LocalTimeUsingPortalTimezoneXIsY'),$row['selected_value'],api_get_local_time()));
}
}
$form->addElement('html', '<div style="text-align: right; clear: both;">');
@ -394,12 +406,13 @@ 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)) {
//$sql = "UPDATE $table_settings_current SET selected_value='".Database::escape_string($value)."' WHERE variable='$key'";
//$result = Database::query($sql);
$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', $value);
$value = api_get_home_path().'/header_extra_content';
break;
// URL validation for some settings.
case 'InstitutionUrl':
@ -431,7 +444,6 @@ if (!empty($_GET['category']) && !in_array($_GET['category'], array('Plugins', '
}
if ($old_value != $value) $keys[] = $key;
$result = api_set_setting($key, $value, null, null, $_configuration['access_url']);
} else {
@ -496,9 +508,11 @@ $action_images['search'] = 'search.png';
$action_images['editor'] = 'html_editor.png';
$action_images['timezones'] = 'timezone.png';
$action_images['extra'] = 'wizard.png';
$action_images['tracking'] = 'statistics.png';
// Grabbing the categories.
$resultcategories = api_get_settings_categories(array('stylesheets', 'Plugins', 'Templates', 'Search'));
echo "<div class=\"actions\">";
foreach ($resultcategories as $row) {
echo "<a href=\"".api_get_self()."?category=".$row['category']."\">".Display::return_icon($action_images[strtolower($row['category'])], api_ucfirst(get_lang($row['category'])),'','32')."</a>";

@ -1053,7 +1053,7 @@ div.admin_section {
div.admin_section h4 {
margin: 5px 0px 5px 5px;
padding: 0px 0px 5px 0px;
/*padding: 0px 0px 5px 0px; */
border-bottom: 1px solid #E1E1E0;
width: 100%;
}

@ -187,6 +187,12 @@ if (isset($_configuration['multiple_access_urls']) && $_configuration['multiple_
}
}
echo $favico;
if (!api_is_platform_admin()) {
$extra_header = trim(api_get_setting('header_extra_content'));
if (!empty($extra_header)) {
$this->assign('header_extra_content', $extra_header);
}
}
?>
</head>
<body dir="<?php echo api_get_text_direction(); ?>" <?php

@ -1770,9 +1770,14 @@ function api_get_coachs_from_course($session_id=0,$course_code='') {
* @author Bart Mollet
*/
function api_get_setting($variable, $key = null) {
global $_setting;
//return is_null($key) ? (!empty($_setting[$variable]) ? $_setting[$variable] : null) : $_setting[$variable][$key]; does not allow "0" values
//Allowing "0" values
global $_setting;
if ($variable == 'header_extra_content') {
$filename = api_get_path(SYS_PATH).api_get_home_path().'header_extra_content';
if (file_exists($filename)) {
$value = file_get_contents($filename);
return $value ;
}
}
return is_null($key) ? ((isset($_setting[$variable]) && $_setting[$variable] != '') ? $_setting[$variable] : null) : $_setting[$variable][$key];
}
@ -5211,7 +5216,7 @@ function api_get_multiple_access_url() {
return false;
}
/*
/**
* Returns a md5 unique id
* @todo add more parameters
*/
@ -5223,5 +5228,18 @@ function api_get_unique_id() {
function api_get_home_path() {
$home = 'home';
if (api_get_multiple_access_url()) {
$access_url_id = api_get_current_access_url_id();
$url_info = api_get_access_url($access_url_id);
$url = api_remove_trailing_slash(preg_replace('/https?:\/\//i', '', $url_info['url']));
$clean_url = replace_dangerous_char($url);
$clean_url = str_replace('/', '-', $clean_url);
$clean_url .= '/';
// if $clean_url == "localhost/" means that the multiple URL was not well configured we don't rename the $home variable
if ($clean_url != 'localhost/')
$home = 'home/'.$clean_url;
}
return $home;
}

@ -42,11 +42,18 @@ class Template extends Smarty {
$this->assign('style', $this->style);
}
/**
* Sets the footer visibility
* @param bool true if we show the footer
*/
function set_footer($status) {
$this->assign('show_footer', $status);
}
function set_header($status) {
/**
* Sets the header visibility
*
*/
function set_header($status) {
$this->assign('show_header', $status);
}
@ -189,8 +196,8 @@ class Template extends Smarty {
$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('style_print', $style_print);
$extra_headers = '';
if (isset($htmlHeadXtra) && $htmlHeadXtra) {
@ -198,8 +205,7 @@ class Template extends Smarty {
$extra_headers .= $this_html_head;
}
}
$this->assign('extra_headers', $extra_headers);
$this->assign('extra_headers', $extra_headers);
$favico = '<link rel="shortcut icon" href="'.api_get_path(WEB_PATH).'favicon.ico" type="image/x-icon" />';
if (isset($_configuration['multiple_access_urls']) && $_configuration['multiple_access_urls']) {
@ -249,11 +255,6 @@ class Template extends Smarty {
if (isset($database_connection)) {
// connect to the main database.
// if single database, don't pefix table names with the main database name in SQL queries
// (ex. SELECT * FROM table)
// if multiple database, prefix table names with the course database name in SQL queries (or no prefix if the table is in
// the main database)
// (ex. SELECT * FROM table_from_main_db - SELECT * FROM courseDB.table_from_course_db)
Database::select_db($_configuration['main_database'], $database_connection);
}
@ -279,6 +280,13 @@ class Template extends Smarty {
$this->assign('header3', $header3);
$this->assign('header4', $header4);
if (!api_is_platform_admin()) {
$extra_header = trim(api_get_setting('header_extra_content'));
if (!empty($extra_header)) {
$this->assign('header_extra_content', $extra_header);
}
}
header('Content-Type: text/html; charset='.api_get_system_encoding());
header('X-Powered-By: '.$_configuration['software_name'].' '.substr($_configuration['system_version'],0,1));
}

@ -19,19 +19,8 @@ class IndexManager {
$this->tpl = new Template($title);
}
$home = 'home/';
if (api_get_multiple_access_url()) {
$access_url_id = api_get_current_access_url_id();
$url_info = api_get_access_url($access_url_id);
$url = api_remove_trailing_slash(preg_replace('/https?:\/\//i', '', $url_info['url']));
$clean_url = replace_dangerous_char($url);
$clean_url = str_replace('/', '-', $clean_url);
$clean_url .= '/';
// if $clean_url == "localhost/" means that the multiple URL was not well configured we don't rename the $home variable
if ($clean_url != 'localhost/')
$home = 'home/'.$clean_url;
}
$this->home = $home;
$this->home = api_get_home_path();
$this->user_id = api_get_user_id();
$this->load_directories_preview = true;
}

@ -150,5 +150,13 @@ if (isset($htmlHeadXtra) && $htmlHeadXtra) {
echo $this_html_head;
}
}
if (!api_is_platform_admin()) {
$extra_header = trim(api_get_setting('header_extra_content'));
if (!empty($extra_header)) {
$this->assign('header_extra_content', $extra_header);
}
}
?>
</head>

@ -1,3 +1,4 @@
<!-- head start -->
<link href="http://www.chamilo.org/documentation.php" rel="Help" />
<link href="http://www.chamilo.org/team.php" rel="Author" />
<link href="http://www.chamilo.org" rel="Copyright" />
@ -13,7 +14,6 @@
<style type="text/css" media="screen, projection">
/*<![CDATA[*/
{$css_style}
?>
/*]]>*/
</style>
<style type="text/css" media="print">
@ -44,3 +44,6 @@ if ( ( navigator.userAgent.toLowerCase().indexOf('msie') != -1 ) && ( navigator.
{$css_file_to_string}
{$extra_headers}
{$favico}
{$header_extra_content}
<!-- head end-->
Loading…
Cancel
Save