made a widget to change the web configurator theme
-
It looks a little clunky, but doesn't throw any errors and works as expected. Would someone that understands the code better than me mind helping me clean it up, and let me know if they see any problems?
change_theme.widget.php
<?php require_once("guiconfig.inc"); $pconfig['webguicss'] = $config['system']['webgui']['webguicss']; $changedesc = gettext("System") . ": "; $changecount = 0; if ($_POST) { $changecount++; unset($input_errors); $pconfig = $_POST; validate_webguicss_field($input_errors, $_POST['webguicss']); if ($_POST['webguicss']) { $config['system']['webgui']['webguicss'] = $_POST['webguicss']; } else { unset($config['system']['webgui']['webguicss']); } if ($changecount > 0) { write_config($changedesc); } $changes_applied = true; // Reload the filter - plugins might need to be run. $retval |= filter_configure(); } if ($input_errors) { print_input_errors($input_errors); } if ($changes_applied) { print_apply_result_box($retval); } ?> <div id="container"> <?php $form = new Form; $section = new Form_Section(' '); gen_webguicss_field($section, $pconfig['webguicss']); $form->add($section); print $form; $csswarning = sprintf(gettext("%sUser-created themes are unsupported, use at your own risk."), "<br />"); ?> </div> <script type="text/javascript"> //<![CDATA[ events.push(function() { function setThemeWarning() { if ($('#webguicss').val().startsWith("pfSense")) { $('#csstxt').html("").addClass("text-default"); } else { $('#csstxt').html("<?=$csswarning?>").addClass("text-danger"); } } $('#webguicss').change(function() { setThemeWarning(); }); setThemeWarning(); // Suppress "Delete row" button if there are fewer than two rows checkLastRow(); }); //]]> </script>