本文整理汇总了PHP中data_entry_helper::outputAttribute方法的典型用法代码示例。如果您正苦于以下问题:PHP data_entry_helper::outputAttribute方法的具体用法?PHP data_entry_helper::outputAttribute怎么用?PHP data_entry_helper::outputAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类data_entry_helper
的用法示例。
在下文中一共展示了data_entry_helper::outputAttribute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_attribute_html
/**
* List of methods that can be used for a prebuilt form control generation.
* @package Client
* @subpackage PrebuiltForms.
* @param array $attributes
* @param array $args
* @param array $defAttrOptions
* @param array $outerFilter
* @param array $blockOptions Associative array of control names that have non-default options. Each entry
* is keyed by the control name and has an array of the options and values to override.
* @param array $idPrefix Optional prefix to give to IDs (e.g. for fieldsets) to allow you to ensure they remain unique.
*/
function get_attribute_html($attributes, $args, $defAttrOptions, $outerFilter = null, $blockOptions = null, $idPrefix = '')
{
$lastOuterBlock = '';
$lastInnerBlock = '';
$r = '';
foreach ($attributes as $attribute) {
// Apply filter to only output 1 block at a time. Also hide controls that have already been handled.
if (($outerFilter === null || strcasecmp($outerFilter, $attribute['outer_structure_block']) == 0) && !isset($attribute['handled'])) {
if (empty($outerFilter) && $lastOuterBlock != $attribute['outer_structure_block']) {
if (!empty($lastInnerBlock)) {
$r .= '</fieldset>';
}
if (!empty($lastOuterBlock)) {
$r .= '</fieldset>';
}
if (!empty($attribute['outer_structure_block'])) {
$r .= '<fieldset id="' . get_fieldset_id($attribute['outer_structure_block'], $idPrefix) . '"><legend>' . lang::get($attribute['outer_structure_block']) . '</legend>';
}
if (!empty($attribute['inner_structure_block'])) {
$r .= '<fieldset id="' . get_fieldset_id($attribute['outer_structure_block'], $attribute['inner_structure_block'], $idPrefix) . '"><legend>' . lang::get($attribute['inner_structure_block']) . '</legend>';
}
} elseif ($lastInnerBlock != $attribute['inner_structure_block']) {
if (!empty($lastInnerBlock)) {
$r .= '</fieldset>';
}
if (!empty($attribute['inner_structure_block'])) {
$r .= '<fieldset id="' . get_fieldset_id($lastOuterBlock, $attribute['inner_structure_block'], $idPrefix) . '"><legend>' . lang::get($attribute['inner_structure_block']) . '</legend>';
}
}
$lastInnerBlock = $attribute['inner_structure_block'];
$lastOuterBlock = $attribute['outer_structure_block'];
$options = $defAttrOptions + get_attr_validation($attribute, $args);
if (isset($blockOptions[$attribute['fieldname']])) {
$options = array_merge($options, $blockOptions[$attribute['fieldname']]);
}
$r .= data_entry_helper::outputAttribute($attribute, $options);
$attribute['handled'] = true;
}
}
if (!empty($lastInnerBlock)) {
$r .= '</fieldset>';
}
if (!empty($lastOuterBlock) && strcasecmp($outerFilter, $lastOuterBlock) !== 0) {
$r .= '</fieldset>';
}
return $r;
}
示例2: get_occurrences_form
public static function get_occurrences_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.';
}
drupal_add_js('misc/tableheader.js');
// for sticky heading
data_entry_helper::add_resource('jquery_form');
$auth = data_entry_helper::get_read_write_auth($args['website_id'], $args['password']);
// did the parent sample previously exist? Default is no.
$existing = false;
$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));
if (isset($_POST['sample:id'])) {
// have just posted an edit to the existing sample
$sampleId = $_POST['sample:id'];
$existing = true;
data_entry_helper::load_existing_record($auth['read'], 'sample', $sampleId);
} else {
if (isset($response['outer_id'])) {
// have just posted a new sample.
$sampleId = $response['outer_id'];
} else {
$sampleId = $_GET['sample_id'];
$existing = true;
}
}
$sample = data_entry_helper::get_population_data(array('table' => 'sample', 'extraParams' => $auth['read'] + array('view' => 'detail', 'id' => $sampleId, 'deleted' => 'f')));
$sample = $sample[0];
$date = $sample['date_start'];
if (!function_exists('module_exists') || !module_exists('easy_login')) {
// work out the CMS User sample ID.
$sampleMethods = helper_base::get_termlist_terms($auth, 'indicia:sample_methods', array('Field Observation'));
$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']));
if (false == ($cmsUserAttr = extract_cms_user_attr($attributes))) {
return 'Easy Login not active: This form is designed to be used with the CMS User ID attribute setup for samples in the survey.';
}
}
$allTaxonMeaningIdsAtSample = array();
if ($existing) {
// Only need to load the occurrences for a pre-existing sample
$o = data_entry_helper::get_population_data(array('report' => 'reports_for_prebuilt_forms/UKBMS/ukbms_occurrences_list_for_sample', 'extraParams' => $auth['read'] + array('view' => 'detail', 'sample_id' => $sampleId, 'survey_id' => $args['survey_id'], 'date_from' => '', 'date_to' => '', 'taxon_group_id' => '', 'smpattrs' => '', 'occattrs' => $args['occurrence_attribute_ids']), 'nocache' => true));
// build an array keyed for easy lookup
$occurrences = array();
$attrs = explode(',', $args['occurrence_attribute_ids']);
if (!isset($o['error'])) {
foreach ($o as $occurrence) {
if (!in_array($occurrence['taxon_meaning_id'], $allTaxonMeaningIdsAtSample)) {
$allTaxonMeaningIdsAtSample[] = $occurrence['taxon_meaning_id'];
}
$occurrences[$occurrence['taxon_meaning_id']] = array('ttl_id' => $occurrence['taxa_taxon_list_id'], 'ttl_id' => $occurrence['taxa_taxon_list_id'], 'preferred_ttl_id' => $occurrence['preferred_ttl_id'], 'o_id' => $occurrence['occurrence_id'], 'processed' => false);
foreach ($attrs as $attr) {
$occurrences[$occurrence['taxon_meaning_id']]['value_' . $attr] = $occurrence['attr_occurrence_' . $attr];
$occurrences[$occurrence['taxon_meaning_id']]['a_id_' . $attr] = $occurrence['attr_id_occurrence_' . $attr];
}
}
}
// store it in data for JS to read when populating the grid
data_entry_helper::$javascript .= "indiciaData.existingOccurrences = " . json_encode($occurrences) . ";\n";
} else {
data_entry_helper::$javascript .= "indiciaData.existingOccurrences = {};\n";
}
$occ_attributes = data_entry_helper::getAttributes(array('valuetable' => 'occurrence_attribute_value', 'attrtable' => 'occurrence_attribute', 'key' => 'occurrence_id', 'fieldprefix' => 'occAttr', 'extraParams' => $auth['read'], 'survey_id' => $args['survey_id'], 'multiValue' => false));
data_entry_helper::$javascript .= "indiciaData.occurrence_totals = [];\n";
data_entry_helper::$javascript .= "indiciaData.occurrence_attribute = [];\n";
data_entry_helper::$javascript .= "indiciaData.occurrence_attribute_ctrl = [];\n";
$defAttrOptions = array('extraParams' => $auth['read'] + array('orderby' => 'id'), 'suffixTemplate' => 'nosuffix');
$occ_attributes_captions = array();
foreach (explode(',', $args['occurrence_attribute_ids']) as $idx => $attr) {
$occ_attributes_captions[$idx] = $occ_attributes[$attr]['caption'];
unset($occ_attributes[$attr]['caption']);
$ctrl = data_entry_helper::outputAttribute($occ_attributes[$attr], $defAttrOptions);
data_entry_helper::$javascript .= "indiciaData.occurrence_totals[" . $idx . "] = [];\n";
data_entry_helper::$javascript .= "indiciaData.occurrence_attribute[" . $idx . "] = {$attr};\n";
data_entry_helper::$javascript .= "indiciaData.occurrence_attribute_ctrl[" . $idx . "] = jQuery('" . str_replace("\n", "", $ctrl) . "');\n";
}
// $r = "<h2>".$location[0]['name']." on ".$date."</h2>\n";
$r = '<div id="tabs">';
$tabs = array('#grid1' => t($args['species_tab_1']));
// tab 1 is required.
if (isset($args['taxon_list_id_2']) && $args['taxon_list_id_2'] != '') {
$tabs['#grid2'] = t(isset($args['species_tab_2']) && $args['species_tab_2'] != '' ? $args['species_tab_2'] : 'Species Tab 2');
}
if (isset($args['taxon_list_id_3']) && $args['taxon_list_id_3'] != '') {
//.........这里部分代码省略.........
示例3: get_occurrences_form
public static function get_occurrences_form($args, $node, $response)
{
if (!module_exists('iform_ajaxproxy')) {
return 'This form must be used in Drupal with the Indicia AJAX Proxy module enabled.';
}
data_entry_helper::add_resource('jquery_form');
$auth = data_entry_helper::get_read_write_auth($args['website_id'], $args['password']);
// did the parent sample previously exist? Default is no.
$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'];
$parentLocId = $_POST['sample:location_id'];
$date = $_POST['sample:date'];
$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;
}
$sample = data_entry_helper::get_population_data(array('table' => 'sample', 'extraParams' => $auth['read'] + array('view' => 'detail', 'id' => $parentSampleId, 'deleted' => 'f')));
$sample = $sample[0];
$parentLocId = $sample['location_id'];
$date = $sample['date_start'];
}
// find any attributes that apply to transect section samples.
$sampleMethods = helper_base::get_termlist_terms($auth, 'indicia:sample_methods', array('Transect Section'));
$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'], 'multiValue' => false));
if ($existing) {
// as the parent sample exists, we need to load the sub-samples and occurrences
$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));
// transcribe the response array into a couple of forms that are useful elsewhere - one for outputting JSON so the JS knows about
// the samples, and another for lookup of sample data by code later.
$subSampleJson = array();
$subSamplesByCode = array();
foreach ($subSamples as $subSample) {
$subSampleJson[] = '"' . $subSample['code'] . '": ' . $subSample['sample_id'];
$subSamplesByCode[$subSample['code']] = $subSample;
}
data_entry_helper::$javascript .= "indiciaData.samples = { " . implode(', ', $subSampleJson) . "};\n";
$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));
// build an array keyed for easy lookup
$occurrences = array();
foreach ($o as $occurrence) {
$occurrences[$occurrence['sample_id'] . ':' . $occurrence['taxa_taxon_list_id']] = array('value' => $occurrence['attr_occurrence_' . $args['occurrence_attribute_id']], 'o_id' => $occurrence['occurrence_id'], 'a_id' => $occurrence['attr_id_occurrence_' . $args['occurrence_attribute_id']]);
}
// store it in data for JS to read when populating the grid
data_entry_helper::$javascript .= "indiciaData.existingOccurrences = " . json_encode($occurrences) . ";\n";
} else {
data_entry_helper::$javascript .= "indiciaData.samples = {};\n";
data_entry_helper::$javascript .= "indiciaData.existingOccurrences = {};\n";
}
$sections = data_entry_helper::get_population_data(array('table' => 'location', 'extraParams' => $auth['read'] + array('view' => 'detail', 'parent_id' => $parentLocId, 'deleted' => 'f', 'orderby' => 'code')));
$r = "<form method=\"post\"><div id=\"tabs\">\n";
$r .= '<input type="hidden" name="sample:id" value="' . $parentSampleId . '" />';
$r .= '<input type="hidden" name="website_id" value="' . $args['website_id'] . '"/>';
$r .= '<input type="hidden" name="survey_id" value="' . $args['survey_id'] . '"/>';
$r .= '<input type="hidden" name="page" value="grid"/>';
$r .= data_entry_helper::tab_header(array('tabs' => array('#grid' => lang::get('Enter Transect Data'), '#notes' => lang::get('Notes'))));
data_entry_helper::enable_tabs(array('divId' => 'tabs', 'style' => $args['interface']));
$r .= "<div id=\"grid\">\n";
$r .= '<table id="transect-input" class="ui-widget"><thead>';
$r .= '<tr><th class="ui-widget-header">' . lang::get('Sections') . '</th>';
foreach ($sections as $section) {
$r .= '<th class="ui-widget-header">' . $section['code'] . '</th>';
}
$r .= '</tr></thead>';
$r .= '<tbody class="ui-widget-content">';
// output rows at the top for any transect section level sample attributes
$rowClass = '';
foreach ($attributes as $attr) {
$r .= '<tr ' . $rowClass . '><td>' . $attr['caption'] . '</td>';
$rowClass = $rowClass == '' ? 'class="alt-row"' : '';
unset($attr['caption']);
foreach ($sections as $section) {
// output a cell with the attribute - tag it with a class & id to make it easy to find from JS.
$attrOpts = array('class' => 'smp-input smpAttr-' . $section['code'], 'id' => $attr['fieldname'] . ':' . $section['code'], 'extraParams' => $auth['read']);
// if there is an existing value, set it and also ensure the attribute name reflects the attribute value id.
if (isset($subSamplesByCode[$section['code']])) {
$attrOpts['fieldname'] = $attr['fieldname'] . ':' . $subSamplesByCode[$section['code']]['attr_id_sample_' . $attr['attributeId']];
$attr['default'] = $subSamplesByCode[$section['code']]['attr_sample_' . $attr['attributeId']];
} else {
$attr['default'] = isset($_POST[$attr['fieldname']]) ? $_POST[$attr['fieldname']] : '';
}
$r .= '<td>' . data_entry_helper::outputAttribute($attr, $attrOpts) . '</td>';
}
$r .= '</tr>';
}
$r .= '</tbody>';
$r .= '<tbody class="ui-widget-content" id="occs-body"></tbody>';
$r .= '</table>';
$r .= '</div>';
$r .= "<div id=\"notes\">\n";
$r .= data_entry_helper::textarea(array('fieldname' => 'sample:comment', 'label' => lang::get('Notes'), 'helpText' => "Use this space to input comments about this week's walk."));
$r .= '<input type="submit" value="' . lang::get('Save') . '"/>';
$r .= '</div></div></form>';
// A stub form for AJAX posting when we need to create an occurrence
//.........这里部分代码省略.........
示例4: get_form
//.........这里部分代码省略.........
<span>' . lang::get('LANG_Name_Filter_Title') . '</span>
</div>
</div>
<div id="name-filter-body" class="ui-accordion-content ui-helper-reset ui-widget-content ui-corner-all">
' . data_entry_helper::text_input(array('label' => lang::get('LANG_Name'), 'fieldname' => 'username', 'suffixTemplate' => 'nosuffix')) . '
</div>
<div id="date-filter-header" class="ui-accordion-header ui-helper-reset ui-state-default ui-corner-all">
<div id="fold-date-button" class="ui-state-default ui-corner-all fold-button fold-button-folded"> </div>
<div id="reset-date-button" class="ui-state-default ui-corner-all reset-button">' . lang::get('LANG_Reset_Filter') . '</div>
<div id="general-filter-title">
<span>' . lang::get('LANG_Date_Filter_Title') . '</span>
</div>
</div>
<div id="date-filter-body" class="ui-accordion-content ui-helper-reset ui-widget-content ui-corner-all">
<label for="start_date" >' . lang::get('LANG_Created_Between') . ':</label>
<input type="text" size="10" id="start_date" name="start_date" value="' . lang::get('click here') . '" />
<input type="hidden" id="real_start_date" name="real_start_date" />
<label for="end_date" >' . lang::get('LANG_And') . ':</label>
<input type="text" size="10" id="end_date" name="end_date" value="' . lang::get('click here') . '" />
<input type="hidden" id="real_end_date" name="real_end_date" />
</div>
<div id="flower-filter-header" class="ui-accordion-header ui-helper-reset ui-state-default ui-corner-all">
<div id="fold-flower-button" class="ui-state-default ui-corner-all fold-button fold-button-folded"> </div>
<div id="reset-flower-button" class="ui-state-default ui-corner-all reset-button">' . lang::get('LANG_Reset_Filter') . '</div>
<div id="flower-filter-title">
<span>' . lang::get('LANG_Flower_Filter_Title') . '</span>
</div>
</div>
<div id="flower-filter-body" class="ui-accordion-content ui-helper-reset ui-widget-content ui-corner-all">
' . data_entry_helper::select($flower_ctrl_args) . '
<input type="text" name="flower:taxon_extra_info" class="taxon-info" value="' . lang::get('LANG_More_Precise') . '"
onclick="if(this.value==\'' . lang::get('LANG_More_Precise') . '\'){this.value=\'\'; this.style.color=\'#000\'}"
onblur="if(this.value==\'\'){this.value=\'' . lang::get('LANG_More_Precise') . '\'; this.style.color=\'#555\'}" />
' . str_replace("\n", "", data_entry_helper::outputAttribute($occurrence_attributes[$args['flower_type_attr_id']], $defAttrOptions)) . str_replace("\n", "", data_entry_helper::outputAttribute($location_attributes[$args['habitat_attr_id']], $defAttrOptions)) . '
</div>
<div id="insect-filter-header" class="ui-accordion-header ui-helper-reset ui-state-default ui-corner-all">
<div id="fold-insect-button" class="ui-state-default ui-corner-all fold-button fold-button-folded"> </div>
<div id="reset-insect-button" class="ui-state-default ui-corner-all reset-button">' . lang::get('LANG_Reset_Filter') . '</div>
<div id="insect-filter-title">
<span>' . lang::get('LANG_Insect_Filter_Title') . '</span>
</div>
</div>
<div id="insect-filter-body" class="ui-accordion-content ui-helper-reset ui-widget-content ui-corner-all">
' . data_entry_helper::select($insect_ctrl_args) . '
<input type="text" name="insect:taxon_extra_info" class="taxon-info" value="' . lang::get('LANG_More_Precise') . '"
onclick="if(this.value==\'' . lang::get('LANG_More_Precise') . '\'){this.value=\'\'; this.style.color=\'#000\'}"
onblur="if(this.value==\'\'){this.value=\'' . lang::get('LANG_More_Precise') . '\'; this.style.color=\'#555\'}" />
</div>
<div id="conditions-filter-header" class="ui-accordion-header ui-helper-reset ui-state-default ui-corner-all">
<div id="fold-conditions-button" class="ui-state-default ui-corner-all fold-button fold-button-folded"> </div>
<div id="reset-conditions-button" class="ui-state-default ui-corner-all reset-button">' . lang::get('LANG_Reset_Filter') . '</div>
<div id="conditions-filter-title">
<span>' . lang::get('LANG_Conditions_Filter_Title') . '</span>
</div>
</div>
<div id="conditions-filter-body" class="ui-accordion-content ui-helper-reset ui-widget-content ui-corner-all">
' . str_replace("\n", "", data_entry_helper::outputAttribute($sample_attributes[$args['sky_state_attr_id']], $defAttrOptions)) . str_replace("\n", "", data_entry_helper::outputAttribute($sample_attributes[$args['temperature_attr_id']], $defAttrOptions)) . str_replace("\n", "", data_entry_helper::outputAttribute($sample_attributes[$args['wind_attr_id']], $defAttrOptions)) . str_replace("\n", "", data_entry_helper::outputAttribute($sample_attributes[$args['shade_attr_id']], $defAttrOptions)) . '
</div>
<div id="location-filter-header" class="ui-accordion-header ui-helper-reset ui-state-active ui-corner-all">
<div id="fold-location-button" class="ui-state-default ui-corner-all fold-button"> </div>
<div id="reset-location-button" class="ui-state-default ui-corner-all reset-button">' . lang::get('LANG_Reset_Filter') . '</div>
<div id="location-filter-title">
<span>' . lang::get('LANG_Location_Filter_Title') . '</span>
</div>
</div>
<div id="location-filter-body" class="ui-accordion-content ui-helper-reset ui-widget-content ui-accordion-content-active ui-corner-all">
示例5: get_form
//.........这里部分代码省略.........
$fieldValue = data_entry_helper::check_default_value($fieldName, $user->mail);
$r .= "<input type=\"hidden\" name=\"" . $fieldName . "\" value=\"" . $fieldValue . "\" />\n";
$fieldName = $attributes[$username_attr_id]['fieldname'];
$fieldValue = data_entry_helper::check_default_value($fieldName, $user->name);
$r .= "<input type=\"hidden\" name=\"" . $fieldName . "\" value=\"" . $fieldValue . "\" />\n";
}
$defAttrOptions['validation'] = array('required');
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?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[$sample_walk_direction_id], $languageFilteredAttrOptions) . ($sample_reliability_id ? data_entry_helper::outputAttribute($attributes[$sample_reliability_id], $languageFilteredAttrOptions) : "<span style=\"display: none;\">Sample attribute '" . self::ATTR_RELIABILITY . "' not assigned to this survey</span>") . data_entry_helper::outputAttribute($attributes[$sample_visit_number_id], array_merge($languageFilteredAttrOptions, array('default' => 1, 'noBlankText' => true)));
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
$d = new DateTime(data_entry_helper::$entity_to_load['sample:date']);
data_entry_helper::$entity_to_load['sample:date'] = $d->format('d/m/Y');
}
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 ($surveyReadOnly) {
$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'));
}
$r .= ($sample_wind_id ? data_entry_helper::outputAttribute($attributes[$sample_wind_id], $languageFilteredAttrOptions) : "<span style=\"display: none;\">Sample attribute '" . self::ATTR_WIND . "' not assigned to this survey</span>") . ($sample_precipitation_id ? data_entry_helper::outputAttribute($attributes[$sample_precipitation_id], $languageFilteredAttrOptions) : "<span style=\"display: none;\">Sample attribute '" . self::ATTR_RAIN . "' not assigned to this survey</span>") . ($sample_temperature_id ? data_entry_helper::outputAttribute($attributes[$sample_temperature_id], array_merge($defAttrOptions, array('suffixTemplate' => 'nosuffix'))) . "<span class=\"attr-trailer\"> °C</span><br />" : "<span style=\"display: none;\">Sample attribute '" . self::ATTR_TEMP . "' not assigned to this survey</span>") . ($sample_cloud_id ? data_entry_helper::outputAttribute($attributes[$sample_cloud_id], $defAttrOptions) : "<span style=\"display: none;\">Sample attribute '" . self::ATTR_CLOUD . "' not assigned to this survey</span>") . ($sample_start_time_id ? data_entry_helper::outputAttribute($attributes[$sample_start_time_id], array_merge($defAttrOptions, array('suffixTemplate' => 'nosuffix'))) . "<span class=\"attr-trailer\"> hh:mm</span><br />" : "<span style=\"display: none;\">Sample attribute '" . self::ATTR_START_TIME . "' not assigned to this survey</span>") . ($sample_end_time_id ? data_entry_helper::outputAttribute($attributes[$sample_end_time_id], array_merge($defAttrOptions, array('suffixTemplate' => 'nosuffix'))) . "<span class=\"attr-trailer\"> hh:mm</span><br />" : "<span style=\"display: none;\">Sample attribute '" . self::ATTR_END_TIME . "' not assigned to this survey</span>");
data_entry_helper::$javascript .= "\njQuery('.attr-trailer').prev('br').remove();\n";
unset($defAttrOptions['suffixTemplate']);
unset($defAttrOptions['validation']);
if (user_access($args['edit_permission'])) {
// 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[$sample_closure_id], $defAttrOptions);
// In addition admin users can delete a survey/sample.
$r .= data_entry_helper::checkbox(array('label' => lang::get('Deleted'), 'fieldname' => 'sample:deleted', 'id' => 'main-sample-deleted'));
} else {
// hidden closed
$r .= "<input type=\"hidden\" id=\"main-sample-closed\" name=\"" . $closedFieldName . "\" value=\"" . $closedFieldValue . "\" />\n";
}
data_entry_helper::$javascript .= "\n\$.validator.messages.required = \"" . lang::get('validation_required') . "\";\n\$.validator.defaults.onsubmit = false; // override default - so that we handle all submission validation.\n";
示例6: iform_mnhnl_locationattributes
function iform_mnhnl_locationattributes($auth, $args, $tabalias, $options)
{
$creatorAttr = iform_mnhnl_getAttrID($auth, $args, 'location', 'Creator');
if ($creatorAttr) {
data_entry_helper::$javascript .= "\njQuery('[name=locAttr:" . $creatorAttr . "],[name^=locAttr:" . $creatorAttr . ":]').removeClass('wide').attr('readonly','readonly');";
}
$attrArgs = array('valuetable' => 'location_attribute_value', 'attrtable' => 'location_attribute', 'key' => 'location_id', 'fieldprefix' => 'locAttr', 'extraParams' => $auth['read'], 'survey_id' => $args['survey_id']);
// if($options['read_only']===true) $attrArgs['read_only']='read_only';
$tabName = isset($options['tabNameFilter']) && isset($options['tabNameFilter']) != '' ? $options['tabNameFilter'] : '';
if (array_key_exists('location:id', data_entry_helper::$entity_to_load) && data_entry_helper::$entity_to_load['location:id'] != "") {
// if we have location Id to load, use it to get attribute values
$attrArgs['id'] = data_entry_helper::$entity_to_load['location:id'];
}
$locationAttributes = data_entry_helper::getAttributes($attrArgs, false);
$defAttrOptions = array_merge(array('extraParams' => array_merge($auth['read'], array('view' => 'detail')), 'language' => iform_lang_iso_639_2($args['language'])), $options);
$r = '';
foreach ($locationAttributes as $attribute) {
if ($tabName == '' && $attribute['inner_structure_block'] != "Filter" || strcasecmp($tabName, $attribute['inner_structure_block']) == 0) {
$opt = $defAttrOptions + get_attr_validation($attribute, $args);
$r .= data_entry_helper::outputAttribute($attribute, $opt);
}
}
return $r;
}
示例7: bats_get_attribute_html
private function bats_get_attribute_html($attributes, $args, $defAttrOptions, $blockFilter = null, $blockOptions = null)
{
$r = '';
foreach ($attributes as $attribute) {
// Apply filter to only output 1 block at a time. Also hide controls that have already been handled.
if (($blockFilter === null || strcasecmp($blockFilter, $attribute['inner_structure_block']) == 0) && !isset($attribute['handled'])) {
$options = $defAttrOptions + get_attr_validation($attribute, $args);
if (isset($blockOptions[$attribute['fieldname']])) {
$options = array_merge($options, $blockOptions[$attribute['fieldname']]);
}
$r .= data_entry_helper::outputAttribute($attribute, $options);
$attribute['handled'] = true;
}
}
return $r;
}
示例8: get_sample_attribute_html
private function get_sample_attribute_html($attributes, $args, $defAttrOptions, $outerBlockFilter, $innerBlockFilter, $useCaptions = false)
{
$r = '';
if (!isset($attributes)) {
return $r;
}
foreach ($attributes as $attribute) {
// Apply filter to only output 1 block at a time.
if (($innerBlockFilter === null || strcasecmp($innerBlockFilter, $attribute['inner_structure_block']) == 0) && ($outerBlockFilter === null || strcasecmp($outerBlockFilter, $attribute['outer_structure_block']) == 0)) {
$options = $defAttrOptions + get_attr_validation($attribute, $args);
if (!$useCaptions) {
unset($attribute['caption']);
}
$r .= '<td ' . (isset($defAttrOptions['cellClass']) ? 'class="' . $defAttrOptions['cellClass'] . '"' : '') . '>' . data_entry_helper::outputAttribute($attribute, $options) . '</td>';
}
}
return $r;
}
示例9: get_species_checklist_clonable_row
/**
* When the species checklist grid has a lookup list associated with it, this is a
* secondary checklist which you can pick species from to add to the grid. As this happens,
* a hidden table is used to store a clonable row which provides the template for new rows
* to be added to the grid.
*/
private static function get_species_checklist_clonable_row($options, $occAttrControls, $occAttrCaptions, $attributes, $precision)
{
global $indicia_templates;
// assume always removeable and presence is hidden.
// DEBUG/DEV MODE
// $r = '<table border=3 id="'.$options['id'].'-scClonable">';
// $hiddenCTRL = "text";
$r = '<table style="display: none" id="' . $options['id'] . '-scClonable">';
$hiddenCTRL = "hidden";
$numRows = 0;
$maxCellsPerRow = 1;
//covers header and comment
$i = 1;
do {
$foundRows = false;
$attrsPerRow = 0;
foreach ($attributes as $attribute) {
if ($attribute["inner_structure_block"] == "Row" . $i) {
$numRows = $i;
$foundRows = true;
$attrsPerRow++;
}
}
$i++;
if ($attrsPerRow > $maxCellsPerRow) {
$maxCellsPerRow = $attrsPerRow;
}
} while ($foundRows);
if ($numRows) {
$foundRows = true;
} else {
$numRows = 1;
$maxCellsPerRow = count($attributes);
}
if ($options['includeSubSample']) {
$maxCellsPerRow = max($maxCellsPerRow, 2 + ($options['displaySampleDate'] ? 1 : 0) + ($precision ? 1 : 0));
}
$idex = 1;
$prefix = "sc:--GroupID--:--SampleID--:--TTLID--:--OccurrenceID--";
$r .= '<tbody><tr class="scClonableRow first" id="' . $options['id'] . '-scClonableRow' . $idex . '"><td class="ui-state-default remove-row" rowspan="' . $options['numRows'] . '">X</td>';
$colspan = ' colspan="' . $maxCellsPerRow . '"';
$r .= str_replace('{colspan}', $colspan, $indicia_templates['taxon_label_cell']) . '<td class="scPresenceCell" style="display:none"><input type="hidden" class="scPresence" name="" value="false" /></td></tr>';
if ($options['includeSubSample']) {
if (!isset($options['subsample_method_id']) || $options['subsample_method_id'] == "") {
throw new exception('subsample_method_id must be set for this form configuration.');
}
$idex++;
$r .= '<tr class="scClonableRow scDataRow" id="' . $options['id'] . '-scClonableRow' . $idex . '">';
if ($options['displaySampleDate']) {
$r .= "<td class='ui-widget-content'><label class=\"auto-width\" for=\"{$prefix}:sample:date\">" . lang::get('LANG_Date') . ":</label> <input type=\"text\" id=\"{$prefix}:sample:date\" class=\"date\" name=\"{$prefix}:sample:date\" value=\"\" /></td>";
}
$r .= "<td class='ui-widget-content'><input type=\"{$hiddenCTRL}\" id=\"sg---GroupID---imp-sref\" name=\"{$prefix}:sample:entered_sref\" value=\"\" />\n<input type=\"{$hiddenCTRL}\" id=\"sg---GroupID---imp-geom\" name=\"{$prefix}:sample:geom\" value=\"\" />\n<input type=\"{$hiddenCTRL}\" name=\"{$prefix}:sample:sample_method_id\" value=\"" . $options['subsample_method_id'] . "\" />\n<label class=\"auto-width\" for=\"sg---GroupID---imp-srefX\">" . lang::get('LANG_Species_X_Label') . ":</label> <input type=\"text\" id=\"sg---GroupID---imp-srefX\" class=\"imp-srefX integer required\" name=\"dummy:srefX\" value=\"\" /><span class='deh-required'>*</span></td>\n<td class='ui-widget-content'><label class=\"auto-width\" for=\"sg---GroupID---imp-srefY\">" . lang::get('LANG_Species_Y_Label') . ":</label> <input type=\"text\" id=\"sg---GroupID---imp-srefY\" class=\"imp-srefY integer required\" name=\"dummy:srefY\" value=\"\"/><span class='deh-required'>*</span></td>";
if ($precision) {
$ctrlId = $prefix . ":smpAttr:" . $precision['attributeId'];
$ctrlOptions = array('class' => 'scPrecision ' . (isset($precision['class']) ? ' ' . $precision['class'] : ''), 'extraParams' => $options['readAuth'], 'language' => $options['language']);
if (isset($options['lookUpKey'])) {
$ctrlOptions['lookUpKey'] = $options['lookUpKey'];
}
// if($options['useCaptionsInHeader'] || $options['useCaptionsInPreRow']) unset($attrDef['caption']);
$precision['fieldname'] = $ctrlId;
$precision['id'] = $ctrlId;
//$headerPreRow .= '<td class="ui-widget-content" ><label class="auto-width">'.$occAttrCaptions[$attrId].':</label></td>';
$r .= "<td class='ui-widget-content scSmpAttrCell'>" . data_entry_helper::outputAttribute($precision, $ctrlOptions) . "</td>";
}
if ($maxCellsPerRow > 2 + ($options['displaySampleDate'] ? 1 : 0) + ($precision ? 1 : 0)) {
$r .= "<td class='ui-widget-content' colspan=" . ($maxCellsPerRow - (2 + ($options['displaySampleDate'] ? 1 : 0) + ($precision ? 1 : 0))) . "></td>";
}
$r .= "</tr>";
}
$idx = 0;
for ($i = 1; $i <= $numRows; $i++) {
$numCtrls = 0;
$row = '';
$headerPreRow = '';
foreach ($attributes as $attrId => $attribute) {
$control = $occAttrControls[$attrId];
if ($foundRows && $attribute["inner_structure_block"] != "Row" . $i) {
continue;
}
$ctrlId = $prefix . ":occAttr:" . $attrId;
$oc = str_replace('{fieldname}', $ctrlId, $control);
if (isset($attributes[$attrId]['default']) && !empty($attributes[$attrId]['default'])) {
$existing_value = $attributes[$attrId]['default'];
if (substr($oc, 0, 7) == '<select') {
// For select controls, specify which option is selected from the existing value
$oc = str_replace('value="' . $existing_value . '"', 'value="' . $existing_value . '" selected="selected"', $oc);
} else {
if (strpos($oc, 'radio') !== false) {
$oc = str_replace('value="' . $existing_value . '"', 'value="' . $existing_value . '" checked="checked"', $oc);
} else {
if (strpos($oc, 'checkbox') !== false) {
if ($existing_value == "1") {
$oc = str_replace('type="checkbox"', 'type="checkbox" checked="checked"', $oc);
}
//.........这里部分代码省略.........
示例10: species_checklist_prepare_attributes
public static function species_checklist_prepare_attributes($options, $attributes, &$occAttrControls, &$occAttrs)
{
$idx = 0;
if (array_key_exists('occAttrs', $options)) {
$attrs = $options['occAttrs'];
} else {
// There is no specified list of occurrence attributes, so use all available for the survey
$attrs = array_keys($attributes);
}
foreach ($attrs as $occAttrId) {
// test that this occurrence attribute is linked to the survey
if (!isset($attributes[$occAttrId])) {
throw new Exception("The occurrence attribute {$occAttrId} requested for the grid is not linked with the survey.");
}
$attrDef = array_merge($attributes[$occAttrId]);
$occAttrs[$occAttrId] = $attrDef['caption'];
// Get the control class if available. If the class array is too short, the last entry gets reused for all remaining.
$ctrlOptions = array('class' => self::species_checklist_occ_attr_class($options, $idx, $attrDef['untranslatedCaption']) . (isset($attrDef['class']) ? ' ' . $attrDef['class'] : ''), 'extraParams' => $options['readAuth'], 'language' => $options['language']);
if (isset($options['lookUpKey'])) {
$ctrlOptions['lookUpKey'] = $options['lookUpKey'];
}
if (isset($options['blankText'])) {
$ctrlOptions['blankText'] = $options['blankText'];
}
$attrDef['fieldname'] = '{fieldname}';
$attrDef['id'] = '{fieldname}';
$occAttrControls[$occAttrId] = data_entry_helper::outputAttribute($attrDef, $ctrlOptions);
$idx++;
}
}
示例11: get_form
//.........这里部分代码省略.........
$r .= iform_user_get_hidden_inputs($args);
if (array_key_exists('sample:id', data_entry_helper::$entity_to_load)) {
$r .= "<input type=\"hidden\" id=\"sample:id\" name=\"sample:id\" value=\"" . data_entry_helper::$entity_to_load['sample:id'] . "\" />\n";
}
$defAttrOptions['validation'] = array('required');
$defAttrOptions['suffixTemplate'] = 'requiredsuffix';
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();
}
示例12: output_habitats_block
protected static function output_habitats_block($title, $prefix, $auth, $args)
{
global $indicia_templates;
static $existingSubSamples;
$r = '<fieldset class="ui-corner-all">
<legend>' . $title . ' habitats</legend>
<table class="habitats">
<thead><tr>
<td>Habitat</td>
<td>0%</td>
<td>1-25%</td>
<td>26-50%</td>
<td>51-75%</td>
<td>76-100%</td>
<td>Further info. about habitat e.g management, recent changes</td>';
$r .= '</tr></thead>
<tbody>';
$coverageAttrs = data_entry_helper::getAttributes(array('valuetable' => 'sample_attribute_value', 'attrtable' => 'sample_attribute', 'fieldprefix' => "{$prefix}:smpAttr", 'extraParams' => $auth + array('inner_structure_block' => 'Habitats'), 'survey_id' => $args['survey_id']));
$otherInfoAttrs = data_entry_helper::getAttributes(array('valuetable' => 'sample_attribute_value', 'attrtable' => 'sample_attribute', 'fieldprefix' => "{$prefix}:smpAttr", 'extraParams' => $auth + array('inner_structure_block' => 'HabitatsOtherInfo'), 'survey_id' => $args['survey_id']));
if (isset($_GET['sample_id'])) {
// use a static here to load all the subsample data in one hit
if (!isset($existingSubSamples)) {
$attrIds = array();
foreach ($coverageAttrs as $attr) {
$attrIds[] = $attr['attributeId'];
}
foreach ($otherInfoAttrs as $attr) {
$attrIds[] = $attr['attributeId'];
}
$existingSubSamples = data_entry_helper::get_population_data(array('nocache' => true, 'report' => 'library/samples/samples_list_for_parent_sample', 'extraParams' => $auth + array('sample_id' => $_GET['sample_id'], 'date_from' => '', 'date_to' => '', 'sample_method_id' => '', 'smpattrs' => implode(',', $attrIds))));
}
/// find the set of sub-sample data that matches the current block type
foreach ($existingSubSamples as $existingSubSample) {
if ($existingSubSample['location_name'] === $prefix) {
$thisSubSample = $existingSubSample;
break;
}
}
// apply the defaults we just loaded to the list of attributes
if (isset($thisSubSample)) {
foreach ($coverageAttrs as $idx => $attr) {
if (isset($thisSubSample['attr_id_sample_' . $attr['attributeId']])) {
$coverageAttrs[$idx]['fieldname'] .= ':' . $thisSubSample['attr_id_sample_' . $attr['attributeId']];
$coverageAttrs[$idx]['default'] = $thisSubSample['attr_sample_' . $attr['attributeId']];
}
}
foreach ($otherInfoAttrs as $idx => $attr) {
if (isset($thisSubSample['attr_id_sample_' . $attr['attributeId']])) {
$otherInfoAttrs[$idx]['fieldname'] .= ':' . $thisSubSample['attr_id_sample_' . $attr['attributeId']];
$otherInfoAttrs[$idx]['default'] = $thisSubSample['attr_sample_' . $attr['attributeId']];
}
}
}
}
$coverageAttrs = array_values($coverageAttrs);
$otherInfoAttrs = array_values($otherInfoAttrs);
// put radio buttons inside table cells, without labels as these are in the header
$labelTemplate = $indicia_templates['label'];
$itemTemplate = $indicia_templates['check_or_radio_group_item'];
$template = $indicia_templates['check_or_radio_group'];
$indicia_templates['label'] = '';
$indicia_templates['check_or_radio_group_item'] = '<td><input type="{type}" name="{fieldname}" id="{itemId}" value="{value}"{class}{checked} {disabled}/></td>';
$indicia_templates['check_or_radio_group'] = '{items}';
//We need to remove the attribute_value ids from the fieldnames if cloning data onto a new record, otherwise it will save over the
//top of the existing record.
if (self::$mode === self::MODE_CLONE) {
self::cloneEntity($args, $auth, $coverageAttrs);
self::cloneEntity($args, $auth, $otherInfoAttrs);
}
foreach ($coverageAttrs as $idx => $attr) {
$r .= '<tr><td><label>' . $attr['caption'] . '</label></td>';
//unset the attribute caption as we have already drawn it
unset($attr['caption']);
$r .= data_entry_helper::outputAttribute($attr, array('extraParams' => $auth));
$r .= '<td>';
if (isset($otherInfoAttrs[$idx])) {
$r .= data_entry_helper::outputAttribute($otherInfoAttrs[$idx], array('extraParams' => $auth));
}
$r .= '</td></tr>';
}
// reset templates
$indicia_templates['check_or_radio_group_item'] = $itemTemplate;
$indicia_templates['check_or_radio_group'] = $template;
$indicia_templates['label'] = $labelTemplate;
$r .= '</tbody></table>';
//In mode close, we want the form to act as if it is a new record even though it is showing existing data, so
//we don't want the system to know about existing sample/sub-sample IDs at the point of save.
if (isset($thisSubSample) && self::$mode !== self::MODE_CLONE) {
$r .= '<input type="hidden" name="' . $prefix . '_sample_id" value="' . $thisSubSample['sample_id'] . '" />';
}
$r .= '</fieldset>';
return $r;
}
示例13: get_form
//.........这里部分代码省略.........
</div>
<div id="date-filter-body" class="ui-accordion-content ui-helper-reset ui-widget-content ui-corner-all">
<label for="start_date" >' . lang::get('LANG_Created_Between') . ':</label>
<input type="text" size="10" id="start_date" name="start_date" value="' . lang::get('click here') . '" />
<input type="hidden" id="real_start_date" name="real_start_date" />
<label for="end_date" >' . lang::get('LANG_And') . '</label>
<input type="text" size="10" id="end_date" name="end_date" value="' . lang::get('click here') . '" />
<input type="hidden" id="real_end_date" name="real_end_date" />
</div>
<div id="flower-filter-header" class="ui-accordion-header ui-helper-reset ui-state-default ui-corner-all">
<div id="fold-flower-button" class="ui-state-default ui-corner-all fold-button fold-button-folded"> </div>
<div id="reset-flower-button" class="ui-state-default ui-corner-all reset-button">' . lang::get('LANG_Reset_Filter') . '</div>
<div id="flower-filter-title">
<span>' . lang::get('LANG_Flower_Filter_Title') . '</span>
</div>
</div>
<div id="flower-filter-body" class="ui-accordion-content ui-helper-reset ui-widget-content ui-corner-all">
' . data_entry_helper::select($flower_ctrl_args) . '
<input type="text" name="flower:taxon_extra_info" class="taxon-info" value="' . lang::get('LANG_More_Precise') . '"
onclick="if(this.value==\'' . lang::get('LANG_More_Precise') . '\'){this.value=\'\'; this.style.color=\'#000\'}"
onblur="if(this.value==\'\'){this.value=\'' . lang::get('LANG_More_Precise') . '\'; this.style.color=\'#555\'}" />
<label >' . lang::get('LANG_ID_Status') . ':</label>
<span class="control-box "><nobr>
<span><input type="checkbox" value="X" id="flower_id_status:0" name="flower_id_status[]"><label for="flower_id_status:0">' . lang::get('LANG_ID_Status_Unidentified') . '</label></span></nobr> <nobr>
<span><input type="checkbox" value="A" id="flower_id_status:1" name="flower_id_status[]"><label for="flower_id_status:1">' . lang::get('LANG_ID_Status_Initial') . '</label></span></nobr> <nobr>
<span><input type="checkbox" value="B" id="flower_id_status:2" name="flower_id_status[]"><label for="flower_id_status:2">' . lang::get('LANG_ID_Status_Doubt') . '</label></span></nobr> <nobr>
<span><input type="checkbox" value="C" id="flower_id_status:3" name="flower_id_status[]"><label for="flower_id_status:3">' . lang::get('LANG_ID_Status_Validated') . '</label></span></nobr>
</span>
<label >' . lang::get('LANG_ID_Type') . ':</label>
<span class="control-box "><nobr>
<span><input type="checkbox" value="seul" id="flower_id_type:0" name="flower_id_type[]"><label for="flower_id_type:0">' . lang::get('LANG_ID_Type_Single') . '</label></span></nobr> <nobr>
<span><input type="checkbox" value="multi" id="flower_id_type:1" name="flower_id_type[]"><label for="flower_id_type:1">' . lang::get('LANG_ID_Type_Multiple') . '</label></span></nobr>
</span>
' . str_replace("\n", "", data_entry_helper::outputAttribute($occurrence_attributes[$flowerTypeAttrID], $defAttrOptions)) . str_replace("\n", "", data_entry_helper::outputAttribute($location_attributes[$habitatAttrID], $defAttrOptions)) . '
</div>
<div id="insect-filter-header" class="ui-accordion-header ui-helper-reset ui-state-default ui-corner-all">
<div id="fold-insect-button" class="ui-state-default ui-corner-all fold-button fold-button-folded"> </div>
<div id="reset-insect-button" class="ui-state-default ui-corner-all reset-button">' . lang::get('LANG_Reset_Filter') . '</div>
<div id="insect-filter-title">
<span>' . lang::get('LANG_Insect_Filter_Title') . '</span>
</div>
</div>
<div id="insect-filter-body" class="ui-accordion-content ui-helper-reset ui-widget-content ui-corner-all">
' . data_entry_helper::select($insect_ctrl_args) . '
<input type="text" name="insect:taxon_extra_info" class="taxon-info" value="' . lang::get('LANG_More_Precise') . '"
onclick="if(this.value==\'' . lang::get('LANG_More_Precise') . '\'){this.value=\'\'; this.style.color=\'#000\'}"
onblur="if(this.value==\'\'){this.value=\'' . lang::get('LANG_More_Precise') . '\'; this.style.color=\'#555\'}" />
<label >' . lang::get('LANG_ID_Status') . ':</label>
<span class="control-box "><nobr>
<span><input type="checkbox" value="X" id="insect_id_status:0" name="insect_id_status[]"><label for="insect_id_status:0">' . lang::get('LANG_ID_Status_Unidentified') . '</label></span></nobr> <nobr>
<span><input type="checkbox" value="A" id="insect_id_status:1" name="insect_id_status[]"><label for="insect_id_status:1">' . lang::get('LANG_ID_Status_Initial') . '</label></span></nobr> <nobr>
<span><input type="checkbox" value="B" id="insect_id_status:2" name="insect_id_status[]"><label for="insect_id_status:2">' . lang::get('LANG_ID_Status_Doubt') . '</label></span></nobr> <nobr>
<span><input type="checkbox" value="C" id="insect_id_status:3" name="insect_id_status[]"><label for="insect_id_status:3">' . lang::get('LANG_ID_Status_Validated') . '</label></span></nobr>
</span>
<label >' . lang::get('LANG_ID_Type') . ':</label>
<span class="control-box "><nobr>
<span><input type="checkbox" value="seul" id="insect_id_type:0" name="insect_id_type[]"><label for="insect_id_type:0">' . lang::get('LANG_ID_Type_Single') . '</label></span></nobr> <nobr>
<span><input type="checkbox" value="multi" id="insect_id_type:1" name="insect_id_type[]"><label for="insect_id_type:1">' . lang::get('LANG_ID_Type_Multiple') . '</label></span></nobr>
</span>
' . str_replace("\n", "", data_entry_helper::outputAttribute($occurrence_attributes[$foragingAttrID], $defAttrOptions)) . '
</div>
<div id="conditions-filter-header" class="ui-accordion-header ui-helper-reset ui-state-default ui-corner-all">
<div id="fold-conditions-button" class="ui-state-default ui-corner-all fold-button fold-button-folded"> </div>
<div id="reset-conditions-button" class="ui-state-default ui-corner-all reset-button">' . lang::get('LANG_Reset_Filter') . '</div>
<div id="conditions-filter-title">
<span>' . lang::get('LANG_Conditions_Filter_Title') . '</span>
示例14: get_tab_content
protected static function get_tab_content($auth, $args, $tab, $tabContent, $tabalias, &$attributes, &$hasControls)
{
// cols array used if we find | splitters
$cols = array();
$defAttrOptions = array('extraParams' => $auth['read']);
if (isset($args['attribute_termlist_language_filter']) && $args['attribute_termlist_language_filter']) {
$defAttrOptions['language'] = iform_lang_iso_639_2($args['language']);
}
//create array of attribute field names to test against later
$attribNames = array();
foreach ($attributes as $key => $attrib) {
$attribNames[$key] = $attrib['id'];
}
$html = '';
// Now output the content of the tab. Use a for loop, not each, so we can treat several rows as one object
for ($i = 0; $i < count($tabContent); $i++) {
$component = trim($tabContent[$i]);
if (preg_match('/\\A\\?[^�]*\\?\\z/', $component) === 1) {
// Component surrounded by ? so represents a help text
$helpText = substr($component, 1, -1);
$html .= '<div class="page-notice ui-state-highlight ui-corner-all">' . lang::get($helpText) . "</div>";
} elseif (preg_match('/\\A\\[[^�]*\\]\\z/', $component) === 1) {
// Component surrounded by [] so represents a control or control block
// Anything following the component that starts with @ is an option to pass to the control
$options = array();
while ($i < count($tabContent) - 1 && substr($tabContent[$i + 1], 0, 1) == '@' || trim($tabContent[$i]) === '') {
$i++;
// ignore empty lines
if (trim($tabContent[$i]) !== '') {
$option = explode('=', substr($tabContent[$i], 1), 2);
if (!isset($option[1]) || $option[1] === 'false') {
$options[$option[0]] = FALSE;
} else {
$options[$option[0]] = json_decode($option[1], TRUE);
// if not json then need to use option value as it is
if ($options[$option[0]] == '') {
$options[$option[0]] = $option[1];
}
}
// urlParam is special as it loads the control's default value from $_GET
if ($option[0] === 'urlParam' && isset($_GET[$option[1]])) {
$options['default'] = $_GET[$option[1]];
}
}
}
// if @permission specified as an option, then check that the user has access to this control
if (!empty($options['permission']) && !user_access($options['permission'])) {
continue;
}
$parts = explode('.', str_replace(array('[', ']'), '', $component));
$method = 'get_control_' . preg_replace('/[^a-zA-Z0-9]/', '', strtolower($component));
if (!empty($args['high_volume']) && $args['high_volume']) {
// enable control level report caching when in high_volume mode
$options['caching'] = empty($options['caching']) ? true : $options['caching'];
$options['cachetimeout'] = empty($options['cachetimeout']) ? HIGH_VOLUME_CONTROL_CACHE_TIMEOUT : $options['cachetimeout'];
}
// allow user settings to override the control - see iform_user_ui_options.module
if (isset(data_entry_helper::$data['structureControlOverrides']) && !empty(data_entry_helper::$data['structureControlOverrides'][$component])) {
$options = array_merge($options, data_entry_helper::$data['structureControlOverrides'][$component]);
}
if (count($parts) === 1 && method_exists(self::$called_class, $method)) {
//outputs a control for which a specific output function has been written.
$html .= call_user_func(array(self::$called_class, $method), $auth, $args, $tabalias, $options);
$hasControls = true;
} elseif (count($parts) === 2) {
require_once dirname($_SERVER['SCRIPT_FILENAME']) . '/' . data_entry_helper::relative_client_helper_path() . '/prebuilt_forms/extensions/' . $parts[0] . '.php';
if (method_exists('extension_' . $parts[0], $parts[1])) {
//outputs a control for which a specific extension function has been written.
$path = call_user_func(array(self::$called_class, 'getReloadPath'));
//pass the classname of the form through to the extension control method to allow access to calling class functions and variables
$args["calling_class"] = 'iform_' . self::$node->iform;
$html .= call_user_func(array('extension_' . $parts[0], $parts[1]), $auth, $args, $tabalias, $options, $path, $attributes);
$hasControls = true;
// auto-add JavaScript for the extension
if (file_exists(iform_client_helpers_path() . 'prebuilt_forms/extensions/' . $parts[0] . '.js')) {
drupal_add_js(iform_client_helpers_path() . 'prebuilt_forms/extensions/' . $parts[0] . '.js', array('preprocess' => FALSE));
}
if (file_exists(iform_client_helpers_path() . 'prebuilt_forms/extensions/' . $parts[0] . '.css')) {
drupal_add_css(iform_client_helpers_path() . 'prebuilt_forms/extensions/' . $parts[0] . '.css', array('preprocess' => FALSE));
}
} else {
$html .= lang::get("The {$component} extension cannot be found.");
}
} elseif (($attribKey = array_search(substr($component, 1, -1), $attribNames)) !== false || preg_match('/^\\[[a-zA-Z]+:(?P<ctrlId>[0-9]+)\\]/', $component, $matches)) {
// control is a smpAttr or other attr control.
if (empty($options['extraParams'])) {
$options['extraParams'] = array_merge($defAttrOptions['extraParams']);
} else {
$options['extraParams'] = array_merge($defAttrOptions['extraParams'], (array) $options['extraParams']);
}
//merge extraParams first so we don't loose authentication
$options = array_merge($defAttrOptions, $options);
foreach ($options as $key => &$value) {
$value = apply_user_replacements($value);
}
if ($attribKey !== false) {
// a smpAttr control
$html .= data_entry_helper::outputAttribute($attributes[$attribKey], $options);
$attributes[$attribKey]['handled'] = true;
} else {
//.........这里部分代码省略.........
示例15: get_form
/**
* Return the generated form output.
* @return Form HTML.
*/
public static function get_form($args, $node)
{
global $user;
// There is a language entry in the args parameter list: this is derived from the $language DRUPAL global.
// It holds the 2 letter code, used to pick the language file from the lang subdirectory of prebuilt_forms.
// There should be no explicitly output text in this file.
// We must translate any field names and ensure that the termlists and taxonlists use the correct language.
// For attributes, the caption is automatically translated by data_entry_helper.
$logged_in = $user->uid > 0;
$uid = $user->uid;
$email = $user->mail;
$username = $user->name;
if (!user_access('IForm n' . $node->nid . ' access')) {
return "<p>" . lang::get('LANG_Insufficient_Privileges') . "</p>";
}
$r = '';
// Get authorisation tokens to update and read from the Warehouse.
$readAuth = data_entry_helper::get_read_auth($args['website_id'], $args['password']);
$svcUrl = data_entry_helper::$base_url . '/index.php/services';
drupal_add_js(drupal_get_path('module', 'iform') . '/media/js/jquery.form.js', 'module');
data_entry_helper::link_default_stylesheet();
data_entry_helper::add_resource('jquery_ui');
data_entry_helper::enable_validation('cc-1-collection-details');
// don't care about ID itself, just want resources
if ($args['help_module'] != '' && $args['help_inclusion_function'] != '' && module_exists($args['help_module']) && function_exists($args['help_inclusion_function'])) {
$use_help = true;
data_entry_helper::$javascript .= call_user_func($args['help_inclusion_function']);
} else {
$use_help = false;
}
if ($args['ID_tool_module'] != '' && $args['ID_tool_inclusion_function'] != '' && module_exists($args['ID_tool_module']) && function_exists($args['ID_tool_inclusion_function'])) {
$use_ID_tool = true;
data_entry_helper::$javascript .= call_user_func($args['ID_tool_inclusion_function']);
} else {
$use_ID_tool = false;
}
// The only things that will be editable after the collection is saved will be the identifiaction of the flower/insects.
// no id - just getting the attributes, rest will be filled in using AJAX
$sample_attributes = data_entry_helper::getAttributes(array('valuetable' => 'sample_attribute_value', 'attrtable' => 'sample_attribute', 'key' => 'sample_id', 'fieldprefix' => 'smpAttr', 'extraParams' => $readAuth, 'survey_id' => $args['survey_id']));
$occurrence_attributes = data_entry_helper::getAttributes(array('valuetable' => 'occurrence_attribute_value', 'attrtable' => 'occurrence_attribute', 'key' => 'occurrence_id', 'fieldprefix' => 'occAttr', 'extraParams' => $readAuth, 'survey_id' => $args['survey_id']));
$location_attributes = data_entry_helper::getAttributes(array('valuetable' => 'location_attribute_value', 'attrtable' => 'location_attribute', 'key' => 'location_id', 'fieldprefix' => 'locAttr', 'extraParams' => $readAuth, 'survey_id' => $args['survey_id']));
$defAttrOptions = array('extraParams' => $readAuth, 'lookUpListCtrl' => 'radio_group', 'validation' => array('required'), 'language' => iform_lang_iso_639_2($args['language']), 'containerClass' => 'group-control-box', 'suffixTemplate' => 'nosuffix');
$language = iform_lang_iso_639_2($args['language']);
global $indicia_templates;
$indicia_templates['sref_textbox_latlong'] = '<label for="{idLat}">{labelLat}:</label>' . '<input type="text" id="{idLat}" name="{fieldnameLat}" {class} {disabled} value="{default}" />' . '<label for="{idLong}">{labelLong}:</label>' . '<input type="text" id="{idLong}" name="{fieldnameLong}" {class} {disabled} value="{default}" />';
$r .= data_entry_helper::loading_block_start();
// note we have to proxy the post. Every time a write transaction is carried out, the write nonce is trashed.
// For security reasons we don't want to give the user the ability to generate their own nonce, so we use
// the fact that the user is logged in to drupal as the main authentication/authorisation/identification
// process for the user. The proxy packages the post into the correct format
//
// There are 2 types of submission:
// When a user validates a panel using the validate button, the following panel is opened on success
// When a user presses a modify button, the open panel gets validated, and the panel to be modified is opened.
$r .= '
<div id="cc-1" class="poll-section">
<div id="cc-1-title" class="ui-accordion-header ui-helper-reset ui-state-active ui-corner-top poll-section-title">
<span id="cc-1-title-details">' . lang::get('LANG_Collection_Details') . '</span>
<div class="right">
<div>
<span id="cc-1-reinit-button" class="ui-state-default ui-corner-all reinit-button">' . lang::get('LANG_Reinitialise') . '</span>
<span id="cc-1-mod-button" class="ui-state-default ui-corner-all mod-button">' . lang::get('LANG_Modify') . '</span>
</div>
</div>
</div>
<div id="cc-1-details" class="ui-accordion-content ui-helper-reset ui-widget-content ui-accordion-content-active">
<span id="cc-1-protocol-details"></span>
</div>
<div id="cc-1-body" class="ui-accordion-content ui-helper-reset ui-widget-content ui-accordion-content-active poll-section-body">
<form id="cc-1-collection-details" action="' . iform_ajaxproxy_url($node, 'loc-sample') . '" method="POST">
<input type="hidden" id="website_id" name="website_id" value="' . $args['website_id'] . '" />
<input type="hidden" id="imp-sref" name="location:centroid_sref" value="" />
<input type="hidden" id="imp-geom" name="location:centroid_geom" value="" />
<input type="hidden" id="imp-sref-system" name="location:centroid_sref_system" value="4326" />
<input type="hidden" id="sample:survey_id" name="sample:survey_id" value="' . $args['survey_id'] . '" />
' . iform_pollenators::help_button($use_help, "collection-help-button", $args['help_function'], $args['help_collection_arg']) . '
<label for="location:name">' . lang::get('LANG_Collection_Name_Label') . '</label>
<input type="text" id="location:name" name="location:name" value="" class="required"/>
<input type="hidden" id="sample:location_name" name="sample:location_name" value=""/>
' . data_entry_helper::outputAttribute($sample_attributes[$args['protocol_attr_id']], $defAttrOptions) . ' <input type="hidden" name="sample:date" value="2010-01-01"/>
<input type="hidden" id="smpAttr:' . $args['complete_attr_id'] . '" name="smpAttr:' . $args['complete_attr_id'] . '" value="0" />
<input type="hidden" id="smpAttr:' . $args['uid_attr_id'] . '" name="smpAttr:' . $args['uid_attr_id'] . '" value="' . $uid . '" />
<input type="hidden" id="smpAttr:' . $args['email_attr_id'] . '" name="smpAttr:' . $args['email_attr_id'] . '" value="' . $email . '" />
<input type="hidden" id="smpAttr:' . $args['username_attr_id'] . '" name="smpAttr:' . $args['username_attr_id'] . '" value="' . $username . '" />
<input type="hidden" id="locations_website:website_id" name="locations_website:website_id" value="' . $args['website_id'] . '" />
<input type="hidden" id="location:id" name="location:id" value="" disabled="disabled" />
<input type="hidden" id="sample:id" name="sample:id" value="" disabled="disabled" />
</form>
<div id="cc-1-valid-button" class="ui-state-default ui-corner-all save-button">' . lang::get('LANG_Validate') . '</div>
</div>
<div style="display:none" />
<form id="cc-1-delete-collection" action="' . iform_ajaxproxy_url($node, 'sample') . '" method="POST">
<input type="hidden" name="website_id" value="' . $args['website_id'] . '" />
<input type="hidden" name="sample:survey_id" value="' . $args['survey_id'] . '" />
<input type="hidden" name="sample:id" value="" />
<input type="hidden" name="sample:date" value="2010-01-01"/>
//.........这里部分代码省略.........