/** * Define the HTML required for this filter's UI panel. */ public function get_controls($readAuth, $options) { $r = "<p id=\"what-filter-instruct\">" . lang::get('You can either filter by species group (first tab) or a selection of individual species (second tab)') . "</p>\n" . '<div id="what-tabs">' . "\n"; // data_entry_helper::tab_header breaks inside fancybox. So output manually. $r .= '<ul class="ui-helper-hidden"><li id="species-group-tab-tab"><a href="#species-group-tab" rel="address:species-group-tab"><span>Species groups</span></a></li>' . '<li id="species-tab-tab"><a href="#species-tab" rel="address:species-tab"><span>Species and other taxa</span></a></li></ul>'; $r .= '<div id="species-group-tab">' . "\n"; $myGroupIds = hostsite_get_user_field('taxon_groups', ''); if ($myGroupIds) { $r .= '<h3>' . lang::get('My groups') . '</h3>'; $myGroupsData = data_entry_helper::get_population_data(array('table' => 'taxon_group', 'extraParams' => $readAuth + array('query' => json_encode(array('in' => array('id', unserialize($myGroupIds))))))); $myGroupNames = array(); data_entry_helper::$javascript .= "indiciaData.myGroups = [];\n"; foreach ($myGroupsData as $group) { $myGroupNames[] = $group['title']; data_entry_helper::$javascript .= "indiciaData.myGroups.push([{$group['id']},'{$group['title']}']);\n"; } $r .= '<button type="button" id="my_groups">' . lang::get('Include my groups') . '</button>'; $r .= '<ul class="inline"><li>' . implode('</li><li>', $myGroupNames) . '</li></ul>'; $r .= '<h3>' . lang::get('Build a list of groups') . '</h3>'; } $r .= '<p>' . lang::get('Search for and build a list of species groups to include') . '</p>' . ' <div class="context-instruct messages warning">' . lang::get('Please note that your access permissions are limiting the groups available to choose from.') . '</div>'; $r .= data_entry_helper::sub_list(array('fieldname' => 'taxon_group_list', 'table' => 'taxon_group', 'captionField' => 'title', 'valueField' => 'id', 'extraParams' => $readAuth, 'addToTable' => false)); $r .= "</div>\n"; $r .= '<div id="species-tab">' . "\n"; $r .= '<p>' . lang::get('Search for and build a list of species to include') . '</p>' . ' <div class="context-instruct messages warning">' . lang::get('Please note that your access permissions will limit the records returned to the species you are allowed to see.') . '</div>'; if (empty($options['taxon_list_id'])) { $r .= '<p>Please specify a @taxon_list_id option in the page configuration.</p>'; } $r .= data_entry_helper::sub_list(array('fieldname' => 'taxa_taxon_list_list', 'table' => 'cache_taxa_taxon_list', 'captionField' => 'taxon', 'valueField' => 'id', 'extraParams' => $readAuth + array('taxon_list_id' => $options['taxon_list_id'], 'preferred' => 't'), 'addToTable' => false)); $r .= "</div>\n"; $r .= "</div>\n"; data_entry_helper::enable_tabs(array('divId' => 'what-tabs')); return $r; }
/** * Returns controls for defining the list of group members and administrators if this option is enabled. * @param array $args Form configuration arguments * @return string HTML to output */ private static function memberControls($args, $auth) { $r = ''; $class = empty(data_entry_helper::$validation_errors['groups_user:general']) ? 'control-width-5' : 'ui-state-error control-width-5'; if ($args['include_administrators']) { global $user; $me = hostsite_get_user_field('last_name') . ', ' . hostsite_get_user_field('first_name') . ' (' . $user->mail . ')'; $r .= data_entry_helper::sub_list(array('fieldname' => 'groups_user:admin_user_id', 'label' => ucfirst(lang::get('{1} administrators', self::$groupType)), 'table' => 'user', 'captionField' => 'name_and_email', 'valueField' => 'id', 'extraParams' => $auth['read'] + array('view' => 'detail'), 'helpText' => lang::get('LANG_Admins_Field_Instruct', self::$groupType), 'addToTable' => false, 'class' => $class, 'default' => array(array('fieldname' => 'groups_user:admin_user_id[]', 'default' => hostsite_get_user_field('indicia_user_id'), 'caption' => $me)))); } if ($args['include_members']) { $r .= data_entry_helper::sub_list(array('fieldname' => 'groups_user:user_id', 'label' => lang::get('Other {1} members', self::$groupType), 'table' => 'user', 'captionField' => 'name_and_email', 'valueField' => 'id', 'extraParams' => $auth['read'] + array('view' => 'detail'), 'helpText' => lang::get('LANG_Members_Field_Instruct'), 'addToTable' => false, 'class' => $class)); } if (!empty(data_entry_helper::$validation_errors['groups_user:general'])) { global $indicia_templates; $fieldname = $args['include_administrators'] ? 'groups_user:admin_user_id' : ($args['include_members'] ? 'groups_user:user_id' : ''); $template = str_replace('{class}', $indicia_templates['error_class'], $indicia_templates['validation_message']); $template = str_replace('{for}', $fieldname, $template); $r .= str_replace('{error}', lang::get(data_entry_helper::$validation_errors['groups_user:general']), $template); $r .= '<br/>'; } return $r; }
/** * Returns controls for defining the list of group members and administrators if this option is enabled. * @param array $args Form configuration arguments * @return string HTML to output */ private static function memberControls($args, $auth) { $r = ''; if ($args['include_administrators']) { $r .= data_entry_helper::sub_list(array('fieldname' => 'groups_user:admin_user_id', 'label' => ucfirst(lang::get('{1} administrators', self::$groupType)), 'table' => 'user', 'captionField' => 'person_name', 'valueField' => 'id', 'extraParams' => $auth['read'] + array('view' => 'detail'), 'helpText' => lang::get('Search for users to assign admin role to by typing a few characters of their surname'), 'addToTable' => false)); } if ($args['include_members']) { $r .= data_entry_helper::sub_list(array('fieldname' => 'groups_user:user_id', 'label' => lang::get('Other {1} members', self::$groupType), 'table' => 'user', 'captionField' => 'person_name', 'valueField' => 'id', 'extraParams' => $auth['read'] + array('view' => 'detail'), 'helpText' => lang::get('Search for users to give membership to by typing a few characters of their surname'), 'addToTable' => false)); } return $r; }
echo html::initial_value($values, 'known_subject:id'); ?> " /> <?php } ?> <input type="hidden" name="website_id" value="<?php echo html::initial_value($values, 'website_id'); ?> " /> <fieldset> <legend>Known subject details</legend> <?php $readAuth = data_entry_helper::get_read_auth(0 - $_SESSION['auth_user']->id, kohana::config('indicia.private_key')); echo data_entry_helper::sub_list(array('label' => 'Taxa', 'fieldname' => 'joinsTo:taxa_taxon_list:id', 'default' => array_key_exists('joinsTo:taxa_taxon_list:id', $values) ? $values['joinsTo:taxa_taxon_list:id'] : '', 'table' => 'taxa_taxon_list', 'view' => 'cache', 'captionField' => 'taxon', 'valueField' => 'id', 'addToTable' => false, 'extraParams' => $readAuth)); echo data_entry_helper::sub_list(array('label' => 'Identifiers', 'fieldname' => 'metaFields:identifiers', 'default' => array_key_exists('metaFields:identifiers', $values) ? $values['metaFields:identifiers'] : '', 'table' => 'identifier', 'view' => 'cache', 'captionField' => 'coded_value', 'valueField' => 'id', 'addToTable' => false, 'extraParams' => $readAuth)); echo data_entry_helper::select(array('label' => 'Subject Type', 'fieldname' => 'known_subject:subject_type_id', 'default' => html::initial_value($values, 'known_subject:subject_type_id'), 'lookupValues' => $other_data['subject_type_terms'], 'blankText' => '<Please select>', 'extraParams' => $readAuth)); echo data_entry_helper::select(array('label' => 'Website', 'fieldname' => 'known_subject:website_id', 'table' => 'website', 'captionField' => 'title', 'valueField' => 'id', 'default' => html::initial_value($values, 'known_subject:website_id'), 'extraParams' => $readAuth)); echo data_entry_helper::textarea(array('label' => 'Description', 'fieldname' => 'known_subject:description', 'class' => 'control-width-6', 'default' => html::initial_value($values, 'known_subject:description'))); ?> </fieldset> <?php if (array_key_exists('attributes', $values) && count($values['attributes']) > 0) { ?> <fieldset> <legend>Custom Attributes</legend> <ol> <?php foreach ($values['attributes'] as $attr) { $name = 'ksjAttr:' . $attr['known_subject_attribute_id']; // if this is an existing attribute, tag it with the attribute value record id so we can re-save it
/** * Define the HTML required for this filter's UI panel. * @param array $readAuth Read authorisation tokens * @param array $options * @return string * @throws \exception */ public function get_controls($readAuth, $options) { $r = ''; $familySortOrder = empty($options['familySortOrder']) ? 180 : $options['familySortOrder']; //There is only one tab when running on the Warehouse. if (!isset($options['runningOnWarehouse']) || $options['runningOnWarehouse'] == false) { $r .= "<p id=\"what-filter-instruct\">" . lang::get('You can filter by species group (first tab), a selection of families or other higher taxa (second tab), ' . 'a selection of genera or species (third tab), the level within the taxonomic hierarchy (fourth tab) or other flags such as marine taxa (fifth tab).') . "</p>\n"; } $r .= '<div id="what-tabs">' . "\n"; // data_entry_helper::tab_header breaks inside fancybox. So output manually. $r .= '<ul class="ui-helper-hidden">' . '<li id="species-group-tab-tab"><a href="#species-group-tab" rel="address:species-group-tab"><span>Species groups</span></a></li>'; if ($familySortOrder !== 'off') { $r .= '<li id="families-tab-tab"><a href="#families-tab" rel="address:families-tab"><span>Families and other higher taxa</span></a></li>'; $r .= '<li id="species-tab-tab"><a href="#species-tab" rel="address:species-tab"><span>Species and lower taxa</span></a></li>'; } else { $r .= '<li id="species-tab-tab"><a href="#species-tab" rel="address:species-tab"><span>Species</span></a></li>'; } $r .= '<li id="rank-tab-tab"><a href="#rank-tab" rel="address:rank-tab"><span>Level</span></a></li>' . '<li id="flags-tab-tab"><a href="#flags-tab" rel="address:flags-tab"><span>Other flags</span></a></li>' . '</ul>'; $r .= '<div id="species-group-tab">' . "\n"; if (function_exists('hostsite_get_user_field')) { $myGroupIds = hostsite_get_user_field('taxon_groups', array(), true); } else { $myGroupIds = array(); } if ($myGroupIds) { $r .= '<h3>' . lang::get('My groups') . '</h3>'; $myGroupsData = data_entry_helper::get_population_data(array('table' => 'taxon_group', 'extraParams' => $readAuth + array('query' => json_encode(array('in' => array('id', $myGroupIds)))))); $myGroupNames = array(); data_entry_helper::$javascript .= "indiciaData.myGroups = [];\n"; foreach ($myGroupsData as $group) { $myGroupNames[] = $group['title']; data_entry_helper::$javascript .= "indiciaData.myGroups.push([{$group['id']},'{$group['title']}']);\n"; } $r .= '<button type="button" id="my_groups">' . lang::get('Include my groups') . '</button>'; $r .= '<ul class="inline"><li>' . implode('</li><li>', $myGroupNames) . '</li></ul>'; $r .= '<h3>' . lang::get('Build a list of groups') . '</h3>'; } //Warehouse doesn't have master taxon list, so only need warning when not running on warehouse if (empty($options['taxon_list_id']) && (!isset($options['runningOnWarehouse']) || $options['runningOnWarehouse'] == false)) { throw new exception('Please specify a @taxon_list_id option in the page configuration.'); } $r .= '<p>' . lang::get('Search for and build a list of species groups to include') . '</p>' . ' <div class="context-instruct messages warning">' . lang::get('Please note that your access permissions are limiting the groups available to choose from.') . '</div>'; if (empty($options['taxon_list_id'])) { $extraParams = $readAuth; } else { $extraParams = $readAuth + array('taxon_list_id' => $options['taxon_list_id']); } $r .= data_entry_helper::sub_list(array('fieldname' => 'taxon_group_list', 'report' => 'library/taxon_groups/taxon_groups_used_in_checklist_lookup', 'captionField' => 'q', 'valueField' => 'id', 'extraParams' => $extraParams, 'addToTable' => false)); $r .= "</div>\n"; if ($familySortOrder !== 'off') { $r .= '<div id="families-tab">' . "\n"; $r .= '<p>' . lang::get('Search for and build a list of families or other higher taxa to include') . '</p>' . ' <div class="context-instruct messages warning">' . lang::get('Please note that your access permissions will limit the records returned to the species you are allowed to see.') . '</div>'; $subListOptions = array('fieldname' => 'higher_taxa_taxon_list_list', 'table' => 'cache_taxa_taxon_list', 'captionField' => 'taxon', 'valueField' => 'id', 'extraParams' => $readAuth + array('preferred' => 't', 'query' => '{"where":["taxon_rank_sort_order<=' . $familySortOrder . '"]}'), 'addToTable' => FALSE); //Use all taxa in the warehouse as there isn't an iform master list so don't need the taxon list id param if (isset($options['taxon_list_id'])) { $subListOptions['extraParams'] = array_merge(array('taxon_list_id' => $options['taxon_list_id']), $subListOptions['extraParams']); } $r .= data_entry_helper::sub_list($subListOptions); $r .= "</div>\n"; } $r .= '<div id="species-tab">' . "\n"; $r .= '<p>' . lang::get('Search for and build a list of species or genera to include.') . '</p>' . ' <div class="context-instruct messages warning">' . lang::get('Please note that your access permissions will limit the records returned to the species you are allowed to see.') . '</div>'; $rankFilter = $familySortOrder === 'off' ? array() : array('query' => '{"where":["taxon_rank_sort_order>' . $familySortOrder . '"]}'); $subListOptions = array('fieldname' => 'taxa_taxon_list_list', 'table' => 'cache_taxa_taxon_list', 'captionField' => 'taxon', 'valueField' => 'preferred_taxa_taxon_list_id', 'extraParams' => $readAuth + $rankFilter, 'addToTable' => false); //Use all taxa in the warehouse as there isn't an iform master list so don't need the taxon list id param if (isset($options['taxon_list_id'])) { $subListOptions['extraParams'] = array_merge(array('taxon_list_id' => $options['taxon_list_id']), $subListOptions['extraParams']); } $r .= data_entry_helper::sub_list($subListOptions); $r .= "</div>\n"; $r .= "<div id=\"rank-tab\">\n"; $r .= '<p id="level-label">' . lang::get('Include records where the level') . '</p>'; $r .= data_entry_helper::select(array('labelClass' => 'auto', 'fieldname' => 'taxon_rank_sort_order_op', 'lookupValues' => array('=' => lang::get('is'), '>=' => lang::get('is the same or lower than'), '<=' => lang::get('is the same or higher than')))); // we fudge this select rather than using data entry helper, since we want to allow duplicate keys which share the same sort order. We also // include both the selected ID and sort order in the key, and split it out later. $ranks = data_entry_helper::get_population_data(array('table' => 'taxon_rank', 'extraParams' => $readAuth + array('orderby' => 'sort_order', 'sortdir' => 'DESC'))); $r .= '<select id="taxon_rank_sort_order_combined" name="taxon_rank_sort_order_combined"><option value=""><' . lang::get('Please select') . '></option>'; foreach ($ranks as $rank) { $r .= "<option value=\"{$rank['sort_order']}:{$rank['id']}\">{$rank['rank']}</option>"; } $r .= '</select>'; $r .= "</div>\n"; $r .= "<div id=\"flags-tab\">\n"; $r .= '<p>' . lang::get('Select additional flags to filter for.') . '</p>' . ' <div class="context-instruct messages warning">' . lang::get('Please note that your access permissions limit the settings you can change on this tab.') . '</div>'; $r .= data_entry_helper::select(array('label' => 'Marine species', 'fieldname' => 'marine_flag', 'lookupValues' => array('all' => lang::get('Include marine and non-marine species'), 'Y' => lang::get('Only marine species'), 'N' => lang::get('Exclude marine species')))); $r .= '</div>'; $r .= "</div>\n"; data_entry_helper::enable_tabs(array('divId' => 'what-tabs')); return $r; }