diff --git a/bmlt-meeting-list.php b/bmlt-meeting-list.php index 85788c2..845df67 100644 --- a/bmlt-meeting-list.php +++ b/bmlt-meeting-list.php @@ -5,10 +5,11 @@ Description: Maintains and generates a PDF Meeting List from BMLT. Author: bmlt-enabled Author URI: https://bmlt.app -Version: 2.0.0 +Version: 2.1.0 */ /* Disallow direct access to the plugin file */ use Mpdf\Mpdf; +use function DeepCopy\deep_copy; error_reporting(1); if (basename($_SERVER['PHP_SELF']) == basename(__FILE__)) { die('Sorry, but you cannot access this page directly.'); @@ -22,9 +23,11 @@ class Bread { var $mpdf = ''; var $meeting_count = 0; var $formats_used = ''; - var $formats_by_key = ''; + var $formats_by_key = array(); var $formats_spanish = ''; var $formats_all = ''; + var $translate = array(); + var $services = ''; var $meeting_fields = array ( 'id_bigint', 'service_body_bigint', @@ -124,7 +127,7 @@ function __construct() { $current_settings = isset($holder['current-meeting-list']) ? intval($holder['current-meeting-list']) : 1; $this->getMLOptions($current_settings); $this->lang = $this->get_bmlt_server_lang(); - + $this->load_translations(); if (isset($holder['current-meeting-list']) && !is_admin()) { $this->bmlt_meeting_list(); } else if (is_admin()) { @@ -307,194 +310,20 @@ function my_theme_add_editor_styles() { add_editor_style( plugin_dir_url(__FILE__) . "css/editor-style.css" ); } } - - function getday( $day, $abbreviate = false, $language = '') { - $data = ''; - if ( $day == 1 ) { - if ( $language == 'en' || $language == 'en' ) { - $data = ($abbreviate ? 'Sun' : "Sunday"); - } elseif ( $language == 'es' ) { - $data = ($abbreviate ? 'Dom' : "Domingo"); - } elseif ( $language == 'fr' ) { - $data = ($abbreviate ? 'Dim' : "Dimanche"); - } elseif ( $language == 'both_po' ) { - $data = ($abbreviate ? 'Sun / Dom' : "Sunday / Domingo"); - } elseif ( $language == 'po' ) { - $data = ($abbreviate ? 'Dom' : "Domingo"); - } elseif ( $language == 'both' ) { - $data = ($abbreviate ? 'Sun / Dom' : "Sunday / Domingo"); - } elseif ( $language == 'fr_en' ) { - $data = ($abbreviate ? 'Dim / Sun' : "Dimanche / Sunday"); - } elseif ( $language == 'se') { - $data = ($abbreviate ? "Sön" : "Söndag"); - } elseif ( $language == 'dk') { - $data = ($abbreviate ? "Sø" : "Søndag"); - } elseif ( $language == 'de' ) { - $data = ($abbreviate ? 'So.' : "Sonntag"); - } elseif ( $language == 'fa' ) { - $data = ($abbreviate ? '' : mb_convert_encoding ('یَکشَنبه', 'HTML-ENTITIES')); - } elseif ( $language == 'it') { - $data = ($abbreviate ? "Do" : "Domenica"); - } - } elseif ( $day == 2 ) { - if ( $language == 'en' || $language == 'en' ) { - $data = ($abbreviate ? 'Mon' : "Monday"); - } elseif ( $language == 'es' ) { - $data = ($abbreviate ? 'Lun' : "Lunes"); - } elseif ( $language == 'fr' ) { - $data = ($abbreviate ? 'Lun' : "Lundi"); - } elseif ( $language == 'both_po' ) { - $data = ($abbreviate ? 'Mon / Lun / Seg' : "Monday / Lunes / Segunda-feira"); - } elseif ( $language == 'po' ) { - $data = ($abbreviate ? 'Seq' : "Segunda-feira"); - } elseif ( $language == 'both' ) { - $data = ($abbreviate ? 'Mon / Lun' : "Monday / Lunes"); - } elseif ( $language == 'fr_en' ) { - $data = ($abbreviate ? 'Lun / Mon' : "Lundi / Monday"); - } elseif ( $language == 'se') { - $data = ($abbreviate ? "Mån" : "Måndag"); - } elseif ( $language == 'dk') { - $data = ($abbreviate ? "Ma" : "Mandag"); - } elseif ( $language == 'de' ) { - $data = ($abbreviate ? 'Mo.' : "Montag"); - } elseif ( $language == 'fa' ) { - $data = ($abbreviate ? '' : mb_convert_encoding ('دوشَنبه', 'HTML-ENTITIES')); - } elseif ( $language == 'it') { - $data = ($abbreviate ? "Lun" : "Lunedì"); - } - } elseif ( $day == 3 ) { - if ( $language == 'en' || $language == 'en' ) { - $data = ($abbreviate ? 'Tue' : "Tuesday"); - } elseif ( $language == 'es' ) { - $data = ($abbreviate ? 'Mar' : "Martes"); - } elseif ( $language == 'fr' ) { - $data = ($abbreviate ? 'Mar' : "Mardi"); - } elseif ( $language == 'both_po' ) { - $data = ($abbreviate ? 'Tue / Mar / Ter' : "Tuesday / Martes / Terça-feira"); - } elseif ( $language == 'po' ) { - $data = ($abbreviate ? 'Ter' : "Terça-feira"); - } elseif ( $language == 'both' ) { - $data = ($abbreviate ? 'Tue / Mar' : "Tuesday / Martes"); - } elseif ( $language == 'fr_en' ) { - $data = ($abbreviate ? 'Mar / Tues' : "Mardi / Tuesday"); - } elseif ( $language == 'se') { - $data = ($abbreviate ? "Tis" : "Tisdag"); - } elseif ( $language == 'dk') { - $data = ($abbreviate ? "Ti" : "Tirsdag"); - } elseif ( $language == 'de' ) { - $data = ($abbreviate ? 'Di.' : "Dienstag"); - } elseif ( $language == 'fa' ) { - $data = ($abbreviate ? '' : mb_convert_encoding('سهشنبه', 'HTML-ENTITIES')); - } elseif ( $language == 'it') { - $data = ($abbreviate ? "Mar" : "Martedì"); - } - } elseif ( $day == 4 ) { - if ( $language == 'en' || $language == 'en' ) { - $data = ($abbreviate ? 'Wed' : "Wednesday"); - } elseif ( $language == 'es' ) { - $data = ($abbreviate ? 'Mié' : "Miércoles"); - } elseif ( $language == 'fr' ) { - $data = ($abbreviate ? 'Mer' : "Mercredi"); - } elseif ( $language == 'both_po' ) { - $data = ($abbreviate ? 'Wed / Mié / Qua' : "Wednesday / Miércoles / Quarta-feira"); - } elseif ( $language == 'po' ) { - $data = ($abbreviate ? 'Qua' : "Quarta-feira"); - } elseif ( $language == 'both' ) { - $data = ($abbreviate ? 'Wed / Mié' : "Wednesday / Miércoles"); - } elseif ( $language == 'fr_en' ) { - $data = ($abbreviate ? 'Mer / Wed' : "Mercredi / Wednesday"); - } elseif ( $language == 'se') { - $data = ($abbreviate ? "Ons" : "Onsdag"); - } elseif ( $language == 'dk') { - $data = ($abbreviate ? "On" : "Onsdag"); - } elseif ( $language == 'de' ) { - $data = ($abbreviate ? 'Mi.' : "Mittwoch"); - } elseif ( $language == 'fa' ) { - $data = ($abbreviate ? '' : mb_convert_encoding('چهار شنبه', 'HTML-ENTITIES')); - } elseif ( $language == 'it') { - $data = ($abbreviate ? "Mer" : "Mercoledì"); - } - } elseif ( $day == 5 ) { - if ( $language == 'en' || $language == 'en' ) { - $data = ($abbreviate ? 'Thu' : "Thursday"); - } elseif ( $language == 'es' ) { - $data = ($abbreviate ? 'Jue' : "Jueves"); - } elseif ( $language == 'fr' ) { - $data = ($abbreviate ? 'Jeu' : "Jeudi"); - } elseif ( $language == 'both_po' ) { - $data = ($abbreviate ? 'Thu / Jue / Qui' : "Thursday / Jueves / Quinta-feira"); - } elseif ( $language == 'po' ) { - $data = ($abbreviate ? 'Qui' : "Quinta-feira"); - } elseif ( $language == 'both' ) { - $data = ($abbreviate ? 'Thu / Jue' : "Thursday / Jueves"); - } elseif ( $language == 'fr_en' ) { - $data = ($abbreviate ? 'Jeu / Thu' : "Jeudi / Thursday"); - } elseif ( $language == 'se') { - $data = ($abbreviate ? "Tors" : "Torsdag"); - } elseif ( $language == 'dk') { - $data = ($abbreviate ? "To" : "Torsdag"); - } elseif ( $language == 'de' ) { - $data = ($abbreviate ? 'Do.' : "Donnerstag"); - } elseif ( $language == 'fa' ) { - $data = ($abbreviate ? '' : mb_convert_encoding ('پَنج شَنبه', 'HTML-ENTITIES')); - } elseif ( $language == 'it') { - $data = ($abbreviate ? "Gio" : "Giovedì"); - } - } elseif ( $day == 6 ) { - if ( $language == 'en' || $language == 'en' ) { - $data = ($abbreviate ? 'Fri' : "Friday"); - } elseif ( $language == 'es' ) { - $data = ($abbreviate ? 'Vie' : "Viernes"); - } elseif ( $language == 'fr' ) { - $data = ($abbreviate ? 'Ven' : "Vendredi"); - } elseif ( $language == 'both_po' ) { - $data = ($abbreviate ? 'Fri / Vie / Sex' : "Friday / Viernes / Sexta-feira"); - } elseif ( $language == 'po' ) { - $data = ($abbreviate ? 'Sex' : "Sexta-feira"); - } elseif ( $language == 'both' ) { - $data = ($abbreviate ? 'Fri / Vie' : "Friday / Viernes"); - } elseif ( $language == 'fr_en' ) { - $data = ($abbreviate ? 'Ven / Fri' : "Vendredi / Friday"); - } elseif ( $language == 'se') { - $data = ($abbreviate ? "Fre" : "Fredag"); - } elseif ( $language == 'dk') { - $data = ($abbreviate ? "Fr" : "Fredag"); - } elseif ( $language == 'de' ) { - $data = ($abbreviate ? 'Fr.' : "Freitag"); - } elseif ( $language == 'fa' ) { - $data = ($abbreviate ? '' : mb_convert_encoding ('جُمعه', 'HTML-ENTITIES')); - } elseif ( $language == 'it') { - $data = ($abbreviate ? "Ven" : "Venerdì"); - } - } elseif ( $day == 7 ) { - if ( $language == 'en' || $language == 'en' ) { - $data = ($abbreviate ? 'Sat' : "Saturday"); - } elseif ( $language == 'es' ) { - $data = ($abbreviate ? 'Sáb' : "Sábado"); - } elseif ( $language == 'fr' ) { - $data = ($abbreviate ? 'Sam' : "Samedi"); - } elseif ( $language == 'both_po' ) { - $data = ($abbreviate ? 'Sat / Sáb' : "Saturday / Sábado"); - } elseif ( $language == 'po' ) { - $data = ($abbreviate ? 'Sáb' : "Sábado"); - } elseif ( $language == 'both' ) { - $data = ($abbreviate ? 'Sat / Sáb' : "Saturday / Sábado"); - } elseif ( $language == 'fr_en' ) { - $data = ($abbreviate ? 'Sam / Sat' : "Samedi / Saturday"); - } elseif ( $language == 'se') { - $data = ($abbreviate ? "Lör" : "Lördag"); - } elseif ( $language == 'dk') { - $data = ($abbreviate ? "Lø" : "Lørdag"); - } elseif ( $language == 'de' ) { - $data = ($abbreviate ? 'Sa.' : "Samstag"); - } elseif ( $language == 'fa' ) { - $data = ($abbreviate ? '' : mb_convert_encoding ('شَنبه', 'HTML-ENTITIES')); - } elseif ( $language == 'it') { - $data = ($abbreviate ? "Sab" : "Sabato"); - } + function load_translations() { + $files = scandir(dirname(__FILE__)."/lang"); + foreach ($files as $file) { + if (strpos($file,"translate_")!==0) continue; + include(dirname(__FILE__)."/lang/".$file); + $key = substr($file,10,-4); + $this->translate[$key] = $translate; } - - Return utf8_encode($data); + } + function getday( $day, $abbreviate = false, $language = 'en') { + $data = ''; + $key = "WEEKDAYS"; + if ($abbreviate) $key = "WKDYS"; + return utf8_encode($this->translate[$language][$key][$day]); } function authenticate_root_server() { @@ -601,6 +430,8 @@ function testRootServer($override_root_server = null) { $results = $results["serverVersion"]["readableString"]; return $results; } + // This is used from the AdminUI, not to generate the + // meeting list. function getUsedFormats() { if ( !isset($this->options['recurse_service_bodies']) ) {$this->options['recurse_service_bodies'] = 1;} $area_data = explode(',',$this->options['service_body_1']); @@ -634,32 +465,45 @@ function sortBySubkey(&$array, $subkey, $sortType = SORT_ASC) { } array_multisort($keys, $sortType, $array); } - + function upgrade_settings() { + if (!isset($this->options['cont_header_shown']) + && isset($this->options['page_height_fix'])) { + $fix = floatval($this->options['page_height_fix']); + // say, the height of 2 lines + $x = floatval($this->options['content_font_size']) * + floatval($this->options['content_line_height']) * 2.0 * 0.35; // pt to mm + if ($fix < $x) { + $this->options['cont_header_shown'] = true; + } else { + $this->options['cont_header_shown'] = false; + } + unset($this->options['page_height_fix']); + } + if ($this->options['weekday_language'] == 'both') { + $this->options['weekday_language'] = "en_es"; + } + if ($this->options['weekday_language'] == 'both_po') { + $this->options['weekday_language'] = "en_po"; + } + } function bmlt_meeting_list($atts = null, $content = null) { ini_set('max_execution_time', 600); // tomato server can take a long time to generate a schedule, override the server setting $area_data = explode(',',$this->options['service_body_1']); $area = $area_data[0]; - $this->options['service_body_1'] = $area; - $service_body_id = $area_data[1]; - $parent_body_id = $area_data[2]; - if ( !isset($this->options['recurse_service_bodies']) ) {$this->options['recurse_service_bodies'] = 1;} - if ( $this->options['recurse_service_bodies'] == 1 ) { - $services = '&recursive=1&services[]=' . $service_body_id; - $services_service_body_1 = '&recursive=1&services[]=' . $service_body_id; - } else { - $services = '&services[]='.$service_body_id; - $services_service_body_1 = '&services[]='.$service_body_id; - } - $services .= $this->addServiceBody('service_body_2'); - $services .= $this->addServiceBody('service_body_3'); - $services .= $this->addServiceBody('service_body_4'); - $services .= $this->addServiceBody('service_body_5'); + if (isset($_GET['custom_query'])) { $services = $_GET['custom_query']; - } elseif ( false === ( $this->options['custom_query'] == '' )) { + } elseif ( $this->options['custom_query'] !== '' ) { $services = $this->options['custom_query']; + } else { + $services = $this->addServiceBody('service_body_1'); + $services .= $this->addServiceBody('service_body_2'); + $services .= $this->addServiceBody('service_body_3'); + $services .= $this->addServiceBody('service_body_4'); + $services .= $this->addServiceBody('service_body_5'); } + $this->services = $services; if ( $this->options['root_server'] == '' ) { echo '
bread Error: BMLT Server missing.
Please go to Settings -> bread and verify BMLT Server
[new_column]
' => 'No Meetings Found
Or
Internet or Server Problem
'.$this->options['root_server'].'
Please try again or contact your BMLT Administrator
".$subheader."
"; @@ -1237,48 +1053,31 @@ function bmlt_meeting_list($atts = null, $content = null) { } if ( $newVal ) { $header .= "[service_meetings]
', $str, $data); $data = str_replace('[service_meetings]', $str, $data); @@ -1787,7 +1581,9 @@ function write_formats($formats, $page) { $data .= ""; return $data; } - + function asm_required($data) { + return strpos($data,'[service_meetings]') || strpos($data,'[additional_meetings]'); + } function write_detailed_formats($formats, $page) { if ( $formats == null ) { return ''; } $this->mpdf->WriteHTML('td{font-size: '.$this->options[$page.'_font_size']."pt;line-height:".$this->options[$page.'_line_height'].';}',1); @@ -1820,7 +1616,7 @@ function get_field($obj,$field) { function write_service_meetings($font_size, $line_height) { if ( $this->service_meeting_result == null ) { // Why not add a query string that limits to meetings having the desired format???? - $asm_query = "client_interface/json/?switcher=GetSearchResults$services_service_body_1&sort_keys=$this->options['asm_sort_order']"; + $asm_query = "client_interface/json/?switcher=GetSearchResults$this->services&sort_keys=$this->options['asm_sort_order']"; // I'm not sure we need this, but for now we need to emulate the old behavior if ($this->options['asm_format_key']==='ASM') { $asm_query .= "&advanced_published=0"; @@ -1854,7 +1650,8 @@ function write_service_meetings($font_size, $line_height) { $area_name = $this->get_area_name($meeting_value); if ($template != '') { $template = str_replace(" ", " ", $template); - $data .= $this->write_single_meeting($value, $template, $this->analyseTemplate($template), $area_name); + $data .= $this->write_single_meeting($value, $template, $this->analyseTemplate($template), + $area_name, $this->options['asm_language']); continue; } $display_string = ''.$value['meeting_name'].''; @@ -1982,8 +1779,7 @@ function admin_options_page() { $this->options['header_uppercase'] = intval($_POST['header_uppercase']); $this->options['header_bold'] = intval($_POST['header_bold']); $this->options['sub_header_shown'] = intval($_POST['sub_header_shown']); - $this->options['page_height_fix'] = intval($_POST['page_height_fix']); - $this->options['column_gap'] = intval($_POST['column_gap']); + $this->options['cont_header_shown'] = intval($_POST['cont_header_shown']); $this->options['column_gap'] = intval($_POST['column_gap']); $this->options['margin_right'] = intval($_POST['margin_right']); $this->options['margin_left'] = intval($_POST['margin_left']); $this->options['margin_bottom'] = intval($_POST['margin_bottom']); @@ -2018,6 +1814,7 @@ function admin_options_page() { $this->options['extra_meetings_enabled'] = isset($_POST['extra_meetings_enabled']) ? intval($_POST['extra_meetings_enabled']) : 0; $this->options['include_protection'] = boolval($_POST['include_protection']); $this->options['weekday_language'] = sanitize_text_field($_POST['weekday_language']); + $this->options['asm_language'] = sanitize_text_field($_POST['asm_language']); $this->options['weekday_start'] = sanitize_text_field($_POST['weekday_start']); $this->options['include_asm'] = boolval($_POST['include_asm']); $this->options['asm_format_key'] = sanitize_text_field($_POST['asm_format_key']); @@ -2026,6 +1823,7 @@ function admin_options_page() { $this->options['bmlt_login_id'] = sanitize_text_field($_POST['bmlt_login_id']); $this->options['bmlt_login_password'] = sanitize_text_field($_POST['bmlt_login_password']); $this->options['base_font'] = sanitize_text_field($_POST['base_font']); + $this->options['colorspace'] = sanitize_text_field($_POST['colorspace']); $this->options['protection_password'] = sanitize_text_field($_POST['protection_password']); $this->options['time_clock'] = sanitize_text_field($_POST['time_clock']); $this->options['time_option'] = intval($_POST['time_option']); @@ -2146,6 +1944,9 @@ function admin_options_page() { options['front_page_line_height']) || strlen(trim($this->options['front_page_line_height'])) == 0 ) { - $this->options['front_page_line_height'] = '1.0'; - } - if ( !isset($this->options['front_page_font_size']) || strlen(trim($this->options['front_page_font_size'])) == 0 ) { - $this->options['front_page_font_size'] = '10'; - } - if ( !isset($this->options['last_page_font_size']) || strlen(trim($this->options['last_page_font_size'])) == 0 ) { - $this->options['last_page_font_size'] = '10'; - } - if ( !isset($this->options['content_font_size']) || strlen(trim($this->options['content_font_size'])) == 0 ) { - $this->options['content_font_size'] = '9'; - } - if ( !isset($this->options['header_font_size']) || strlen(trim($this->options['header_font_size'])) == 0 ) { - $this->options['header_font_size'] = $this->options['content_font_size']; - } - if ( !isset($this->options['pageheader_fontsize']) || strlen(trim($this->options['pageheader_fontsize'])) == 0 ) { - $this->options['pageheader_fontsize'] = $this->options['header_font_size']; - } - if ( !isset($this->options['suppress_heading']) || strlen(trim($this->options['suppress_heading'])) == 0 ) { - $this->options['suppress_heading'] = 0; - } - if ( !isset($this->options['header_text_color']) || strlen(trim($this->options['header_text_color'])) == 0 ) { - $this->options['header_text_color'] = '#ffffff'; - } - if ( !isset($this->options['header_background_color']) || strlen(trim($this->options['header_background_color'])) == 0 ) { - $this->options['header_background_color'] = '#000000'; - } - if ( !isset($this->options['pageheader_textcolor']) || strlen(trim($this->options['pageheader_textcolor'])) == 0 ) { - $this->options['pageheader_textcolor'] = '#000000'; - } - if ( !isset($this->options['pageheader_backgroundcolor']) || strlen(trim($this->options['pageheader_backgroundcolor'])) == 0 ) { - $this->options['pageheader_backgroundcolor'] = '#ffffff'; - } - if ( !isset($this->options['header_uppercase']) || strlen(trim($this->options['header_uppercase'])) == 0 ) { - $this->options['header_uppercase'] = '0'; - } - if ( !isset($this->options['header_bold']) || strlen(trim($this->options['header_bold'])) == 0 ) { - $this->options['header_bold'] = '1'; - } - if ( !isset($this->options['sub_header_shown']) || strlen(trim($this->options['sub_header_shown'])) == 0 ) { - $this->options['sub_header_shown'] = '0'; - } - if ( !isset($this->options['margin_top']) || strlen(trim($this->options['margin_top'])) == 0 ) { - $this->options['margin_top'] = 3; - } - if ( !isset($this->options['margin_bottom']) || strlen(trim($this->options['margin_bottom'])) == 0 ) { - $this->options['margin_bottom'] = 3; - } - if ( !isset($this->options['margin_left']) || strlen(trim($this->options['margin_left'])) == 0 ) { - $this->options['margin_left'] = 3; - } - if ( !isset($this->options['margin_right']) || strlen(trim($this->options['margin_right'])) == 0 ) { - $this->options['margin_right'] = 3; - } - if ( !isset($this->options['page_height_fix']) || strlen(trim($this->options['page_height_fix'])) == 0 ) { - $this->options['page_height_fix'] = 0; - } - if ( !isset($this->options['column_gap']) || strlen(trim($this->options['column_gap'])) == 0 ) { - $this->options['column_gap'] = "5"; - } - if ( !isset($this->options['content_line_height']) || strlen(trim($this->options['content_line_height'])) == 0 ) { - $this->options['content_line_height'] = '1.0'; - } - if ( !isset($this->options['last_page_line_height']) || strlen(trim($this->options['last_page_line_height'])) == 0 ) { - $this->options['last_page_line_height'] = '1.0'; - } - if ( !isset($this->options['page_size']) || strlen(trim($this->options['page_size'])) == 0 ) { - $this->options['page_size'] = 'legal'; - } - if ( !isset($this->options['page_orientation']) || strlen(trim($this->options['page_orientation'])) == 0 ) { - $this->options['page_orientation'] = 'L'; - } - if ( !isset($this->options['page_fold']) || strlen(trim($this->options['page_fold'])) == 0 ) { - $this->options['page_fold'] = 'quad'; - } - if ( !isset($this->options['meeting_sort']) || strlen(trim($this->options['meeting_sort'])) == 0 ) { - $this->options['meeting_sort'] = 'day'; - } - if ( !isset($this->options['booklet_pages']) ) { - $this->options['booklet_pages'] = false; - } - if ( !isset($this->options['borough_suffix']) ) { - $this->options['borough_suffix'] = 'Borough'; - } - if ( !isset($this->options['county_suffix']) ) { - $this->options['county_suffix'] = 'County'; - } - if ( !isset($this->options['neighborhood_suffix']) ) { - $this->options['neighborhood_suffix'] = 'Neighborhood'; - } - if ( !isset($this->options['city_suffix']) ) { - $this->options['city_suffix'] = 'City'; - } - if ( !isset($this->options['meeting_template_content']) || strlen(trim($this->options['meeting_template_content'])) == 0 ) { - $this->options['meeting_template_content'] = ''; - } - if ( !isset($this->options['asm_template_content']) || strlen(trim($this->options['asm_template_content'])) == 0 ) { - $this->options['asm_template_content'] = ''; - } - if ( !isset($this->options['column_line']) || strlen(trim($this->options['column_line'])) == 0 ) { - $this->options['column_line'] = 0; - } - if ( !isset($this->options['col_color']) || strlen(trim($this->options['col_color'])) == 0 ) { - $this->options['col_color'] = '#bfbfbf'; - } - if ( !isset($this->options['custom_section_content']) || strlen(trim($this->options['custom_section_content'])) == 0 ) { - $this->options['custom_section_content'] = ''; - } - if ( !isset($this->options['custom_section_line_height']) || strlen(trim($this->options['custom_section_line_height'])) == 0 ) { - $this->options['custom_section_line_height'] = '1'; - } - if ( !isset($this->options['custom_section_font_size']) || strlen(trim($this->options['custom_section_font_size'])) == 0 ) { - $this->options['custom_section_font_size'] = '9'; - } - if ( !isset($this->options['pagenumbering_font_size']) || strlen(trim($this->options['pagenumbering_font_size'])) == 0 ) { - $this->options['pagenumbering_font_size'] = '9'; - } - if ( !isset($this->options['used_format_1']) || strlen(trim($this->options['used_format_1'])) == 0 ) { - $this->options['used_format_1'] = ''; - } - if ( !isset($this->options['used_format_2']) || strlen(trim($this->options['used_format_2'])) == 0 ) { - $this->options['used_format_2'] = ''; - } - if ( !isset($this->options['include_meeting_email']) || strlen(trim($this->options['include_meeting_email'])) == 0 ) { - $this->options['include_meeting_email'] = 0; - } - if ( !isset($this->options['base_font']) || strlen(trim($this->options['base_font'])) == 0 ) { - $this->options['base_font'] = 'dejavusanscondensed'; - } - if ( !isset($this->options['recurse_service_bodies']) || strlen(trim($this->options['recurse_service_bodies'])) == 0) { - $this->options['recurse_service_bodies'] = 1; - } - if ( !isset($this->options['retrieve_all_fields']) || strlen(trim($this->options['retrieve_all_fields'])) == 0) { - $this->options['retrieve_all_fields'] = 0; - } - if ( !isset($this->options['extra_meetings_enabled']) || strlen(trim($this->options['extra_meetings_enabled'])) == 0) { - $this->options['extra_meetings_enabled'] = 0; - } - if ( !isset($this->options['include_protection']) || strlen(trim($this->options['include_protection'])) == 0 ) { - $this->options['include_protection'] = 0; - } - if ( !isset($this->options['weekday_language']) || strlen(trim($this->options['weekday_language'])) == 0 ) { - $this->options['weekday_language'] = 'en'; - } - if ( !isset($this->options['weekday_start']) || strlen(trim($this->options['weekday_start'])) == 0 ) { - $this->options['weekday_start'] = '1'; - } - if ( !isset($this->options['include_asm']) || strlen(trim($this->options['include_asm'])) == 0 ) { - $this->options['include_asm'] = '0'; - } - if ( !isset($this->options['asm_format_key']) || strlen(trim($this->options['asm_format_key'])) == 0 ) { - $this->options['asm_format_key'] = 'ASM'; - } - if ( !isset($this->options['asm_sort_order']) || strlen(trim($this->options['asm_sort_order'])) == 0 ) { - $this->options['asm_sort_order'] = 'name'; - } - if ( !isset($this->options['bmlt_login_id']) || strlen(trim($this->options['bmlt_login_id'])) == 0 ) { - $this->options['bmlt_login_id'] = ''; + function fillUnsetOption($option, $default) { + if ( !isset($this->options[$option]) || strlen(trim($this->options[$option])) == 0 ) { + $this->options[$option] = $default; } - if ( !isset($this->options['bmlt_login_password']) || strlen(trim($this->options['bmlt_login_password'])) == 0 ) { - $this->options['bmlt_login_password'] = ''; - } - if ( !isset($this->options['protection_password']) || strlen(trim($this->options['protection_password'])) == 0 ) { - $this->options['protection_password'] = ''; - } - if ( !isset($this->options['custom_query']) || strlen(trim($this->options['custom_query'])) == 0 ) { - $this->options['custom_query'] = ''; + } + function fillUnsetStringOption($option, $default) { + if ( !isset($this->options[$option]) ) { + $this->options[$option] = $default; } - if ( !isset($this->options['cache_time']) || strlen(trim($this->options['cache_time'])) == 0 ) { - $this->options['cache_time'] = 0; - } - if ( !isset($this->options['extra_meetings']) || $this->options['extra_meetings'] == '' || count($this->options['extra_meetings']) == 0 ) { - $this->options['extra_meetings'] = ''; - } else { + } + function fillUnsetOptions() { + $this->fillUnsetOption('front_page_line_height', '1.0'); + $this->fillUnsetOption('front_page_font_size', '10'); + $this->fillUnsetOption('last_page_font_size', '10'); + $this->fillUnsetOption('content_font_size', '9'); + $this->fillUnsetOption('header_font_size', $this->options['content_font_size']); + $this->fillUnsetOption('pageheader_fontsize', $this->options['header_font_size']); + $this->fillUnsetOption('suppress_heading', 0); + $this->fillUnsetOption('header_text_color', '#ffffff'); + $this->fillUnsetOption('header_background_color', '#000000'); + $this->fillUnsetOption('pageheader_textcolor', '#000000'); + $this->fillUnsetOption('pageheader_backgroundcolor', '#ffffff'); + $this->fillUnsetOption('header_uppercase', '0'); + $this->fillUnsetOption('header_bold', '1'); + $this->fillUnsetOption('sub_header_shown', '0'); + $this->fillUnsetOption('margin_top', 3); + $this->fillUnsetOption('margin_bottom', 3); + $this->fillUnsetOption('margin_left', 3); + $this->fillUnsetOption('margin_right', 3); + $this->fillUnsetOption('column_gap', "5"); + $this->fillUnsetOption('content_line_height', '1.0'); + $this->fillUnsetOption('last_page_line_height', '1.0'); + $this->fillUnsetOption('page_size', 'legal'); + $this->fillUnsetOption('page_orientation', 'L'); + $this->fillUnsetOption('page_fold', 'quad'); + $this->fillUnsetOption('meeting_sort', 'day'); + $this->fillUnsetStringOption('booklet_pages', false); + $this->fillUnsetStringOption('borough_suffix', 'Borough'); + $this->fillUnsetStringOption('county_suffix', 'County'); + $this->fillUnsetStringOption('neighborhood_suffix', 'Neighborhood'); + $this->fillUnsetStringOption('city_suffix', 'City'); + $this->fillUnsetStringOption('meeting_template_content',''); + $this->fillUnsetStringOption('asm_template_content',''); + $this->fillUnsetOption('column_line', 0); + $this->fillUnsetOption('col_color', '#bfbfbf'); + $this->fillUnsetStringOption('custom_section_content', ''); + $this->fillUnsetOption('custom_section_line_height', '1'); + $this->fillUnsetOption('custom_section_font_size', '9'); + $this->fillUnsetOption('pagenumbering_font_size', '9'); + $this->fillUnsetStringOption('used_format_1', ''); + $this->fillUnsetOption('include_meeting_email', 0); + $this->fillUnsetOption('base_font', 'dejavusanscondensed'); + $this->fillUnsetOption('colorspace', 0); + $this->fillUnsetOption('recurse_service_bodies', 1); + $this->fillUnsetOption('retrieve_all_fields', 0); + $this->fillUnsetOption('extra_meetings_enabled', 0); + $this->fillUnsetOption('include_protection', 0); + $this->fillUnsetOption('weekday_language', 'en'); + $this->fillUnsetStringOption('asm_language', ''); // same as main language + $this->fillUnsetOption('weekday_start', '1'); + $this->fillUnsetOption('include_asm', '0'); + $this->fillUnsetOption('asm_format_key', 'ASM'); + $this->fillUnsetOption('asm_sort_order', 'name'); + $this->fillUnsetStringOption('bmlt_login_id', ''); + $this->fillUnsetStringOption('bmlt_login_password', ''); + $this->fillUnsetStringOption('protection_password', ''); + $this->fillUnsetStringOption('custom_query',''); + $this->fillUnsetOption('cache_time', 0); + $this->fillUnsetStringOption('extra_meetings', ''); + if (strlen($this->options[extra_meetings])>0) { $this->options['extra_meetings_enabled'] = 1; + }else{ + $this->options['extra_meetings_enabled'] = 0; } if ( !isset($this->options['asm_logged_in']) ) { if (strlen ($this->options['bmlt_login_password']) > 0 && strlen ($this->options['bmlt_login_password']) > 0) { @@ -2432,11 +2130,11 @@ function pwsix_process_settings_export() { if( ! current_user_can( 'manage_bread' ) ) // TODO: Is this necessary? Why not let the user make a copy return; - $blogname = str_replace(" - ", " ", get_option('blogname')); + $blogname = str_replace(" - ", " ", get_option('blogname').'-'.$this->allSettings[$this->loaded_setting]); $blogname = str_replace(" ", "-", $blogname); $date = date("m-d-Y"); $blogname = trim(preg_replace('/[^a-z0-9]+/', '-', strtolower($blogname)), '-'); - $json_name = $blogname."-meeting-list-settings-".$date.".json"; // Naming the filename will be generated. + $json_name = $blogname.$date.".json"; // Naming the filename will be generated. $settings = get_option( $this->optionsName ); foreach ($settings as $key => $value) { @@ -2580,6 +2278,7 @@ function getMLOptions($current_setting) { } $this->options = $theOptions; $this->fillUnsetOptions(); + $this->upgrade_settings(); $this->authors_safe = $theOptions['authors']; $this->loaded_setting = $current_setting; } @@ -2609,19 +2308,6 @@ function save_admin_options(){ update_option($this->optionsName, $this->options); return; } - - public function uniqueFormat(&$array_of_formats, $subkey) { - $lastFormat = ""; - for ( $i = 0; $i < count( $array_of_formats ); $i++ ) { - if ( strtoupper($lastFormat) == strtoupper($array_of_formats[$i][$subkey]) ) { - array_splice($array_of_formats, $i, 1); - $i--; - } else { - $lastFormat = $array_of_formats[$i][$subkey]; - } - } - } - public function getLatestRootVersion() { $results = $this->get("https://api.github.com/repos/bmlt-enabled/bmlt-root-server/releases/latest"); $httpcode = wp_remote_retrieve_response_code( $results ); @@ -2638,5 +2324,4 @@ public function getLatestRootVersion() { //instantiate the class if (class_exists("Bread")) { $BMLTMeetinglist_instance = new Bread(); -} -?> \ No newline at end of file +} \ No newline at end of file diff --git a/composer.json b/composer.json index 58f482c..1731508 100644 --- a/composer.json +++ b/composer.json @@ -3,6 +3,10 @@ { "type": "git", "url": "https://github.com/mpdf/mpdf" + }, + { + "type": "git", + "url": "https://github.com/myclabs/DeepCopy" } ], "require": { diff --git a/composer.lock b/composer.lock index 7ddc73e..d6fc313 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "2ac4b49bb34d290ac490bbd36c3deaf7", + "content-hash": "8a64634ef088784292ca6a383147a1a8", "packages": [ { "name": "mpdf/mpdf", @@ -88,17 +88,11 @@ }, { "name": "myclabs/deep-copy", - "version": "1.9.1", + "version": "1.9.3", "source": { "type": "git", - "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "e6828efaba2c9b79f4499dae1d66ef8bfa7b2b72" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/e6828efaba2c9b79f4499dae1d66ef8bfa7b2b72", - "reference": "e6828efaba2c9b79f4499dae1d66ef8bfa7b2b72", - "shasum": "" + "url": "https://github.com/myclabs/DeepCopy", + "reference": "007c053ae6f31bba39dfa19a7726f56e9763bbea" }, "require": { "php": "^7.1" @@ -120,7 +114,12 @@ "src/DeepCopy/deep_copy.php" ] }, - "notification-url": "https://packagist.org/downloads/", + "autoload-dev": { + "psr-4": { + "DeepCopy\\": "fixtures/", + "DeepCopyTest\\": "tests/DeepCopyTest/" + } + }, "license": [ "MIT" ], @@ -132,7 +131,7 @@ "object", "object graph" ], - "time": "2019-04-07T13:18:21+00:00" + "time": "2019-08-09T12:45:53+00:00" }, { "name": "paragonie/random_compat", diff --git a/includes/booklet_settings.json b/includes/booklet_settings.json index cad55ed..8e501b3 100644 --- a/includes/booklet_settings.json +++ b/includes/booklet_settings.json @@ -1 +1 @@ -{"root_server":"","service_body_1":"","service_body_2":"Not Used","service_body_3":"Not Used","header_font_size":9.5,"area_service_meetings":null,"helplines":null,"helplines_line_height":null,"front_page_content":"