|
|
|
@ -13,7 +13,6 @@ class Sorting
|
|
|
|
|
public static function tags()
|
|
|
|
|
{
|
|
|
|
|
$pages = (new Book("../content/pages"))->getContents();
|
|
|
|
|
|
|
|
|
|
foreach ($pages as $page) {
|
|
|
|
|
$temp = [];
|
|
|
|
|
$temp = explode(",", $page["tags"]);
|
|
|
|
@ -23,13 +22,8 @@ class Sorting
|
|
|
|
|
array_push(self::$_tags, [
|
|
|
|
|
"tag_name" => $label,
|
|
|
|
|
"slug" => StringTools::safeString($label),
|
|
|
|
|
"count" => 1,
|
|
|
|
|
"pages" => self::tagPages($label, $pages),
|
|
|
|
|
]);
|
|
|
|
|
} else {
|
|
|
|
|
$item = find(self::$_tags, ["tag_name" => $label]);
|
|
|
|
|
//echo "TAG: " . $item["tag_name"] . "\n";
|
|
|
|
|
$count = $item["count"];
|
|
|
|
|
self::$_tags[$label]["count"] = $count + 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -37,18 +31,38 @@ class Sorting
|
|
|
|
|
return self::$_tags;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static function tagPages($tag, $pages)
|
|
|
|
|
{
|
|
|
|
|
$tagged = [];
|
|
|
|
|
foreach ($pages as $page) {
|
|
|
|
|
if (strpos($page["tags"], $tag) !== false) {
|
|
|
|
|
array_push($tagged, [
|
|
|
|
|
"title" => $page["title"],
|
|
|
|
|
"slug" => $page["slug"],
|
|
|
|
|
"path" => $page["path"],
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $tagged;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static function archive()
|
|
|
|
|
{
|
|
|
|
|
$pages = (new Book("../content/pages"))->getContents();
|
|
|
|
|
$years = [];
|
|
|
|
|
$archive = [];
|
|
|
|
|
foreach ($pages as $page) {
|
|
|
|
|
$year = date("Y", date($page["rawCreated"]));
|
|
|
|
|
//$year = date("Y", date($page["rawCreated"]));
|
|
|
|
|
$date = explode("/", $page["path"]);
|
|
|
|
|
//echo $page["title"] . " : " . $year . "\n";
|
|
|
|
|
if (!find($years, ["year" => $year])) {
|
|
|
|
|
$findPages = filter($pages, ["createdYear" => $year]);
|
|
|
|
|
if (!find($years, ["year" => trim($date[0])])) {
|
|
|
|
|
$findPages = filter($pages, ["createdYear" => trim($date[0])]);
|
|
|
|
|
//var_dump($findPages);
|
|
|
|
|
array_push($years, ["year" => $year, "count" => count($findPages)]);
|
|
|
|
|
array_push($years, [
|
|
|
|
|
"year" => trim($date[0]),
|
|
|
|
|
"count" => count($findPages),
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
foreach ($years as $year) {
|
|
|
|
@ -59,8 +73,7 @@ class Sorting
|
|
|
|
|
$month = date("m", date($obj["rawCreated"]));
|
|
|
|
|
if (!find($sorted, ["month" => $month])) {
|
|
|
|
|
$perMonth = filter($pages, [
|
|
|
|
|
"createdYear" => $year["year"],
|
|
|
|
|
"createdMonth" => $month,
|
|
|
|
|
"path" => $year["year"] . "/" . $month,
|
|
|
|
|
"deleted" => false,
|
|
|
|
|
"published" => true,
|
|
|
|
|
"layout" => "page",
|
|
|
|
|