Skip to content

Commit

Permalink
added the ability to adjust the start day of the week #55
Browse files Browse the repository at this point in the history
  • Loading branch information
dgershman committed Jan 3, 2019
1 parent 063dac4 commit b7329a9
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 25 deletions.
20 changes: 17 additions & 3 deletions bmlt-meeting-list.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,17 @@ function my_theme_add_editor_styles() {
}
}

function getday( $day, $abbreviate = false, $language = '' ) {

function getday( $day, $abbreviate = false, $language = '', $listing = false) {
if (!$listing) {
$adjusted_day = isset($this->options['weekday_start']) ? intval($this->options['weekday_start']) + $day - 1 : 1;

if ($adjusted_day > 7) {
$day = $adjusted_day - 7;
} else {
$day = $adjusted_day;
}
}

$data = '';
if ( $day == 1 ) {
if ( $language == 'en' || $language == 'en' ) {
Expand Down Expand Up @@ -556,6 +565,7 @@ function bmlt_meeting_list($atts = null, $content = null) {
if ( !isset($this->options['include_protection']) ) {$this->options['include_protection'] = 0;}
if ( !isset($this->options['base_font']) ) {$this->options['base_font'] = 'dejavusanscondensed';}
if ( !isset($this->options['weekday_language']) ) {$this->options['weekday_language'] = 'en';}
if ( !isset($this->options['weekday_start']) ) {$this->options['weekday_start'] = '1';}
if ( !isset($this->options['include_asm']) ) {$this->options['include_asm'] = '0';}
if ( !isset($this->options['header_uppercase']) ) {$this->options['header_uppercase'] = '0';}
if ( !isset($this->options['header_bold']) ) {$this->options['header_bold'] = '1';}
Expand Down Expand Up @@ -1701,6 +1711,7 @@ function admin_options_page() {
$this->options['extra_meetings_enabled'] = intval($_POST['extra_meetings_enabled']);
$this->options['include_protection'] = boolval($_POST['include_protection']);
$this->options['weekday_language'] = sanitize_text_field($_POST['weekday_language']);
$this->options['weekday_start'] = sanitize_text_field($_POST['weekday_start']);
$this->options['include_asm'] = boolval($_POST['include_asm']);
$this->options['bmlt_login_id'] = sanitize_text_field($_POST['bmlt_login_id']);
$this->options['bmlt_login_password'] = sanitize_text_field($_POST['bmlt_login_password']);
Expand Down Expand Up @@ -1870,7 +1881,10 @@ function admin_options_page() {
}
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';
}
Expand Down
6 changes: 5 additions & 1 deletion js/bmlt_meeting_list.js
Original file line number Diff line number Diff line change
Expand Up @@ -364,8 +364,10 @@ var $ml = jQuery.noConflict
var meeting_sort_val = $ml("#meeting_sort").val();
if (meeting_sort_val === 'day' || meeting_sort_val === 'weekday_area' || meeting_sort_val === 'weekday_city' || meeting_sort_val === 'weekday_county') {
$ml('.weekday_language_div').show();
$ml('.weekday_start_div').show();
} else {
$ml('.weekday_language_div').hide();
$ml('.weekday_start_div').hide();
}
$ml('.borough_by_suffix').hide();
$ml('.county_by_suffix').hide();
Expand All @@ -390,9 +392,11 @@ var $ml = jQuery.noConflict
$ml('.neighborhood_by_suffix').hide();
$ml('.city_by_suffix').hide();
if (meeting_sort_val === 'day' || meeting_sort_val === 'weekday_area' || meeting_sort_val === 'weekday_city' || meeting_sort_val === 'weekday_county') {
$ml('.weekday_language_div').show();
$ml('.weekday_language_div').show()
$ml('.weekday_start_div').show();
} else {
$ml('.weekday_language_div').hide();
$ml('.weekday_start_div').hide();
}
if (meeting_sort_val === 'borough_county') {
$ml('.borough_by_suffix').show();
Expand Down
57 changes: 36 additions & 21 deletions partials/_meetings_setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,31 +96,46 @@

</p>
</div>
<?php
$languages = [
"en" => "English",
"fr" => "French",
"po" => "Portuguese",
"both" => "English/Spanish",
"both_po" => "English/Spanish/Portuguese",
"fr_en" => "French/English",
"se" => "Swedish"
];
?>
<div class="weekday_language_div">
<label for="weekday_language">Weekday Language: </label>
<select name="weekday_language">
<?php
foreach ($languages as $key => $value) {
if ($this->options['weekday_language'] == $key || $this->options['weekday_language'] == '' ) {
echo "<option value=\"$key\" selected=\"selected\">$value</option>";
} else {
echo "<option value=\"$key\">$value</option>";
}
}
?>
</select>
</div>

<div class="weekday_language_div" style="display: inline;">
<label for="weekday_language">Weekday Language: </label>
<select name="weekday_language">
<div class="weekday_start_div">
<label for="weekday_start">Weekday Start: </label>
<select name="weekday_start">
<?php
$languages = [
"en" => "English",
"fr" => "French",
"po" => "Portuguese",
"both" => "English/Spanish",
"both_po" => "English/Spanish/Portuguese",
"fr_en" => "French/English",
"se" => "Swedish"
];

foreach ($languages as $key => $value) {
if ($this->options['weekday_language'] == $key || $this->options['weekday_language'] == '' ) {
echo "<option value=\"$key\" selected=\"selected\">$value</option>";
} else {
echo "<option value=\"$key\">$value</option>";
}
for ($d = 1; $d <= 7; $d++) {
if ($this->options['weekday_start'] == $d || $this->options['weekday_start'] == '' ) {
echo "<option value=\"$d\" selected=\"selected\">" . $this->getday($d, false, $this->options['weekday_language'], true) . "</option>";
} else {
echo "<option value=\"$d\">" . $this->getday($d, false, $this->options['weekday_language'], true) . "</option>";
}
}
?>
</select>
</div>
</select>
</div>
<p>
</div>
</div>
Expand Down
1 change: 1 addition & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ Follow all these steps, keep in mind that once you start using bread, it's not g
== Changelog ==

= 1.9.0 =
* Added a feature to change the start day of the week [#55]
* Support for Swedish, better language support overall [#54]
* Only allow Administrator role to see the plugin (specifically manage_options permission flag) [#53]

Expand Down

0 comments on commit b7329a9

Please sign in to comment.