Changeset 2006543
- Timestamp:
- 01/04/2019 09:43:12 PM (7 years ago)
- Location:
- bread/trunk
- Files:
-
- 6 edited
-
Dockerfile (modified) (1 diff)
-
bmlt-meeting-list.php (modified) (27 diffs)
-
contribute.md (modified) (1 diff)
-
js/bmlt_meeting_list.js (modified) (2 diffs)
-
partials/_meetings_setup.php (modified) (1 diff)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
bread/trunk/Dockerfile
r1971708 r2006543 19 19 && echo "xdebug.remote_autostart=1" >> ${PHP_INI_PATH} \ 20 20 && echo "xdebug.remote_log=/tmp/xdebug.log" >> ${PHP_INI_PATH} \ 21 && echo "xdebug.profiler_enable_trigger=1" >> ${PHP_INI_PATH} \ 21 22 && echo "log_errors = On" >> ${PHP_INI_PATH} \ 22 23 && echo "error_reporting = E_ALL" >> ${PHP_INI_PATH} \ -
bread/trunk/bmlt-meeting-list.php
r1971708 r2006543 5 5 Description: Maintains and generates a PDF Meeting List from BMLT. 6 6 Author: odathp, radius314, pjaudiomv, klgrimley 7 Version: 1. 8.07 Version: 1.9.0 8 8 */ 9 9 /* Disallow direct access to the plugin file */ … … 183 183 } 184 184 185 function getday( $day, $abbreviate = false, $language = '' ) { 186 185 function getday( $day, $abbreviate = false, $language = '') { 187 186 $data = ''; 188 187 if ( $day == 1 ) { … … 201 200 } elseif ( $language == 'fr_en' ) { 202 201 $data = ($abbreviate ? 'Dim / Sun' : "Dimanche / Sunday"); 203 } 202 } elseif ( $language == 'se') { 203 $data = ($abbreviate ? "Sön" : "Söndag"); 204 } 204 205 } elseif ( $day == 2 ) { 205 206 if ( $language == 'en' || $language == 'en' ) { … … 217 218 } elseif ( $language == 'fr_en' ) { 218 219 $data = ($abbreviate ? 'Lun / Mon' : "Lundi / Monday"); 219 } 220 } elseif ( $language == 'se') { 221 $data = ($abbreviate ? "Mån" : "Måndag"); 222 } 220 223 } elseif ( $day == 3 ) { 221 224 if ( $language == 'en' || $language == 'en' ) { … … 233 236 } elseif ( $language == 'fr_en' ) { 234 237 $data = ($abbreviate ? 'Mar / Tues' : "Mardi / Tuesday"); 235 } 238 } elseif ( $language == 'se') { 239 $data = ($abbreviate ? "Tis" : "Tisdag"); 240 } 236 241 } elseif ( $day == 4 ) { 237 242 if ( $language == 'en' || $language == 'en' ) { … … 249 254 } elseif ( $language == 'fr_en' ) { 250 255 $data = ($abbreviate ? 'Mer / Wed' : "Mercredi / Wednesday"); 251 } 256 } elseif ( $language == 'se') { 257 $data = ($abbreviate ? "Ons" : "Onsdag"); 258 } 252 259 } elseif ( $day == 5 ) { 253 260 if ( $language == 'en' || $language == 'en' ) { … … 265 272 } elseif ( $language == 'fr_en' ) { 266 273 $data = ($abbreviate ? 'Jeu / Thu' : "Jeudi / Thursday"); 267 } 274 } elseif ( $language == 'se') { 275 $data = ($abbreviate ? "Tors" : "Torsdag"); 276 } 268 277 } elseif ( $day == 6 ) { 269 278 if ( $language == 'en' || $language == 'en' ) { … … 281 290 } elseif ( $language == 'fr_en' ) { 282 291 $data = ($abbreviate ? 'Ven / Fri' : "Vendredi / Friday"); 283 } 292 } elseif ( $language == 'se') { 293 $data = ($abbreviate ? "Fre" : "Fredag"); 294 } 284 295 } elseif ( $day == 7 ) { 285 296 if ( $language == 'en' || $language == 'en' ) { … … 297 308 } elseif ( $language == 'fr_en' ) { 298 309 $data = ($abbreviate ? 'Sam / Sat' : "Samedi / Saturday"); 299 } 310 } elseif ( $language == 'se') { 311 $data = ($abbreviate ? "Lör" : "Lördag"); 312 } 300 313 } 301 314 … … 338 351 } 339 352 340 function get_all_meetings () {353 function get_all_meetings() { 341 354 $results = $this->get_configured_root_server_request("client_interface/json/?switcher=GetSearchResults&data_field_key=weekday_tinyint,start_time,service_body_bigint,id_bigint,meeting_name,location_text,email_contact&sort_keys=meeting_name,service_body_bigint,weekday_tinyint,start_time"); 342 355 $result = json_decode(wp_remote_retrieve_body($results),true); … … 543 556 if ( !isset($this->options['base_font']) ) {$this->options['base_font'] = 'dejavusanscondensed';} 544 557 if ( !isset($this->options['weekday_language']) ) {$this->options['weekday_language'] = 'en';} 558 if ( !isset($this->options['weekday_start']) ) {$this->options['weekday_start'] = '1';} 545 559 if ( !isset($this->options['include_asm']) ) {$this->options['include_asm'] = '0';} 546 560 if ( !isset($this->options['header_uppercase']) ) {$this->options['header_uppercase'] = '0';} … … 747 761 $extra_results = $this->get_configured_root_server_request("client_interface/json/?switcher=GetSearchResults&sort_keys=".$sort_keys."".$extras."".$get_used_formats ); 748 762 $extra_result = json_decode(wp_remote_retrieve_body($extra_results), true); 749 if ( $extra_result <> Null ) {763 if ( $extra_result <> null ) { 750 764 $result_meetings = array_merge($result['meetings'], $extra_result['meetings']); 751 765 foreach ($result_meetings as $key => $row) { … … 765 779 } 766 780 767 if ( $result_meetings == Null ) {781 if ( $result_meetings == null ) { 768 782 echo "<script type='text/javascript'>\n"; 769 783 echo "document.body.innerHTML = ''"; … … 811 825 $unique_data = array(); 812 826 827 $days = array_column($result_meetings, 'weekday_tinyint'); 828 $today_str = $this->options['weekday_start']; 829 $result_meetings = array_merge( 830 array_splice($result_meetings, array_search($today_str, $days)), 831 array_splice($result_meetings, 0) 832 ); 833 813 834 foreach ($result_meetings as $value) { 814 $result_meetings_temp[] = $value;815 835 $unique_states[] = $value['location_province']; 816 836 if ( $this->options['meeting_sort'] === 'state' ) { … … 847 867 } elseif ( $this->options['meeting_sort'] === 'weekday_city' ) { 848 868 $unique_data[] = $value['weekday_tinyint'] . ',' . $value['location_municipality']; 849 } elseif ( $this->options['meeting_sort'] === 'weekday_county' ) {869 } elseif ( $this->options['meeting_sort'] === 'weekday_county' ) { 850 870 $unique_data[] = $value['weekday_tinyint'] . ',' . $value['location_sub_province']; 851 871 } else { … … 855 875 856 876 $unique_states = array_unique($unique_states); 857 asort($unique_data, SORT_NATURAL | SORT_FLAG_CASE); 877 if (strpos($this->options['meeting_sort'], "weekday") === false && strpos($this->options['meeting_sort'], "day") === false) { 878 asort($unique_data, SORT_NATURAL | SORT_FLAG_CASE); 879 } 880 858 881 $unique_data = array_unique($unique_data); 859 882 if ( $this->options['page_fold'] === 'full' || $this->options['page_fold'] === 'half' ) { … … 902 925 903 926 if ( $this->options['meeting_sort'] === 'weekday_area' || $this->options['meeting_sort'] === 'weekday_city' || $this->options['meeting_sort'] === 'weekday_county' ) { 904 $current_weekday = 1;927 $current_weekday = intval($this->options['weekday_start']); 905 928 $show_first_weekday = true; 906 929 } … … 911 934 if ( $weekday_tinyint !== $current_weekday ) { 912 935 $current_weekday++; 936 if ($current_weekday > 7) { 937 $current_weekday = 1; 938 } 913 939 $show_first_weekday = true; 914 940 } … … 916 942 $newVal = true; 917 943 if ( $this->options['meeting_sort'] === 'state' && strpos($this_unique_value, $this_state) === false ) { continue; } 944 918 945 foreach ($result_meetings as $meeting_value) { 919 946 if ( $this->options['meeting_sort'] === 'weekday_area' || $this->options['meeting_sort'] === 'weekday_city' || $this->options['meeting_sort'] === 'weekday_county' ) { … … 963 990 $header = ''; 964 991 965 if ( $this-> lang == 'fr' ) {992 if ( $this->options['weekday_language'] === 'fr' ) { 966 993 $cont = '(suite)'; 967 } else { 994 } else if ( $this->options['weekday_language'] === 'se' ) { 995 $cont = '(forts)'; 996 } else { 968 997 $cont = '(cont)'; 969 998 } … … 976 1005 977 1006 if ( $this->options['meeting_sort'] === 'borough' ) { 978 979 1007 if ( $this_unique_value == '' ) { 980 981 1008 $this_unique_data = '[NO BOROUGH DATA]'; 982 983 1009 } else { 984 1010 $this_unique_data = $this_unique_value; 985 986 1011 } 987 1012 $header_suffix = $this->options['borough_suffix']; 988 989 1013 } 990 1014 if ( $this->options['meeting_sort'] === 'county' ) { 991 992 1015 if ( $this_unique_value == '' ) { 993 994 1016 $this_unique_data = '[NO COUNTY DATA]'; 995 996 1017 } else { 997 1018 $this_unique_data = $this_unique_value; 998 999 1019 } 1000 1020 $header_suffix = $this->options['county_suffix']; 1001 1002 1021 } 1003 1022 if ( $newVal ) { … … 1032 1051 if ( $newVal ) { 1033 1052 if ( $show_first_weekday === true ) { 1034 if ( $current_weekday === 1) {1053 if ( $current_weekday === $this->options['weekday_start'] ) { 1035 1054 $header .= "<h2 style='".$header_style."'>".$this->getday($meeting_value['weekday_tinyint'], false, $this->options['weekday_language'])."</h2>"; 1036 1055 } else { … … 1106 1125 $space = ''; 1107 1126 } 1108 if ( $this->options['time_clock'] == Null || $this->options['time_clock'] == '12' || $this->options['time_option'] == '' ) {1127 if ( $this->options['time_clock'] == null || $this->options['time_clock'] == '12' || $this->options['time_option'] == '' ) { 1109 1128 $time_format = "g:i".$space."A"; 1110 1129 … … 1446 1465 $this->options['front_page_content'] = mb_convert_encoding($this->options['front_page_content'], 'HTML-ENTITIES'); 1447 1466 $this->mpdf->WriteHTML(utf8_encode(wpautop(stripslashes($this->options['front_page_content'])))); 1448 1467 1449 1468 } 1450 1469 … … 1593 1612 function admin_menu_link() { 1594 1613 global $my_admin_page; 1595 $my_admin_page = add_menu_page( 'Meeting List', 'Meeting List', ' edit_posts', basename(__FILE__), array(&$this, 'admin_options_page'), 'dashicons-admin-page');1614 $my_admin_page = add_menu_page( 'Meeting List', 'Meeting List', 'manage_options', basename(__FILE__), array(&$this, 'admin_options_page'), 'dashicons-admin-page'); 1596 1615 } 1597 1616 … … 1688 1707 $this->options['include_protection'] = boolval($_POST['include_protection']); 1689 1708 $this->options['weekday_language'] = sanitize_text_field($_POST['weekday_language']); 1709 $this->options['weekday_start'] = sanitize_text_field($_POST['weekday_start']); 1690 1710 $this->options['include_asm'] = boolval($_POST['include_asm']); 1691 1711 $this->options['bmlt_login_id'] = sanitize_text_field($_POST['bmlt_login_id']); … … 1857 1877 if ( !isset($this->options['weekday_language']) || strlen(trim($this->options['weekday_language'])) == 0 ) { 1858 1878 $this->options['weekday_language'] = 'en'; 1859 } 1879 } 1880 if ( !isset($this->options['weekday_start']) || strlen(trim($this->options['weekday_start'])) == 0 ) { 1881 $this->options['weekday_start'] = '1'; 1882 } 1860 1883 if ( !isset($this->options['include_asm']) || strlen(trim($this->options['include_asm'])) == 0 ) { 1861 1884 $this->options['include_asm'] = '0'; -
bread/trunk/contribute.md
r1964360 r2006543 14 14 15 15 Now you can make edits to the bmlt-meeting-list.php file and it will instantly take effect. 16 17 To profile a PHP page, include `XDEBUG_PROFILE` as part of the querystring. The result will be in `/tmp/cachegrind.out.???`, the extension being the process ID. 18 19 You can then open this file in IntelliJ, Valgrind, or any other tool that let's you review an Xdebug profiler result. 20 21 If you are using a mac for development and Homebrew, this is a fairly easy way to get going. 22 23 `brew install qcachegrind --with-graphviz` -
bread/trunk/js/bmlt_meeting_list.js
r1964355 r2006543 365 365 if (meeting_sort_val === 'day' || meeting_sort_val === 'weekday_area' || meeting_sort_val === 'weekday_city' || meeting_sort_val === 'weekday_county') { 366 366 $ml('.weekday_language_div').show(); 367 $ml('.weekday_start_div').show(); 367 368 } else { 368 369 $ml('.weekday_language_div').hide(); 370 $ml('.weekday_start_div').hide(); 369 371 } 370 372 $ml('.borough_by_suffix').hide(); … … 391 393 $ml('.city_by_suffix').hide(); 392 394 if (meeting_sort_val === 'day' || meeting_sort_val === 'weekday_area' || meeting_sort_val === 'weekday_city' || meeting_sort_val === 'weekday_county') { 393 $ml('.weekday_language_div').show(); 395 $ml('.weekday_language_div').show() 396 $ml('.weekday_start_div').show(); 394 397 } else { 395 398 $ml('.weekday_language_div').hide(); 399 $ml('.weekday_start_div').hide(); 396 400 } 397 401 if (meeting_sort_val === 'borough_county') { -
bread/trunk/partials/_meetings_setup.php
r1964355 r2006543 97 97 </p> 98 98 </div> 99 100 <div class="weekday_language_div" style="display: inline;"> 101 <label for="weekday_language">Weekday Language: </label> 102 <select name="weekday_language"> 103 <?php if ( $this->options['weekday_language'] == 'en' || $this->options['weekday_language'] == '' ) { ?> 104 <option selected="selected" value="en">English</option> 105 <option value="es">Spanish</option> 106 <option value="fr">French</option> 107 <option value="po">Portuguese</option> 108 <option value="both">English/Spanish</option> 109 <option value="both_po">English/Spanish/Portuguese</option> 110 <option value="fr_en">French/English</option> 111 <?php } elseif ( $this->options['weekday_language'] == 'es' ) { ?> 112 <option selected="selected" value="es">Spanish</option> 113 <option value="en">English</option> 114 <option value="fr">French</option> 115 <option value="po">Portuguese</option> 116 <option value="both">English/Spanish</option> 117 <option value="both_po">English/Spanish/Portuguese</option> 118 <option value="fr_en">French/English</option> 119 <?php } elseif ( $this->options['weekday_language'] == 'both' ) { ?> 120 <option selected="selected" value="both">English/Spanish</option> 121 <option value="en">English</option> 122 <option value="es">Spanish</option> 123 <option value="fr">French</option> 124 <option value="po">Portuguese</option> 125 <option value="both_po">English/Spanish/Portuguese</option> 126 <option value="fr_en">French/English</option> 127 <?php } elseif ( $this->options['weekday_language'] == 'fr' ) { ?> 128 <option selected="selected" value="fr">French</option> 129 <option value="en">English</option> 130 <option value="es">Spanish</option> 131 <option value="po">Portuguese</option> 132 <option value="both">English/Spanish</option> 133 <option value="both_po">English/Spanish/Portuguese</option> 134 <option value="fr_en">French/English</option> 135 <?php } elseif ( $this->options['weekday_language'] == 'po' ) { ?> 136 <option selected="selected" value="po">Portuguese</option> 137 <option value="en">English</option> 138 <option value="es">Spanish</option> 139 <option value="fr">French</option> 140 <option value="both">English/Spanish</option> 141 <option value="both_po">English/Spanish/Portuguese</option> 142 <option value="fr_en">French/English</option> 143 <?php } elseif ( $this->options['weekday_language'] == 'fr_en' ) { ?> 144 <option selected="selected" value="fr_en">French/Engish</option> 145 <option value="en">English</option> 146 <option value="es">Spanish</option> 147 <option value="fr">French</option> 148 <option value="po">Portuguese</option> 149 <option value="both">English/Spanish</option> 150 <option value="both_po">English/Spanish/Portuguese</option> 151 <?php } elseif ( $this->options['weekday_language'] == 'both_po' ) { ?> 152 <option selected="selected" value="both_po">English/Spanish/Portuguese</option> 153 <option value="en">English</option> 154 <option value="es">Spanish</option> 155 <option value="fr">French</option> 156 <option value="po">Portuguese</option> 157 <option value="both">English/Spanish</option> 158 <option value="fr_en">French/English</option> 159 <?php } ?> 160 </select> 161 </div> 99 <?php 100 $languages = [ 101 "en" => "English", 102 "fr" => "French", 103 "po" => "Portuguese", 104 "both" => "English/Spanish", 105 "both_po" => "English/Spanish/Portuguese", 106 "fr_en" => "French/English", 107 "se" => "Swedish" 108 ]; 109 ?> 110 <div class="weekday_language_div"> 111 <label for="weekday_language">Weekday Language: </label> 112 <select name="weekday_language"> 113 <?php 114 foreach ($languages as $key => $value) { 115 if ($this->options['weekday_language'] == $key || $this->options['weekday_language'] == '' ) { 116 echo "<option value=\"$key\" selected=\"selected\">$value</option>"; 117 } else { 118 echo "<option value=\"$key\">$value</option>"; 119 } 120 } 121 ?> 122 </select> 123 </div> 124 125 <div class="weekday_start_div"> 126 <label for="weekday_start">Weekday Start: </label> 127 <select name="weekday_start"> 128 <?php 129 for ($d = 1; $d <= 7; $d++) { 130 if ($this->options['weekday_start'] == $d || $this->options['weekday_start'] == '' ) { 131 echo "<option value=\"$d\" selected=\"selected\">" . $this->getday($d, false, $this->options['weekday_language']) . "</option>"; 132 } else { 133 echo "<option value=\"$d\">" . $this->getday($d, false, $this->options['weekday_language']) . "</option>"; 134 } 135 } 136 ?> 137 </select> 138 </div> 162 139 <p> 163 140 </div> -
bread/trunk/readme.txt
r1971708 r2006543 6 6 Requires PHP: 5.6 7 7 Tested up to: 5.0.0 8 Stable tag: 1. 8.08 Stable tag: 1.9.0 9 9 License: GPLv2 or later 10 10 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 54 54 55 55 == Changelog == 56 57 = 1.9.0 = 58 * Added a feature to change the start day of the week [#55] 59 * Support for Swedish, better language support overall [#54] 60 * Only allow Administrator role to see the plugin (specifically manage_options permission flag) [#53] 56 61 57 62 = 1.8.0 =
Note: See TracChangeset
for help on using the changeset viewer.