当前位置: 首页>>代码示例>>PHP>>正文


PHP data_entry_helper::js_read_tokens方法代码示例

本文整理汇总了PHP中data_entry_helper::js_read_tokens方法的典型用法代码示例。如果您正苦于以下问题:PHP data_entry_helper::js_read_tokens方法的具体用法?PHP data_entry_helper::js_read_tokens怎么用?PHP data_entry_helper::js_read_tokens使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在data_entry_helper的用法示例。


在下文中一共展示了data_entry_helper::js_read_tokens方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: get_form

 /**
  * Return the generated form output.
  * @param array $args List of parameter values passed through to the form depending on how the form has been configured.
  * This array always contains a value for language.
  * @param object $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)
 {
     $conn = iform_get_connection_details($node);
     data_entry_helper::$js_read_tokens = data_entry_helper::get_read_auth($conn['website_id'], $conn['password']);
     if (!empty($_GET)) {
         self::do_data_services_download($args, $node);
     }
 }
开发者ID:joewoodhouse,项目名称:client_helpers,代码行数:17,代码来源:data_services.php

示例2: get_form

 /**
  * 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 = "' . $user->name . "\";\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";
//.........这里部分代码省略.........
开发者ID:BirenRathod,项目名称:indicia-code,代码行数:101,代码来源:verification_4.php

示例3: get_form

 /**
  * Return the generated form output.
  * @param array $args List of parameter values passed through to the form depending on how the form has been configured.
  * This array always contains a value for language.
  * @param object $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)
 {
     $conn = iform_get_connection_details($node);
     data_entry_helper::$js_read_tokens = data_entry_helper::get_read_auth($conn['website_id'], $conn['password']);
     if (!empty($_POST) && !empty($_POST['format'])) {
         self::do_data_services_download($args, $node);
     }
     $conn = iform_get_connection_details($node);
     data_entry_helper::$js_read_tokens = data_entry_helper::get_read_auth($conn['website_id'], $conn['password']);
     $types = self::get_download_types($args);
     $formats = self::get_download_formats($args);
     if (count($types) === 0) {
         return 'This download page is configured so that no download type options are available.';
     }
     if (count($formats) === 0) {
         return 'This download page is configured so that no download format options are available.';
     }
     $reload = data_entry_helper::get_reload_link_parts();
     $reloadPath = $reload['path'];
     if (count($reload['params'])) {
         $reloadPath .= '?' . helper_base::array_to_query_string($reload['params']);
     }
     $r = '<form method="POST" action="' . $reloadPath . '">';
     $r .= '<fieldset id="download-type-fieldset"><legend>' . lang::get('Records to download') . '</legend>';
     if (count($types) === 1) {
         $r .= '<input type="hidden" name="download-type" id="download-type" value="' . implode('', array_keys($types)) . '"/>';
         hostsite_set_page_title(lang::get('Download {1}', strtolower(implode('', $types))));
     } else {
         $r .= data_entry_helper::select(array('fieldname' => 'download-type', 'label' => lang::get('Download type'), 'lookupValues' => $types, 'class' => 'control-width-5', 'helpText' => 'Select the type of download you require, i.e. the purpose for the data. This defines which records are available to download.'));
     }
     $r .= data_entry_helper::select(array('fieldname' => 'download-subfilter', 'label' => lang::get('Filter to apply'), 'lookupValues' => array(), 'class' => 'control-width-5', 'helpText' => lang::get('Optionally select from the available filters. Filters you create on the Explore pages will be available here.')));
     $r .= "</fieldset>\n";
     $r .= '<fieldset><legend>' . lang::get('Limit the records') . '</legend>';
     if (empty($args['survey_id'])) {
         // put up an empty surveys drop down. AJAX will populate it.
         $r .= data_entry_helper::select(array('fieldname' => 'survey_id', 'label' => lang::get('Survey to include'), 'helpText' => 'Choose a survey, or <all> to not filter by survey.', 'lookupValues' => array(), 'class' => 'control-width-5'));
     } else {
         $r .= '<input type="hidden" name="survey_id" value="' . $args['survey_id'] . '"/>';
     }
     // Let the user pick the date range to download.
     $r .= data_entry_helper::select(array('label' => lang::get('Date field'), 'fieldname' => 'date_type', 'lookupValues' => array('recorded' => lang::get('Field record date'), 'input' => lang::get('Input date'), 'edited' => lang::get('Last changed date'), 'verified' => 'Verification status change date'), 'helpText' => 'If filtering on date, which date field would you like to filter on?'));
     $r .= data_entry_helper::date_picker(array('fieldname' => 'date_from', 'label' => lang::get('Start Date'), 'helpText' => 'Leave blank for no start date filter', 'class' => 'control-width-4'));
     $r .= data_entry_helper::date_picker(array('fieldname' => 'date_to', 'label' => lang::get('End Date'), 'helpText' => 'Leave blank for no end date filter', 'class' => 'control-width-4'));
     $r .= '</fieldset>';
     if (!empty($args['custom_formats'])) {
         $customFormats = json_decode($args['custom_formats'], true);
         foreach ($customFormats as $idx => $format) {
             if (empty($format['permission']) || user_access($format['permission'])) {
                 $formats["custom-{$idx}"] = lang::get(isset($format['title']) ? $format['title'] : 'Untitled format');
             }
         }
     }
     if (count($formats) > 1) {
         $r .= '<fieldset><legend>' . lang::get('Select a format to download') . '</legend>';
         $keys = array_keys($formats);
         $r .= data_entry_helper::radio_group(array('fieldname' => 'format', 'lookupValues' => $formats, 'default' => $keys[0]));
         $r .= '</fieldset>';
     } else {
         // only allowed 1 format, so no need for a selection control
         $keys = array_keys($formats);
         $r .= '<input type="hidden" name="format" value="' . array_pop($keys) . '"/>';
     }
     $r .= '<input type="submit" value="' . lang::get('Download') . '"/></form>';
     data_entry_helper::$javascript .= 'indiciaData.ajaxUrl="' . url('iform/ajax/easy_download_2') . "\";\n";
     data_entry_helper::$javascript .= 'indiciaData.nid = "' . $node->nid . "\";\n";
     data_entry_helper::$javascript .= "setAvailableDownloadFilters();\n";
     return $r;
 }
开发者ID:joewoodhouse,项目名称:client_helpers,代码行数:77,代码来源:easy_download_2.php

示例4: verification_panel

 /**
  * Outputs a panel and "Precheck my records" button. When clicked, the contents of the
  * current form are sent to the warehouse and run through any data cleaner verification
  * rules. The results are then displayed in the panel allowing the user to provide more
  * details for records of interest before submitting the form. Requires the data_cleaner 
  * module to be enabled on the warehouse.
  * The output of this control can be configured using the following templates: 
  * <ul>
  * <li><b>verification_panel</b></br>
  * HTML template used to generate container element for the verification panel.
  * </li>
  * </ul>
  * @global type $indicia_templates
  * @param array $options Options array with the following possibilities:<ul>
  * <li><b>readAuth</b><br/>
  * Read authorisation tokens
  * </ul>
  * <li><b>panelOnly</b><br/>
  * Default false. If true, then the button is ommited and the button's functionality
  * must be included elsewhere on the page.
  * </li>
  * </ul>
  * @return type HTML to insert onto the page for the verification panel.
  */
 public function verification_panel($options)
 {
     global $indicia_templates;
     $options = array_merge(array('panelOnly' => false), $options);
     $button = $options['panelOnly'] ? '' : self::apply_replacements_to_template($indicia_templates['button'], array('href' => '#', 'id' => 'verify-btn', 'class' => 'class="indicia-button"', 'caption' => lang::get('Precheck my records'), 'title' => ''));
     $replacements = array('button' => $button);
     self::add_resource('verification');
     self::$js_read_tokens = $options['readAuth'];
     self::$javascript .= "indiciaData.verifyMessages=[];\n";
     self::$javascript .= "indiciaData.verifyMessages.nothingToCheck='" . lang::get('There are no records on this form to check.') . "';\n";
     self::$javascript .= "indiciaData.verifyMessages.completeRecordFirst='" . lang::get('Before checking, please complete at least the date and grid reference of the record.') . "';\n";
     self::$javascript .= "indiciaData.verifyMessages.noProblems='" . lang::get('Automated verification checks did not find anything of note.') . "';\n";
     self::$javascript .= "indiciaData.verifyMessages.problems='" . lang::get('Automated verification checks resulted in the following messages:') . "';\n";
     self::$javascript .= "indiciaData.verifyMessages.problemsFooter='" . lang::get('A message not mean that there is anything wrong with the record, but if you can provide as much information ' . 'as possible, including photos, then it will help with its confirmation.') . "';\n";
     return self::apply_replacements_to_template($indicia_templates['verification_panel'], $replacements);
 }
开发者ID:BirenRathod,项目名称:indicia-code,代码行数:40,代码来源:data_entry_helper.php

示例5: add_sites_to_any_user

 public static function add_sites_to_any_user($auth, $args, $tabalias, $options, $path)
 {
     //Need to call this so we can use indiciaData.read
     data_entry_helper::$js_read_tokens = $auth['read'];
     if (!function_exists('iform_ajaxproxy_url')) {
         return 'An AJAX Proxy module must be enabled for user sites administration to work.';
     }
     $r = "<form><fieldset><legend>" . lang::get('Add locations to the sites lists for other users') . "</legend>";
     if (empty($options['locationTypes']) || !preg_match('/^([0-9]+,( )?)*[0-9]+$/', $options['locationTypes'])) {
         return 'The sites form is not correctly configured. Please provide the location type you can add.';
     }
     $locationTypes = explode(',', str_replace(' ', '', $options['locationTypes']));
     if (empty($options['mySitesPsnAttrId']) || !preg_match('/^[0-9]+$/', $options['mySitesPsnAttrId'])) {
         return 'The sites form is not correctly configured. Please provide the person attribute ID used to store My Sites.';
     }
     if (!empty($options['locationParamFromURL']) && !empty($_GET[$options['locationParamFromURL']])) {
         $locationIdFromURL = $_GET[$options['locationParamFromURL']];
     } else {
         $locationIdFromURL = 0;
     }
     //If we don't want to automatically get the location id from the URL, then display a drop-down of locations the user can select from
     if (empty($locationIdFromURL)) {
         $r .= '<label>' . lang::get('Location :') . '</label> ';
         //Get a list of all the locations that match the given location types (in this case my sites are returned first, although this isn't a requirement)
         $r .= data_entry_helper::location_select(array('id' => 'location-select', 'nocache' => true, 'report' => 'reports_for_prebuilt_forms/Shorewatch/locations_with_my_sites_first', 'extraParams' => $auth['read'] + array('location_type_ids' => $options['locationTypes'], 'user_id' => hostsite_get_user_field('indicia_user_id'), 'my_sites_person_attr_id' => $options['mySitesPsnAttrId']), 'blankText' => '<' . lang::get('please select') . '>'));
     }
     //Get the user select control
     $r .= self::user_select_for_add_sites_to_any_user_control($auth['read'], $args);
     $r .= '<input id="add-user-site-button" type="button" value="' . lang::get('Add to this User\'s Sites List') . '"/><br></form><br>';
     $postUrl = iform_ajaxproxy_url(null, 'person_attribute_value');
     //Firstly check both a uer and location have been selected.
     //Then get the current user/sites saved in the database and if the new combination doesn't already exist then call a function to add it.
     data_entry_helper::$javascript .= "\n    function duplicateCheck(locationId, userId) {\n      var userIdToAdd = \$('#user-select').val();\n      var locationIdToAdd = locationId;\n      var sitesReport = indiciaData.read.url +'/index.php/services/report/requestReport?report=library/locations/all_user_sites.xml&mode=json&mode=json&callback=?';\n        \n      var sitesReportParameters = {\n        'person_site_attr_id': '" . $options['mySitesPsnAttrId'] . "',\n        'auth_token': indiciaData.read.auth_token,\n        'nonce': indiciaData.read.nonce,\n        'reportSource':'local'\n      };\n        \n      if (!userIdToAdd||!locationIdToAdd) {\n        alert('Please select both a user and a location to add.');\n      } else {\n        \$.getJSON (\n          sitesReport,\n          sitesReportParameters,\n          function (data) {\n            var duplicateDetected=false;\n            \$.each(data, function(i, dataItem) {\n              if (userIdToAdd==dataItem.pav_user_id&&locationIdToAdd==dataItem.location_id) {\n                  duplicateDetected=true;\n              }\n            });\n            if (duplicateDetected===true) {\n              alert('The site/user combination you are adding already exists in the database.');\n            } else {\n              addUserSiteData(locationId, userIdToAdd);\n            }\n          }\n        );\n      }    \n    }\n    ";
     //After duplicate check is performed, add the user/site combination to the person_attribute_values database table
     data_entry_helper::$javascript .= "\n    function addUserSiteData(locationId, userIdToAdd) {\n      if (!isNaN(locationId) && locationId!=='') {\n        \$.post('{$postUrl}', \n          {\"website_id\":" . $args['website_id'] . ",\"person_attribute_id\":" . $options['mySitesPsnAttrId'] . ",\"user_id\":userIdToAdd,\"int_value\":locationId},\n          function (data) {\n            if (typeof data.error === 'undefined') {\n              alert('User site configuration saved successfully');\n              location.reload();\n            } else {\n              alert(data.error);\n            }              \n          },\n          'json'\n        );\n      }\n    }\n    ";
     //Call duplicate check when administrator elects to save a user/site combination
     data_entry_helper::$javascript .= "\n    \$('#add-user-site-button').click(function() {\n      //We can get the location id from the url or from the locations drop-down depending on the option the administrator has set.\n      var locationId;\n      if (" . $locationIdFromURL . ") {\n        locationId = " . $locationIdFromURL . ";\n      } else {\n        locationId = \$('#location-select').val()       \n      }\n      duplicateCheck(locationId,\$('#dynamic-the_user_id').val());\n    });";
     //Zoom map as user selects locations
     data_entry_helper::$javascript .= "\n    \$('#location-select, #location-search, #locality_id').change(function() {\n      if (typeof indiciaData.mapdiv!=='undefined') {\n        indiciaData.mapdiv.locationSelectedInInput(indiciaData.mapdiv, this.value);\n      }\n    });\n    ";
     //Function for when user elects to remove sites
     data_entry_helper::$javascript .= "\n    user_site_delete = function(pav_id) {\n      var userId=\$('#dynamic-the_user_id').val();\n      \$.post('{$postUrl}', \n        {\"website_id\":" . $args['website_id'] . ",\"id\":pav_id, \"deleted\":\"t\"},\n        function (data) {\n          if (typeof data.error === 'undefined') {\n            location.reload(); \n          } else {\n            alert(data.error);\n          }\n        },\n        'json'\n      );\n    }\n    ";
     return $r;
 }
开发者ID:BirenRathod,项目名称:drupal-6,代码行数:43,代码来源:my_sites.php

示例6: species_checklist

 /**
  * Helper function to generate a species checklist from a given taxon list.
  *
  * Please not that although this is based on the data_entry_helper function, it has only been tested with the following
  * options for seasearch - @id,@useThirdLevelSamples,@lookupListId,@gridIdAttributeId,@speciesControlToUseSubSamples,@subSamplePerRow,@resizeWidth,@resizeHeight
  * If you intend to use any other options, they will require further testing or development.
  *
  */
 private static function species_checklist($options)
 {
     global $indicia_templates;
     data_entry_helper::add_resource('addrowtogrid');
     $options = data_entry_helper::get_species_checklist_options($options);
     $classlist = array('ui-widget', 'ui-widget-content', 'species-grid');
     if (!empty($options['class'])) {
         $classlist[] = $options['class'];
     }
     if ($options['subSamplePerRow']) {
         // we'll track 1 sample per grid row.
         $smpIdx = 0;
     }
     if ($options['columns'] > 1 && count($options['mediaTypes']) > 1) {
         throw new Exception('The species_checklist control does not support having more than one occurrence per row (columns option > 0) ' . 'at the same time has having the mediaTypes option in use.');
     }
     data_entry_helper::add_resource('json');
     data_entry_helper::add_resource('autocomplete');
     $filterArray = data_entry_helper::get_species_names_filter($options);
     $filterNameTypes = array('all', 'currentLanguage', 'preferred', 'excludeSynonyms');
     //make a copy of the options so that we can maipulate it
     $overrideOptions = $options;
     //We are going to cycle through each of the name filter types
     //and save the parameters required for each type in an array so
     //that the Javascript can quickly access the required parameters
     foreach ($filterNameTypes as $filterType) {
         $overrideOptions['speciesNameFilterMode'] = $filterType;
         $nameFilter[$filterType] = data_entry_helper::get_species_names_filter($overrideOptions);
         $nameFilter[$filterType] = json_encode($nameFilter[$filterType]);
     }
     if (count($filterArray)) {
         $filterParam = json_encode($filterArray);
         data_entry_helper::$javascript .= "indiciaData['taxonExtraParams-" . $options['id'] . "'] = {$filterParam};\n";
         // Apply a filter to extraParams that can be used when loading the initial species list, to get just the correct names.
         if (isset($options['speciesNameFilterMode']) && !empty($options['listId'])) {
             $filterFields = array();
             $filterWheres = array();
             self::parse_species_name_filter_mode($options, $filterFields, $filterWheres);
             if (count($filterWheres)) {
                 $options['extraParams'] += array('query' => json_encode(array('where' => $filterWheres)));
             }
             $options['extraParams'] += $filterFields;
         }
     }
     data_entry_helper::$js_read_tokens = $options['readAuth'];
     data_entry_helper::$javascript .= "indiciaData['rowInclusionCheck-" . $options['id'] . "'] = '" . $options['rowInclusionCheck'] . "';\n";
     data_entry_helper::$javascript .= "indiciaData['copyDataFromPreviousRow-" . $options['id'] . "'] = '" . $options['copyDataFromPreviousRow'] . "';\n";
     data_entry_helper::$javascript .= "indiciaData['includeSpeciesGridLinkPage-" . $options['id'] . "'] = '" . $options['includeSpeciesGridLinkPage'] . "';\n";
     data_entry_helper::$javascript .= "indiciaData.speciesGridPageLinkUrl = '" . $options['speciesGridPageLinkUrl'] . "';\n";
     data_entry_helper::$javascript .= "indiciaData.speciesGridPageLinkParameter = '" . $options['speciesGridPageLinkParameter'] . "';\n";
     data_entry_helper::$javascript .= "indiciaData.speciesGridPageLinkTooltip = '" . $options['speciesGridPageLinkTooltip'] . "';\n";
     data_entry_helper::$javascript .= "indiciaData['editTaxaNames-" . $options['id'] . "'] = '" . $options['editTaxaNames'] . "';\n";
     data_entry_helper::$javascript .= "indiciaData['subSpeciesColumn-" . $options['id'] . "'] = '" . $options['subSpeciesColumn'] . "';\n";
     data_entry_helper::$javascript .= "indiciaData['subSamplePerRow-" . $options['id'] . "'] = " . ($options['subSamplePerRow'] ? 'true' : 'false') . ";\n";
     if ($options['copyDataFromPreviousRow']) {
         data_entry_helper::$javascript .= "indiciaData['previousRowColumnsToInclude-" . $options['id'] . "'] = '" . $options['previousRowColumnsToInclude'] . "';\n";
         data_entry_helper::$javascript .= "indiciaData.langAddAnother='" . lang::get('Add another') . "';\n";
     }
     if (count($options['mediaTypes'])) {
         data_entry_helper::add_resource('plupload');
         // store some globals that we need later when creating uploaders
         $relpath = data_entry_helper::getRootFolder() . data_entry_helper::client_helper_path();
         $interim_image_folder = isset(parent::$interim_image_folder) ? parent::$interim_image_folder : 'upload/';
         data_entry_helper::$javascript .= "indiciaData.uploadSettings = {\n";
         data_entry_helper::$javascript .= "  uploadScript: '" . $relpath . "upload.php',\n";
         data_entry_helper::$javascript .= "  destinationFolder: '" . $relpath . $interim_image_folder . "',\n";
         data_entry_helper::$javascript .= "  jsPath: '" . data_entry_helper::$js_path . "'";
         if (isset($options['resizeWidth'])) {
             data_entry_helper::$javascript .= ",\n  resizeWidth: " . $options['resizeWidth'];
         }
         if (isset($options['resizeHeight'])) {
             data_entry_helper::$javascript .= ",\n  resizeHeight: " . $options['resizeHeight'];
         }
         if (isset($options['resizeQuality'])) {
             data_entry_helper::$javascript .= ",\n  resizeQuality: " . $options['resizeQuality'];
         }
         data_entry_helper::$javascript .= "\n}\n";
         if ($indicia_templates['file_box'] != '') {
             data_entry_helper::$javascript .= "file_boxTemplate = '" . str_replace('"', '\\"', $indicia_templates['file_box']) . "';\n";
         }
         if ($indicia_templates['file_box_initial_file_info'] != '') {
             data_entry_helper::$javascript .= "file_box_initial_file_infoTemplate = '" . str_replace('"', '\\"', $indicia_templates['file_box_initial_file_info']) . "';\n";
         }
         if ($indicia_templates['file_box_uploaded_image'] != '') {
             data_entry_helper::$javascript .= "file_box_uploaded_imageTemplate = '" . str_replace('"', '\\"', $indicia_templates['file_box_uploaded_image']) . "';\n";
         }
     }
     $occAttrControls = array();
     $occAttrs = array();
     $occAttrControlsExisting = array();
     $taxonRows = array();
     $subSampleRows = array();
//.........这里部分代码省略.........
开发者ID:BirenRathod,项目名称:indicia-code,代码行数:101,代码来源:dynamic_progressive_seasearch_survey.php

示例7: get_form

 /**
  * 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 = "' . $user->name . "\";\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";
//.........这里部分代码省略.........
开发者ID:BirenRathod,项目名称:indicia-code,代码行数:101,代码来源:verification_samples.php

示例8: add_locations_to_user

 public static function add_locations_to_user($auth, $args, $tabalias, $options, $path)
 {
     global $user;
     //Need to call this so we can use indiciaData.read
     data_entry_helper::$js_read_tokens = $auth['read'];
     if (!function_exists('iform_ajaxproxy_url')) {
         return 'An AJAX Proxy module must be enabled for user sites administration to work.';
     }
     if (!empty($options['locationDropDownLabel'])) {
         $locationDropDownLabel = $addButtonLabel = $options['locationDropDownLabel'] . ' :';
     } else {
         $locationDropDownLabel = lang::get('Location :');
     }
     if (!empty($options['addButtonLabel'])) {
         $addButtonLabel = $options['addButtonLabel'];
     } else {
         $addButtonLabel = lang::get('Add to this User\'s Sites List');
     }
     if (!empty($options['fieldSetLegend'])) {
         $fieldSetLegendText = $options['fieldSetLegend'];
     } else {
         $fieldSetLegendText = lang::get('Add locations to the sites lists for other users');
     }
     if (!empty($options['rolesExemptFromApproval'])) {
         $RolesExemptFromApproval = explode(',', $options['rolesExemptFromApproval']);
     } else {
         $RolesExemptFromApproval = array();
     }
     $r = "<form><fieldset><legend>" . $fieldSetLegendText . "</legend>";
     if (empty($options['locationTypes']) || !preg_match('/^([0-9]+,( )?)*[0-9]+$/', $options['locationTypes'])) {
         return 'The sites form is not correctly configured. Please provide the location type you can add.';
     }
     $locationTypes = explode(',', str_replace(' ', '', $options['locationTypes']));
     if (empty($options['mySitesPsnAttrId']) || !preg_match('/^[0-9]+$/', $options['mySitesPsnAttrId'])) {
         return 'The sites form is not correctly configured. Please provide the person attribute ID used to store My Sites.';
     }
     if (!empty($options['locationParamFromURL']) && !empty($_GET[$options['locationParamFromURL']])) {
         $locationIdFromURL = $_GET[$options['locationParamFromURL']];
     } else {
         $locationIdFromURL = 0;
     }
     //Get the user_id from the URL if we can, this would hide the user drop-down and make
     //the control applicable to a single user.
     if (!empty($options['userParamFromURL']) && !empty($_GET[$options['userParamFromURL']])) {
         $userIdFromURL = $_GET[$options['userParamFromURL']];
     } elseif (!empty($_GET['dynamic-the_user_id'])) {
         $userIdFromURL = $_GET['dynamic-the_user_id'];
     } else {
         $userIdFromURL = 0;
     }
     $extraParams = array('location_type_ids' => $options['locationTypes'], 'user_id' => hostsite_get_user_field('indicia_user_id'), 'my_sites_person_attr_id' => $options['mySitesPsnAttrId']);
     //Can limit results in location drop-down to certain distance of a post code
     if (!empty($options['postCodeGeomParamName']) && !empty($_GET[$options['postCodeGeomParamName']])) {
         $extraParams['post_code_geom'] = $_GET[$options['postCodeGeomParamName']];
     }
     if (!empty($options['distanceFromPostCodeParamName']) && !empty($_GET[$options['distanceFromPostCodeParamName']])) {
         $extraParams['distance_from_post_code'] = $_GET[$options['distanceFromPostCodeParamName']];
     }
     if (!empty($options['excludedSquareAttrId'])) {
         $extraParams['excluded_square_attr_id'] = $options['excludedSquareAttrId'];
     }
     if (!empty($options['dontReturnAllocatedLocations'])) {
         $extraParams['dont_return_allocated_locations'] = $options['dontReturnAllocatedLocations'];
     }
     if (!empty($options['maxAllocationForLocationAttrId'])) {
         $extraParams['max_allocation_for_location_attr_id'] = $options['maxAllocationForLocationAttrId'];
     }
     //If we don't want to automatically get the location id from the URL, then display a drop-down of locations the user can select from
     if (empty($locationIdFromURL)) {
         $r .= '<label>' . $locationDropDownLabel . '</label> ';
         //Get a list of all the locations that match the given location types (in this case my sites are returned first, although this isn't a requirement)
         $r .= data_entry_helper::location_select(array('id' => 'location-select', 'nocache' => true, 'report' => 'reports_for_prebuilt_forms/Splash/locations_for_add_location_drop_down', 'extraParams' => $auth['read'] + $extraParams, 'blankText' => '<' . lang::get('please select') . '>'));
     }
     //Get the user select control if the user id isn't in the url
     if (empty($userIdFromURL)) {
         $r .= self::user_select_for_add_sites_to_any_user_control($auth['read'], $args);
     }
     $r .= '<input id="add-user-site-button" type="button" value="' . $addButtonLabel . '"/><br></form><br>';
     $postUrl = iform_ajaxproxy_url(null, 'person_attribute_value');
     //Firstly check both a uer and location have been selected.
     //Then get the current user/sites saved in the database and if the new combination doesn't already exist then call a function to add it.
     data_entry_helper::$javascript .= "\n    function duplicateCheck(locationId, userId) {\n      var userIdToAdd = userId;\n      var locationIdToAdd = locationId;\n      var sitesReport = indiciaData.read.url +'/index.php/services/report/requestReport?report=library/locations/all_user_sites.xml&mode=json&mode=json&callback=?';\n        \n      var sitesReportParameters = {\n        'person_site_attr_id': '" . $options['mySitesPsnAttrId'] . "',\n        'auth_token': indiciaData.read.auth_token,\n        'nonce': indiciaData.read.nonce,\n        'reportSource':'local'\n      };\n      \n      if (!userIdToAdd||!locationIdToAdd) {\n        alert('Please select both a user and a location to add.');\n      } else {\n        \$.getJSON (\n          sitesReport,\n          sitesReportParameters,\n          function (data) {\n            var duplicateDetected=false;\n            \$.each(data, function(i, dataItem) {\n              if (userIdToAdd==dataItem.pav_user_id&&locationIdToAdd==dataItem.location_id) {\n                  duplicateDetected=true;\n              }\n            });\n            if (duplicateDetected===true) {\n              alert('The site/user combination you are adding already exists in the database.');\n            } else {\n              addUserSiteData(locationId, userIdToAdd);\n            }\n          }\n        );\n      }    \n    }\n    ";
     //This veriabe holds the updated_by_id=1 if the user is found to be exempt, if they aren't exempt then this is blank so that the
     //updated_by_id is set automatically by the system.
     $updatedBySystem = '';
     //See if any of the user's roles are in the exempt list.
     foreach ($RolesExemptFromApproval as $exemptRole) {
         foreach ($user->roles as $userRole) {
             if ($exemptRole === $userRole) {
                 $updatedBySystem = ',"updated_by_id":1';
             }
         }
     }
     //Add the user/site combination to the person_attribute_values database table.
     //This overrides the function in the my_sites.php file.
     data_entry_helper::$javascript .= "\n    var addUserSiteData = function (locationId, userIdToAdd) {\n      if (!isNaN(locationId) && locationId!=='') {\n        \$.post('{$postUrl}', \n          {\"website_id\":" . $args['website_id'] . ",\"person_attribute_id\":" . $options['mySitesPsnAttrId'] . ",\"user_id\":userIdToAdd,\"int_value\":locationId" . $updatedBySystem . "},\n          function (data) {\n            if (typeof data.error === 'undefined') {\n              alert('User site configuration saved successfully');\n              location.reload();\n            } else {\n              alert(data.error);\n            }              \n          },\n          'json'\n        );\n      }\n    }\n    ";
     //Call duplicate check when administrator elects to save a user/site combination
     data_entry_helper::$javascript .= "\n    \$('#add-user-site-button').click(function() {\n      //We can get the location id from the url or from the locations drop-down depending on the option the administrator has set.\n      var locationId;\n      var userId;\n      if (" . $locationIdFromURL . ") {\n        locationId = " . $locationIdFromURL . ";\n      } else {\n        locationId = \$('#location-select').val();       \n      }\n      if (" . $userIdFromURL . ") {\n        userId = " . $userIdFromURL . ";\n      } else {\n        userId = \$('#user-select').val();     \n      }\n      duplicateCheck(locationId,userId);\n    });";
     //Zoom map as user selects locations
     data_entry_helper::$javascript .= "\n    \$('#location-select, #location-search, #locality_id').change(function() {\n      if (typeof indiciaData.mapdiv!=='undefined') {\n        indiciaData.mapdiv.locationSelectedInInput(indiciaData.mapdiv, this.value);\n      }\n    });\n    ";
//.........这里部分代码省略.........
开发者ID:BirenRathod,项目名称:indicia-code,代码行数:101,代码来源:splash_extensions.php

示例9: get_form

 /**
  * Return the generated form output.
  * @param array $args List of parameter values passed through to the form depending on how the form has been configured.
  * This array always contains a value for language.
  * @param object $nid The Drupal node object's ID.
  * @param array $response When this form is reloading after saving a submission, contains the response from the service call.
  * Note this does not apply when redirecting (in this case the details of the saved object are in the $_GET data).
  * @return Form HTML.
  */
 public static function get_form($args, $nid, $response = null)
 {
     drupal_add_js(iform_client_helpers_path() . "prebuilt_forms/js/easy_download_2.js");
     drupal_add_css(iform_client_helpers_path() . "prebuilt_forms/css/easy_download_2.css");
     $conn = iform_get_connection_details($nid);
     $args = array_merge(array('download_administered_groups' => 'indicia data admin', 'download_group_types' => ''), $args);
     $readAuth = data_entry_helper::get_read_auth($conn['website_id'], $conn['password']);
     if (data_entry_helper::$js_read_tokens === null) {
         data_entry_helper::$js_read_tokens = $readAuth;
     }
     if (!empty($_POST) && !empty($_POST['format'])) {
         self::do_data_services_download($args, $nid);
     }
     $types = self::get_download_types($args);
     $formats = self::get_download_formats($args);
     if (count($types) === 0) {
         return 'This download page is configured so that no download type options are available.';
     }
     if (count($formats) === 0) {
         return 'This download page is configured so that no download format options are available.';
     }
     $reload = data_entry_helper::get_reload_link_parts();
     $reloadPath = $reload['path'];
     if (count($reload['params'])) {
         $reloadPath .= '?' . helper_base::array_to_query_string($reload['params']);
     }
     $r = '<form method="POST" action="' . $reloadPath . '">';
     $r .= '<fieldset id="download-type-fieldset"><legend>' . lang::get('Records to download') . '</legend>';
     if (count($types) === 1) {
         $r .= '<input type="hidden" name="download-type" id="download-type" value="' . implode('', array_keys($types)) . '"/>';
         hostsite_set_page_title(lang::get('Download {1}', strtolower(implode('', $types))));
     } else {
         $r .= data_entry_helper::select(array('fieldname' => 'download-type', 'label' => lang::get('Download type'), 'lookupValues' => $types, 'class' => 'control-width-5', 'helpText' => 'Select the type of download you require, i.e. the purpose for the data. This defines which records are available to download.'));
     }
     $r .= data_entry_helper::select(array('fieldname' => 'download-subfilter', 'label' => lang::get('Filter to apply'), 'lookupValues' => array(), 'class' => 'control-width-5', 'helpText' => lang::get('Optionally select from the available filters. Filters you create on the Explore pages will be available here.')));
     $r .= "</fieldset>\n";
     $r .= '<fieldset><legend>' . lang::get('Limit the records') . '</legend>';
     // Hub
     // TODO may run into URL size limits
     $vocabulary = taxonomy_vocabulary_machine_name_load('hubs');
     $terms = entity_load('taxonomy_term', FALSE, array('vid' => $vocabulary->vid));
     // the hub is driven by a user field, stored as tid.
     $hubList = array('' => lang::get('<All>'));
     foreach ($terms as $term) {
         // TODO Cache
         $query = new EntityFieldQuery();
         $query->entityCondition('entity_type', 'user')->fieldCondition('field_preferred_training_hub', 'tid', $term->tid);
         $result = $query->execute();
         // This gives us the list of users which are in the hub: CMS user ID: now convert to indicia user id
         $userIDList = array();
         if (count($result) > 0) {
             $cmsUserIDs = array_keys($result['user']);
             foreach ($cmsUserIDs as $cmsUserID) {
                 $user_data = user_load($cmsUserID);
                 // TODO Making assumption about language
                 if (!empty($user_data->field_indicia_user_id['und'][0]['value'])) {
                     $userIDList[] = $user_data->field_indicia_user_id['und'][0]['value'];
                 }
             }
             if (count($userIDList) > 0) {
                 $hubList[implode(',', $userIDList)] = $term->tid . ' ' . $term->name;
             }
         }
     }
     $r .= data_entry_helper::select(array('fieldname' => 'user_id_list', 'label' => lang::get('Hub to include'), 'helpText' => 'Choose a Hub, or &lt;All&gt; to not filter by Hub. This is driven off the users currently allocated to the hub. This currently does not apply to the NBN download.', 'lookupValues' => $hubList, 'class' => 'control-width-5'));
     // End Cocoast Hub
     if (empty($args['survey_id'])) {
         // put up an empty surveys drop down. AJAX will populate it.
         $r .= data_entry_helper::select(array('fieldname' => 'survey_id', 'label' => lang::get('Survey to include'), 'helpText' => 'Choose a survey, or &lt;All&gt; to not filter by survey.', 'lookupValues' => array(), 'class' => 'control-width-5'));
     } else {
         $r .= '<input type="hidden" name="survey_id" value="' . $args['survey_id'] . '"/>';
     }
     // Let the user pick the date range to download.
     $r .= data_entry_helper::select(array('label' => lang::get('Date field'), 'fieldname' => 'date_type', 'lookupValues' => array('recorded' => lang::get('Field record date'), 'input' => lang::get('Input date'), 'edited' => lang::get('Last changed date'), 'verified' => 'Verification status change date'), 'helpText' => 'If filtering on date, which date field would you like to filter on?'));
     $r .= data_entry_helper::date_picker(array('fieldname' => 'date_from', 'label' => lang::get('Start Date'), 'helpText' => 'Leave blank for no start date filter', 'class' => 'control-width-4'));
     $r .= data_entry_helper::date_picker(array('fieldname' => 'date_to', 'label' => lang::get('End Date'), 'helpText' => 'Leave blank for no end date filter', 'class' => 'control-width-4'));
     $r .= '</fieldset>';
     if (!empty($args['custom_formats'])) {
         $customFormats = json_decode($args['custom_formats'], true);
         foreach ($customFormats as $idx => $format) {
             if (empty($format['permission']) || hostsite_user_has_permission($format['permission'])) {
                 $formats["custom-{$idx}"] = lang::get(isset($format['title']) ? $format['title'] : 'Untitled format');
             }
         }
     }
     if (count($formats) > 1) {
         $r .= '<fieldset><legend>' . lang::get('Select a format to download') . '</legend>';
         $keys = array_keys($formats);
         $r .= data_entry_helper::radio_group(array('fieldname' => 'format', 'lookupValues' => $formats, 'default' => $keys[0]));
         $r .= '</fieldset>';
     } else {
//.........这里部分代码省略.........
开发者ID:Indicia-Team,项目名称:CoCoast,代码行数:101,代码来源:cocoast_easy_download_2.php


注:本文中的data_entry_helper::js_read_tokens方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。