Пример #1
0
        if ($lastDate !== null) {
            ?>
	</div>
</div>

<?php 
        }
        $lastDate = $currentDate;
        ?>
<div class="section activity-section group" data-date="<?php 
        p($currentDate);
        ?>
">
	<h2>
		<span class="tooltip" title="<?php 
        p(\OCP\Util::formatDate(strip_time($event['timestamp']), true));
        ?>
">
			<?php 
        p(ucfirst($currentDate));
        ?>
		</span>
	</h2>
	<div class="boxcontainer">
<?php 
    }
    echo \OCA\Activity\Display::show($event);
}
if (!empty($_['activity'])) {
    ?>
	</div>
Пример #2
0
/**
 * Formats timestamp relatively to the current time using
 * a human-friendly format like "x minutes ago" or "yesterday"
 * @param int $timestamp timestamp to format
 * @param int $fromTime timestamp to compare from, defaults to current time
 * @param bool $dateOnly whether to strip time information
 * @return OC_L10N_String timestamp
 */
function relative_modified_date($timestamp, $fromTime = null, $dateOnly = false)
{
    $l = \OC::$server->getL10N('lib');
    if (!isset($fromTime) || $fromTime === null) {
        $fromTime = time();
    }
    if ($dateOnly) {
        $fromTime = strip_time($fromTime);
        $timestamp = strip_time($timestamp);
    }
    $timediff = $fromTime - $timestamp;
    $diffminutes = round($timediff / 60);
    $diffhours = round($diffminutes / 60);
    $diffdays = round($diffhours / 24);
    $diffmonths = round($diffdays / 31);
    if (!$dateOnly && $timediff < 60) {
        return $l->t('seconds ago');
    } else {
        if (!$dateOnly && $timediff < 3600) {
            return $l->n('%n minute ago', '%n minutes ago', $diffminutes);
        } else {
            if (!$dateOnly && $timediff < 86400) {
                return $l->n('%n hour ago', '%n hours ago', $diffhours);
            } else {
                if (date('G', $fromTime) - $diffhours >= 0) {
                    return $l->t('today');
                } else {
                    if (date('G', $fromTime) - $diffhours >= -24) {
                        return $l->t('yesterday');
                    } else {
                        if ($timediff < 2678400) {
                            return $l->n('%n day go', '%n days ago', $diffdays);
                        } else {
                            if ($timediff < 5184000) {
                                return $l->t('last month');
                            } else {
                                if (date('n', $fromTime) - $diffmonths > 0) {
                                    return $l->n('%n month ago', '%n months ago', $diffmonths);
                                } else {
                                    if ($timediff < 63113852) {
                                        return $l->t('last year');
                                    } else {
                                        return $l->t('years ago');
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
        if ($lastDate !== null) {
            // output box group
            if (count($eventsInGroup) > 0) {
                \OCA\Activity\Data::show(makeEventGroup($eventsInGroup));
            }
            $eventsInGroup = array();
            $lastGroup = null;
            // close previous date group
            echo '</div>';
            // boxcontainer
            echo '</div>';
            // date group
        }
        $lastDate = $currentDate;
        echo '<div class="group" data-date="' . $currentDate . '">';
        echo '<div class="groupheader"><span class="tooltip" title="' . \OCP\Util::formatDate(strip_time($event['timestamp']), true) . '">' . ucfirst($currentDate) . '</span></div>';
        echo '<div class="boxcontainer">';
    }
    $currentGroup = makeGroupKey($event);
    // new box group
    if ($lastGroup !== $currentGroup) {
        if ($lastGroup !== null) {
            // create meta event and add it to the list
            \OCA\Activity\Data::show(makeEventGroup($eventsInGroup));
            $eventsInGroup = array();
        }
        $lastGroup = $currentGroup;
    }
    $eventsInGroup[] = $event;
}
// show last group