aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorzotlabs <mike@macgirvin.com>2017-11-15 12:41:03 -0800
committerzotlabs <mike@macgirvin.com>2017-11-15 12:41:03 -0800
commitcf4588f16fbe6dc55eabdb590480bc88d560dad3 (patch)
treec056ad6dd6a173d342b6b86252e086e7d68271da
parentd43542dd7a64136626550ba0569b1939b84b8146 (diff)
parent601f1eb624fce19a1da966e0e102b208a6ae7b74 (diff)
downloadvolse-hubzilla-cf4588f16fbe6dc55eabdb590480bc88d560dad3.tar.gz
volse-hubzilla-cf4588f16fbe6dc55eabdb590480bc88d560dad3.tar.bz2
volse-hubzilla-cf4588f16fbe6dc55eabdb590480bc88d560dad3.zip
Merge branch 'dev' of https://github.com/redmatrix/hubzilla into dev_merge
-rw-r--r--Zotlabs/Storage/Browser.php2
-rw-r--r--Zotlabs/Storage/Directory.php11
-rw-r--r--Zotlabs/Storage/File.php11
-rw-r--r--include/attach.php6
-rw-r--r--include/channel.php2
-rw-r--r--include/photo/photo_driver.php16
-rw-r--r--include/photos.php50
-rw-r--r--view/css/widgets.css28
-rw-r--r--view/tpl/notifications_widget.tpl35
9 files changed, 113 insertions, 48 deletions
diff --git a/Zotlabs/Storage/Browser.php b/Zotlabs/Storage/Browser.php
index 77201f387..b5440aacf 100644
--- a/Zotlabs/Storage/Browser.php
+++ b/Zotlabs/Storage/Browser.php
@@ -210,8 +210,6 @@ class Browser extends DAV\Browser\Plugin {
}
}
-
-
$attachIcon = ""; // "<a href=\"attach/".$attachHash."\" title=\"".$displayName."\"><i class=\"fa fa-arrow-circle-o-down\"></i></a>";
// put the array for this file together
diff --git a/Zotlabs/Storage/Directory.php b/Zotlabs/Storage/Directory.php
index 0ed7a3c68..27df3569f 100644
--- a/Zotlabs/Storage/Directory.php
+++ b/Zotlabs/Storage/Directory.php
@@ -299,6 +299,17 @@ class Directory extends DAV\Node implements DAV\ICollection, DAV\IQuota {
$is_photo = 1;
}
+ // If we know it's a photo, over-ride the type in case the source system could not determine what it was
+
+ if($is_photo) {
+ q("update attach set filetype = '%s' where hash = '%s' and uid = %d",
+ dbesc($gis['mime']),
+ dbesc($hash),
+ intval($c[0]['channel_id'])
+ );
+ }
+
+
// updates entry with filesize and timestamp
$d = q("UPDATE attach SET filesize = '%s', os_path = '%s', display_path = '%s', is_photo = %d, edited = '%s' WHERE hash = '%s' AND uid = %d",
dbesc($size),
diff --git a/Zotlabs/Storage/File.php b/Zotlabs/Storage/File.php
index 947a9fde3..8bf9997ed 100644
--- a/Zotlabs/Storage/File.php
+++ b/Zotlabs/Storage/File.php
@@ -168,6 +168,17 @@ class File extends DAV\Node implements DAV\IFile {
if(($gis) && ($gis[2] === IMAGETYPE_GIF || $gis[2] === IMAGETYPE_JPEG || $gis[2] === IMAGETYPE_PNG)) {
$is_photo = 1;
}
+
+ // If we know it's a photo, over-ride the type in case the source system could not determine what it was
+
+ if($is_photo) {
+ q("update attach set filetype = '%s' where hash = '%s' and uid = %d",
+ dbesc($gis['mime']),
+ dbesc($this->data['hash']),
+ intval($this->data['uid'])
+ );
+ }
+
}
else {
// this shouldn't happen any more
diff --git a/include/attach.php b/include/attach.php
index 2bb57722b..96b9c0b44 100644
--- a/include/attach.php
+++ b/include/attach.php
@@ -588,6 +588,12 @@ function attach_store($channel, $observer_hash, $options = '', $arr = null) {
$def_extension = '.png';
}
+ // If we know it's a photo, over-ride the type in case the source system could not determine what it was
+
+ if($is_photo) {
+ $type = $gis['mime'];
+ }
+
$pathname = '';
if($is_photo) {
diff --git a/include/channel.php b/include/channel.php
index 4f0e8ec6a..b12491936 100644
--- a/include/channel.php
+++ b/include/channel.php
@@ -1743,7 +1743,7 @@ function get_theme_uid() {
if((get_pconfig(local_channel(),'system','always_my_theme')) || (! $uid))
return local_channel();
}
- if(! $uierd) {
+ if(! $uid) {
$x = get_sys_channel();
if($x)
return $x['channel_id'];
diff --git a/include/photo/photo_driver.php b/include/photo/photo_driver.php
index 5eb1f9113..21431e96f 100644
--- a/include/photo/photo_driver.php
+++ b/include/photo/photo_driver.php
@@ -309,6 +309,11 @@ abstract class photo_driver {
public function save($arr) {
+ if(! $this->is_valid()) {
+ logger('attempt to store invalid photo.');
+ return false;
+ }
+
$p = array();
$p['aid'] = ((intval($arr['aid'])) ? intval($arr['aid']) : 0);
@@ -331,6 +336,8 @@ abstract class photo_driver {
$p['os_path'] = $arr['os_path'];
$p['os_syspath'] = ((array_key_exists('os_syspath',$arr)) ? $arr['os_syspath'] : '');
$p['display_path'] = (($arr['display_path']) ? $arr['display_path'] : '');
+ $p['width'] = (($arr['width']) ? $arr['width'] : $this->getWidth());
+ $p['height'] = (($arr['height']) ? $arr['height'] : $this->getHeight());
if(! intval($p['imgscale']))
logger('save: ' . print_r($arr,true), LOGGER_DATA);
@@ -378,8 +385,8 @@ abstract class photo_driver {
dbesc(basename($p['filename'])),
dbesc($this->getType()),
dbesc($p['album']),
- intval($this->getHeight()),
- intval($this->getWidth()),
+ intval($p['height']),
+ intval($p['width']),
(intval($p['os_storage']) ? dbescbin($p['os_syspath']) : dbescbin($this->imageString())),
intval($p['os_storage']),
intval(strlen($this->imageString())),
@@ -409,8 +416,8 @@ abstract class photo_driver {
dbesc(basename($p['filename'])),
dbesc($this->getType()),
dbesc($p['album']),
- intval($this->getHeight()),
- intval($this->getWidth()),
+ intval($p['height']),
+ intval($p['width']),
(intval($p['os_storage']) ? dbescbin($p['os_syspath']) : dbescbin($this->imageString())),
intval($p['os_storage']),
intval(strlen($this->imageString())),
@@ -426,6 +433,7 @@ abstract class photo_driver {
dbesc($p['deny_gid'])
);
}
+ logger('photo save ' . $p['imgscale'] . ' returned ' . intval($r));
return $r;
}
diff --git a/include/photos.php b/include/photos.php
index c38e2bed4..41a1d18cb 100644
--- a/include/photos.php
+++ b/include/photos.php
@@ -62,27 +62,52 @@ function photo_upload($channel, $observer, $args) {
$ac = $acl->get();
+ $width = $height = 0;
+
+ if($args['getimagesize']) {
+ $width = $args['getimagesize'][0];
+ $height = $args['getimagesize'][1];
+ }
+
+
$os_storage = 0;
+ $max_thumb = get_config('system','max_thumbnail',1600);
+
if($args['os_syspath'] && $args['getimagesize']) {
- if($args['getimagesize'][0] > 1600 || $args['getimagesize'][1] > 1600) {
+ if($args['getimagesize'][0] > $max_thumb || $args['getimagesize'][1] > $max_thumb) {
$imagick_path = get_config('system','imagick_convert_path');
if($imagick_path && @file_exists($imagick_path)) {
$tmp_name = $args['os_syspath'] . '-001';
- $newsize = photo_calculate_1600_scale($args['getimagesize']);
- exec($imagick_path . ' ' . $args['os_syspath'] . ' -resize ' . $newsize . '^ ' . $tmp_name);
+ $newsize = photo_calculate_scale(array_merge($args['getimagesize'],['max' => $max_thumb]));
+ $cmd = $imagick_path . ' ' . escapeshellarg(PROJECT_BASE . '/' . $args['os_syspath']) . ' -thumbnail ' . $newsize . ' ' . escapeshellarg(PROJECT_BASE . '/' . $tmp_name);
+ // logger('imagick thumbnail command: ' . $cmd);
+ for($x = 0; $x < 4; $x ++) {
+ exec($cmd);
+ if(! file_exists($tmp_name)) {
+ logger('imagick scale failed. Retrying.');
+ continue;
+ }
+ }
+ if(! file_exists($tmp_name)) {
+ logger('imagick scale failed. Abort.');
+ return $ret;
+ }
+
$imagedata = @file_get_contents($tmp_name);
+ $filesize = @filesize($args['os_syspath']);
@unlink($tmp_name);
}
else {
$imagedata = @file_get_contents($args['os_syspath']);
+ $filesize = strlen($imagedata);
}
}
else {
$imagedata = @file_get_contents($args['os_syspath']);
+ $filesize = strlen($imagedata);
}
$filename = $args['filename'];
- $filesize = strlen($imagedata);
// this is going to be deleted if it exists
$src = '/tmp/deletemenow';
$type = $args['getimagesize']['mime'];
@@ -188,8 +213,10 @@ function photo_upload($channel, $observer, $args) {
if ($max_length > 0)
$ph->scaleImage($max_length);
- $width = $ph->getWidth();
- $height = $ph->getHeight();
+ if(! $width)
+ $width = $ph->getWidth();
+ if(! $height)
+ $height = $ph->getHeight();
$smallest = 0;
@@ -203,6 +230,7 @@ function photo_upload($channel, $observer, $args) {
$p = array('aid' => $account_id, 'uid' => $channel_id, 'xchan' => $visitor, 'resource_id' => $photo_hash,
'filename' => $filename, 'album' => $album, 'imgscale' => 0, 'photo_usage' => PHOTO_NORMAL,
+ 'width' => $width, 'height' => $height,
'allow_cid' => $ac['allow_cid'], 'allow_gid' => $ac['allow_gid'],
'deny_cid' => $ac['deny_cid'], 'deny_gid' => $ac['deny_gid'],
'os_storage' => $os_storage, 'os_syspath' => $args['os_syspath'],
@@ -224,14 +252,16 @@ function photo_upload($channel, $observer, $args) {
'rel' => 'alternate',
'type' => 'text/html',
'href' => z_root() . '/photo/' . $photo_hash . '-0.' . $ph->getExt(),
- 'width' => $ph->getWidth(),
- 'height' => $ph->getHeight()
+ 'width' => $width,
+ 'height' => $height
);
if(! $r0)
$errors = true;
unset($p['os_storage']);
unset($p['os_syspath']);
+ unset($p['width']);
+ unset($p['height']);
if(($width > 1024 || $height > 1024) && (! $errors))
$ph->scaleImage(1024);
@@ -462,9 +492,9 @@ function photo_upload($channel, $observer, $args) {
}
-function photo_calculate_1600_scale($arr) {
+function photo_calculate_scale($arr) {
- $max = 1600;
+ $max = $arr['max'];
$width = $arr[0];
$height = $arr[1];
diff --git a/view/css/widgets.css b/view/css/widgets.css
index cea3a3820..5b1273e25 100644
--- a/view/css/widgets.css
+++ b/view/css/widgets.css
@@ -168,3 +168,31 @@ a.wikilist {
.active .conv-participants {
color: #fff;
}
+
+/* notifications */
+
+.notification-content {
+ max-height: 70vh;
+ overflow: auto;
+}
+
+.notification-content.collapsing {
+ overflow: hidden;
+}
+
+.fs {
+ position: fixed;
+ top: 0px;
+ left: 0px;
+ padding: 4.5rem .5rem 1rem .5rem;
+ background-color: white;
+ width: 100%;
+ max-width: 100%;
+ height: 100%;
+ z-index: 1029;
+ overflow: auto;
+}
+
+#notifications {
+ margin-bottom: 1rem;
+}
diff --git a/view/tpl/notifications_widget.tpl b/view/tpl/notifications_widget.tpl
index 29892ba79..3ef7bff7d 100644
--- a/view/tpl/notifications_widget.tpl
+++ b/view/tpl/notifications_widget.tpl
@@ -1,32 +1,3 @@
-<style>
- .notification-content {
- max-height: 70vh;
- overflow: auto;
- }
-
- .notification-content.collapsing {
- overflow: hidden;
- }
-
- .fs {
- position: fixed;
- top: 0px;
- left: 0px;
- padding: 4.5rem .5rem 1rem .5rem;
- background-color: white;
- width: 100%;
- max-width: 100%;
- height: 100%;
- z-index: 1029;
- overflow: auto;
- }
-
- #notifications {
- margin-bottom: 1rem;
- }
-</style>
-
-{{if $module == 'display'}}
<script>
var notifications_parent;
$(document).ready(function() {
@@ -44,6 +15,7 @@
});
});
+ {{if $module == 'display'}}
$(document).on('click', '.notification', function(e) {
var b64mid = $(this).data('b64mid');
var path = $(this)[0].pathname.substr(1,7);
@@ -60,11 +32,12 @@
liveUpdate();
if($('#notifications_wrapper').hasClass('fs'))
- $('#notifications_wrapper').prependTo('#' + notifications_parent).removeClass('fs'); //var notifications_parent is defined in redbasic.js
+ $('#notifications_wrapper').prependTo('#' + notifications_parent).removeClass('fs');
}
});
+ {{/if}}
</script>
-{{/if}}
+
{{if $notifications}}
<div id="notifications_wrapper">