<?php /** * Elgg Polls plugin * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 */ $poll = $vars['entity']; $owner = $poll->getOwnerEntity(); $friendlytime = elgg_get_friendly_time($poll->time_created); $responses = $poll->countAnnotations('vote'); $icon = '<img src="' . elgg_get_site_url() . 'mod/polls/graphics/poll.png" />'; $info = "<a href=\"{$poll->getURL()}\">{$poll->question}</a><br>"; if ($responses == 1) { $noun = elgg_echo('polls:noun_response'); } else { $noun = elgg_echo('polls:noun_responses'); } $info .= "{$responses} {$noun}<br>"; $info .= "<p class=\"owner_timestamp\"><a href=\"{$owner->getURL()}\">{$owner->name}</a> {$friendlytime}</p>"; echo elgg_view_image_block($icon, $info);
$result .= $message->value; $result .= "</div>"; } $info .= $result; } $info .= "</td></tr>"; } else { $info .= "<p>" . elgg_echo('elggchat:session:no_messages') . "</p></td></tr>"; } $info .= "</table>"; echo "<div class='elggchat-chatsessions'>"; echo $info; echo "</div>"; } else { $session_details = elgg_view("output/url", array('href' => elgg_get_site_url() . "admin/administer_utilities/elggchat?session_guid=" . $session->getGUID(), 'text' => elgg_echo('elggchat:chatsession_details'), 'is_trusted' => true, 'class' => 'elgg-button elgg-button-action')) . "<br><br>"; $delete_session = elgg_view("output/confirmlink", array('href' => elgg_get_site_url() . "action/elggchat/delete_session?chatsession=" . $session->getGUID(), 'text' => elgg_echo('elggchat:chatsession_delete'), 'confirm' => elgg_echo('elggchat:chatsession_deleteconfirm'), 'class' => 'elgg-button elgg-button-cancel')); $info = "<table>"; $info .= "<tr><td class='elggchat-chatsession-text'><label>" . elgg_echo('elggchat:session:guid', array($session->getGUID())) . "</label><td><tr>"; $info .= "<tr>"; $info .= "<td class='elggchat-chatsession-text'>" . $session_details . $delete_session . "</td>"; $info .= "<td class='elggchat-chatsession-text'>"; $info .= "<label>" . elgg_echo('elggchat:session:last_updated') . "</label>" . elgg_get_friendly_time($session->time_updated) . "<br>"; $members_count = elgg_get_entities_from_relationship(array('relationship' => ELGGCHAT_MEMBER, 'relationship_guid' => $session->getGUID(), 'count' => true)); $info .= "<label>" . elgg_echo('elggchat:session:number_chat_participants') . "</label>" . $members_count . "<br>"; $messages_count = elgg_get_annotations(array('annotation_names' => array(ELGGCHAT_MESSAGE, ELGGCHAT_SYSTEM_MESSAGE), 'guid' => $session->guid, 'count' => true)); $info .= "<label>" . elgg_echo('elggchat:session:number_session_messages') . "</label>" . $messages_count; $info .= "</td></tr></table>"; echo "<div class='elggchat-chatsessions'>"; echo $info; echo "</div>"; }
$onlineStatus = true; } if (empty($iconSize) || !in_array($iconSize, array("tiny", "small", "medium", "large", "profile"))) { $iconSize = "tiny"; } $result = ""; $result .= "<tr class='chatmember'>"; if ($icon) { $result .= "<td>" . elgg_view('output/img', array('src' => elgg_format_url($user->getIconURL($iconSize)), 'class' => 'messageIcon')) . "</td>"; } if ($link) { $result .= "<td class='chatmemberinfo'><a href='" . $user->getUrl() . "' title='" . $user->name . "' rel='" . $user->guid . "'>" . $user->name . "</a></td>"; } else { $result .= "<td class='chatmemberinfo'>" . $user->name . "</td>"; } if ($onlineStatus) { $diff = time() - $user->last_action; $inactive = (int) elgg_get_plugin_setting("onlinestatus_inactive", "elggchat"); $active = (int) elgg_get_plugin_setting("onlinestatus_active", "elggchat"); $title = elgg_echo("elggchat:session:onlinestatus", array(elgg_get_friendly_time($user->last_action))); if ($diff <= $active) { $result .= "<td><div class='online_status_chat' title='" . $title . "'></div></td>"; } elseif ($diff <= $inactive) { $result .= "<td><div class='online_status_chat online_status_idle' title='" . $title . "'></div></td>"; } else { $result .= "<td><div class='online_status_chat online_status_inactive' title='" . $title . "'></div></td>"; } } $result .= "</tr>"; echo $result; }
<?php /** * Body of river item * * @uses $vars['item'] ElggRiverItem * @uses $vars['summary'] Alternate summary (the short text summary of action) * @uses $vars['message'] Optional message (usually excerpt of text) * @uses $vars['attachments'] Optional attachments (displaying icons or other non-text data) * @uses $vars['responses'] Alternate respones (comments, replies, etc.) */ $item = $vars['item']; $menu = elgg_view_menu('river', array('item' => $item, 'sort_by' => 'priority')); // river item header $timestamp = elgg_get_friendly_time($item->getPostedTime()); $summary = elgg_extract('summary', $vars, elgg_view('river/elements/summary', array('item' => $vars['item']))); if ($summary === false) { $subject = $item->getSubjectEntity(); $summary = elgg_view('output/url', array('href' => $subject->getURL(), 'text' => $subject->name, 'class' => 'elgg-river-subject')); } $message = elgg_extract('message', $vars, false); if ($message !== false) { $message = "<div class=\"elgg-river-message\">{$message}</div>"; } $attachments = elgg_extract('attachments', $vars, false); if ($attachments !== false) { $attachments = "<div class=\"elgg-river-attachments\">{$attachments}</div>"; } $responses = elgg_view('river/elements/responses', $vars); if ($responses) { $responses = "<div class=\"elgg-river-responses\">{$responses}</div>";
$subtitle['group_admin'] = elgg_echo('user:membership:group_admin'); } if ($member = check_entity_relationship($entity->guid, 'member', $group->guid)) { $subtitle[] = elgg_echo('user:membership:member_since', [date('j M, Y', $member->time_created)]); } else { if ($request = check_entity_relationship($entity->guid, 'membership_request', $group->guid)) { $subtitle[] = elgg_echo('user:membership:requested', [date('j M, Y', $request->time_created)]); } else { if ($invite = check_entity_relationship($group->guid, 'invited', $entity->guid)) { $subtitle[] = elgg_echo('user:membership:invited', [date('j M, Y', $invite->time_created)]); } } } $last_action = max($entity->last_action, $entity->last_login, $entity->time_created); if ($last_action) { $subtitle['last_action'] = elgg_echo('user:membership:last_action', [elgg_get_friendly_time($last_action)]); } $menu_params = $vars; $menu_params['sort_by'] = 'priority'; $menu_params['class'] = 'elgg-menu-user-membership'; $menu = elgg_view_menu('membership', $menu_params); $metadata = ''; if (!elgg_in_context('widgets')) { $menu_params['class'] = 'elgg-menu-hz'; $metadata = elgg_view_menu('entity', $menu_params); } $title = null; $query = elgg_extract('query', $vars, get_input('query')); if ($query && elgg_is_active_plugin('search')) { $name = search_get_highlighted_relevant_substrings($entity->getDisplayName(), $query); $username = search_get_highlighted_relevant_substrings(strtolower($entity->username), $query);
/** * Test elgg_get_friendly_time() */ public function testElggGetFriendlyTime() { $current_time = time(); $offsets = array('0' => elgg_echo('friendlytime:justnow'), '-120' => elgg_echo('friendlytime:minutes', array('2')), '-60' => elgg_echo('friendlytime:minutes:singular'), '-10800' => elgg_echo('friendlytime:hours', array('3')), '-86400' => elgg_echo('friendlytime:days:singular'), '120' => elgg_echo('friendlytime:future:minutes', array('2')), '86400' => elgg_echo('friendlytime:future:days:singular')); foreach ($offsets as $num_seconds => $friendlytime) { $this->assertIdentical(elgg_get_friendly_time($current_time + $num_seconds, $current_time), $friendlytime); } }
<?php $entity = elgg_extract("entity", $vars); $full_view = elgg_extract("full_view", $vars, false); // the api application of which this is the user settings object $api_application = $entity->getContainerEntity(); $owner = $entity->getOwnerEntity(); if ($full_view) { // display information about the api application $summary = elgg_view_entity($api_application, array("full_view" => false)); // list all the push notification services $body = ""; if ($pns = $api_application->getPushNotificationServices()) { $pns_names = array_keys($pns); $pns_options = array("guid" => $entity->getGUID(), "annotation_names" => $pns_names, "limit" => false, "owner_guid" => $owner->getGUID(), "pagination" => false); $body .= elgg_view_module("pns", elgg_echo("ws_pack:usersettings:push_notification_services"), elgg_list_annotations($pns_options)); } echo elgg_view("object/elements/full", array("summary" => $summary, "body" => $body)); } else { // listing view $owner_icon = elgg_view_entity_icon($owner, "small"); $owner_link = elgg_view("output/url", array("text" => $owner->name, "href" => $owner->getURL(), "is_trusted" => true)); $subtitle = elgg_echo("entity:default:strapline", array(elgg_get_friendly_time($entity->time_created), $owner_link)); $params = array("entity" => $entity, "metadata" => "", "title" => $api_application->getTitle(), "subtitle" => $subtitle, "content" => ""); $params = $params + $vars; $summary = elgg_view("object/elements/summary", $params); echo elgg_view_image_block($owner_icon, $summary); }
?> </td> </tr> </tbody> </table> <ol> <?php foreach ($content_array as $type => $array) { echo '<li><div class="contentWrapper">' . elgg_echo('izap-antispam:total') . '<b>' . elgg_echo($type) . ': ' . count($content_array[$type]) . '</b></div>'; if (sizeof($array)) { echo '<ol>'; foreach ($array as $val) { echo '<li>'; echo '<a href = "' . $val['url'] . '" target ="_blank">' . $val['title'] . '</a> '; echo '(' . elgg_get_friendly_time($val['time_created']) . ')'; echo '</li>'; } echo '</ol><br />'; } echo '</li>'; } ?> </ol> <div align = "center"> <?php echo elgg_view('output/confirmlink', array('href' => IzapBase::getFormAction('not_spammer', GLOBAL_IZAP_ELGG_BRIDGE) . '?guid=' . $user->guid, 'text' => elgg_echo('izap-antispam:not_spammer'))); ?> - <?php echo elgg_view('output/confirmlink', array('href' => IzapBase::getFormAction('submit_spammer', GLOBAL_IZAP_ELGG_BRIDGE) . '?guid=' . $user->guid, 'text' => elgg_echo('izap-antispam:submit_spam'), 'confirm' => sprintf(elgg_echo('izap-antispam:confirm'), $user->name . '(' . $user->email . ')')));
<?php /** * Github repository view * * @uses $vars['repo'] */ $name = elgg_view('output/url', array('text' => $vars['repo']->name, 'href' => $vars['repo']->html_url, 'is_trusted' => true)); $description = $vars['repo']->description; $update = elgg_echo('community_github:update', array(elgg_get_friendly_time($vars['repo']->timestamp))); $watchers = elgg_view('output/url', array('text' => $vars['repo']->watchers, 'href' => $vars['repo']->html_url . '/watchers', 'title' => elgg_echo('community_github:watchers'))); $forks = elgg_view('output/url', array('text' => $vars['repo']->forks, 'href' => $vars['repo']->html_url . '/network', 'title' => elgg_echo('community_github:forks'))); $header = <<<HTML <ul class="github-stats"> \t<li class="github-watchers">{$watchers}</li> \t<li class="github-forks">{$forks}</li> </ul> <h3>{$name}</h3> HTML; $body = <<<HTML \t<div class="github-description">{$description}</div> \t<div class="github-updated-at">{$update}</div> HTML; echo elgg_view_module('github', '', $body, array('header' => $header));
/** * Filters listing subtitle * * @param string $hook "view_vars" * @param string $type "group/elements/summary" * @param array $return View vars * @param array $params Hook params * @return array */ function group_list_filter_listing_subtitle($hook, $type, $return, $params) { $entity = elgg_extract('entity', $return); if (!$entity instanceof ElggGroup) { return; } if (!elgg_get_plugin_setting('use_membership_view', 'group_list')) { return; } $subtitle = array(); if ($entity->isPublicMembership()) { $mem = elgg_echo('group:membership:open'); $mem_class = 'group-membership-open'; } else { $mem = elgg_echo('group:membership:closed'); $mem_class = 'group-membership-closed'; } $subtitle['public_membership'] = elgg_format_element('b', ['class' => $mem_class], $mem); if ($entity->featured_group == 'yes') { $subtitle['featured'] = elgg_format_element('b', ['class' => 'group-featured'], elgg_echo('group:featured')); } if (elgg_group_gatekeeper(false, $entity->guid)) { $member_count = $entity->getVolatileData('select:member_count'); if (!isset($member_count)) { $member_count = $entity->getMembers(array('count' => true)); } if ($member_count == 1) { $subtitle['member_count'] = elgg_echo('group:member:count:single', [$member_count]); } else { $subtitle['member_count'] = elgg_echo('group:member:count', [$member_count]); } } //$subtitle['time_created'] = elgg_echo('group:time_created', [date('j M, Y', $entity->time_created)]); if ($entity->last_action) { $subtitle['last_action'] = elgg_echo('group:last_activity', [elgg_get_friendly_time($entity->last_action)]); } $subtitle_str = ''; foreach ($subtitle as $s) { $subtitle_str .= elgg_format_element('span', ['class' => 'elgg-group-subtitle-element'], $s); } $view_subtitle = elgg_extract('subtitle', $return); if ($view_subtitle) { $view_subtitle = $subtitle_str . '<br />' . $view_subtitle; } else { $view_subtitle = $subtitle_str; } $return['subtitle'] = $view_subtitle; return $return; }
<?php /** * Friendly time * Translates an epoch time into a human-readable time. * * @uses string $vars['time'] Unix-style epoch timestamp */ $timestamp = htmlspecialchars(date(elgg_echo('friendlytime:date_format'), $vars['time'])); if (elgg_in_context("questions")) { $friendly_time = $timestamp; } else { $friendly_time = elgg_get_friendly_time($vars['time']); } echo "<acronym title=\"{$timestamp}\">{$friendly_time}</acronym>";
<?php /** * Elgg poll listing * * @package Elggpoll * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 * @author John Mellberg * @copyright John Mellberg 2009 */ $owner = $vars['entity']->getOwnerEntity(); $container = get_entity($vars['entity']->container_guid); $friendlytime = elgg_get_friendly_time($vars['entity']->time_created); $responses = $vars['entity']->countAnnotations('vote'); //$icon = ""; /**/ $icon = elgg_view("profile/icon", array('entity' => $owner, 'size' => 'small')); $info = "<a href=\"{$vars['entity']->getURL()}\">{$vars['entity']->question}</a>"; if ($container instanceof ElggGroup) { $group_bit = '<a href="' . $container->getUrl() . '">' . $container->name . '</a>'; $info .= " " . sprintf(elgg_echo('polls:group_identifier'), $group_bit); } $info .= "<br />{$responses} " . elgg_echo('polls:votes'); $info .= "<p class=\"owner_timestamp\"><a href=\"{$owner->getURL()}\">{$owner->name}</a> {$friendlytime}</p>"; echo elgg_view_image_block($icon, $info);
<?php $annotation_id = $vars['item']->annotation_id; if ($annotation_id != 2010) { $annotation = elgg_get_annotation_from_id($annotation_id); $value = explode(',', $annotation->value); $name = $value[0]; $friends = (int) $value[1]; if ($friends == 0) { $excerpt = "suicide:nocares"; } elseif ($friends < 5) { $excerpt = "suicide:autist"; } elseif ($friends < 10) { $excerpt = "suicide:lonely"; } elseif ($friends < 50) { $excerpt = "suicide:normal"; } elseif ($friends < 100) { $excerpt = "suicide:popular"; } elseif ($friends < 200) { $excerpt = "suicide:respected"; } else { $excerpt = "suicide:godlike"; } $summary = elgg_echo('suicide:suicide', array($name)) . elgg_echo($excerpt); $timestamp = elgg_get_friendly_time($annotation->time_created); $icon = elgg_get_site_url() . "mod/suicide/graphics/suicide.png"; $icon = "<img src=\"{$icon}\" width=\"40\" />"; $body = "<div class=\"elgg-river-summary\">{$summary} <span class=\"elgg-river-timestamp\">{$timestamp}</span></div>"; echo elgg_view('page/components/image_block', array('image' => $icon, 'body' => $body, 'class' => 'elgg-river-item')); }
elgg_load_library('elgg:event_poll'); $event = $vars['event']; $title = elgg_view('output/url', array('href' => 'event_poll/vote/' . $event->guid, 'text' => $event->title, 'is_trusted' => true)); $owner = $event->getOwnerEntity(); $owner_icon = elgg_view_entity_icon($owner, 'tiny'); $owner_link = elgg_view('output/url', array('href' => "event_calendar/owner/{$owner->username}", 'text' => $owner->name, 'is_trusted' => true)); $author_text = elgg_echo('byline', array($owner_link)); $date = elgg_view_friendly_time($event->time_created); $subtitle = "{$author_text} {$date}"; $body = '<div class="mts">'; if (event_poll_get_current_schedule_slot($event)) { $body .= '<label>' . elgg_echo('event_poll:listing:scheduled') . '</label>' . event_calendar_get_formatted_time($event); } else { $body .= '<label>' . elgg_echo('event_poll:listing:responded') . '</label>'; $time_responded = event_poll_get_response_time($event->guid); if ($time_responded) { $body .= elgg_get_friendly_time($time_responded); } else { $body .= elgg_echo('event_poll:listing:not_responded'); } } $body .= '</div>'; if (elgg_in_context('widgets') || !$event->canEdit()) { $metadata = ''; } else { $metadata = elgg_view_menu('entity', array('entity' => $event, 'handler' => 'event_poll', 'sort_by' => 'priority', 'class' => 'elgg-menu-hz')); } $params = array('entity' => $event, 'title' => $title, 'metadata' => $metadata, 'subtitle' => $subtitle, 'content' => $body, 'tags' => false); $params = $params + $vars; $list_body = elgg_view('object/elements/summary', $params); echo elgg_view_image_block($owner_icon, $list_body);
/** * @dataProvider providerElggGetFriendlyTime */ public function testElggGetFriendlyTime($num_seconds, $friendlytime) { $current_time = time(); $this->assertSame(elgg_get_friendly_time($current_time + $num_seconds, $current_time), $friendlytime); }