public function setup() { $this->auth = report_helper::get_read_write_auth(1, 'password'); // make the tokens re-usable $this->auth['write_tokens']['persist_auth'] = true; // set up a tiny bit of data. First pick a termlists_term_id to use which is never going to be a valid location type, // so we can filter for just our test location. $this->db = new Database(); $qry = $this->db->select('id')->from('list_termlists_terms')->where(array('termlist_external_key' => 'indicia:dafor', 'term' => 'Frequent'))->get()->result_array(false); $this->locationTypeId = $qry[0]['id']; $loc = ORM::Factory('location'); $loc->name = 'UnitTest'; $loc->centroid_sref = 'SU01'; $loc->centroid_sref_system = 'OSGB'; $loc->location_type_id = $this->locationTypeId; $loc->set_metadata(); $loc->save(); $this->locationId = $loc->id; $locattr = ORM::Factory('location_attribute'); $locattr->caption = 'UnitTest'; $locattr->data_type = 'T'; $locattr->public = 'f'; $locattr->set_metadata(); $locattr->save(); $this->locationAttributeId = $locattr->id; $locwebsite = ORM::Factory('location_attributes_website'); $locwebsite->website_id = 1; $locwebsite->location_attribute_id = $this->locationAttributeId; $locwebsite->set_metadata(); $locwebsite->save(); $this->locationAttrWebsiteId = $locwebsite->id; }
/** * 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. * @return HTML string */ public static function get_form($args, $node, $response) { require_once drupal_get_path('module', 'iform') . '/client_helpers/report_helper.php'; require_once drupal_get_path('module', 'iform') . '/client_helpers/map_helper.php'; $auth = report_helper::get_read_write_auth($args['website_id'], $args['password']); $reportOptions = iform_report_get_report_options($args, $auth); $r = '<div class="ui-helper-clearfix">'; $reportOptions['geoserverLayer'] = $args['geoserver_layer']; $reportOptions['geoserverLayerStyle'] = $args['geoserver_layer_style']; $reportOptions['cqlTemplate'] = $args['cql_template']; $reportOptions['clickable'] = $args['click_on_map_mode'] != 'none'; $reportOptions['clickableLayersOutputDiv'] = $args['click_on_map_div']; if ($args['click_on_map_mode'] != 'none') { $reportOptions['clickableLayersOutputMode'] = $args['click_on_map_mode']; } // Use the proxy module if enabled, to get round limitations in URL length for // filtered WMS requests. if (defined('DRUPAL_BOOTSTRAP_CONFIGURATION') && module_exists('iform_proxy')) { global $base_url; $reportOptions['proxy'] = $base_url . '/?q=' . variable_get('iform_proxy_path', 'proxy') . '&url='; } $r .= '<br/>' . report_helper::report_map($reportOptions); $options = iform_map_get_map_options($args, $readAuth); $olOptions = iform_map_get_ol_options($args); // This is used for drawing, so need an editlayer, but not used for input $options['editLayer'] = true; $options['editLayerInSwitcher'] = true; $options['clickForSpatialRef'] = false; if ($args['layer_picker'] != 'none') { $picker = array('id' => 'map-layer-picker', 'includeIcons' => false, 'includeSwitchers' => true, 'includeHiddenLayers' => true); if ($args['layer_picker'] == 'before') { $r .= map_helper::layer_list($picker); } // as we have a layer picker, we can drop the layerSwitcher from the OL map. if (array_search('layerSwitcher', $options['standardControls']) !== false) { unset($options['standardControls'][array_search('layerSwitcher', $options['standardControls'])]); } } if ($args['legend'] != 'none') { $legend = array('id' => 'map-legend', 'includeIcons' => true, 'includeSwitchers' => false, 'includeHiddenLayers' => false); if ($args['legend'] == 'before') { $r .= map_helper::layer_list($legend); } } if (isset($args['map_toolbar_pos'])) { $options['toolbarDiv'] = $args['map_toolbar_pos']; } $r .= map_helper::map_panel($options, $olOptions); if ($args['layer_picker'] == 'after') { $r .= map_helper::layer_list($picker); } if ($args['legend'] == 'after') { $r .= map_helper::layer_list($legend); } $r .= '</div>'; 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) { 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); $reportOptions['header'] = $args['header']; $reportOptions['footer'] = $args['footer']; $reportOptions['bands'] = json_decode($args['bands'], true); return report_helper::freeform_report($reportOptions); }
/** * 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; }
/** * 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'; require_once drupal_get_path('module', 'iform') . '/client_helpers/map_helper.php'; $auth = report_helper::get_read_write_auth($args['website_id'], $args['password']); $chartOptions = iform_report_get_report_options($args, $auth); $chartOptions = array_merge($chartOptions, array('id' => 'chart-div', 'width' => $args['width'], 'height' => $args['height'], 'chartType' => $args['chart_type'], 'yValues' => explode(',', $args['y_values']))); $xLabels = trim($args['x_labels']); if (empty($xLabels)) { $chartOptions['xValues'] = explode(',', $args['x_values']); } else { $chartOptions['xLabels'] = explode(',', $args['x_labels']); } // advanced options $rendererOptions = trim($args['renderer_options']); if (!empty($rendererOptions)) { $chartOptions['rendererOptions'] = json_decode($rendererOptions, true); } $legendOptions = trim($args['legend_options']); if (!empty($legendOptions)) { $chartOptions['legendOptions'] = json_decode($legendOptions, true); } $seriesOptions = trim($args['series_options']); if (!empty($seriesOptions)) { $chartOptions['seriesOptions'] = json_decode($seriesOptions, true); } $axesOptions = trim($args['axes_options']); if (!empty($axesOptions)) { $chartOptions['axesOptions'] = json_decode($axesOptions, true); } // now the chart itself $r .= '<br/>' . report_helper::report_chart($chartOptions); return $r; }
/** * 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; }