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. 9
      src/system/helper/format.php

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

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

2
src/bootstrap.php

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

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

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