summaryrefslogtreecommitdiffstats
path: root/src/etc/inc/pfsense-utils.inc
diff options
context:
space:
mode:
authorChris Buechler <cmb@pfsense.org>2016-06-30 00:20:40 -0500
committerChris Buechler <cmb@pfsense.org>2016-06-30 00:20:40 -0500
commit50d369744e40acae883a91cb3d8bcd51b0b80c66 (patch)
tree9c2c342a366d93cab0c39034330fed9efdbee30f /src/etc/inc/pfsense-utils.inc
parent7685fd4eced7e122ee151eb281523594f0c1d7d1 (diff)
parent8bab524e06831489a882e7d65e9cbd52d39febbd (diff)
downloadpfsense-50d369744e40acae883a91cb3d8bcd51b0b80c66.zip
pfsense-50d369744e40acae883a91cb3d8bcd51b0b80c66.tar.gz
Merge pull request #3018 from phil-davis/usersettings
Diffstat (limited to 'src/etc/inc/pfsense-utils.inc')
-rw-r--r--src/etc/inc/pfsense-utils.inc236
1 files changed, 236 insertions, 0 deletions
diff --git a/src/etc/inc/pfsense-utils.inc b/src/etc/inc/pfsense-utils.inc
index cb64aca..66fde46 100644
--- a/src/etc/inc/pfsense-utils.inc
+++ b/src/etc/inc/pfsense-utils.inc
@@ -162,6 +162,242 @@ function get_dns_servers() {
return array_unique($dns_servers);
}
+/****f* pfsense-utils/get_css_files
+ * NAME
+ * get_css_files - get a list of the available CSS files (themes)
+ * INPUTS
+ * none
+ * RESULT
+ * $csslist - an array of the CSS files
+ ******/
+function get_css_files() {
+ $csslist = array();
+
+ // List pfSense files, then any BETA files followed by any user-contributed files
+ $cssfiles = glob("/usr/local/www/css/*.css");
+
+ if (is_array($cssfiles)) {
+ arsort($cssfiles);
+ $usrcss = $pfscss = $betacss = array();
+
+ foreach ($cssfiles as $css) {
+ if (strpos($css, "BETA") != 0) {
+ array_push($betacss, $css);
+ } else if (strpos($css, "pfSense") != 0) {
+ array_push($pfscss, $css);
+ } else {
+ array_push($usrcss, $css);
+ }
+ }
+
+ $css = array_merge($pfscss, $betacss, $usrcss);
+
+ foreach ($css as $file) {
+ $file = basename($file);
+ $csslist[$file] = pathinfo($file, PATHINFO_FILENAME);
+ }
+ }
+ return $csslist;
+}
+
+/****f* pfsense-utils/gen_webguicss_field
+ * NAME
+ * gen_webguicss_field
+ * INPUTS
+ * Pointer to section object
+ * Initial value for the field
+ * RESULT
+ * no return value, section object is updated
+ ******/
+function gen_webguicss_field(&$section, $value) {
+
+ $csslist = get_css_files();
+
+ if (!isset($csslist[$value])) {
+ $value = "pfSense.css";
+ }
+
+ $section->addInput(new Form_Select(
+ 'webguicss',
+ 'Theme',
+ $value,
+ $csslist
+ ))->setHelp(sprintf(gettext('Choose an alternative css file (if installed) to change the appearance of the webConfigurator. css files are located in /usr/local/www/css/%s'), '<span id="csstxt"></span>'));
+}
+
+/****f* pfsense-utils/gen_webguifixedmenu_field
+ * NAME
+ * gen_webguifixedmenu_field
+ * INPUTS
+ * Pointer to section object
+ * Initial value for the field
+ * RESULT
+ * no return value, section object is updated
+ ******/
+function gen_webguifixedmenu_field(&$section, $value) {
+
+ $section->addInput(new Form_Select(
+ 'webguifixedmenu',
+ 'Top Navigation',
+ $value,
+ ["" => gettext("Scrolls with page"), "fixed" => gettext("Fixed (Remains visible at top of page)")]
+ ))->setHelp("The fixed option is intended for large screens only.");
+}
+
+/****f* pfsense-utils/gen_webguihostnamemenu_field
+ * NAME
+ * gen_webguihostnamemenu_field
+ * INPUTS
+ * Pointer to section object
+ * Initial value for the field
+ * RESULT
+ * no return value, section object is updated
+ ******/
+function gen_webguihostnamemenu_field(&$section, $value) {
+
+ $section->addInput(new Form_Select(
+ 'webguihostnamemenu',
+ 'Hostname in Menu',
+ $value,
+ ["" => gettext("Default (No hostname)"), "hostonly" => gettext("Hostname only"), "fqdn" => gettext("Fully Qualified Domain Name")]
+ ))->setHelp("Replaces the Help menu title in the Navbar with the system hostname or FQDN.");
+}
+
+/****f* pfsense-utils/gen_dashboardcolumns_field
+ * NAME
+ * gen_dashboardcolumns_field
+ * INPUTS
+ * Pointer to section object
+ * Initial value for the field
+ * RESULT
+ * no return value, section object is updated
+ ******/
+function gen_dashboardcolumns_field(&$section, $value) {
+
+ if (($value < 1) || ($value > 4)) {
+ $value = 2;
+ }
+
+ $section->addInput(new Form_Input(
+ 'dashboardcolumns',
+ 'Dashboard Columns',
+ 'number',
+ $value,
+ [min => 1, max => 4]
+ ));
+}
+
+/****f* pfsense-utils/gen_associatedpanels_fields
+ * NAME
+ * gen_associatedpanels_fields
+ * INPUTS
+ * Pointer to section object
+ * Initial value for each of the fields
+ * RESULT
+ * no return value, section object is updated
+ ******/
+function gen_associatedpanels_fields(&$section, $value1, $value2, $value3, $value4) {
+
+ $group = new Form_Group('Associated Panels Show/Hide');
+
+ $group->add(new Form_Checkbox(
+ 'dashboardavailablewidgetspanel',
+ null,
+ 'Available Widgets',
+ $value1
+ ))->setHelp('Show the Available Widgets panel on the Dashboard.');
+
+ $group->add(new Form_Checkbox(
+ 'systemlogsfilterpanel',
+ null,
+ 'Log Filter',
+ $value2
+ ))->setHelp('Show the Log Filter panel in System Logs.');
+
+ $group->add(new Form_Checkbox(
+ 'systemlogsmanagelogpanel',
+ null,
+ 'Manage Log',
+ $value3
+ ))->setHelp('Show the Manage Log panel in System Logs.');
+
+ $group->add(new Form_Checkbox(
+ 'statusmonitoringsettingspanel',
+ null,
+ 'Monitoring Settings',
+ $value4
+ ))->setHelp('Show the Settings panel in Status Monitoring.');
+
+ $group->setHelp('These options allow certain panels to be automatically hidden on page load. A control is provided in the title bar to un-hide the panel.');
+
+ $section->add($group);
+}
+
+/****f* pfsense-utils/gen_webguileftcolumnhyper_field
+ * NAME
+ * gen_webguileftcolumnhyper_field
+ * INPUTS
+ * Pointer to section object
+ * Initial value for the field
+ * RESULT
+ * no return value, section object is updated
+ ******/
+function gen_webguileftcolumnhyper_field(&$section, $value) {
+
+ $section->addInput(new Form_Checkbox(
+ 'webguileftcolumnhyper',
+ 'Left Column Labels',
+ 'Active',
+ $value
+ ))->setHelp('If selected, clicking a label in the left column will select/toggle the first item of the group.');
+}
+
+/****f* pfsense-utils/gen_pagenamefirst_field
+ * NAME
+ * gen_pagenamefirst_field
+ * INPUTS
+ * Pointer to section object
+ * Initial value for the field
+ * RESULT
+ * no return value, section object is updated
+ ******/
+function gen_pagenamefirst_field(&$section, $value) {
+
+ $section->addInput(new Form_Checkbox(
+ 'pagenamefirst',
+ 'Browser tab text',
+ 'Display page name first in browser tab',
+ $value
+ ))->setHelp('When this is unchecked, the browser tab shows the host name followed '.
+ 'by the current page. Check this box to display the current page followed by the '.
+ 'host name.');
+}
+
+/****f* pfsense-utils/gen_user_settings_fields
+ * NAME
+ * gen_user_settings_fields
+ * INPUTS
+ * Pointer to section object
+ * Array of initial values for the fields
+ * RESULT
+ * no return value, section object is updated
+ ******/
+function gen_user_settings_fields(&$section, $pconfig) {
+
+ gen_webguicss_field($section, $pconfig['webguicss']);
+ gen_webguifixedmenu_field($section, $pconfig['webguifixedmenu']);
+ gen_webguihostnamemenu_field($section, $pconfig['webguihostnamemenu']);
+ gen_dashboardcolumns_field($section, $pconfig['dashboardcolumns']);
+ gen_associatedpanels_fields(
+ $section,
+ $pconfig['dashboardavailablewidgetspanel'],
+ $pconfig['systemlogsfilterpanel'],
+ $pconfig['systemlogsmanagelogpanel'],
+ $pconfig['statusmonitoringsettingspanel']);
+ gen_webguileftcolumnhyper_field($section, $pconfig['webguileftcolumnhyper']);
+ gen_pagenamefirst_field($section, $pconfig['pagenamefirst']);
+}
+
function hardware_offloading_applyflags($iface) {
global $config;
OpenPOWER on IntegriCloud