sitemap을 위하여 메뉴를 php에서 직접 출력하도록 변경

This commit is contained in:
2018-09-12 00:12:32 +09:00
parent 09f399db9a
commit effced24d1
8 changed files with 36 additions and 31 deletions
+22
View File
@@ -135,4 +135,26 @@ class WebUtil
$purifier = new \HTMLPurifier($config);
return $purifier->purify($text);
}
public static function drawMenu(string $path): string{
$json = Json::decode(file_get_contents($path));
$result = [];
foreach($json as $menuItem){
if (count($path) == 2) {
[$url, $title] = $menuItem;
$targetAttr = '';
}
else{
[$url, $title, $target] = $menuItem;
$target = htmlspecialchars($target);
$targetAttr = "target='$target' ";
}
$title = htmlspecialchars($title);
$url = htmlspecialchars($url);
$result[] = "<a class='nav-link' href='$url' $targetAttr>$title</a>";
}
return join("\n", $result);
}
}