user->pass('administrator'); if (!self::isExists()) { throw new Exception(_t('外观配置功能不存在'), 404); } } /** * 配置功能是否存在 * * @param string|null $theme * @return boolean */ public static function isExists(?string $theme = null): bool { $options = Options::alloc(); $theme = $theme ?? $options->theme; $configFile = $options->themeFile($theme, 'functions.php'); if (!$options->missingTheme && file_exists($configFile)) { require_once $configFile; if (function_exists('themeConfig')) { return true; } } return false; } /** * 配置外观 * * @return Form */ public function config(): Form { $form = new Form( $this->security->getIndex('/action/themes-edit?config=' . Options::alloc()->theme), Form::POST_METHOD ); themeConfig($form); $inputs = $form->getInputs(); if (!empty($inputs)) { foreach ($inputs as $key => $val) { if (isset($this->options->{$key})) { $form->getInput($key)->value($this->options->{$key}); } } } $submit = new Submit(null, null, _t('保存设置')); $submit->input->setAttribute('class', 'btn primary'); $form->addItem($submit); return $form; } }