function display_field($n, $field, $newtab = false) { global $use, $ref, $original_fields, $multilingual_text_fields, $multiple, $lastrt, $is_template, $language, $lang, $blank_edit_template, $edit_autosave, $errors, $tabs_on_edit, $collapsible_sections, $ctrls_to_save, $embedded_data_user_select, $embedded_data_user_select_fields; $name = "field_" . $field["ref"]; $value = $field["value"]; $value = trim($value); if ($field["omit_when_copying"] && $use != $ref) { # Omit when copying - return this field back to the value it was originally, instead of using the current value which has been fetched from the new resource. reset($original_fields); foreach ($original_fields as $original_field) { if ($original_field["ref"] == $field["ref"]) { $value = $original_field["value"]; } } } $displaycondition = true; if ($field["display_condition"] != "") { #Check if field has a display condition set $displaycondition = check_display_condition($n, $field); } if ($multilingual_text_fields) { # Multilingual text fields - find all translations and display the translation for the current language. $translations = i18n_get_translations($value); if (array_key_exists($language, $translations)) { $value = $translations[$language]; } else { $value = ""; } } if ($multiple) { $value = ""; } # Blank the value for multi-edits. if ($field["resource_type"] != $lastrt && $lastrt != -1 && $collapsible_sections) { ?> </div><h2 class="CollapsibleSectionHead" id="resource_type_properties"><?php echo htmlspecialchars(get_resource_type_name($field["resource_type"])); ?> <?php echo $lang["properties"]; ?> </h2><div class="CollapsibleSection" id="ResourceProperties<?php if ($ref == -1) { echo "Upload"; } echo $field["resource_type"]; ?> Section"><?php } $lastrt = $field["resource_type"]; # Blank form if 'reset form' has been clicked. if (getval("resetform", "") != "") { $value = ""; } # If config option $blank_edit_template is set, always show a blank form for user edit templates. if ($ref < 0 && $blank_edit_template && getval("submitted", "") == "") { $value = ""; } ?> <?php if ($multiple && !hook("replace_edit_all_checkbox", "", array($field["ref"]))) { # Multiple items, a toggle checkbox appears which activates the question ?> <div class="edit_multi_checkbox"><input name="editthis_<?php echo htmlspecialchars($name); ?> " id="editthis_<?php echo $n; ?> " type="checkbox" value="yes" onClick="var q=document.getElementById('question_<?php echo $n; ?> ');var m=document.getElementById('modeselect_<?php echo $n; ?> ');var f=document.getElementById('findreplace_<?php echo $n; ?> ');if (this.checked) {q.style.display='block';m.style.display='block';} else {q.style.display='none';m.style.display='none';f.style.display='none';document.getElementById('modeselectinput_<?php echo $n; ?> ').selectedIndex=0;}"> <label for="editthis<?php echo $n; ?> "><?php echo htmlspecialchars($field["title"]); ?> </label></div><!-- End of edit_multi_checkbox --><?php } ?> <?php if ($multiple && !hook("replace_edit_all_mode_select", "", array($field["ref"]))) { # When editing multiple, give option to select Replace All Text or Find and Replace ?> <div class="Question" id="modeselect_<?php echo $n; ?> " style="display:none;padding-bottom:0;margin-bottom:0;"> <label for="modeselectinput"><?php echo $lang["editmode"]; ?> </label> <select id="modeselectinput_<?php echo $n; ?> " name="modeselect_<?php echo $field["ref"]; ?> " class="stdwidth" onChange="var fr=document.getElementById('findreplace_<?php echo $n; ?> ');var q=document.getElementById('question_<?php echo $n; ?> ');if (this.value=='FR') {fr.style.display='block';q.style.display='none';} else {fr.style.display='none';q.style.display='block';}<?php hook("edit_all_mode_js"); ?> "> <option value="RT"><?php echo $lang["replacealltext"]; ?> </option> <?php if (in_array($field["type"], array("0", "1", "5", "8"))) { # Find and replace appies to text boxes only. ?> <option value="FR"><?php echo $lang["findandreplace"]; ?> </option> <?php } ?> <?php if ($field["type"] == 0 || $field["type"] == 1 || $field["type"] == 5) { # Prepend applies to text boxes only. ?> <option value="PP"><?php echo $lang["prependtext"]; ?> </option> <?php } if (in_array($field["type"], array("0", "1", "2", "3", "5", "7", "8", "9"))) { # Append applies to text boxes, checkboxes ,category tree and dropdowns only. ?> <option value="AP"><?php echo $lang["appendtext"]; ?> </option> <?php } if ($field["type"] == 0 || $field["type"] == 1 || $field["type"] == 5 || $field["type"] == 2 || $field["type"] == 3) { ?> <!--- Remove applies to text boxes, checkboxes and dropdowns only. --> <option value="RM"><?php echo $lang["removetext"]; ?> </option> <?php } ?> <?php hook("edit_all_extra_modes"); ?> </select> </div><!-- End of modeselect_<?php echo $n; ?> --> <div class="Question" id="findreplace_<?php echo $n; ?> " style="display:none;border-top:none;"> <label> </label> <?php echo $lang["find"]; ?> <input type="text" name="find_<?php echo $field["ref"]; ?> " class="shrtwidth"> <?php echo $lang["andreplacewith"]; ?> <input type="text" name="replace_<?php echo $field["ref"]; ?> " class="shrtwidth"> </div><!-- End of findreplace_<?php echo $n; ?> --> <?php hook("edit_all_after_findreplace", "", array($field, $n)); ?> <?php } ?> <div class="Question" id="question_<?php echo $n; ?> " <?php if ($multiple || !$displaycondition || $newtab) { ?> style="border-top:none;<?php if ($multiple || !$displaycondition) { ?> display:none; <?php } } ?> "> <?php $labelname = $name; // Add _selector to label so it will keep working: if ($field['type'] == 9) { $labelname .= '_selector'; } // Add -d to label so it will keep working if ($field['type'] == 4) { $labelname .= '-d'; } ?> <label for="<?php echo htmlspecialchars($labelname); ?> " ><?php if (!$multiple) { echo htmlspecialchars($field["title"]); ?> <?php if (!$is_template && $field["required"] == 1) { ?> <sup>*</sup><?php } } ?> </label> <?php # Autosave display if ($edit_autosave || $ctrls_to_save) { ?> <div class="AutoSaveStatus" id="AutoSaveStatus<?php echo $field["ref"]; ?> " style="display:none;"></div> <?php } ?> <?php # Define some Javascript for help actions (applies to all fields) $help_js = "onBlur=\"HideHelp(" . $field["ref"] . ");return false;\" onFocus=\"ShowHelp(" . $field["ref"] . ");return false;\""; #hook to modify field type in special case. Returning zero (to get a standard text box) doesn't work, so return 1 for type 0, 2 for type 1, etc. $modified_field_type = ""; $modified_field_type = hook("modifyfieldtype"); if ($modified_field_type) { $field["type"] = $modified_field_type - 1; } hook("addfieldextras"); # ---------------------------- Show field ----------------------------------- $type = $field["type"]; if ($type == "") { $type = 0; } # Default to text type. if (!hook("replacefield", "", array($field["type"], $field["ref"], $n))) { global $auto_order_checkbox; include "edit_fields/" . $type . ".php"; } # ---------------------------------------------------------------------------- # Display any error messages from previous save if (array_key_exists($field["ref"], $errors)) { ?> <div class="FormError">!! <?php echo $errors[$field["ref"]]; ?> !!</div> <?php } if (trim($field["help_text"] != "")) { # Show inline help for this field. # For certain field types that have no obvious focus, the help always appears. ?> <div class="FormHelp" style="padding:0;<?php if (!in_array($field["type"], array(2, 4, 6, 7, 10))) { ?> display:none;<?php } else { ?> clear:left;<?php } ?> " id="help_<?php echo $field["ref"]; ?> "><div class="FormHelpInner"><?php echo nl2br(trim(htmlspecialchars(i18n_get_translated($field["help_text"], false)))); ?> </div></div> <?php } # If enabled, include code to produce extra fields to allow multilingual free text to be entered. if ($multilingual_text_fields && ($field["type"] == 0 || $field["type"] == 1 || $field["type"] == 5)) { display_multilingual_text_field($n, $field, $translations); } if ($embedded_data_user_select || isset($embedded_data_user_select_fields) && in_array($field["ref"], $embedded_data_user_select_fields)) { ?> <table id="exif_<?php echo $field["ref"]; ?> " class="ExifOptions" cellpadding="3" cellspacing="3" <?php if ($embedded_data_user_select) { ?> style="display: none;" <?php } ?> > <tbody> <tr> <td> <?php echo " " . $lang["embeddedvalue"] . ": "; ?> </td> <td width="10" valign="middle"> <input type="radio" id="exif_extract_<?php echo $field["ref"]; ?> " name="exif_option_<?php echo $field["ref"]; ?> " value="yes" checked> </td> <td align="left" valign="middle"> <label class="customFieldLabel" for="exif_extract_<?php echo $field["ref"]; ?> "><?php echo $lang["embedded_metadata_extract_option"]; ?> </label> </td> <td width="10" valign="middle"> <input type="radio" id="no_exif_<?php echo $field["ref"]; ?> " name="exif_option_<?php echo $field["ref"]; ?> " value="no"> </td> <td align="left" valign="middle"> <label class="customFieldLabel" for="no_exif_<?php echo $field["ref"]; ?> "><?php echo $lang["embedded_metadata_donot_extract_option"]; ?> </label> </td> <td width="10" valign="middle"> <input type="radio" id="exif_append_<?php echo $field["ref"]; ?> " name="exif_option_<?php echo $field["ref"]; ?> " value="append"> </td> <td align="left" valign="middle"> <label class="customFieldLabel" for="exif_append_<?php echo $field["ref"]; ?> "><?php echo $lang["embedded_metadata_append_option"]; ?> </label> </td> <td width="10" valign="middle"> <input type="radio" id="exif_prepend_<?php echo $field["ref"]; ?> " name="exif_option_<?php echo $field["ref"]; ?> " value="prepend"> </td> <td align="left" valign="middle"> <label class="customFieldLabel" for="exif_prepend_<?php echo $field["ref"]; ?> "><?php echo $lang["embedded_metadata_prepend_option"]; ?> </label> </td> </tr> </tbody> </table> <?php } ?> <div class="clearerleft"> </div> </div><!-- end of question_<?php echo $n; ?> div --> <?php hook('afterfielddisplay', '', array($n, $field)); }
echo $lang["keyword"]; ?> </td> <td><?php echo $lang["matchingresourcesheading"]; ?> </td> <td><div class="ListTools"><?php echo $lang["tools"]; ?> </div></td> </tr> <?php for ($n = 0; $n < count($options); $n++) { $trans = i18n_get_translations($options[$n]["rawoption"]); # Work out the default language value (for the title and first field) $var = ""; if (array_key_exists($defaultlanguage, $trans)) { $var = $trans[$defaultlanguage]; } ?> <tr> <td><div class="ListTitle"> <?php if ($show_all_languages) { ?> <h2><?php echo $var; ?> </h2><?php
function display_field($n, $field) { global $ref, $original_fields, $multilingual_text_fields, $is_template, $language, $lang, $errors, $proposed_changes, $editaccess; $edit_autosave = false; $name = "field_" . $field["ref"]; $value = $field["value"]; $value = trim($value); # is there a proposed value set for this field? foreach ($proposed_changes as $proposed_change) { if ($proposed_change["resource_type_field"] == $field["ref"]) { $proposed_value = $proposed_change["value"]; } } // Don't show this if user is an admin viewing proposed changes, needs to be on form so that form is still submitted with all data if ($editaccess && !isset($proposed_value)) { ?> <div style="display:none" > <?php } if ($multilingual_text_fields) { # Multilingual text fields - find all translations and display the translation for the current language. $translations = i18n_get_translations($value); if (array_key_exists($language, $translations)) { $value = $translations[$language]; } else { $value = ""; } } ?> <div class="Question ProposeChangesQuestion" id="question_<?php echo $n; ?> "> <div class="ProposeChangesLabel" ><?php echo htmlspecialchars($field["title"]); ?> </div> <?php # Define some Javascript for help actions (applies to all fields) $help_js = "onBlur=\"HideHelp(" . $field["ref"] . ");return false;\" onFocus=\"ShowHelp(" . $field["ref"] . ");return false;\""; #hook to modify field type in special case. Returning zero (to get a standard text box) doesn't work, so return 1 for type 0, 2 for type 1, etc. $modified_field_type = ""; $modified_field_type = hook("modifyfieldtype"); if ($modified_field_type) { $field["type"] = $modified_field_type - 1; } hook("addfieldextras"); // ------------------------------ // Show existing value so can edit $value = $field["value"]; $realvalue = $value; // Store this in case it gets changed by view processing if ($value != "") { # Draw this field normally. # value filter plugin should be used regardless of whether a display template is used. if ($field['value_filter'] != "") { eval($field['value_filter']); } else { if ($field["type"] == 4 || $field["type"] == 6) { $value = NiceDate($value, false, true); } } ?> <div class="propose_changes_current stdwidth"><?php echo $value; ?> </div><?php } else { ?> <div class="propose_changes_current stdwidth"><?php echo $lang["propose_changes_novalue"]; ?> </div> <?php } ?> <?php if (!$editaccess && !isset($proposed_value)) { ?> <div class="propose_change_button" id="propose_change_button_<?php echo $field["ref"]; ?> "> <input type="submit" value="<?php echo $lang["propose_changes_buttontext"]; ?> " onClick="ShowProposeChanges(<?php echo $field["ref"]; ?> );return false;" /> </div> <?php } ?> <div class="proposed_change" <?php if (!isset($proposed_value)) { echo "style=\"display:none;\""; } ?> id="proposed_change_<?php echo $field["ref"]; ?> "> <input type="hidden" id="propose_change_<?php echo $field["ref"]; ?> " name="propose_change_<?php echo $field["ref"]; ?> " value="true" <?php if (!isset($proposed_value)) { echo "disabled=\"disabled\""; } ?> /> <?php # ---------------------------- Show field ----------------------------------- # Checkif we have a proposed value for this field if (isset($proposed_value)) { $value = $proposed_value; } else { $value = $realvalue; } $type = $field["type"]; if ($type == "") { $type = 0; } # Default to text type. if (!hook("replacefield", "", array($field["type"], $field["ref"], $n))) { global $auto_order_checkbox; include dirname(__FILE__) . "/../../../pages/edit_fields/" . $type . ".php"; } # ---------------------------------------------------------------------------- ?> </div><!-- close proposed_change_<?php echo $field["ref"]; ?> --> <?php if ($editaccess) { ?> <div class="ProposeChangesAccept ProposeChangesAcceptDeleteColumn"> <table> <tr> <td><input class="ProposeChangesAcceptCheckbox" type="checkbox" id="accept_change_<?php echo $field["ref"]; ?> " name="accept_change_<?php echo $field["ref"]; ?> " onchange="UpdateProposals(this,<?php echo $field["ref"]; ?> );" checked ></input><?php echo $lang["propose_changes_accept_change"]; ?> </td> <td> <input class="ProposeChangesDeleteCheckbox" type="checkbox" id="delete_change_<?php echo $field["ref"]; ?> " name="delete_change_<?php echo $field["ref"]; ?> " onchange="DeleteProposal(this,<?php echo $field["ref"]; ?> );" ></input><?php echo $lang["action-delete"]; ?> </td> </tr> </table> </div> <?php } if (trim($field["help_text"] != "")) { # Show inline help for this field. # For certain field types that have no obvious focus, the help always appears. ?> <div class="FormHelp" style="padding:0;<?php if (!in_array($field["type"], array(2, 4, 6, 7, 10))) { ?> display:none;<?php } else { ?> clear:left;<?php } ?> " id="help_<?php echo $field["ref"]; ?> "><div class="FormHelpInner"><?php echo nl2br(trim(htmlspecialchars(i18n_get_translated($field["help_text"], false)))); ?> </div></div> <?php } # If enabled, include code to produce extra fields to allow multilingual free text to be entered. if ($multilingual_text_fields && ($field["type"] == 0 || $field["type"] == 1 || $field["type"] == 5)) { display_multilingual_text_field($n, $field, $translations); } ?> <div class="clearerleft"> </div> </div><!-- end of question_<?php echo $n; ?> div --> <?php // Don't show this if user is an admin viewing proposed changes if ($editaccess && !isset($proposed_value)) { ?> </div><!-- End of hidden field --> <?php } }
else {jQuery('#question_" . $n . "').css('border-top','none');} } "; ?>} </script> <?php } if ($multilingual_text_fields) { # Multilingual text fields - find all translations and display the translation for the current language. $translations=i18n_get_translations($value); if (array_key_exists($language,$translations)) {$value=$translations[$language];} else {$value="";} } if ($multiple) {$value="";} # Blank the value for multi-edits. if (($fields[$n]["resource_type"]!=$lastrt)&& ($lastrt!=-1)) { ?><br /><h1 id="resource_type_properties"><?php echo htmlspecialchars(get_resource_type_name($fields[$n]["resource_type"]))?> <?php echo $lang["properties"]?></h1><?php } $lastrt=$fields[$n]["resource_type"]; # Blank form if 'reset form' has been clicked. if (getval("resetform","")!="") {$value="";} # If config option $blank_edit_template is set, always show a blank form for user edit templates.
function display_field($n, $field, $newtab=false){ global $use, $ref, $original_fields, $multilingual_text_fields, $multiple, $lastrt,$is_template, $language, $lang, $blank_edit_template, $edit_autosave, $errors, $tabs_on_edit,$collapsible_sections, $ctrls_to_save, $embedded_data_user_select, $embedded_data_user_select_fields; $name="field_" . $field["ref"]; $value=$field["value"]; $value=trim($value); if ($field["omit_when_copying"] && $use!=$ref){ # Omit when copying - return this field back to the value it was originally, instead of using the current value which has been fetched from the new resource. reset($original_fields); foreach ($original_fields as $original_field){ if ($original_field["ref"]==$field["ref"]) {$value=$original_field["value"];} } } $displaycondition=true; if ($field["display_condition"]!=""){ #Check if field has a display condition set $displaycondition=check_display_condition($n,$field); } if ($multilingual_text_fields){ # Multilingual text fields - find all translations and display the translation for the current language. $translations=i18n_get_translations($value); if (array_key_exists($language,$translations)) {$value=$translations[$language];} else {$value="";} } if ($multiple) {$value="";} # Blank the value for multi-edits. if ($field["resource_type"]!=$lastrt && $lastrt!=-1 && $collapsible_sections){?> </div><h2 class="CollapsibleSectionHead" id="resource_type_properties"> <?php echo htmlspecialchars(get_resource_type_name($field["resource_type"]))?> <?php echo $lang["properties"]?></h2><div class="CollapsibleSection" id="ResourceProperties<?php if ($ref==-1) echo "Upload"; ?> <?php echo $field["resource_type"]; ?>Section"><?php } $lastrt=$field["resource_type"]; # Blank form if 'reset form' has been clicked. if (getval("resetform","")!="") {$value="";} # If config option $blank_edit_template is set, always show a blank form for user edit templates. if ($ref<0 && $blank_edit_template && getval("submitted","")=="") {$value="";} if ($multiple && !hook("replace_edit_all_checkbox","",array($field["ref"]))) { # Multiple items, a toggle checkbox appears which activates the question ?><div class="edit_multi_checkbox"><input name="editthis_<?php echo htmlspecialchars($name)?>" id="editthis_<?php echo $n?>" type="checkbox" value="yes" onClick="var q=document.getElementById('question_<?php echo $n?>');var m=document.getElementById('modeselect_<?php echo $n?>');var f=document.getElementById('findreplace_<?php echo $n?>');if (this.checked) {q.style.display='block';m.style.display='block';} else {q.style.display='none';m.style.display='none';f.style.display='none';document.getElementById('modeselectinput_<?php echo $n?>').selectedIndex=0;}"> <label for="editthis<?php echo $n?>"><?php echo htmlspecialchars($field["title"])?></label></div><!-- End of edit_multi_checkbox --><?php } ?> <div class="Question" id="question_<?php echo $n?>" <?php if ($multiple || !$displaycondition || $newtab) {?>style="border-top:none;<?php if ($multiple || !$displaycondition){?>display:none;<?php } } ?>"> <?php $labelname = $name; // Add _selector to label so it will keep working: if($field['type'] == 9) { $labelname .= '_selector'; } // Add -d to label so it will keep working if($field['type'] == 4) { $labelname .= '-d'; } ?> <label for="<?php echo htmlspecialchars($labelname)?>" > <?php if (!$multiple) {?><?php echo htmlspecialchars($field["title"])?> <?php if (!$is_template && $field["required"]==1) { ?><sup>*</sup><?php } ?><?php } ?> </label> <?php # Define some Javascript for help actions (applies to all fields) $help_js="onBlur=\"HideHelp(" . $field["ref"] . ");return false;\" onFocus=\"ShowHelp(" . $field["ref"] . ");return false;\""; #hook to modify field type in special case. Returning zero (to get a standard text box) doesn't work, so return 1 for type 0, 2 for type 1, etc. $modified_field_type=""; $modified_field_type=(hook("modifyfieldtype")); if ($modified_field_type){$field["type"]=$modified_field_type-1;} hook("addfieldextras"); # ---------------------------- Show field ----------------------------------- $type=$field["type"]; if ($type=="") {$type=0;} # Default to text type. if (!hook("replacefield","",array($field["type"],$field["ref"],$n))) { global $auto_order_checkbox; include "edit_fields/" . $type . ".php"; } # ---------------------------------------------------------------------------- # Display any error messages from previous save if (array_key_exists($field["ref"],$errors)) { ?> <div class="FormError">!! <?php echo $errors[$field["ref"]]?> !!</div> <?php } if (trim($field["help_text"]!="")) { # Show inline help for this field. # For certain field types that have no obvious focus, the help always appears. ?> <div class="FormHelp-selector" onmouseenter="ShowHelp(<?php echo $field["ref"] ?>); return false;" onmouseleave="HideHelp(<?php echo $field["ref"]?>)"><em>i</em></div> <div class="FormHelp" style="padding:0; display:none;" id="help_<?php echo $field["ref"]?>"> <div class="FormHelpInner"><?php echo nl2br(trim(htmlspecialchars(i18n_get_translated($field["help_text"],false))))?></div></div> <?php } # If enabled, include code to produce extra fields to allow multilingual free text to be entered. if ($multilingual_text_fields && ($field["type"]==0 || $field["type"]==1 || $field["type"]==5)) { display_multilingual_text_field($n, $field, $translations); } ?> <div class="clearerleft"> </div> </div><!-- end of question_<?php echo $n?> div --> <?php hook('afterfielddisplay', '', array($n, $field)); }