From 39e5f2647ef505ee0a10423e634c6cd657dbd2fd Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Fri, 9 Jan 2009 23:00:07 -0800 Subject: [PATCH] Templatize admin/settings.php * admin/global.php: Include DecoratorHelpers.php * admin/settings.php: Complete rewrite with templates * admin/templates/nav.html: Add id's to nav elements * admin/templates/settings.html: New file * includes/functions.php: (construct_option_select): Add an id attribute --- admin/global.php | 2 + admin/settings.php | 177 ++--------------- admin/templates/nav.html | 4 +- admin/templates/settings.html | 351 ++++++++++++++++++++++++++++++++++ includes/functions.php | 2 +- 5 files changed, 368 insertions(+), 168 deletions(-) create mode 100644 admin/templates/settings.html diff --git a/admin/global.php b/admin/global.php index 39391a5..2f8a485 100755 --- a/admin/global.php +++ b/admin/global.php @@ -27,6 +27,8 @@ require_once('./includes/functions.php'); // ################################################################### // setup admin templates +require_once ISSO . '/DecoratorHelpers.php'; + require_once ISSO . '/Template.php'; BSTemplate::$dbCacheTable = TABLE_PREFIX . 'template'; BSTemplate::$templatePath = 'admin/templates/%s.html'; diff --git a/admin/settings.php b/admin/settings.php index 43a01a1..2421406 100755 --- a/admin/settings.php +++ b/admin/settings.php @@ -19,14 +19,14 @@ || ################################################################### \*=====================================================================*/ +$fetchtemplates = array( + 'settings' +); + require_once('./global.php'); require_once('./includes/class_sort.php'); require_once('./includes/functions_datastore.php'); -NavLinks::optionsPages(); -$navigator->set_focus('tab', 'options', null); -$navigator->set_focus('link', 'options-pages-settings', 'options-pages'); - if (!can_perform('canadmintools')) { admin_login(); @@ -44,7 +44,7 @@ if (empty($_REQUEST['do'])) if ($_POST['do'] == 'update') { $updates = array(); - foreach ($input->in['setting'] AS $varname => $value) + foreach ($input->in['settings'] as $varname => $value) { if (is_array($value)) { @@ -58,187 +58,34 @@ if ($_POST['do'] == 'update') } } - $updates[] = "('" . $bugsys->escape($varname) . "', '" . $bugsys->escape($value) . "')"; + $updates[] = "('" . $input->escape($varname) . "', '" . $input->escape($value) . "')"; } $db->query("REPLACE INTO " . TABLE_PREFIX . "setting (varname, value) VALUES " . implode(',', $updates)); build_settings(); - $admin->redirect('setting.php'); + $admin->redirect('settings.php'); } // ################################################################### if ($_REQUEST['do'] == 'modify') { - $admin->page_start(T('Settings')); - - $admin->form_start('setting.php', 'update'); - - $IS_SETTINGS = true; - - // ################################################################### - $admin->table_start(); - $admin->table_head(T('General Options')); + $admin = new BSTemplate('settings'); // authmethod - $admin->row_span(T('Authentication Method'), 'thead'); $methods = BSFunctions::scan_directory('./includes/auth/'); - foreach ($methods[''] AS $path) + $admin->vars['authmethods'] = ''; + foreach ($methods AS $path) { if (preg_match('#auth_(.*)\.php#', $path, $matches)) { - $admin->list_item(ucwords(str_replace('_', ' ', $matches[1])), $matches[1], ($matches[1] == bugdar::$options['authmethod'])); + $admin->vars['authmethods'] .= ''; } } - $admin->row_list(T('The authentication class to use to validate cookie data and longins. You may need to edit the actual file for certain authentication systems.'), 'setting[authmethod]'); - - // allownewreg - $admin->row_span(T('Allow New Registrations'), 'thead'); - $admin->row_yesno(T('If this is set to yes, then new users will be allowed to register.'), 'setting[allownewreg]', bugdar::$options['allownewreg']); - - // verifyemail - $admin->row_span(T('Require Activation Email'), 'thead'); - $admin->row_yesno(T('Setting this to yes will force all new users to verify their account with an email activation link.'), 'setting[verifyemail]', bugdar::$options['verifyemail']); - - // moderatenewusers - $admin->row_span(T('Moderate New Users'), 'thead'); - $admin->row_yesno(T('All new users will have to be approved by the administration before being able to have normal user rights.'), 'setting[moderatenewusers]', bugdar::$options['moderatenewusers']); - - // sendwelcomemail - $admin->row_span(T('Send New Use Welcome Email'), 'thead'); - $admin->row_yesno(T('Setting this option to yes will send each new verified user a welcome email.'), 'setting[sendwelcomemail]', bugdar::$options['sendwelcomemail']); - - // webmasteremail - $admin->row_span(T('Webmaster Email Address'), 'thead'); - $admin->row_input(T('The email address from which emails will be sent out.'), 'setting[webmasteremail]', bugdar::$options['webmasteremail']); - - // trackertitle - $admin->row_span(T('Tracker Title'), 'thead'); - $admin->row_input(T('The global name of the bug tracker. Example: Blue Static Bug Tracker'), 'setting[trackertitle]', bugdar::$options['trackertitle']); - - // trackerurl - $admin->row_span(T('Tracker Base URL'), 'thead'); - $admin->row_input(T('The base URL of the tracker. This is used when creating external links to the tracker. Be sure that this does not end in a trailing slash ("/").
Example: http://www.bluestatic.org/bugs'), 'setting[trackerurl]', bugdar::$options['trackerurl']); - - // dateformat - $admin->row_span(T('Date Format'), 'thead'); - $admin->row_input(T('Set the date format used for bug report and comment information. This is based on PHP\'s date() function.'), 'setting[dateformat]', bugdar::$options['dateformat']); - - // defaulttimezone - $admin->row_span(T('Default Time Zone'), 'thead'); - $admin->row_text(T('This controls the time zone that all unregistered users view the tracker with.'), construct_option_select('setting[defaulttimezone]', $bugsys->datef->fetch_timezone_list(), bugdar::$options['defaulttimezone']), bugdar::$options['defaulttimezone']); - - // defaultlanguage - $admin->row_span(T('Default Language'), 'thead'); - $admin->row_text(T('You can set the default language that all new users (and guests) will use.'), construct_option_select('setting[defaultlanguage]', bugdar::$datastore['language'], bugdar::$options['defaultlanguage'], 'languageid', 'title'), bugdar::$options['defaultlanguage']); - - // syndicateditems - $admin->row_span(T('Number of Syndicated Items'), 'thead'); - $admin->row_input(T('The number of bugs to be syndicated at any one time by the Atom XML feed.'), 'setting[syndicateditems]', bugdar::$options['syndicateditems']); - - // redirectheaders - $admin->row_span(T('Use Header Redirects'), 'thead'); - $admin->row_yesno(T('Instead of displaying an intermediate page informing the user that their action was a success and a redirect is occurring, just send the user to the next screen using HTTP headers. This can save bandwidth.'), 'setting[redirectheaders]', bugdar::$options['redirectheaders']); - - $admin->table_end(); - - // ################################################################### - $admin->table_start(); - $admin->table_head(T('Bug Reporting Options')); - - // allowhtml - $admin->row_span(T('Allow HTML in Bug Reports'), 'thead'); - $admin->row_yesno(T('Set this to yes if you want to allow users to post raw HTML in their bug reports. This is very dangerous and it is not recommended.'), 'setting[allowhtml]', bugdar::$options['allowhtml']); - - // defaultseverity - $admin->row_span(T('Default Severity'), 'thead'); - $admin->row_text(T('The default severity that is selected when creating a new bug report.'), construct_option_select('setting[defaultseverity]', bugdar::$datastore['severity'], bugdar::$options['defaultseverity'], 'severityid', 'severity')); - - // defaultpriority - $admin->row_span(T('Default Priority'), 'thead'); - $admin->row_text(T('The default priority that will be selected when creating a new bug report. Depending on your permission setup, the user may not be able to set this in a new report so this will act as the value.'), construct_option_select('setting[defaultpriority]', bugdar::$datastore['priority'], bugdar::$options['defaultpriority'], 'priorityid', 'priority')); - - // defaultstatus - $admin->row_span(T('Default Status'), 'thead'); - $admin->row_text(T('The default default that is selected when creating a new bug report. If a user can not assign a status, this will be the one inserted into the database.'), construct_option_select('setting[defaultstatus]', bugdar::$datastore['status'], bugdar::$options['defaultstatus'], 'statusid', 'status')); - - // defaultresolve - $admin->row_span(T('Default Resolution'), 'thead'); - $admin->row_text(T('This is the default bug resolution. If a user is not able to change this field, setting this will act as the default value.'), construct_option_select('setting[defaultresolve]', bugdar::$datastore['resolution'], bugdar::$options['defaultresolve'], 'resolutionid', 'resolution')); - - // defaultassign - $admin->row_span(T('Default Bug Assignment'), 'thead'); - $admin->row_text(T('This is the default developer new bugs will be assigned to. If a user does not have permisssion to assign bugs, this will be the default. If you don\'t want any default assignment, leave this as Not Selected.'), construct_option_select('setting[defaultassign]', bugdar::$datastore['assignto'], bugdar::$options['defaultassign'], 'userid', 'displayname', 0)); - - // defaultcomment - $admin->row_span(T('Default Comment Text'), 'thead'); - $admin->row_textarea(T('If you wish to set a template for entering the initial comment of a bug report, then you may specify this here. However, the template will only take effect on the initial report/comment. Note: the template cannot be forced on the user as there is no way to validate it.'), 'setting[defaultcomment]', bugdar::$options['defaultcomment']); - - $admin->table_end(); - - // ################################################################### - $admin->table_start(); - $admin->table_head(T('Bug Listing Display Options')); - - // hidestatuses - $admin->row_span(T('Hide Statuses on Bug Listings'), 'thead'); - $admin->row_text(T('Here you can specify which statuses to hide on the bug list displays. Users have options in their controls to change this from these values, and this does not affect searches or the favorites list.'), construct_option_select('setting[hidestatuses]', bugdar::$datastore['status'], bugdar::$options['hidestatuses'], 'statusid', 'status', 0, true)); - - // defaultsortkey - $admin->row_span(T('Default Sort Column'), 'thead'); - $admin->row_text(T('Select the column to sort bugs by on listings. This is only a default setting which users can override in their preferences.'), construct_option_select('setting[defaultsortkey]', ListSorter::fetch_by_text(false, false), bugdar::$options['defaultsortkey'])); - - // defaultsortas - $admin->row_span(T('Default Sort Direction'), 'thead'); - $admin->row_text(T('Specify the default direction to sort bugs in the selected column. This works with and follows the same rules as the Sort Column.'), construct_option_select('setting[defaultsortas]', ListSorter::fetch_as_text(false), bugdar::$options['defaultsortas'])); - - // columnoptions - $admin->row_span(T('Default Column Ordering Options'), 'thead'); - $admin->row_text(T('Specify the order of the columns for bug listings. The value 0 disables the display of a column and if two or more columns have the same position number, they will be displayed in the same column.'), ConstructColumnOptionsSetting()); - - $admin->table_end(); - - // ################################################################### - $admin->table_start(); - $admin->table_head(T('Pagination Options')); - - // defaultpp - $admin->row_span(T('Default Per-Page Amount'), 'thead'); - $admin->row_input(T('The number of items (e.g. bugs) to be displayed on a page by default. The user will have the option of over-riding these values.'), 'setting[defaultpp]', bugdar::$options['defaultpp']); - - // maxpp - $admin->row_span(T('Maximum Per-Page Value'), 'thead'); - $admin->row_input(T('To prevent your server from experiencing load problems, set the maximum per page limit. Specifying a value here will make sure any user-entered value will not be higher than this, preventing server load problems.'), 'setting[maxpp]', bugdar::$options['maxpp']); - - // pagelinks - $admin->row_span(T('Number of Page Links'), 'thead'); - $admin->row_input(T('The number of pages that will appear in the page navigation system on either side of the current page. Set this to 0 to display all pages.'), 'setting[pagelinks]', bugdar::$options['pagelinks']); - - $admin->table_end(); - - // ################################################################### - if (DEVDEBUG) - { - $admin->table_start(); - $admin->table_head('Untouchables'); - - // trackerversion - $admin->row_span('Version Number', 'thead'); - $admin->row_input('Version Number', 'setting[trackerversion]', bugdar::$options['trackerversion']); - - $admin->row_span('Custom Gettext Localizer', 'thead'); - $admin->row_yesno('Use the custom MOReader implementation rather than the built-in Gettext extension.', 'setting[devgettext]', bugdar::$options['devgettext']); - } - // ################################################################### - $admin->table_start(); - $admin->row_submit(); - $admin->table_end(); - $admin->form_end(); - - $admin->page_end(); + $admin->evaluate()->flush(); } // ################################################################### diff --git a/admin/templates/nav.html b/admin/templates/nav.html index 31f2f56..e007bca 100644 --- a/admin/templates/nav.html +++ b/admin/templates/nav.html @@ -10,10 +10,10 @@