本文整理汇总了PHP中data_entry_helper::get_species_names_filter方法的典型用法代码示例。如果您正苦于以下问题:PHP data_entry_helper::get_species_names_filter方法的具体用法?PHP data_entry_helper::get_species_names_filter怎么用?PHP data_entry_helper::get_species_names_filter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类data_entry_helper
的用法示例。
在下文中一共展示了data_entry_helper::get_species_names_filter方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: species_checklist
/**
* Helper function to generate a species checklist from a given taxon list.
*
* Please not that although this is based on the data_entry_helper function, it has only been tested with the following
* options for seasearch - @id,@useThirdLevelSamples,@lookupListId,@gridIdAttributeId,@speciesControlToUseSubSamples,@subSamplePerRow,@resizeWidth,@resizeHeight
* If you intend to use any other options, they will require further testing or development.
*
*/
private static function species_checklist($options)
{
global $indicia_templates;
data_entry_helper::add_resource('addrowtogrid');
$options = data_entry_helper::get_species_checklist_options($options);
$classlist = array('ui-widget', 'ui-widget-content', 'species-grid');
if (!empty($options['class'])) {
$classlist[] = $options['class'];
}
if ($options['subSamplePerRow']) {
// we'll track 1 sample per grid row.
$smpIdx = 0;
}
if ($options['columns'] > 1 && count($options['mediaTypes']) > 1) {
throw new Exception('The species_checklist control does not support having more than one occurrence per row (columns option > 0) ' . 'at the same time has having the mediaTypes option in use.');
}
data_entry_helper::add_resource('json');
data_entry_helper::add_resource('autocomplete');
$filterArray = data_entry_helper::get_species_names_filter($options);
$filterNameTypes = array('all', 'currentLanguage', 'preferred', 'excludeSynonyms');
//make a copy of the options so that we can maipulate it
$overrideOptions = $options;
//We are going to cycle through each of the name filter types
//and save the parameters required for each type in an array so
//that the Javascript can quickly access the required parameters
foreach ($filterNameTypes as $filterType) {
$overrideOptions['speciesNameFilterMode'] = $filterType;
$nameFilter[$filterType] = data_entry_helper::get_species_names_filter($overrideOptions);
$nameFilter[$filterType] = json_encode($nameFilter[$filterType]);
}
if (count($filterArray)) {
$filterParam = json_encode($filterArray);
data_entry_helper::$javascript .= "indiciaData['taxonExtraParams-" . $options['id'] . "'] = {$filterParam};\n";
// Apply a filter to extraParams that can be used when loading the initial species list, to get just the correct names.
if (isset($options['speciesNameFilterMode']) && !empty($options['listId'])) {
$filterFields = array();
$filterWheres = array();
self::parse_species_name_filter_mode($options, $filterFields, $filterWheres);
if (count($filterWheres)) {
$options['extraParams'] += array('query' => json_encode(array('where' => $filterWheres)));
}
$options['extraParams'] += $filterFields;
}
}
data_entry_helper::$js_read_tokens = $options['readAuth'];
data_entry_helper::$javascript .= "indiciaData['rowInclusionCheck-" . $options['id'] . "'] = '" . $options['rowInclusionCheck'] . "';\n";
data_entry_helper::$javascript .= "indiciaData['copyDataFromPreviousRow-" . $options['id'] . "'] = '" . $options['copyDataFromPreviousRow'] . "';\n";
data_entry_helper::$javascript .= "indiciaData['includeSpeciesGridLinkPage-" . $options['id'] . "'] = '" . $options['includeSpeciesGridLinkPage'] . "';\n";
data_entry_helper::$javascript .= "indiciaData.speciesGridPageLinkUrl = '" . $options['speciesGridPageLinkUrl'] . "';\n";
data_entry_helper::$javascript .= "indiciaData.speciesGridPageLinkParameter = '" . $options['speciesGridPageLinkParameter'] . "';\n";
data_entry_helper::$javascript .= "indiciaData.speciesGridPageLinkTooltip = '" . $options['speciesGridPageLinkTooltip'] . "';\n";
data_entry_helper::$javascript .= "indiciaData['editTaxaNames-" . $options['id'] . "'] = '" . $options['editTaxaNames'] . "';\n";
data_entry_helper::$javascript .= "indiciaData['subSpeciesColumn-" . $options['id'] . "'] = '" . $options['subSpeciesColumn'] . "';\n";
data_entry_helper::$javascript .= "indiciaData['subSamplePerRow-" . $options['id'] . "'] = " . ($options['subSamplePerRow'] ? 'true' : 'false') . ";\n";
if ($options['copyDataFromPreviousRow']) {
data_entry_helper::$javascript .= "indiciaData['previousRowColumnsToInclude-" . $options['id'] . "'] = '" . $options['previousRowColumnsToInclude'] . "';\n";
data_entry_helper::$javascript .= "indiciaData.langAddAnother='" . lang::get('Add another') . "';\n";
}
if (count($options['mediaTypes'])) {
data_entry_helper::add_resource('plupload');
// store some globals that we need later when creating uploaders
$relpath = data_entry_helper::getRootFolder() . data_entry_helper::client_helper_path();
$interim_image_folder = isset(parent::$interim_image_folder) ? parent::$interim_image_folder : 'upload/';
data_entry_helper::$javascript .= "indiciaData.uploadSettings = {\n";
data_entry_helper::$javascript .= " uploadScript: '" . $relpath . "upload.php',\n";
data_entry_helper::$javascript .= " destinationFolder: '" . $relpath . $interim_image_folder . "',\n";
data_entry_helper::$javascript .= " jsPath: '" . data_entry_helper::$js_path . "'";
if (isset($options['resizeWidth'])) {
data_entry_helper::$javascript .= ",\n resizeWidth: " . $options['resizeWidth'];
}
if (isset($options['resizeHeight'])) {
data_entry_helper::$javascript .= ",\n resizeHeight: " . $options['resizeHeight'];
}
if (isset($options['resizeQuality'])) {
data_entry_helper::$javascript .= ",\n resizeQuality: " . $options['resizeQuality'];
}
data_entry_helper::$javascript .= "\n}\n";
if ($indicia_templates['file_box'] != '') {
data_entry_helper::$javascript .= "file_boxTemplate = '" . str_replace('"', '\\"', $indicia_templates['file_box']) . "';\n";
}
if ($indicia_templates['file_box_initial_file_info'] != '') {
data_entry_helper::$javascript .= "file_box_initial_file_infoTemplate = '" . str_replace('"', '\\"', $indicia_templates['file_box_initial_file_info']) . "';\n";
}
if ($indicia_templates['file_box_uploaded_image'] != '') {
data_entry_helper::$javascript .= "file_box_uploaded_imageTemplate = '" . str_replace('"', '\\"', $indicia_templates['file_box_uploaded_image']) . "';\n";
}
}
$occAttrControls = array();
$occAttrs = array();
$occAttrControlsExisting = array();
$taxonRows = array();
$subSampleRows = array();
//.........这里部分代码省略.........
示例2: get_control_species_single
/**
* Returns a control for picking a single species
* @global type $indicia_templates
* @param array $auth Read authorisation tokens
* @param array $args Form configuration
* @param array $extraParams Extra parameters pre-configured with taxon and taxon name type filters.
* @param array $options additional options for the control, e.g. those configured in the form structure.
* @return string HTML for the control.
*/
protected static function get_control_species_single($auth, $args, $extraParams, $options)
{
$r = '';
if ($args['extra_list_id'] === '' && $args['list_id'] !== '') {
$extraParams['taxon_list_id'] = $args['list_id'];
} elseif ($args['extra_list_id'] !== '' && $args['list_id'] === '') {
$extraParams['taxon_list_id'] = $args['extra_list_id'];
} elseif ($args['extra_list_id'] !== '' && $args['list_id'] !== '') {
$extraParams['query'] = json_encode(array('in' => array('taxon_list_id' => array($args['list_id'], $args['extra_list_id']))));
}
if (isset($options['taxonGroupSelect']) && $options['taxonGroupSelect']) {
$label = isset($options['taxonGroupSelectLabel']) ? $options['taxonGroupSelectLabel'] : 'Species Group';
$helpText = isset($options['taxonGroupSelectHelpText']) ? $options['taxonGroupSelectHelpText'] : 'Choose which species group you want to pick a species from.';
$default = '';
if (!empty(data_entry_helper::$entity_to_load['occurrence:taxa_taxon_list_id'])) {
// need to find the default value
$species = data_entry_helper::get_population_data(array('table' => 'cache_taxa_taxon_list', 'extraParams' => $auth['read'] + array('id' => data_entry_helper::$entity_to_load['occurrence:taxa_taxon_list_id'])));
data_entry_helper::$entity_to_load['taxon_group_id'] = $species[0]['taxon_group_id'];
}
$r .= data_entry_helper::select(array('fieldname' => 'taxon_group_id', 'id' => 'taxon_group_id', 'label' => lang::get($label), 'helpText' => lang::get($helpText), 'report' => 'library/taxon_groups/taxon_groups_used_in_checklist', 'valueField' => 'id', 'captionField' => 'title', 'extraParams' => $auth['read'] + array('taxon_list_id' => $extraParams['taxon_list_id'])));
// update the select box to link to the species group picker. It must be a select box!
$args['species_ctrl'] = 'select';
$options['parentControlId'] = 'taxon_group_id';
$options['parentControlLabel'] = lang::get($label);
$options['filterField'] = 'taxon_group_id';
}
$options['speciesNameFilterMode'] = self::getSpeciesNameFilterMode($args);
global $indicia_templates;
$ctrl = $args['species_ctrl'] === 'autocomplete' ? 'species_autocomplete' : $args['species_ctrl'];
$species_ctrl_opts = array_merge(array('fieldname' => 'occurrence:taxa_taxon_list_id', 'label' => lang::get('occurrence:taxa_taxon_list_id'), 'columns' => 2, 'parentField' => 'parent_id', 'blankText' => lang::get('Please select'), 'cacheLookup' => $args['cache_lookup']), $options);
if (isset($species_ctrl_opts['extraParams'])) {
$species_ctrl_opts['extraParams'] = array_merge($extraParams, $species_ctrl_opts['extraParams']);
} else {
$species_ctrl_opts['extraParams'] = $extraParams;
}
if (!empty($args['taxon_filter'])) {
$species_ctrl_opts['taxonFilterField'] = $args['taxon_filter_field'];
// applies to autocompletes
$species_ctrl_opts['taxonFilter'] = helper_base::explode_lines($args['taxon_filter']);
// applies to autocompletes
}
// obtain table to query and hence fields to use
$db = data_entry_helper::get_species_lookup_db_definition($args['cache_lookup']);
// get local vars for the array
extract($db);
if ($ctrl !== 'species_autocomplete') {
// The species autocomplete has built in support for the species name filter.
// For other controls we need to apply the species name filter to the params used for population
if (!empty($species_ctrl_opts['taxonFilter']) || $options['speciesNameFilterMode']) {
$species_ctrl_opts['extraParams'] = array_merge($species_ctrl_opts['extraParams'], data_entry_helper::get_species_names_filter($species_ctrl_opts));
}
// for controls which don't know how to do the lookup, we need to tell them
$species_ctrl_opts = array_merge(array('table' => $tblTaxon, 'captionField' => $colTaxon, 'valueField' => $colId), $species_ctrl_opts);
}
// if using something other than an autocomplete, then set the caption template to include the appropriate names. Autocompletes
// use a JS function instead.
if ($ctrl !== 'autocomplete' && isset($args['species_include_both_names']) && $args['species_include_both_names']) {
if ($args['species_names_filter'] === 'all') {
$indicia_templates['species_caption'] = "{{$colTaxon}}";
} elseif ($args['species_names_filter'] === 'language') {
$indicia_templates['species_caption'] = "{{$colTaxon}} - {{$colPreferred}}";
} else {
$indicia_templates['species_caption'] = "{{$colTaxon}} - {{$colCommon}}";
}
$species_ctrl_opts['captionTemplate'] = 'species_caption';
}
if ($ctrl == 'tree_browser') {
// change the node template to include images
$indicia_templates['tree_browser_node'] = '<div>' . '<img src="' . data_entry_helper::$base_url . '/upload/thumb-{image_path}" alt="Image of {caption}" width="80" /></div>' . '<span>{caption}</span>';
}
// Dynamically generate the species selection control required.
$r .= call_user_func(array('data_entry_helper', $ctrl), $species_ctrl_opts);
return $r;
}
示例3: get_site_trees_tab
private static function get_site_trees_tab($auth, $args, $settings)
{
global $indicia_templates;
$r = '<div id="site-trees" class="ui-helper-clearfix">';
$r .= '<form method="post" id="tree-form" action="' . self::$ajaxFormUrl . '">';
$help = '<p>' . lang::get('To add a tree, click on the "Add Tree" button. You can then use the map\'s Location Tool to select the approximate location of your tree on the map. A new tree will then appear on the map.') . '</p>' . '<p>' . lang::get('To select a tree from the existing list of trees at this site you can either:') . '</p>' . '<ol><li>' . lang::get('Click on the button for the tree you wish to view, or') . '</li>' . '<li>' . lang::get('Use the map\'s Query Tool to click on the tree you wish to view on the map.') . '</li></ol>' . '<p>' . lang::get('To remove a tree, first select the tree you wish to remove, then click on the "Remove Tree" button. It will remove the current tree you are viewing completely.') . '</p>';
$r .= '<div class="ui-state-highlight page-notice ui-corner-all">' . $help . '</div>';
$r .= self::tree_selector($settings);
$r .= '<input type="button" value="' . lang::get('Remove Tree') . '" class="remove-tree form-button right" title="' . lang::get('Completely remove the highlighted tree. The total number of tree will be reduced by one. The form will be reloaded after the tree is deleted.') . '">';
$r .= '<input type="button" value="' . lang::get('Add Tree') . '" class="insert-tree form-button right" title="' . lang::get('This inserts an extra tree.') . '">';
$r .= '<div id="cols" class="ui-helper-clearfix"><div class="left" style="width: ' . (98 - (isset($args['percent_width']) ? $args['percent_width'] : 50)) . '%">';
$r .= '<fieldset><legend>' . lang::get('Tree Details') . '</legend>';
$r .= '<input type="hidden" name="location:id" value="" id="tree-location-id" />';
$r .= '<input type="hidden" name="locations_website:website_id" value="' . $args['website_id'] . '" id="locations-website-website-id" />';
$r .= '<input type="hidden" name="location:parent_id" value="' . $settings['locationId'] . '" />';
$r .= '<input type="hidden" name="location:location_type_id" value="' . $settings['TreeLocationType'][0]['id'] . '" />';
$r .= '<input type="hidden" name="website_id" value="' . $args['website_id'] . "\" />\n";
$r .= data_entry_helper::text_input(array('fieldname' => 'location:name', 'label' => lang::get('Tree ID'), 'class' => 'control-width-4 required'));
$systems = array();
$list = explode(',', str_replace(' ', '', $args['spatial_systems']));
foreach ($list as $system) {
$systems[$system] = lang::get($system);
}
$srefOptions = array('id' => 'imp-sref-tree', 'fieldname' => 'location:centroid_sref', 'geomid' => 'imp-geom-tree', 'geomFieldname' => 'location:centroid_geom', 'label' => 'Grid Ref', 'labelClass' => 'auto', 'class' => 'required', 'helpText' => lang::get('You can also click on the map to set the grid reference. If directly entering the coordinates from a GPS device, set the format to "Lat/Long" first. To enter an OS Grid square, choose the "OSGB" or "OSIE" formats.'));
data_entry_helper::$javascript .= "\n\$('#imp-sref-tree').attr('title',\n '" . lang::get("When directly entering coordinates as a GPS Lat/Long reading, there should be no spaces between the numbers and the letter. " . "The degrees, minutes and seconds must all be separated by a colon (:). The direction letter can be placed at the start or the end of the number (e.g. N56.532 or 56.532N). " . "The figures may be entered as decimal degrees (e.g. 56.532), degrees and decimal minutes (e.g. 56:31.92), or degrees, minutes and decimal seconds (e.g. 56:31:55.2). " . "You can mix the formats of the Latitude and Longitude, provided they each follow the previous guidelines and a space separates them (e.g. N56.532 2:30W).") . " " . lang::get("When directly entering an OS map reference, there should be no spaces between any of the characters. " . "An OSGB reference should comprise of 2 letters followed by an even number of digits (e.g. NT274628). " . "An OSIE reference should comprise of of 1 letter followed by an even number of digits (e.g. J081880).") . "');\n";
// Output the sref control
$r .= data_entry_helper::sref_textbox($srefOptions);
$srefOptions = array('id' => 'imp-sref-system-tree', 'fieldname' => 'location:centroid_sref_system', 'class' => 'required', 'systems' => $systems);
// Output the system control
if (count($systems) < 2) {
// Hidden field for the system
$keys = array_keys($options['systems']);
$r .= "<input type=\"hidden\" id=\"imp-sref-system-tree\" name=\"" . $options['fieldname'] . "\" value=\"" . $keys[0] . "\" />\n";
// TODO self::include_sref_handler_js($options['systems']);
} else {
$r .= data_entry_helper::sref_system_select($srefOptions);
}
$r .= '<input type="hidden" name="survey_id" value="' . $args['survey_id'] . '" />';
$r .= '<input type="hidden" name="sample:survey_id" value="' . $args['survey_id'] . '" />';
$r .= '<input type="hidden" name="sample:id" value="" />';
// this sample will reference the location id.
if (isset(data_entry_helper::$entity_to_load['sample:date']) && preg_match('/^(\\d{4})/', data_entry_helper::$entity_to_load['sample:date'])) {
// Date has 4 digit year first (ISO style) - convert date to expected output format
// @todo The date format should be a global configurable option. It should also be applied to reloading of custom date attributes.
$d = new DateTime(data_entry_helper::$entity_to_load['sample:date']);
data_entry_helper::$entity_to_load['sample:date'] = $d->format('d/m/Y');
}
$r .= data_entry_helper::date_picker(array('label' => lang::get('Date Tree Selected'), 'fieldname' => 'sample:date', 'class' => 'control-width-2 required'));
$r .= '<input type="hidden" id="sample:sample_method_id" value="' . $settings['treeSampleMethod']['id'] . '" name="sample:sample_method_id">';
$r .= '<input type="hidden" id="sample:location_name" value="" name="sample:location_name">';
$r .= '<input type="hidden" name="occurrence:id" value="" id="occurrence:id" />';
$r .= '<input type="hidden" name="occurrence:record_status" value="C" id="occurrence:record_status" />';
$extraParams = $auth['read'];
$extraParams['taxon_list_id'] = $args['taxon_list_id'];
$options = array('speciesNameFilterMode' => $args['speciesNameFilterMode']);
$ctrl = $args['species_ctrl'];
$species_ctrl_opts = array_merge(array('fieldname' => 'occurrence:taxa_taxon_list_id', 'label' => lang::get('Tree Species'), 'columns' => 1, 'parentField' => 'parent_id', 'blankText' => lang::get('Please select'), 'cacheLookup' => false), $options);
if (isset($species_ctrl_opts['extraParams'])) {
$species_ctrl_opts['extraParams'] = array_merge($extraParams, $species_ctrl_opts['extraParams']);
} else {
$species_ctrl_opts['extraParams'] = $extraParams;
}
if (!empty($args['taxon_filter'])) {
$species_ctrl_opts['taxonFilterField'] = $args['taxon_filter_field'];
// applies to autocompletes
$species_ctrl_opts['taxonFilter'] = helper_base::explode_lines($args['taxon_filter']);
// applies to autocompletes
}
// obtain table to query and hence fields to use
$db = data_entry_helper::get_species_lookup_db_definition(false);
// get local vars for the array
extract($db);
if ($ctrl !== 'species_autocomplete') {
// The species autocomplete has built in support for the species name filter.
// For other controls we need to apply the species name filter to the params used for population
if (!empty($species_ctrl_opts['taxonFilter']) || $options['speciesNameFilterMode']) {
$species_ctrl_opts['extraParams'] = array_merge($species_ctrl_opts['extraParams'], data_entry_helper::get_species_names_filter($species_ctrl_opts));
}
// for controls which don't know how to do the lookup, we need to tell them
$species_ctrl_opts = array_merge(array('table' => $tblTaxon, 'captionField' => $colTaxon, 'valueField' => $colId), $species_ctrl_opts);
}
// if using something other than an autocomplete, then set the caption template to include the appropriate names. Autocompletes
// use a JS function instead.
if ($ctrl !== 'autocomplete' && isset($args['species_include_both_names']) && $args['species_include_both_names']) {
if ($args['speciesNameFilterMode'] === 'all') {
$indicia_templates['species_caption'] = "{{$colTaxon}}";
} elseif ($args['speciesNameFilterMode'] === 'language') {
$indicia_templates['species_caption'] = "{{$colTaxon}} - {{$colPreferred}}";
} else {
$indicia_templates['species_caption'] = "{{$colTaxon}} - {{$colCommon}}";
}
$species_ctrl_opts['captionTemplate'] = 'species_caption';
}
if ($ctrl == 'tree_browser') {
// change the node template to include images
$indicia_templates['tree_browser_node'] = '<div>' . '<img src="' . data_entry_helper::$base_url . '/upload/thumb-{image_path}" alt="Image of {caption}" width="80" /></div>' . '<span>{caption}</span>';
}
// Dynamically generate the species selection control required.
$r .= call_user_func(array('data_entry_helper', $ctrl), $species_ctrl_opts);
$ctrlOptions = array('extraParams' => $auth['read']);
//.........这里部分代码省略.........