public function editPHP(Request $request) { $file_locale = $request->input('file_locale', 'en'); $file_name = $request->input('file_name', 'validation'); $storage = Storage::disk('lang'); $file_path = str_replace(['../', '..'], '', $file_locale . '/' . $file_name . '.php'); if (!$storage->exists($file_path)) { abort(404); } $file_content = $storage->get($file_path); $php_files = []; foreach (allSupportedLocales() as $localeCode => $properties) { if (!$storage->exists($localeCode)) { continue; } $locale = $localeCode . ' (' . $properties['native'] . ')'; $php_files[$locale] = []; $files = $storage->files($localeCode); foreach ($files as $file) { $php_files[$locale][] = ['locale' => $localeCode, 'file' => preg_replace('/(^' . $localeCode . '\\/|\\.php$)/', '', $file)]; } } $this->theme->title(trans('pages.admin_ui_lang_php_title')); $this->theme->description(trans('pages.admin_ui_lang_php_desc')); return $this->_any('php', ['file_locale' => $file_locale, 'file_name' => $file_name, 'file_content' => $file_content, 'files' => $php_files]); }
function supportedLocalesAsOptions() { $selected_locale = currentLocaleCode(); $options = ''; foreach (allSupportedLocales() as $localeCode => $properties) { $options .= '<option value="' . $localeCode . '"' . ($localeCode == $selected_locale ? ' selected' : '') . '>' . $properties['native'] . '</option>'; } return $options; }