|
59 | 59 | }
|
60 | 60 | }
|
61 | 61 |
|
62 |
| - $cache = Cache::getInstance(); |
63 |
| - if ($cache->enabled()) { |
64 |
| - $cache->delete('template_menus'); |
65 |
| - } |
66 |
| - |
| 62 | + onTemplateMenusChange(); |
67 | 63 | success('Saved at ' . date('H:i'));
|
68 | 64 | }
|
69 | 65 |
|
|
93 | 89 | Menu::where('template', $template)->where('category', $id)->update(['color' => str_replace('#', '', $color)]);
|
94 | 90 | }
|
95 | 91 |
|
96 |
| - $cache = Cache::getInstance(); |
97 |
| - if ($cache->enabled()) { |
98 |
| - $cache->delete('template_menus'); |
99 |
| - } |
| 92 | + onTemplateMenusChange(); |
| 93 | + success('Colors has been reset at ' . date('H:i')); |
| 94 | + } |
100 | 95 |
|
101 |
| - success('Colors has been reset.'); |
| 96 | + if (isset($_GET['reset_menus'])) { |
| 97 | + $configMenus = config('menus'); |
| 98 | + if (isset($configMenus)) { |
| 99 | + Plugins::installMenus($template, config('menus'), true); |
| 100 | + |
| 101 | + onTemplateMenusChange(); |
| 102 | + success('Menus has been reset at ' . date('H:i')); |
| 103 | + } |
| 104 | + else { |
| 105 | + error("This template don't support reinstalling menus."); |
| 106 | + } |
102 | 107 | }
|
103 | 108 |
|
104 | 109 | $title = 'Menus - ' . $template;
|
| 110 | + |
| 111 | + $canChangeColor = isset($config['menu_default_color']); |
| 112 | + foreach ($config['menu_categories'] as $id => $options) { |
| 113 | + if (isset($options['default_links_color'])) { |
| 114 | + $canChangeColor = true; |
| 115 | + } |
| 116 | + } |
105 | 117 | ?>
|
106 | 118 | <div align="center" class="text-center">
|
107 | 119 | <p class="note">You are editing: <?= $template ?><br/><br/>
|
108 | 120 | Hint: You can drag menu items.<br/>
|
109 | 121 | Hint: Add links to external sites using: <b>http://</b> or <b>https://</b> prefix.<br/>
|
110 | 122 | Not all templates support blank and colorful links.
|
111 | 123 | </p>
|
112 |
| - <?php if (isset($config['menu_default_color'])) {?> |
113 |
| - <form method="post" action="?p=menus&reset_colors" onsubmit="return confirm('Do you really want to reset colors?');"> |
114 |
| - <?php csrf(); ?> |
115 |
| - <input type="hidden" name="template" value="<?php echo $template ?>"/> |
116 |
| - <button type="submit" class="btn btn-danger">Reset Colors to default</button> |
117 |
| - </form> |
118 |
| - <br/> |
119 |
| - <?php } ?> |
| 124 | + <div class="row text-center"> |
| 125 | + <div class="col-md-2 col-sm-1"></div> |
| 126 | + <div class="col-md-8 col-sm-10"> |
| 127 | + <div class="row justify-content-center"> |
| 128 | + <?php if (isset($config['menus'])) {?> |
| 129 | + <form method="post" action="?p=menus&reset_menus" onsubmit="return confirm('Do you really want to reset menus?');"> |
| 130 | + <?php csrf(); ?> |
| 131 | + <input type="hidden" name="template" value="<?php echo $template ?>"/> |
| 132 | + <button type="submit" class="btn btn-danger">Reset Menus to default</button> |
| 133 | + </form> |
| 134 | + <br/> |
| 135 | + <?php } ?> |
| 136 | + <?php if ($canChangeColor) {?> |
| 137 | + <form method="post" action="?p=menus&reset_colors" onsubmit="return confirm('Do you really want to reset colors?');"> |
| 138 | + <?php csrf(); ?> |
| 139 | + <input type="hidden" name="template" value="<?php echo $template ?>"/> |
| 140 | + <button type="submit" class="btn btn-warning" style="margin-left: 20px">Reset Colors to default</button> |
| 141 | + </form> |
| 142 | + <br/> |
| 143 | + <?php } ?> |
| 144 | + </div> |
| 145 | + </div> |
| 146 | + <div class="col-md-2 col-sm-1"></div> |
| 147 | + </div> |
120 | 148 | </div>
|
121 | 149 | <?php
|
122 | 150 | $menus = Menu::query()
|
|
198 | 226 | 'templates' => $templates
|
199 | 227 | ));
|
200 | 228 | }
|
| 229 | + |
| 230 | +function onTemplateMenusChange(): void |
| 231 | +{ |
| 232 | + $cache = Cache::getInstance(); |
| 233 | + if ($cache->enabled()) { |
| 234 | + $cache->delete('template_menus'); |
| 235 | + } |
| 236 | +} |
0 commit comments