/**
  * 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 = '';
     /**
      * filter: pdb-before_display_form_element
      * 
      * @since 1.6
      * 
      * @param string $return the value display
      * @param object $field the field object
      * 
      * formerly, this was set as "pdb-before_display_field" and included a more limited set of arguments
      */
     if (has_filter(Participants_Db::$prefix . 'before_display_form_element')) {
         $return = Participants_Db::set_filter('before_display_form_element', $return, $field);
     } elseif (has_filter(Participants_Db::$prefix . 'before_display_field')) {
         // provided for backward-compatibility
         $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 : false, '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'))) {
                         $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 = Participants_Db::files_uri() . $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_setting_is_true('show_time') 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
                  */
                 $return = self::array_display($field);
                 break;
             case 'link':
                 $linkdata = maybe_unserialize($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':
                 $pattern = $html ? '<span ' . self::class_attribute('textarea') . '>%s</span>' : '%s';
                 $return = sprintf($pattern, $field->value);
                 break;
             case 'rich-text':
                 if ($html) {
                     $return = sprintf('<span ' . self::class_attribute('textarea richtext') . '>%s</span>', Participants_Db::process_rich_text($field->value));
                 } else {
                     $return = strip_tags($field->value);
                 }
                 break;
             case 'dropdown':
             case 'radio':
             case 'checkbox':
             case 'dropdown-other':
             case 'select-other':
                 $field->value = self::array_display($field);
                 if ($html) {
                     $return = sprintf('<span %s>%s</span>', self::class_attribute($field->form_element), self::make_link($field));
                 } else {
                     $return = $field->value;
                 }
                 break;
             case 'placeholder':
                 $field->value = $field->default;
                 $return = $html ? self::make_link($field) : $field->value;
                 break;
             case 'hidden':
                 if ($field->value === $field->default) {
                     $field->value = '';
                 } elseif (!Participants_Db::is_dynamic_value($field->default)) {
                     $field->value = $field->default;
                 }
             default:
                 $return = $html ? self::make_link($field) : $field->value;
         }
     }
     return $return;
 }
 /**
  * sets the default path to the image directory
  *
  */
 public function set_image_directory()
 {
     $this->image_directory = Participants_Db::files_path();
     $this->image_directory_uri = Participants_Db::files_uri();
 }