/** * prints the sorting and filtering forms * * @param string $mode determines whether to print filter, sort, both or * none of the two functions */ private static function _sort_filter_forms() { global $post; ?> <div class="pdb-searchform"> <form method="post" id="sort_filter_form" > <input type="hidden" name="action" value="sort"> <table class="form-table"><tbody><tr><td> <fieldset class="widefat inline-controls"> <legend><?php _e('Show only records with', 'participants-database'); ?> :</legend> <?php //build the list of columns available for filtering $filter_columns = array(); foreach (Participants_db::get_column_atts('backend') as $column) { if (in_array($column->name, array('id', 'private_id'))) { continue; } $filter_columns[$column->title] = $column->name; } // alphabetize the dropdown asort($filter_columns); $element = array('type' => 'dropdown', 'name' => 'search_field', 'value' => self::$filter['search_field'], 'options' => array('(' . __('show all', 'participants-database') . ')' => 'none') + $filter_columns); PDb_FormElement::print_element($element); ?> that <?php $element = array('type' => 'dropdown', 'name' => 'operator', 'value' => self::$filter['operator'], 'options' => array('null_select' => false, __('is', 'participants-database') => '=', __('is not', 'participants-database') => '!=', __('contains', 'participants-database') => 'LIKE', __('doesn't contain', 'participants-database') => 'NOT LIKE', __('is greater than', 'participants-database') => 'gt', __('is less than', 'participants-database') => 'lt')); PDb_FormElement::print_element($element); ?> <input id="participant_search_term" type="text" name="value" value="<?php echo @self::$filter['value']; ?> "> <input class="button button-default" name="submit-button" type="submit" value="<?php echo self::$i18n['filter']; ?> "> <input class="button button-default" name="submit-button" type="submit" value="<?php echo self::$i18n['clear']; ?> "> </fieldset> </td></tr><tr><td> <fieldset class="widefat inline-controls"> <legend><?php _e('Sort by', 'participants-database'); ?> :</legend> <?php $element = array('type' => 'dropdown', 'name' => 'sortBy', 'value' => self::$filter['sortBy'], 'options' => self::$sortables); PDb_FormElement::print_element($element); $element = array('type' => 'radio', 'name' => 'ascdesc', 'value' => self::$filter['ascdesc'], 'options' => array(__('Ascending', 'participants-database') => 'asc', __('Descending', 'participants-database') => 'desc')); PDb_FormElement::print_element($element); ?> <input class="button button-default" name="submit-button" type="submit" value="<?php echo self::$i18n['sort']; ?> "> </fieldset> </td></tr></tbody></table> </form> </div><?php }
<?php if (is_object(Participants_Db::$validation_errors)) { echo Participants_Db::$validation_errors->get_error_html(); } else { Participants_Db::admin_message(); } ?> <form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?> " enctype="multipart/form-data" autocomplete="off" > <?php PDb_FormElement::print_hidden_fields($hidden); // get the columns and output form $readonly_columns = Participants_Db::get_readonly(); foreach (Participants_db::get_column_atts('backend') as $column) { $id_line = ''; $attributes = array(); // set a new section if ($column->group != $section) { if (!empty($section)) { ?> </table> <?php } else { $id_line = '<tr><th>' . _x('ID', 'abbreviation for "identification"', 'participants-database') . '</th><td>' . (false === $participant_id ? _x('(new record)', 'indicates a new record is being entered', 'participants-database') : $participant_id) . '</td></tr>'; } $section = $column->group; ?> <h3 class="field-group-title"><?php echo $groups[$section]['title'];
/** * prints the sorting and filtering forms * * @param string $mode determines whether to print filter, sort, both or * none of the two functions */ private static function _sort_filter_forms() { global $post; $filter_count = intval(self::$filter['list_filter_count']); //build the list of columns available for filtering $filter_columns = array(); foreach (Participants_db::get_column_atts('backend') as $column) { // add the field name if a field with the same title is already in the list $title = Participants_Db::set_filter('translate_string', $column->title); $select_title = isset($filter_columns[$column->title]) || strlen($column->title) === 0 ? $title . ' (' . $column->name . ')' : $title; $filter_columns[$select_title] = $column->name; } $record_id_field = Participants_Db::$fields['id']; $filter_columns += array(Participants_Db::set_filter('translate_string', $record_id_field->title) => 'id'); ?> <div class="pdb-searchform"> <form method="post" id="sort_filter_form" action="<?php echo self::prepare_page_link($_SERVER['REQUEST_URI']); ?> " > <input type="hidden" name="action" value="admin_list_filter"> <table class="form-table"> <tbody><tr><td> <?php for ($i = 0; $i <= $filter_count - 1; $i++) { $filter_set = self::get_filter_set($i); ?> <fieldset class="widefat inline-controls"> <?php if ($i === 0) { ?> <legend><?php _e('Show only records with', 'participants-database'); ?> :</legend> <?php } $element = array('type' => 'dropdown', 'name' => 'search_field[' . $i . ']', 'value' => $filter_set['search_field'], 'options' => array('' => 'none') + $filter_columns); PDb_FormElement::print_element($element); _ex('that', 'joins two search terms, such as in "Show only records with last name that is Smith"', 'participants-database'); $element = array('type' => 'dropdown', 'name' => 'operator[' . $i . ']', 'value' => $filter_set['operator'], 'options' => array('null_select' => false, __('is', 'participants-database') => '=', __('is not', 'participants-database') => '!=', __('contains', 'participants-database') => 'LIKE', __('doesn't contain', 'participants-database') => 'NOT LIKE', __('is greater than', 'participants-database') => 'gt', __('is less than', 'participants-database') => 'lt')); PDb_FormElement::print_element($element); ?> <input id="participant_search_term_<?php echo $i; ?> " type="text" name="value[<?php echo $i; ?> ]" value="<?php echo htmlspecialchars(esc_attr($filter_set['value'])); ?> "> <?php if ($i < $filter_count - 1) { echo '<br />'; $element = array('type' => 'radio', 'name' => 'logic[' . $i . ']', 'value' => $filter_set['logic'], 'options' => array(__('and', 'participants-database') => 'AND', __('or', 'participants-database') => 'OR')); } else { $element = array('type' => 'hidden', 'name' => 'logic[' . $i . ']', 'value' => $filter_set['logic']); } PDb_FormElement::print_element($element); ?> </fieldset> <?php } ?> <fieldset class="widefat inline-controls"> <input class="button button-default" name="submit-button" type="submit" value="<?php echo self::$i18n['filter']; ?> "> <input class="button button-default" name="submit-button" type="submit" value="<?php echo self::$i18n['clear']; ?> "> <div class="widefat inline-controls filter-count"> <label for="list_filter_count"><?php _e('Number of filters to use: ', 'participants-database'); ?> <input id="list_filter_count" name="list_filter_count" class="number-entry single-digit" type="number" max="5" min="1" value="<?php echo $filter_count; ?> " /></label> </div> </fieldset> </td></tr><tr><td> <fieldset class="widefat inline-controls"> <legend><?php _e('Sort by', 'participants-database'); ?> :</legend> <?php $element = array('type' => 'dropdown', 'name' => 'sortBy', 'value' => self::$filter['sortBy'], 'options' => self::$sortables); PDb_FormElement::print_element($element); $element = array('type' => 'radio', 'name' => 'ascdesc', 'value' => strtolower(self::$filter['ascdesc']), 'options' => array(__('Ascending', 'participants-database') => 'asc', __('Descending', 'participants-database') => 'desc')); PDb_FormElement::print_element($element); ?> <input class="button button-default" name="submit-button" type="submit" value="<?php echo self::$i18n['sort']; ?> "> </fieldset> </td></tr></tbody></table> </form> </div> <h3><?php printf(_n('%s record found, sorted by: %s.', '%s records found, sorted by: %s.', self::$num_records, 'participants-database'), self::$num_records, Participants_Db::column_title(self::$filter['sortBy'])); ?> </h3> <?php }