@ -2,12 +2,13 @@
namespace brain\utility;
namespace brain\utility;
use function _\filter;
use function _\find;
use brain\data\Book;
use brain\data\Book;
use brain\data\Settings;
use brain\data\Settings;
use Mni\FrontYAML\Parser;
use Mni\FrontYAML\Parser;
use function _\filter;
use function _\find;
class Sorting
class Sorting
{
{
private static $p_tags = [];
private static $p_tags = [];
@ -16,6 +17,7 @@ class Sorting
public function __construct()
public function __construct()
{
{
}
}
public static function tags()
public static function tags()
{
{
$pages = (new Book('../content/pages'))->getContents();
$pages = (new Book('../content/pages'))->getContents();
@ -36,6 +38,7 @@ class Sorting
return self::$p_tags;
return self::$p_tags;
}
}
private static function tagPages($tag, $pages)
private static function tagPages($tag, $pages)
{
{
$tagged = [];
$tagged = [];
@ -52,6 +55,7 @@ class Sorting
return $tagged;
return $tagged;
}
}
public static function archive()
public static function archive()
{
{
$pages = (new Book('../content/pages'))->getContents();
$pages = (new Book('../content/pages'))->getContents();
@ -64,10 +68,13 @@ class Sorting
if (!find($years, ['year' => trim($date[0])])) {
if (!find($years, ['year' => trim($date[0])])) {
$findPages = filter($pages, ['createdYear' => trim($date[0])]);
$findPages = filter($pages, ['createdYear' => trim($date[0])]);
// var_dump($findPages);
// var_dump($findPages);
array_push($years, [
array_push(
'year' => trim($date[0]),
$years,
'count' => count($findPages),
[
]);
'year' => trim($date[0]),
'count' => count($findPages),
]
);
}
}
}
}
foreach ($years as $year) {
foreach ($years as $year) {
@ -77,12 +84,15 @@ class Sorting
foreach ($filtered as $obj) {
foreach ($filtered as $obj) {
$month = date('m', date($obj['rawCreated']));
$month = date('m', date($obj['rawCreated']));
if (!find($sorted, ['month' => $month])) {
if (!find($sorted, ['month' => $month])) {
$perMonth = filter($pages, [
$perMonth = filter(
'path' => $year['year'] . '/' . $month,
$pages,
'deleted' => false,
[
'published' => true,
'path' => $year['year'] . '/' . $month,
'layout' => 'page',
'deleted' => false,
]);
'published' => true,
'layout' => 'page',
]
);
array_push($sorted, [
array_push($sorted, [
'month' => $month,
'month' => $month,
'full_month' => date('F', date($obj['rawCreated'])),
'full_month' => date('F', date($obj['rawCreated'])),
@ -99,6 +109,7 @@ class Sorting
return self::$p_archive;
return self::$p_archive;
}
}
public static function page($page)
public static function page($page)
{
{
$config = new Settings();
$config = new Settings();