| 1: | <?php |
| 2: | |
| 3: | |
| 4: | |
| 5: | |
| 6: | |
| 7: | |
| 8: | |
| 9: | |
| 10: | if (!defined('DEBUG_MODE')) { |
| 11: | die(); |
| 12: | } |
| 13: | |
| 14: | |
| 15: | |
| 16: | |
| 17: | |
| 18: | |
| 19: | class Hm_Handler_load_theme extends Hm_Handler_Module |
| 20: | { |
| 21: | public function process() |
| 22: | { |
| 23: | $theme = $this->user_config->get('theme_setting', DEFAULT_THEME); |
| 24: | $themes = custom_themes($this->config, hm_themes()); |
| 25: | if ($theme == 'hn') { |
| 26: | $this->user_config->set('list_style', 'news_style'); |
| 27: | } |
| 28: | $this->out('themes', $themes); |
| 29: | $this->out('theme', $theme); |
| 30: | } |
| 31: | } |
| 32: | |
| 33: | |
| 34: | |
| 35: | |
| 36: | |
| 37: | class Hm_Handler_process_theme_setting extends Hm_Handler_Module |
| 38: | { |
| 39: | public function process() |
| 40: | { |
| 41: | list($success, $form) = $this->process_form(array('save_settings', 'theme_setting')); |
| 42: | $new_settings = $this->get('new_user_settings', array()); |
| 43: | $settings = $this->get('user_settings', array()); |
| 44: | |
| 45: | if ($success) { |
| 46: | $new_settings['theme_setting'] = $form['theme_setting']; |
| 47: | } else { |
| 48: | $settings['theme'] = $this->user_config->get('theme_setting', DEFAULT_THEME); |
| 49: | } |
| 50: | $this->out('new_user_settings', $new_settings, false); |
| 51: | $this->out('user_settings', $settings, false); |
| 52: | } |
| 53: | } |
| 54: | |
| 55: | |
| 56: | |
| 57: | |
| 58: | |
| 59: | class Hm_Output_theme_css extends Hm_Output_Module |
| 60: | { |
| 61: | |
| 62: | |
| 63: | |
| 64: | protected function output() |
| 65: | { |
| 66: | if ($this->get('theme') && in_array($this->get('theme'), array_keys($this->get('themes', array())), true)) { |
| 67: | $theme_name = $this->html_safe($this->get('theme')); |
| 68: | return '<link href="' . ASSETS_THEMES_ROOT . 'modules/themes/assets/' . $theme_name . '/css/' . $theme_name . '.css?v=' . CACHE_ID . '" media="all" rel="stylesheet" type="text/css" />'; |
| 69: | } |
| 70: | } |
| 71: | } |
| 72: | |
| 73: | |
| 74: | |
| 75: | |
| 76: | |
| 77: | class Hm_Output_theme_setting extends Hm_Output_Module |
| 78: | { |
| 79: | |
| 80: | |
| 81: | |
| 82: | protected function output() |
| 83: | { |
| 84: | |
| 85: | $current = $this->get('theme', DEFAULT_THEME); |
| 86: | $res = '<tr class="general_setting"><td><label for="theme_setting">' . |
| 87: | $this->trans('Theme') . '</label></td>' . |
| 88: | '<td><select class="form-select form-select-sm" id="theme_setting" name="theme_setting" data-default-value="'.DEFAULT_THEME.'">'; |
| 89: | $reset = ''; |
| 90: | foreach ($this->get('themes', array()) as $name => $label) { |
| 91: | $res .= '<option '; |
| 92: | if ($name == $current) { |
| 93: | $res .= 'selected="selected" '; |
| 94: | if ($name != 'default') { |
| 95: | $reset = '<span class="tooltip_restore" restore_aria_label="Restore default value"><i class="bi bi-arrow-counterclockwise refresh_list reset_default_value_select"></i></span>'; |
| 96: | } |
| 97: | } |
| 98: | $res .= 'value="' . $this->html_safe($name) . '">' . $this->trans($label) . '</option>'; |
| 99: | } |
| 100: | $res .= '</select>' . $reset; |
| 101: | return $res; |
| 102: | } |
| 103: | } |
| 104: | |
| 105: | |
| 106: | |
| 107: | |
| 108: | if (!hm_exists('icon_color')) { |
| 109: | function icon_color($theme) |
| 110: | { |
| 111: | } |
| 112: | } |
| 113: | |
| 114: | |
| 115: | |
| 116: | |
| 117: | |
| 118: | if (!hm_exists('hm_themes')) { |
| 119: | function hm_themes() |
| 120: | { |
| 121: | return array( |
| 122: | 'default' => 'White Bread (Default)', |
| 123: | 'cosmo' => 'Cosmo', |
| 124: | 'cerulean' => 'Cerulean', |
| 125: | 'cyborg' => 'Cyborg', |
| 126: | 'darkly' => 'Darkly', |
| 127: | 'flatly' => 'Flatly', |
| 128: | 'journal' => 'Journal', |
| 129: | 'litera' => 'Litera', |
| 130: | 'lumen' => 'Lumen', |
| 131: | 'lux' => 'Lux', |
| 132: | 'materia' => 'Materia', |
| 133: | 'minty' => 'Minty', |
| 134: | 'morph' => 'Morph', |
| 135: | 'pulse' => 'Pulse', |
| 136: | 'quartz' => 'Quartz', |
| 137: | 'sandstone' => 'Sandstone', |
| 138: | 'simplex' => 'Simplex', |
| 139: | 'sketchy' => 'Sketchy', |
| 140: | 'slate' => 'Slate', |
| 141: | 'solar' => 'Solar', |
| 142: | 'spacelab' => 'Spacelab', |
| 143: | 'superhero' => 'Superhero', |
| 144: | 'united' => 'United', |
| 145: | 'vapor' => 'Vapor', |
| 146: | 'yeti' => 'Yeti', |
| 147: | 'zephyr' => 'Zephyr' |
| 148: | ); |
| 149: | } |
| 150: | } |
| 151: | |
| 152: | |
| 153: | |
| 154: | |
| 155: | if (!hm_exists('custom_themes')) { |
| 156: | function custom_themes($config, $themes) |
| 157: | { |
| 158: | $custom = $config->get('theme', []); |
| 159: | if (!is_array($custom)) { |
| 160: | return $themes; |
| 161: | } |
| 162: | if (!array_key_exists('theme', $custom)) { |
| 163: | return $themes; |
| 164: | } |
| 165: | if (!is_array($custom['theme'])) { |
| 166: | return $themes; |
| 167: | } |
| 168: | foreach ($custom['theme'] as $val) { |
| 169: | if (mb_strpos($val, '|') === false) { |
| 170: | continue; |
| 171: | } |
| 172: | $parts = explode('|', $val, 2); |
| 173: | $themes[$parts[0]] = $parts[1]; |
| 174: | } |
| 175: | return $themes; |
| 176: | } |
| 177: | } |
| 178: | |