/** * prints the form open tag and all hidden fields * * The incoming hidden fields are merged with the default fields * * @param array $hidden array of hidden fields to print * @return null */ protected function _print_form_head($hidden = '') { $uri_components = parse_url($_SERVER['REQUEST_URI']); echo '<form method="post" enctype="multipart/form-data" autocomplete="' . $this->shortcode_atts['autocomplete'] . '" action="' . $_SERVER['REQUEST_URI'] . '" >'; $default_hidden_fields = array('action' => $this->module, 'subsource' => Participants_Db::PLUGIN_NAME, 'shortcode_page' => $uri_components['path'] . (isset($uri_components['query']) ? '?' . $uri_components['query'] : ''), 'thanks_page' => $this->submission_page, 'instance_index' => $this->instance_index, 'pdb_data_keys' => $this->_form_data_keys(), 'session_hash' => Participants_Db::nonce(Participants_Db::$main_submission_nonce_key)); if ($this->get_form_status() === 'multipage') { $default_hidden_fields['previous_multipage'] = $default_hidden_fields['shortcode_page']; } $hidden = is_array($hidden) ? $hidden : array(); $hidden_fields = $this->hidden_fields + $hidden + $default_hidden_fields; PDb_FormElement::print_hidden_fields($hidden_fields); }
<form id="manage_field_groups" method="post"> <input type="hidden" name="action" value="<?php echo $PDb_i18n['update groups']; ?> " /> <h3><?php _e('Edit / Add / Remove Field Groups', 'participants-database'); ?> </h3> <p> <?php // "add group" functionality PDb_FormElement::print_element(array('type' => 'submit', 'value' => $PDb_i18n['add group'], 'name' => 'action', 'attributes' => array('class' => 'button button-default', 'onclick' => 'return false;'))); PDb_FormElement::print_element(array('type' => 'text', 'name' => 'group_title', 'value' => $PDb_i18n['new group title'] . '…', 'attributes' => array('onfocus' => "this.value='';jQuery(this).prev('input').removeAttr( 'onclick' )", 'class' => 'add_field'))); $next_order = count($groups) + 1; PDb_FormElement::print_hidden_fields(array('group_order' => $next_order)); ?> </p> <table class="wp-list-table widefat fixed manage-fields manage-field-groups" cellspacing="0" > <thead> <tr> <th scope="col" class="fields vertical-title"><span><?php echo PDb_header(__('fields', 'participants-database')); ?> </span></th> <th scope="col" class="delete vertical-title"><span><?php echo PDb_header(__('delete', 'participants-database')); ?> </span></th> <?php foreach (current($groups) as $column => $value) {
/** * prints a series of hidden fields * * @param array $fields name => value pairs * @param bool $print true to print, false to return */ public static function print_hidden_fields($fields, $print = true) { $hidden_fields = PDb_FormElement::print_hidden_fields($fields, false); if ($print) { echo $hidden_fields; } else { return $hidden_fields; } }
echo $page_title; ?> </h2> <?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;
/** * prints the groups edit tab content * * @global object $wpdb * @return null */ protected function print_group_edit_tab_content() { global $wpdb; ?> <div id="field_groups" class="manage-fields-wrap"> <form id="manage_field_groups" method="post"> <input type="hidden" name="action" value="<?php echo $this->i18n['update groups']; ?> " /> <h3><?php _e('Edit / Add / Remove Field Groups', 'participants-database'); ?> </h3> <p> <?php // "add group" functionality PDb_FormElement::print_element(array('type' => 'submit', 'value' => $this->i18n['add group'], 'name' => 'action', 'attributes' => array('class' => 'button button-default', 'disabled' => 'disabled'))); PDb_FormElement::print_element(array('type' => 'text', 'name' => 'group_title', 'value' => '', 'attributes' => array('placeholder' => $this->i18n['new group title'] . '…', 'class' => 'add_field'))); $next_order = count($this->group_values) + 1; PDb_FormElement::print_hidden_fields(array('group_order' => $next_order)); ?> </p> <table class="wp-list-table widefat fixed manage-fields manage-field-groups" > <thead> <tr> <th scope="col" class="fields vertical-title"><span><?php echo $this->table_header(__('fields', 'participants-database')); ?> </span></th> <th scope="col" class="delete vertical-title"><span><?php echo $this->table_header(__('delete', 'participants-database')); ?> </span></th> <?php foreach (current($this->group_values) as $column => $value) { $column_class = in_array($column, array('order', 'admin', 'display')) ? $column . ' vertical-title' : $column; ?> <th scope="col" class="<?php echo $column_class; ?> "><span><?php echo $this->table_header($column); ?> </span></th> <?php } ?> </tr> </thead> <tbody> <?php foreach ($this->group_values as $group => $group_values) { // if ($group == 'internal') // continue; $group_count = $wpdb->get_var($wpdb->prepare('SELECT COUNT(*) FROM ' . Participants_Db::$fields_table . ' WHERE `group` = "%s"', $group)); ?> <tr> <td id="field_count_<?php echo $group; ?> "><?php echo $group_count; ?> </td> <td><a href="<?php echo $group_count; ?> " data-thing-name="delete_<?php echo $group; ?> " class="delete" data-thing="<?php _e('group', 'participants-database'); ?> "><span class="glyphicon glyphicon-remove"></span></a></td> <?php foreach ($group_values as $column => $value) { $attributes = array(); $options = array(); $name = ''; switch ($column) { case 'display': case 'admin': $attributes = array('style' => 'width:20px'); $type = 'checkbox'; $options = array(1, 0); break; case 'description': $type = 'text-area'; break; case 'order': $attributes = array('style' => 'width:30px'); $name = 'order_' . $group; $type = 'drag-sort'; break; case 'name': $type = 'text'; $attributes = array('readonly' => 'readonly'); default: $type = 'text'; } $element_atts = array('name' => empty($name) ? $group . '[' . $column . ']' : $name, 'value' => htmlspecialchars(stripslashes($value)), 'type' => $type); if (!empty($attributes)) { $element_atts['attributes'] = $attributes; } if (!empty($options)) { $element_atts['options'] = $options; } ?> <td class="<?php echo $column; ?> "><?php PDb_FormElement::print_element($element_atts); ?> </td> <?php } ?> </tr> <?php } ?> </tbody> </table> <p class="submit"> <?php PDb_FormElement::print_element(array('type' => 'submit', 'name' => 'submit-button', 'value' => $this->i18n['update groups'], 'class' => 'button button-primary')); ?> </p> </form> </div><!-- groups tab panel --> <?php }
/** * prints the top of the search/sort form * * @param string $target set the action attribute of the search form to another * page, giving the ability to have the search on a * different page than the list, defaults to the same page * @global object $post */ public function search_sort_form_top($target = false, $class = false, $print = true) { $this->shortcode_atts['target_page'] = trim($this->shortcode_atts['target_page']); if (!empty($this->shortcode_atts['action']) && empty($this->shorcode_atts['target_page'])) { $this->shorcode_atts['target_page'] = $this->shortcode_atts['action']; } global $post; $output = array(); $ref = 'update'; if ($target === false && !empty($this->shortcode_atts['target_page']) && $this->module == 'search') { $target = Participants_Db::find_permalink($this->shortcode_atts['target_page']); } if ($target) { $ref = 'remote'; } $action = $target !== false ? $target : get_permalink($post->ID) . '#' . $this->list_anchor; $class_att = $class ? 'class="' . $class . '"' : ''; $output[] = '<form method="post" class="sort_filter_form" action="' . $action . '"' . $class_att . ' data-ref="' . $ref . '" >'; $hidden_fields = array('action' => 'pdb_list_filter', 'target_instance' => $this->shortcode_atts['target_instance'], 'instance_index' => $this->instance_index, 'pagelink' => $this->prepare_page_link($_SERVER['REQUEST_URI']), 'sortstring' => $this->filter['sortstring'], 'orderstring' => $this->filter['orderstring'], 'filterNonce' => Participants_Db::nonce(self::$list_filter_nonce_key)); if ($ref === 'remote') { $hidden_fields['submit_button'] = 'search'; } $output[] = PDb_FormElement::print_hidden_fields($hidden_fields, false); if ($print) { echo $this->output_HTML($output); } else { return $this->output_HTML($output); } }
/** * prints the form open tag and all hidden fields * * The incoming hidden fields are merged with the default fields * * @param array $hidden array of hidden fields to print * @return null */ protected function _print_form_head($hidden = '') { $uri_components = parse_url($_SERVER['REQUEST_URI']); echo '<form method="post" enctype="multipart/form-data" autocomplete="off" action="' . $_SERVER['REQUEST_URI'] . '" >'; $default_hidden_fields = array('action' => $this->module, 'subsource' => Participants_Db::PLUGIN_NAME, 'shortcode_page' => $uri_components['path'], 'thanks_page' => $this->submission_page, 'instance_index' => Participants_Db::$instance_index, 'pdb_data_keys' => implode('.', PDb_Base::get_field_indices($this->display_columns))); if (!$this->_empty($hidden)) { $hidden_fields = $hidden + $default_hidden_fields; } else { $hidden_fields = $default_hidden_fields; } if (!$this->_empty($this->hidden_fields)) { $hidden_fields = $hidden_fields + $this->hidden_fields; } PDb_FormElement::print_hidden_fields($hidden_fields); }
/** * prints the general list form controls for the admin lising: deleting and items-per-page selector */ private static function _general_list_form_top() { ?> <form id="list_form" method="post"> <?php PDb_FormElement::print_hidden_fields(array('action' => 'list_action')); ?> <input type="hidden" id="select_count" value="0" /> <table class="form-table"><tbody><tr><td> <fieldset class="widefat inline-controls"> <?php if (current_user_can(Participants_Db::$plugin_options['plugin_admin_capability'])) { ?> <span style="padding-right:20px" ><input type="submit" name="submit-button" class="button button-default" value="<?php echo self::$i18n['delete_checked']; ?> " onClick="return delete_confirm();" id="delete_button" ></span> <?php } ?> <?php $list_limit = PDb_FormElement::get_element(array('type' => 'text-line', 'name' => 'list_limit', 'value' => self::$page_list_limit, 'attributes' => array('style' => 'width:2.8em', 'maxLength' => '3'))); ?> <?php printf(__('Show %s items per page.', 'participants-database'), $list_limit); ?> <?php PDb_FormElement::print_element(array('type' => 'submit', 'name' => 'submit-button', 'class' => 'button button-default', 'value' => self::$i18n['change'])); ?> </fieldset> </td></tr></tbody> <?php }
/** * prints the general list form controls for the admin lising: deleting and items-per-page selector */ private static function _general_list_form_top() { ?> <form id="list_form" method="post"> <?php PDb_FormElement::print_hidden_fields(array('action' => 'list_action')); ?> <input type="hidden" id="select_count" value="0" /> <?php /** * action pdb-admin_list_form_top * @version 1.6 * * todo: add relevent data to action * * good for adding functionality to the admin list */ // do_action(Participants_Db::$prefix . 'admin_list_form_top', $this); do_action(Participants_Db::$prefix . 'admin_list_form_top'); ?> <table class="form-table"><tbody><tr><td> <fieldset class="widefat inline-controls"> <?php if (current_user_can(Participants_Db::plugin_capability('plugin_admin_capability', 'delete participants'))) { ?> <span style="padding-right:20px" ><input type="submit" name="submit-button" class="button button-default" value="<?php echo self::$i18n['delete_checked']; ?> " id="delete_button" ></span> <?php } ?> <?php $list_limit = PDb_FormElement::get_element(array('type' => 'text-line', 'name' => 'list_limit', 'value' => self::$page_list_limit, 'attributes' => array('style' => 'width:2.8em', 'maxLength' => '3'))); ?> <?php printf(__('Show %s items per page.', 'participants-database'), $list_limit); ?> <?php PDb_FormElement::print_element(array('type' => 'submit', 'name' => 'submit-button', 'class' => 'button button-default', 'value' => self::$i18n['change'])); ?> </fieldset> </td></tr></tbody></table> <?php }
/** * outputs a set of hidden inputs * * @param array $fields name=>value pairs for each hidden input tag */ public static function print_hidden_fields($fields, $print = true) { PDb_FormElement::print_hidden_fields($fields, $print); }