Skip to content

Commit

Permalink
Add extended fields as possible headings
Browse files Browse the repository at this point in the history
  • Loading branch information
Ron Barack committed Oct 4, 2019
1 parent 8e60367 commit 21b6e12
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 30 deletions.
31 changes: 20 additions & 11 deletions bmlt-meeting-list.php
Original file line number Diff line number Diff line change
Expand Up @@ -388,21 +388,25 @@ function get_fieldkeys() {
$results = $this->get_configured_root_server_request("client_interface/json/?switcher=GetFieldKeys");
return json_decode(wp_remote_retrieve_body($results), true);
}
var $standard_keys = array(
"id_bigint","worldid_mixed","service_body_bigint",
"weekday_tinyint","start_time","duration_time","formats",
"lang_enum","longitude","latitude","meeting_name"."location_text",
"location_info","location_street","location_city_subsection",
"location_neighborhood","location_municipality","location_sub_province",
"location_province","location_postal_code_1","location_nation","comments","zone");
function get_nonstandard_fieldkeys() {
$all_fks = $this->get_fieldkeys();
$standard_keys = array(
"id_bigint","worldid_mixed","service_body_bigint",
"weekday_tinyint","start_time","duration_time","formats",
"lang_enum","longitude","latitude","meeting_name"."location_text",
"location_info","location_street","location_city_subsection",
"location_neighborhood","location_municipality","location_sub_province",
"location_province","location_postal_code_1","location_nation","comments","zone");
$ret = array();
foreach ($all_fks as $fk) {
if (!in_array($fk['key'],$standard_keys)) {
if (!in_array($fk['key'],$this->standard_keys)) {
$ret[] = $fk;
}
}
$ext_fields = apply_filters("Bread_Enrich_Meeting_Data", array(), array());
foreach ($ext_fields as $key=>$value) {
$ret[] = array("key" => $key, "description" => $key);
}
return $ret;
}
function get_areas() {
Expand Down Expand Up @@ -1022,7 +1026,7 @@ function bmlt_meeting_list($atts = null, $content = null) {
asort($unique_subheading, SORT_NATURAL | SORT_FLAG_CASE);
foreach ($unique_subheading as $this_subheading_raw) {
$newSubHeading = true;
$this_subheading = $this->remove_sort_key($this_heading_raw);
$this_subheading = $this->remove_sort_key($this_subheading_raw);
foreach ($headerMeetings[$this_heading_raw][$this_subheading_raw] as $meeting_value) {
$header = '';
if ( !empty($this->options['combine_headings'])) {
Expand Down Expand Up @@ -1270,13 +1274,13 @@ function getHeaderItem($value,$name) {
if ($day < $off) $day = $day + 7;
return '['.str_pad($day, 2, '0', STR_PAD_LEFT).']'.$value['day'];
} elseif (isset($value[$this->options[$name]])) {
$header1 = $value[$this->options[$name]];
$header1 = $this->parse_field($value[$this->options[$name]]);
}
$alt = '';
if ($header1==''
&& !empty($this->options[$name.'_alt'])
&& isset($value[$this->options[$name.'_alt']])) {
$header1 = $value[$this->options[$name.'_alt']];
$header1 = $this->parse_field($value[$this->options[$name.'_alt']]);
$alt = '_alt';
}
if (strlen(trim($header1))==0) {
Expand All @@ -1288,6 +1292,9 @@ function getHeaderItem($value,$name) {
return $header1;
}
function upgradeHeaderData() {
if ($this->options['meeting_sort'] === 'user_defined') {
return;
}
if ( $this->options['meeting_sort'] === 'state' ) {
$this->options['header1'] = 'location_province';
$this->options['header2'] = 'location_municipality';
Expand Down Expand Up @@ -1832,6 +1839,8 @@ function admin_options_page() {
$this->options['page_fold'] = sanitize_text_field($_POST['page_fold']);
$this->options['booklet_pages'] = boolval($_POST['booklet_pages']);
$this->options['meeting_sort'] = sanitize_text_field($_POST['meeting_sort']);
$this->options['header1'] = sanitize_text_field($_POST['header1']);
$this->options['header2'] = sanitize_text_field($_POST['header2']);
$this->options['borough_suffix'] = sanitize_text_field($_POST['borough_suffix']);
$this->options['county_suffix'] = sanitize_text_field($_POST['county_suffix']);
$this->options['neighborhood_suffix'] = sanitize_text_field($_POST['neighborhood_suffix']);
Expand Down
38 changes: 19 additions & 19 deletions partials/_meetings_setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,38 +102,38 @@
</div>
<div class="user_defined_headings">
<p>
<label for="heading1">Main Grouping: </label>
<select id="heading1" name="heading1">
<option <?php echo ($this->options['heading1'] == 'day' ? 'selected="selected"' : '') ?> value="day">Weekday</option>
<option <?php echo ($this->options['heading1'] == 'city' ? 'selected="selected"' : '') ?> value="city">City</option>
<option <?php echo ($this->options['heading1'] == 'group' ? 'selected="selected"' : '') ?> value="group">Group</option>
<option <?php echo ($this->options['heading1'] == 'county' ? 'selected="selected"' : '') ?> value="county">County</option>
<option <?php echo ($this->options['heading1'] == 'borough' ? 'selected="selected"' : '') ?> value="borough">Borough</option>
<option <?php echo ($this->options['heading1'] == 'state' ? 'selected="selected"' : '') ?> value="state">State</option>
<label for="header1">Main Grouping: </label>
<select id="header1" name="header1">
<option <?php echo ($this->options['header1'] == 'day' ? 'selected="selected"' : '') ?> value="day">Weekday</option>
<option <?php echo ($this->options['header1'] == 'city' ? 'selected="selected"' : '') ?> value="city">City</option>
<option <?php echo ($this->options['header1'] == 'group' ? 'selected="selected"' : '') ?> value="group">Group</option>
<option <?php echo ($this->options['header1'] == 'county' ? 'selected="selected"' : '') ?> value="county">County</option>
<option <?php echo ($this->options['header1'] == 'borough' ? 'selected="selected"' : '') ?> value="borough">Borough</option>
<option <?php echo ($this->options['header1'] == 'state' ? 'selected="selected"' : '') ?> value="state">State</option>
<?php
$fks = $this->get_nonstandard_fieldkeys();
foreach ($fks as $fk) {
$selected = '';
if ($fk['key']==$this->options['heading1']) {
if ($fk['key']==$this->options['header1']) {
$selected = ' selected="selected"';
}
echo '<option value="'.$fk['key'].'" '.$selected.'>'.$fk['description'].'</option>';
}
?>
</select>
<label for="heading2">Sub-Grouping: </label>
<select id="heading2" name="heading2">
<option <?php echo (empty($this->options['heading2']) ? 'selected="selected"' : '') ?> value="">None</option>
<option <?php echo ($this->options['heading2'] == 'day' ? 'selected="selected"' : '') ?> value="day">Weekday</option>
<option <?php echo ($this->options['heading2'] == 'city' ? 'selected="selected"' : '') ?> value="city">City</option>
<option <?php echo ($this->options['heading2'] == 'group' ? 'selected="selected"' : '') ?> value="group">Group</option>
<option <?php echo ($this->options['heading2'] == 'county' ? 'selected="selected"' : '') ?> value="county">County</option>
<option <?php echo ($this->options['heading2'] == 'borough' ? 'selected="selected"' : '') ?> value="borough">Borough</option>
<option <?php echo ($this->options['heading2'] == 'state' ? 'selected="selected"' : '') ?> value="state">State</option>
<label for="header2">Sub-Grouping: </label>
<select id="header2" name="header2">
<option <?php echo (empty($this->options['header2']) ? 'selected="selected"' : '') ?> value="">None</option>
<option <?php echo ($this->options['header2'] == 'day' ? 'selected="selected"' : '') ?> value="day">Weekday</option>
<option <?php echo ($this->options['header2'] == 'city' ? 'selected="selected"' : '') ?> value="city">City</option>
<option <?php echo ($this->options['header2'] == 'group' ? 'selected="selected"' : '') ?> value="group">Group</option>
<option <?php echo ($this->options['header2'] == 'county' ? 'selected="selected"' : '') ?> value="county">County</option>
<option <?php echo ($this->options['header2'] == 'borough' ? 'selected="selected"' : '') ?> value="borough">Borough</option>
<option <?php echo ($this->options['header2'] == 'state' ? 'selected="selected"' : '') ?> value="state">State</option>
<?php
foreach ($fks as $fk) {
$selected = '';
if ($fk['key']==$this->options['heading2']) {
if ($fk['key']==$this->options['header2']) {
$selected = ' selected="selected"';
}
echo '<option value="'.$fk['key'].'" '.$selected.'>'.$fk['description'].'</option>';
Expand Down

0 comments on commit 21b6e12

Please sign in to comment.