diff --git a/admin/class-bread-admin.php b/admin/class-bread-admin.php index 3c2d85d..4d090b5 100644 --- a/admin/class-bread-admin.php +++ b/admin/class-bread-admin.php @@ -378,8 +378,7 @@ function get($url, $cookies = array()) 'timeout' => '120', 'cookies' => $cookies, ); - if ( - isset($this->options['user_agent']) + if (isset($this->options['user_agent']) && $this->bread->getOption('user_agent') != 'None' ) { $args['headers'] = array( @@ -451,7 +450,7 @@ function pwsix_process_wizard() if (!$this->current_user_can_create()) { return; } - $layout = sanitize_url($_POST['wizard_layout']); + $layout = sanitize_text_field($_POST['wizard_layout']); $encode_options = file_get_contents(plugin_dir_path(__FILE__) . 'templates/' . $layout); while (0 === strpos(bin2hex($encode_options), 'efbbbf')) { $encode_options = substr($encode_options, 3); @@ -473,7 +472,7 @@ function pwsix_process_wizard() $settings['additional_list_format_key'] = '@Virtual@'; } $str = file_get_contents(plugin_dir_path(__FILE__) . 'templates/meeting_data_templates.json'); - $meeting_templates = json_decode($str); + $meeting_templates = json_decode($str, true); if ($vm_flag == '1') { $settings['custom_section_content'] = ' @@ -484,7 +483,7 @@ function pwsix_process_wizard()

[additional_meetinglist]

' . $settings['custom_section_content']; - $settings['additional_list_template_content'] = $meeting_templates['Online Meeting Two Column']; + $settings['additional_list_template_content'] = join('', $meeting_templates['Online Meeting Two Column - Link in QR-Code']); } $settings['meeting_sort'] = sanitize_text_field($_POST['wizard_meeting_sort']); if ($settings['meeting_sort'] != 'day') { @@ -496,8 +495,19 @@ function pwsix_process_wizard() } } update_option($optionsName, $settings); - $this->bread->setAndSaveSetting($id, 'Setting ' . $id); + $setting_name = sanitize_title($_POST['wizard-setting-name']); + $setting_name = $setting_name == '' ? $setting_name : 'Setting ' . $id; + $this->bread->setAndSaveSetting($id, $setting_name); $this->bread->getMLOptions($id); + $this->bread->setRequestedSetting($id); + ignore_user_abort(true); + ob_clean(); + header('Content-Type: application/json; charset=utf-8'); + header("Expires: 0"); + $message = ['result' => ['setting' => $id]]; + $data = json_encode($message); + header('Content-Length: ' . strlen($data)); + file_put_contents('php://output', $data); } function pwsix_process_settings_admin() { @@ -505,7 +515,7 @@ function pwsix_process_settings_admin() return; } $this->bread->getMLOptions($this->bread->getRequestedSetting()); - if (isset($_POST['delete'])) { + if (isset($_POST['delete_settings'])) { if (!$this->current_user_can_modify()) { return; } diff --git a/admin/css/admin.css b/admin/css/admin.css index b77a480..675d693 100644 --- a/admin/css/admin.css +++ b/admin/css/admin.css @@ -509,3 +509,17 @@ select.service_body_select { .chosen-container-multi .chosen-choices li.search-field input[type=text] { font-family: "Open Sans",sans-serif !important; } +.step-description { + margin: 10px; + border: solid; + padding: 10px; + background-color: cornsilk; +} +.invalid-feedback { + color: red; + font-weight: bold; +} +.valid-feedback { + color: green; + font-weight: bold; +} diff --git a/admin/js/bread-wizard.js b/admin/js/bread-wizard.js index e3fe7f7..17cd883 100644 --- a/admin/js/bread-wizard.js +++ b/admin/js/bread-wizard.js @@ -18,15 +18,50 @@ jQuery(document).ready(function($){ return false; }) } + BreadWizard.prototype.ajax_submit = function() { + var myform = document.getElementById("wizard_form"); + + var formData = new FormData(myform); + + fetch(window.location.href, { + method: "POST", + body: formData, + }) + .then((response) => { + if (!response.ok) { + throw new Error("network returns error"); + } + return response.json(); + }) + .then((resp) => { + finalInstructions(resp); + }) + .catch((error) => { + // Handle error + console.log("error ", error); + }); + } + var href; + finalInstructions = function(response) { + $('#wizard-before-create').hide(); + $('#wizard-after-create').show(); + href = window.location.href.substring(0, window.location.href.indexOf('/wp-admin')); + href = href+"?current-meeting-list="+response.result.setting; + const tag = '
<a href="'+href+'">'+href+'
'; + $('#wizard-show-link').html(tag); + } + BreadWizard.prototype.generate_meeting_list = function() { + window.open(href, '_blank').focus(); + } BreadWizard.prototype.test_root_server = function() { ask_bmlt("switcher=GetServerInfo", (info) => { - $('#wizard_root_server_result').removeClass('invalid-feedback') - .addClass('valid-feedback').html('BMLT Server version '+info[0]['version']); + $('#wizard_root_server_result').removeClass('invalid-feedback dashicons-dismiss') + .addClass('valid-feedback dashicons-before dashicons-yes-alt').html('Connected! - BMLT Server version '+info[0]['version']); }, (error) => { - $('#wizard_root_server_result').removeClass('valid-feedback') - .addClass('invalid-feedback').html('Could not connect: Check spelling and internet connection.'); + $('#wizard_root_server_result').removeClass('valid-feedback dashicons-yes-alt') + .addClass('invalid-feedback dashicons-before dashicons-dismiss').html('Could not connect: Check spelling and internet connection.'); }); } BreadWizard.prototype.root_server_keypress = function(event) { @@ -113,8 +148,10 @@ jQuery(document).ready(function($){ break; case 3: lang_options(); - case 3: + case 4: if ($("wizard_layout").val()=='') handle_error('Layout not defined'); + $('#wizard-before-create').show(); + $('#wizard-after-create').hide(); default: break; } diff --git a/admin/partials/_bmlt_server_setup.php b/admin/partials/_bmlt_server_setup.php index 3bc5e46..bf61405 100644 --- a/admin/partials/_bmlt_server_setup.php +++ b/admin/partials/_bmlt_server_setup.php @@ -29,7 +29,7 @@

- bread->emptyOption('root_server')) { echo "

ERROR: Please enter a BMLT Server"; echo ''; @@ -51,7 +51,7 @@ bread->getOption('sslverify') ? 'checked' : ''; ?> />

-

@@ -92,14 +92,15 @@

Include Extra Meetings(?)

- connected && $this->bread->getOption('extra_meetings_enabled') == 1) { $extra_meetings_array = $this->bread->bmlt()->get_all_meetings(); diff --git a/admin/partials/_bread_wizard.php b/admin/partials/_bread_wizard.php index 4b95dd0..6619c34 100644 --- a/admin/partials/_bread_wizard.php +++ b/admin/partials/_bread_wizard.php @@ -31,12 +31,20 @@ -
+

Step 1: Enter your BMLT root server

+
+

This wizard guides you through the initial configuation of a meeting list. If you have already created one or more meeting lists, + don't worry, this process alway creates a new configuration, and never overwrites old ones.

+

Bread is highly customizable, as areas often try to maintain the appearance of their old meeting lists. This wizard only attempts to give you a reasonable + starting point, not an end product. At the end of the wizard we make a few suggestions for possible next steps.

+

The first thing we need is the location of your BMLT root server. Once you have entered it, you need check that the URL is correct + by clicking the "Test Connection" button.

+

Visit Do I have the BMLT? to find your BMLT server

Step 2: Select a service body

+
+

Next, we need to know which meetings are going to be on the meeting list. This will help the wizard when it + tries to choose an a appropriate layout for you.

+
+

Step 3: Page Layout

+
+

Most areas try to fit their meetings onto a single sheet of paper. And it is particularly adventageous to + use a tri-fold format, so that the list can be printed at home and placed along side the pamphlets. Remember though, that when fonts become + too small, the meeting list becomes unreadable. For many areas, a booklet format is better, even + if the reqire more effort or expense to print.

+

In this step we suggest suitible formats based on your meeting count.

+

Number of meetings on list:

Select one of the layouts appropriate to the number of meetings

- +
+

In this step, we create the meeting list settings. If you already have a meeting list defined + on this site, the old settings will not be overwriten, rather, a new setting will be created.

+

Before creating the meeting list configuration, you are given the opportunity to give the configuration + a mnemonic name. If you are managing multiple meeting lists on this same, this name can help you keep track of which + configuration is which.

+

After creating the configuration, you will be able to view the resulting meeting list. Note that this is not usually + ready to be printed. Users almost always want to add content, such as service meetings, help lines, place for people to + collect phone numbers etc. To do this, click on the "Customize" tab to the left, and then go to either the "Front Page" or + "Custom Section" tabs. The editors there contain a "Meeting List Shortcodes" dropdown menu. Using these, new structures can + be added with only a few mouse clicks.

+

You may also want to adjust the font sizes on your meeting list so that it fits on a single sheet or is more readable. This is only + of the many options available in the "Customizer".

+
+
+

+

+ +
+
+ +

+ To add a link to the meeting list on your website, use the following link. +

+
diff --git a/admin/partials/_meeting_list_setup.php b/admin/partials/_meeting_list_setup.php index 3cf2a3c..6302f4f 100644 --- a/admin/partials/_meeting_list_setup.php +++ b/admin/partials/_meeting_list_setup.php @@ -12,34 +12,15 @@
-

Read This Section First

-
-

Getting Started

-

bread is first activated using a "Tri Fold - Landscape - Letter Size" layout. This is a "starter" meeting list that uses an Area with about 100 meetings. The starter meeting list will contain standard content for a basic meeting list that can be printed on a home computer. A basic NA logo will be added to your media libray. The starter meeting list uses a logo being hosted on https://nameetinglist.org.

-

Step 1.

-

Click on the BMLT Server tab to the left. Change the BMLT Server and click the Save Changes button.

-

To find your BMLT Server click on the red question (?) mark.

-

Step 2.

-

From the Service Body 1 dropdown select your Area or Region. Then click Save Changes.

-

Step 3.

-

Click Generate Meeting List. Your meeting list will open in a new tab or window.

-

Step 4.

-

See the "Meeting List Setup" section below for additional defaults.

-

Repeat steps 1, 2 and 3 after changing to new Default Settings.

-

What Now?

-

From here you will move forward with setting up your meeting list by exploring the Page Layout, Front Page, Custom Section, Meetings, etc tabs. There are countless ways to setup a meeting list.

-

Please allow yourself to experiment with mixing and matching different settings and content. There is a good chance you can find a way to match or at least come very close to your current meeting list.

-

When setting up the meeting list it is helpful to have some knowledge of HTML when using the editors. Very little or no knowledge of HTML is required to maintain the meeting list after the setup. If you get stuck or would like some help with the setup, read the Support section below.

-
-

Meeting List Setup Wizard

+

Start Here: Meeting List Setup Wizard

Multiple Meeting Lists

This tool supports multiple meeting lists per site.

-

This feature is configured from the Configuration Tab. There, each concurrent meeting list can be given a +

This feature is configured from the

Backup/Restore
Tab. There, each concurrent meeting list can be given a name, and the system gives the meeting list a numberic identifier. The meeting list can then be generated using

a link of the form http://[host]?current-meeting-list=[id]

-

After switching to another concurrent meeting list, any changes in the admin UI impact the currently selected meeting list

+

After switching to another meeting list, any changes in the admin UI impact the currently selected meeting list

If you want to give another user access to bread you can give that use the "manage_bread" capability using a custom role editor.

Reusable Templating

@@ -50,6 +31,28 @@

You can use any HTML characters, including line breaks.

Here is a video of it in action: https://bmlt.app/reusable-templates-with-bread-1-6-x/

+

Extending Bread

+
+

Advanced users can extend the functionality of Bread using the WordPress filter mechanism.

+

The Bread_Enrich_Meeting_Data filter allows the user to expose calculated fields in their the templates to their meetings. + An example for the use of this is to make meetings in other languages easier to find by modifying the name of such a meeting to include a text in the other language. (Normally, other languages are + just noted in the formats, which make the meetings quite hard to find.)

+

This extension has the form:

+
+                add_filter('Bread_Enrich_Meeting_Data', 'enrichMeetingData', 10, 2);
+                function enrichMeetingData($value, $formatsByKey) {...}
+                
+ where $value is an array containing the properties of the meeting, and formatsByKey is a list of the available formats and their properties. +

Similarly, the Bread_Section_Shortcodes filter allows the user to make additional commands available in the Front-Page and Custom-Section parts of their meeting lists. +

This can be used to exposed additional mPdf commands. +

This extension has the form:

+
+                add_filter('Bread_Section_Shortcodes', 'sectionShortcodes', 10, 3);
+                function sectionShortcodes($section_shortcodes, $areas, $formats_used) {...}
+                
+ where $section_shortcodes is an array containing the default shortcodes, areas is a list of the service bodies and their metadata and formats_used is an array of format metadata. + +

Support and Help

File an issue https://github.com/bmlt-enabled/bread/issues

diff --git a/admin/partials/bread-admin-display.php b/admin/partials/bread-admin-display.php index 81c6cfe..d06f55d 100644 --- a/admin/partials/bread-admin-display.php +++ b/admin/partials/bread-admin-display.php @@ -214,7 +214,7 @@ function admin_options_page() $this->bread->setOption('extra_meetings', wp_kses_post($extra)); } } - $authors = $_POST['authors_select']; + $authors = isset($_POST['author_chosen']) ? $_POST['author_chosen'] : []; $this->bread->setOption('authors', array()); foreach ($authors as $author) { $this->bread->appendOption('authors', intval($author)); @@ -251,12 +251,6 @@ function admin_options_page() echo '

Your default settings were successfully updated!

'; $num = delete_transient($this->bread->get_TransientKey($this->bread->getRequestedSetting())); } - global $wpdb; - $query = "SELECT COUNT(*) FROM {$wpdb->posts} WHERE guid LIKE '%default_nalogo.jpg%'"; - if ($wpdb->get_var($query) == 0) { - $url = plugin_dir_url(__FILE__) . "includes/default_nalogo.jpg"; - media_sideload_image($url, 0); - } $this->bread->fillUnsetOptions(); ?>
@@ -266,8 +260,8 @@ function admin_options_page()
diff --git a/admin/templates/meeting_data_templates.json b/admin/templates/meeting_data_templates.json index 0030702..2f2d13d 100644 --- a/admin/templates/meeting_data_templates.json +++ b/admin/templates/meeting_data_templates.json @@ -1,22 +1,21 @@ { "One Column Template [Time Meeting Data]": "
time group, location, info, street, city, state, zip (formats) comments
virtual_meeting_link
virtual_meeting_additional_info
", - "Two Column Template [Time] [Meeting Data]": "
timegroup, location, info, street, city, state, zip (formats) comments
virtual_meeting_link
virtual_meeting_additional_info
", + "Two Column Template [Time] [Meeting Data]": "
timegroup, location, info, street, city, state, zip (formats) comments
virtual_meeting_link
virtual_meeting_additional_info
", "One Column Template with Day [Day Time Meeting Data]": "
day_abbr time group, location, info, street,city, state,zip(formats)comments
virtual_meeting_link
virtual_meeting_additional_info
", - "Two Column Template with Day [Day/Time] [Meeting Data]": "
day
time
group, location, info, street, city, state, zip (formats) comments
virtual_meeting_link
virtual_meeting_additional_info
", - "Online Meeting Two Column": [ + "Two Column Template with Day [Day/Time] [Meeting Data]": "
day
time
group, location, info, street, city, state, zip (formats) comments
virtual_meeting_link
virtual_meeting_additional_info
", + "Online Meeting Two Column - Link in QR-Code": [ "'", "", "", -"", "", "", diff --git a/admin/tinymce/front_page_button/plugin.min.js b/admin/tinymce/front_page_button/plugin.min.js index f70af87..ae6ee07 100644 --- a/admin/tinymce/front_page_button/plugin.min.js +++ b/admin/tinymce/front_page_button/plugin.min.js @@ -81,9 +81,9 @@ } }, { - text: 'Service Meetings Template', + text: 'Additional Meetinglist Template', onclick: function () { - editor.insertContent('
", +"", "

time

", -"

[QRCode code='virtual_meeting_link' size='0.70']

", +"

[QRCode code='virtual_meeting_link' size='0.50']

", "
group", "

comments

", "

formats

", "

phone_meeting_number

", -"

virtual_meeting_link

", "

virtual_meeting_additional_info

", "
Service Meetings

[service_meetings]

'); + editor.insertContent('
Additional Meetings

[additional_meetinglist]

'); } }, { diff --git a/includes/class-bread.php b/includes/class-bread.php index 0ad162d..5922445 100644 --- a/includes/class-bread.php +++ b/includes/class-bread.php @@ -565,6 +565,9 @@ function fillUnsetOptionsInner() $this->fillUnsetStringOption('neighborhood_suffix', 'Neighborhood'); $this->fillUnsetStringOption('city_suffix', 'City'); $this->fillUnsetStringOption('meeting_template_content', ''); + //TODO:remove....clean up after a bug... + if (is_array($this->options['additional_list_template_content'])) + $this->options['additional_list_template_content'] = join('', $this->options['additional_list_template_content']); $this->fillUnsetStringOption('additional_list_template_content', ''); $this->fillUnsetOption('column_line', 0); $this->fillUnsetOption('col_color', '#bfbfbf'); @@ -643,8 +646,7 @@ function upgrade_settings() $this->options['root_server'] = 'http://' . $this->options['root_server']; } } - if ( - !isset($this->options['cont_header_shown']) + if (!isset($this->options['cont_header_shown']) && isset($this->options['page_height_fix']) ) { $fix = floatval($this->options['page_height_fix']); diff --git a/public/class-bread-public.php b/public/class-bread-public.php index 16be4cc..3d94d26 100644 --- a/public/class-bread-public.php +++ b/public/class-bread-public.php @@ -277,12 +277,17 @@ private function constuct_page_type_settings() } elseif ($this->options['page_size'] == 'A4') { $page_type_settings = ['format' => array(99.0, 210.0), 'margin_footer' => $this->options['margin_footer']]; } + } elseif ($this->options['page_size'] == '5inch') { + $this->options['page_fold'] = 'full'; + $page_type_settings = ['format' => array(197.2,279.4), 'margin_footer' => $this->options['margin_footer']]; } elseif ($this->options['page_fold'] == 'full') { $ps = $this->options['page_size']; if ($ps == 'ledger') { $ps = 'tabloid'; } $page_type_settings = ['format' => $ps . "-" . $this->options['page_orientation'], 'margin_footer' => $this->options['margin_footer']]; + } elseif ($this->options['page_size'] == '5inch') { + $page_type_settings = ['format' => array(197.2,279.4), 'margin_footer' => $this->options['margin_footer']]; } else { $ps = $this->options['page_size']; if ($ps == 'ledger') {