aboutsummaryrefslogtreecommitdiffstats
path: root/include/ItemObject.php
diff options
context:
space:
mode:
Diffstat (limited to 'include/ItemObject.php')
-rw-r--r--include/ItemObject.php44
1 files changed, 40 insertions, 4 deletions
diff --git a/include/ItemObject.php b/include/ItemObject.php
index 9e694b8ac..6f1c76fa1 100644
--- a/include/ItemObject.php
+++ b/include/ItemObject.php
@@ -28,6 +28,7 @@ class Item extends BaseObject {
private $threaded = false;
private $visiting = false;
private $channel = null;
+ private $display_mode = 'normal';
public function __construct($data) {
@@ -78,6 +79,7 @@ class Item extends BaseObject {
$indent = '';
$osparkle = '';
$total_children = $this->count_descendants();
+ $unseen_comments = (($item->real_uid) ? 0 : $this->count_unseen_descendants());
$conv = $this->get_conversation();
$observer = $conv->get_observer();
@@ -226,11 +228,14 @@ class Item extends BaseObject {
if(strcmp(datetime_convert('UTC','UTC',$item['created']),datetime_convert('UTC','UTC','now - 12 hours')) > 0)
$indent .= ' shiny';
- localize_item($item);
+ localize_item($item);
$body = prepare_body($item,true);
+
$comment_count_txt = sprintf( tt('%d comment','%d comments',$total_children),$total_children );
+ $list_unseen_txt = (($unseen_comments) ? sprintf('%d unseen',$unseen_comments) : '');
+
$children = $this->get_children();
$tmp_item = array(
@@ -243,6 +248,7 @@ class Item extends BaseObject {
'id' => $this->get_id(),
'linktitle' => sprintf( t('View %s\'s profile - %s'), $profile_name, $item['author']['xchan_addr']),
'olinktitle' => sprintf( t('View %s\'s profile - %s'), $this->get_owner_name(), $item['owner']['xchan_addr']),
+ 'llink' => $item['llink'],
'to' => t('to'),
'via' => t('via'),
'wall' => t('Wall-to-Wall'),
@@ -287,8 +293,12 @@ class Item extends BaseObject {
'drop' => $drop,
'multidrop' => ((feature_enabled($conv->get_profile_owner(),'multi_delete')) ? $multidrop : ''),
// end toolbar buttons
+
+ 'unseen_comments' => $unseen_comments,
'comment_count' => $total_children,
'comment_count_txt' => $comment_count_txt,
+ 'list_unseen_txt' => $list_unseen_txt,
+ 'markseen' => t('Mark all seen'),
'like_count' => $like_count,
'like_list' => $like_list,
'like_list_part' => $like_list_part,
@@ -315,7 +325,8 @@ class Item extends BaseObject {
$result['children'] = array();
$nb_children = count($children);
- if($nb_children > 0) {
+
+ if(($this->get_display_mode() === 'normal') && ($nb_children > 0)) {
foreach($children as $child) {
$result['children'][] = $child->get_template_data($alike, $dlike, $thread_level + 1);
}
@@ -352,6 +363,14 @@ class Item extends BaseObject {
return $this->get_data_value('id');
}
+ public function get_display_mode() {
+ return $this->display_mode;
+ }
+
+ public function set_display_mode($mode) {
+ $this->display_mode = $mode;
+ }
+
public function is_threaded() {
return $this->threaded;
}
@@ -503,12 +522,12 @@ class Item extends BaseObject {
/**
* Get template
*/
- private function get_template() {
+ public function get_template() {
return $this->template;
}
- private function set_template($t) {
+ public function set_template($t) {
$this->template = $t;
}
@@ -533,6 +552,23 @@ class Item extends BaseObject {
return $total;
}
+ private function count_unseen_descendants() {
+ $children = $this->get_children();
+ $total = count($children);
+ if($total > 0) {
+ $total = 0;
+ foreach($children as $child) {
+ if((! visible_activity($child->data)) || array_key_exists('author_blocked',$child->data)) {
+ continue;
+ }
+ if($child->data['item_flags'] & ITEM_UNSEEN)
+ $total ++;
+ }
+ }
+ return $total;
+ }
+
+
/**
* Get the template for the comment box
*/