} ?> <th><?php echo $column_title . $add_title; ?> </th> <td id="<?php echo Participants_Db::$prefix . $column->name; ?> " > <?php /* * get the value from the record; if it is empty, use the default value if the * "persistent" flag is set. */ $column->value = empty($participant_values[$column->name]) ? $column->persistent == '1' ? $column->default : '' : Participants_Db::unserialize_array($participant_values[$column->name]); // get the existing value if any //$column->value = isset($participant_values[$column->name]) ? Participants_Db::unserialize_array($participant_values[$column->name]) : ''; // replace it with the new value if provided if (isset($_POST[$column->name])) { if (is_array($_POST[$column->name])) { $column->value = $_POST[$column->name]; } elseif ('rich-text' == $column->form_element) { $column->value = $_POST[$column->name]; } else { $column->value = esc_html(stripslashes($_POST[$column->name])); } } $field_class = ($column->validation != 'no' ? "required-field" : '') . (in_array($column->form_element, array('text-line', 'date')) ? ' regular-text' : ''); if (isset($column->value)) { //error_log(basename(__FILE__) . ' ' . $column->name . ':' . $column->value);
/** * converts an array value to a readable string * * @param array $value * @param string $glue string to use for concatenation * @param bool $print if true, echo the output * @return string HTML */ public function show_array($value, $glue = ', ', $print = true) { $array = array_filter((array) Participants_Db::unserialize_array($value), array('PDb_FormElement', 'is_displayable')); $output = implode($glue, $array); if ($print) { echo $output; } else { return $output; } }
/** * escape a value from a form submission * * can handle both single values and arrays */ protected function _esc_submitted_value($value) { $value = Participants_Db::unserialize_array($value); if (is_array($value)) { $return = array(); foreach ($value as $k => $v) { $return[$k] = $this->_esc_value($v); } } else { $return = $this->_esc_value($value); } return $return; }
/** * returns an element value formatted for display or storage * * this supplants the function Participants_Db::prep_field_for_display * * @param object $field a Field_Item object * @param bool $html if true, retuns the value wrapped in HTML, false returns * the formatted value alone * @return string the object's current value, formatted */ public static function get_field_value_display($field, $html = true) { $return = ''; if (has_filter(Participants_Db::$prefix . 'before_display_field')) { $return = Participants_Db::set_filter('before_display_field', $return, $field->value, $field->form_element); } if (empty($return)) { switch ($field->form_element) { case 'image-upload': $image = new PDb_Image(array('filename' => $field->value, 'link' => isset($field->link) ? $field->link : '', 'mode' => 'both', 'module' => $field->module)); if ($html) { if (isset($field->module) and in_array($field->module, array('single', 'list'))) { $image->display_mode = 'image'; } elseif (isset($field->module) and in_array($field->module, array('signup', 'admin-edit'))) { $image->display_mode = $image->image_defined ? 'both' : 'none'; $image->link = false; } $image->set_image_wrap(); $return = $image->get_image_html(); } elseif ($image->file_exists) { $return = $image->get_image_file(); } else { $return = $field->value; } break; case 'file-upload': if ($html and !empty($field->value)) { if ($field->module == 'signup') { $field->link = false; $return = $field->value; } else { $field->link = xnau_Image_Handler::concatenate_directory_path(get_bloginfo('url'), Participants_Db::$plugin_options['image_upload_location']) . $field->value; $return = self::make_link($field); } break; } else { $return = $field->value; break; } case 'date': case 'timestamp': $return = ''; if (self::is_empty($field->value) === false) { $date = Participants_Db::parse_date($field->value, $field); $format = Participants_Db::$date_format; if (Participants_Db::$plugin_options['show_time'] == '1' and $field->form_element == 'timestamp') { $format .= ' ' . get_option('time_format'); } $return = date_i18n($format, $date); } else { $return = ''; } break; case 'multi-checkbox': case 'multi-select-other': /* * these elements are stored as serialized arrays of values, the data is displayed * a comma-separated string of the values, using the value titles if defined */ $multivalues = Participants_Db::unserialize_array($field->value); // remove empty elements and convert to string for display $multivalues = array_filter((array) $multivalues, array(__CLASS__, 'is_displayable')); $titles = array(); foreach ($multivalues as $value) { $titles[] = self::get_value_title($value, $field->name); } $return = implode(', ', $titles); break; case 'link': $linkdata = Participants_Db::unserialize_array($field->value); if (!is_array($linkdata)) { $return = ''; break; } if (empty($linkdata[1])) { $linkdata[1] = str_replace('http://', '', $linkdata[0]); } if ($html) { $return = vsprintf(empty($linkdata[0]) ? '%1$s%2$s' : '<a href="%1$s">%2$s</a>', $linkdata); } else { $return = $linkdata[0]; } break; case 'text-line': if ($html) { $field->value = self::get_value_title($field->value, $field->name); $return = self::make_link($field); break; } else { $return = $field->value; break; } case 'text-area': case 'textarea': $return = sprintf('<span class="textarea">%s</span>', $field->value); break; case 'rich-text': $return = sprintf('<span class="textarea richtext">%s</span>', Participants_Db::process_rich_text($field->value)); break; default: $field->value = self::get_value_title($field->value, $field->name); $return = self::make_link($field); } } return $return; }
public function show_array($value, $glue = ', ', $print = true) { $output = implode($glue, Participants_Db::unserialize_array($value)); if ($print) { echo $output; } else { return $output; } }