/** * Return the generated form output. * @param array $args List of parameter values passed through to the form depending on how the form has been configured. * This array always contains a value for language. * @param object $node The Drupal node object. * @param array $response When this form is reloading after saving a submission, contains the response from the service call. * Note this does not apply when redirecting (in this case the details of the saved object are in the $_GET data). * @return Form HTML. * @todo: Implement this method */ public static function get_form($args, $node, $response = null) { iform_load_helpers(array('report_helper', 'map_helper')); $conn = iform_get_connection_details($node); $readAuth = report_helper::get_read_auth($conn['website_id'], $conn['password']); $r = '<div id="leftcol">'; $reportOptions = iform_report_get_report_options($args, $readAuth); iform_report_apply_explore_user_own_preferences($reportOptions); $reportOptions = array_merge(array('rowId' => 'external_key', 'columns' => array(), 'callback' => 'grid_load', 'rememberParamsReportGroup' => 'explore', 'paramsFormButtonCaption' => lang::get('Filter')), $reportOptions); $reportOptions['rowId'] = 'external_key'; $imgPath = empty(report_helper::$images_path) ? report_helper::relative_client_helper_path() . "../media/images/" : report_helper::$images_path; $reportOptions['columns'][] = array('actions' => array(array('img' => "{$imgPath}/add.png", 'caption' => 'Click to add this species to the map'))); $r .= report_helper::report_grid($reportOptions); $r .= '</div>'; $args['indicia_species_layer_slds'] = report_helper::explode_lines($args['indicia_species_layer_slds']); $r .= '<div id="rightcol">'; $r .= '<div id="layerbox">'; $r .= '<p id="instruct">' . lang::get('Click on the + buttons in the grid to add species layers to the map. You can add up to {1} layers at a time.', count($args['indicia_species_layer_slds'])); $r .= '<p id="instruct2" style="display: none">' . lang::get('Use the - buttons to permanently remove layers, or untick the box in the legend to temporarily hide them.'); $mapOptions = iform_map_get_map_options($args, $readAuth); $mapOptions['clickForSpatialRef'] = false; $olOptions = iform_map_get_ol_options($args, $readAuth); $r .= map_helper::layer_list(array('layerTypes' => array('overlay'), 'includeSwitchers' => true, 'includeHiddenLayers' => true)); $r .= '</div>'; $r .= map_helper::map_panel($mapOptions, $olOptions); $r .= '</div>'; $websiteIds = iform_get_allowed_website_ids($readAuth); if (!empty($args['indicia_species_layer_feature_type']) && !empty(report_helper::$geoserver_url)) { $training = function_exists('hostsite_get_user_field') && hostsite_get_user_field('training') ? 't' : 'f'; $cql = 'website_id IN (' . implode(',', $websiteIds) . ') AND ' . $args['indicia_species_layer_filter_field'] . "='{filterValue}' AND record_status NOT IN ('R', 'I', 'T') AND training='{$training}'"; if (isset($_POST[$reportOptions['reportGroup'] . '-quality'])) { $quality = $_POST[$reportOptions['reportGroup'] . '-quality']; } else { $quality = $reportOptions['extraParams']['quality']; } // logic here must match the quality_check function logic on the database. switch ($quality) { case 'V': $cql .= " AND record_status='V'"; break; case 'C': $cql .= " AND (record_status='V' OR certainty='C')"; break; case 'L': $cql .= " AND (record_status='V' OR ((certainty <> 'U' OR certainty IS NULL) AND record_status <> 'D'))"; break; case '!D': $cql .= " AND record_status<>'D'"; break; case '!R': // nothing to add - rejects are always excluded } report_helper::$javascript .= "indiciaData.indiciaSpeciesLayer = {\n" . ' "title":"' . lang::get('{1}') . "\",\n" . ' "myRecords":"' . lang::get('my records') . "\",\n" . ' "userId":"' . hostsite_get_user_field('indicia_user_id') . "\",\n" . ' "featureType":"' . $args['indicia_species_layer_feature_type'] . "\",\n" . ' "wmsUrl":"' . data_entry_helper::$geoserver_url . "wms\",\n" . " \"cqlFilter\":\"{$cql}\",\n" . " \"filterField\":\"taxon_meaning_id\",\n" . ' "slds":' . json_encode($args['indicia_species_layer_slds']) . "\n" . "};\n"; } return $r; }
public static function add_template_locations_to_map($auth, $args, $tabalias, $options, $path) { if (empty($options['location_type_id']) || !preg_match('/^\\d+$/', $options['location_type_id'])) { throw new exception('Please supply a valid location_type_id option.'); } iform_load_helpers(array('report_helper')); $r = report_helper::report_map(array('readAuth' => $auth['read'], 'dataSource' => 'library/locations/locations_list_mapping', 'dataSourceLoRes' => 'library/locations/locations_list_mapping', 'extraParams' => array('location_type_id' => $options['location_type_id']), 'ajax' => TRUE, 'clickable' => FALSE)); // output a hidden grid, since the AJAX code for a report_map is in the grid. $r .= report_helper::report_grid(array('readAuth' => $auth['read'], 'dataSource' => 'library/locations/locations_list_mapping', 'extraParams' => array('location_type_id' => $options['location_type_id']), 'ajax' => TRUE, 'class' => 'report-grid hidden')); report_helper::$javascript .= "indiciaData.wantPathEditor = true;\n"; return $r; }
/** * Return the generated form output. * @param array $args List of parameter values passed through to the form depending on how the form has been configured. * This array always contains a value for language. * @param object $node The Drupal node object. * @param array $response When this form is reloading after saving a submission, contains the response from the service call. * Note this does not apply when redirecting (in this case the details of the saved object are in the $_GET data). * @return Form HTML. * @todo: Implement this method */ public static function get_form($args, $node, $response = null) { if (empty($_GET['group_id'])) { return 'This page needs a group_id URL parameter.'; } require_once 'includes/map.php'; require_once 'includes/groups.php'; global $indicia_templates; iform_load_helpers(array('report_helper', 'map_helper')); $conn = iform_get_connection_details($node); $readAuth = report_helper::get_read_auth($conn['website_id'], $conn['password']); report_helper::$javascript .= "indiciaData.website_id={$conn['website_id']};\n"; report_helper::$javascript .= "indiciaData.nodeId={$node->nid};\n"; group_authorise_form($args, $readAuth); $group = data_entry_helper::get_population_data(array('table' => 'group', 'extraParams' => $readAuth + array('id' => $_GET['group_id'], 'view' => 'detail'))); $group = $group[0]; hostsite_set_page_title("{$group['title']}: {$node->title}"); $actions = array(); if (!empty($args['edit_location_path'])) { $actions[] = array('caption' => 'edit', 'url' => '{rootFolder}' . $args['edit_location_path'], 'urlParams' => array('group_id' => $_GET['group_id'], 'location_id' => '{location_id}')); } $actions[] = array('caption' => 'remove', 'javascript' => "remove_location_from_group({groups_location_id});"); $leftcol = report_helper::report_grid(array('readAuth' => $readAuth, 'dataSource' => 'library/locations/locations_for_groups', 'sendOutputToMap' => true, 'extraParams' => array('group_id' => $_GET['group_id']), 'rowId' => 'location_id', 'columns' => array(array('display' => 'Actions', 'actions' => $actions, 'caption' => 'edit', 'url' => '{rootFolder}')))); $leftcol .= '<fieldset><legend>' . lang::Get('Add sites to the group') . '</legend>'; $leftcol .= '<p>' . lang::get('LANG_Add_Sites_Instruct') . '</p>'; if (!empty($args['edit_location_path'])) { $leftcol .= lang::get('Either') . ' <a class="button" href="' . hostsite_get_url($args['edit_location_path'], array('group_id' => $_GET['group_id'])) . '">' . lang::get('enter details of a new site') . '</a><br/>'; } $leftcol .= data_entry_helper::select(array('label' => lang::get('Or, add an existing site'), 'fieldname' => 'add_existing_location_id', 'report' => 'library/locations/locations_available_for_group', 'caching' => false, 'blankText' => lang::get('<please select>'), 'valueField' => 'location_id', 'captionField' => 'name', 'extraParams' => $readAuth + array('group_id' => $_GET['group_id'], 'user_id' => hostsite_get_user_field('indicia_user_id', 0)), 'afterControl' => '<button id="add-existing">Add</button>')); $leftcol .= '</fieldset>'; // @todo Link existing My Site to group. Need a new report to list sites I created, with sites already in the group // removed. Show in a drop down with an add button. Adding must create the groups_locations record, plus refresh // the grid and refresh the drop down. // @todo set destination after saving added site $map = map_helper::map_panel(iform_map_get_map_options($args, $readAuth), iform_map_get_ol_options($args)); $r = str_replace(array('{col-1}', '{col-2}'), array($leftcol, $map), $indicia_templates['two-col-50']); data_entry_helper::$javascript .= "indiciaData.group_id={$_GET['group_id']};\n"; return $r; }
/** * Return the generated output. * @param array $args List of parameter values passed through to the form depending on how the form has been configured. * This array always contains a value for language. * @param object $node The Drupal node object. * @param array $response When this form is reloading after saving a submission, contains the response from the service call. * Note this does not apply when redirecting (in this case the details of the saved object are in the $_GET data). * @return Form HTML. */ public static function get_form($args, $node, $response = null) { iform_load_helpers(array('report_helper', 'map_helper')); $readAuth = report_helper::get_read_auth($args['website_id'], $args['password']); $sharing = 'reporting'; $reportOptions = array_merge(iform_report_get_report_options($args, $readAuth), array('reportGroup' => 'explore', 'rememberParamsReportGroup' => 'explore', 'paramsOnly' => true, 'paramsInMapToolbar' => true, 'sharing' => $sharing, 'paramsFormButtonCaption' => lang::get('Filter'), 'rowId' => 'occurrence_id')); iform_report_apply_explore_user_own_preferences($reportOptions); $reportOptions['extraParams']['limit'] = 3000; $r = report_helper::report_grid($reportOptions); $r .= report_helper::report_map(array('readAuth' => $readAuth, 'dataSource' => $args['report_name'], 'extraParams' => $reportOptions['extraParams'], 'paramDefaults' => $reportOptions['paramDefaults'], 'autoParamsForm' => false, 'reportGroup' => 'explore', 'rememberParamsReportGroup' => 'explore', 'clickableLayersOutputMode' => 'report', 'sharing' => $sharing, 'rowId' => 'occurrence_id', 'ajax' => TRUE)); $options = array_merge(iform_map_get_map_options($args, $readAuth), array('featureIdField' => 'occurrence_id', 'clickForSpatialRef' => false, 'reportGroup' => 'explore', 'toolbarDiv' => 'top')); $olOptions = iform_map_get_ol_options($args); $r .= map_helper::map_panel($options, $olOptions); $allowDownload = !isset($args['downloadOwnDataOnly']) || !$args['downloadOwnDataOnly'] || isset($reportOptions['extraParams']['ownData']) && $reportOptions['extraParams']['ownData'] === 1 || isset($_POST['explore-ownData']) && $_POST['explore-ownData'] === '1' || !(isset($_POST['explore-ownData']) || $_POST['explore-ownData'] === '0') && isset($reportOptions['paramDefaults']['ownData']) && $reportOptions['paramDefaults']['ownData'] === 1; $reportOptions = array_merge($reportOptions, array('id' => 'explore-records', 'paramsOnly' => false, 'autoParamsForm' => false, 'downloadLink' => $allowDownload, 'rowClass' => 'certainty{certainty}')); if (isset($args['includeEditLink']) && $args['includeEditLink'] && !empty($args['includeEditLinkPath'])) { $reportOptions['columns'][] = array('display' => 'Actions', 'actions' => array(array('caption' => 'edit', 'url' => url($args['includeEditLinkPath']), 'urlParams' => array('occurrence_id' => '{occurrence_id}'), 'visibility_field' => 'belongs_to_user'))); } $r .= report_helper::report_grid($reportOptions); return $r; }
private static function get_notifications_html($auth, $sourceType, $website_id, $user_id, $options) { iform_load_helpers(array('report_helper')); $imgPath = empty(data_entry_helper::$images_path) ? data_entry_helper::relative_client_helper_path() . "../media/images/" : data_entry_helper::$images_path; $sendReply = $imgPath . "nuvola/mail_send-22px.png"; $cancelReply = $imgPath . "nuvola/mail_delete-22px.png"; //When the user wants to reply to a message, we have to add a new row report_helper::$javascript .= "\n indiciaData.reply_to_message = function(notification_id, occurrence_id) {\n if (!\$('#reply-row-'+occurrence_id).length) {\n rowHtml = '<tr id='+\"reply-row-\"+occurrence_id+'><td><label for=\"\">" . lang::get('Enter your reply below') . ":</label><textarea style=\"width: 95%\" id=\"reply-' +occurrence_id+'\"></textarea></td>';\n rowHtml += '<td class=\"actions\">';\n rowHtml += '<div><img class=\"action-button\" src=\"{$sendReply}\" onclick=\"reply('+occurrence_id+','+notification_id+',true);\" title=\"Send reply\">';\n rowHtml += '<img class=\"action-button\" src=\"{$cancelReply}\" onclick=\"reply('+occurrence_id+','+notification_id+',false);\" title=\"Cancel reply\">';\n rowHtml += '</div></td></tr>';\n \$(rowHtml).insertAfter('tr#row'+notification_id);\n \$('tr#row'+notification_id+' .action-button').hide();\n }\n };\n\n "; $urlParams = array('occurrence_id' => '{occurrence_id}'); if (!empty($_GET['group_id'])) { $urlParams['group_id'] = $_GET['group_id']; } $availableActions = array(array('caption' => lang::get('Edit this record'), 'class' => 'edit-notification', 'url' => '{rootFolder}{editing_form}', 'urlParams' => $urlParams, 'img' => $imgPath . 'nuvola/package_editors-22px.png', 'visibility_field' => 'editable_flag'), array('caption' => lang::get('View this record'), 'class' => 'view-notification', 'url' => '{rootFolder}{viewing_form}', 'urlParams' => $urlParams, 'img' => $imgPath . 'nuvola/find-22px.png', 'visibility_field' => 'viewable_flag'), array('caption' => lang::get('Mark as read'), 'javascript' => 'remove_message({notification_id});', 'img' => $imgPath . 'nuvola/kmail-22px.png')); //Only allow replying for 'user' messages. if (isset($options['allowReply']) && $options['allowReply'] === true) { $availableActions = array_merge($availableActions, array(array('caption' => lang::get('Reply to this message'), 'img' => $imgPath . 'nuvola/mail_reply-22px.png', 'visibility_field' => 'reply_flag', 'javascript' => "indiciaData.reply_to_message(" . '{notification_id}' . "," . '{occurrence_id}' . ");"))); } $extraParams = array('user_id' => $user_id, 'system_name' => 'indicia', 'orderby' => 'triggered_on', 'sortdir' => 'DESC', 'default_edit_page_path' => $options['default_edit_page_path'], 'view_record_page_path' => $options['view_record_page_path'], 'website_id' => $website_id); //Implode the source types so we can submit to the database in one text field. if (!empty($sourceType)) { $extraParams['source_types'] = "'" . implode("' ,'", $sourceType) . "'"; //If the user has supplied some config options for the different source types then we don't need the // source filter drop down. $extraParams['source_filter'] = 'all'; } //Only include notifications associated with a set of recording group ids if option is supplied. if (!empty($options['groupIds'])) { $extraParams['group_ids'] = $options['groupIds']; } $columns = array('data' => array('fieldname' => 'data', 'json' => true, 'template' => '<div class="type-{source_type}"><div class="status-{record_status}"></div></div><div class="note-type-{source_type}">{comment}</div>' . '<div class="comment-from helpText" style="margin-left: 34px; display: block;">from {username} on {triggered_date}</div>', 'display' => 'Message'), 'occurrence_id' => array('fieldname' => 'occurrence_id'), 'actions' => array('actions' => $availableActions), 'triggered_date' => array('fieldname' => 'triggered_date', 'visible' => false)); // allow columns config to override our default setup if (!empty($options['columns'])) { foreach ($options['columns'] as $column) { if (!empty($column['actions'])) { $columns['actions'] = $column; } elseif (!empty($column['fieldname'])) { $columns[$column['fieldname']] = $column; } } } $r = report_helper::report_grid(array('id' => 'notifications-' . $options['id'], 'readAuth' => $auth['read'], 'itemsPerPage' => 10, 'dataSource' => 'library/notifications/notifications_list_for_notifications_centre', 'rowId' => 'notification_id', 'ajax' => true, 'mode' => 'report', 'extraParams' => $extraParams, 'paramDefaults' => array('source_filter' => 'all'), 'paramsFormButtonCaption' => lang::get('Filter'), 'columns' => array_values($columns))); return $r; }
private static function get_notifications_html($auth, $sourceType, $website_id, $user_id, $options) { iform_load_helpers(array('report_helper')); global $auth; $readNonce = $auth['nonce']; $readAuthToken = $auth['auth_token']; $imgPath = empty(data_entry_helper::$images_path) ? data_entry_helper::relative_client_helper_path() . "../media/images/" : data_entry_helper::$images_path; $sendReply = $imgPath . "nuvola/mail_send-22px.png"; $cancelReply = $imgPath . "nuvola/mail_delete-22px.png"; //When the user wants to reply to a message, we have to add a new row report_helper::$javascript .= "\n indiciaData.reply_to_message = function(notification_id, occurrence_id) {\n if (!\$('#reply-row-'+occurrence_id).length) {\n rowHtml = '<tr id='+\"reply-row-\"+occurrence_id+'><td><label for=\"\">" . lang::get('Enter your reply below') . ":</label><textarea style=\"width: 95%\" id=\"reply-' +occurrence_id+'\"></textarea></td>';\n rowHtml += '<td class=\"actions\">';\n rowHtml += '<div><img class=\"action-button\" src=\"{$sendReply}\" onclick=\"reply('+occurrence_id+','+notification_id+',true);\" title=\"Send reply\">';\n rowHtml += '<img class=\"action-button\" src=\"{$cancelReply}\" onclick=\"reply('+occurrence_id+','+notification_id+',false);\" title=\"Cancel reply\">';\n rowHtml += '</div></td></tr>';\n \$(rowHtml).insertAfter('tr#row'+notification_id);\n \$('tr#row'+notification_id+' .action-button').hide();\n }\n };\n\n "; //Setup the javascript needed to support the remove notification button. self::setup_source_types_hidden_fields($options, $sourceType, $website_id, $auth); $auth = report_helper::get_read_auth(variable_get('indicia_website_id', ''), variable_get('indicia_password', '')); //Implode the source types so we can submit to the database in one text field. foreach ($sourceType as &$type) { $type = "'" . $type . "'"; } $sourceType = implode(',', $sourceType); $availableActions = array(array('caption' => lang::get('Edit this record'), 'class' => 'edit-notification', 'url' => '{rootFolder}{editing_form}', 'urlParams' => array('occurrence_id' => '{occurrence_id}'), 'img' => $imgPath . 'nuvola/package_editors-22px.png', 'visibility_field' => 'editable_flag'), array('caption' => lang::get('View this record'), 'class' => 'view-notification', 'url' => '{rootFolder}{viewing_form}', 'urlParams' => array('occurrence_id' => '{occurrence_id}'), 'img' => $imgPath . 'nuvola/find-22px.png', 'visibility_field' => 'viewable_flag'), array('caption' => lang::get('Mark as read'), 'javascript' => 'remove_message({notification_id});', 'img' => $imgPath . 'nuvola/kmail-22px.png')); //Only allow replying for 'user' messages. if ($options['allowReply'] === true) { $availableActions = array_merge($availableActions, array(array('caption' => lang::get('Reply to this message'), 'img' => $imgPath . 'nuvola/mail_reply-22px.png', 'javascript' => "indiciaData.reply_to_message(" . '{notification_id}' . "," . '{occurrence_id}' . ");"))); } return report_helper::report_grid(array('id' => 'notifications-' . $options['id'], 'readAuth' => $auth, 'itemsPerPage' => 10, 'dataSource' => 'library/notifications/notifications_list_for_notifications_centre', 'rowId' => 'notification_id', 'ajax' => true, 'mode' => 'report', 'extraParams' => array('user_id' => $user_id, 'system_name' => 'indicia', 'source_types' => $sourceType, 'orderby' => 'triggered_on', 'sortdir' => 'DESC', 'default_edit_page_path' => $options['default_edit_page_path'], 'view_record_page_path' => $options['view_record_page_path'], 'website_id' => $website_id), 'columns' => array(array('fieldname' => 'data', 'json' => true, 'template' => '<div class="type-{source_type}"><div class="status-{record_status}"></div></div><div class="note-type-{source_type}">{comment}</div>' . '<div class="comment-from helpText" style="margin-left: 34px; display: block;">from {username} on {triggered_date}</div>', 'display' => 'Message'), array('actions' => $availableActions), array('fieldname' => 'triggered_date', 'visible' => false)))); }
private static function _build_taxon_groups_report($args, $readAuth, $output, $type) { $r = self::filter_toolbar(array('my_records', 'year'), $readAuth); $reportPerUser = !empty($_GET['my_records']); $reportOptions = array('readAuth' => $readAuth, 'dataSource' => "library/taxon_groups/filterable_{$type}_counts", 'caching' => true, 'cachePerUser' => $reportPerUser, 'cachetimeout' => $reportPerUser ? self::FAST_CACHE_REFRESH : self::SLOW_CACHE_REFRESH); self::check_filters($reportOptions); if (!empty($args['min_rank_sort_order_for_species'])) { $reportOptions['extraParams'] = array('min_taxon_rank_sort_order' => $args['min_rank_sort_order_for_species']); } if ($output === 'pie_chart') { $data = report_helper::get_report_data($reportOptions); // Get the taxon groups used in the master checklist $groups = report_helper::get_report_data(array('dataSource' => '/library/taxon_groups/taxon_groups_used_in_checklist', 'readAuth' => $readAuth, 'extraParams' => array('taxon_list_id' => variable_get('iform_master_checklist_id', 0)), 'caching' => true, 'cachePerUser' => false, 'cachetimeout' => self::SLOW_CACHE_REFRESH)); // make an easy lookup $groupIds = array(); foreach ($groups as $group) { $groupIds[$group['id']] = $group['title']; } // roll categories into 'other' if too many and process to remove unofficial groups $totalOther = 0; $processedData = array(); foreach ($data as $row) { if (count($processedData) >= 10 || !array_key_exists($row['id'], $groupIds)) { $totalOther += $row['count']; } else { $processedData[] = $row; } } if ($totalOther > 0) { $processedData[] = array('taxon_group' => lang::get('other'), 'count' => $totalOther); } $reportOptions['dataSource'] = 'static'; $reportOptions += array('staticData' => $processedData, 'chartType' => 'pie', 'seriesColors' => array('#ccebc5', '#ffffb3', '#bebada', '#fb8072', '#80b1d3', '#fdb462', '#b3de69', '#fccde5', '#8dd3c7', '#bc80bd', '#d9d9d9'), 'height' => '500', 'yValues' => 'count', 'xLabels' => 'taxon_group', 'autoParamsForm' => false, 'axesOptions' => array('yaxis' => array('min' => 0, 'tickOptions' => array('formatString' => '%d'))), 'legendOptions' => array('show' => true), 'rendererOptions' => array('sliceMargin' => 3)); $r .= report_helper::report_chart($reportOptions); } else { $reportOptions += array('downloadLink' => true); $r .= report_helper::report_grid($reportOptions); } return $r; }
<?php /** * Indicia, the OPAL Online Recording Toolkit. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with this program. If not, see http://www.gnu.org/licenses/gpl.html. * * @package Core * @subpackage Views * @author Indicia Team * @license http://www.gnu.org/licenses/gpl.html GPL * @link http://code.google.com/p/indicia/ */ require_once DOCROOT . 'client_helpers/report_helper.php'; $readAuth = report_helper::get_read_auth(0 - $_SESSION['auth_user']->id, kohana::config('indicia.private_key')); echo report_helper::report_grid(array('readAuth' => $readAuth, 'dataSource' => $_GET['report_name'], 'itemsPerPage' => kohana::config('pagination.default.items_per_page'))); report_helper::link_default_stylesheet(); echo report_helper::dump_javascript();
/** * Return the Indicia form code * @param array $args Input parameters. * @param array $node Drupal node object * @param array $response Response from Indicia services after posting a verification. * @return HTML string */ public static function get_form($args, $node, $response) { iform_load_helpers(array('report_helper')); data_entry_helper::add_resource('jquery_form'); $auth = report_helper::get_read_auth($args['website_id'], $args['password']); $reportOptions = iform_report_get_report_options($args, $auth); // get the grid output before outputting the download link, so we can check if the download link is needed. $reportOptions['id'] = 'grid-' . $node->nid; if (isset($args['footer'])) { $reportOptions['footer'] = $args['footer']; } $reportOptions['downloadLink'] = !isset($args['download_link']) || $args['download_link']; $grid = report_helper::report_grid($reportOptions); return $grid; }
/** * Return the generated form output. * @param array $args List of parameter values passed through to the form depending on how the form has been configured. * This array always contains a value for language. * @param object $node The Drupal node object. * @param array $response When this form is reloading after saving a submission, contains the response from the service call. * Note this does not apply when redirecting (in this case the details of the saved object are in the $_GET data). * @return Form HTML. */ public static function get_form($args, $node, $response = null) { global $indicia_templates; iform_load_helpers(array('map_helper', 'report_helper')); // apply defaults $args = array_merge(array(), $args); $reloadPath = self::getReloadPath(); data_entry_helper::$website_id = $args['website_id']; $auth = data_entry_helper::get_read_write_auth($args['website_id'], $args['password']); if (!empty($_GET['user_trust_id'])) { self::loadExistingUserTrust($_GET['user_trust_id'], $auth, $args); } $r = "<form method=\"post\" id=\"entry_form\" action=\"{$reloadPath}\">\n"; $r .= $auth['write'] . "<input type=\"hidden\" id=\"website_id\" name=\"website_id\" value=\"" . $args['website_id'] . "\" />\n"; $r .= data_entry_helper::hidden_text(array('fieldname' => 'user_trust:id')); $r .= data_entry_helper::autocomplete(array('label' => lang::get('Recorder to trust'), 'fieldname' => 'user_trust:user_id', 'table' => 'user', 'valueField' => 'id', 'captionField' => 'person_name', 'extraParams' => $auth['read'] + array('view' => 'detail'), 'class' => 'control-width-4')); $col1 = '<p>Define the combination of survey, taxon group and/or location that this recorder is trusted for below.</p>'; $col1 .= '<fieldset><legend>' . lang::get('Trust settings') . '</legend>'; $col1 .= data_entry_helper::autocomplete(array('label' => lang::get('Trust records in this survey'), 'fieldname' => 'user_trust:survey_id', 'table' => 'survey', 'valueField' => 'id', 'captionField' => 'title', 'blankText' => '<' . lang::get('any') . '>', 'extraParams' => $auth['read'] + array('sharing' => 'verification'), 'class' => 'control-width-4')); $col1 .= data_entry_helper::autocomplete(array('label' => lang::get('Trust records in this taxon group'), 'fieldname' => 'user_trust:taxon_group_id', 'table' => 'taxon_group', 'valueField' => 'id', 'captionField' => 'title', 'blankText' => '<' . lang::get('any') . '>', 'extraParams' => $auth['read'], 'class' => 'control-width-4')); $col1 .= data_entry_helper::autocomplete(array('label' => lang::get('Trust records in this location'), 'fieldname' => 'user_trust:location_id', 'table' => 'location', 'valueField' => 'id', 'captionField' => 'name', 'blankText' => '<' . lang::get('any') . '>', 'extraParams' => $auth['read'] + array('location_type_id' => variable_get('indicia_profile_location_type_id', '')), 'class' => 'control-width-4')); $col2 = '<p>' . lang::get('Review this recorder\'s experience in the tabs below') . '</p>'; $col2 .= '<div id="summary-tabs">'; $col2 .= data_entry_helper::tab_header(array('tabs' => array('#tab-surveys' => lang::get('Surveys'), '#tab-taxon-groups' => lang::get('Taxon groups'), '#tab-locations' => lang::get('Locations')))); data_entry_helper::enable_tabs(array('divId' => 'summary-tabs')); $col2 .= '<div id="tab-surveys">'; $col2 .= report_helper::report_grid(array('id' => 'surveys-summary', 'readAuth' => $auth['read'], 'dataSource' => 'library/surveys/filterable_surveys_verification_breakdown', 'ajax' => TRUE, 'autoloadAjax' => FALSE, 'extraParams' => array('my_records' => 1))); $col2 .= '</div>'; $col2 .= '<div id="tab-taxon-groups">'; $col2 .= report_helper::report_grid(array('id' => 'taxon-groups-summary', 'readAuth' => $auth['read'], 'dataSource' => 'library/taxon_groups/filterable_taxon_groups_verification_breakdown', 'ajax' => TRUE, 'autoloadAjax' => FALSE, 'extraParams' => array('my_records' => 1))); $col2 .= '</div>'; $col2 .= '<div id="tab-locations">'; $col2 .= report_helper::report_grid(array('id' => 'locations-summary', 'readAuth' => $auth['read'], 'dataSource' => 'library/locations/filterable_locations_verification_breakdown', 'ajax' => TRUE, 'autoloadAjax' => FALSE, 'extraParams' => array('my_records' => 1, 'location_type_id' => variable_get('indicia_profile_location_type_id', '')))); $col2 .= '</div>'; $col2 .= '</div>'; $r .= str_replace(array('{col-1}', '{col-2}'), array($col1, $col2), $indicia_templates['two-col-50']); $r .= '</fieldset>'; $r .= '<input type="submit" class="indicia-button" id="save-button" value="' . (empty(data_entry_helper::$entity_to_load['user_trust_id:id']) ? lang::get('Grant trust') : lang::get('Update trust settings')) . "\" />\n"; if (!empty($_GET['user_trust_id'])) { $r .= '<input type="submit" class="indicia-button" id="delete-button" name="delete-button" value="' . lang::get('Revoke this trust') . "\" />\n"; data_entry_helper::$javascript .= "\$('#delete-button').click(function(e) {\n if (!confirm(\"Are you sure you want to revoke this trust?\")) {\n e.preventDefault();\n return false;\n }\n });\n"; } $r .= '</form>'; data_entry_helper::enable_validation('entry_form'); return $r; }
/** * Return the generated form output. * @param array $args List of parameter values passed through to the form depending on how the form has been configured. * This array always contains a value for language. * @param object $node The Drupal node object. * @param array $response When this form is reloading after saving a submission, contains the response from the service call. * Note this does not apply when redirecting (in this case the details of the saved object are in the $_GET data). * @return Form HTML. */ public static function get_form($args, $node, $response = null) { if (!hostsite_get_user_field('indicia_user_id')) { return 'Please ensure that you\'ve filled in your surname on your user profile before creating or editing groups.'; } self::createBreadcrumb($args); iform_load_helpers(array('report_helper')); report_helper::$website_id = $args['website_id']; $auth = report_helper::get_read_write_auth($args['website_id'], $args['password']); if (empty($_GET['group_id'])) { return 'This form should be called with a group_id parameter'; } $group = self::loadExistingGroup($_GET['group_id'], $auth, $args); hostsite_set_page_title(lang::get('Administer {1}', $group['title'])); report_helper::$javascript .= "indiciaData.website_id={$args['website_id']};\n"; report_helper::$javascript .= "indiciaData.group_id={$group['id']};\n"; report_helper::$javascript .= 'indiciaData.ajaxFormPostUrl="' . iform_ajaxproxy_url(null, 'groups_user') . "\";\n"; if (!empty($args['admin_role_name'])) { $adminRoleOnScreenName = $args['admin_role_name']; } else { $adminRoleOnScreenName = 'administrator'; } if (!empty($args['member_role_name'])) { $memberRoleOnScreenName = $args['member_role_name']; } else { $memberRoleOnScreenName = 'member'; } //Setup actions column $actions = array(array('caption' => 'Approve member', 'javascript' => 'approveMember({groups_user_id});', 'visibility_field' => 'pending')); if ($adminRoleOnScreenName === 'administrator') { $caption = 'Set user to be an ' . $adminRoleOnScreenName; } else { $caption = 'Set user to be a ' . $adminRoleOnScreenName; } //Only allow toggle of user's role if page is configured to allow this. if (isset($args['allow_role_toggle']) && $args['allow_role_toggle'] == true) { $actions[] = array('caption' => $caption, 'javascript' => 'toggleRole({groups_user_id},\'{name}\',\'administrator\');', 'visibility_field' => 'member'); $actions[] = array('caption' => 'Set user to be a ' . $memberRoleOnScreenName, 'javascript' => 'toggleRole({groups_user_id},\'{name}\',\'member\');', 'visibility_field' => 'administrator'); } //Only allow removal of users if page is configured to allow this. if (isset($args['allow_remove']) && $args['allow_remove'] == true) { $actions[] = array('caption' => 'Remove from group', 'javascript' => 'removeMember({groups_user_id},\'{name}\');'); } $r = report_helper::report_grid(array('dataSource' => 'library/groups/group_members', 'readAuth' => $auth['read'], 'extraParams' => array('group_id' => $group['id']), 'columns' => array(array('display' => lang::get('Actions'), 'actions' => $actions)))); return $r; }
public static function known_taxa_summary($auth, $args, $tabalias, $options, $path) { if (!empty($_GET['location_id'])) { iform_load_helpers(array('report_helper')); return report_helper::report_grid(array('id' => 'taxa-summary', 'readAuth' => $auth['read'], 'itemsPerPage' => 10, 'dataSource' => 'library/taxa/filterable_explore_list', 'rowId' => 'id', 'ajax' => true, 'columns' => array(array('fieldname' => 'taxon_group', 'visible' => false), array('fieldname' => 'taxon_group_id', 'visible' => false), array('fieldname' => 'first_date', 'visible' => false), array('fieldname' => 'last_date', 'visible' => false)), 'mode' => 'report', 'extraParams' => array('location_list' => $_GET['location_id'], 'website_id' => $args['website_id']))); } }
<html> <?php include '../../client_helpers/report_helper.php'; include 'data_entry_config.php'; $readAuth = report_helper::get_read_auth($config['website_id'], $config['password']); $svcUrl = report_helper::$base_url . '/index.php/services'; ?> <head> <title>Occurrence Grid Demo</title> </head> <body> <?php report_helper::link_default_stylesheet(); echo report_helper::report_grid(array('readAuth' => $readAuth, 'dataSource' => 'occurrence', 'mode' => 'direct', 'columns' => array(array('display' => 'Actions', 'actions' => array(array('caption' => 'edit', 'url' => '{rootFolder}occurrence.php', 'urlParams' => array('id' => '{id}'))))))); echo report_helper::dump_javascript(); ?> </body> </html>
/** * Return the Indicia form code * @param array $args Input parameters. * @param array $node Drupal node object * @param array $response Response from Indicia services after posting a verification. * @return HTML string */ public static function get_form($args, $node, $response) { require_once drupal_get_path('module', 'iform') . '/client_helpers/report_helper.php'; $auth = report_helper::get_read_write_auth($args['website_id'], $args['password']); $reportOptions = iform_report_get_report_options($args, $auth); // get the grid output before outputting the download link, so we can check if the download link is needed. $reportOptions['id'] = 'grid-' . $node->nid; if (isset($args['footer'])) { $reportOptions['footer'] = $args['footer']; } $reportOptions['downloadLink'] = !isset($args['download_link']) || $args['download_link']; $grid = report_helper::report_grid($reportOptions); return $grid; }
<html> <?php require '../../../client_helpers/report_helper.php'; require '../data_entry_config.php'; $readAuth = report_helper::get_read_auth($config['website_id'], $config['password']); ?> <head> <title>Report Grid Demo</title> </head> <body> <?php report_helper::link_default_stylesheet(); echo report_helper::report_grid(array('readAuth' => $readAuth, 'dataSource' => 'species_occurrence_counts_by_taxon_group')); echo report_helper::dump_javascript(); ?> </body> </html>
protected static function get_control_reportgrid($auth, $args, $tabalias, $options) { iform_load_helpers(array('report_helper')); $columnLists = json_decode($args['columns_config_list']); if (self::$reportCount < count($columnLists)) { $args['columns_config'] = json_encode($columnLists[self::$reportCount]); } else { unset($args['columns_config']); } $args['report_name'] = ''; $sharing = empty($args['sharing']) ? 'reporting' : $args['sharing']; $reportOptions = array_merge(iform_report_get_report_options($args, $auth['read']), array('reportGroup' => 'dynamic', 'autoParamsForm' => false, 'sharing' => $sharing, 'ajax' => true, 'id' => 'report-grid-' . self::$reportCount), $options); if (self::$applyUserPrefs) { iform_report_apply_explore_user_own_preferences($reportOptions); } self::$reportCount++; return report_helper::report_grid($reportOptions); }
/** * Outputs a grid that loads the content of a report or Indicia table. * @param array $options Refer to report_helper::report_grid documentation. * @deprecated Use report_helper::report_grid. */ public static function report_grid($options) { require_once 'report_helper.php'; return report_helper::report_grid($options); }
public static function unallocated_squares_grid($auth, $args, $tabalias, $options, $path) { if (!isset($options['reportGridNumber'])) { drupal_set_message('Please fill in the report grid number option for the unallocated_squares_grid control, starting with 0 for the first grid on the page'); return false; } iform_load_helpers(array('report_helper')); $args['report_name'] = ''; $sharing = empty($args['sharing']) ? 'reporting' : $args['sharing']; $reportOptions = array_merge(iform_report_get_report_options($args, $auth['read']), array('reportGroup' => 'dynamic', 'autoParamsForm' => false, 'sharing' => $sharing, 'ajax' => true, 'id' => 'report-grid-' . $options['reportGridNumber']), $options); if (!empty($_GET['dynamic-post_code_geom']) && !empty($_GET['dynamic-distance_from_post_code'])) { $reportOptions['sendOutputToMap'] = true; $reportOptions['zoomMapToOutput'] = true; } return report_helper::report_grid($reportOptions); }
protected static function get_control_speciesphotos($auth, $args, $tabalias, $options) { iform_load_helpers(array('report_helper')); data_entry_helper::add_resource('fancybox'); global $user; //default an items per page if not set by administrator if (empty($options['itemsPerPage']) || $options['itemsPerPage'] == NULL) { $options['itemsPerPage'] = 6; } //default a column count if not set by administrator if (empty($options['galleryColCount']) || $options['galleryColCount'] == NULL) { $options['galleryColCount'] = 3; } //Use this report to return the photos $reportName = 'library/taxa/species_notes_and_images'; $reportResults = report_helper::report_grid(array('readAuth' => $auth['read'], 'dataSource' => $reportName, 'itemsPerPage' => $options['itemsPerPage'], 'columns' => array(array('fieldname' => 'the_text', 'template' => '<div class="gallery-item"><a class="fancybox" href="{imageFolder}{the_text}"><img src="{imageFolder}thumb-{the_text}" title="{caption}" alt="{caption}"/><br/>{caption}</a></div>')), 'mode' => 'report', 'autoParamsForm' => false, 'includeAllColumns' => false, 'headers' => false, 'galleryColCount' => $options['galleryColCount'], 'extraParams' => array('taxa_taxon_list_id' => self::$taxa_taxon_list_id, 'taxon_meaning_id' => self::$taxon_meaning_id))); return '<div class="detail-panel" id="detail-panel-speciesphotos"><h3>' . lang::get('Photos and media') . '</h3>' . $reportResults . '</div>'; }
/** * Return the Indicia form code. * Expects there to be a sample attribute with caption 'Email' containing the email * address. * @param array $args Input parameters. * @param array $node Drupal node object * @param array $response Response from Indicia services after posting a verification. * @return string HTML */ public static function get_form($args, $node, $response) { if (!self::check_prerequisites()) { return ''; } iform_load_helpers(array('data_entry_helper', 'map_helper', 'report_helper')); $auth = data_entry_helper::get_read_write_auth($args['website_id'], $args['password']); //Clear Verifier Tasks automatically when they open the screen if the option is set. if ($args['clear_verification_task_notifications'] && hostsite_get_user_field('indicia_user_id')) { self::clear_verifier_task_notifications($auth); } // set some defaults, applied when upgrading from a form configured on a previous form version. if (empty($args['email_subject_send_to_recorder'])) { $args['email_subject_send_to_recorder'] = 'Sample requires confirmation (ID:%id%)'; } if (empty($args['email_body_send_to_recorder'])) { $args['email_body_send_to_recorder'] = 'The following record requires confirmation. Please could you reply to this email stating how confident you are that the record is correct ' . 'and any other information you have which may help to confirm this.' . "\n\n%record%"; } if (isset($_POST['enable'])) { module_enable(array('iform_ajaxproxy')); drupal_set_message(lang::get('The Indicia AJAX Proxy module has been enabled.', 'info')); } elseif (!defined('IFORM_AJAXPROXY_PATH')) { $r = '<p>' . lang::get('The Indicia AJAX Proxy module must be enabled to use this form. This lets the form save verifications to the ' . 'Indicia Warehouse without having to reload the page.') . '</p>'; $r .= '<form method="post">'; $r .= '<input type="hidden" name="enable" value="t"/>'; $r .= '<input type="submit" value="' . lang::get('Enable Indicia AJAX Proxy') . '"/>'; $r .= '</form>'; return $r; } if (function_exists('drupal_add_js')) { drupal_add_js('misc/collapse.js'); } // fancybox for popup comment forms etc data_entry_helper::add_resource('fancybox'); data_entry_helper::add_resource('validation'); $indicia_user_id = self::get_indicia_user_id($args); data_entry_helper::$js_read_tokens = $auth['read']; // Find a list of websites we are allowed verify if (function_exists('module_exists') && module_exists('easy_login')) { if (strpos($args['param_presets'] . $args['param_defaults'], 'expertise_location') === false) { $args['param_presets'] .= "\nexpertise_location={profile_location_expertise}"; } if (strpos($args['param_presets'] . $args['param_defaults'], 'expertise_taxon_groups') === false) { $args['param_presets'] .= "\nexpertise_taxon_groups={profile_taxon_groups_expertise}"; } if (strpos($args['param_presets'] . $args['param_defaults'], 'expertise_surveys') === false) { $args['param_presets'] .= "\nexpertise_surveys={profile_surveys_expertise}"; } } $args['sharing'] = 'verification'; $opts = array_merge(iform_report_get_report_options($args, $auth['read']), array('id' => 'verification-grid', 'reportGroup' => 'verification', 'rowId' => 'sample_id', 'paramsFormButtonCaption' => lang::get('Filter'), 'paramPrefix' => '<div class="report-param">', 'paramSuffix' => '</div>', 'sharing' => 'verification', 'ajax' => TRUE, 'callback' => 'verificationGridLoaded')); $opts['columns'][] = array('display' => '', 'template' => '<div class="nowrap">' . '<input type="hidden" class="row-input-form" value="{rootFolder}{input_form}"/><input type="hidden" class="row-belongs-to-site" value="{belongs_to_site}"/>' . '<input type="checkbox" class="check-row no-select" style="display: none" value="{occurrence_id}" /></div>'); $params = self::report_filter_panel($args, $auth['read']); $opts['zoomMapToOutput'] = false; $grid = report_helper::report_grid($opts); $r = str_replace(array('{grid}', '{paramsForm}'), array($grid, $params), self::get_template_with_map($args, $auth['read'], $opts['extraParams'], $opts['paramDefaults'])); $link = data_entry_helper::get_reload_link_parts(); global $user; data_entry_helper::$js_read_tokens = $auth['read']; data_entry_helper::$javascript .= 'indiciaData.nid = "' . $node->nid . "\";\n"; data_entry_helper::$javascript .= 'indiciaData.username = "******"\";\n"; data_entry_helper::$javascript .= 'indiciaData.userId = "' . $indicia_user_id . "\";\n"; data_entry_helper::$javascript .= 'indiciaData.rootUrl = "' . $link['path'] . "\";\n"; data_entry_helper::$javascript .= 'indiciaData.website_id = ' . $args['website_id'] . ";\n"; data_entry_helper::$javascript .= 'indiciaData.ajaxFormPostUrl="' . iform_ajaxproxy_url($node, 'sample') . "&user_id={$indicia_user_id}&sharing=verification\";\n"; data_entry_helper::$javascript .= 'indiciaData.ajaxUrl="' . url('iform/ajax/verification_samples') . "\";\n"; data_entry_helper::$javascript .= 'indiciaData.autoDiscard = ' . $args['auto_discard_rows'] . ";\n"; $imgPath = empty(data_entry_helper::$images_path) ? data_entry_helper::relative_client_helper_path() . "../media/images/" : data_entry_helper::$images_path; data_entry_helper::$javascript .= 'indiciaData.imgPath = "' . $imgPath . "\";\n"; // output some translations for JS to use // @todo: Check list for unused (e.g. query stuff) data_entry_helper::$javascript .= "indiciaData.popupTranslations = {};\n"; data_entry_helper::$javascript .= 'indiciaData.popupTranslations.title="' . lang::get('Add comment regarding setting status to {1}') . "\";\n"; data_entry_helper::$javascript .= 'indiciaData.popupTranslations.save="' . lang::get('Save and {1}') . "\";\n"; data_entry_helper::$javascript .= 'indiciaData.popupTranslations.verbV="' . lang::get('accept') . "\";\n"; data_entry_helper::$javascript .= 'indiciaData.popupTranslations.verbR="' . lang::get('don\'t accept') . "\";\n"; data_entry_helper::$javascript .= 'indiciaData.popupTranslations.verbC3="' . lang::get('mark as plausible') . "\";\n"; data_entry_helper::$javascript .= 'indiciaData.popupTranslations.V="' . lang::get('accepted') . "\";\n"; data_entry_helper::$javascript .= 'indiciaData.popupTranslations.R="' . lang::get('not accepted') . "\";\n"; data_entry_helper::$javascript .= 'indiciaData.popupTranslations.sub1="' . lang::get('correct') . "\";\n"; data_entry_helper::$javascript .= 'indiciaData.popupTranslations.sub2="' . lang::get('considered correct') . "\";\n"; data_entry_helper::$javascript .= 'indiciaData.popupTranslations.sub3="' . lang::get('plausible') . "\";\n"; // @todo: Should this term be unable to accept data_entry_helper::$javascript .= 'indiciaData.popupTranslations.sub4="' . lang::get('unable to verify') . "\";\n"; data_entry_helper::$javascript .= 'indiciaData.popupTranslations.sub5="' . lang::get('incorrect') . "\";\n"; // IS THIS REQUIRED data_entry_helper::$javascript .= 'indiciaData.popupTranslations.D="' . lang::get('Query') . "\";\n"; data_entry_helper::$javascript .= 'indiciaData.popupTranslations.tab_email="' . lang::get('Send query as email') . "\";\n"; data_entry_helper::$javascript .= 'indiciaData.popupTranslations.tab_comment="' . lang::get('Save query to comments log') . "\";\n"; data_entry_helper::$javascript .= 'indiciaData.popupTranslations.emailTitle="' . lang::get('Email record details') . "\";\n"; data_entry_helper::$javascript .= 'indiciaData.popupTranslations.emailInstruction="' . lang::get('Use this form to send an email a copy of the record, for example when you would ' . 'like to get the opinion of another expert.') . "\";\n"; data_entry_helper::$javascript .= 'indiciaData.popupTranslations.sendEmail="' . lang::get('Send Email') . "\";\n"; data_entry_helper::$javascript .= 'indiciaData.popupTranslations.emailSent="' . lang::get('The email was sent successfully.') . "\";\n"; data_entry_helper::$javascript .= 'indiciaData.popupTranslations.requestManualEmail="' . lang::get('The webserver is not correctly configured to send emails. Please send the following email usual your email client:') . "\";\n"; data_entry_helper::$javascript .= 'indiciaData.popupTranslations.multipleWarning="' . lang::get('You are about to process multiple records. Please note that this comment will apply to all the ticked records. ' . 'If you did not intend to do this, please close this box and turn off the Select Records tool before proceeding.') . "\";\n"; // translations for querying data_entry_helper::$javascript .= 'indiciaData.popupTranslations.queryProbablyCantContact="' . lang::get('The record does not have sufficient information for us to be able to contact the recorder. You can leave a query ' . 'in the box below but we cannot guarantee that they will see it.') . "\";\n"; data_entry_helper::$javascript .= 'indiciaData.popupTranslations.queryNeedsEmail="' . lang::get('The recorder can be contacted by email. If you prefer you can just leave the query as a comment on the ' . 'record but it is unlikely that they will see it as they haven\'t previously checked their notifications.') . "\";\n"; data_entry_helper::$javascript .= 'indiciaData.popupTranslations.queryProbablyNeedsEmailNo="' . lang::get('The recorder can be contacted by email. If you prefer you can just leave the query as a comment on the ' . 'record but it they are not known to check their notifications so may not spot the query.') . "\";\n"; data_entry_helper::$javascript .= 'indiciaData.popupTranslations.queryProbablyNeedsEmailUnknown="' . lang::get('The recorder can be contacted by email. If you prefer you can just leave the query as a comment on the ' . 'record though we don\'t have any information to confirm that they will receive the associated notification.') . "\";\n"; data_entry_helper::$javascript .= 'indiciaData.popupTranslations.queryProbablyWillGetNotified="' . lang::get('The recorder normally checks their notifications so your query can be posted as a comment ' . 'against the record. If you prefer, you can send a direct email.') . "\";\n"; self::translateStatusTerms(); data_entry_helper::$javascript .= "indiciaData.statusTranslations = " . json_encode(self::$statusTerms) . ";\n"; data_entry_helper::$javascript .= "indiciaData.commentTranslations = {};\n"; data_entry_helper::$javascript .= 'indiciaData.commentTranslations.emailed = "' . lang::get('I emailed this sample to {1} for checking.') . "\";\n"; data_entry_helper::$javascript .= 'indiciaData.commentTranslations.recorder = "' . lang::get('the recorder') . "\";\n"; data_entry_helper::$javascript .= 'indiciaData.commentTranslations.expert = "' . lang::get('an expert') . "\";\n"; data_entry_helper::$javascript .= 'indiciaData.email_subject_send_to_verifier = "' . $args['email_subject_send_to_verifier'] . "\";\n"; $body = str_replace(array("\r", "\n", '"'), array('', '\\n', '\\"'), $args['email_body_send_to_verifier']); data_entry_helper::$javascript .= 'indiciaData.email_body_send_to_verifier = "' . $body . "\";\n"; data_entry_helper::$javascript .= 'indiciaData.email_subject_send_to_recorder = "' . $args['email_subject_send_to_recorder'] . "\";\n"; $body = str_replace(array("\r", "\n"), array('', '\\n'), $args['email_body_send_to_recorder']); data_entry_helper::$javascript .= 'indiciaData.email_body_send_to_recorder = "' . $body . "\";\n"; data_entry_helper::$javascript .= 'indiciaData.str_month = "' . lang::get('month') . "\";\n"; data_entry_helper::$javascript .= 'indiciaData.expertise_location = "' . $opts['extraParams']['expertise_location'] . "\";\n"; data_entry_helper::$javascript .= 'indiciaData.expertise_surveys = "' . $opts['extraParams']['expertise_surveys'] . "\";\n"; data_entry_helper::$javascript .= 'indiciaData.expertise_taxon_groups = "' . $opts['extraParams']['expertise_taxon_groups'] . "\";\n"; data_entry_helper::add_resource('jqplot'); data_entry_helper::add_resource('jqplot_bar'); return $r; }
/** * Return the Indicia form code. * Expects there to be a sample attribute with caption 'Email' containing the email * address. * @param array $args Input parameters. * @param array $node Drupal node object * @param array $response Response from Indicia services after posting a verification. * @return HTML string */ public static function get_form($args, $node, $response) { iform_load_helpers(array('data_entry_helper', 'map_helper', 'report_helper')); $auth = data_entry_helper::get_read_write_auth($args['website_id'], $args['password']); //Clear Verifier Tasks automatically when they open the screen if the option is set. if ($args['clear_verification_task_notifications'] && hostsite_get_user_field('indicia_user_id')) { self::clear_verifier_task_notifications($auth); } // set some defaults, applied when upgrading from a form configured on a previous form version. if (empty($args['email_subject_send_to_recorder'])) { $args['email_subject_send_to_recorder'] = 'Record of %taxon% requires confirmation (ID:%id%)'; } if (empty($args['email_body_send_to_recorder'])) { $args['email_body_send_to_recorder'] = 'The following record requires confirmation. Please could you reply to this email stating how confident you are that the record is correct ' . 'and any other information you have which may help to confirm this.' . "\n\n%record%"; } if (isset($_POST['enable'])) { module_enable(array('iform_ajaxproxy')); drupal_set_message(lang::get('The Indicia AJAX Proxy module has been enabled.', 'info')); } elseif (!defined('IFORM_AJAXPROXY_PATH')) { $r = '<p>' . lang::get('The Indicia AJAX Proxy module must be enabled to use this form. This lets the form save verifications to the ' . 'Indicia Warehouse without having to reload the page.') . '</p>'; $r .= '<form method="post">'; $r .= '<input type="hidden" name="enable" value="t"/>'; $r .= '<input type="submit" value="' . lang::get('Enable Indicia AJAX Proxy') . '"/>'; $r .= '</form>'; return $r; } if (function_exists('drupal_add_js')) { drupal_add_js('misc/collapse.js'); } // fancybox for popup comment forms etc data_entry_helper::add_resource('fancybox'); data_entry_helper::add_resource('validation'); global $user, $indicia_templates; $indicia_user_id = self::get_indicia_user_id($args); data_entry_helper::$js_read_tokens = $auth['read']; // Find a list of websites we are allowed verify $websiteIds = iform_get_allowed_website_ids($auth['read'], 'verification'); if (function_exists('module_exists') && module_exists('easy_login')) { if (strpos($args['param_presets'] . $args['param_defaults'], 'expertise_location') === false) { $args['param_presets'] .= "\nexpertise_location={profile_location_expertise}"; } if (strpos($args['param_presets'] . $args['param_defaults'], 'expertise_taxon_groups') === false) { $args['param_presets'] .= "\nexpertise_taxon_groups={profile_taxon_groups_expertise}"; } if (strpos($args['param_presets'] . $args['param_defaults'], 'expertise_surveys') === false) { $args['param_presets'] .= "\nexpertise_surveys={profile_surveys_expertise}"; } } $args['sharing'] = 'verification'; $opts = array_merge(iform_report_get_report_options($args, $auth['read']), array('id' => 'verification-grid', 'reportGroup' => 'verification', 'rowId' => 'occurrence_id', 'paramsFormButtonCaption' => lang::get('Filter'), 'paramPrefix' => '<div class="report-param">', 'paramSuffix' => '</div>', 'sharing' => 'verification', 'ajax' => TRUE, 'callback' => 'verificationGridLoaded', 'rowClass' => 'zero-{zero_abundance}')); $opts['columns'][] = array('display' => '', 'template' => '<div class="nowrap"><button class="default-button quick-verify tools-btn" type="button" id="quick-{occurrence_id}" title="Record tools">...</button>' . '<input type="hidden" class="row-input-form" value="{rootFolder}{input_form}"/><input type="hidden" class="row-belongs-to-site" value="{belongs_to_site}"/><ul class="verify-tools"><li><a href="#" class="quick-verify-tool">Bulk verify similar records</a></li>' . '<li><a href="#" class="trust-tool">Recorder\'s trust settings</a></li><li><a href="#" class="edit-record">Edit record</a></li></ul>' . '<input type="checkbox" class="check-row no-select" style="display: none" value="{occurrence_id}" /></div>'); $params = self::report_filter_panel($args, $auth['read']); $opts['zoomMapToOutput'] = false; $grid = report_helper::report_grid($opts); $r = str_replace(array('{grid}', '{paramsForm}'), array($grid, $params), self::get_template_with_map($args, $auth['read'], $opts['extraParams'], $opts['paramDefaults'])); $link = data_entry_helper::get_reload_link_parts(); global $user; data_entry_helper::$js_read_tokens = $auth['read']; data_entry_helper::$javascript .= 'indiciaData.nid = "' . $node->nid . "\";\n"; data_entry_helper::$javascript .= 'indiciaData.username = "******"\";\n"; data_entry_helper::$javascript .= 'indiciaData.userId = "' . $indicia_user_id . "\";\n"; data_entry_helper::$javascript .= 'indiciaData.rootUrl = "' . $link['path'] . "\";\n"; data_entry_helper::$javascript .= 'indiciaData.website_id = ' . $args['website_id'] . ";\n"; data_entry_helper::$javascript .= 'indiciaData.ajaxFormPostUrl="' . iform_ajaxproxy_url($node, 'occurrence') . "&user_id={$indicia_user_id}&sharing=verification\";\n"; data_entry_helper::$javascript .= 'indiciaData.ajaxUrl="' . url('iform/ajax/verification_4') . "\";\n"; data_entry_helper::$javascript .= 'indiciaData.autoDiscard = ' . $args['auto_discard_rows'] . ";\n"; if (!empty($args['indicia_species_layer_feature_type']) && !empty(data_entry_helper::$geoserver_url)) { data_entry_helper::$javascript .= "indiciaData.indiciaSpeciesLayer = {\n" . ' "title":"' . lang::get('Online recording data for this species') . "\",\n" . ' "featureType":"' . $args['indicia_species_layer_feature_type'] . "\",\n" . ' "wmsUrl":"' . data_entry_helper::$geoserver_url . "wms\",\n" . ' "cqlFilter":"website_id IN (' . implode(',', $websiteIds) . ') AND ' . $args['indicia_species_layer_filter_field'] . "='{filterValue}'\",\n" . ' "filterField":"' . $args['indicia_species_layer_ds_filter_field'] . "\",\n" . ' "sld":"' . (isset($args['indicia_species_layer_sld']) ? $args['indicia_species_layer_sld'] : '') . "\"\n" . "};\n"; } if (!empty($args['additional_wms_species_layer_title'])) { data_entry_helper::$javascript .= 'indiciaData.wmsSpeciesLayers = [{"title":"' . $args['additional_wms_species_layer_title'] . '",' . '"url":"' . $args['additional_wms_species_layer_url'] . '",' . '"settings":' . $args['additional_wms_species_layer_settings'] . ',' . '"olSettings":' . $args['additional_wms_species_layer_ol_settings'] . "}];\n"; } // output some translations for JS to use data_entry_helper::$javascript .= "indiciaData.popupTranslations = {};\n"; data_entry_helper::$javascript .= 'indiciaData.popupTranslations.title="' . lang::get('Add {1} comment') . "\";\n"; data_entry_helper::$javascript .= 'indiciaData.popupTranslations.save="' . lang::get('Save and {1}') . "\";\n"; data_entry_helper::$javascript .= 'indiciaData.popupTranslations.verbV="' . lang::get('verify') . "\";\n"; data_entry_helper::$javascript .= 'indiciaData.popupTranslations.verbR="' . lang::get('reject') . "\";\n"; data_entry_helper::$javascript .= 'indiciaData.popupTranslations.verbD="' . lang::get('query') . "\";\n"; data_entry_helper::$javascript .= 'indiciaData.popupTranslations.V="' . lang::get('Verification') . "\";\n"; data_entry_helper::$javascript .= 'indiciaData.popupTranslations.R="' . lang::get('Rejection') . "\";\n"; data_entry_helper::$javascript .= 'indiciaData.popupTranslations.D="' . lang::get('Query') . "\";\n"; data_entry_helper::$javascript .= 'indiciaData.popupTranslations.emailTitle="' . lang::get('Email record details for checking') . "\";\n"; data_entry_helper::$javascript .= 'indiciaData.popupTranslations.sendEmail="' . lang::get('Send Email') . "\";\n"; data_entry_helper::$javascript .= 'indiciaData.popupTranslations.emailSent="' . lang::get('The email was sent successfully.') . "\";\n"; data_entry_helper::$javascript .= 'indiciaData.popupTranslations.requestManualEmail="' . lang::get('The webserver is not correctly configured to send emails. Please send the following email usual your email client:') . "\";\n"; data_entry_helper::$javascript .= 'indiciaData.popupTranslations.multipleWarning="' . lang::get('You are about to verify multiple records. Please note that this comment will apply to all the ticked records. ' . 'If you did not intend to do this, please close this box and turn off the Select Records tool before proceeding.') . "\";\n"; data_entry_helper::$javascript .= "indiciaData.statusTranslations = {};\n"; data_entry_helper::$javascript .= 'indiciaData.statusTranslations.V = "' . lang::get('Verified') . "\";\n"; data_entry_helper::$javascript .= 'indiciaData.statusTranslations.R = "' . lang::get('Rejected') . "\";\n"; data_entry_helper::$javascript .= 'indiciaData.statusTranslations.D = "' . lang::get('Query') . "\";\n"; data_entry_helper::$javascript .= 'indiciaData.statusTranslations.I = "' . lang::get('In progress') . "\";\n"; data_entry_helper::$javascript .= 'indiciaData.statusTranslations.T = "' . lang::get('Test record') . "\";\n"; data_entry_helper::$javascript .= 'indiciaData.statusTranslations.S = "' . lang::get('Sent for verification') . "\";\n"; data_entry_helper::$javascript .= 'indiciaData.statusTranslations.C = "' . lang::get('Awaiting verification') . "\";\n"; data_entry_helper::$javascript .= "indiciaData.commentTranslations = {};\n"; data_entry_helper::$javascript .= 'indiciaData.commentTranslations.emailed = "' . lang::get('I emailed this record to {1} for checking.') . "\";\n"; data_entry_helper::$javascript .= 'indiciaData.commentTranslations.recorder = "' . lang::get('the recorder') . "\";\n"; data_entry_helper::$javascript .= 'indiciaData.commentTranslations.expert = "' . lang::get('an expert') . "\";\n"; data_entry_helper::$javascript .= 'indiciaData.email_subject_send_to_verifier = "' . $args['email_subject_send_to_verifier'] . "\";\n"; $body = str_replace(array("\r", "\n"), array('', '\\n'), $args['email_body_send_to_verifier']); data_entry_helper::$javascript .= 'indiciaData.email_body_send_to_verifier = "' . $body . "\";\n"; data_entry_helper::$javascript .= 'indiciaData.email_subject_send_to_recorder = "' . $args['email_subject_send_to_recorder'] . "\";\n"; $body = str_replace(array("\r", "\n"), array('', '\\n'), $args['email_body_send_to_recorder']); data_entry_helper::$javascript .= 'indiciaData.email_body_send_to_recorder = "' . $body . "\";\n"; data_entry_helper::$javascript .= 'indiciaData.str_month = "' . lang::get('month') . "\";\n"; data_entry_helper::$javascript .= 'indiciaData.expertise_location = "' . $opts['extraParams']['expertise_location'] . "\";\n"; data_entry_helper::$javascript .= 'indiciaData.expertise_surveys = "' . $opts['extraParams']['expertise_surveys'] . "\";\n"; data_entry_helper::$javascript .= 'indiciaData.expertise_taxon_groups = "' . $opts['extraParams']['expertise_taxon_groups'] . "\";\n"; data_entry_helper::add_resource('jqplot'); data_entry_helper::add_resource('jqplot_bar'); return $r; }
/** * Draw Photes section of the page. * @return string The output report grid. * * @package Client * @subpackage PrebuiltForms */ protected static function get_control_photos($auth, $args, $tabalias, $options) { iform_load_helpers(array('report_helper')); data_entry_helper::add_resource('fancybox'); //default an items per page if not set by administrator if (empty($options['itemsPerPage'])) { $options['itemsPerPage'] = 12; } //default a column count if not set by administrator if (empty($options['galleryColCount'])) { $options['galleryColCount'] = 3; } return '<h3>Photos</h3>' . report_helper::report_grid(array('readAuth' => $auth['read'], 'dataSource' => 'occurrence_image', 'itemsPerPage' => $options['itemsPerPage'], 'columns' => array(array('fieldname' => 'path', 'template' => '<div class="gallery-item"><a class="fancybox" href="{imageFolder}{path}"><img src="{imageFolder}thumb-{path}" title="{caption}" alt="{caption}"/><br/>{caption}</a></div>')), 'mode' => 'direct', 'autoParamsForm' => false, 'includeAllColumns' => false, 'headers' => false, 'galleryColCount' => $options['galleryColCount'], 'extraParams' => array('occurrence_id' => $_GET['occurrence_id'], 'sharing' => 'reporting'), 'ajax' => true)); }