Ejemplo n.º 1
0
/**
 * Return a list of options to pass to the data_entry_helper::map_panel method, built from the prebuilt
 * form arguments.
 * @param $args
 * @param $readAuth
 * @return array Options array for the map.
 */
function iform_map_get_map_options($args, $readAuth)
{
    // read out the activated preset layers
    $presetLayers = array();
    if (!empty($args['preset_layers'])) {
        foreach ($args['preset_layers'] as $key => $value) {
            if (is_int($key)) {
                // normally a checkbox group would just output an array
                $presetLayers[] = $value;
            } elseif ($value !== 0) {
                // but the Drupal version of the the parameters form (deprecated) leaves a strange array structure in the parameter value.
                $presetLayers[] = $key;
            }
        }
    }
    $options = array('readAuth' => $readAuth, 'presetLayers' => $presetLayers, 'editLayer' => true, 'layers' => array(), 'initial_lat' => $args['map_centroid_lat'], 'initial_long' => $args['map_centroid_long'], 'initial_zoom' => (int) $args['map_zoom'], 'width' => $args['map_width'], 'height' => $args['map_height'], 'standardControls' => array('layerSwitcher', 'panZoomBar'), 'rememberPos' => isset($args['remember_pos']) ? $args['remember_pos'] == true : false);
    // If they have defined a custom base layer, add it
    if (!empty($args['wms_base_title']) && !empty($args['wms_base_url']) && !empty($args['wms_base_layer'])) {
        data_entry_helper::$onload_javascript .= "var baseLayer = new OpenLayers.Layer.WMS(\n      '" . $args['wms_base_title'] . "',\n      '" . $args['wms_base_url'] . "',\n      {layers: '" . $args['wms_base_layer'] . "', sphericalMercator: true}, {singleTile: true}\n    );\n";
        $options['layers'][] = 'baseLayer';
    }
    // Also add any tilecaches they have defined
    if (!empty($args['tile_cache_layers'])) {
        $options['tilecacheLayers'] = json_decode($args['tile_cache_layers'], true);
    }
    // And any indicia Wms layers from the GeoServer
    if (!empty($args['indicia_wms_layers'])) {
        $options['indiciaWMSLayers'] = explode("\n", $args['indicia_wms_layers']);
    }
    // set up standard control list if supplied
    if (array_key_exists('standard_controls', $args) && $args['standard_controls']) {
        $args['standard_controls'] = str_replace("\r\n", "\n", $args['standard_controls']);
        $options['standardControls'] = explode("\n", $args['standard_controls']);
        // If drawing controls are enabled, then allow polygon recording.
        if (in_array('drawPolygon', $options['standardControls']) || in_array('drawLine', $options['standardControls'])) {
            $options['allowPolygonRecording'] = true;
        }
    }
    // And pass through any translation strings, only if they exist
    $msgGeorefSelectPlace = lang::get('LANG_Georef_SelectPlace');
    if ($msgGeorefSelectPlace != 'LANG_Georef_SelectPlace') {
        $options['msgGeorefSelectPlace'] = $msgGeorefSelectPlace;
    }
    $msgGeorefNothingFound = lang::get('LANG_Georef_NothingFound');
    if ($msgGeorefNothingFound != 'LANG_Georef_NothingFound') {
        $options['msgGeorefNothingFound'] = $msgGeorefNothingFound;
    }
    // if in Drupal, and IForm proxy is installed, then use this path as OpenLayers proxy
    if (defined('DRUPAL_BOOTSTRAP_CONFIGURATION') && module_exists('iform_proxy')) {
        global $base_url;
        $options['proxy'] = $base_url . '/?q=' . variable_get('iform_proxy_path', 'proxy') . '&url=';
    }
    // And a single location boundary if defined
    if (!empty($args['location_boundary_id'])) {
        $location = $args['location_boundary_id'];
    } elseif (isset($args['display_user_profile_location']) && $args['display_user_profile_location']) {
        $location = hostsite_get_user_field('location');
    }
    if (!empty($location)) {
        iform_map_zoom_to_location($location, $readAuth);
    }
    return $options;
}
Ejemplo n.º 2
0
 private static function get_template_with_map($args, $readAuth, $extraParams, $paramDefaults)
 {
     $r = '<div id="outer-with-map" class="ui-helper-clearfix">';
     $r .= '<div id="grid" class="left" style="width:65%">{paramsForm}{grid}';
     // Insert a button to verify all visible, only available if viewing the clean records.
     if (isset($_POST['verification-rule']) && $_POST['verification-rule'] === 'none' && empty($_POST['verification-id'])) {
         $r .= '<button type="button" id="btn-verify-all">' . lang::get('Verify all visible') . '</button>';
     }
     $r .= '</div>';
     $r .= '<div id="map-and-record" class="right" style="width: 34%"><div id="summary-map">';
     $options = iform_map_get_map_options($args, $readAuth);
     $olOptions = iform_map_get_ol_options($args);
     // This is used for drawing, so need an editlayer, but not used for input
     $options['editLayer'] = true;
     $options['editLayerInSwitcher'] = true;
     $options['clickForSpatialRef'] = false;
     $options['featureIdField'] = 'occurrence_id';
     $r .= map_helper::map_panel($options, $olOptions);
     $reportMapOpts = array('dataSource' => !empty($args['mapping_report_name']) ? $args['mapping_report_name'] : $args['report_name'], 'mode' => 'report', 'readAuth' => $readAuth, 'autoParamsForm' => false, 'extraParams' => $extraParams, 'paramDefaults' => $paramDefaults, 'reportGroup' => 'verification', 'clickableLayersOutputMode' => 'report', 'rowId' => 'occurrence_id', 'sharing' => 'verification', 'ajax' => TRUE);
     if (!empty($args['mapping_report_name_lores'])) {
         $reportMapOpts['dataSourceLoRes'] = $args['mapping_report_name_lores'];
     }
     $r .= report_helper::report_map($reportMapOpts);
     $r .= '</div>';
     global $user;
     if (function_exists('hostsite_get_user_field') && ($locationId = hostsite_get_user_field('location_expertise', false))) {
         iform_map_zoom_to_location($locationId, $readAuth);
     }
     $r .= '<div id="record-details-wrap" class="ui-widget ui-widget-content">';
     $r .= self::instructions('grid on the left');
     $r .= '<div id="record-details-content" style="display: none">';
     $r .= '<div id="record-details-toolbar">';
     $r .= '<label>Set status:</label>';
     $r .= '<button type="button" id="btn-verify">' . lang::get('Verify') . '</button>';
     $r .= '<button type="button" id="btn-reject">' . lang::get('Reject') . '</button>';
     $r .= '<button type="button" id="btn-query">' . lang::get('Query') . '</button>';
     $r .= '<button type="button" id="btn-multiple" title="' . lang::get('Select this tool to tick off a list of records and action all of the ticked records in one go') . '">' . lang::get('Select records') . '</button>';
     $r .= '<br/><label>Contact:</label>';
     $r .= '<button type="button" id="btn-email-expert" class="default-button">' . lang::get('Another expert') . '</button>';
     $r .= '<button type="button" id="btn-email-recorder" class="default-button">' . lang::get('Recorder') . '</button>';
     $r .= '</div>';
     $r .= '<div id="record-details-tabs">';
     // note - there is a dependency in the JS that comments is the last tab and images the 2nd to last.
     $r .= data_entry_helper::tab_header(array('tabs' => array('#details-tab' => lang::get('Details'), '#experience-tab' => lang::get('Experience'), '#phenology-tab' => lang::get('Phenology'), '#images-tab' => lang::get('Images'), '#comments-tab' => lang::get('Comments'))));
     data_entry_helper::$javascript .= "indiciaData.detailsTabs = ['details','experience','phenology','images','comments'];\n";
     data_entry_helper::enable_tabs(array('divId' => 'record-details-tabs'));
     $r .= '<div id="details-tab"></div>';
     $r .= self::other_tab_html();
     $r .= '</div></div></div></div></div>';
     return $r;
 }
Ejemplo n.º 3
0
 private static function get_template_with_map($args, $readAuth, $extraParams, $paramDefaults)
 {
     $r = '<div id="outer-with-map" class="ui-helper-clearfix">';
     $r .= '<div id="grid" class="left" style="width:65%">{paramsForm}{grid}</div>';
     $r .= '<div id="map-and-record" class="right" style="width: 34%"><div id="summary-map">';
     $options = iform_map_get_map_options($args, $readAuth);
     $olOptions = iform_map_get_ol_options($args);
     // This is used for drawing, so need an editlayer, but not used for input
     $options['editLayer'] = true;
     $options['editLayerInSwitcher'] = true;
     $options['clickForSpatialRef'] = false;
     $options['featureIdField'] = 'occurrence_id';
     $r .= map_helper::map_panel($options, $olOptions);
     $reportMapOpts = array('dataSource' => !empty($args['mapping_report_name']) ? $args['mapping_report_name'] : $args['report_name'], 'mode' => 'report', 'readAuth' => $readAuth, 'autoParamsForm' => false, 'extraParams' => $extraParams, 'paramDefaults' => $paramDefaults, 'reportGroup' => 'verification', 'clickableLayersOutputMode' => 'report', 'rowId' => 'occurrence_id', 'sharing' => 'verification', 'ajax' => TRUE);
     if (!empty($args['mapping_report_name_lores'])) {
         $reportMapOpts['dataSourceLoRes'] = $args['mapping_report_name_lores'];
     }
     $r .= report_helper::report_map($reportMapOpts);
     $r .= '</div>';
     global $user;
     if (function_exists('hostsite_get_user_field') && ($locationId = hostsite_get_user_field('location_expertise', false))) {
         iform_map_zoom_to_location($locationId, $readAuth);
     }
     $r .= '<div id="record-details-wrap" class="ui-widget ui-widget-content">';
     $r .= self::instructions('grid on the left');
     $r .= '<div id="record-details-content" style="display: none">';
     $r .= '<div id="record-details-toolbar">';
     $r .= '<div id="verify-buttons">';
     $r .= '<div id="verify-buttons-inner">';
     $r .= '<label>' . lang::get('Actions:') . '</label>';
     $imgPath = empty(data_entry_helper::$images_path) ? data_entry_helper::relative_client_helper_path() . "../media/images/" : data_entry_helper::$images_path;
     $r .= '<button type="button" id="btn-verify" title="' . lang::get('Verify') . '"><img width="18" height="18" src="' . $imgPath . 'nuvola/ok-16px.png"/></button>';
     $r .= '<button type="button" id="btn-edit-verify" title="' . lang::get('Edit determination then verify') . '"><img width="18" height="18" src="' . $imgPath . 'nuvola/package_editors-16px.png"/>' . '<img width="18" height="18" src="' . $imgPath . 'nuvola/ok-16px.png"/></button>';
     $r .= '<button type="button" id="btn-reject" title="' . lang::get('Reject') . '"><img width="18" height="18" src="' . $imgPath . 'nuvola/cancel-16px.png"/></button>';
     $r .= '<button type="button" id="btn-query" title="' . lang::get('Query') . '"><img width="18" height="18" src="' . $imgPath . 'nuvola/dubious-16px.png"/></button>';
     $r .= '<div id="redet-dropdown-ctnr" style="display: none"><div id="redet-dropdown">';
     $r .= data_entry_helper::species_autocomplete(array('fieldname' => 'redet', 'label' => lang::get('New determination'), 'labelClass' => 'auto', 'helpText' => lang::get('Enter a new determination for this record before verifying it. The previous determination will be stored with the record.'), 'cacheLookup' => true, 'extraParams' => $readAuth + array('taxon_list_id' => 1), 'speciesIncludeBothNames' => true, 'speciesIncludeTaxonGroup' => true));
     $r .= '</div></div>';
     $r .= '</div></div>';
     $r .= '<label>Contact:</label>';
     $r .= '<button type="button" id="btn-email-expert" class="default-button">' . lang::get('Another expert') . '</button>';
     $r .= '<button type="button" id="btn-email-recorder" class="default-button">' . lang::get('Recorder') . '</button>';
     $r .= '</div>';
     $r .= '<div id="record-details-tabs">';
     // note - there is a dependency in the JS that comments is the last tab and media the 2nd to last.
     $r .= data_entry_helper::tab_header(array('tabs' => array('#details-tab' => lang::get('Details'), '#experience-tab' => lang::get('Experience'), '#phenology-tab' => lang::get('Phenology'), '#media-tab' => lang::get('Media'), '#comments-tab' => lang::get('Comments'))));
     data_entry_helper::$javascript .= "indiciaData.detailsTabs = ['details','experience','phenology','media','comments'];\n";
     data_entry_helper::enable_tabs(array('divId' => 'record-details-tabs'));
     $r .= '<div id="details-tab"></div>';
     $r .= self::other_tab_html();
     $r .= '</div></div></div></div></div>';
     return $r;
 }
 private static function get_template_with_map($args, $readAuth, $extraParams, $paramDefaults)
 {
     $r = '<div id="outer-with-map" class="ui-helper-clearfix">';
     $r .= '<div id="grid" class="left" style="width:65%">{paramsForm}{grid}</div>';
     $r .= '<div id="map-and-record" class="right" style="width: 34%"><div id="summary-map">';
     $options = iform_map_get_map_options($args, $readAuth);
     $olOptions = iform_map_get_ol_options($args);
     // This is used for drawing, so need an editlayer, but not used for input
     $options['editLayer'] = true;
     $options['editLayerInSwitcher'] = true;
     $options['clickForSpatialRef'] = false;
     $options['featureIdField'] = 'sample_id';
     $r .= map_helper::map_panel($options, $olOptions);
     $reportMapOpts = array('dataSource' => !empty($args['mapping_report_name']) ? $args['mapping_report_name'] : $args['report_name'], 'mode' => 'report', 'readAuth' => $readAuth, 'autoParamsForm' => false, 'extraParams' => $extraParams, 'paramDefaults' => $paramDefaults, 'reportGroup' => 'verification', 'clickableLayersOutputMode' => 'report', 'rowId' => 'sample_id', 'sharing' => 'verification', 'ajax' => TRUE);
     $r .= report_helper::report_map($reportMapOpts);
     $r .= '</div>';
     if (function_exists('hostsite_get_user_field') && ($locationId = hostsite_get_user_field('location_expertise', false))) {
         iform_map_zoom_to_location($locationId, $readAuth);
     }
     $r .= '<div id="record-details-wrap" class="ui-widget ui-widget-content">';
     $r .= self::instructions('grid on the left');
     $r .= '<div id="record-details-content" style="display: none">';
     $r .= '<div id="record-details-toolbar">';
     $r .= '<div id="action-buttons">';
     $r .= '<div id="action-buttons-status" class="action-buttons-row">';
     $r .= '<div class="col-1"><label>' . lang::get('Set status:') . '</label></div>';
     $imgPath = empty(data_entry_helper::$images_path) ? data_entry_helper::relative_client_helper_path() . "../media/images/" : data_entry_helper::$images_path;
     $r .= self::status_buttons($imgPath);
     $r .= '</div>';
     $r .= '<div id="action-buttons-other" class="action-buttons-row"><div class="col-1"><label>Other actions:</label></div>';
     $r .= self::other_action_buttons($imgPath);
     $r .= '</div></div>';
     $r .= '<div id="record-details-tabs">';
     // note - there is a dependency in the JS that comments is the last tab and media the 2nd to last.
     $r .= data_entry_helper::tab_header(array('tabs' => array('#details-tab' => lang::get('Details'), '#media-tab' => lang::get('Media'), '#comments-tab' => lang::get('Comments'))));
     data_entry_helper::$javascript .= "indiciaData.detailsTabs = ['details','media','comments'];\n";
     data_entry_helper::enable_tabs(array('divId' => 'record-details-tabs'));
     $r .= '<div id="details-tab"></div>';
     $r .= self::other_tab_html();
     $r .= '</div></div></div></div></div>';
     return $r;
 }