Changeset View
Changeset View
Standalone View
Standalone View
src/app/Http/Controllers/ContentController.php
Show All 21 Lines | public function pageContent(string $page) | ||||
$file = "themes/{$theme}/pages/{$page}.blade.php"; | $file = "themes/{$theme}/pages/{$page}.blade.php"; | ||||
$view = "{$theme}.pages.{$page}"; | $view = "{$theme}.pages.{$page}"; | ||||
if (!file_exists(resource_path($file))) { | if (!file_exists(resource_path($file))) { | ||||
abort(404); | abort(404); | ||||
} | } | ||||
self::loadLocale($theme); | |||||
return view($view)->with('env', \App\Utils::uiEnv()); | return view($view)->with('env', \App\Utils::uiEnv()); | ||||
} | } | ||||
/** | /** | ||||
* Get the list of FAQ entries for the specified page | * Get the list of FAQ entries for the specified page | ||||
* | * | ||||
* @param string $page Page path | * @param string $page Page path | ||||
* | * | ||||
Show All 18 Lines | public function faqContent(string $page) | ||||
$faq = $theme['faq'][$page]; | $faq = $theme['faq'][$page]; | ||||
} | } | ||||
// TODO: Support pages with variables, e.g. users/<user-id> | // TODO: Support pages with variables, e.g. users/<user-id> | ||||
} | } | ||||
// Localization | // Localization | ||||
if (!empty($faq)) { | if (!empty($faq)) { | ||||
self::loadLocale($theme_name); | |||||
foreach ($faq as $idx => $item) { | foreach ($faq as $idx => $item) { | ||||
if (!empty($item['label'])) { | if (!empty($item['label'])) { | ||||
$faq[$idx]['title'] = \trans('theme::faq.' . $item['label']); | $faq[$idx]['title'] = \trans('theme::faq.' . $item['label']); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
return response()->json(['status' => 'success', 'faq' => $faq]); | return response()->json(['status' => 'success', 'faq' => $faq]); | ||||
▲ Show 20 Lines • Show All 77 Lines • ▼ Show 20 Lines | public static function menu(): array | ||||
// Unset properties that we don't need on the client side | // Unset properties that we don't need on the client side | ||||
unset($item['admin'], $item['label']); | unset($item['admin'], $item['label']); | ||||
$menu[$idx] = $item; | $menu[$idx] = $item; | ||||
} | } | ||||
return $menu; | return $menu; | ||||
} | } | ||||
/** | |||||
* Register localization files from the theme. | |||||
* | |||||
* @param string $theme Theme name | |||||
*/ | |||||
protected static function loadLocale(string $theme): void | |||||
{ | |||||
$path = resource_path(sprintf('themes/%s/lang', $theme)); | |||||
\app('translator')->addNamespace('theme', $path); | |||||
} | |||||
} | } |