$options = trim_array(explode(",", $field["options"])); $option_trans = array(); $option_trans_simple = array(); for ($m = 0; $m < count($options); $m++) { $trans = i18n_get_translated($options[$m]); $option_trans[$options[$m]] = $trans; $option_trans_simple[] = $trans; } if ($auto_order_checkbox) { natsort($option_trans); } $options = array_keys($option_trans); # Set the options array to the keys, so it is now effectively sorted by translated string $set = trim_array(explode(",", $value)); $wrap = 0; $l = average_length($option_trans_simple); $cols = 10; if ($l > 5) { $cols = 6; } if ($l > 10) { $cols = 4; } if ($l > 15) { $cols = 3; } if ($l > 25) { $cols = 2; } $height = ceil(count($options) / $cols); global $checkbox_ordered_vertically;
<?php /*******************************************/ /**************RADIO BUTTONS****************/ /*******************************************/ $options = trim_array(explode(",", $field["options"])); $set = trim($value); // Translate the options: for ($i = 0; $i < count($options); $i++) { $options[$i] = i18n_get_translated($options[$i]); } $l = average_length($options); $cols = 10; if ($l > 5) { $cols = 6; } if ($l > 10) { $cols = 4; } if ($l > 15) { $cols = 3; } if ($l > 25) { $cols = 2; } $rows = ceil(count($options) / $cols); // Default behaviour if (!isset($display_as_radiobuttons)) { $display_as_radiobuttons = TRUE; } // Display as checkboxes is a feature for advanced search only
function render_search_field($field, $value = "", $autoupdate, $class = "stdwidth", $forsearchbar = false, $limit_keywords = array()) { # Renders the HTML for the provided $field for inclusion in a search form, for example the # advanced search page. Standard field titles are translated using $lang. Custom field titles are i18n translated. # # $field an associative array of field data, i.e. a row from the resource_type_field table. # $name the input name to use in the form (post name) # $value the default value to set for this field, if any global $auto_order_checkbox, $lang, $category_tree_open, $minyear; $name = "field_" . $field["ref"]; if (!$forsearchbar) { ?> <div class="Question" <?php if (strlen($field["tooltip_text"]) >= 1) { echo "title=\"" . htmlspecialchars(lang_or_i18n_get_translated($field["tooltip_text"], "fieldtooltip-")) . "\""; } ?> > <label><?php echo lang_or_i18n_get_translated($field["title"], "fieldtitle-"); ?> </label> <?php } else { ?> <div class="SearchItem"> <?php echo lang_or_i18n_get_translated($field["title"], "fieldtitle-"); ?> </br> <?php } switch ($field["type"]) { case 0: # -------- Text boxes # -------- Text boxes case 1: case 5: ?> <input class="<?php echo $class; ?> " type=text name="field_<?php echo $field["ref"]; ?> " value="<?php echo htmlspecialchars($value); ?> " <?php if ($autoupdate) { ?> onChange="UpdateResultCount();"<?php } ?> onKeyPress="if (!(updating)) {setTimeout('UpdateResultCount()',2000);updating=true;}"><?php break; case 2: case 3: # -------- Show a check list or dropdown for dropdowns and check lists? # By default show a checkbox list for both (for multiple selections this enabled OR functionality) # Translate all options $options = trim_array(explode(",", $field["options"])); $adjusted_dropdownoptions = hook("adjustdropdownoptions"); if ($adjusted_dropdownoptions) { $options = $adjusted_dropdownoptions; } $option_trans = array(); $option_trans_simple = array(); for ($m = 0; $m < count($options); $m++) { $trans = i18n_get_translated($options[$m]); $option_trans[$options[$m]] = $trans; $option_trans_simple[] = $trans; } if ($auto_order_checkbox) { asort($option_trans); } $options = array_keys($option_trans); # Set the options array to the keys, so it is now effectively sorted by translated string if ($field["display_as_dropdown"]) { # Show as a dropdown box $set = trim_array(explode(";", cleanse_string($value, true))); ?> <select class="<?php echo $class; ?> " name="field_<?php echo $field["ref"]; ?> " <?php if ($autoupdate) { ?> onChange="UpdateResultCount();"<?php } ?> ><option value=""></option><?php foreach ($option_trans as $option => $trans) { if (trim($trans) != "") { ?> <option value="<?php echo htmlspecialchars(trim($trans)); ?> " <?php if (in_array(cleanse_string($trans, true), $set)) { ?> selected<?php } ?> ><?php echo htmlspecialchars(trim($trans)); ?> </option> <?php } } ?> </select><?php } else { # Show as a checkbox list (default) $set = trim_array(explode(";", cleanse_string($value, true))); $wrap = 0; $l = average_length($option_trans_simple); $cols = 10; if ($l > 5) { $cols = 6; } if ($l > 10) { $cols = 4; } if ($l > 15) { $cols = 3; } if ($l > 25) { $cols = 2; } # Filter the options array for blank values and ignored keywords. $newoptions = array(); foreach ($options as $option) { if ($option != "" && (count($limit_keywords) == 0 || in_array($option, $limit_keywords))) { $newoptions[] = $option; } } $options = $newoptions; $height = ceil(count($options) / $cols); global $checkbox_ordered_vertically; if ($checkbox_ordered_vertically) { if (!hook('rendersearchchkboxes')) { # ---------------- Vertical Ordering (only if configured) ----------- ?> <table cellpadding=2 cellspacing=0><tr><?php for ($y = 0; $y < $height; $y++) { for ($x = 0; $x < $cols; $x++) { # Work out which option to fetch. $o = $x * $height + $y; if ($o < count($options)) { $option = $options[$o]; $trans = $option_trans[$option]; $name = $field["ref"] . "_" . md5($option); if ($option != "") { ?> <td valign=middle><input type=checkbox id="<?php echo $name; ?> " name="<?php echo $name; ?> " value="yes" <?php if (in_array(cleanse_string($trans, true), $set)) { ?> checked<?php } ?> <?php if ($autoupdate) { ?> onClick="UpdateResultCount();"<?php } ?> ></td><td valign=middle><?php echo htmlspecialchars($trans); ?> </td> <?php } else { ?> <td></td><td></td><?php } } } ?> </tr><tr><?php } ?> </tr></table><?php } } else { # ---------------- Horizontal Ordering (Standard) --------------------- ?> <table cellpadding=2 cellspacing=0><tr><?php foreach ($option_trans as $option => $trans) { $wrap++; if ($wrap > $cols) { $wrap = 1; ?> </tr><tr><?php } $name = $field["ref"] . "_" . md5($option); if ($option != "") { ?> <td valign=middle><input type=checkbox id="<?php echo $name; ?> " name="<?php echo $name; ?> " value="yes" <?php if (in_array(cleanse_string(i18n_get_translated($option), true), $set)) { ?> checked<?php } ?> <?php if ($autoupdate) { ?> onClick="UpdateResultCount();"<?php } ?> ></td><td valign=middle><?php echo htmlspecialchars($trans); ?> </td> <?php } } ?> </tr></table><?php } } break; case 4: case 6: # ----- Date types $found_year = ''; $found_month = ''; $found_day = ''; $s = explode("-", $value); if (count($s) >= 3) { $found_year = $s[0]; $found_month = $s[1]; $found_day = $s[2]; } ?> <select name="<?php echo $name; ?> _year" class="SearchWidth" style="width:100px;" <?php if ($autoupdate) { ?> onChange="UpdateResultCount();"<?php } ?> > <option value=""><?php echo $lang["anyyear"]; ?> </option> <?php $y = date("Y"); for ($d = $minyear; $d <= $y; $d++) { ?> <option <?php if ($d == $found_year) { ?> selected<?php } ?> ><?php echo $d; ?> </option><?php } ?> </select> <select name="<?php echo $name; ?> _month" class="SearchWidth" style="width:100px;" <?php if ($autoupdate) { ?> onChange="UpdateResultCount();"<?php } ?> > <option value=""><?php echo $lang["anymonth"]; ?> </option> <?php for ($d = 1; $d <= 12; $d++) { $m = str_pad($d, 2, "0", STR_PAD_LEFT); ?> <option <?php if ($d == $found_month) { ?> selected<?php } ?> value="<?php echo $m; ?> "><?php echo $lang["months"][$d - 1]; ?> </option><?php } ?> </select> <select name="<?php echo $name; ?> _day" class="SearchWidth" style="width:100px;" <?php if ($autoupdate) { ?> onChange="UpdateResultCount();"<?php } ?> > <option value=""><?php echo $lang["anyday"]; ?> </option> <?php for ($d = 1; $d <= 31; $d++) { $m = str_pad($d, 2, "0", STR_PAD_LEFT); ?> <option <?php if ($d == $found_day) { ?> selected<?php } ?> value="<?php echo $m; ?> "><?php echo $m; ?> </option><?php } ?> </select> <?php break; case 7: # ----- Category Tree $options = $field["options"]; $set = trim_array(explode(";", cleanse_string($value, true))); if ($forsearchbar) { # On the search bar? # Produce a smaller version of the category tree in a single dropdown - max two levels ?> <select class="<?php echo $class; ?> " name="field_<?php echo $field["ref"]; ?> "><option value=""></option><?php $class = explode("\n", $options); for ($t = 0; $t < count($class); $t++) { $s = explode(",", $class[$t]); if (count($s) == 3 && $s[1] == 0) { # Found a first level ?> <option <?php if (in_array(cleanse_string($s[2], true), $set)) { ?> selected<?php } ?> ><?php echo $s[2]; ?> </option> <?php # Parse tree again looking for level twos at this point for ($u = 0; $u < count($class); $u++) { $v = explode(",", $class[$u]); if (count($v) == 3 && $v[1] == $s[0]) { # Found a first level ?> <option value="<?php echo $s[2] . "," . $v[2]; ?> " <?php if (in_array(cleanse_string($s[2], true), $set) && in_array(cleanse_string($v[2], true), $set)) { ?> selected<?php } ?> > - <?php echo $v[2]; ?> </option> <?php } } } } ?> </select> <?php } else { # For advanced search and elsewhere, include the category tree. include "../pages/edit_fields/7.php"; } break; case 9: #-- Dynamic keywords list $value = str_replace(";", ",", $value); # Different syntax used for keyword separation when searching. include "../pages/edit_fields/9.php"; break; } ?> <div class="clearerleft"> </div> </div> <?php }
function render_search_field($field, $value = "", $autoupdate, $class = "stdwidth", $forsearchbar = false, $limit_keywords = array()) { # Renders the HTML for the provided $field for inclusion in a search form, for example the # advanced search page. Standard field titles are translated using $lang. Custom field titles are i18n translated. # # $field an associative array of field data, i.e. a row from the resource_type_field table. # $name the input name to use in the form (post name) # $value the default value to set for this field, if any global $auto_order_checkbox, $auto_order_checkbox_case_insensitive, $lang, $category_tree_open, $minyear, $daterange_search, $is_search, $values, $n; $name = "field_" . $field["ref"]; #Check if field has a display condition set $displaycondition = true; if ($field["display_condition"] != "") { $s = explode(";", $field["display_condition"]); $condref = 0; foreach ($s as $condition) { $displayconditioncheck = false; $s = explode("=", $condition); global $fields; for ($cf = 0; $cf < count($fields); $cf++) { if ($s[0] == $fields[$cf]["name"] && ($fields[$cf]["resource_type"] == 0 || $fields[$cf]["resource_type"] == $field["resource_type"])) { $scriptconditions[$condref]["field"] = $fields[$cf]["ref"]; # add new jQuery code to check value $scriptconditions[$condref]['type'] = $fields[$cf]['type']; $scriptconditions[$condref]['options'] = $fields[$cf]['options']; $checkvalues = $s[1]; $validvalues = explode("|", strtoupper($checkvalues)); $scriptconditions[$condref]["valid"] = "\""; $scriptconditions[$condref]["valid"] .= implode("\",\"", $validvalues); $scriptconditions[$condref]["valid"] .= "\""; if (isset($values[$fields[$cf]["name"]])) { $v = trim_array(explode(" ", strtoupper($values[$fields[$cf]["name"]]))); foreach ($validvalues as $validvalue) { if (in_array($validvalue, $v)) { $displayconditioncheck = true; } # this is a valid value } } if (!$displayconditioncheck) { $displaycondition = false; } #add jQuery code to update on changes if ($fields[$cf]["type"] == 2 && $fields[$cf]["display_as_dropdown"] == 0) { # construct the value from the ticked boxes $val = ","; # Note: it seems wrong to start with a comma, but this ensures it is treated as a comma separated list by split_keywords(), so if just one item is selected it still does individual word adding, so 'South Asia' is split to 'South Asia','South','Asia'. $options = trim_array(explode(",", $fields[$cf]["options"])); ?> <script type="text/javascript"> jQuery(document).ready(function() {<?php for ($m = 0; $m < count($options); $m++) { $checkname = $fields[$cf]["ref"] . "_" . md5($options[$m]); echo "\n jQuery('input[name=\"" . $checkname . "\"]').change(function (){\n checkDisplayCondition" . $field["ref"] . "();\n });"; } ?> }); </script><?php } else { if ($fields[$cf]['type'] == 12 && $fields[$cf]['display_as_dropdown'] == 0) { ?> <script type="text/javascript"> jQuery(document).ready(function() { // Check for radio buttons (default behaviour) jQuery('input[name=field_<?php echo $fields[$cf]["ref"]; ?> ]:radio').change(function() { checkDisplayCondition<?php echo $field["ref"]; ?> (); }); <?php $options = trim_array(explode(',', $fields[$cf]['options'])); foreach ($options as $option) { $name = 'field_' . $fields[$cf]['ref'] . '_' . sha1($option); ?> // Check for checkboxes (advanced search behaviour) jQuery('input[name=<?php echo $name; ?> ]:checkbox').change(function() { checkDisplayCondition<?php echo $field['ref']; ?> (); }); <?php } ?> }); </script> <?php } else { ?> <script type="text/javascript"> jQuery(document).ready(function() { jQuery('#field_<?php echo $fields[$cf]["ref"]; ?> ').change(function (){ checkDisplayCondition<?php echo $field["ref"]; ?> (); }); }); </script> <?php } } } } # see if next field needs to be checked $condref++; } # check next condition ?> <script type="text/javascript"> function checkDisplayCondition<?php echo $field["ref"]; ?> () { var questionField = jQuery('#question_<?php echo $n; ?> '); var fieldStatus = questionField.css('display'); var newFieldStatus = 'none'; var newFieldProvisional = true; var newFieldProvisionalTest; <?php foreach ($scriptconditions as $scriptcondition) { ?> newFieldProvisionalTest = false; if (jQuery('#field_<?php echo $scriptcondition["field"]; ?> ').length != 0) { fieldValues<?php echo $scriptcondition["field"]; ?> = jQuery('#field_<?php echo $scriptcondition["field"]; ?> ').val().toUpperCase().split(','); } else { <?php # Handle Radio Buttons type: if ($scriptcondition['type'] == 12) { $scriptcondition["options"] = explode(',', $scriptcondition["options"]); foreach ($scriptcondition["options"] as $key => $radio_button_value) { $scriptcondition["options"][$key] = sha1($radio_button_value); } $scriptcondition["options"] = implode(',', $scriptcondition["options"]); ?> var options_string = '<?php echo $scriptcondition["options"]; ?> '; var field<?php echo $scriptcondition["field"]; ?> _options = options_string.split(','); var checked = null; var fieldOkValues<?php echo $scriptcondition["field"]; ?> = [<?php echo $scriptcondition["valid"]; ?> ]; for(var i=0; i < field<?php echo $scriptcondition["field"]; ?> _options.length; i++) { if(jQuery('#field_<?php echo $scriptcondition["field"]; ?> _' + field<?php echo $scriptcondition["field"]; ?> _options[i]).is(':checked')) { checked = jQuery('#field_<?php echo $scriptcondition["field"]; ?> _' + field<?php echo $scriptcondition["field"]; ?> _options[i] + ':checked').val().toUpperCase(); if(jQuery.inArray(checked, fieldOkValues<?php echo $scriptcondition["field"]; ?> ) > -1) { newFieldProvisionalTest = true; } } } <?php } # end of handling radio buttons type ?> fieldValues<?php echo $scriptcondition["field"]; ?> = new Array(); checkedVals<?php echo $scriptcondition["field"]; ?> = jQuery('input[name^=<?php echo $scriptcondition["field"]; ?> _]'); jQuery.each(checkedVals<?php echo $scriptcondition["field"]; ?> , function() { if (jQuery(this).is(':checked')) { checkText<?php echo $scriptcondition["field"]; ?> = jQuery(this).parent().next().text().toUpperCase(); fieldValues<?php echo $scriptcondition["field"]; ?> .push(jQuery.trim(checkText<?php echo $scriptcondition["field"]; ?> )); } }); } fieldOkValues<?php echo $scriptcondition["field"]; ?> = [<?php echo $scriptcondition["valid"]; ?> ]; jQuery.each(fieldValues<?php echo $scriptcondition["field"]; ?> ,function(f,v) { if ((jQuery.inArray(v,fieldOkValues<?php echo $scriptcondition["field"]; ?> ))>-1 || (fieldValues<?php echo $scriptcondition["field"]; ?> == fieldOkValues<?php echo $scriptcondition["field"]; ?> )) { newFieldProvisionalTest = true; } }); if (newFieldProvisionalTest == false) { newFieldProvisional = false; } <?php } ?> if (newFieldProvisional == true) { newFieldStatus = 'block' } if (newFieldStatus != fieldStatus) { questionField.slideToggle(); if (questionField.css('display') == 'block') { questionField.css('border-top',''); } else { questionField.css('border-top','none'); } } } </script> <?php } $is_search = true; if (!$forsearchbar) { ?> <div class="Question" id="question_<?php echo $n; ?> " <?php if (!$displaycondition) { ?> style="display:none;border-top:none;"<?php } if (strlen($field["tooltip_text"]) >= 1) { echo "title=\"" . htmlspecialchars(lang_or_i18n_get_translated($field["tooltip_text"], "fieldtooltip-")) . "\""; } ?> > <label><?php echo htmlspecialchars(lang_or_i18n_get_translated($field["title"], "fieldtitle-")); ?> </label> <?php } else { ?> <div class="SearchItem"> <?php echo htmlspecialchars(lang_or_i18n_get_translated($field["title"], "fieldtitle-")); ?> </br> <?php } //hook("rendersearchhtml", "", array($field, $class, $value, $autoupdate)); switch ($field["type"]) { case 0: # -------- Text boxes # -------- Text boxes case 1: case 5: case 8: ?> <input class="<?php echo $class; ?> " type=text name="field_<?php echo $field["ref"]; ?> " id="field_<?php echo $field["ref"]; ?> " value="<?php echo htmlspecialchars($value); ?> " <?php if ($autoupdate) { ?> onChange="UpdateResultCount();"<?php } ?> onKeyPress="if (!(updating)) {setTimeout('UpdateResultCount()',2000);updating=true;}"><?php break; case 2: case 3: if (!hook("customchkboxes", "", array($field, $value, $autoupdate, $class, $forsearchbar, $limit_keywords))) { # -------- Show a check list or dropdown for dropdowns and check lists? # By default show a checkbox list for both (for multiple selections this enabled OR functionality) # Translate all options $options = trim_array(explode(",", $field["options"])); $adjusted_dropdownoptions = hook("adjustdropdownoptions"); if ($adjusted_dropdownoptions) { $options = $adjusted_dropdownoptions; } $option_trans = array(); $option_trans_simple = array(); for ($m = 0; $m < count($options); $m++) { $trans = i18n_get_translated($options[$m]); $option_trans[$options[$m]] = $trans; $option_trans_simple[] = $trans; } if ($auto_order_checkbox && !hook("ajust_auto_order_checkbox", "", array($field))) { if ($auto_order_checkbox_case_insensitive) { natcasesort($option_trans); } else { asort($option_trans); } } $options = array_keys($option_trans); # Set the options array to the keys, so it is now effectively sorted by translated string if ($field["display_as_dropdown"]) { # Show as a dropdown box $set = trim_array(explode(";", cleanse_string($value, true))); ?> <select class="<?php echo $class; ?> " name="field_<?php echo $field["ref"]; ?> " id="field_<?php echo $field["ref"]; ?> " <?php if ($autoupdate) { ?> onChange="UpdateResultCount();"<?php } ?> ><option value=""></option><?php foreach ($option_trans as $option => $trans) { if (trim($trans) != "") { ?> <option value="<?php echo htmlspecialchars(trim($trans)); ?> " <?php if (in_array(cleanse_string($trans, true), $set)) { ?> selected<?php } ?> ><?php echo htmlspecialchars(trim($trans)); ?> </option> <?php } } ?> </select><?php } else { # Show as a checkbox list (default) $set = trim_array(explode(";", cleanse_string($value, true))); $wrap = 0; $l = average_length($option_trans_simple); $cols = 10; if ($l > 5) { $cols = 6; } if ($l > 10) { $cols = 4; } if ($l > 15) { $cols = 3; } if ($l > 25) { $cols = 2; } # Filter the options array for blank values and ignored keywords. $newoptions = array(); foreach ($options as $option) { if ($option != "" && (count($limit_keywords) == 0 || in_array($option, $limit_keywords))) { $newoptions[] = $option; } } $options = $newoptions; $height = ceil(count($options) / $cols); global $checkbox_ordered_vertically, $checkbox_vertical_columns; if ($checkbox_ordered_vertically) { if (!hook('rendersearchchkboxes')) { # ---------------- Vertical Ordering (only if configured) ----------- ?> <table cellpadding=2 cellspacing=0><tr><?php for ($y = 0; $y < $height; $y++) { for ($x = 0; $x < $cols; $x++) { # Work out which option to fetch. $o = $x * $height + $y; if ($o < count($options)) { $option = $options[$o]; $trans = $option_trans[$option]; $name = $field["ref"] . "_" . md5($option); if ($option != "") { ?> <td valign=middle><input type=checkbox id="<?php echo htmlspecialchars($name); ?> " name="<?php echo $name; ?> " value="yes" <?php if (in_array(cleanse_string($trans, true), $set)) { ?> checked<?php } ?> <?php if ($autoupdate) { ?> onClick="UpdateResultCount();"<?php } ?> ></td><td valign=middle><?php echo htmlspecialchars($trans); ?> </td> <?php } else { ?> <td></td><td></td><?php } } } ?> </tr><tr><?php } ?> </tr></table><?php } } else { # ---------------- Horizontal Ordering (Standard) --------------------- ?> <table cellpadding=2 cellspacing=0><tr><?php foreach ($option_trans as $option => $trans) { $wrap++; if ($wrap > $cols) { $wrap = 1; ?> </tr><tr><?php } $name = $field["ref"] . "_" . md5($option); if ($option != "") { ?> <td valign=middle><input type=checkbox id="<?php echo htmlspecialchars($name); ?> " name="<?php echo htmlspecialchars($name); ?> " value="yes" <?php if (in_array(cleanse_string(i18n_get_translated($option), true), $set)) { ?> checked<?php } ?> <?php if ($autoupdate) { ?> onClick="UpdateResultCount();"<?php } ?> ></td><td valign=middle><?php echo htmlspecialchars($trans); ?> </td> <?php } } ?> </tr></table><?php } } } break; case 4: case 6: case 10: # ----- Date types $found_year = ''; $found_month = ''; $found_day = ''; $found_start_year = ''; $found_start_month = ''; $found_start_day = ''; $found_end_year = ''; $found_end_month = ''; $found_end_day = ''; if ($daterange_search) { $startvalue = substr($value, strpos($value, "start") + 5, 10); $ss = explode(" ", $startvalue); if (count($ss) >= 3) { $found_start_year = $ss[0]; $found_start_month = $ss[1]; $found_start_day = $ss[2]; } $endvalue = substr($value, strpos($value, "end") + 3, 10); $se = explode(" ", $endvalue); if (count($se) >= 3) { $found_end_year = $se[0]; $found_end_month = $se[1]; $found_end_day = $se[2]; } ?> <!-- date range search start --> <div><label class="InnerLabel"><?php echo $lang["fromdate"]; ?> </label> <select name="<?php echo htmlspecialchars($name); ?> _startyear" class="SearchWidth" style="width:100px;" <?php if ($autoupdate) { ?> onChange="UpdateResultCount();"<?php } ?> > <option value=""><?php echo $lang["anyyear"]; ?> </option> <?php $y = date("Y"); for ($d = $y; $d >= $minyear; $d--) { ?> <option <?php if ($d == $found_start_year) { ?> selected<?php } ?> ><?php echo $d; ?> </option><?php } ?> </select> <select name="<?php echo $name; ?> _startmonth" class="SearchWidth" style="width:100px;" <?php if ($autoupdate) { ?> onChange="UpdateResultCount();"<?php } ?> > <option value=""><?php echo $lang["anymonth"]; ?> </option> <?php for ($d = 1; $d <= 12; $d++) { $m = str_pad($d, 2, "0", STR_PAD_LEFT); ?> <option <?php if ($d == $found_start_month) { ?> selected<?php } ?> value="<?php echo $m; ?> "><?php echo $lang["months"][$d - 1]; ?> </option><?php } ?> </select> <select name="<?php echo $name; ?> _startday" class="SearchWidth" style="width:100px;" <?php if ($autoupdate) { ?> onChange="UpdateResultCount();"<?php } ?> > <option value=""><?php echo $lang["anyday"]; ?> </option> <?php for ($d = 1; $d <= 31; $d++) { $m = str_pad($d, 2, "0", STR_PAD_LEFT); ?> <option <?php if ($d == $found_start_day) { ?> selected<?php } ?> value="<?php echo $m; ?> "><?php echo $m; ?> </option><?php } ?> </select> </div><br><div><label></label><label class="InnerLabel"><?php echo $lang["todate"]; ?> </label><select name="<?php echo $name; ?> _endyear" class="SearchWidth" style="width:100px;" <?php if ($autoupdate) { ?> onChange="UpdateResultCount();"<?php } ?> > <option value=""><?php echo $lang["anyyear"]; ?> </option> <?php $y = date("Y"); for ($d = $y; $d >= $minyear; $d--) { ?> <option <?php if ($d == $found_end_year) { ?> selected<?php } ?> ><?php echo $d; ?> </option><?php } ?> </select> <select name="<?php echo $name; ?> _endmonth" class="SearchWidth" style="width:100px;" <?php if ($autoupdate) { ?> onChange="UpdateResultCount();"<?php } ?> > <option value=""><?php echo $lang["anymonth"]; ?> </option> <?php $md = date("n"); for ($d = 1; $d <= 12; $d++) { $m = str_pad($d, 2, "0", STR_PAD_LEFT); ?> <option <?php if ($d == $found_end_month) { ?> selected<?php } ?> value="<?php echo $m; ?> "><?php echo $lang["months"][$d - 1]; ?> </option><?php } ?> </select> <select name="<?php echo $name; ?> _endday" class="SearchWidth" style="width:100px;" <?php if ($autoupdate) { ?> onChange="UpdateResultCount();"<?php } ?> > <option value=""><?php echo $lang["anyday"]; ?> </option> <?php $td = date("d"); for ($d = 1; $d <= 31; $d++) { $m = str_pad($d, 2, "0", STR_PAD_LEFT); ?> <option <?php if ($d == $found_end_day) { ?> selected<?php } ?> value="<?php echo $m; ?> "><?php echo $m; ?> </option><?php } ?> </select> <!-- date range search end date--> </div> <?php } else { $s = explode("|", $value); if (count($s) >= 3) { $found_year = $s[0]; $found_month = $s[1]; $found_day = $s[2]; } ?> <select name="<?php echo $name; ?> _year" class="SearchWidth" style="width:100px;" <?php if ($autoupdate) { ?> onChange="UpdateResultCount();"<?php } ?> > <option value=""><?php echo $lang["anyyear"]; ?> </option> <?php $y = date("Y"); for ($d = $minyear; $d <= $y; $d++) { ?> <option <?php if ($d == $found_year) { ?> selected<?php } ?> ><?php echo $d; ?> </option><?php } ?> </select> <select name="<?php echo $name; ?> _month" class="SearchWidth" style="width:100px;" <?php if ($autoupdate) { ?> onChange="UpdateResultCount();"<?php } ?> > <option value=""><?php echo $lang["anymonth"]; ?> </option> <?php for ($d = 1; $d <= 12; $d++) { $m = str_pad($d, 2, "0", STR_PAD_LEFT); ?> <option <?php if ($d == $found_month) { ?> selected<?php } ?> value="<?php echo $m; ?> "><?php echo $lang["months"][$d - 1]; ?> </option><?php } ?> </select> <select name="<?php echo $name; ?> _day" class="SearchWidth" style="width:100px;" <?php if ($autoupdate) { ?> onChange="UpdateResultCount();"<?php } ?> > <option value=""><?php echo $lang["anyday"]; ?> </option> <?php for ($d = 1; $d <= 31; $d++) { $m = str_pad($d, 2, "0", STR_PAD_LEFT); ?> <option <?php if ($d == $found_day) { ?> selected<?php } ?> value="<?php echo $m; ?> "><?php echo $m; ?> </option><?php } ?> </select> <?php } break; case 7: # ----- Category Tree $options = $field["options"]; $set = trim_array(explode(";", cleanse_string($value, true))); if ($forsearchbar) { # On the search bar? # Produce a smaller version of the category tree in a single dropdown - max two levels ?> <select class="<?php echo $class; ?> " name="field_<?php echo $field["ref"]; ?> "><option value=""></option><?php $class = explode("\n", $options); for ($t = 0; $t < count($class); $t++) { $s = explode(",", $class[$t]); if (count($s) == 3 && $s[1] == 0) { # Found a first level ?> <option <?php if (in_array(cleanse_string($s[2], true), $set)) { ?> selected<?php } ?> ><?php echo htmlspecialchars($s[2]); ?> </option> <?php # Parse tree again looking for level twos at this point for ($u = 0; $u < count($class); $u++) { $v = explode(",", $class[$u]); if (count($v) == 3 && $v[1] == $s[0]) { # Found a first level ?> <option value="<?php echo htmlspecialchars($s[2]) . "," . htmlspecialchars($v[2]); ?> " <?php if (in_array(cleanse_string($s[2], true), $set) && in_array(cleanse_string($v[2], true), $set)) { ?> selected<?php } ?> > - <?php echo htmlspecialchars($v[2]); ?> </option> <?php } } } } ?> </select> <?php } else { # For advanced search and elsewhere, include the category tree. include "../pages/edit_fields/7.php"; } break; case 9: #-- Dynamic keywords list $value = str_replace(";", ",", $value); # Different syntax used for keyword separation when searching. include "../pages/edit_fields/9.php"; break; // Radio buttons: // Radio buttons: case 12: // auto save is not needed when searching $edit_autosave = FALSE; $display_as_radiobuttons = FALSE; $display_as_checkbox = TRUE; if ($field['display_as_dropdown']) { $display_as_dropdown = TRUE; $display_as_checkbox = FALSE; } include '../pages/edit_fields/12.php'; break; } ?> <div class="clearerleft"> </div> </div> <?php }