diff --git a/bl-kernel/admin/views/settings.php b/bl-kernel/admin/views/settings.php
index 84030a14..87b09279 100644
--- a/bl-kernel/admin/views/settings.php
+++ b/bl-kernel/admin/views/settings.php
@@ -19,6 +19,7 @@
p('Social Networks') ?>
p('Images') ?>
p('Language') ?>
+ p('Logo') ?>
@@ -464,4 +465,33 @@
?>
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/bl-kernel/ajax/upload-image.php b/bl-kernel/ajax/upload-image.php
deleted file mode 100644
index f6ddbed5..00000000
--- a/bl-kernel/ajax/upload-image.php
+++ /dev/null
@@ -1,92 +0,0 @@
-1,
- 'message'=>'Error in option parameter.'
- )));
-}
-
-// (string) $_POST['username']
-if ($option=='profilePicture') {
- $username = empty($_POST['username']) ? false : $_POST['username'];
- if ($username===false) {
- exit (json_encode(array(
- 'status'=>1,
- 'message'=>'Error in username parameter.'
- )));
- }
-
- $transformation = array(
- 'resize'=>true,
- 'width'=>PROFILE_IMG_WIDTH,
- 'height'=>PROFILE_IMG_HEIGHT,
- 'quality'=>PROFILE_IMG_QUALITY,
- 'forceJPG'=>false,
- 'forcePNG'=>true,
- 'option'=>'crop'
- );
-
- $finalPath = PATH_UPLOADS_PROFILES;
- $finalFilename = $username.'png';
-} elseif ($option=='siteLogo') {
- $finalPath = PATH_UPLOADS;
- $finalFilename = 'logo';
-}
-
-// ----------------------------------------------------------------------------
-
-if (!isset($_FILES['inputFile'])) {
- exit (json_encode(array(
- 'status'=>1,
- 'message'=>'Error trying to upload the file.'
- )));
-}
-
-// File extension
-$fileExtension = pathinfo($_FILES['inputFile']['name'], PATHINFO_EXTENSION);
-
-// Tmp filename
-$tmpFilename = 'tmp.'.$fileExtension;
-
-// Move from temporary directory to uploads folder
-rename($_FILES['inputFile']['tmp_name'], PATH_TMP.$tmpFilename);
-
-// Resize and crop image
-if ($transformation['resize']) {
- $image = new Image();
- $image->setImage(PATH_TMP.$tmpFilename, $transformation['width'], $transformation['heigh'], $transformation['option']);
- $image->saveImage($finalPath.$finalFilename, $transformation['quality'], $transformation['forceJPG'], $transformation['forcePNG']);
-} else {
- rename(PATH_TMP.$tmpFilename, $finalPath.$finalFilename.'.'.$fileExtension);
-}
-
-// Remove the tmp file
-unlink(PATH_TMP.$tmpFilename);
-
-// Permissions
-chmod($finalPath.$finalFilename, 0644);
-
-exit (json_encode(array(
- 'status'=>0,
- 'message'=>'Image uploaded success.',
- 'filename'=>$finalPath.$finalFilename
-)));
-
-?>
\ No newline at end of file
diff --git a/bl-kernel/ajax/upload-logo.php b/bl-kernel/ajax/upload-logo.php
new file mode 100644
index 00000000..a919f59f
--- /dev/null
+++ b/bl-kernel/ajax/upload-logo.php
@@ -0,0 +1,40 @@
+1,
+ 'message'=>'Error trying to upload the site logo.'
+ )));
+}
+
+// File extension
+$fileExtension = pathinfo($_FILES['inputFile']['name'], PATHINFO_EXTENSION);
+
+// Final filename
+$filename = 'logo.'.$fileExtension;
+
+// Delete old image
+$oldFilename = $site->logo(false);
+if ($oldFilename) {
+ Filesystem::rmfile(PATH_UPLOADS.$oldFilename);
+}
+
+// Move from temporary directory to uploads
+rename($_FILES['inputFile']['tmp_name'], PATH_UPLOADS.$filename);
+
+// Permissions
+chmod(PATH_UPLOADS.$filename, 0644);
+
+// Store the filename in the database
+$site->set(array('logo'=>$filename));
+
+exit (json_encode(array(
+ 'status'=>0,
+ 'message'=>'Image uploaded success.',
+ 'filename'=>$filename,
+ 'absoluteURL'=>DOMAIN_UPLOADS.$filename,
+ 'absolutePath'=>PATH_UPLOADS.$filename
+)));
+
+?>
\ No newline at end of file
diff --git a/bl-kernel/site.class.php b/bl-kernel/site.class.php
index 30919076..7da8a13a 100644
--- a/bl-kernel/site.class.php
+++ b/bl-kernel/site.class.php
@@ -42,7 +42,8 @@ class Site extends dbJSON {
'imageRelativeToAbsolute'=> false,
'thumbnailWidth' => 400, // px
'thumbnailHeight' => 400, // px
- 'thumbnailQuality' => 100
+ 'thumbnailQuality' => 100,
+ 'logo'=> ''
);
function __construct()
@@ -268,6 +269,17 @@ class Site extends dbJSON {
return $this->getField('titleFormatTag');
}
+ // Returns the absolute URL of the site logo
+ // If you set $absolute=false returns only the filename
+ public function logo($absolute=true)
+ {
+ $logo = $this->getField('logo');
+ if ($absolute) {
+ return DOMAIN_UPLOADS.$logo;
+ }
+ return $logo;
+ }
+
// Returns the full domain and base url
// For example, https://www.domain.com/bludit
public function url()