private function themes() { if (isset($_GET['theme']) && Validate::slug($_GET['theme']) && file_exists(PATH . '/themes/' . $_GET['theme'] . '/theme.json')) { $opt = Options::where('name', 'theme')->findOne(); $opt->value = $_GET['theme']; $opt->save(); Base::redirect('/admin/themes'); } /** * Get themes */ $dir = PATH . '/themes/'; if ($dh = opendir($dir)) { $themes = array(); while (($theme = readdir($dh)) !== false) { $file = $dir . $theme . '/theme.json'; if (file_exists($file)) { $file = file_get_contents($file); $file = (array) json_decode($file); $file['theme'] = $theme; $themes[] = $file; } } closedir($dh); } View::set('themes', $themes); View::show('admin/themes'); }
function update_option($option, $value = '') { $options = Options::where('option_name', '=', $option); if (!$options->first()) { add_option($option, $value); } else { $options->update(['option_value' => $value]); } }