Static helper class that provides methods for dealing with reports.
Provides several generally useful methods and also includes resource management.
| package | Client |
|---|
add_resource(string $resource)
This is normally called internally by the control methods to ensure the required files are linked into the page so does not need to be called directly. However it can be useful when writing custom code that uses one of these standard libraries such as jQuery. Ensures each file is only linked once.
| inherited_from | \helper_base::add_resource() |
|---|
stringName of resource to link. The following options are available:
apply_template(string $template, array $options)
Outputs the prefix template, a label (if in the options), a control, the control's errors and a suffix template.
| inherited_from | \helper_base::apply_template() |
|---|
stringName of the control template, from the global $indicia_templates variable.
arrayOptions array containing the control replacement values for the templates. Options can contain a setting for prefixTemplate or suffixTemplate to override the standard templates.
array_to_query_string(array $array, boolean $encodeValues) : string
This is like http_build_query but it does not url encode the & separator, and gives control over urlencoding the array values.
| inherited_from | \helper_base::array_to_query_string() |
|---|
arrayAssociative array to convert.
booleanDefault false. Set to true to URL encode the values being added to the string.
stringThe query string.build_params_form(array $options, boolean $hasVisibleContent)
Returns the HTML required for a parameters form, e.g. the form defined for input of report parameters or the default values for a csv import.
arrayOptions array with the following possibilities:
<
ul>
booleanOn completion, this is set to true if there are visible controls in the params form. If not, then it may be appropriate to skip the displaying of this params form since it is not necessary.
check_errors(string $fieldname, boolean $plaintext)
| inherited_from | \helper_base::check_errors() |
|---|
stringFieldname of the control to retrieve errors for.
booleanSet to true to return just the error text, otherwise it is wrapped in a span.
client_helper_path()
| inherited_from | \helper_base::client_helper_path() |
|---|
dump_header(\$resources $resources) : string
The advantage of dump_javascript is that it intelligently builds the required links depending on what is on your form. dump_header is not intelligent because the form is not built yet, but placing links in the header leads to cleaner code which validates better.
| inherited_from | \helper_base::dump_header() |
|---|
\$resourcesList of resources to include in the header. The available options are described in the documentation for the add_resource method. The default for this is jquery_ui and defaultStylesheet.
stringText to place in the head section of the html file.dump_javascript() : string
Should be called at the end of each HTML page which uses the data entry helper so output all JavaScript required by previous calls.
| link | http://code.google.com/p/indicia/wiki/TutorialBuildingBasicPage#Build_a_data_entry_page |
|---|---|
| inherited_from | \helper_base::dump_javascript() |
stringJavaScript to insert into the page for all the controls added to the page so far.enable_validation(string $form_id)
To specify validation on each control, set the control's options array to contain a 'validation' entry. This must be set to an array of validation rules in Indicia validation format. For example, 'validation' => array('required', 'email').
| inherited_from | \helper_base::enable_validation() |
|---|
string@form_id Id of the form the validation is being attached to.
explode_lines(string $value) : array
Tolerates any line ending.
| inherited_from | \helper_base::explode_lines() |
|---|
stringA multi-line string to be split.
arrayAn array with one entry per line in $value.explode_lines_key_value_pairs(string $value) : array
Tolerates any line ending.
| inherited_from | \helper_base::explode_lines_key_value_pairs() |
|---|
stringA multi-line string to be split.
arrayAn associative array with one entry per line in $value. Array keys are the items before the = on each line,
and values are the data after the = on each line.freeform_report(array $options)
Has a header and footer plus any number of bands which are output once per row, or once each time a particular field value changes (i.e. acting as a header band).
arrayOptions array with the following possibilities:
getRootFolder()
| inherited_from | \helper_base::getRootFolder() |
|---|
get_auth(string $website_id, string $password)
| inherited_from | \helper_base::get_auth() |
|---|
stringIndicia ID for the website.
stringIndicia password for the website.
get_read_auth(string $website_id, string $password)
| inherited_from | \helper_base::get_read_auth() |
|---|
stringIndicia ID for the website.
stringIndicia password for the website.
get_read_write_auth(string $website_id, string $password) : \Returns
| inherited_from | \helper_base::get_read_write_auth() |
|---|
stringIndicia ID for the website.
stringIndicia password for the website.
\Returnsan array containing:
'read' => the read authorisation array,
'write' => the write authorisation input controls to insert into your form.
'write_tokens' => the write authorisation array, if needed as separate tokens rather than just placing in form.get_reload_link_parts() : array
| inherited_from | \helper_base::get_reload_link_parts() |
|---|
arrayAssociative array containing path and params (itself a key/value paired associative array).get_report_data(array $options, string $extra) : object
Respects the filters and columns $_GET variables generated by a grid's filter form when JavaScript is disabled.
arrayOptions array with the following possibilities:
stringAny additional parameters to append to the request URL, for example orderby, limit or offset.
objectIf linkOnly is set in the options, returns the link string, otherwise returns the response as an array.get_resources()
| inherited_from | \helper_base::get_resources() |
|---|
get_scripts(string $javascript, string $late_javascript, string $onload_javascript, bool $includeWrapper)
Can optionally include the script tags wrapper around the script generated.
| inherited_from | \helper_base::get_scripts() |
|---|
stringJavaScript to run when the page is ready, i.e. in $(document).ready.
stringJavaScript to run at the end of $(document).ready.
stringJavaScript to run in the window.onLoad handler which comes later in the page load process.
boolIf true then includes script tags around the script.
get_termlist_terms(array $auth, mixed $termlist, array $filter) : array
| inherited_from | \helper_base::get_termlist_terms() |
|---|
arrayRead authorisation array.
mixedEither the id or external_key of the termlist to load.
arrayList of the terms that are required, or null for all terms.
arrayOutput of the Warehouse data services request for the terms.get_uploaded_image_folder()
| inherited_from | \helper_base::get_uploaded_image_folder() |
|---|
http_post(string $url, string $postargs, boolean $output_errors) : array
| inherited_from | \helper_base::http_post() |
|---|
stringThe URL the POST request is sent to.
stringArguments to include in the POST data.
booleanSet to false to prevent echoing of errors. Defaults to true.
arrayAn array with a result element set to true or false for successful or failed posts respectively.
The output is returned in an output element in the array. If there is an error, then an errorno element gives the
cUrl error number (as generated by the cUrl library used for the post).link_default_stylesheet()
This gives a basic form layout. This also adds default JavaScript to the page to cause buttons to highlight when you hover the mouse over them.
| inherited_from | \helper_base::link_default_stylesheet() |
|---|
mergeParamsIntoTemplate(array $params, string $template, boolean $useTemplateAsIs, boolean $allowHtml, boolean $allowEscapeQuotes) : string
This is used to build the output for each item in a list, such as a species checklist grid or a radio group.
| inherited_from | \helper_base::mergeParamsIntoTemplate() |
|---|
arrayArray holding the parameters to merge into the template.
stringName of the template to use, or actual template text if $useTemplateAsIs is set to true.
booleanIf true then the template parameter contains the actual template text, otherwise it is the name of a template in the $indicia_templates array. Default false.
booleanIf true then HTML is emitted as is from the parameter values inserted into the template, otherwise they are escaped.
booleanIf true then parameter names can be suffixes -esape-quote, -escape-dblquote, -escape-htmlquote or -escape-htmldblquote to insert backslashes or html entities into the replacements for string escaping.
stringHTML for the item labelrelative_client_helper_path()
| inherited_from | \helper_base::relative_client_helper_path() |
|---|
report_calendar_grid(array $options)
If you need 2 grids on one page, then you must define a different id in the options for each grid.
The grid operation has NOT been AJAXified.
| todo | Future Enhancements? Allow restriction to month. |
|---|
arrayOptions array with the following possibilities:
report_calendar_summary(array $options)
There is no download option.
| todo | : Future Enhancements? Allow restriction to month. |
|---|
arrayOptions array with the following possibilities:
report_chart(array $options)
Each of these can be an array to define a multi-series chart. The largest array from these 4 options defines the total series count. If an option is not an array, or the array is smaller than the total series count, then the last option is used to fill in the missing values. For example, by setting:<br/> 'dataSource' => array('report_1', 'report_2'),<br/> 'yValues' => 'count',<br/> 'xLabels' => 'month'<br/> then you get a chart of count by month, with 2 series' loaded separately from report 1 and report 2. Alternatively you can use a single report, with 2 different columns for count to define the 2 series:<br/> 'dataSource' => 'combined_report',<br/> 'yValues' => array('count_1','count_2'),<br/> 'xLabels' => 'month'<br/> The latter is obviuosly slightly more efficient as only a single report is run. Pie charts will always revert to a single series.
For summary reports, the user can optionally setup clicking functionality so that another report is called when the user clicks on the chart.
| todo | look at the ReportEngine to check it is not prone to SQL injection (eg. offset, limit). |
|---|---|
| link | http://www.jqplot.com/docs/files/jqplot-core-js.html#Series |
| link | http://www.jqplot.com/docs/files/jqplot-core-js.html#Axis |
| link | http://www.jqplot.com/docs/files/plugins/jqplot-barRenderer-js.html |
| link | http://www.jqplot.com/docs/files/plugins/jqplot-lineRenderer-js.html |
| link | http://www.jqplot.com/docs/files/plugins/jqplot-pieRenderer-js.html |
| link | http://www.jqplot.com/docs/files/jqplot-core-js.html#Legend |
arrayOptions array with the following possibilities:
report_download_link(array $options)
The options arguments supported are the same as for the report_grid method. Pagination information will be ignored (e.g. itemsPerPage). If this download link is to be displayed alongside a report_grid to provide a download of the same data, set the id option to the same value for both the report_download_link and report_grid controls to link them together. Use the itemsPerPage parameter to control how many records are downloaded.
arrayOptions array with the following possibilities:
report_grid(array $options)
If used as a PHP grid, note that the current web page will reload when you page or sort the grid, with the same $_GET parameters but no $_POST information. If you need 2 grids on one page, then you must define a different id in the options for each grid.
For summary reports, the user can optionally setup clicking functionality so that another report is called when the user clicks on the grid.
The grid operation will be handled by AJAX calls when possible to avoid reloading the web page.
| todo | Allow additional params to filter by table column or report parameters |
|---|---|
| todo | Display a filter form for direct mode |
| todo | For report mode, provide an AJAX/PHP button that can load the report from parameters in a form on the page. |
arrayOptions array with the following possibilities:
report_map(array $options)
Because there are many options for the map, this method does not generate the map itself, rather it sends the output of the report onto a map_panel output elsewhere on the page. Like the report_grid, this can output a parameters form or can be set to use the parameters form from another output report (e.g. another call to report_grid, allowing both a grid and map of the same data to be generated). The report definition must contain a single column which is configured as a mappable column or the report must specify a parameterised CQL query to draw the map using WMS.
arrayOptions array with the following possibilities:
report_picker(array $options)
The title and description of the currently selected report are displayed alongside.
arrayOptions array which accepts the following standard options: id, fieldname, class, default, readAuth.
setup_jquery_validation_js()
This JavaScript must be added at the end of form preparation otherwise we would not know all the control messages. It will normally be called by dump_javascript automatically, but is exposed here as a public method since the iform Drupal module does not call dump_javascript, but is responsible for adding JavaScript to the page via drupal_add_js.
| inherited_from | \helper_base::setup_jquery_validation_js() |
|---|
_cacheResponse(string $file, array $response, array $options)
| inherited_from | \helper_base::_cacheResponse() |
|---|
stringCache file to be removed, includes path - will be false if no caching to take place
arrayhttp_post return value
arrayOptions array : contents used to tag what this data is.
_getCacheFileName(string $path, array $options, \number $timeout) : string
| inherited_from | \helper_base::_getCacheFileName() |
|---|
stringdirectory path for file
arrayOptions array : contents are used along with md5 to generate the filename.
\numberstringfilename, else FALSE if data is not to be cached._getCacheTimeOut(array $options) : \Timeout
| inherited_from | \helper_base::_getCacheTimeOut() |
|---|
arrayOptions array with the following possibilities:
\Timeoutin number of seconds, else FALSE if data is not to be cached._getCachedResponse(string $file, \number $timeout, array $options) : array
| inherited_from | \helper_base::_getCachedResponse() |
|---|
stringCache file to be used, includes path
\numberarrayOptions array : contents used to confirm what this data is.
arrayequivalent of call to http_post, else FALSE if data is not to be cached._timeOutCacheFile(string $file, \number $timeout)
| inherited_from | \helper_base::_timeOutCacheFile() |
|---|
stringCache file to be removed, includes path
\numberapply_replacements_to_template(string $template, string $options)
<
div id="{id}">) and replaces the tokens with the equivalent values looked up from the $options array.
| inherited_from | \helper_base::apply_replacements_to_template() |
|---|
stringThe templatable string.
stringThe array of items which can be merged into the template.
apply_static_template(string $name, array $options) : string
| inherited_from | \helper_base::apply_static_template() |
|---|
stringThe static template type. e.g. prefix or suffix.
arrayArray of options which may contain a template name.
stringTemplate value.build_validation_class(\$options. $options) : string
| inherited_from | \helper_base::build_validation_class() |
|---|
\$options.Control options array. For validation to be applied should contain a validation entry, containing a single validation string or an array of strings.
stringThe validation rules formatted as a class.get_help_text(array $options, string $pos) : string
| inherited_from | \helper_base::get_help_text() |
|---|
arrayControl's options array. Can specify the class for the help text item using option helpTextClass.
stringEither before or after. Defines the position that is being requested.
stringTemplated help text, or nothing.internal_dump_resources(array $resources)
| access | private |
|---|---|
| inherited_from | \helper_base::internal_dump_resources() |
arrayList of resources to include.
jq_esc(string $name) : string
| inherited_from | \helper_base::jq_esc() |
|---|
stringThe string to be escaped.
stringescaped name.send_file_to_warehouse(string $path, boolean $persist_auth, array $readAuth, string $service) : string
| inherited_from | \helper_base::send_file_to_warehouse() |
|---|
stringPath to the file to upload, relative to the interim image path folder (normally the client_helpers/upload folder.
booleanAllows the write nonce to be preserved after sending the file, useful when several files are being uploaded.
arrayreadAuth Read authorisation tokens, if not supplied then the $_POST array should contain them.
stringPath to the service URL used. Default is data/handle_media, but could be import/upload_csv.
stringError message, or true if successful.addFeaturesLoadingJs(string $addFeaturesJs, string $defsettings, string $selsettings, string $styleFns, boolean $zoomToExtent)
stringJavaScript which creates the list of features.
stringDefault style settings.
stringSelected item style settings.
stringJavaScript snippet which places any style functions required into the context parameter when creating a Style.
booleanIf true, then the map will zoom to show the extent of the features added.
advanced_pager(array $options, array $sortAndPageUrlParams, array $response, string $pagLinkUrl) : string
arrayReport options array.
arrayCurrent parameters for the page and sort order.
arrayResponse from the call to reporting services, which we are paginating.
stringThe basic URL used to construct page reload links in the pager.
stringThe HTML for the advanced paginator.apply_error_template(string $error, string $fieldname)
| inherited_from | \helper_base::apply_error_template() |
|---|
stringThe error message.
stringThe name of the field which the error is being attached to.
check_for_jqplot_plugins(Array $options)
Currently only scans for the trendline and category_axis_rendered plugins.
ArrayChart control's options array
get_direct_mode_params_form(array $options)
arrayOptions passed to the report control, which should contain the column definitions.
get_params_form_control(string $key, array $info, array $options, array $tools) : string
| inherited_from | \helper_base::get_params_form_control() |
|---|
stringThe unique identifier of this control.
arrayConfiguration options for the parameter as defined in the report, including the description, display (label), default and datatype.
arrayControl options array
arrayAny tools to be embedded in the map toolbar are returned in this parameter rather than as the return result of the function.
stringThe HTML for the form parameter.get_preset_param(array $options, string $name)
Returns empty string if not defined.
| inherited_from | \helper_base::get_preset_param() |
|---|
arrayThe options array, containing a presetParams entry that the parameter should be found in.
stringThe key identifying the preset parameter to look for.
get_report_calendar_grid_page_url_params(\$options $options) : array
Note there is no need to sort for the calender grid.
\$optionsControl options array
arrayContains the page params, as an assoc array. Each array value is an array containing name & value.get_report_grid_actions(array $actions, array $row, string $pathParam)
arrayList of the action definitions to convert to HTML.
arrayThe content of the row loaded from the database.
stringSet to the name of a URL param used to pass the path to this page. E.g. in Drupal with clean urls disabled, this is set to q. Otherwise leave empty.
get_report_grid_current_param_values($options) : Array
ArrayAssociative array of parameters.get_report_grid_parameters_form($response, $options, $params) : string
If the autoParamsForm is false then an empty string is returned.
stringHTML for the form.get_report_grid_sort_page_url_params(\$options $options) : array
\$optionsControl options array
arrayContains the orderby, sortdir and page params, as an assoc array. Each array value
is an array containing name & value.get_report_list_level(string $fieldname, string $default, array $list) : \HTML
| access | private |
|---|
stringThe fieldname for the report_picker control (=HTML form value)
stringName of the report to be initially selected
arrayArray of the reports and folders within the level to be output.
\HTMLfor the unordered list containing the level.get_report_sorting_paging_params(array $options, array $sortAndPageUrlParams) : string
array@options Options array sent to the report.
array@sortAndPageUrlParams Paging and sorting info returned from a call to get_report_grid_sort_page_url_params.
stringSnippet of URL containing the required URL parameters.output_pager(array $options, string $pageUrl, array $sortAndPageUrlParams, array $response) : string
arrayReport options array.
stringThe URL of the page to reload when paginating (normally the current page). Only used when JavaScript is disabled.
arrayCurrent parameters for the page and sort order.
arrayResponse from the call to reporting services, which we are paginating.
stringThe HTML for the paginator.params_form_if_required(array $response, array $options, string $currentParamValues)
arrayResponse from the call to the report services, which may contain a parameter request.
arrayArray of report options.
stringArray of current parameter values, e.g. the contents of a submitted parameters form.
report_calendar_grid_get_reload_url(array $pageUrlParams) : string
This effectively re-builds the current page's URL, but drops the query string parameters that indicate the year and site. Note there is no need to sort for the calender grid.
arrayList pagination parameters which should be excluded.
stringreport_calendar_summary_initLocation(array $records, integer $locationID)
arrayRecords to scan through.
integerID of the location to check for.
report_calendar_summary_processEstimates(array $summaryArray, array $locationArray, integer $numSamples, integer $minWeekNo, integer $maxWeekNo, string $taxon, array $options)
| todo | : document this method |
|---|
array
array
integer
integer
integer
string
array
report_grid_get_columns($response, $options) : \unknown_type
\unknown_typereport_grid_get_reload_url(array $sortAndPageUrlParams) : \unknown_type
This effectively re-builds the current page's URL, but drops the query string parameters that indicate the sort order and page number.
arrayList of the sorting and pagination parameters which should be excluded.
\unknown_typerequest_report(array $response, array $options, array $currentParamValues, boolean $wantCount, string $extras)
arrayData to be returned.
arrayOptions array defining the report request.
arrayArray of current parameter values, e.g. the contents of parameters form.
booleanSet to true if a count of total results (ignoring limit) is required in the response.
stringSet any additional URL filters if required, e.g. taxon_list_id=1 to filter for taxon list 1.
simple_pager(array $options, array $sortAndPageUrlParams, array $response, string $pagLinkUrl) : string
arrayReport options array.
arrayCurrent parameters for the page and sort order.
arrayResponse from the call to reporting services, which we are paginating.
stringThe basic URL used to construct page reload links in the pager.
stringThe HTML for the simple paginator.$cache_allowed_file_count : integer
| inherited_from | \helper_base::$$cache_allowed_file_count |
|---|
$cache_chance_purge : integer
| inherited_from | \helper_base::$$cache_chance_purge |
|---|
$cache_chance_refresh_file : integer
| inherited_from | \helper_base::$$cache_chance_refresh_file |
|---|
$cache_timeout : integer
| inherited_from | \helper_base::$$cache_timeout |
|---|
$css_path : string
| inherited_from | \helper_base::$$css_path |
|---|
$default_validation_rules : Array
| inherited_from | \helper_base::$$default_validation_rules |
|---|
$dumped_resources : array
| inherited_from | \helper_base::$$dumped_resources |
|---|
$form_mode : string
| inherited_from | \helper_base::$$form_mode |
|---|
$helpTextPos : string
| inherited_from | \helper_base::$$helpTextPos |
|---|
$images_path : string
| inherited_from | \helper_base::$$images_path |
|---|
$is_ajax : boolean
| inherited_from | \helper_base::$$is_ajax |
|---|
$javascript : string
| inherited_from | \helper_base::$$javascript |
|---|
$js_path : string
| inherited_from | \helper_base::$$js_path |
|---|
$late_javascript : string
| inherited_from | \helper_base::$$late_javascript |
|---|
$nocache : boolean
| inherited_from | \helper_base::$$nocache |
|---|
$onload_javascript : string
| inherited_from | \helper_base::$$onload_javascript |
|---|
$required_resources : Array
| inherited_from | \helper_base::$$required_resources |
|---|
$resource_list : Array
| inherited_from | \helper_base::$$resource_list |
|---|
$validated_form_id : array
| inherited_from | \helper_base::$$validated_form_id |
|---|
$validation_errors : array
| inherited_from | \helper_base::$$validation_errors |
|---|
$validation_mode : array
Options are message, message, hint, icon, colour, inline. The inline option specifies that the message should appear on the same line as the control. Otherwise it goes on the next line, indented by the label width. Because in many cases, controls on an Indicia form occupy the full available width, it is often more appropriate to place error messages on the next line so this is the default behaviour.
| inherited_from | \helper_base::$$validation_mode |
|---|
$warehouse_proxy : string
| inherited_from | \helper_base::$$warehouse_proxy |
|---|
$default_styles : Boolean
| inherited_from | \helper_base::$$default_styles |
|---|
$displayed_errors : array
| inherited_from | \helper_base::$$displayed_errors |
|---|
$html_attributes
When replacing items in a template, these get automatically wrapped. E.g. a template replacement for the class will be converted to class="value". The key is the parameter name, and the value is the html attribute it will be wrapped into.
| inherited_from | \helper_base::$$html_attributes |
|---|
$using_locking : Boolean
| inherited_from | \helper_base::$$using_locking |
|---|
$website_id : integer
| inherited_from | \helper_base::$$website_id |
|---|