18 require_once SQ_PACKAGES_PATH.
'/search/search_page/search_page_edit_fns.inc';
38 parent::__construct();
39 $this->static_screens[
'details'][
'force_unlock'] = 0;
56 $write_access = $asset->writeAccess(
'all');
57 $filters = $asset->attr(
'events_filters');
60 'none' =>
'-- '.ucfirst(translate(
'page_events_search_filter_select_options').
' --'),
61 'single_date' => ucfirst(translate(
'page_events_search_filter_select_options_single_date')),
62 'date_range' => ucfirst(translate(
'page_events_search_filter_select_options_date_range')),
63 'fuzzy_dropdown' => ucfirst(translate(
'page_events_search_filter_select_options_fuzzy_dropdown')),
64 'fuzzy_checkboxes' => ucfirst(translate(
'page_events_search_filter_select_options_fuzzy_checkboxes')),
67 $fuzzy_options = Array();
68 $default_fuzzy_options = Array();
69 foreach($asset->fuzzy_date_types as $fuzzy_opt => $default) {
70 $fuzzy_options[$fuzzy_opt] = ucfirst($fuzzy_opt);
73 $default_fuzzy_options[] = $fuzzy_opt;
78 <table
class ="sq-backend-table" border=
"1" style=
"margin-bottom: 7px">
84 echo
"<th>Delete</th>";
89 $input_box_extra = $write_access ?
'' :
'disabled';
90 foreach ($filters as $filter_name => $filter_data) {
92 echo
"<td>$filter_name</td>";
95 if (isset($filter_data[
'type'])) {
96 echo ucwords(str_replace(
'_',
' ', $filter_data[
'type']));
98 switch($filter_data[
'type']) {
102 check_box($prefix.
'_filters['.$filter_name.
'][use_picker]', 1, array_get_index($filter_data,
'use_picker', TRUE),
'', $input_box_extra);
103 echo
"Include date picker";
106 case 'fuzzy_dropdown':
107 case 'fuzzy_checkboxes':
108 $selected_fuzzy_options = array_get_index($filter_data,
'fuzzy_options', $default_fuzzy_options);
110 combo_box($prefix.
'_filters['.$filter_name.
'][fuzzy_options]', $fuzzy_options, TRUE, $selected_fuzzy_options, 8, $input_box_extra);
116 combo_box($prefix.
'_filters['.$filter_name.
'][type]', $query_types, FALSE,
'none');
123 check_box($prefix.
'_filters['.$filter_name.
'][delete]');
134 label(
"New events date filter", $prefix.
'_new_events_date_filter_name');
136 text_box($prefix.
'_new_events_date_filter_name',
'', 15);
155 $old_filters = $asset->attr(
'events_filters');
157 $new_filters = Array();
159 if (isset($_POST[$prefix.
'_filters'])) {
160 foreach ($_POST[$prefix.
'_filters'] as $filter_name => $filter) {
161 if (!isset($filter[
'delete'])) {
162 $new_filters[$filter_name][
'name'] = $old_filters[$filter_name][
'name'];
164 if (isset($filter[
'type']) && $filter[
'type'] !=
'none') {
165 $new_filters[$filter_name][
'type'] = $filter[
'type'];
166 unset($new_filters[$filter_name][
'fuzzy_options']);
168 if (isset($old_filters[$filter_name][
'type'])) {
169 $new_filters[$filter_name][
'type'] = $old_filters[$filter_name][
'type'];
170 if (isset($filter[
'fuzzy_options'])) {
171 $new_filters[$filter_name][
'fuzzy_options'] = $filter[
'fuzzy_options'];
175 $new_filters[$filter_name][
'use_picker'] = isset($filter[
'use_picker']) ? TRUE : FALSE;
181 if (!empty($_POST[$prefix.
'_new_events_date_filter_name'])) {
182 $safe_name = strtolower(str_replace(
' ',
'_', $_POST[$prefix.
'_new_events_date_filter_name']));
185 if (!isset($old_filters[$safe_name])) {
186 $new_filters[$safe_name][
'name'] = $_POST[$prefix.
'_new_events_date_filter_name'];
187 $new_filters[$safe_name][
'use_picker'] = TRUE;
191 return $asset->setAttrValue(
'events_filters', $new_filters);
213 $wa = $asset->writeAccess(
'attributes');
214 $pmap = $asset->getAttribute(
'stored_query_session');
215 $current_params = $pmap->_params;
217 $fields = $asset->attr(
'fields');
218 foreach ($fields as $fieldname => $fieldvalue) {
219 $current_params[
'parameters'][$fieldname] =
'Search Field: '.$fieldname;
222 $fields = $asset->attr(
'events_filters');
223 foreach ($fields as $fieldname => $fieldvalue) {
224 $current_params[
'parameters'][
'f:'.$fieldname] =
'Date Filter: '.$fieldname;
226 $pmap->_params = $current_params;
228 $pmap->paint($prefix);
230 $pmap->paint($prefix, TRUE);