diff options
Diffstat (limited to 'mod')
7 files changed, 205 insertions, 16 deletions
| diff --git a/mod/riverdashboard/index.php b/mod/riverdashboard/index.php index 2bc5f949c..802536416 100644 --- a/mod/riverdashboard/index.php +++ b/mod/riverdashboard/index.php @@ -62,7 +62,7 @@ if (empty($callback)) {  		'content' => $title . $body,  		'sidebar' => $sidebar  	); -	$body = elgg_view_layout('one_column_with_sidebar', $params); +	$body = elgg_view_layout('one_sidebar', $params);  	echo elgg_view_page($title_wording, $body);  } else {  	header("Content-type: text/html; charset=UTF-8"); diff --git a/mod/riverdashboard/start.php b/mod/riverdashboard/start.php index 71eef330e..e42bc6e01 100644 --- a/mod/riverdashboard/start.php +++ b/mod/riverdashboard/start.php @@ -205,7 +205,6 @@ $posted_max = 0) {  			" ORDER BY e.last_action desc LIMIT {$offset}, {$limit}";  	// Get data -	//return get_data($sql);  	return get_data($sql, 'elgg_row_to_elgg_river_item');  } @@ -348,6 +347,25 @@ $posted_max = 0, $pagination = true) {   * @return string|false Depending on success   */  function riverdashboard_view_river_item($item) { + +	if (!$item || !$item->getView() || !elgg_view_exists($item->getView())) { +		return ''; +	} + +	$subject = $item->getSubjectEntity(); +	$object = $item->getObjectEntity(); +	if (!$subject || !$object) { +		// subject is disabled or subject/object deleted +		return ''; +	} + +	$vars = array( +		'pict' => elgg_view('core/river/image', array('item' => $item)), +		'body' => elgg_view('riverdashboard/river/body', array('item' => $item)), +		'class' => 'elgg-river-item', +	); +	return elgg_view('layout/objects/media', $vars); +/*  	if (isset($item->view)) {  		$object = get_entity($item->object_guid);  		$subject = get_entity($item->subject_guid); @@ -367,4 +385,6 @@ function riverdashboard_view_river_item($item) {  		));  	}  	return false; + *  + */  } diff --git a/mod/riverdashboard/views/default/riverdashboard/css.php b/mod/riverdashboard/views/default/riverdashboard/css.php index f4870d116..29d0d6bb8 100644 --- a/mod/riverdashboard/views/default/riverdashboard/css.php +++ b/mod/riverdashboard/views/default/riverdashboard/css.php @@ -29,14 +29,14 @@  }  /* RIVER ENTRY */ -.river-item { +.elgg-river-item {  	border-bottom:1px solid #cccccc;  	padding:7px 0 7px 0;  } -.river-item p { +.elgg-river-item p {  	margin:0;  } -.river-item .entity-subtext { +.elgg-river-item .entity-subtext {  	display: block;  	line-height: 1.4em;  } @@ -120,26 +120,26 @@  	margin-left: 7px;  }  /* hidden list of users that liked item */ -.river-item .elgg-likes-user { +.elgg-likes-user {  	border-bottom:1px solid white;  	padding:3px;  } -.river-item .elgg-likes-user .entity-listing-icon { +.elgg-likes-user .entity-listing-icon {  	margin:3px 0 4px 2px;  } -.river-item .elgg-likes-user .entity-listing-info { +.elgg-likes-user .entity-listing-info {  	width:635px;  }  #profile-content .river-item .elgg-likes-user .entity-listing-info { /* when likes is displayed on profile page activity stream */  	width:600px;  } -.river-item .elgg-likes-user .entity-metadata { +.elgg-likes-user .entity-metadata {  	margin-top:3px;  } -.river-item p.elgg-likes-owner { +p.elgg-likes-owner {  	padding-top:0;  } -.river-item a.river-more-comments { +a.river-more-comments {  	display:block;  	float:right;  	padding:1px 7px 1px 7px; @@ -154,14 +154,14 @@  	-webkit-border-top-left-radius:4px;  	-webkit-border-top-right-radius:4px;  } -.river-item a.river-more-comments.off { +a.river-more-comments.off {  	background-color: white;  } -.river-item .river-comment-owner-icon { +.river-comment-owner-icon {  	float:left;  	margin:3px 8px 4px 2px;  } -.river-item .river-comment-contents { +.river-comment-contents {  	margin-left:34px;  }  a.river-more-comments { diff --git a/mod/riverdashboard/views/default/riverdashboard/js.php b/mod/riverdashboard/views/default/riverdashboard/js.php index 09b1113d8..9286d33fe 100644 --- a/mod/riverdashboard/views/default/riverdashboard/js.php +++ b/mod/riverdashboard/views/default/riverdashboard/js.php @@ -1,7 +1,7 @@  <script type="text/javascript">  	$(document).ready(function() {  		$('.river-comment-form-button').click(function() { -			elgg_slide_toggle(this, '.river-item', '.river-comment_form'); +			elgg_slide_toggle(this, '.elgg-module', '.river-comment-form');  		});  		$('.likes_user_list_button').click(function() { diff --git a/mod/riverdashboard/views/default/riverdashboard/river/body.php b/mod/riverdashboard/views/default/riverdashboard/river/body.php new file mode 100644 index 000000000..ab1227609 --- /dev/null +++ b/mod/riverdashboard/views/default/riverdashboard/river/body.php @@ -0,0 +1,38 @@ +<?php +/** + * Body of river item + * + * @uses $vars[item] + */ + +$item = $vars[item]; +$subject = $item->getSubjectEntity(); +$object = $item->getObjectEntity(); + +// river item header +$params = array( +	'href' => $subject->getURL(), +	'text' => $subject->name, +); +$subject_link = elgg_view('output/url', $params); +$timestamp = elgg_get_friendly_time($item->getPostedTime()); +$header = "$subject_link <span class=\"elgg-river-timestamp\">$timestamp</span>"; + +// body +$body = elgg_view($item->getView(), array('item' => $item)); +if ($object->getType() == 'object' && $vars['item']->annotation_id == 0) { +	$body .= '<div></div>'; +	$body .= "<a class='river-comment-form-button link'>Comment</a>"; +	$body .= elgg_view('forms/likes/link', array('entity' => $object)); +} + +// footer +$footer = elgg_view('riverdashboard/river/footer', $vars); + +$params = array( +	'header' => $header, +	'body' => $body, +	'footer' => $footer, +	'show_inner' => false, +); +echo elgg_view('layout/objects/module', $params); diff --git a/mod/riverdashboard/views/default/riverdashboard/river/footer.php b/mod/riverdashboard/views/default/riverdashboard/river/footer.php new file mode 100644 index 000000000..82aae00c2 --- /dev/null +++ b/mod/riverdashboard/views/default/riverdashboard/river/footer.php @@ -0,0 +1,131 @@ +<?php +/** + * River item footer + */ + + +$object = get_entity($vars['item']->object_guid); +$object_url = $object->getURL(); +$likes_count = elgg_count_likes($object); + +//user +//if displaying on the profile get the object owner, else the subject_guid +if (elgg_get_context() == 'profile' && $object->getSubtype() ==  'thewire') { +	$user = get_entity($object->owner_guid); +} else { +	$user = get_entity($vars['item']->subject_guid); +} + +// get last three comments display +// want the 3 most recent comments (order by time_created desc = 3 2 1 limit 3) +// but will display them with the newest at the bottom (1 2 3) +if ($comments = get_annotations($vars['item']->object_guid, "", "", 'generic_comment', "", "", 3, 0, "desc")) { +	$comments = array_reverse($comments); +} + +// for displaying "+N more" +// -3 from the count because the 3 displayed don't count in the "more" +$comment_count = count_annotations($vars['item']->object_guid, $vars['item']->type, $vars['item']->subtype, 'generic_comment'); +if ($comment_count < 3) { +	$more_comments_count = 0; +} else { +	$more_comments_count = $comment_count - 3; +} + +// body contents, generated by the river view in each plugin +echo $vars['body']; + +// display latest 3 comments if there are any +if ($comments){ +	$counter = 0; + +	echo "<div class='river-comments-tabs clearfix'>"; +	echo "<a class='river-more-comments show_comments_button link'>" . elgg_echo('comments') . '</a>'; + +	if ($likes_count != 0) { +		echo elgg_view('forms/likes/display', array('entity' => $object)); +	} + +	echo "</div>"; // close river-comments-tabs + +	echo "<div class='river-comments'>"; + +	if ($likes_count != 0) { +		//show the users who liked the object +		// this is loaded via ajax to avoid pounding the server with avatar requests. +		echo "<div class='likes-list hidden'></div>"; +	} + +	echo "<div class=\"comments_container\">"; +	// display appropriate comment link +	if ($more_comments_count > 0) { +		echo "<a class=\"river-more-comments show_more_button link\">" . +		elgg_echo('riverdashboard:n_more_comments', array($more_comments_count)) . '</a>'; + +		echo "<a style=\"display: none\" class=\"river-more-comments show_less_button link\">" . elgg_echo('riverdashboard:show_less') . '</a>'; +	} +	echo "<div class=\"comments_list\">"; +	foreach ($comments as $comment) { +		//get the comment owner +		$comment_owner = get_user($comment->owner_guid); +		//get the comment owner's profile url +		$comment_owner_url = $comment_owner->getURL(); +		// color-code each of the 3 comments +		// @todo this isn't used in CSS... +		if( ($counter == 2 && $comment_count >= 4) || ($counter == 1 && $comment_count == 2) || ($counter == 0 && $comment_count == 1) || ($counter == 2 && $comment_count == 3) ) { +			$alt = 'latest'; +		} else if( ($counter == 1 && $comment_count >= 4) || ($counter == 0 && $comment_count == 2) || ($counter == 1 && $comment_count == 3) ) { +			$alt = 'penultimate'; +		} +		//display comment +		echo "<div class='river-comment $alt clearfix'>"; +		echo "<span class='river-comment-owner-icon'>"; +		echo elgg_view("profile/icon", array('entity' => $comment_owner, 'size' => 'tiny')); +		echo "</span>"; + +		//truncate comment to 150 characters and strip tags +		$contents = elgg_get_excerpt($comment->value, 150); + +		echo "<div class='river-comment-contents'>"; +		echo "<a href=\"{$comment_owner_url}\">" . $comment_owner->name . '</a> <span class="elgg_excerpt">' . parse_urls($contents) . '</span>'; +		echo "<span class='entity-subtext'>" . elgg_view_friendly_time($comment->time_created) . "</span>"; +		echo "</div></div>"; +		$counter++; +	} + +	// close comments_list, comments_container and river-comments +	echo '</div></div>' . elgg_make_river_comment($object) . '</div>'; +} else { +	// tab bar nav - for users that liked object +	if ($vars['item']->type != 'user' && $likes_count != 0) { +		echo "<div class='river-comments-tabs clearfix'>"; +	} + +	if ($likes_count != 0) { +		echo elgg_view('forms/likes/display', array('entity' => $object)); +	} + +	if ($vars['item']->type != 'user' && $likes_count != 0) { +		echo "</div>"; // close river-comments-tabs +	} + +	if ($vars['item']->type != 'user') { +		echo "<div class='river-comments'>"; +	} +	if ($likes_count != 0) { +		//show the users who liked the object +		echo "<div class='likes-list hidden'>"; +		echo list_annotations($object->getGUID(), 'likes', 99); +		echo "</div>"; +	} + +	// if there are no comments to display +	// and this is not a user - include the inline comment form +	if ($vars['item']->type != 'user') { +		echo elgg_make_river_comment($object); +	} +	if ($vars['item']->type != 'user') { +		echo "</div>"; +	} +} +?> diff --git a/mod/riverdashboard/views/default/riverdashboard/rivercomment.php b/mod/riverdashboard/views/default/riverdashboard/rivercomment.php index d6037557d..e1c6ab07f 100644 --- a/mod/riverdashboard/views/default/riverdashboard/rivercomment.php +++ b/mod/riverdashboard/views/default/riverdashboard/rivercomment.php @@ -5,7 +5,7 @@   */  if (isset($vars['entity']) && isloggedin()) { -	$form_body = "<div class='river-comment_form hidden'>"; +	$form_body = "<div class='river-comment-form hidden'>";  	$form_body .= elgg_view('input/text',array(  							'internalname' => 'generic_comment',  							'value' => 'Add a comment...', | 
