本文整理汇总了PHP中time_ago函数的典型用法代码示例。如果您正苦于以下问题:PHP time_ago函数的具体用法?PHP time_ago怎么用?PHP time_ago使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了time_ago函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: render_chat_messages
/**
* Render the div full of chat messages.
* @param $chatlength Essentially the limit on the number of messages.
**/
function render_chat_messages($chatlength, $show_elipsis = null)
{
// Eventually there might be a reason to abstract out get_chats();
$sql = new DBAccess();
$sql->Query("SELECT sender_id, uname, message, age(now(), date) as ago FROM chat join players on chat.sender_id = player_id ORDER BY chat_id DESC LIMIT {$chatlength}");
// Pull messages
$chats = $sql->fetchAll();
$message_rows = '';
$messageCount = $sql->QueryItem("select count(*) from chat");
if (!isset($show_elipsis) && $messageCount > $chatlength) {
$show_elipsis = true;
}
$res = "<div class='chatMessages'>";
$previous_date = null;
$skip_interval = 3;
// minutes
foreach ($chats as $messageData) {
$l_ago = time_ago($messageData['ago'], $previous_date);
$message_rows .= "<li><<a href='player.php?player_id={$messageData['sender_id']}'\n\t\t target='main'>{$messageData['uname']}</a>> " . out($messageData['message']) . " <span class='chat-time'>{$l_ago}</span></li>";
$previous_date = $messageData['ago'];
// Store just prior date.
}
$res .= $message_rows;
if ($show_elipsis) {
// to indicate there are more chats available
$res .= ".<br>.<br>.<br>";
}
$res .= "</div>";
return $res;
}
开发者ID:ninjajerry,项目名称:ninjawars,代码行数:34,代码来源:lib_chat.php
示例2: Hace
/**
* @link http://css-tricks.com/snippets/php/time-ago-function/
* @param String
* @return string
*/
public function Hace($diahora)
{
$rcs = 0;
$tm = is_int($diahora) ? $diahora : strtotime($diahora);
$curTm = time();
$dif = $curTm - $tm;
$negativo = false;
if ($dif < 0) {
$dif = $dif * -1;
$negativo = true;
}
$pds = array('seg', 'min', 'hour', 'day', 'week', 'month', 'year', 'decade');
//$pds = array('segundo', 'minuto', 'hora', 'día', 'semana', 'mes', 'año', 'década');
$lngh = array(1, 60, 3600, 86400, 604800, 2630880, 31570560, 315705600);
for ($v = sizeof($lngh) - 1; $v >= 0 && ($no = $dif / $lngh[$v]) <= 1; $v--) {
}
if ($v < 0) {
$v = 0;
}
$_tm = $curTm - $dif % $lngh[$v];
$no = floor($no);
if ($no != 1) {
$pds[$v] .= substr($pds[$v], -1) == 's' ? 'es' : 's';
}
$x = sprintf("%d %s ", $no, $pds[$v]);
if ($rcs == 1 && $v >= 1 && $curTm - $_tm > 0) {
$x .= time_ago($_tm);
}
if ($negativo) {
return "-" . $x;
}
return $x;
}
开发者ID:josmel,项目名称:PortalWapMovistar,代码行数:38,代码来源:Hace.php
示例3: showDate
function showDate($date)
{
$stf = 0;
$current_time = time();
$diff = $current_time - $date;
$seconds = array('секунду', 'секунды', 'секунд');
$minutes = array('минуту', 'минуты', 'минут');
$hours = array('час', 'часа', 'часов');
$days = array('день', 'дня', 'дней');
$weeks = array('неделю', 'недели', 'недель');
$months = array('месяц', 'месяца', 'месяцев');
$years = array('год', 'года', 'лет');
$phrase = array($seconds, $minutes, $hours, $days, $weeks, $months, $years);
$length = array(1, 60, 3600, 86400, 604800, 2630880, 31570560);
for ($i = sizeof($length) - 1; $i >= 0 && ($no = $diff / $length[$i]) <= 1; $i--) {
}
if ($i < 0) {
$i = 0;
}
$_time = $current_time - $diff % $length[$i];
$no = floor($no);
$value = sprintf("%d %s ", $no, getPhrase($no, $phrase[$i]));
if ($stf == 1 && $i >= 1 && $current_time - $_time > 0) {
$value .= time_ago($_time);
}
if (strCaseCmp($value, '1 день ') == 0) {
return 'вчера';
} else {
return $value . ' назад';
}
}
开发者ID:iSkript,项目名称:Imgur-clone,代码行数:31,代码来源:functions.php
示例4: timeFromPublish
function timeFromPublish($tm, $rcs = 0)
{
$cur_tm = time();
$dif = $cur_tm - $tm;
$lngh = array(1, 60, 3600, 86400, 604800, 2630880, 31570560, 315705600);
for ($v = sizeof($lngh) - 1; $v >= 0 && ($no = $dif / $lngh[$v]) <= 1; $v--) {
}
if ($v < 0) {
$v = 0;
$_tm = $cur_tm - $dif % $lngh[$v];
}
$no = floor($no);
$useName = $this->timeNames[$v];
if ($no != 1) {
if ($useName == "mes") {
$useName .= 'es';
} else {
$useName .= 's';
}
}
$x = sprintf("%d %s ", $no, $useName);
if ($rcs == 1 && $v >= 1 && $cur_tm - $_tm > 0) {
$x .= time_ago($_tm);
}
return $x;
}
开发者ID:AndressJose,项目名称:bolsa-proyecto-integrado,代码行数:26,代码来源:YRssTwitter.php
示例5: site_getinfo
/**
* @return mixed
*/
function site_getinfo()
{
$site = elgg_get_config('site');
$siteinfo['url'] = elgg_get_site_url();
$siteinfo['sitename'] = $site->name;
$siteinfo['logo'] = elgg_get_plugin_setting('ws_get_logo', 'elgg_with_rest_api');
if ($site->description == null) {
$siteinfo['description'] = '';
} else {
$siteinfo['description'] = $site->description;
}
$siteinfo['time_created'] = time_ago($site->time_created);
$siteinfo['language'] = elgg_get_config('language');
return $siteinfo;
}
开发者ID:rohit1290,项目名称:elgg_with_rest_api,代码行数:18,代码来源:site.php
示例6: index
function index()
{
$h = new History();
$events = $h->include_related('user')->order_by('id DESC')->get_iterated();
foreach ($events as $e) {
$message = unserialize($e->message);
if (is_string($message)) {
$message = $this->messages[$message];
} else {
$key = array_shift($message);
$message = vsprintf($this->messages[$key], $message);
}
echo $message . ' by ' . $e->user_username . ' ' . time_ago($e->created_on) . '<br>';
}
exit;
}
开发者ID:Atomox,项目名称:benhelmerphotography,代码行数:16,代码来源:histories.php
示例7: time_ago
function time_ago($tm, $rcs = 0)
{
$cur_tm = time();
$dif = $cur_tm - $tm;
$pds = array('s', 'm', 'h', 'd', 'w');
$lngh = array(1, 60, 3600, 86400, 604800);
for ($v = sizeof($lngh) - 1; $v >= 0 && ($no = $dif / $lngh[$v]) <= 1; $v--) {
}
if ($v < 0) {
$v = 0;
}
$_tm = $cur_tm - $dif % $lngh[$v];
$x = sprintf("%d%s ", $no, $pds[$v]);
if ($rcs == 1 && $v >= 1 && $cur_tm - $_tm > 0) {
$x .= time_ago($_tm);
}
return $x;
}
开发者ID:ryankelley,项目名称:RaidRifts-Site,代码行数:18,代码来源:data_helper.php
示例8: get_comments
function get_comments($post_id)
{
$comment = array();
$sql = "SELECT * FROM pb_comments WHERE post_id='{$post_id}'";
$conn = new mysqli(DB_HOSTNAME, DB_USERNAME, DB_PASSWORD, DB_NAME);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$result = $conn->query($sql);
if ($result->num_rows > 0) {
while ($val = $result->fetch_assoc()) {
$user_data = json_decode(pb_table_data('pb_users', 'user_data', "user_id='+{$val['author']}'"), true);
$item = array('id' => $val['id'], 'date' => $val['date'], 'timestamp' => array('date' => $val['date'], 'laps' => time_ago(strtotime($val['date']))), 'user' => array('id' => $val['author'], 'name' => $user_data[0]['name'], 'username' => $user_data[0]['username'], 'avatar' => $user_data[0]['avatar']), 'status' => $val['status'], 'comment' => $val['comment']);
array_push($comment, $item);
}
}
$conn->close();
return json_encode($comment);
}
开发者ID:JosephsPlace,项目名称:PccBay,代码行数:19,代码来源:functions.php
示例9: render_message
function render_message($message_row, $show_buttons = true, $selected = false)
{
if (isset($_SESSION["user_id"])) {
// set a class based on the readflag
$readflag_class = $message_row["ReadFlag"] == 1 ? "read" : "";
$selected_class = $selected ? "selected" : "";
$avatar_image = $message_row["FromUsersAvatar"] != "" ? $message_row["FromUsersAvatar"] : "avatars/generic_64.jpg";
$meta = "<div class=\"avatar\"><a href=\"/" . $message_row["FromUsersUsername"] . "\" title=\"" . $message_row["FromUsersUsername"] . "\"><img src=\"/" . $avatar_image . "\" width=\"32\" height=\"32\" alt=\"" . $message_row["FromUsersUsername"] . "\" /></a></div>\n" . "<div class=\"meta\">\n" . "<div class=\"username\">from <a href=\"/" . $message_row["FromUsersUsername"] . "\" title=\"" . $message_row["FromUsersUsername"] . "\">" . $message_row["FromUsersUsername"] . "</a> to <a href=\"/" . $message_row["ToUsersUsername"] . "\" title=\"" . $message_row["ToUsersUsername"] . "\">" . $message_row["ToUsersUsername"] . "</a></div>\n" . "<div class=\"data\">" . ($message_row["Type"] == 0 ? "<a href=\"/message/" . $message_row["Id"] . "\">" . time_ago($message_row["Created"]) . "</a>" : time_ago($message_row["Created"])) . ($message_row["ParentMessagesId"] != null ? " in response to a <a href=\"/message/" . $message_row["ParentMessagesId"] . "\">message</a> by <a href=\"/" . $message_row["ParentUsersUsername"] . "\">" . $message_row["ParentUsersUsername"] . "</a>" : "") . "</div>\n" . "</div> <!-- .meta -->\n";
// work out the remove button (remove, or restore)
$remove_restore_button = "";
if ($message_row["ToUserId"] == $_SESSION["user_id"] && $message_row["ToStatus"] == 0 || $message_row["FromUserId"] == $_SESSION["user_id"] && $message_row["FromStatus"] == 0) {
$remove_restore_button = "<div class=\"button\"><a href=\"/api/message/remove/" . $message_row["Id"] . "\" title=\"Remove\" onclick=\"return confirm('Are you sure?');\">Remove</a></div>";
} else {
$remove_restore_button = "<div class=\"button\"><a href=\"/api/message/restore/" . $message_row["Id"] . "\" title=\"Restore\" onclick=\"return confirm('Are you sure?');\">Restore</a></div>";
}
$html = "<div class=\"message_wrapper\">\n" . "<div class=\"message " . $readflag_class . " " . $selected_class . "\">\n" . "<div class=\"body\">" . Markdown($message_row["Body"]) . "</div>\n" . "<div class=\"info\">\n" . ($show_buttons ? ($message_row["ToUserId"] == $_SESSION["user_id"] && $message_row["Type"] == 0 ? "<div class=\"button\"><a href=\"/messages/compose/" . $message_row["FromUsersUsername"] . "/" . $message_row["Id"] . "/#form\" title=\"Reply\">Reply</a></div>" : "") . $remove_restore_button : "") . $meta . "<div class=\"clear\"></div>\n" . "</div> <!-- .info -->\n" . "</div> <!-- .message -->\n" . "</div> <!-- .message_wrapper -->\n\n";
return $html;
}
}
开发者ID:jonbeckett,项目名称:wetheusers,代码行数:19,代码来源:messages.php
示例10: rkv_ago
function rkv_ago($tm, $rcs = 0)
{
$cur_tm = time();
$dif = $cur_tm - $tm;
$pds = array('second', 'minute', 'hour', 'day', 'week', 'month', 'year', 'decade');
$lngh = array(1, 60, 3600, 86400, 604800, 2630880, 31570560, 315705600);
for ($v = sizeof($lngh) - 1; $v >= 0 && ($no = $dif / $lngh[$v]) <= 1; $v--) {
}
if ($v < 0) {
$v = 0;
}
$_tm = $cur_tm - $dif % $lngh[$v];
$no = floor($no);
if ($no != 1) {
$pds[$v] .= 's';
}
$x = sprintf("%d %s ", $no, $pds[$v]);
if ($rcs == 1 && $v >= 1 && $cur_tm - $_tm > 0) {
$x .= time_ago($_tm);
}
return $x;
}
开发者ID:norcross,项目名称:norcross_v4,代码行数:22,代码来源:rkv-builds.php
示例11: wk_twitter
/**
* Fetches and displays twitter messages
*
* @example wk_twitter('en', 'TechblogGR', 3, '<h3>Twitter</h3><ul>', '</ul>', '<li>the_twit @ the_time</li>', 60);
*
* @return The twits
* @param string $language
* @param string $username
* @param int $messages[optional]
* @param string $prefix[optional]
* @param string $suffix[optional]
* @param string $between[optional] Using the vars: the_twit, the_time
* @param int $update_time[optional]
*/
function wk_twitter($language, $username, $messages = 1, $prefix = '', $suffix = '', $between = '', $update_time = 15)
{
//languages
if ($language == 'en') {
$ago = 'ago';
} elseif ($language == 'gr') {
$ago = 'πριν';
}
//include necessary files
include_once 'time_ago.php';
//fetch data from database
//data in db are saved like that: updated_time . '~' . $alltwits . '~' . $alltimes
$data = get_option('wk_twitter');
//seperate to time, twits, times
$data = explode('~', $data);
$updated_time = $data[0];
//seperate twits
$mytwits = explode('|', $data[1]);
//seperate times
$mytimes = explode('|', $data[2]);
//calculate current time
$mytime = date('G') * 60 + date('i');
//check if we should update twits
if ($mytime > $updated_time + $update_time || $mytime + $update_time < $updated_time) {
include_once 'update.php';
wk_twitter_update($username, $messages);
}
//create final string
$final = $prefix;
for ($i = 0; $i < $messages; $i++) {
//replace dummy vars with the real ones
$temp = str_replace('the_twit', $mytwits[$i], $between);
$temp = str_replace('the_time', time_ago($mytimes[$i], $language) . " {$ago}", $temp);
$final .= $temp;
}
$final .= $suffix;
echo $final;
}
开发者ID:Knorcedger,项目名称:main,代码行数:52,代码来源:index.php
示例12: ShowDate
function ShowDate($timestamp)
{
$stf = 0;
$cur_time = time();
$diff = $cur_time - $timestamp;
$phrase = array('second', 'minute', 'hour', 'day', 'week', 'month', 'year', 'decade');
$length = array(1, 60, 3600, 86400, 604800, 2630880, 31570560, 315705600);
for ($i = sizeof($length) - 1; $i >= 0 && ($no = $diff / $length[$i]) <= 1; $i--) {
}
if ($i < 0) {
$i = 0;
}
$_time = $cur_time - $diff % $length[$i];
$no = floor($no);
if ($no != 1) {
$phrase[$i] .= 's';
}
$value = sprintf("%d %s ", $no, $phrase[$i]);
if ($stf == 1 && $i >= 1 && $cur_tm - $_time > 0) {
$value .= time_ago($_time);
}
return $value . ' ago ';
}
开发者ID:aldogint,项目名称:SistemInformasiTerdistribusi,代码行数:23,代码来源:testCarbon.php
示例13: hace
/**
* @link http://css-tricks.com/snippets/php/time-ago-function/
* @param String
* @return string
*/
public static function hace($diahora)
{
$rcs = 0;
$tm = strtotime($diahora);
$cur_tm = time();
$dif = $cur_tm - $tm;
$pds = array('segundo', 'minuto', 'hora', 'dia', 'semana', 'mes', 'año', 'decada');
$lngh = array(1, 60, 3600, 86400, 604800, 2630880, 31570560, 315705600);
for ($v = sizeof($lngh) - 1; $v >= 0 && ($no = $dif / $lngh[$v]) <= 1; $v--) {
}
if ($v < 0) {
$v = 0;
}
$_tm = $cur_tm - $dif % $lngh[$v];
$no = floor($no);
if ($no != 1) {
$pds[$v] .= substr($pds[$v], -1) == 's' ? 'es' : 's';
}
$x = sprintf("%d %s ", $no, $pds[$v]);
if ($rcs == 1 && $v >= 1 && $cur_tm - $_tm > 0) {
$x .= time_ago($_tm);
}
return 'hace ' . $x;
}
开发者ID:helmutpacheco,项目名称:ventas,代码行数:29,代码来源:Tools.php
示例14: ot_get_option
<?php
$newscategory = ot_get_option('news-category');
$categorynum = ot_get_option('news-category-num');
$queryObject = new WP_query(array('category__and' => $newscategory, 'posts_per_page' => $categorynum));
if ($queryObject->have_posts()) {
while ($queryObject->have_posts()) {
$queryObject->the_post();
?>
<li><a href="<?php
the_permalink();
?>
"><span><time class="post_date date updated" datetime="<?php
the_time('j M, Y');
?>
"><?php
echo time_ago();
?>
</time></span> <b class="post-title entry-title"><?php
the_title();
?>
</b> </a></li>
<?php
}
}
wp_reset_query();
?>
</ul><!-- /ticker -->
<?php
} elseif (ot_get_option('breaking-or-menu') === '2') {
?>
<nav id="mymenutwo">
开发者ID:sekane81,项目名称:ratoninquietoweb,代码行数:31,代码来源:head_sec.php
示例15: foreach
foreach ($user_data as $data) {
$author = $data['name'];
$user = $data['username'];
$avatar = $data['avatar'];
}
if (isset($_GET['timeago'])) {
$val['date'] = time_ago(strtotime($val['date']));
}
$entity = array('id' => $val['id'], 'post_id' => $val['post_id'], 'date' => $val['date'], 'author' => $val['author'], 'user' => array('name' => $author, 'username' => $user, 'avatar' => $avatar), 'status' => $val['status'], 'comment' => $val['comment']);
array_push($mainJson, $entity);
}
// end pb_comments
//pb_users
if ($slq_table == 'pb_users') {
if (isset($_GET['timeago'])) {
$val['date'] = time_ago(strtotime($val['date']));
}
$entity = array('user_id' => $val['user_id'], 'username' => $val['username'], 'num_of_ratings' => $val['num_of_ratings'], 'total_ratings' => $val['total_ratings'], 'permissions' => $val['permissions'], 'id_card_key' => $val['id_card_key'], 'contact_info' => json_decode($val['contact_info']), 'user_data' => json_decode($val['user_data']));
array_push($mainJson, $entity);
}
// end pb_users
//pb_tags
if ($slq_table == 'pb_tags') {
$entity = array('id' => $val['tag_id'], 'tag' => $val['tag'], 'count' => $val['count']);
array_push($mainJson, $entity);
}
// end pb_tags
//pb_notify
if ($slq_table == 'pb_notify') {
$entity = array('id' => $val['id'], 'to' => $val['notify_to'], 'from' => $val['notify_from'], 'item' => $val['item'], 'item' => $val['item'], 'intro' => $val['intro'], 'content' => $val['content'], 'link' => $val['link'], 'date' => $val['date'], 'seen' => $val['seen']);
array_push($mainJson, $entity);
开发者ID:JosephsPlace,项目名称:PccBay,代码行数:31,代码来源:arrays.php
示例16: album_get_posts
/**
* Created by IntelliJ IDEA.
* User: mlui
* Date: 2/11/2016
* Time: 4:40 PM
*/
function album_get_posts($context, $limit = 20, $offset = 0, $username)
{
if (!$username) {
$user = elgg_get_logged_in_user_entity();
throw new InvalidParameterException('registration:usernamenotvalid');
} else {
$user = get_user_by_username($username);
if (!$user) {
throw new InvalidParameterException('registration:usernamenotvalid');
}
}
$loginUser = elgg_get_logged_in_user_entity();
if ($context == "all") {
$params = array('type' => 'object', 'subtype' => 'album', 'owner_guid' => NULL, 'limit' => $limit, 'offset' => $offset, 'full_view' => false, 'list_type' => 'gallery', 'gallery_class' => 'tidypics-gallery');
} else {
if ($context == 'mine') {
$params = array('type' => 'object', 'subtype' => 'album', 'owner_guid' => $user->guid, 'limit' => $limit, 'offset' => $offset, 'full_view' => false, 'list_type' => 'gallery', 'gallery_class' => 'tidypics-gallery');
} else {
if ($context == 'friends') {
if ($friends = $user->getFriends(array('limit' => false))) {
$friendguids = array();
foreach ($friends as $friend) {
$friendguids[] = $friend->getGUID();
}
$params = array('type' => 'object', 'subtype' => 'album', 'owner_guids' => $friendguids, 'limit' => $limit, 'offset' => $offset, 'full_view' => false, 'list_type' => 'gallery', 'gallery_class' => 'tidypics-gallery');
}
} else {
$params = array('type' => 'object', 'subtype' => 'album', 'owner_guid' => NULL, 'limit' => $limit, 'offset' => $offset, 'full_view' => false, 'list_type' => 'gallery', 'gallery_class' => 'tidypics-gallery');
}
}
}
$albums = elgg_get_entities($params);
$site_url = get_config('wwwroot');
if ($albums) {
$return = array();
foreach ($albums as $single) {
$album['guid'] = $single->guid;
$album_cover = $single->getCoverImage();
$file_name = $album_cover->getFilenameOnFilestore();
$image_join_date = $album_cover->time_created;
$position = strrpos($file_name, '/');
$position = $position + 1;
$icon_file_name = substr_replace($file_name, 'smallthumb', $position, 0);
$image_icon_url = $site_url . 'services/api/rest/json/?method=image.get_post';
$image_icon_url = $image_icon_url . '&joindate=' . $image_join_date . '&guid=' . $album_cover->guid . '&name=' . $icon_file_name;
$image_url = $site_url . 'services/api/rest/json/?method=image.get_post';
$image_url = $image_url . '&joindate=' . $image_join_date . '&guid=' . $album_cover->guid . '&name=' . $file_name;
$album['cover_icon_url'] = $image_icon_url;
$album['cover_image_url'] = $image_url;
if ($single->title != null) {
$album['title'] = $single->title;
} else {
$album['title'] = '';
}
$album['time_create'] = time_ago($single->time_created);
if ($single->description != null) {
if (strlen($single->description) > 300) {
$entityString = substr(strip_tags($single->description), 0, 300);
$album['description'] = preg_replace('/\\W\\w+\\s*(\\W*)$/', '$1', $entityString) . '...';
} else {
$album['description'] = strip_tags($single->description);
}
} else {
$album['description'] = '';
}
$owner = get_entity($single->owner_guid);
$album['owner']['guid'] = $owner->guid;
$album['owner']['name'] = $owner->name;
$album['owner']['username'] = $owner->username;
$album['owner']['avatar_url'] = getProfileIcon($owner);
//$owner->getIconURL('small');
// $photo['img_url'] = $img_url;
$album['like_count'] = likes_count_number_of_likes($single->guid);
$album['comment_count'] = api_get_image_comment_count($single->guid);
$album['like'] = checkLike($single->guid, $loginUser->guid);
$return[] = $album;
}
} else {
$msg = elgg_echo('blog:none');
throw new InvalidParameterException($msg);
}
return $return;
}
开发者ID:manlui,项目名称:elgg_with_rest_api,代码行数:89,代码来源:album.php
示例17: strtotime
}
} else {
?>
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Archived</h3>
</div>
<div class="panel-body">
<div class="media">
<div class="media-body">
<p>
The message has been archived.
<abbr title="<?php
$archived_str = strtotime($message['archived']);
// Tuesday 8:53 AM, Jan 26 2016
echo time_ago($archived_str);
?>
">
<?php
echo date('l g:i A, M j Y', $archived_str);
?>
GMT
</abbr>
</p>
</div>
<?php
if ($message['type'] != 'campaign') {
?>
<div class="media-right">
<a href="<?php
开发者ID:RimeOfficial,项目名称:postmaster,代码行数:31,代码来源:view.php
示例18: wire_get_comments
/**
* @param $guid
* @param $username
* @param int $limit
* @param int $offset
* @return array
* @throws InvalidParameterException
*/
function wire_get_comments($guid, $username, $limit = 20, $offset = 0)
{
if (!$username) {
$user = elgg_get_logged_in_user_entity();
} else {
$user = get_user_by_username($username);
if (!$user) {
throw new InvalidParameterException('registration:usernamenotvalid');
}
}
$options = array("metadata_name" => "wire_thread", "metadata_value" => $guid, "type" => "object", "subtype" => "thewire", "limit" => $limit, "offset" => $offset);
$comments = get_elgg_comments($options, 'elgg_get_entities_from_metadata');
$return = array();
if ($comments) {
foreach ($comments as $single) {
$comment['guid'] = $single->guid;
$comment['description'] = $single->description;
$owner = get_entity($single->owner_guid);
$comment['owner']['guid'] = $owner->guid;
$comment['owner']['name'] = $owner->name;
$comment['owner']['username'] = $owner->username;
$comment['owner']['avatar_url'] = getProfileIcon($owner);
//$owner->getIconURL('small');
$comment['time_created'] = time_ago($single->time_created);
$comment['like_count'] = likes_count_number_of_likes($single->guid);
$comment['like'] = checkLike($single->guid, $user->guid);
$return[] = $comment;
}
} else {
$msg = elgg_echo('generic_comment:none');
throw new InvalidParameterException($msg);
}
return $return;
}
开发者ID:manlui,项目名称:elgg_with_rest_api,代码行数:42,代码来源:wire.php
示例19: picturefill
?>
role="article">
<header class="article-header">
<figure class="helper-image">
<?php
picturefill('dreams-640x400', 'dreams-560x350', 'dreams-480x300');
?>
</figure>
</header>
<section class="entry-content cf">
<small>
<?php
single_tag_title();
?>
<i><?php
time_ago();
?>
</i>
</small>
<h2 class="h2 entry-title">
<a href="<?php
the_permalink();
?>
" rel="bookmark" title="<?php
the_title_attribute();
?>
"><?php
the_title();
?>
</a>
</h2>
开发者ID:luisomontano,项目名称:ProtoCulture,代码行数:31,代码来源:tag-default.php
示例20: time_ago
}
// public user
} else {
$lines[] = '
<tr onmouseover="document.getElementById(\'timeago-' . $userid . '\').style.display = \'block\'" onmouseout="document.getElementById(\'timeago-' . $userid . '\').style.display = \'none\'"><td class="chatter-box"><a href="profile.php?user=' . $nick . '" class="chatter" title="View ' . $nick . ' Profile"><strong>' . $nick . '</strong></a><br /><span class="timeAgo">' . time_ago($posttime) . '</span></td>
<td>' . $shoutx . '<div class="timeago" id="timeago-' . $userid . '" style="display:none;text-align:right;">';
$lines[] = '<span class="label label-success reply-nick" style="font-weight:normal;" onclick="insertNickname(\'@' . $nick . '\')"><i class="icon-retweet icon-white"></i> Reply</span> ';
$lines[] = '</div></td></tr>
';
}
}
}
// public user
} else {
$lines[] = '
<tr onmouseover="document.getElementById(\'timeago-' . $userid . '\').style.display = \'block\'" onmouseout="document.getElementById(\'timeago-' . $userid . '\').style.display = \'none\'"><td class="chatter-box"><a href="profile.php?user=' . $nick . '" class="chatter" title="View ' . $nick . ' Profile"><strong>' . $nick . '</strong></a><br /><span class="timeAgo">' . time_ago($posttime) . '</span></td>
<td>' . $shoutx . '<div class="timeago" id="timeago-' . $userid . '" style="display:none;text-align:right;">';
$lines[] = '<span class="label label-success reply-nick" style="font-weight:normal;" onclick="insertNickname(\'@' . $nick . '\')"><i class="icon-retweet icon-white"></i> Reply</span> ';
$lines[] = '</div></td></tr>
';
}
$j++;
}
echo implode($lines);
echo '</tbody></table>';
echo "<div style='padding-top:15px;height:30px'><div style='float:right'>";
if ($show_page > 1 && $show_page < $total_pages) {
$olderpage = $show_page + 1;
$newerpage = $show_page - 1;
$firstpage = 1;
$lastpage = $total_pages;
开发者ID:heiswayi,项目名称:ishare-plus,代码行数:31,代码来源:more.php
注:本文中的time_ago函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论