the browser-facing portion of osu!
at master 1.5 kB view raw
1<?php 2 3// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the GNU Affero General Public License v3.0. 4// See the LICENCE file in the repository root for full licence text. 5 6namespace App\Http\Controllers; 7 8use App\Libraries\LocaleMeta; 9use App\Models\Wiki; 10 11class LegalController extends Controller 12{ 13 public function show($locale = null, $path = null) 14 { 15 if (!LocaleMeta::isValid($locale)) { 16 $redirect = concat_path(['Legal', $locale, $path]); 17 18 return ujs_redirect(wiki_url($redirect)); 19 } 20 21 if (substr(request()->getPathInfo(), -1) === '/') { 22 return ujs_redirect(route('legal', ['path' => rtrim($path, '/'), 'locale' => $locale])); 23 } 24 25 switch ($path) { 26 case 'copyright': 27 $redirect = 'Copyright'; 28 break; 29 case 'privacy': 30 $redirect = 'Privacy'; 31 break; 32 case 'terms': 33 $redirect = 'Terms'; 34 break; 35 } 36 37 if (isset($redirect)) { 38 return ujs_redirect(wiki_url("Legal/{$redirect}")); 39 } 40 41 $page = Wiki\Page::lookupForController("Legal/{$path}", $locale); 42 $legal = true; 43 44 return ext_view('wiki.show', compact('legal', 'locale', 'page')); 45 } 46 47 public function update($locale, $path) 48 { 49 priv_check('WikiPageRefresh')->ensureCan(); 50 51 (new Wiki\Page("Legal/{$path}", $locale))->sync(true); 52 53 return ext_view('layout.ujs-reload', [], 'js'); 54 } 55}