Commit 874a915a authored by Chris Graham's avatar Chris Graham

Fixed MANTIS-4042 (Issues with Comcode fields, and multi-input fields)

parent 95281234
......@@ -929,20 +929,20 @@ function get_catalogue_entry_map($entry, $catalogue, $view_type, $tpl_set, $root
// Value to show
$ev = $field['effective_value'];
$dereference_ev = is_object($field['effective_value']) ? $field['effective_value']->evaluate() : $field['effective_value'];
$ev_pure = $field['effective_value_pure'];
$ob = get_fields_hook($field['cf_type']);
list(, , $storage_type) = $ob->get_field_value_row_bits($field);
if (($i == 0) && ($catalogue['c_display_type'] == C_DT_TITLELIST)) {
$use_ev = $ev;
} else {
$use_ev = $ob->render_field_value($field, $ev, $i, $only_fields, 'catalogue_efv_' . $storage_type, $id, 'ce_id', 'cf_id', 'cv_value', $entry['ce_submitter']);
$use_ev = $ob->render_field_value($field, $ev, $i, $only_fields, 'catalogue_efv_' . $storage_type, $id, 'ce_id', 'cf_id', 'cv_value', $entry['ce_submitter'], $ev_pure);
}
// Special case for access to raw thumbnail
if ($field['cf_type'] == 'picture') {
if (($ev !== null) && ($dereference_ev != '')) {
if (($ev !== null) && ($ev_pure != '')) {
require_code('images');
$map['FIELD_' . $str_i . '_THUMB'] = do_image_thumb($dereference_ev, ($i == 0) ? new Tempcode() : (is_object($map['FIELD_0']) ? $map['FIELD_0'] : protect_from_escaping(escape_html($map['FIELD_0']))), false, false);
$map['FIELD_' . $str_i . '_THUMB'] = do_image_thumb($ev_pure, ($i == 0) ? new Tempcode() : (is_object($map['FIELD_0']) ? $map['FIELD_0'] : protect_from_escaping(escape_html($map['FIELD_0']))), false, false);
} else {
$map['FIELD_' . $str_i . '_THUMB'] = new Tempcode();
}
......
......@@ -333,7 +333,7 @@ function cns_get_all_custom_fields_match_member($member_id, $public_view = null,
}
if ($display_cpf) {
$rendered_value = $ob->render_field_value($field_to_show, $member_value, $i, null, 'f_member_custom_fields', $member_id, 'mf_member_id', null, 'field_' . strval($field_to_show['id']), $member_id);
$rendered_value = $ob->render_field_value($field_to_show, $member_value, $i, null, 'f_member_custom_fields', $member_id, 'mf_member_id', null, 'field_' . strval($field_to_show['id']), $member_id, $member_value_raw);
$editability = mixed(); // If stays as null, not editable
if (isset($editable_with_comcode[$field_to_show['cf_type']])) {
......
......@@ -127,7 +127,7 @@ class Hook_fields_content_link_multi
$ret = new Tempcode();
foreach ($out as $o) {
list($title, $url) = $o;
$ret->attach(paragraph(hyperlink(build_url($map, $zone), $title, false, true)));
$ret->attach(paragraph(hyperlink(build_url($map, $zone), $title, false, true), 'content_link_multi'));
}
return $ret;
......
......@@ -74,14 +74,22 @@ class Hook_fields_long_trans
*
* @param array $field The field details
* @param mixed $ev The raw value
* @param integer $i Position in fieldset
* @param ?array $only_fields List of fields the output is being limited to (null: N/A)
* @param ?ID_TEXT $table The table we store in (null: N/A)
* @param ?AUTO_LINK $id The ID of the row in the table (null: N/A)
* @param ?ID_TEXT $id_field Name of the ID field in the table (null: N/A)
* @param ?ID_TEXT $field_id_field Name of the field ID field in the table (null: N/A)
* @param ?ID_TEXT $url_field Name of the URL field in the table (null: N/A)
* @param ?MEMBER $submitter Submitter (null: current member)
* @return mixed Rendered field (Tempcode or string)
*/
public function render_field_value($field, $ev)
public function render_field_value(&$field, $ev, $i, $only_fields, $table = null, $id = null, $id_field = null, $field_id_field = null, $url_field = null, $submitter = null)
{
if (is_object($ev)) {
return $ev;
}
return comcode_to_tempcode($ev);
return comcode_to_tempcode($ev, $submitter);
}
// ======================
......
......@@ -114,7 +114,7 @@ class Hook_fields_member_multi
$ret = new Tempcode();
foreach (array_keys($out) as $key) {
$ret->attach(paragraph($GLOBALS['FORUM_DRIVER']->member_profile_hyperlink($key)));
$ret->attach(paragraph($GLOBALS['FORUM_DRIVER']->member_profile_hyperlink($key), 'member_multi'));
}
return $ret;
......
......@@ -74,14 +74,22 @@ class Hook_fields_posting_field
*
* @param array $field The field details
* @param mixed $ev The raw value
* @param integer $i Position in fieldset
* @param ?array $only_fields List of fields the output is being limited to (null: N/A)
* @param ?ID_TEXT $table The table we store in (null: N/A)
* @param ?AUTO_LINK $id The ID of the row in the table (null: N/A)
* @param ?ID_TEXT $id_field Name of the ID field in the table (null: N/A)
* @param ?ID_TEXT $field_id_field Name of the field ID field in the table (null: N/A)
* @param ?ID_TEXT $url_field Name of the URL field in the table (null: N/A)
* @param ?MEMBER $submitter Submitter (null: current member)
* @return mixed Rendered field (Tempcode or string)
*/
public function render_field_value($field, $ev)
public function render_field_value(&$field, $ev, $i, $only_fields, $table = null, $id = null, $id_field = null, $field_id_field = null, $url_field = null, $submitter = null)
{
if (is_object($ev)) {
return $ev;
}
return escape_html($ev);
return comcode_to_tempcode($ev, $submitter);
}
// ======================
......
......@@ -132,7 +132,7 @@ class Hook_fields_reference_multi
$ret = new Tempcode();
foreach ($out as $o) {
list($title, $url) = $o;
$ret->attach(paragraph(hyperlink($url, $title, false, true)));
$ret->attach(paragraph(hyperlink($url, $title, false, true), 'reference_multi'));
}
return $ret;
......
......@@ -90,7 +90,7 @@ class Hook_fields_short_text_multi
$ret = new Tempcode();
foreach ($exploded as $ev) {
$ret->attach(paragraph(escape_html($ev)));
$ret->attach(paragraph(escape_html($ev), 'short_text_multi'));
}
return $ret;
......
......@@ -74,14 +74,22 @@ class Hook_fields_short_trans
*
* @param array $field The field details
* @param mixed $ev The raw value
* @param integer $i Position in fieldset
* @param ?array $only_fields List of fields the output is being limited to (null: N/A)
* @param ?ID_TEXT $table The table we store in (null: N/A)
* @param ?AUTO_LINK $id The ID of the row in the table (null: N/A)
* @param ?ID_TEXT $id_field Name of the ID field in the table (null: N/A)
* @param ?ID_TEXT $field_id_field Name of the field ID field in the table (null: N/A)
* @param ?ID_TEXT $url_field Name of the URL field in the table (null: N/A)
* @param ?MEMBER $submitter Submitter (null: current member)
* @return mixed Rendered field (Tempcode or string)
*/
public function render_field_value($field, $ev)
public function render_field_value(&$field, $ev, $i, $only_fields, $table = null, $id = null, $id_field = null, $field_id_field = null, $url_field = null, $submitter = null)
{
if (is_object($ev)) {
return $ev;
}
return comcode_to_tempcode($ev);
return comcode_to_tempcode($ev, $submitter);
}
// ======================
......
......@@ -74,23 +74,36 @@ class Hook_fields_short_trans_multi
*
* @param array $field The field details
* @param mixed $ev The raw value
* @param integer $i Position in fieldset
* @param ?array $only_fields List of fields the output is being limited to (null: N/A)
* @param ?ID_TEXT $table The table we store in (null: N/A)
* @param ?AUTO_LINK $id The ID of the row in the table (null: N/A)
* @param ?ID_TEXT $id_field Name of the ID field in the table (null: N/A)
* @param ?ID_TEXT $field_id_field Name of the field ID field in the table (null: N/A)
* @param ?ID_TEXT $url_field Name of the URL field in the table (null: N/A)
* @param ?MEMBER $submitter Submitter (null: current member)
* @param ?mixed $ev_pure The 'pure' form of the raw value, meaning Comcode is not pre-parsed and string conversion has not been performed (null: unknown)
* @return mixed Rendered field (Tempcode or string)
*/
public function render_field_value($field, $ev)
public function render_field_value(&$field, $ev, $i, $only_fields, $table = null, $id = null, $id_field = null, $field_id_field = null, $url_field = null, $submitter = null, $ev_pure = null)
{
if (is_object($ev)) {
if ((is_object($ev)) && ($ev_pure === null)) {
return $ev;
}
$exploded = ($ev == '') ? array() : explode("\n", $ev);
if ($ev_pure === null) {
$ev_pure = $ev;
}
$exploded = ($ev_pure == '') ? array() : explode("\n", $ev_pure);
$auto_sort = option_value_from_field_array($field, 'auto_sort', 'off');
if ($auto_sort == 'on') {
natsort($exploded);
}
$ret = new Tempcode();
foreach ($exploded as $ev) {
$ret->attach(paragraph(comcode_to_tempcode($ev)));
foreach ($exploded as $ev_pure) {
$ret->attach(paragraph(comcode_to_tempcode($ev_pure, $submitter), 'short_trans_multi'));
}
return $ret;
......
......@@ -121,7 +121,7 @@ class Hook_fields_upload_multi
$download_url = (url_is_local($ev) ? (get_custom_base_url() . '/') : '') . $ev;
}
$ret->attach(paragraph(hyperlink($download_url, $original_filename, true, true)));
$ret->attach(paragraph(hyperlink($download_url, $original_filename, true, true), 'upload_multi'));
}
return $ret;
}
......
......@@ -109,7 +109,7 @@ class Hook_fields_url_multi
$ret = new Tempcode();
foreach ($out as $ev => $link_captions_title) {
$ret->attach(paragraph(hyperlink((url_is_local($ev) ? (get_base_url() . '/') : '') . $ev, $link_captions_title, true, true)));
$ret->attach(paragraph(hyperlink((url_is_local($ev) ? (get_base_url() . '/') : '') . $ev, $link_captions_title, true, true), 'url_multi'));
}
return $ret;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment