本文整理汇总了PHP中data_entry_helper::get_auth方法的典型用法代码示例。如果您正苦于以下问题:PHP data_entry_helper::get_auth方法的具体用法?PHP data_entry_helper::get_auth怎么用?PHP data_entry_helper::get_auth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类data_entry_helper
的用法示例。
在下文中一共展示了data_entry_helper::get_auth方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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_form
/**
* Return the generated form output.
* @return Form HTML.
*/
public static function get_form($args, $node)
{
global $user;
$logged_in = $user->uid > 0;
$r = '';
// Get authorisation tokens to update and read from the Warehouse.
$writeAuth = data_entry_helper::get_auth($args['website_id'], $args['password']);
$readAuth = data_entry_helper::get_read_auth($args['website_id'], $args['password']);
$svcUrl = data_entry_helper::$base_url . '/index.php/services';
$mode = 0;
// default mode : display survey selector
// mode 1: display new sample
// mode 2: display existing sample
$loadID = null;
$displayThisOcc = true;
// when populating from the DB rather than POST we have to be
// careful with selection object, as geom in wrong format.
if ($_POST) {
if (!is_null(data_entry_helper::$entity_to_load)) {
$mode = 2;
// errors with new sample, entity poulated with post, so display this data.
}
// else valid save, so go back to gridview: default mode 0
} else {
if (array_key_exists('sample_id', $_GET)) {
$mode = 2;
$loadID = $_GET['sample_id'];
} else {
if (array_key_exists('newSample', $_GET)) {
$mode = 1;
data_entry_helper::$entity_to_load = array();
}
}
// else default to mode 0
}
///////////////////////////////////////////////////////////////////
// default mode 0 : display survey selector
///////////////////////////////////////////////////////////////////
if ($mode == 0) {
// Create the Sample list datagrid for this user.
drupal_add_js(drupal_get_path('module', 'iform') . '/media/js/hasharray.js', 'module');
drupal_add_js(drupal_get_path('module', 'iform') . '/media/js/jquery.datagrid.js', 'module');
drupal_add_js("jQuery(document).ready(function(){\n \$('div#smp_grid').indiciaDataGrid('rpt:mnhnl_collab_list_samples', {\n indiciaSvc: '" . $svcUrl . "',\n dataColumns: ['location_name', 'entered_sref', 'date', 'num_occurrences', 'completed'],\n reportColumnTitles: {location_name : '" . lang::get('LANG_Location') . "', entered_sref : '" . lang::get('LANG_Spatial_ref') . "', date : '" . lang::get('LANG_Date') . "', num_occurrences : '" . lang::get('LANG_Num_Occurrences') . "', completed : '" . lang::get('LANG_Completed') . "'},\n actionColumns: {" . lang::get('LANG_Edit') . " : \"" . url('node/' . $node->nid, array('query' => 'sample_id=�id�')) . "\"},\n auth : { nonce : '" . $readAuth['nonce'] . "', auth_token : '" . $readAuth['auth_token'] . "'},\n parameters : {\n \t\t\tsurvey_id : '" . $args['survey_id'] . "',\n \t\t\tuserID_attr_id : '" . $args['uid_attr_id'] . "',\n \t\t\tuserID : '" . $user->uid . "'\n \t\t\t\t},\n itemsPerPage : 12 \n });\n});\n\n", 'inline');
$r .= '<div id="sampleList" class="mnhnl-btw-datapanel"><div id="smp_grid"></div>';
$r .= '<form><input type="button" value="' . lang::get('LANG_Add_Sample') . '" onclick="window.location.href=\'' . url('node/' . $node->nid, array('query' => 'newSample')) . '\'"></form></div>';
$r .= "</div>\n";
return $r;
}
///////////////////////////////////////////////////////////////////
data_entry_helper::$javascript .= "\n// Create vector layers: one to display the location onto, and another for the occurrence list\n// the default edit layer is used for the occurrences themselves\nlocStyleMap = new OpenLayers.StyleMap({\n \"default\": new OpenLayers.Style({\n fillColor: \"Green\",\n strokeColor: \"Black\",\n fillOpacity: 0.3,\n strokeWidth: 1\n })\n });\nlocationLayer = new OpenLayers.Layer.Vector(\"" . lang::get("LANG_Location_Layer") . "\",\n {styleMap: locStyleMap});\n";
if ($loadID) {
// Can't cache these as data may have just changed
data_entry_helper::$entity_to_load['occurrence:record_status'] = 'I';
$url = $svcUrl . '/data/sample/' . $loadID;
$url .= "?mode=json&view=detail&auth_token=" . $readAuth['auth_token'] . "&nonce=" . $readAuth["nonce"];
$session = curl_init($url);
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
$entity = json_decode(curl_exec($session), true);
// Attributes should be loaded by get_attributes.
data_entry_helper::$entity_to_load = array();
foreach ($entity[0] as $key => $value) {
data_entry_helper::$entity_to_load['sample:' . $key] = $value;
}
$url = $svcUrl . '/data/occurrence';
$url .= "?mode=json&view=detail&auth_token=" . $readAuth['auth_token'] . "&nonce=" . $readAuth["nonce"] . "&sample_id=" . $loadID . "&deleted=FALSE";
$session = curl_init($url);
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
$entities = json_decode(curl_exec($session), true);
foreach ($entities as $entity) {
data_entry_helper::$entity_to_load['occurrence:record_status'] = $entity['record_status'];
data_entry_helper::$entity_to_load['sc:' . $entity['taxa_taxon_list_id'] . ':' . $entity['id'] . ':present'] = true;
}
data_entry_helper::$entity_to_load['sample:geom'] = '';
// value received from db is not WKT, which is assumed by all the code.
data_entry_helper::$entity_to_load['sample:date'] = data_entry_helper::$entity_to_load['sample:date_start'];
// bit of a bodge to get around vague dates.
}
$defAttrOptions = array('extraParams' => $readAuth);
// $r .= "<h1>MODE = ".$mode."</h1>";
// $r .= "<h2>readOnly = ".$readOnly."</h2>";
$r = "<form method=\"post\" id=\"entry_form\">\n";
// Get authorisation tokens to update and read from the Warehouse.
$r .= $writeAuth;
$r .= "<input type=\"hidden\" id=\"website_id\" name=\"website_id\" value=\"" . $args['website_id'] . "\" />\n";
$r .= "<input type=\"hidden\" id=\"sample:survey_id\" name=\"sample:survey_id\" value=\"" . $args['survey_id'] . "\" />\n";
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";
}
// request automatic JS validation
data_entry_helper::enable_validation('entry_form');
$attributes = data_entry_helper::getAttributes(array('id' => data_entry_helper::$entity_to_load['sample:id'], 'valuetable' => 'sample_attribute_value', 'attrtable' => 'sample_attribute', 'key' => 'sample_id', 'fieldprefix' => 'smpAttr', 'extraParams' => $readAuth, 'survey_id' => $args['survey_id']));
if ($logged_in) {
// If logged in, output some hidden data about the user
$uid = $user->uid;
$email = $user->mail;
$username = $user->name;
//.........这里部分代码省略.........
示例5: get_form
//.........这里部分代码省略.........
}
$r .= "</fieldset>\n";
}
// Species tab
$r .= "<fieldset id=\"species\">\n";
if ($args['interface'] == 'one_page') {
$r .= '<legend>' . lang::get('what did you see') . '</legend>';
}
$species_list_args = array('label' => lang::get('Species'), 'fieldname' => 'occurrence:taxa_taxon_list_id', 'table' => 'taxa_taxon_list', 'captionField' => 'taxon', 'valueField' => 'id', 'listId' => $args['species_list_id'], 'columns' => 1, 'parentField' => 'parent_id', 'checkboxCol' => false, 'occAttrs' => array($args['abundance_attr_id']), 'extraParams' => $readAuth + array('view' => 'detail', 'orderby' => 'taxonomic_sort_order'), 'survey_id' => $args['survey_id'], 'header' => false, 'view' => 'detail', 'PHPtaxonLabel' => true);
// Build a nice template to show a picture of each species, with fancybox.
data_entry_helper::add_resource('fancybox');
data_entry_helper::$javascript .= "jQuery('a.fancybox').fancybox();\n";
$indicia_templates['taxon_label'] = 'return \'<div class="taxon-cell">' . '<a href="' . data_entry_helper::$base_url . 'upload/{image_path}" class="fancybox" >' . '<img alt="{taxon}" src="' . data_entry_helper::$base_url . 'upload/med-{image_path}" width="250"/></a>' . '<div>{taxon}</div></div>' . '<div class="taxon-desc"><ul><li>\'.str_replace("\\n", "</li><li>","{description_in_list}").\'</li></ul>' . '<a href="http://www.marine-life.org.uk/northeastcetaceans/?q=\'.
strtolower(str_replace(array(" ", "\\\'"), array("-", ""), "{taxon}")).
\'" target="_blank" class="ui-state-default ui-corner-all indicia-button">' . lang::get('More Info') . '...</a></div>\';';
// Template the taxon label cell
$indicia_templates['taxon_label_cell'] = "\n<td class='scTaxonCell'>{content}</td>";
// Also template the attribute controls to show the label in place.
$indicia_templates['attribute_cell'] = "\n<td class='scOccAttrCell'><label>{label}:</label><br/>{content}</td>";
$r .= data_entry_helper::species_checklist($species_list_args);
if ($args['interface'] == 'wizard') {
$r .= data_entry_helper::wizard_buttons(array('divId' => 'controls', 'page' => $user->uid == 0 ? 'middle' : 'first'));
}
$r .= "</fieldset>";
// --Place tab--
$r .= "<fieldset id=\"place\">\n";
if ($args['interface'] == 'one_page') {
$r .= '<legend>' . lang::get('where was it') . '</legend>';
}
$r .= data_entry_helper::radio_group(array('label' => 'Where were you when you made the sighting?', 'fieldname' => 'smpAttr:' . $args['platform_attr_id'], 'table' => 'termlists_term', 'captionField' => 'term', 'valueField' => 'id', 'extraParams' => $readAuth + array('termlist_id' => $args['platform_termlist_id']), 'sep' => '<br />', 'labelClass' => 'auto', 'class' => 'inline sighting-platform', 'validation' => array('required')));
$r .= '<div id="place_wrapper" class="hidden">';
// Some instructions only visible when entering data from a boat
$r .= '<p class="boat_mode page-notice ui-state-highlight ui-corner-all">' . lang::get('Instructions for when on boat') . '</p>';
// Some instructions only visible when entering data from the shore
$r .= '<p class="shore_mode page-notice ui-state-highlight ui-corner-all">' . lang::get('Instructions for clicking on map') . '</p>';
$r .= '<div class="boat_mode">';
// Add help examples to the lat and long boxes
$indicia_templates['sref_textbox_latlong'] = '<label for="{idLat}">{labelLat}:</label>' . '<input type="text" id="{idLat}" name="{fieldnameLat}" {class} {disabled} value="{default}" /> <p class="helpText">e.g. 55:12.345N</p>' . '<label for="{idLong}">{labelLong}:</label>' . '<input type="text" id="{idLong}" name="{fieldnameLong}" {class} {disabled} value="{default}" /> <p class="helpText">e.g. 0:45.678W</p>' . '<input type="hidden" id="imp-geom" name="{table}:geom" value="{defaultGeom}" />' . '<input type="text" id="{id}" name="{fieldname}" style="display:none" value="{default}" />';
$r .= data_entry_helper::sref_and_system(array('systems' => array(4326 => lang::get('Latitude, Longitude')), 'splitLatLong' => true, 'helpText' => lang::get('Instructions for latlong')));
$r .= '</div>';
// Initially, we hide the map. Only show it when the user selects the sighting was from the shore,
// as a click on the map for boat recordings will not be accurate.
$r .= '<div class="shore_mode">';
$options = iform_map_get_map_options($args, $readAuth);
$olOptions = iform_map_get_ol_options($args);
$options['maxZoom'] = 9;
// Switch to degrees and decimal minutes for lat long.
$options['latLongFormat'] = 'DM';
$r .= data_entry_helper::map_panel($options, $olOptions);
// Now, add some JavaScript to show or hide the map. Show it for when the sighting was from the shore.
// Hide it for boat based sightings as we want a GPS coordinate in this case. The JavaScript looks for the
// checked radio button to see the value
data_entry_helper::$javascript .= 'jQuery(".sighting-platform input").click(
function() {
var platformId = jQuery("input[name=smpAttr\\\\:' . $args['platform_attr_id'] . ']:checked").val();
if (platformId == ' . $args['platform_mapped_term_id'] . ') {
jQuery("#place_wrapper").removeClass("hidden");
jQuery(".shore_mode").removeClass("hidden");
jQuery(".boat_mode").addClass("hidden");
} else {
jQuery("#place_wrapper").removeClass("hidden");
jQuery(".shore_mode").addClass("hidden");
jQuery(".boat_mode").removeClass("hidden");
}
}
);' . "\n";
// Force existing setting of the radio buttons to reload when showign page after validation failure
data_entry_helper::$onload_javascript .= '
jQuery("input[name=smpAttr\\\\:' . $args['platform_attr_id'] . ']:checked").trigger("click");
';
$r .= '</div></div>';
if ($args['interface'] == 'wizard') {
$r .= data_entry_helper::wizard_buttons(array('divId' => 'controls'));
}
$r .= '</fieldset>';
// --Other information tab--
$r .= "<fieldset id=\"other\">\n";
// Get authorisation tokens to update and read from the Warehouse.
$r .= data_entry_helper::get_auth($args['website_id'], $args['password']);
$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=\"occurrence:record_status\" value=\"C\" />\n";
if ($args['interface'] == 'one_page') {
$r .= '<legend>' . lang::get('other information') . '</legend>';
}
$r .= data_entry_helper::date_picker(array('label' => lang::get('Sighting Date'), 'fieldname' => 'sample:date'));
$indicia_templates['timeFormat'] = '<label>hh:mm</label><br/>';
$r .= data_entry_helper::text_input(array('label' => lang::get('Sighting Time'), 'fieldname' => 'smpAttr:' . $args['sample_time_attr_id'], 'class' => 'control-width-1', 'suffixTemplate' => 'timeFormat'));
$r .= data_entry_helper::textarea(array('label' => lang::get('Any other information'), 'fieldname' => 'sample:comment', 'class' => 'control-width-6', 'helpText' => lang::get('Instructions for any other info')));
$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></div>";
$r .= "</form>";
$r .= data_entry_helper::loading_block_end();
return $r;
}
示例6: curl_setopt
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
$entity = json_decode(curl_exec($session), true);
$entity_to_load = $entity[0];
} else {
$entity = null;
}
}
}
global $reload_post_data;
$reload_post_data = true;
?>
<form method="post" enctype="multipart/form-data" >
<?php
// Get authentication information
echo data_entry_helper::get_auth($config['website_id'], $config['password']);
?>
<input type='hidden' id='website_id' name='website_id' value='1' />
<input type='hidden' id='record_status' name='record_status' value='C' />
<input type='hidden' id='id' name='id' value='<?php
echo data_entry_helper::check_default_value('id');
?>
' />
<?php
echo data_entry_helper::autocomplete(array('label' => 'Taxon', 'fieldname' => 'occurrence:taxa_taxon_list_id', 'table' => 'taxa_taxon_list', 'captionField' => 'taxon', 'valueField' => 'id', 'extraParams' => $readAuth));
echo data_entry_helper::date_picker(array('label' => 'Date', 'fieldname' => 'sample:date'));
echo data_entry_helper::map();
echo data_entry_helper::text_input(array('label' => 'Locality Description', 'fieldname' => 'sample:location_name', 'class' => 'wide'));
echo data_entry_helper::select(array('label' => 'Survey', 'fieldname' => 'sample:survey_id', 'table' => 'survey', 'captionField' => 'title', 'valueField' => 'id', 'extraParams' => $readAuth));
?>
<br />
示例7: get_form
/**
* Return the generated form output.
* @return Form HTML.
*/
public static function get_form($args, $node, $response = null)
{
global $user;
$logged_in = $user->uid > 0;
$r = '';
// Get authorisation tokens to update and read from the Warehouse.
$writeAuth = data_entry_helper::get_auth($args['website_id'], $args['password']);
$readAuth = data_entry_helper::get_read_auth($args['website_id'], $args['password']);
$svcUrl = data_entry_helper::$base_url . '/index.php/services';
$presetLayers = array();
// read out the activated preset layers
if (isset($args['preset_layers'])) {
foreach ($args['preset_layers'] as $layer => $active) {
if ($active !== 0) {
$presetLayers[] = $layer;
}
}
}
// When invoked by GET there are the following modes:
// Not logged in: Display an information message.
// No additional arguments: display the survey selector.
// Additional argument - newSample: display the main page, no occurrence or occurrence list tabs. Survey tab active.
// Additional argument - sample_id=<id>: display the main page, fill in the main sample details, "Add Occurrence" tab present, survey tab active.
// Additional argument - occurrence_id=<id>: display the main page, fill in the main sample details, "Add Occurrence" tab active.
$mode = 0;
// default mode : display survey selector
// mode 1: display new sample: no occurrence list or add occurrence tabs. Survey tab active
// mode 2: display existing sample. Survey tab active. No occurence details filled in.
// mode 3: display existing occurrence. Add Occurrence tab active. Occurence details filled in.
// mode 4: NO LONGER USED. display Occurrence List. Occurrence List tab active. No occurence details filled in.
$readOnly = false;
// On top of this, things can be flagged as readonly. RO mode 2+4 means no Add Occurrence tab.
if (!$logged_in) {
return lang::get('LANG_not_logged_in');
}
$parentSample = array();
$parentErrors = null;
$parentLoadID = null;
$childSample = array();
$childErrors = null;
$childLoadID = null;
$saveErrors = data_entry_helper::$validation_errors;
$thisOccID = -1;
// IDs have to be >0, so this is outside the valid range
$displayThisOcc = true;
// when populating from the DB rather than POST we have to be
// careful with selection object, as geom in wrong format.
if ($_POST) {
if (array_key_exists('website_id', $_POST)) {
// Indicia POST, already handled.
if (array_key_exists('newSample', $_GET)) {
if (!is_null(data_entry_helper::$entity_to_load)) {
$mode = 1;
// errors with new sample, entity populated with post, so display this data.
$parentSample = data_entry_helper::$entity_to_load;
$parentErrors = $saveErrors;
} else {
// else new sample just saved, so reload it ready to add occurrences
// OR, child sample/occurrence saved against new parent sample, in which case parent sample is in the post.
$mode = 2;
$parentLoadID = array_key_exists('sample:parent_id', $_POST) ? $_POST['sample:parent_id'] : $response['outer_id'];
}
} else {
// could have saved parent sample or child sample/occurrence pair.
if (array_key_exists('sample:parent_id', $_POST)) {
// have saved child sample/occurrence pair
$parentLoadID = $_POST['sample:parent_id'];
// load the parent sample.
$mode = 3;
if (isset(data_entry_helper::$entity_to_load)) {
// errors so display Edit Occurrence page.
$childSample = data_entry_helper::$entity_to_load;
$childErrors = $saveErrors;
$displayThisOcc = false;
if ($childSample['occurrence:id']) {
$thisOccID = $childSample['occurrence:id'];
}
}
} else {
// saved parent record. display updated parent, no child.
$mode = 2;
// display parent sample details, whether errors or not.
if (isset(data_entry_helper::$entity_to_load)) {
// errors so use posted data.
$parentSample = data_entry_helper::$entity_to_load;
$parentErrors = $saveErrors;
} else {
$parentLoadID = $_POST['sample:id'];
// load the parent sample.
}
}
}
} else {
// non Indicia POST, in this case must be the location allocations. add check to ensure we don't corrept the data by accident
if (iform_loctools_checkaccess($node, 'admin') && array_key_exists('mnhnlbtw', $_POST)) {
iform_loctools_deletelocations($node);
//.........这里部分代码省略.........
示例8: get_form
/**
* Return the generated form output.
* @return Form HTML.
*/
public static function get_form($args, $node, $response = null)
{
global $user;
global $custom_terms;
$logged_in = $user->uid > 0;
$r = '';
// Get authorisation tokens to update and read from the Warehouse.
$writeAuth = data_entry_helper::get_auth($args['website_id'], $args['password']);
$readAuth = data_entry_helper::get_read_auth($args['website_id'], $args['password']);
$svcUrl = data_entry_helper::$base_url . '/index.php/services';
$presetLayers = array();
// read out the activated preset layers
if (isset($args['preset_layers'])) {
foreach ($args['preset_layers'] as $layer => $active) {
if ($active !== 0) {
$presetLayers[] = $layer;
}
}
}
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');
if ($args['language'] != 'en') {
data_entry_helper::add_resource('jquery_ui_' . $args['language']);
}
// If not logged in: Display an information message.
// This form should only be called in POST mode when setting the location allocation.
// All other posting is now done via AJAX.
// When invoked by GET there are the following modes:
// No additional arguments: mode 0.
// Additional argument - newSample: mode 1.
// Additional argument - sample_id=<id>: mode 2.
// Additional argument - occurrence_id=<id>: mode 3.
$mode = 0;
// default mode : output survey selector
// mode 1: output the main Data Entry page: occurrence list or add/edit occurrence tabs hidden. "Survey" tab active
// mode 2: output the main Data Entry page, display existing sample. Active tab determined by iform params. No occurence details filled in.
// mode 3: output the main Data Entry page, display existing occurrence. "Edit Occurrence" tab active. Occurence details filled in.
$surveyReadOnly = false;
// On top of this, things can be flagged as readonly. RO mode 2+4 means no Add Occurrence tab.
if (!$logged_in) {
return lang::get('LANG_not_logged_in');
}
$parentSample = array();
$parentLoadID = null;
$childSample = array();
$childLoadID = null;
$thisOccID = -1;
// IDs have to be >0, so this is outside the valid range
if ($_POST) {
if (!array_key_exists('website_id', $_POST)) {
// non Indicia POST, in this case must be the location allocations. add check to ensure we don't corrept the data by accident
if (iform_loctools_checkaccess($node, 'admin') && array_key_exists('mnhnlbtw', $_POST)) {
iform_loctools_deletelocations($node);
foreach ($_POST as $key => $value) {
$parts = explode(':', $key);
if ($parts[0] == 'location' && $value) {
iform_loctools_insertlocation($node, $value, $parts[1]);
}
}
}
}
} else {
if (array_key_exists('sample_id', $_GET)) {
$mode = 2;
$parentLoadID = $_GET['sample_id'];
} else {
if (array_key_exists('occurrence_id', $_GET)) {
$mode = 3;
$childLoadID = $_GET['occurrence_id'];
$thisOccID = $childLoadID;
} else {
if (array_key_exists('newSample', $_GET)) {
$mode = 1;
}
}
}
// else default to mode 0
}
// define language strings so they can be used for validation translation.
data_entry_helper::$javascript .= "var translations = [\n";
foreach ($custom_terms as $key => $value) {
if (substr($key, 0, 4) != "LANG") {
data_entry_helper::$javascript .= " {key: \"" . $key . "\", translated: \"" . $value . "\"},\n";
}
}
data_entry_helper::$javascript .= "];\n";
// define layers for all maps.
// each argument is a comma separated list eg:
// "Name:Lux Outline,URL:http://localhost/geoserver/wms,LAYERS:indicia:nation2,SRS:EPSG:2169,FORMAT:image/png,minScale:0,maxScale:1000000,units:m";
$optionArray_1 = array();
$optionArray_2 = array();
$optionArray_Location = array();
$options = explode(',', $args['layer1']);
foreach ($options as $option) {
$parts = explode(':', $option);
//.........这里部分代码省略.........