Browse Source

Merge branch '1.10.x' of github.com:chamilo/chamilo-lms into 1.10.x

jmontoya 9 years ago
parent
commit
c220189ee8

+ 82 - 3
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,67 @@ function handle_stylesheets()
             }
         }
     }
+    
+    $logoForm = new FormValidator(
+        'logo_upload',
+        'post',
+        '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/';
+    $logoFileName = 'header-logo.png';
+    $newLogoFileName = 'header-logo-custom.png';
+    
+    if (is_file($dir.$newLogoFileName)) {
+        $logoForm->addLabel(get_lang('CurrentLogo'), '<img id="header-logo-custom" src="'. $url . $newLogoFileName .'?'. time() . '">'); 
+    } else {
+        $logoForm->addLabel(get_lang('CurrentLogo'), '<img id="header-logo-custom" src="'. $url . $logoFileName .'?'. time() . '">');
+    }
+    
+    $logoForm->addFile('new_logo', get_lang('UpdateLogo'));
+    $allowedFileTypes = ['png'];
+    
+    if (isset($_POST['logo_reset'])) {
+        if (is_file($dir.$newLogoFileName)) {
+            unlink($dir.$newLogoFileName);
+            Display::display_normal_message(get_lang('ResetToTheOriginalLogo'));
+            echo '<script>'
+                . '$("#header-logo").attr("src","'.$url.$logoFileName.'");'
+            . '</script>';
+        }
+    } 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.$newLogoFileName)) {
+                    unlink($dir.$newLogoFileName);
+                }
+                
+                $status = move_uploaded_file($_FILES['new_logo']['tmp_name'], $dir.$newLogoFileName);
+
+                if ($status) {
+                    Display::display_normal_message(get_lang('NewLogoUpdated'));
+                    echo '<script>'
+                            . '$("#header-logo").attr("src","'.$url.$newLogoFileName.'");'
+                        . '</script>';
+                } 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 +432,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 '<script>
@@ -379,12 +447,23 @@ function handle_stylesheets()
             });
             </script>';
             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();
         }
+        
+        //Little hack to update the logo image in update form when submiting
+        if (isset($_POST['logo_reset'])) {
+            echo '<script>'
+                    . '$("#header-logo-custom").attr("src","'.$url.$logoFileName.'");'
+                . '</script>';
+        } elseif (isset($_POST['logo_upload']) && is_file($dir.$newLogoFileName)) {
+            echo '<script>'
+                    . '$("#header-logo-custom").attr("src","'.$url.$newLogoFileName.'");'
+                . '</script>';
+        }
     } else {
         $form_change->freeze();
     }

+ 21 - 10
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 .= '<a href="'.api_get_path(WEB_PATH).'index.php" target="_top">'.$site_name.'</a>';
+        $html .= '<a href="'.api_get_path(WEB_PATH).'index.php" target="_top">'.$siteName.'</a>';
         $iurl = api_get_setting('InstitutionUrl');
         $iname = api_get_setting('Institution');
 

+ 5 - 6
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 .= "</$type>" . $lnEnd;
 
-                    if (!empty($contents) || is_numeric($contents)) {
+                    if (!empty($contents)) {
                         $strHtml .= $typeContent;
                     }
 

+ 1 - 0
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";
 ?>

+ 5 - 0
main/lang/english/trad4all.inc.php

@@ -7621,4 +7621,9 @@ $MessagingGDCProjectNumberComment = "You need register a project on <a href=\"ht
 $MessagingGDCApiKeyTitle = "API Key of Google Developer Console for Google Cloud Messaging";
 $MessagingGDCApiKeyComment = "You need enable the Google Cloud Messaging API and create one credential for Android";
 $Overwrite = "Overwrite";
+$TheLogoMustBeSizeXAndFormatY = "The logo must be of %s px in size and in %s format";
+$ResetToTheOriginalLogo = "Original logo recovered";
+$NewLogoUpdated = "New logo uploaded";
+$CurrentLogo = "Current logo";
+$UpdateLogo = "Update logo";
 ?>

+ 5 - 0
main/lang/french/trad4all.inc.php

@@ -7608,4 +7608,9 @@ $MessagingGDCProjectNumberComment = "Vous devez enregistrer un projet sur <a hre
 $MessagingGDCApiKeyTitle = "Clef API de la Google Developer Console pour le Google Cloud Messaging";
 $MessagingGDCApiKeyComment = "Vous devez activer l'API du Google Cloud Messaging et créer un accès pour Android";
 $Overwrite = "Écraser";
+$TheLogoMustBeSizeXAndFormatY = "Le logo doit être de taille %s px et au format %s";
+$ResetToTheOriginalLogo = "Logo original récupéré";
+$NewLogoUpdated = "Nouveau logo envoyé";
+$CurrentLogo = "Logo actif";
+$UpdateLogo = "Changer le logo";
 ?>

+ 5 - 0
main/lang/spanish/trad4all.inc.php

@@ -7646,4 +7646,9 @@ $MessagingGDCProjectNumberComment = "Necesita registrar un proyecto en <a href=\
 $MessagingGDCApiKeyTitle = "API key de Google Developer Console para Google Cloud Messaging";
 $MessagingGDCApiKeyComment = "Necesita habilitar la API de Google Cloud Messaging y crear una credencial para Android";
 $Overwrite = "Sobreescribir";
+$TheLogoMustBeSizeXAndFormatY = "El logo debe ser de un tamaño de %s px y en el formato %s";
+$ResetToTheOriginalLogo = "Reseteado al logo original";
+$NewLogoUpdated = "Nuevo logo subido";
+$CurrentLogo = "Logo activo";
+$UpdateLogo = "Cambiar el logo";
 ?>