Browse Source

rename localization helper to format, add posts br support

main
ghost 3 years ago
parent
commit
88b2dd53a5
  1. 8
      src/application/controller/api/post/get.php
  2. 2
      src/bootstrap.php
  3. 11
      src/system/helper/format.php

8
src/application/controller/api/post/get.php

@ -43,16 +43,16 @@ if (isset($_SESSION['userName'])) { @@ -43,16 +43,16 @@ if (isset($_SESSION['userName'])) {
}
$reTwist = [
'message' => implode('', $reTwists),
'time' => Localization::time($post['userpost']['rt']['time']),
'message' => Format::post(implode('', $reTwists)),
'time' => Format::time($post['userpost']['rt']['time']),
'userName' => $post['userpost']['rt']['n'],
'reTwist' => $reTwist,
];
}
$posts[] = [
'message' => implode('', $messages),
'time' => Localization::time($post['userpost']['time']),
'message' => Format::post(implode('', $messages)),
'time' => Format::time($post['userpost']['time']),
'userName' => $post['userpost']['n'],
'reTwist' => $reTwist,
];

2
src/bootstrap.php

@ -12,7 +12,7 @@ require(PROJECT_DIR . '/system/twister.php'); @@ -12,7 +12,7 @@ require(PROJECT_DIR . '/system/twister.php');
require(PROJECT_DIR . '/system/icon.php');
require(PROJECT_DIR . '/system/helper/filter.php');
require(PROJECT_DIR . '/system/helper/valid.php');
require(PROJECT_DIR . '/system/helper/localization.php');
require(PROJECT_DIR . '/system/helper/format.php');
// Init libraries
$_twister = new Twister(

11
src/system/helper/localization.php → src/system/helper/format.php

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
<?php
class Localization {
class Format {
public static function plural(int $number, array $texts) {
@ -33,5 +33,10 @@ class Localization { @@ -33,5 +33,10 @@ class Localization {
return sprintf('%s %s ago', $r, self::plural($r, $v));
}
}
}
}
}
public static function post(string $text) {
return nl2br($text);
}
}
Loading…
Cancel
Save