aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/ItemObject.php12
-rw-r--r--include/bb2diaspora.php15
-rwxr-xr-xinclude/items.php2
-rw-r--r--include/photos.php70
-rw-r--r--mod/editpost.php2
-rw-r--r--mod/item.php1
-rw-r--r--view/css/conversation.css8
-rw-r--r--view/theme/redbasic/css/style.css8
-rwxr-xr-xview/tpl/conv_item.tpl9
-rwxr-xr-xview/tpl/jot.tpl2
10 files changed, 98 insertions, 31 deletions
diff --git a/include/ItemObject.php b/include/ItemObject.php
index ee431dccb..9fe86118c 100644
--- a/include/ItemObject.php
+++ b/include/ItemObject.php
@@ -278,7 +278,16 @@ class Item extends BaseObject {
$children = $this->get_children();
- $is_photo = ((($item['resource_type'] == 'photo') && (feature_enabled($conv->get_profile_owner(),'large_photos'))) ? true : false);
+ $is_photo = (($item['obj_type'] == ACTIVITY_OBJ_PHOTO) ? true : false);
+ if($is_photo) {
+ $object = json_decode($item['object'],true);
+ $photo = array(
+ 'url' => rawurldecode($object['id']) . '?zid=' . $observer['xchan_addr'],
+ 'link' => rawurldecode(get_rel_link($object['link'],'alternate')) . '?zid=' . $observer['xchan_addr'],
+ 'width' => $object['width'],
+ 'height' => $object['height']
+ );
+ }
$has_tags = (($body['tags'] || $body['categories'] || $body['mentions'] || $body['attachments'] || $body['folders']) ? true : false);
@@ -334,6 +343,7 @@ class Item extends BaseObject {
'owner_photo' => $this->get_owner_photo(),
'owner_name' => $this->get_owner_name(),
'is_photo' => $is_photo,
+ 'photo' => (($is_photo) ? $photo : ''),
'has_tags' => $has_tags,
// Item toolbar buttons
diff --git a/include/bb2diaspora.php b/include/bb2diaspora.php
index 692128087..95de43ec3 100644
--- a/include/bb2diaspora.php
+++ b/include/bb2diaspora.php
@@ -305,6 +305,21 @@ function bb2diaspora_itembody($item, $force_update = false) {
$matches = array();
+ //if we have a photo item just prepend the photo bbcode to item['body']
+ $is_photo = (($item['obj_type'] == ACTIVITY_OBJ_PHOTO) ? true : false);
+ if($is_photo) {
+ $object = json_decode($item['object'],true);
+ $photo = array(
+ 'url' => rawurldecode($object['id']),
+ 'link' => rawurldecode(get_rel_link($object['link'],'alternate')),
+ 'width' => $object['width'],
+ 'height' => $object['height']
+ );
+
+ $photo_bb = '[zrl=' . $photo['link'] . ']' . '[zmg=' . $photo['width'] . 'x' . $photo['height'] . ']' . $photo['url'] . '[/zmg]' . '[/zrl]';
+ $item['body'] = (($item['body']) ? $photo_bb . $item['body'] : $photo_bb);
+ }
+
if(($item['diaspora_meta']) && (! $force_update)) {
$diaspora_meta = json_decode($item['diaspora_meta'],true);
if($diaspora_meta) {
diff --git a/include/items.php b/include/items.php
index 9159f6da3..08be981e7 100755
--- a/include/items.php
+++ b/include/items.php
@@ -889,7 +889,6 @@ function get_item_elements($x,$allow_code = false) {
$arr['mimetype'] = (($x['mimetype']) ? htmlspecialchars($x['mimetype'], ENT_COMPAT,'UTF-8',false) : '');
$arr['obj_type'] = (($x['object_type']) ? htmlspecialchars($x['object_type'], ENT_COMPAT,'UTF-8',false) : '');
$arr['tgt_type'] = (($x['target_type']) ? htmlspecialchars($x['target_type'], ENT_COMPAT,'UTF-8',false) : '');
- $arr['resource_type'] = (($x['resource_type']) ? htmlspecialchars($x['resource_type'], ENT_COMPAT,'UTF-8',false) : '');
$arr['public_policy'] = (($x['public_scope']) ? htmlspecialchars($x['public_scope'], ENT_COMPAT,'UTF-8',false) : '');
if($arr['public_policy'] === 'public')
@@ -1286,7 +1285,6 @@ function encode_item($item,$mirror = false) {
$x['verb'] = $item['verb'];
$x['object_type'] = $item['obj_type'];
$x['target_type'] = $item['tgt_type'];
- $x['resource_type'] = $item['resource_type'];
$x['permalink'] = $item['plink'];
$x['location'] = $item['location'];
$x['longlat'] = $item['coord'];
diff --git a/include/photos.php b/include/photos.php
index e78b899e0..2ec983833 100644
--- a/include/photos.php
+++ b/include/photos.php
@@ -186,7 +186,8 @@ function photo_upload($channel, $observer, $args) {
$p['description'] = $args['description'];
$r0 = $ph->save($p);
- $r0wxh = $ph->getWidth() . 'x' . $ph->getHeight();
+ $r0width = $ph->getWidth();
+ $r0height = $ph->getHeight();
if(! $r0)
$errors = true;
@@ -198,7 +199,8 @@ function photo_upload($channel, $observer, $args) {
$p['scale'] = 1;
$r1 = $ph->save($p);
- $r1wxh = $ph->getWidth() . 'x' . $ph->getHeight();
+ $r1width = $ph->getWidth();
+ $r1height = $ph->getHeight();
if(! $r1)
$errors = true;
@@ -207,7 +209,8 @@ function photo_upload($channel, $observer, $args) {
$p['scale'] = 2;
$r2 = $ph->save($p);
- $r2wxh = $ph->getWidth() . 'x' . $ph->getHeight();
+ $r2width = $ph->getWidth();
+ $r2height = $ph->getHeight();
if(! $r2)
$errors = true;
@@ -216,7 +219,8 @@ function photo_upload($channel, $observer, $args) {
$p['scale'] = 3;
$r3 = $ph->save($p);
- $r3wxh = $ph->getWidth() . 'x' . $ph->getHeight();
+ $r3width = $ph->getWidth();
+ $r3height = $ph->getHeight();
if(! $r3)
$errors = true;
@@ -242,17 +246,48 @@ function photo_upload($channel, $observer, $args) {
}
}
- $larger = feature_enabled($channel['channel_id'], 'large_photos');
+ $title = (($args['filename']) ? $args['filename'] : '');
- if($larger) {
- $tag = (($r1wxh) ? '[zmg=' . $r1wxh . ']' : '[zmg]');
+ $large_photos = feature_enabled($channel['channel_id'], 'large_photos');
+
+ if($large_photos) {
$scale = 1;
+ $width = $r1width;
+ $height = $r1height;
+ $tag = (($r1) ? '[zmg=' . $width . 'x' . $height . ']' : '[zmg]');
+
+ // Create item object
+ $href = rawurlencode(z_root() . '/photos/' . $channel['channel_address'] . '/image/' . $photo_hash);
+ $url = rawurlencode(z_root() . "/photo/{$photo_hash}-{$scale}.".$ph->getExt());
+
+ $link = array();
+ $link[] = array(
+ 'rel' => 'alternate',
+ 'type' => 'text/html',
+ 'href' => $href
+ );
+
+ $object = array(
+ 'type' => ACTIVITY_OBJ_PHOTO,
+ 'title' => $title,
+ 'id' => $url,
+ 'link' => $link,
+ 'width' => $width,
+ 'height' => $height
+ );
}
else {
- $tag = (($r2wxh) ? '[zmg=' . $r2wxh . ']' : '[zmg]');
$scale = 2;
+ $width = $r2width;
+ $height = $r2height;
+ $tag = (($r2) ? '[zmg=' . $width . 'x' . $height . ']' : '[zmg]');
+
+ $body = '[zrl=' . z_root() . '/photos/' . $channel['channel_address'] . '/image/' . $photo_hash . ']'
+ . $tag . z_root() . "/photo/{$photo_hash}-{$scale}.".$ph->getExt() . '[/zmg]'
+ . '[/zrl]';
}
+
// Create item container
if($args['item']) {
@@ -263,13 +298,14 @@ function photo_upload($channel, $observer, $args) {
if($item['mid'] === $item['parent_mid']) {
- $item['body'] = '[zrl=' . z_root() . '/photos/' . $channel['channel_address'] . '/image/' . $photo_hash . ']'
- . $tag . z_root() . "/photo/{$photo_hash}-{$scale}.".$ph->getExt() . '[/zmg]'
- . '[/zrl]';
+ $item['body'] = (($body) ? $body: '');
+
+ $arr['obj_type'] = (($object) ? ACTIVITY_OBJ_PHOTO : '');
+ $arr['object'] = (($object) ? json_encode($object) : '');
if($item['author_xchan'] === $channel['channel_hash']) {
- $item['sig'] = base64url_encode(rsa_sign($item['body'],$channel['channel_prvkey']));
- $item['item_verified'] = 1;
+ $item['sig'] = base64url_encode(rsa_sign($item['body'],$channel['channel_prvkey']));
+ $item['item_verified'] = 1;
}
else {
$item['sig'] = '';
@@ -297,7 +333,6 @@ function photo_upload($channel, $observer, $args) {
}
}
else {
- $title = $args['filename'] ? $args['filename'] : '';
$mid = item_message_id();
$arr = array();
@@ -320,15 +355,14 @@ function photo_upload($channel, $observer, $args) {
$arr['deny_cid'] = $ac['deny_cid'];
$arr['deny_gid'] = $ac['deny_gid'];
$arr['verb'] = ACTIVITY_POST;
+ $arr['obj_type'] = (($object) ? ACTIVITY_OBJ_PHOTO : '');
+ $arr['object'] = (($object) ? json_encode($object) : '');
$arr['item_wall'] = 1;
$arr['item_origin'] = 1;
$arr['item_thread_top'] = 1;
$arr['item_private'] = intval($acl->is_private());
$arr['plink'] = z_root() . '/channel/' . $channel['channel_address'] . '/?f=&mid=' . $arr['mid'];
-
- $arr['body'] = '[zrl=' . z_root() . '/photos/' . $channel['channel_address'] . '/image/' . $photo_hash . ']'
- . $tag . z_root() . "/photo/{$photo_hash}-{$scale}.".$ph->getExt() . '[/zmg]'
- . '[/zrl]';
+ $arr['body'] = (($body) ? $body : '');
$result = item_store($arr);
$item_id = $result['item_id'];
diff --git a/mod/editpost.php b/mod/editpost.php
index d4dc35ef8..1bee16ee7 100644
--- a/mod/editpost.php
+++ b/mod/editpost.php
@@ -129,7 +129,7 @@ function editpost_content(&$a) {
'$consensus' => intval($itm[0]['item_consensus']),
'$wait' => t('Please wait'),
'$permset' => t('Permission settings'),
- '$ptyp' => $itm[0]['type'],
+ '$ptyp' => $itm[0]['obj_type'],
'$content' => undo_post_tagging($itm[0]['body']),
'$post_id' => $post_id,
'$parent' => (($itm[0]['parent'] != $itm[0]['id']) ? $itm[0]['parent'] : ''),
diff --git a/mod/item.php b/mod/item.php
index 7488e709b..32c417c56 100644
--- a/mod/item.php
+++ b/mod/item.php
@@ -107,7 +107,6 @@ function item_post(&$a) {
$layout_mid = ((x($_REQUEST,'layout_mid')) ? escape_tags($_REQUEST['layout_mid']): '');
$plink = ((x($_REQUEST,'permalink')) ? escape_tags($_REQUEST['permalink']) : '');
$obj_type = ((x($_REQUEST,'obj_type')) ? escape_tags($_REQUEST['obj_type']) : ACTIVITY_OBJ_NOTE);
-
// allow API to bulk load a bunch of imported items with sending out a bunch of posts.
$nopush = ((x($_REQUEST,'nopush')) ? intval($_REQUEST['nopush']) : 0);
diff --git a/view/css/conversation.css b/view/css/conversation.css
index df89eb7d1..ba2eac3b6 100644
--- a/view/css/conversation.css
+++ b/view/css/conversation.css
@@ -78,8 +78,12 @@ code {
/* conv_item */
.wall-photo-item img {
- width: 100% !important;
- max-width: 100% !important;
+
+}
+
+.wall-photo-item {
+ display: table;
+ margin: 0px auto;
}
.wall-item-info {
diff --git a/view/theme/redbasic/css/style.css b/view/theme/redbasic/css/style.css
index b25ca333b..e079af4da 100644
--- a/view/theme/redbasic/css/style.css
+++ b/view/theme/redbasic/css/style.css
@@ -1623,19 +1623,19 @@ img.mail-conv-sender-photo {
/* conversation */
.wall-item-head {
- padding: 10px 10px 0px 10px;
+ padding: 10px 10px 0.5em 10px;
}
.wall-item-content {
- padding: 1em 10px;
+ padding: 0.5em 10px;
}
.wall-photo-item {
- padding: 10px 0px;
+ padding: 0.5em 0px;
}
.wall-item-tools {
- padding: 0px 10px 10px 10px;
+ padding: 0.5em 10px 10px 10px;
}
diff --git a/view/tpl/conv_item.tpl b/view/tpl/conv_item.tpl
index 5bac5b412..0a6622fa4 100755
--- a/view/tpl/conv_item.tpl
+++ b/view/tpl/conv_item.tpl
@@ -33,12 +33,19 @@
</div>
<div class="clear"></div>
</div>
- <div class="{{if $item.is_photo}}wall-photo-item{{else}}wall-item-content{{/if}}" id="wall-item-content-{{$item.id}}">
+ {{if $item.is_photo}}
+ <div class="wall-photo-item" id="wall-photo-item-{{$item.id}}">
+ <a href="{{$item.photo.link}}"><img style="max-width:{{$item.photo.width}}px; width:100%; height:auto;" src={{$item.photo.url}}></a>
+ </div>
+ {{/if}}
+ {{if $item.body}}
+ <div class="wall-item-content" id="wall-item-content-{{$item.id}}">
<div class="wall-item-body" id="wall-item-body-{{$item.id}}" >
{{$item.body}}
</div>
<div class="clear"></div>
</div>
+ {{/if}}
{{if $item.has_tags}}
<div class="wall-item-tools">
{{if $item.mentions}}
diff --git a/view/tpl/jot.tpl b/view/tpl/jot.tpl
index ea68368aa..e61d75fee 100755
--- a/view/tpl/jot.tpl
+++ b/view/tpl/jot.tpl
@@ -3,7 +3,7 @@
{{if $parent}}
<input type="hidden" name="parent" value="{{$parent}}" />
{{/if}}
- <input type="hidden" name="type" value="{{$ptyp}}" />
+ <input type="hidden" name="obj_type" value="{{$ptyp}}" />
<input type="hidden" name="profile_uid" value="{{$profile_uid}}" />
<input type="hidden" name="return" value="{{$return_path}}" />
<input type="hidden" name="location" id="jot-location" value="{{$defloc}}" />