本文整理汇总了PHP中data_entry_helper::date_picker方法的典型用法代码示例。如果您正苦于以下问题:PHP data_entry_helper::date_picker方法的具体用法?PHP data_entry_helper::date_picker怎么用?PHP data_entry_helper::date_picker使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类data_entry_helper
的用法示例。
在下文中一共展示了data_entry_helper::date_picker方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_form
/**
* Return the generated form output.
* @return Form HTML.
*/
public static function get_form($args)
{
$r = "<form method=\"post\">\n";
// Get authorisation tokens to update and read from the Warehouse.
$r .= data_entry_helper::get_auth(1, 'password');
$readAuth = data_entry_helper::get_read_auth($args['website_id'], $args['password']);
$r .= '<input type="hidden" name="website_id" value="' . $args['website_id'] . '" />' . "\n";
$r .= '<input type="hidden" name="sample:survey_id" value="' . $args['survey_id'] . '" />' . "\n";
$r .= "<input type=\"hidden\" id=\"record_status\" value=\"C\" />\n";
$r .= data_entry_helper::autocomplete(array('label' => 'Species', 'fieldname' => 'occurrence:taxa_taxon_list_id', 'table' => 'taxa_taxon_list', 'captionField' => 'taxon', 'valueField' => 'id', 'extraParams' => $readAuth + array('taxon_list_id' => $args['taxon_list_id'])));
$r .= data_entry_helper::date_picker(array('label' => 'Date', 'fieldname' => 'sample:date'));
$r .= data_entry_helper::map();
$r .= "<input type=\"submit\" class=\"ui-state-default ui-corner-all\" value=\"Save\" />\n";
$r .= "</form>";
return $r;
}
示例2: get_form
/**
* Return the generated form output.
* @return Form HTML.
*/
public static function get_form($args)
{
data_entry_helper::enable_tabs(array('divId' => 'controls'));
$r = "<form method=\"post\">\n";
// Get authorisation tokens to update and read from the Warehouse.
$r .= data_entry_helper::get_auth($args['website_id'], $args['password']);
$readAuth = data_entry_helper::get_read_auth($args['website_id'], $args['password']);
$r .= "<input type=\"hidden\" id=\"website_id\" name=\"website_id\" value=\"" . $args['website_id'] . "\" />\n";
$r .= "<input type=\"hidden\" id=\"record_status\" name=\"record_status\" value=\"C\" />\n";
$r .= "<div id=\"controls\">\n";
// Create a list which jQuery can parse to create the tabs.
$r .= "<ul>\r\n <li><a href=\"#recorder\"><span>Recorder</span></a></li>\r\n <li><a href=\"#site\"><span>Site</span></a></li>\r\n <li><a href=\"#species_tab_1\"><span>" . $args['tab_title_1'] . "</span></a></li>\n";
if ($args['list_id_2']) {
$r .= "<li><a href=\"#species_tab_2\"><span>" . $args['tab_title_2'] . "</span></a></li>\n";
}
if ($args['list_id_3']) {
$r .= "<li><a href=\"#species_tab_3\"><span>" . $args['tab_title_3'] . "</span></a></li>\n";
}
if ($args['list_id_4']) {
$r .= "<li><a href=\"#species_tab_4\"><span>" . $args['tab_title_4'] . "</span></a></li>\n";
}
$r .= "</ul>\n";
$r .= "<div id=\"recorder\">\n";
$r .= data_entry_helper::select(array('label' => 'Title', 'fieldname' => 'smpAttr:5', 'table' => 'termlists_term', 'captionField' => 'term', 'valueField' => 'id', 'extraParams' => $readAuth + array('termlist_external_key' => 'indicia:titles')));
$r .= data_entry_helper::text_input(array('label' => 'First name', 'fieldname' => 'smpAttr:6'));
$r .= data_entry_helper::text_input(array('label' => 'Last name', 'fieldname' => 'smpAttr:7'));
$r .= data_entry_helper::text_input(array('label' => 'Email', 'fieldname' => 'smpAttr:8'));
// Postcode before address since entering the postcode auto-populates part of the address.
$r .= data_entry_helper::postcode_textbox(array('label' => 'Postcode', 'fieldname' => 'smpAttr:10', 'linkedAddressBoxId' => 'address', 'hiddenFields' => false));
$r .= data_entry_helper::textarea(array('label' => 'Address', 'fieldname' => 'smpAttr:9', 'id' => 'address'));
$r .= "</div>\n";
$r .= "<div id=\"site\">\n";
$r .= data_entry_helper::map();
$r .= data_entry_helper::date_picker(array('label' => 'Date', 'fieldname' => 'sample:date'));
$r .= "</div>\n";
$r .= "<div id=\"species_tab_1\">\n";
$species_list_args = array('label' => 'Species', 'fieldname' => 'occurrence:taxa_taxon_list_id', 'table' => 'taxa_taxon_list', 'captionField' => 'taxon', 'valueField' => 'id', 'columns' => 2, 'extraParams' => $readAuth + array('taxon_list_id' => $args['list_id_1']));
$r .= data_entry_helper::species_checklist($species_list_args);
$r .= "</div>\n";
$r .= "</div>\n";
$r .= "<input type=\"submit\" class=\"ui-state-default ui-corner-all\" value=\"Save\" />\n";
$r .= "</form>";
return $r;
}
示例3: get_form
/**
* Return the generated form output.
* @return Form HTML.
*/
public static function get_form($args)
{
$r = "<form method=\"post\">\n";
// Get authorisation tokens to update and read from the Warehouse.
$r .= data_entry_helper::get_auth($args['website_id'], $args['password']);
$readAuth = data_entry_helper::get_read_auth($args['website_id'], $args['password']);
$r .= "<input type=\"hidden\" id=\"website_id\" name=\"website_id\" value=\"" . $args['website_id'] . "\" />\n";
$r .= "<input type=\"hidden\" id=\"record_status\" name=\"record_status\" value=\"C\" />\n";
$r .= "<div id=\"controls\">\n";
if ($args['tabs']) {
$r .= "<ul>\n <li><a href=\"#species\"><span>Species</span></a></li>\n <li><a href=\"#place\"><span>Place</span></a></li>\n <li><a href=\"#other\"><span>Other Information</span></a></li>\n </ul>\n";
data_entry_helper::enable_tabs(array('divId' => 'controls'));
}
$r .= "<div id=\"species\">\n";
$extraParams = $readAuth + array('taxon_list_id' => $args['list_id']);
if ($args['preferred']) {
$extraParams += array('preferred' => 't');
}
$species_list_args = array('label' => 'Species', 'itemTemplate' => 'select_species', 'fieldname' => 'occurrence:taxa_taxon_list_id', 'table' => 'taxa_taxon_list', 'captionField' => 'taxon', 'valueField' => 'id', 'columns' => 2, 'extraParams' => $extraParams);
// Dynamically generate the species selection control required.
$r .= call_user_func(array('data_entry_helper', $args['species_ctrl']), $species_list_args);
$r .= "</div>\n";
$r .= "<div id=\"place\">\n";
// for this form, use bing and no geoplanet lookup, since then it requires no API keys so is a good
// quick demo of how things work.
$mapOptions = array('presetLayers' => array('bing_aerial'), 'locate' => false);
if ($args['tabs']) {
$mapOptions['tabDiv'] = 'place';
}
$r .= data_entry_helper::map($mapOptions);
$r .= "</div>\n";
$r .= "<div id=\"other\">\n";
$r .= data_entry_helper::date_picker(array('label' => 'Date', 'fieldname' => 'sample:date'));
$r .= data_entry_helper::select(array('label' => 'Survey', 'fieldname' => 'sample:survey_id', 'table' => 'survey', 'captionField' => 'title', 'valueField' => 'id', 'extraParams' => $readAuth));
$r .= data_entry_helper::textarea(array('label' => 'Comment', 'fieldname' => 'sample:comment', 'class' => 'wide'));
$r .= "</div>\n";
$r .= "</div>\n";
$r .= "<input type=\"submit\" class=\"ui-state-default ui-corner-all\" value=\"Save\" />\n";
$r .= "</form>";
return $r;
}
示例4: get_occurrences_form
public static function get_occurrences_form($args, $node, $response)
{
global $user;
data_entry_helper::add_resource('jquery_form');
data_entry_helper::add_resource('jquery_ui');
data_entry_helper::add_resource('json');
data_entry_helper::add_resource('autocomplete');
$auth = data_entry_helper::get_read_write_auth($args['website_id'], $args['password']);
// did the parent sample previously exist? Default is no.
$parentSampleId = null;
$existing = false;
if (isset($_POST['sample:id'])) {
// have just posted an edit to the existing parent sample, so can use it to get the parent location id.
$parentSampleId = $_POST['sample:id'];
$existing = true;
} else {
if (isset($response['outer_id'])) {
// have just posted a new parent sample, so can use it to get the parent location id.
$parentSampleId = $response['outer_id'];
} else {
$parentSampleId = $_GET['sample_id'];
$existing = true;
}
}
if (!$parentSampleId || $parentSampleId == '') {
return 'Could not determine the parent sample.';
}
// find any attributes that apply to Timed Count Count samples.
$sampleMethods = helper_base::get_termlist_terms($auth, 'indicia:sample_methods', array('Timed Count Count'));
if (count($sampleMethods) == 0) {
return 'The sample method "Timed Count Count" must be defined in the termlist in order to use this form.';
}
$attributes = data_entry_helper::getAttributes(array('valuetable' => 'sample_attribute_value', 'attrtable' => 'sample_attribute', 'key' => 'sample_id', 'fieldprefix' => 'smpAttr', 'extraParams' => $auth['read'], 'survey_id' => $args['survey_id'], 'sample_method_id' => $sampleMethods[0]['id'], 'multiValue' => false));
if (!isset(data_entry_helper::$validation_errors)) {
// the parent sample and at least one sub-sample have already been created: can't cache in case a new subsample (Count) added.
data_entry_helper::load_existing_record($auth['read'], 'sample', $parentSampleId);
$d = new DateTime(data_entry_helper::$entity_to_load['sample:date']);
data_entry_helper::$entity_to_load['sample:date'] = $d->format('Y');
// using the report returns the attributes as well.
$subSamples = data_entry_helper::get_population_data(array('report' => 'library/samples/samples_list_for_parent_sample', 'extraParams' => $auth['read'] + array('sample_id' => $parentSampleId, 'date_from' => '', 'date_to' => '', 'sample_method_id' => '', 'smpattrs' => implode(',', array_keys($attributes))), 'nocache' => true));
// subssamples ordered by id desc, so reorder by date asc.
usort($subSamples, "iform_timed_count_subsample_cmp");
for ($i = 0; $i < count($subSamples); $i++) {
data_entry_helper::$entity_to_load['C' . ($i + 1) . ':sample:id'] = $subSamples[$i]['sample_id'];
data_entry_helper::$entity_to_load['C' . ($i + 1) . ':sample:date'] = $subSamples[$i]['date'];
// this is in correct format
foreach ($subSamples[$i] as $field => $value) {
if (preg_match('/^attr_sample_/', $field)) {
$parts = explode('_', $field);
if ($subSamples[$i]['attr_id_sample_' . $parts[2]] != null) {
data_entry_helper::$entity_to_load['C' . ($i + 1) . ':smpAttr:' + $parts[2] + ':' + $subSamples[$i]['attr_id_sample_' . $parts[2]]] = $value;
}
}
}
}
}
data_entry_helper::$javascript .= "indiciaData.speciesList = " . $args['taxon_list_id'] . ";\n";
if (!empty($args['taxon_filter_field']) && !empty($args['taxon_filter'])) {
data_entry_helper::$javascript .= "indiciaData.speciesListFilterField = '" . $args['taxon_filter_field'] . "';\n";
$filterLines = helper_base::explode_lines($args['taxon_filter']);
data_entry_helper::$javascript .= "indiciaData.speciesListFilterValues = '" . json_encode($filterLines) . "';\n";
}
data_entry_helper::$javascript .= "\r\nindiciaData.indiciaSvc = '" . data_entry_helper::$base_url . "';\n";
data_entry_helper::$javascript .= "indiciaData.readAuth = {nonce: '" . $auth['read']['nonce'] . "', auth_token: '" . $auth['read']['auth_token'] . "'};\n";
data_entry_helper::$javascript .= "indiciaData.parentSample = " . $parentSampleId . ";\n";
data_entry_helper::$javascript .= "indiciaData.occAttrId = " . $args['occurrence_attribute_id'] . ";\n";
if ($existing) {
// Only need to load the occurrences for a pre-existing sample
$o = data_entry_helper::get_population_data(array('report' => 'library/occurrences/occurrences_list_for_parent_sample', 'extraParams' => $auth['read'] + array('view' => 'detail', 'sample_id' => $parentSampleId, 'survey_id' => '', 'date_from' => '', 'date_to' => '', 'taxon_group_id' => '', 'smpattrs' => '', 'occattrs' => $args['occurrence_attribute_id']), 'nocache' => true));
// the report is ordered id desc. REverse it
$o = array_reverse($o);
} else {
$o = array();
}
// empty array of occurrences when no creating a new sample.
// we pass through the read auth. This makes it possible for the get_submission method to authorise against the warehouse
// without an additional (expensive) warehouse call.
// pass a param that sets the next page to display
$r = "<form method='post' id='subsamples'>" . $auth['write'] . "\r\n<input type='hidden' name='page' value='occurrences'/>\r\n<input type='hidden' name='read_nonce' value='" . $auth['read']['nonce'] . "'/>\r\n<input type='hidden' name='read_auth_token' value='" . $auth['read']['auth_token'] . "'/>\r\n<input type='hidden' name='website_id' value='" . $args['website_id'] . "'/>\r\n<input type='hidden' name='sample:id' value='" . data_entry_helper::$entity_to_load['sample:id'] . "'/>\r\n<input type='hidden' name='sample:survey_id' value='" . $args['survey_id'] . "'/>\r\n<input type='hidden' name='sample:date' value='" . data_entry_helper::$entity_to_load['sample:date'] . "'/>\r\n<input type='hidden' name='sample:entered_sref' value='" . data_entry_helper::$entity_to_load['sample:entered_sref'] . "'/>\r\n<input type='hidden' name='sample:entered_sref_system' value='" . data_entry_helper::$entity_to_load['sample:entered_sref_system'] . "'/>\r\n<input type='hidden' name='sample:geom' value='" . data_entry_helper::$entity_to_load['sample:geom'] . "'/>\r\n";
if (isset($args['custom_attribute_options']) && $args['custom_attribute_options']) {
$blockOptions = get_attr_options_array_with_user_data($args['custom_attribute_options']);
} else {
$blockOptions = array();
}
for ($i = 0; $i < $args['numberOfCounts']; $i++) {
$subSampleId = isset($subSamples[$i]) ? $subSamples[$i]['sample_id'] : null;
$r .= "<fieldset id=\"count-{$i}\"><legend>" . lang::get('Count ') . ($i + 1) . "</legend>";
if ($subSampleId) {
$r .= "<input type='hidden' name='C" . ($i + 1) . ":sample:id' value='" . $subSampleId . "'/>";
}
$r .= '<input type="hidden" name="C' . ($i + 1) . ':sample:sample_method_id" value="' . $sampleMethods[0]['id'] . '" />';
if ($subSampleId || isset(data_entry_helper::$entity_to_load['C' . ($i + 1) . ':sample:date']) && data_entry_helper::$entity_to_load['C' . ($i + 1) . ':sample:date'] != '') {
$dateValidation = array('required', 'date');
} else {
$dateValidation = array('date');
}
$r .= data_entry_helper::date_picker(array('label' => lang::get('Date'), 'fieldname' => 'C' . ($i + 1) . ':sample:date', 'validation' => $dateValidation));
data_entry_helper::$javascript .= "\$('#C" . ($i + 1) . "\\\\:sample\\\\:date' ).datepicker( 'option', 'minDate', new Date(" . data_entry_helper::$entity_to_load['sample:date'] . ", 1 - 1, 1) );\r\n\$('#C" . ($i + 1) . "\\\\:sample\\\\:date' ).datepicker( 'option', 'maxDate', new Date(" . data_entry_helper::$entity_to_load['sample:date'] . ", 12 - 1, 31) );\n";
if (!$subSampleId && $i) {
$r .= "<p>" . lang::get('You must enter the date before you can enter any further information.') . '</p>';
//.........这里部分代码省略.........
示例5: get_control_date
/**
* Get the date control.
*/
protected static function get_control_date($auth, $args, $tabAlias, $options)
{
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.
//Note this only affects the loading of the date itself when the form initially loads, the format displayed as soon as the
//date picker is selected is determined by Drupal's settings.
// @todo The date format should be a global configurable option.
$d = new DateTime(data_entry_helper::$entity_to_load['sample:date']);
data_entry_helper::$entity_to_load['sample:date'] = $d->format(helper_base::$date_format);
}
if ($args['language'] != 'en') {
data_entry_helper::add_resource('jquery_ui_' . $args['language']);
}
// this will autoload the jquery_ui resource. The date_picker does not have access to the args.
if (lang::get('LANG_Date_Explanation') != 'LANG_Date_Explanation') {
data_entry_helper::$javascript .= "\njQuery('[name=sample\\:date]').next().after('<span class=\"date-explanation\"> " . lang::get('LANG_Date_Explanation') . "</span>');\n";
}
return data_entry_helper::date_picker(array_merge(array('label' => lang::get('LANG_Date'), 'fieldname' => 'sample:date', 'default' => isset($args['defaults']['sample:date']) ? $args['defaults']['sample:date'] : ''), $options));
}
示例6: dateControls
/**
* Returns controls for defining the date range of a group if this option is enabled.
* @param array $args Form configuration arguments
* @return string HTML to output
*/
private static function dateControls($args)
{
$r = '';
if ($args['include_dates']) {
$r .= data_entry_helper::date_picker(array('label' => ucfirst(lang::get('{1} active from', self::$groupType)), 'fieldname' => 'group:from_Date', 'suffixTemplate' => 'nosuffix'));
$r .= data_entry_helper::date_picker(array('label' => lang::get('to'), 'fieldname' => 'group:to_Date', 'labelClass' => 'auto', 'helpText' => lang::get('Specify the period during which the {1} was active.', self::$groupType)));
}
return '';
}
示例7: get_sample_form
public static function get_sample_form($args, $node, $response)
{
global $user;
if (!module_exists('iform_ajaxproxy')) {
return 'This form must be used in Drupal with the Indicia AJAX Proxy module enabled.';
}
iform_load_helpers(array('map_helper'));
$auth = data_entry_helper::get_read_write_auth($args['website_id'], $args['password']);
$sampleId = isset($_GET['sample_id']) ? $_GET['sample_id'] : null;
$locationId = null;
if ($sampleId) {
data_entry_helper::load_existing_record($auth['read'], 'sample', $sampleId, 'detail', false, true);
$locationId = data_entry_helper::$entity_to_load['sample:location_id'];
} else {
// location ID also might be in the $_POST data after a validation save of a new record
if (isset($_POST['sample:location_id'])) {
$locationId = $_POST['sample:location_id'];
}
}
$url = explode('?', $args['my_obs_page'], 2);
$params = NULL;
$fragment = NULL;
// fragment is always at the end.
if (count($url) > 1) {
$params = explode('#', $url[1], 2);
if (count($params) > 1) {
$fragment = $params[1];
}
$params = $params[0];
} else {
$url = explode('#', $url[0], 2);
if (count($url) > 1) {
$fragment = $url[1];
}
}
$args['my_obs_page'] = url($url[0], array('query' => $params, 'fragment' => $fragment, 'absolute' => TRUE));
$r = '<form method="post" id="sample">';
$r .= $auth['write'];
$r .= '<input type="hidden" name="page" value="mainSample"/>';
$r .= '<input type="hidden" name="website_id" value="' . $args['website_id'] . '"/>';
if (isset(data_entry_helper::$entity_to_load['sample:id'])) {
$r .= '<input type="hidden" name="sample:id" value="' . data_entry_helper::$entity_to_load['sample:id'] . '"/>';
}
$r .= '<input type="hidden" name="sample:survey_id" value="' . $args['survey_id'] . '"/>';
$r .= '<div id="cols" class="ui-helper-clearfix"><div class="left" style="width: ' . (98 - (isset($args['percent_width']) ? $args['percent_width'] : 50)) . '%">';
// Output only the locations for this website and location type.
$availableSites = data_entry_helper::get_population_data(array('report' => 'library/locations/locations_list', 'extraParams' => $auth['read'] + array('website_id' => $args['website_id'], 'location_type_id' => $args['locationType'], 'locattrs' => 'CMS User ID', 'attr_location_cms_user_id' => $user->uid), 'nocache' => true));
// convert the report data to an array for the lookup, plus one to pass to the JS so it can keep the map updated
$sitesLookup = array();
$sitesIds = array();
$sitesJs = array();
foreach ($availableSites as $site) {
$sitesLookup[$site['location_id']] = $site['name'];
$sitesIds[] = $site['location_id'];
}
$sites = data_entry_helper::get_population_data(array('table' => 'location', 'extraParams' => $auth['read'] + array('website_id' => $args['website_id'], 'id' => $sitesIds, 'view' => 'detail')));
foreach ($sites as $site) {
$sitesJs[$site['id']] = $site;
}
data_entry_helper::$javascript .= "indiciaData.sites = " . json_encode($sitesJs) . ";\n";
if ($locationId) {
$r .= '<input type="hidden" name="sample:location_id" id="sample_location_id" value="' . $locationId . '"/>';
// for reload of existing, don't let the user switch the square as that could mess everything up.
$r .= '<label>' . lang::get('1km square') . ':</label><span>' . $sitesJs[$locationId]['name'] . '</span><br/>' . lang::get('<p class="ui-state-highlight page-notice ui-corner-all">Please use the map to select a more precise location for your timed observation.</p>');
} else {
$options = array('label' => lang::get('Select 1km square'), 'validation' => array('required'), 'blankText' => lang::get('Please select'), 'lookupValues' => $sitesLookup, 'id' => "sample_location_id");
// if ($locationId) $options['default'] = $locationId;
$r .= data_entry_helper::location_select($options) . lang::get('<p class="ui-state-highlight page-notice ui-corner-all">After selecting the 1km square, use the map to select a more precise location for your timed observation.</p>');
}
// [spatial reference]
$systems = array();
foreach (explode(',', str_replace(' ', '', $args['spatial_systems'])) as $system) {
$systems[$system] = lang::get("sref:{$system}");
}
$r .= data_entry_helper::sref_and_system(array('label' => lang::get('Grid Ref'), 'systems' => $systems));
$r .= data_entry_helper::file_box(array('table' => 'sample_image', 'readAuth' => $auth['read'], 'caption' => lang::get('Upload photo(s) of timed search area')));
$sampleMethods = helper_base::get_termlist_terms($auth, 'indicia:sample_methods', array('Field Observation'));
$attributes = data_entry_helper::getAttributes(array('id' => $sampleId, 'valuetable' => 'sample_attribute_value', 'attrtable' => 'sample_attribute', 'key' => 'sample_id', 'fieldprefix' => 'smpAttr', 'extraParams' => $auth['read'], 'survey_id' => $args['survey_id'], 'sample_method_id' => $sampleMethods[0]['id']));
$r .= get_user_profile_hidden_inputs($attributes, $args, '', $auth['read']);
if (isset($_GET['date'])) {
$r .= '<input type="hidden" name="sample:date" value="' . $_GET['date'] . '"/>';
$r .= '<label>' . lang::get('Date') . ':</label> <span class="value-label">' . $_GET['date'] . '</span><br/>';
} else {
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'), 'fieldname' => 'sample:date'));
}
// are there any option overrides for the custom attributes?
if (isset($args['custom_attribute_options']) && $args['custom_attribute_options']) {
$blockOptions = get_attr_options_array_with_user_data($args['custom_attribute_options']);
} else {
$blockOptions = array();
}
$r .= get_attribute_html($attributes, $args, array('extraParams' => $auth['read']), null, $blockOptions);
$r .= '<input type="hidden" name="sample:sample_method_id" value="' . $sampleMethods[0]['id'] . '" />';
$r .= '<input type="submit" value="' . lang::get('Next') . '" />';
//.........这里部分代码省略.........
示例8: get_control_identifier
//.........这里部分代码省略.........
$attr_name = 'text-colour';
} elseif ($attribute['attrType'] === 'idn' && $options['positionId'] == $attribute['typeId']) {
$attr_name = 'position';
if (count($args['position']) > 0) {
// filter the identifier position available
$query = array('in' => array('id', $args['position']));
}
} elseif ($attribute['attrType'] === 'idn' && $options['sequenceId'] == $attribute['typeId']) {
$attr_name = 'sequence';
$options['maxlength'] = $options['seq_maxlength'] ? $options['seq_maxlength'] : '';
if ($options['seq_format_class']) {
$options['class'] = empty($options['class']) ? $options['seq_format_class'] : (strstr($options['class'], $options['seq_format_class']) ? $options['class'] : $options['class'] . ' ' . $options['seq_format_class']);
}
} elseif ($attribute['attrType'] === 'iso' && $options['conditionsId'] == $attribute['typeId']) {
// filter the identifier conditions available
if ($options['identifierTypeId'] == $args['neck_collar_type'] && !empty($args['neck_collar_conditions'])) {
$query = array('in' => array('id', $args['neck_collar_conditions']));
} elseif ($options['identifierTypeId'] == $args['enscribed_colour_ring_type'] && !empty($args['coloured_ring_conditions'])) {
$query = array('in' => array('id', $args['coloured_ring_conditions']));
} elseif ($options['identifierTypeId'] == $args['metal_ring_type'] && !empty($args['metal_ring_conditions'])) {
$query = array('in' => array('id', $args['metal_ring_conditions']));
}
$attr_name = 'conditions';
}
// add classes as identifiers
$options['class'] = empty($options['class']) ? $options['classprefix'] . $attr_name : (strstr($options['class'], $options['classprefix'] . $attr_name) ? $options['class'] : $options['class'] . ' ' . $options['classprefix'] . $attr_name);
$options['class'] = $options['class'] . ' idn-' . $attr_name;
if ($attribute['attrType'] === 'idn' && ($options['baseColourId'] == $attribute['typeId'] || $options['textColourId'] == $attribute['typeId'])) {
$options['class'] = strstr($options['class'], 'select_colour') ? $options['class'] : $options['class'] . ' select_colour';
$options['class'] = strstr($options['class'], 'textAndBaseMustDiffer') ? $options['class'] : $options['class'] . ' textAndBaseMustDiffer';
}
if ($attribute['attrType'] === 'idn' && $options['sequenceId'] == $attribute['typeId']) {
$options['class'] = strstr($options['class'], 'identifier_sequence') ? $options['class'] : $options['class'] . ' identifier_sequence';
}
if (!empty($attribute['hidden']) && $attribute['hidden'] === true) {
$dataType = 'H';
// hidden
if (!empty($attribute['hiddenValue'])) {
$dataDefault = $attribute['hiddenValue'];
} else {
$dataDefault = '';
}
} else {
$dataType = $attrType['data_type'];
}
// output an appropriate control for the attribute data type
switch ($dataType) {
case 'D':
case 'V':
$r .= data_entry_helper::date_picker(array_merge(array('label' => lang::get($attrType['caption']), 'fieldname' => $fieldPrefix . $attribute['attrType'] . 'Attr:' . $attrType['id']), $options));
break;
case 'L':
$filter = array('termlist_id' => $attrType['termlist_id']);
if (!empty($query)) {
$filter += array('query' => json_encode($query));
}
$extraParams = array_merge($filter, $auth['read']);
if ($attribute['attrType'] === 'iso' && $options['conditionsId'] == $attribute['typeId']) {
$fieldname = $fieldPrefix . $attribute['attrType'] . 'Attr:' . $attrType['id'];
$default = array();
// if this attribute exists on DB, we need to write a hidden with id appended to fieldname and set defaults for checkboxes
if (is_array(data_entry_helper::$entity_to_load)) {
$stored_keys = preg_grep('/^' . $fieldname . ':[0-9]+$/', array_keys(data_entry_helper::$entity_to_load));
foreach ($stored_keys as $stored_key) {
$r .= '<input type="hidden" name="' . $stored_key . '" value="" />';
$default[] = array('fieldname' => $stored_key, 'default' => data_entry_helper::$entity_to_load[$stored_key]);
unset(data_entry_helper::$entity_to_load[$stored_key]);
}
}
$r .= data_entry_helper::checkbox_group(array_merge(array('label' => lang::get($attrType['caption']), 'fieldname' => $fieldname, 'table' => 'termlists_term', 'captionField' => 'term', 'valueField' => 'id', 'default' => $default, 'extraParams' => $extraParams), $options));
} else {
$r .= data_entry_helper::select(array_merge(array('label' => lang::get($attrType['caption']), 'fieldname' => $fieldPrefix . $attribute['attrType'] . 'Attr:' . $attrType['id'], 'table' => 'termlists_term', 'captionField' => 'term', 'valueField' => 'id', 'blankText' => '<Please select>', 'extraParams' => $extraParams), $options));
}
break;
case 'B':
$r .= data_entry_helper::checkbox(array_merge(array('label' => lang::get($attrType['caption']), 'fieldname' => $fieldPrefix . $attribute['attrType'] . 'Attr:' . $attrType['id']), $options));
break;
case 'H':
// Any multi-value attributes shown as hidden will be single-valued
// so transform the array to a scalar
$fieldname = $fieldPrefix . $attribute['attrType'] . 'Attr:' . $attrType['id'];
if (!empty(data_entry_helper::$entity_to_load[$fieldname]) && is_array(data_entry_helper::$entity_to_load[$fieldname])) {
data_entry_helper::$entity_to_load[$fieldname] = data_entry_helper::$entity_to_load[$fieldname][0];
}
$r .= data_entry_helper::hidden_text(array_merge(array('fieldname' => $fieldname, 'default' => $dataDefault), $options));
break;
default:
$r .= data_entry_helper::text_input(array_merge(array('label' => lang::get($attrType['caption']), 'fieldname' => $fieldPrefix . $attribute['attrType'] . 'Attr:' . $attrType['id']), $options));
}
$options['class'] = $classes;
if (isset($options['maxlength'])) {
unset($options['maxlength']);
}
if (isset($options['lockable'])) {
unset($options['lockable']);
}
}
$r .= '</div>';
return $r;
}
示例9: get_form
//.........这里部分代码省略.........
$r .= "<div id=\"controls\">\n";
if ($args['interface'] != 'one_page') {
$r .= "<ul>\n";
if (!$logged_in) {
$r .= ' <li><a href="#about_you"><span>' . lang::get('LANG_About_You_Tab') . "</span></a></li>\n";
}
$r .= ' <li><a href="#species"><span>' . lang::get('LANG_Species_Tab') . "</span></a></li>\n";
$r .= ' <li><a href="#place"><span>' . lang::get('LANG_Place_Tab') . "</span></a></li>\n";
$r .= ' <li><a href="#other"><span>' . lang::get('LANG_Other_Information_Tab') . "</span></a></li>\n";
$r .= "</ul>\n";
data_entry_helper::enable_tabs(array('divId' => 'controls', 'style' => $args['interface']));
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////
if (!$logged_in) {
$r .= "<div id=\"about_you\">\n";
$r .= '<p class="page-notice ui-state-highlight ui-corner-all">' . lang::get('LANG_About_You_Tab_Instructions') . "</p>";
$defAttrOptions['class'] = 'control-width-4';
$r .= data_entry_helper::outputAttribute($attributes[$args['first_name_attr_id']], $defAttrOptions);
$r .= data_entry_helper::outputAttribute($attributes[$args['surname_attr_id']], $defAttrOptions);
$r .= data_entry_helper::outputAttribute($attributes[$args['email_attr_id']], $defAttrOptions);
$r .= data_entry_helper::outputAttribute($attributes[$args['phone_attr_id']], $defAttrOptions);
if ($args['interface'] == 'wizard') {
$r .= data_entry_helper::wizard_buttons(array('divId' => 'controls', 'page' => 'first'));
}
unset($defAttrOptions['class']);
$r .= "</div>\n";
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////
global $indicia_templates;
$indicia_templates['taxon_label'] = '<div class="biota"><span class="nobreak sci binomial"><em>{taxon}</em></span> {authority}</div>';
$r .= "<div id=\"species\">\n";
$r .= '<p class="page-notice ui-state-highlight ui-corner-all">' . lang::get('LANG_Species_Tab_Instructions') . "</p>";
$extraParams = $readAuth + array('taxon_list_id' => $args['list_id']);
$species_list_args = array('label' => lang::get('occurrence:taxa_taxon_list_id'), 'fieldname' => 'occurrence:taxa_taxon_list_id', 'table' => 'taxa_taxon_list', 'captionField' => 'taxon', 'valueField' => 'id', 'columns' => 1, 'view' => 'detail', 'parentField' => 'parent_id', 'occAttrs' => explode(',', $args['checklist_attributes']), 'extraParams' => $extraParams, 'survey_id' => $args['survey_id']);
$r .= data_entry_helper::species_checklist($species_list_args);
$r .= "<label for=\"sample:comment\">" . lang::get('LANG_Sample_Comment_Label') . "</label><input type=\"text\" id=\"sample:comment\" name=\"sample:comment\" value=\"" . data_entry_helper::$entity_to_load['sample:comment'] . "\" />\n";
if ($args['interface'] == 'wizard') {
$r .= data_entry_helper::wizard_buttons(array('divId' => 'controls', 'page' => $user->id == 0 ? 'first' : 'middle'));
}
$r .= "</div>\n";
////////////////////////////////////////////////////////////////////////////////////////////////////////////
$r .= "<div id=\"place\">\n";
$r .= '<p class="page-notice ui-state-highlight ui-corner-all">' . lang::get('LANG_Place_Tab_Instructions') . "</p>";
// Build the array of spatial reference systems into a format Indicia can use.
$systems = array();
$list = explode(',', str_replace(' ', '', $args['spatial_systems']));
foreach ($list as $system) {
$systems[$system] = lang::get($system);
}
$r .= data_entry_helper::sref_and_system(array('label' => lang::get('LANG_SRef_Label'), 'systems' => $systems));
$location_list_args = array('label' => lang::get('LANG_Location_Label'), 'view' => 'detail', 'extraParams' => array_merge(array('view' => 'detail', 'orderby' => 'name'), $extraParams));
$r .= call_user_func(array('data_entry_helper', $args['location_ctrl']), $location_list_args);
$r .= data_entry_helper::georeference_lookup(array('label' => lang::get('LANG_Georef_Label'), 'georefPreferredArea' => $args['georefPreferredArea'], 'georefCountry' => $args['georefCountry'], 'georefLang' => $args['language']));
$options = iform_map_get_map_options($args, $readAuth);
$options['layers'][] = 'locationLayer';
$olOptions = iform_map_get_ol_options($args);
$r .= data_entry_helper::map_panel($options, $olOptions);
if ($args['interface'] == 'wizard') {
$r .= data_entry_helper::wizard_buttons(array('divId' => 'controls'));
}
$r .= "</div>\n";
////////////////////////////////////////////////////////////////////////////////////////////////////////////
$r .= "<div id=\"other\">\n";
$r .= '<p class="page-notice ui-state-highlight ui-corner-all">' . lang::get('LANG_Other_Information_Tab_Instructions') . "</p>";
$r .= data_entry_helper::date_picker(array('label' => lang::get('LANG_Date'), 'fieldname' => 'sample:date'));
$r .= data_entry_helper::outputAttribute($attributes[$args['biotope_attr_id']], $defAttrOptions);
$r .= data_entry_helper::outputAttribute($attributes[$args['voucher_attr_id']], $defAttrOptions);
$values = array('I', 'C');
// not initially doing V=Verified
$r .= '<label for="occurrence:record_status">' . lang::get('LANG_Record_Status_Label') . '</label><select id="occurrence:record_status" name="occurrence:record_status">';
foreach ($values as $value) {
$r .= '<option value="' . $value . '"';
if (isset(data_entry_helper::$entity_to_load['occurrence:record_status'])) {
if (data_entry_helper::$entity_to_load['occurrence:record_status'] == $value) {
$r .= ' selected="selected"';
}
}
$r .= '>' . lang::get('LANG_Record_Status_' . $value) . '</option>';
}
$r .= '</select>';
// TODO image upload - not sure how to do this as images are attached to occurrences, and occurrences
// are embedded in the species list.
// $r .= "<label for='occurrence:image'>".lang::get('LANG_Image_Label')."</label>\n".
// data_entry_helper::image_upload('occurrence:image');
$r .= '<br/><br/>';
if ($args['interface'] == 'wizard') {
$r .= data_entry_helper::wizard_buttons(array('divId' => 'controls', 'page' => 'last'));
} else {
$r .= "<input type=\"submit\" class=\"ui-state-default ui-corner-all\" value=\"" . lang::get('LANG_Save') . "\" />\n";
}
$r .= "</div>\n";
$r .= "</div>\n";
if (!empty(data_entry_helper::$validation_errors)) {
$r .= data_entry_helper::dump_remaining_errors();
}
$r .= "</form>";
// may need to keep following code for location change functionality
data_entry_helper::$onload_javascript .= "\n \nlocationChange = function(obj){\n\tlocationLayer.destroyFeatures();\n\tif(obj.value != ''){\n\t\tjQuery.getJSON(\"" . $svcUrl . "\" + \"/data/location/\"+obj.value +\n\t\t\t\"?mode=json&view=detail&auth_token=" . $readAuth['auth_token'] . "&nonce=" . $readAuth["nonce"] . "\" +\n\t\t\t\"&callback=?\", function(data) {\n if (data.length>0) {\n \tvar parser = new OpenLayers.Format.WKT();\n \tfor (var i=0;i<data.length;i++)\n\t\t\t\t{\n\t \t\t\tif(data[i].centroid_geom){\n\t\t\t\t\t\tfeature = parser.read(data[i].centroid_geom);\n\t\t\t\t\t\tcentre = feature.geometry.getCentroid();\n\t\t\t\t\t\tcentrefeature = new OpenLayers.Feature.Vector(centre, {}, {label: data[i].name});\n\t\t\t\t\t\tlocationLayer.addFeatures([feature, centrefeature]); \n\t\t\t\t\t}\n\t\t\t\t\tif(data[i].boundary_geom){\n\t\t\t\t\t\tfeature = parser.read(data[i].boundary_geom);\n\t\t\t\t\t\tfeature.style = {strokeColor: \"Blue\",\n \t \tstrokeWidth: 2,\n \t\t\t\t\t\t\tlabel: (data[i].centroid_geom ? \"\" : data[i].name)};\n\t\t\t\t\t\tlocationLayer.addFeatures([feature]);\n \t\t\t\t\t}\n \t\t\t\tlocationLayer.map.zoomToExtent(locationLayer.getDataExtent());\n \t\t\t\t}\n\t\t\t}\n\t\t});\n }\n};\njQuery('#imp-location').unbind('change');\njQuery('#imp-location').change(function(){\n\tlocationChange(this);\n});\n// upload location & sref initial values into map.\njQuery('#imp-location').change();\njQuery('#imp-sref').change();\n\n";
return $r;
}
示例10: get_form
//.........这里部分代码省略.........
}
$r .= "</fieldset>\n";
}
// the species tab is ommitted if the page is called with a taxon in the querystring parameters
if (isset($taxa_taxon_list_id)) {
$r .= "<input type=\"hidden\" name=\"occurrence:taxa_taxon_list_id\" value=\"{$taxa_taxon_list_id}\"/>\n";
} else {
$r .= "<fieldset id=\"species\">\n";
$r .= '<p class="page-notice ui-state-highlight ui-corner-all">' . lang::get('species tab instructions') . "</p>";
$extraParams = $readAuth + array('taxon_list_id' => $args['list_id']);
if ($args['preferred']) {
$extraParams += array('preferred' => 't');
}
if ($args['restrict_species_to_users_lang']) {
$extraParams += array('language_iso' => iform_lang_iso_639_2($user->lang));
}
$species_list_args = array('label' => lang::get('occurrence:taxa_taxon_list_id'), 'fieldname' => 'occurrence:taxa_taxon_list_id', 'table' => 'taxa_taxon_list', 'captionField' => 'taxon', 'valueField' => 'id', 'columns' => 2, 'view' => 'detail', 'parentField' => 'parent_id', 'extraParams' => $extraParams);
if ($args['species_ctrl'] == 'tree_browser') {
// change the node template to include images
global $indicia_templates;
$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', $args['species_ctrl']), $species_list_args);
if ($args['interface'] == 'wizard') {
$r .= data_entry_helper::wizard_buttons(array('divId' => 'controls', 'page' => $user->id == 0 ? 'first' : 'middle'));
}
$r .= "</fieldset>\n";
}
$r .= "<fieldset id=\"place\">\n";
// Output all our hidden data here, because this tab is always present
$r .= $auth['write'];
if ($logged_in) {
// If logged in, output some hidden data about the user
$r .= iform_user_get_hidden_inputs($args);
}
// if the species being recorded is a fixed species defined in the URL, then output a hidden
if (isset($taxa_taxon_list_id)) {
$r .= "<input type=\"hidden\" name=\"occurrence:taxa_taxon_list_id'\" value=\"" . $taxa_taxon_list_id . "\" />\n";
}
$r .= "<input type=\"hidden\" name=\"website_id\" value=\"" . $args['website_id'] . "\" />\n";
$r .= "<input type=\"hidden\" name=\"survey_id\" value=\"" . $args['survey_id'] . "\" />\n";
$r .= "<input type=\"hidden\" name=\"record_status\" value=\"" . $args['record_status'] . "\" />\n";
$r .= '<p class="page-notice ui-state-highlight ui-corner-all">' . lang::get('place tab instructions') . "</p>";
// Build the array of spatial reference systems into a format Indicia can use.
$systems = array();
$list = explode(',', str_replace(' ', '', $args['spatial_systems']));
foreach ($list as $system) {
$systems[$system] = lang::get($system);
}
$r .= data_entry_helper::georeference_lookup(iform_map_get_georef_options($args, $auth['read']));
$r .= data_entry_helper::sref_and_system(array('label' => lang::get('sample:entered_sref'), 'systems' => $systems));
// retrieve options for the IndiciaMapPanel, and optionally options for OpenLayers.
$options = iform_map_get_map_options($args, $readAuth);
$options['tabDiv'] = 'place';
$olOptions = iform_map_get_ol_options($args);
$options['scroll_wheel_zoom'] = false;
$r .= data_entry_helper::map_panel($options, $olOptions);
if ($args['interface'] == 'wizard') {
$r .= data_entry_helper::wizard_buttons(array('divId' => 'controls', 'page' => $user->id == 0 && isset($taxa_taxon_list_id) ? 'first' : 'middle'));
}
$r .= "</fieldset>\n";
$r .= "<fieldset id=\"other\">\n";
$r .= '<p class="page-notice ui-state-highlight ui-corner-all">' . lang::get('other tab instructions') . "</p>";
$r .= data_entry_helper::date_picker(array('label' => lang::get('Date'), 'fieldname' => 'sample:date'));
$r .= data_entry_helper::file_box(array('caption' => 'Upload your photos', 'readAuth' => $readAuth, 'resizeWidth' => 1024, 'resizeHeight' => 768, 'table' => 'occurrence_image', 'tabDiv' => 'other', 'runtimes' => array('html5', 'html4')));
// Dynamically create a control for the abundance, unless overridden for this species
if (isset($species) && count($species) > 0 && trim($args['abundance_overrides']) !== '') {
$overrides = explode("\n", $args['abundance_overrides']);
foreach ($overrides as $override) {
$tokens = explode(':', $override);
if ($tokens[0] == $species[0]['taxon']) {
// remove the default abundance attribute behaviour
$args['abundance_attr_id'] = '';
if (trim($tokens[1]) !== '') {
$attrIds = explode(',', $tokens[1]);
$attributes = data_entry_helper::getAttributes(array('id' => null, 'valuetable' => 'occurrence_attribute_value', 'attrtable' => 'occurrence_attribute', 'key' => 'occurrence_id', 'fieldprefix' => "occAttr", 'extraParams' => $readAuth + array('query' => urlencode(json_encode(array('in' => array('id', $attrIds))))), 'survey_id' => $args['survey_id']));
foreach ($attributes as $attribute) {
$r .= data_entry_helper::outputAttribute($attribute, array('language' => iform_lang_iso_639_2($user->lang), 'booleanCtrl' => 'checkbox'));
}
}
}
}
}
if (!empty($args['abundance_attr_id'])) {
$abundance_args = array('label' => lang::get('abundance'), 'fieldname' => 'occAttr:' . $args['abundance_attr_id'], 'table' => 'termlists_term', 'captionField' => 'term', 'valueField' => 'id', 'extraParams' => $readAuth + array('termlist_id' => $args['abundance_termlist_id']), 'size' => 6, 'sep' => '<br/>');
$r .= call_user_func(array('data_entry_helper', $args['abundance_ctrl']), $abundance_args);
}
$r .= data_entry_helper::textarea(array('label' => lang::get('sample:comment'), 'fieldname' => 'sample:comment', 'class' => 'wide'));
$r .= '<div class="footer">' . data_entry_helper::checkbox(array('label' => lang::get('happy for contact'), 'labelClass' => 'auto', 'fieldname' => 'smpAttr:' . $args['contact_attr_id'])) . '</div>';
if ($args['interface'] == 'wizard') {
$r .= data_entry_helper::wizard_buttons(array('divId' => 'controls', 'page' => 'last'));
} else {
$r .= "<input type=\"submit\" class=\"ui-state-default ui-corner-all\" value=\"Save\" />\n";
}
$r .= "</fieldset>\n";
$r .= "</div>\n";
$r .= "</form>";
return $r;
}
示例11: array
);
}
</script>
</head>
<body>
<div id="wrap">
<h1>Record Card Header</h1>
<p>Please enter summary information for your record card below.</p>
<form action="list.php" method="post">
<fieldset>
<legend>Card Header</legend>
<label for="date">Date:</label>
<?php
echo data_entry_helper::date_picker('sample:date');
?>
<br/>
<div id="map"></div>
<div id="panel" class="olControlPanel"></div><span id="mousePos"></span>
<label for="smpAttr:1">Weather:</label>
<input type="text" id="smpAttr:1" name="smpAttr:1" class="wide" />
<br/>
<label for="smpAttr:3">Surroundings:</label>
<?php
echo data_entry_helper::select("smpAttr:3", 'termlists_term', 'term', 'id', $readAuth + array('termlist_id' => 2));
?>
<br/>
<input type="submit" value="Next" class="auto" />
</fieldset>
</form>
示例12:
// Get authorisation tokens to update and read from the Warehouse.
$auth = data_entry_helper::get_read_write_auth($config['website_id'], $config['password']);
echo $auth['write'];
$readAuth = $auth['read'];
?>
<input type='hidden' name='website_id' value='<?php
echo $config['website_id'];
?>
' />
<input type='hidden' name='survey_id' value='<?php
echo $config['survey_id'];
?>
' />
<input type='hidden' name='occurrence:record_status' value='C' />
<?php
echo data_entry_helper::date_picker(array('label' => 'Date', 'fieldname' => 'sample:date'));
echo data_entry_helper::sref_and_system(array('label' => 'Grid Ref', 'fieldname' => 'sample:entered_sref'));
?>
<div class="smaller">
<?php
echo data_entry_helper::species_checklist(array('listId' => $config['species_checklist_taxon_list'], 'lookupListId' => $config['species_checklist_alt_list'], 'extraParams' => $readAuth, 'survey_id' => $config['survey_id']));
?>
</div>
<br />
<input type='submit' value='Save' />
</form>
</div>
</body>
<?php
echo data_entry_helper::dump_javascript();
示例13: foreach
if (array_key_exists('attributes', $values) && count($values['attributes']) > 0) {
?>
<fieldset>
<legend>Custom Attributes</legend>
<ol>
<?php
foreach ($values['attributes'] as $attr) {
$name = 'idnAttr:' . $attr['identifier_attribute_id'];
// if this is an existing attribute, tag it with the attribute value record id so we can re-save it
if ($attr['id']) {
$name .= ':' . $attr['id'];
}
switch ($attr['data_type']) {
case 'D':
case 'V':
echo data_entry_helper::date_picker(array('label' => $attr['caption'], 'fieldname' => $name, 'default' => $attr['value']));
break;
case 'L':
echo data_entry_helper::select(array('label' => $attr['caption'], 'fieldname' => $name, 'default' => $attr['raw_value'], 'lookupValues' => $values['terms_' . $attr['termlist_id']], 'blankText' => '<Please select>'));
break;
case 'B':
echo data_entry_helper::checkbox(array('label' => $attr['caption'], 'fieldname' => $name, 'default' => $attr['value']));
break;
default:
echo data_entry_helper::text_input(array('label' => $attr['caption'], 'fieldname' => $name, 'default' => $attr['value']));
}
}
?>
</ol>
</fieldset>
<?php
示例14: get_form
/**
* Return the generated form output.
* @param array $args List of parameter values passed through to the form depending on how the form has been configured.
* This array always contains a value for language.
* @param object $nid The Drupal node object's ID.
* @param array $response When this form is reloading after saving a submission, contains the response from the service call.
* Note this does not apply when redirecting (in this case the details of the saved object are in the $_GET data).
* @return Form HTML.
*/
public static function get_form($args, $nid, $response = null)
{
drupal_add_js(iform_client_helpers_path() . "prebuilt_forms/js/easy_download_2.js");
drupal_add_css(iform_client_helpers_path() . "prebuilt_forms/css/easy_download_2.css");
$conn = iform_get_connection_details($nid);
$args = array_merge(array('download_administered_groups' => 'indicia data admin', 'download_group_types' => ''), $args);
$readAuth = data_entry_helper::get_read_auth($conn['website_id'], $conn['password']);
if (data_entry_helper::$js_read_tokens === null) {
data_entry_helper::$js_read_tokens = $readAuth;
}
if (!empty($_POST) && !empty($_POST['format'])) {
self::do_data_services_download($args, $nid);
}
$types = self::get_download_types($args);
$formats = self::get_download_formats($args);
if (count($types) === 0) {
return 'This download page is configured so that no download type options are available.';
}
if (count($formats) === 0) {
return 'This download page is configured so that no download format options are available.';
}
$reload = data_entry_helper::get_reload_link_parts();
$reloadPath = $reload['path'];
if (count($reload['params'])) {
$reloadPath .= '?' . helper_base::array_to_query_string($reload['params']);
}
$r = '<form method="POST" action="' . $reloadPath . '">';
$r .= '<fieldset id="download-type-fieldset"><legend>' . lang::get('Records to download') . '</legend>';
if (count($types) === 1) {
$r .= '<input type="hidden" name="download-type" id="download-type" value="' . implode('', array_keys($types)) . '"/>';
hostsite_set_page_title(lang::get('Download {1}', strtolower(implode('', $types))));
} else {
$r .= data_entry_helper::select(array('fieldname' => 'download-type', 'label' => lang::get('Download type'), 'lookupValues' => $types, 'class' => 'control-width-5', 'helpText' => 'Select the type of download you require, i.e. the purpose for the data. This defines which records are available to download.'));
}
$r .= data_entry_helper::select(array('fieldname' => 'download-subfilter', 'label' => lang::get('Filter to apply'), 'lookupValues' => array(), 'class' => 'control-width-5', 'helpText' => lang::get('Optionally select from the available filters. Filters you create on the Explore pages will be available here.')));
$r .= "</fieldset>\n";
$r .= '<fieldset><legend>' . lang::get('Limit the records') . '</legend>';
// Hub
// TODO may run into URL size limits
$vocabulary = taxonomy_vocabulary_machine_name_load('hubs');
$terms = entity_load('taxonomy_term', FALSE, array('vid' => $vocabulary->vid));
// the hub is driven by a user field, stored as tid.
$hubList = array('' => lang::get('<All>'));
foreach ($terms as $term) {
// TODO Cache
$query = new EntityFieldQuery();
$query->entityCondition('entity_type', 'user')->fieldCondition('field_preferred_training_hub', 'tid', $term->tid);
$result = $query->execute();
// This gives us the list of users which are in the hub: CMS user ID: now convert to indicia user id
$userIDList = array();
if (count($result) > 0) {
$cmsUserIDs = array_keys($result['user']);
foreach ($cmsUserIDs as $cmsUserID) {
$user_data = user_load($cmsUserID);
// TODO Making assumption about language
if (!empty($user_data->field_indicia_user_id['und'][0]['value'])) {
$userIDList[] = $user_data->field_indicia_user_id['und'][0]['value'];
}
}
if (count($userIDList) > 0) {
$hubList[implode(',', $userIDList)] = $term->tid . ' ' . $term->name;
}
}
}
$r .= data_entry_helper::select(array('fieldname' => 'user_id_list', 'label' => lang::get('Hub to include'), 'helpText' => 'Choose a Hub, or <All> to not filter by Hub. This is driven off the users currently allocated to the hub. This currently does not apply to the NBN download.', 'lookupValues' => $hubList, 'class' => 'control-width-5'));
// End Cocoast Hub
if (empty($args['survey_id'])) {
// put up an empty surveys drop down. AJAX will populate it.
$r .= data_entry_helper::select(array('fieldname' => 'survey_id', 'label' => lang::get('Survey to include'), 'helpText' => 'Choose a survey, or <All> to not filter by survey.', 'lookupValues' => array(), 'class' => 'control-width-5'));
} else {
$r .= '<input type="hidden" name="survey_id" value="' . $args['survey_id'] . '"/>';
}
// Let the user pick the date range to download.
$r .= data_entry_helper::select(array('label' => lang::get('Date field'), 'fieldname' => 'date_type', 'lookupValues' => array('recorded' => lang::get('Field record date'), 'input' => lang::get('Input date'), 'edited' => lang::get('Last changed date'), 'verified' => 'Verification status change date'), 'helpText' => 'If filtering on date, which date field would you like to filter on?'));
$r .= data_entry_helper::date_picker(array('fieldname' => 'date_from', 'label' => lang::get('Start Date'), 'helpText' => 'Leave blank for no start date filter', 'class' => 'control-width-4'));
$r .= data_entry_helper::date_picker(array('fieldname' => 'date_to', 'label' => lang::get('End Date'), 'helpText' => 'Leave blank for no end date filter', 'class' => 'control-width-4'));
$r .= '</fieldset>';
if (!empty($args['custom_formats'])) {
$customFormats = json_decode($args['custom_formats'], true);
foreach ($customFormats as $idx => $format) {
if (empty($format['permission']) || hostsite_user_has_permission($format['permission'])) {
$formats["custom-{$idx}"] = lang::get(isset($format['title']) ? $format['title'] : 'Untitled format');
}
}
}
if (count($formats) > 1) {
$r .= '<fieldset><legend>' . lang::get('Select a format to download') . '</legend>';
$keys = array_keys($formats);
$r .= data_entry_helper::radio_group(array('fieldname' => 'format', 'lookupValues' => $formats, 'default' => $keys[0]));
$r .= '</fieldset>';
} else {
//.........这里部分代码省略.........
示例15: get_form
//.........这里部分代码省略.........
if ($locations == 'all') {
$locOptions = array_merge(array('label' => lang::get('LANG_Transect')), $defAttrOptions);
$locOptions['extraParams'] = array_merge(array('parent_id' => 'NULL', 'view' => 'detail', 'orderby' => 'name'), $locOptions['extraParams']);
$r .= data_entry_helper::location_select($locOptions);
} else {
// can't use location select due to location filtering.
$r .= "<label for=\"imp-location\">" . lang::get('LANG_Transect') . ":</label>\n<select id=\"imp-location\" name=\"sample:location_id\" " . $disabled_text . " class=\" \" >";
$url = $svcUrl . '/data/location';
$url .= "?mode=json&view=detail&parent_id=NULL&orderby=name&auth_token=" . $readAuth['auth_token'] . "&nonce=" . $readAuth["nonce"];
$session = curl_init($url);
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
$entities = json_decode(curl_exec($session), true);
if (!empty($entities)) {
foreach ($entities as $entity) {
if (in_array($entity["id"], $locations)) {
if ($entity["id"] == data_entry_helper::$entity_to_load['sample:location_id']) {
$selected = 'selected="selected"';
} else {
$selected = '';
}
$r .= "<option value=\"" . $entity["id"] . "\" " . $selected . ">" . $entity["name"] . "</option>";
}
}
}
$r .= "</select><span class=\"deh-required\">*</span><br />";
}
$languageFilteredAttrOptions = $defAttrOptions + array('language' => iform_lang_iso_639_2($args['language']));
$r .= data_entry_helper::outputAttribute($attributes[$args['sample_walk_direction_id']], $languageFilteredAttrOptions);
$r .= data_entry_helper::outputAttribute($attributes[$args['sample_reliability_id']], $languageFilteredAttrOptions);
$r .= data_entry_helper::outputAttribute($attributes[$args['sample_visit_number_id']], array_merge($languageFilteredAttrOptions, array('default' => 1, 'noBlankText' => true)));
if ($readOnly) {
$r .= data_entry_helper::text_input(array_merge($defAttrOptions, array('label' => lang::get('LANG_Date'), 'fieldname' => 'sample:date', 'disabled' => $disabledText)));
} else {
$r .= data_entry_helper::date_picker(array('label' => lang::get('LANG_Date'), 'fieldname' => 'sample:date', 'class' => 'vague-date-picker', 'suffixTemplate' => 'requiredsuffix'));
}
$r .= data_entry_helper::outputAttribute($attributes[$args['sample_wind_id']], $languageFilteredAttrOptions);
$r .= data_entry_helper::outputAttribute($attributes[$args['sample_precipitation_id']], $languageFilteredAttrOptions);
$r .= data_entry_helper::outputAttribute($attributes[$args['sample_temperature_id']], array_merge($defAttrOptions, array('suffixTemplate' => 'nosuffix')));
$r .= " degC<span class=\"deh-required\">*</span><br />";
$r .= data_entry_helper::outputAttribute($attributes[$args['sample_cloud_id']], $defAttrOptions);
$r .= data_entry_helper::outputAttribute($attributes[$args['sample_start_time_id']], array_merge($defAttrOptions, array('suffixTemplate' => 'nosuffix')));
$r .= " hh:mm<span class=\"deh-required\">*</span><br />";
$r .= data_entry_helper::outputAttribute($attributes[$args['sample_end_time_id']], array_merge($defAttrOptions, array('suffixTemplate' => 'nosuffix')));
$r .= " hh:mm<span class=\"deh-required\">*</span><br />";
unset($defAttrOptions['suffixTemplate']);
unset($defAttrOptions['validation']);
if (user_access($adminPerm)) {
// users with admin permissions can override the closing of the
// sample by unchecking the checkbox.
// Because this is attached to the sample, we have to include the sample required fields in the
// the post. This means they can't be disabled, so we enable all fields in this case.
// Normal users can only set this to closed, and they do this using a button/hidden field.
$r .= data_entry_helper::outputAttribute($attributes[$args['sample_closure_id']], $defAttrOptions);
} else {
// hidden closed
$r .= "<input type=\"hidden\" id=\"" . $closedFieldName . "\" name=\"" . $closedFieldName . "\" value=\"" . $closedFieldValue . "\" />\n";
}
if (!empty(data_entry_helper::$validation_errors)) {
$r .= data_entry_helper::dump_remaining_errors();
}
$escaped_id = str_replace(':', '\\\\:', $closedFieldName);
if (!$readOnly) {
$r .= "<input type=button id=\"close1\" class=\"ui-state-default ui-corner-all\" value=\"" . lang::get('LANG_Save_Survey_Details') . "\";\n onclick=\"var result = \$('#SurveyForm input').valid();\n var result2 = \$('#SurveyForm select').valid();\n if (!result || !result2) {\n return;\n }\n jQuery('#SurveyForm').submit();\">\n";
if (!user_access($adminPerm) && $mode != 1) {
$r .= "<input type=button id=\"close2\" class=\"ui-state-default ui-corner-all\" value=\"" . lang::get('LANG_Save_Survey_And_Close') . "\"\n onclick=\"if(confirm('" . lang::get('LANG_Close_Survey_Confirm') . "')){\n var result = \$('#SurveyForm input').valid();\n var result2 = \$('#SurveyForm select').valid();\n if (!result || !result2) {\n return;\n }\n jQuery('#" . $escaped_id . "').val('1');\n jQuery('#SurveyForm').submit();\n };\">\n";
}