public function addForm() { $themes = glob(DIR_THEME . '/*'); $themeNames = []; foreach ($themes as $theme) { $themeData = parse_json_file($theme . '/composer.json'); $theme = str_replace(DIR_THEME . '/', '', $theme); $themeNames[$theme] = $themeData['extra']['name']; } $data = []; $data['content'] = view('sites/form', ['title' => t('new_site'), 'name' => '', 'locales' => substr(app('request')->getPreferredLanguage(app('translator')->installedPackages), 0, 2), 'domains' => app('request')->server['HTTP_HOST'], 'use_alias_as_path' => 0, 'maintenance_mode' => 0, 'need_cache' => 0, 'template' => HTML::select('theme', '', $themeNames, 'class="form-control"'), 'site' => 'new', 'sites' => str_replace(DIR_SITE, '', glob(DIR_SITE . 's*'))]); $data['sidebar_right'] = HTML::saveButton() . HTML::mastercodeInput(); $data['sidebar_left'] = ''; $data['form_url'] = 'admin/sites/add'; $data['meta_title'] = t('site_creation'); $data['breadcrumbs'] = [['url' => '?route=config', 'title' => t('settings')], ['url' => '?route=config/sites', 'title' => t('site_list')], ['title' => t('site_creation')]]; $d = document($data); return $d; }
function process_request() { global $parsedown, $modules, $static_pages, $hidden_pages, $external_pages; // Set up Parsedown $parsedown = null; if (file_exists('lib/parsedown.php')) { include 'lib/parsedown.php'; $parsedown = Parsedown::instance(); } // Build the static page array if (file_exists('static/metadata.json')) { $site_metadata = parse_json_file('static/metadata.json'); $modules->run('site_metadata', $site_metadata); // Pack non-iterable site info into a series of constants foreach ($site_metadata['info'] as $k => $v) { if (!is_int($k)) { define('SITE_' . strtoupper($k), $v); } } // These are global array variables instead of lists of constants for two reasons // 1) $external_pages, by necessity, contains characters that cannot be used in a constant // 2) It greatly simplifies iterating them, which should be the focus as that is the most common use case. foreach ($site_metadata['pages']['internal'] as $page) { if (isset($page['hidden']) && $page['hidden'] == true) { $hidden_pages[$page['page']] = $page['title']; } else { $static_pages[$page['page']] = $page['title']; } } foreach ($site_metadata['pages']['external'] as $page) { $external_pages[$page['page']] = $page['title']; } $pages = array_merge($static_pages, $hidden_pages); $files = implode('|', array_keys($pages)); } // Run any daily tasks... run_tasks(); $pieces = array('story' => '(?P<story>[-a-z0-9_]+)', 'page' => '(?P<page>[-a-z0-9_]*)', 'static' => '(?P<file>(' . $files . '))'); $URI = $_SERVER['REQUEST_URI']; $result = array(); $debug = 'No Match'; $mode = 'comics'; $url_root = parse_url(SITE_LINK)['path']; switch ($URI) { case SITE_LINK: $mode = 'comics'; $debug = 'Landing/Splash Page'; break; case preg_match('#^' . $url_root . $pieces['static'] . '$#', $URI, $result) === 1 ? true : false: $mode = 'static'; $debug = 'Static Content'; break; case preg_match('#^' . $url_root . 'archive/' . $pieces['page'] . '$#', $URI, $result) === 1 ? true : false: $mode = 'comics'; $debug = 'Default Comic Archive'; break; case preg_match('#^' . $url_root . 'archive/' . $pieces['story'] . '/' . $pieces['page'] . '$#', $URI, $result) === 1 ? true : false: $mode = 'comics'; $debug = 'Specific Comic Archive'; break; default: $mode = 'error'; $debug = 'Default'; $result = array('err' => '404'); $param = array('mode' => &$mode, 'debug' => &$debug, 'URI' => &$URI, 'result' => &$result); $modules->run("mode_select", $param); break; } $values = array('mode' => &$mode, 'debug' => &$debug, 'result' => &$result); $modules->run('pre_process', $values); if (file_exists('lib/' . $mode . '.php')) { include 'lib/' . $mode . '.php'; if (function_exists('pre_process')) { $result = pre_process($result); } } $modules->run('process_request', $result); foreach ($result as $k => $v) { if (!is_int($k)) { define('COMIC_' . strtoupper($k), $v); } } if (!defined('COMIC_DEBUG')) { define('COMIC_DEBUG', $debug); } if (!defined('COMIC_MODE')) { define('COMIC_MODE', $mode); } }