63 return self::normalizeTime(
$time)->getTimestamp();
76 if (
$time instanceof ElggDateTime) {
79 $dt =
new ElggDateTime(
$time->format(\DateTimeInterface::RFC3339_EXTENDED));
81 $dt =
new ElggDateTime();
86 $dt =
new ElggDateTime();
88 }
catch (\Exception $e) {
109 foreach (
$args as $arg) {
114 if (is_object($arg) && isset($arg->id)) {
115 $ids[] = (int) $arg->id;
116 }
elseif (is_array($arg)) {
117 foreach ($arg as $a) {
118 $el_ids = self::normalizeIds($a);
119 $ids = array_merge($ids, $el_ids);
121 }
elseif (is_numeric($arg)) {
124 $arg = print_r($arg,
true);
129 return array_unique($ids);
146 foreach (
$args as $arg) {
151 if (is_object($arg) && isset($arg->guid)) {
152 $guids[] = (int) $arg->guid;
153 }
elseif (is_array($arg)) {
154 foreach ($arg as $a) {
155 $el_guids = self::normalizeGuids($a);
158 }
elseif (is_numeric($arg)) {
161 $arg = print_r($arg,
true);
166 return array_unique(
$guids);
178 return [ViewsService::OUTPUT_KEY =>
''];
212 if (!is_numeric($n)) {
217 $negative = abs($n) !== $n;
220 $decimal_separator = substr(
elgg_echo(
'number_counter:decimal_separator'), 0, 1);
224 $n = self::numberFormat($n, $decimals);
227 $n = self::numberFormat($n / 1000, $decimals);
228 $text_key =
'number_counter:view:thousand';
229 }
elseif ($n < 1000000000) {
231 $n = self::numberFormat($n / 1000000, $decimals);
232 $text_key =
'number_counter:view:million';
233 }
elseif ($n < 1000000000000) {
235 $n = self::numberFormat($n / 1000000000, $decimals);
236 $text_key =
'number_counter:view:billion';
239 $n = self::numberFormat($n / 1000000000000, $decimals);
240 $text_key =
'number_counter:view:trillion';
243 if (stristr($n, $decimal_separator) !==
false) {
245 $parts = explode($decimal_separator, $n);
246 $parts[1] = rtrim($parts[1], 0);
248 $n = implode($decimal_separator, array_filter($parts));
252 $n = $negative ?
"-{$n}" : $n;
254 return $text_key ?
elgg_echo($text_key, [$n]) : $n;
267 public static function numberFormat(
float $number,
int $decimals = 0): string {
268 $decimal_separator = substr(
elgg_echo(
'number_counter:decimal_separator'), 0, 1);
269 $thousands_separator = substr(
elgg_echo(
'number_counter:thousands_separator'), 0, 1);
271 return number_format($number, $decimals, $decimal_separator, $thousands_separator);
$guids
Activates all specified installed and inactive plugins.
if(! $annotation instanceof ElggAnnotation) $time
Extension of the DateTime class to support formatting a date using the locale.
Functions for use as event handlers or other situations where you need a globally accessible callable...
static getNull()
Return null.
static normalizeGuids(... $args)
Flatten an array of data into an array of GUIDs.
static getTrue()
Return true.
static normalizeIds(... $args)
Prepare IDs.
static getArray()
Return empty array.
static shortFormatOutput($n, int $decimals=0)
Use to convert large positive numbers in to short form like 1K, 1M, 1B or 1T Example: shortFormatOutp...
static normalizeTimestamp($time)
Returns timestamp value of the time representation.
static numberFormat(float $number, int $decimals=0)
Format a number with grouped thousands using language specific separators.
static isEmpty($value)
Check if a value isn't empty, but allow 0 and '0'.
static preventViewOutput()
Return array with __view_output set to prevent view output during view_vars event.
static normalizeTime($time)
Returns DateTime object based on time representation.
static getFalse()
Return false.
const ELGG_ENTITIES_ANY_VALUE
Constant to request the value of a parameter be ignored in elgg_get_*() functions.
if($item instanceof \ElggEntity) elseif($item instanceof \ElggRiverItem) elseif($item instanceof \ElggRelationship) elseif(is_callable([ $item, 'getType']))
$args
Some servers don't allow PHP to check the rewrite, so try via AJAX.
elgg_echo(string $message_key, array $args=[], string $language='')
Elgg language module Functions to manage language and translations.
if(parse_url(elgg_get_site_url(), PHP_URL_PATH) !=='/') if(file_exists(elgg_get_root_path() . 'robots.txt'))
Set robots.txt.