From 0457341994b6340fac830901de42dffd6a6c7e6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Loguercio?= Date: Thu, 3 Mar 2016 19:23:39 -0500 Subject: [PATCH 1/4] Added Feature to customize the logo of each StyleSheet - Refs #8118 --- main/admin/settings.lib.php | 61 +++++++++++++++++++++++++++++++++++-- 1 file changed, 58 insertions(+), 3 deletions(-) diff --git a/main/admin/settings.lib.php b/main/admin/settings.lib.php index be015d56c1..3415917c56 100755 --- a/main/admin/settings.lib.php +++ b/main/admin/settings.lib.php @@ -229,7 +229,7 @@ function handle_stylesheets() $form = new FormValidator( 'stylesheet_upload', 'post', - 'settings.php?category=Stylesheets#tabs-2' + 'settings.php?category=Stylesheets#tabs-3' ); $form->addElement('text', 'name_stylesheet', get_lang('NameStylesheet'), array('size' => '40', 'maxlength' => '40')); $form->addRule('name_stylesheet', get_lang('ThisFieldIsRequired'), 'required'); @@ -362,6 +362,54 @@ function handle_stylesheets() } } } + + $logoForm = new FormValidator( + 'logo_upload', + 'post', + 'settings.php?category=Stylesheets#tabs-2' + ); + + $dir = api_get_path(SYS_PUBLIC_PATH).'css/themes/' . $selected . '/images/'; + $url = api_get_path(WEB_CSS_PATH).'themes/' . $selected . '/images/'; + $newLogoFileName = 'header-logo.png'; + + $logoForm->addLabel(get_lang('CurrentLogo'), ''); + $logoForm->addFile('new_logo', get_lang('UpdateLogo')); + $allowedFileTypes = ['png']; + + if (isset($_POST['logo_reset'])) { + if (is_file($dir.'header-logo-org.png')) { + unlink($dir.$newLogoFileName); + rename($dir.'header-logo-org.png', $dir.$newLogoFileName); + Display::display_normal_message(get_lang('Reset')); + } + } elseif (isset($_POST['logo_upload'])) { + + $logoForm->addRule('new_logo', get_lang('InvalidExtension').' ('.implode(',', $allowedFileTypes).')', 'filetype', $allowedFileTypes); + $logoForm->addRule('new_logo', get_lang('ThisFieldIsRequired'), 'required'); + + if ($logoForm->validate()) { + + $imageInfo = getimagesize($_FILES['new_logo']['tmp_name']); + $width = $imageInfo[0]; + $height = $imageInfo[1]; + if ($width <= 250 && $height <= 70 ) { + if (!is_file($dir.'header-logo-org.png')) { + rename($dir.$newLogoFileName, $dir.'header-logo-org.png'); + } + + $status = move_uploaded_file($_FILES['new_logo']['tmp_name'], $dir.$newLogoFileName); + + if ($status) { + Display::display_normal_message(get_lang('Saved')); + } else { + Display::display_error_message('Error - '.get_lang('UplNoFileUploaded')); + } + } else { + Display::display_error_message('Error - '.get_lang('InvalidImageDimensions')); + } + } + } if ($is_style_changeable) { $group = [ @@ -371,6 +419,13 @@ function handle_stylesheets() ]; $form_change->addGroup($group); + + $logoGroup = [ + $logoForm->addButtonUpload(get_lang('Upload'), 'logo_upload', true), + $logoForm->addButtonCancel(get_lang('Reset'), 'logo_reset', true) + ]; + + $logoForm->addGroup($logoGroup); if ($show_upload_form) { echo ''; echo Display::tabs( - array(get_lang('Update'), get_lang('UploadNewStylesheet')), - array($form_change->return_form(), $form->return_form()) + array(get_lang('Update'),get_lang('UpdateLogo'), get_lang('UploadNewStylesheet')), + array($form_change->return_form(), $logoForm->return_form(), $form->return_form()) ); } else { $form_change->display(); From cf7627c04079d38a23530965ebe1d12fc11913b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Loguercio?= Date: Tue, 15 Mar 2016 09:55:46 -0500 Subject: [PATCH 2/4] Added Feature to customize the logo of each StyleSheet - Refs #8118 --- main/admin/settings.lib.php | 40 +++++++++++++++++++++++++++++-------- main/inc/lib/banner.lib.php | 31 ++++++++++++++++++---------- 2 files changed, 53 insertions(+), 18 deletions(-) diff --git a/main/admin/settings.lib.php b/main/admin/settings.lib.php index 3415917c56..aa8e88bf26 100755 --- a/main/admin/settings.lib.php +++ b/main/admin/settings.lib.php @@ -369,19 +369,29 @@ function handle_stylesheets() 'settings.php?category=Stylesheets#tabs-2' ); + $logoForm->addHtml(Display::return_message(sprintf(get_lang('TheLogoMustBeSizeXAndFormatY'), '250 x 70', 'PNG'), 'info')); + $dir = api_get_path(SYS_PUBLIC_PATH).'css/themes/' . $selected . '/images/'; $url = api_get_path(WEB_CSS_PATH).'themes/' . $selected . '/images/'; - $newLogoFileName = 'header-logo.png'; + $logoFileName = 'header-logo.png'; + $newLogoFileName = 'header-logo-custom.png'; + + if (is_file($dir.$newLogoFileName)) { + $logoForm->addLabel(get_lang('CurrentLogo'), ''); + } else { + $logoForm->addLabel(get_lang('CurrentLogo'), ''); + } - $logoForm->addLabel(get_lang('CurrentLogo'), ''); $logoForm->addFile('new_logo', get_lang('UpdateLogo')); $allowedFileTypes = ['png']; if (isset($_POST['logo_reset'])) { - if (is_file($dir.'header-logo-org.png')) { + if (is_file($dir.$newLogoFileName)) { unlink($dir.$newLogoFileName); - rename($dir.'header-logo-org.png', $dir.$newLogoFileName); - Display::display_normal_message(get_lang('Reset')); + Display::display_normal_message(get_lang('ResetToTheOriginalLogo')); + echo ''; } } elseif (isset($_POST['logo_upload'])) { @@ -394,14 +404,17 @@ function handle_stylesheets() $width = $imageInfo[0]; $height = $imageInfo[1]; if ($width <= 250 && $height <= 70 ) { - if (!is_file($dir.'header-logo-org.png')) { - rename($dir.$newLogoFileName, $dir.'header-logo-org.png'); + if (is_file($dir.$newLogoFileName)) { + unlink($dir.$newLogoFileName); } $status = move_uploaded_file($_FILES['new_logo']['tmp_name'], $dir.$newLogoFileName); if ($status) { - Display::display_normal_message(get_lang('Saved')); + Display::display_normal_message(get_lang('NewLogoUpdated')); + echo ''; } else { Display::display_error_message('Error - '.get_lang('UplNoFileUploaded')); } @@ -440,6 +453,17 @@ function handle_stylesheets() } else { $form_change->display(); } + + //Little hack to update the logo image in update form when submiting + if (isset($_POST['logo_reset'])) { + echo ''; + } elseif (isset($_POST['logo_upload']) && is_file($dir.$newLogoFileName)) { + echo ''; + } } else { $form_change->freeze(); } diff --git a/main/inc/lib/banner.lib.php b/main/inc/lib/banner.lib.php index e19fd5cc5c..04f195a098 100755 --- a/main/inc/lib/banner.lib.php +++ b/main/inc/lib/banner.lib.php @@ -152,33 +152,44 @@ function return_logo($theme) $_course = api_get_course_info(); $html = ''; $logoBase = api_get_path(SYS_CSS_PATH).'themes/'.$theme.'/images/header-logo.'; + $customLogoBase = api_get_path(SYS_PUBLIC_PATH).'css/themes/'.$theme.'/images/header-logo-custom.'; - $site_name = api_get_setting('siteName'); + $siteName = api_get_setting('siteName'); $attributes = array( - 'title' => $site_name, + 'title' => $siteName, 'class' => 'img-responsive', + 'id' => 'header-logo' ); $testServer = api_get_setting('server_type'); if ($testServer == 'test' && is_file($logoBase . 'svg')) { $logo = $logoBase . 'svg'; $attributes['width'] = '245'; $attributes['height'] = '68'; - $image_url = api_get_path(WEB_CSS_PATH).'themes/'.$theme.'/images/header-logo.svg'; + $imageUrl = api_get_path(WEB_CSS_PATH).'themes/'.$theme.'/images/header-logo.svg'; } else { $logo = $logoBase . 'png'; - $image_url = api_get_path(WEB_CSS_PATH).'themes/'.$theme.'/images/header-logo.png'; + $customLogo = $customLogoBase . 'png'; + $imageUrl = api_get_path(WEB_CSS_PATH).'themes/'.$theme.'/images/header-logo.png'; + $customImageUrl = api_get_path(WEB_CSS_PATH).'themes/'.$theme.'/images/header-logo-custom.png'; } - - if (file_exists($logo)) { - $site_name = api_get_setting('Institution').' - '.$site_name; + if (file_exists($customLogo)) { + $siteName = api_get_setting('Institution').' - '.$siteName; + $customLogo = Display::img( + $customImageUrl, + $siteName, + $attributes + ); + $html .= Display::url($customLogo, api_get_path(WEB_PATH).'index.php'); + } elseif (file_exists($logo)) { + $siteName = api_get_setting('Institution').' - '.$siteName; $logo = Display::img( - $image_url, - $site_name, + $imageUrl, + $siteName, $attributes ); $html .= Display::url($logo, api_get_path(WEB_PATH).'index.php'); } else { - $html .= ''.$site_name.''; + $html .= ''.$siteName.''; $iurl = api_get_setting('InstitutionUrl'); $iname = api_get_setting('Institution'); From 4b2d9f1d0eff550cb75c96fd9faa82b9e58f902a Mon Sep 17 00:00:00 2001 From: Yannick Warnier Date: Thu, 17 Mar 2016 17:34:58 -0500 Subject: [PATCH 3/4] Update language terms --- main/lang/brazilian/trad4all.inc.php | 1 + main/lang/english/trad4all.inc.php | 5 +++++ main/lang/french/trad4all.inc.php | 5 +++++ main/lang/spanish/trad4all.inc.php | 5 +++++ 4 files changed, 16 insertions(+) diff --git a/main/lang/brazilian/trad4all.inc.php b/main/lang/brazilian/trad4all.inc.php index 04cd1d311a..ac9a4d093e 100644 --- a/main/lang/brazilian/trad4all.inc.php +++ b/main/lang/brazilian/trad4all.inc.php @@ -7551,4 +7551,5 @@ $MessagingGDCProjectNumberTitle = "Número do projeto de Google Developer Consol $MessagingGDCProjectNumberComment = "Você precisa registrar um projeto no Google Developer Console"; $MessagingGDCApiKeyTitle = "Key API do Google Developer Console para o Google Cloud Mensagens"; $MessagingGDCApiKeyComment = "Você precisa ativar a API do Google Cloud Mensagens e criar uma credencial para Android"; +$Overwrite = "Sobrescrever"; ?> \ No newline at end of file diff --git a/main/lang/english/trad4all.inc.php b/main/lang/english/trad4all.inc.php index 1b6a988f53..c18c92f628 100644 --- a/main/lang/english/trad4all.inc.php +++ b/main/lang/english/trad4all.inc.php @@ -7621,4 +7621,9 @@ $MessagingGDCProjectNumberComment = "You need register a project on \ No newline at end of file diff --git a/main/lang/french/trad4all.inc.php b/main/lang/french/trad4all.inc.php index bf7a7a25f4..190b677d89 100644 --- a/main/lang/french/trad4all.inc.php +++ b/main/lang/french/trad4all.inc.php @@ -7608,4 +7608,9 @@ $MessagingGDCProjectNumberComment = "Vous devez enregistrer un projet sur \ No newline at end of file diff --git a/main/lang/spanish/trad4all.inc.php b/main/lang/spanish/trad4all.inc.php index ee8505bca3..4497a8a197 100644 --- a/main/lang/spanish/trad4all.inc.php +++ b/main/lang/spanish/trad4all.inc.php @@ -7646,4 +7646,9 @@ $MessagingGDCProjectNumberComment = "Necesita registrar un proyecto en \ No newline at end of file From 81e1bbf6769c22d94f132953c0891d79396b67d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Loguercio?= Date: Thu, 17 Mar 2016 17:49:17 -0500 Subject: [PATCH 4/4] Revert "Fix Questions results stats page does not show minimum score - Refs #8121" --- main/inc/lib/pear/HTML/Table/Storage.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/main/inc/lib/pear/HTML/Table/Storage.php b/main/inc/lib/pear/HTML/Table/Storage.php index f4fb91b3d1..d83f354b89 100755 --- a/main/inc/lib/pear/HTML/Table/Storage.php +++ b/main/inc/lib/pear/HTML/Table/Storage.php @@ -769,18 +769,17 @@ class HTML_Table_Storage extends HTML_Common { } $typeContent = $tabs . $tab . $tab . $extraTab . "<$type" . $this->_getAttrString($attr) . '>'; - - if ($contents || is_numeric($contents)) { - $typeContent .= $contents; - } elseif (empty($contents)) { + + if (empty($contents)) { if (isset($this->_autoFill) && $this->_autoFill) { $contents = $this->_autoFill; } + } else { + $typeContent .= $contents; } - $typeContent .= "" . $lnEnd; - if (!empty($contents) || is_numeric($contents)) { + if (!empty($contents)) { $strHtml .= $typeContent; }