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() |
---|
string
Name 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() |
---|
string
Name of the control template, from the global $indicia_templates variable.
array
Options 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() |
---|
array
Associative array to convert.
boolean
Default false. Set to true to URL encode the values being added to the string.
string
The 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.
array
Options array with the following possibilities:
<
ul>
boolean
On 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() |
---|
string
Fieldname of the control to retrieve errors for.
boolean
Set 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() |
---|
\$resources
List 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.
string
Text 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() |
string
JavaScript 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() |
---|
string
A multi-line string to be split.
array
An 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() |
---|
string
A multi-line string to be split.
array
An 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).
array
Options array with the following possibilities:
getRootFolder()
inherited_from | \helper_base::getRootFolder() |
---|
get_auth(string $website_id, string $password)
inherited_from | \helper_base::get_auth() |
---|
string
Indicia ID for the website.
string
Indicia password for the website.
get_read_auth(string $website_id, string $password)
inherited_from | \helper_base::get_read_auth() |
---|
string
Indicia ID for the website.
string
Indicia password for the website.
get_read_write_auth(string $website_id, string $password) : \Returns
inherited_from | \helper_base::get_read_write_auth() |
---|
string
Indicia ID for the website.
string
Indicia password for the website.
\Returns
an 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() |
---|
array
Associative 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.
array
Options array with the following possibilities:
string
Any additional parameters to append to the request URL, for example orderby, limit or offset.
object
If 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() |
---|
string
JavaScript to run when the page is ready, i.e. in $(document).ready.
string
JavaScript to run at the end of $(document).ready.
string
JavaScript to run in the window.onLoad handler which comes later in the page load process.
bool
If 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() |
---|
array
Read authorisation array.
mixed
Either the id or external_key of the termlist to load.
array
List of the terms that are required, or null for all terms.
array
Output 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() |
---|
string
The URL the POST request is sent to.
string
Arguments to include in the POST data.
boolean
Set to false to prevent echoing of errors. Defaults to true.
array
An 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() |
---|
array
Array holding the parameters to merge into the template.
string
Name of the template to use, or actual template text if $useTemplateAsIs is set to true.
boolean
If 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.
boolean
If true then HTML is emitted as is from the parameter values inserted into the template, otherwise they are escaped.
boolean
If 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.
string
HTML 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. |
---|
array
Options array with the following possibilities:
report_calendar_summary(array $options)
There is no download option.
todo | : Future Enhancements? Allow restriction to month. |
---|
array
Options 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 |
array
Options 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.
array
Options 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. |
array
Options 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.
array
Options array with the following possibilities:
report_picker(array $options)
The title and description of the currently selected report are displayed alongside.
array
Options 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() |
---|
string
Cache file to be removed, includes path - will be false if no caching to take place
array
http_post return value
array
Options array : contents used to tag what this data is.
_getCacheFileName(string $path, array $options, \number $timeout) : string
inherited_from | \helper_base::_getCacheFileName() |
---|
string
directory path for file
array
Options array : contents are used along with md5 to generate the filename.
\number
string
filename, else FALSE if data is not to be cached._getCacheTimeOut(array $options) : \Timeout
inherited_from | \helper_base::_getCacheTimeOut() |
---|
array
Options array with the following possibilities:
\Timeout
in 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() |
---|
string
Cache file to be used, includes path
\number
array
Options array : contents used to confirm what this data is.
array
equivalent of call to http_post, else FALSE if data is not to be cached._timeOutCacheFile(string $file, \number $timeout)
inherited_from | \helper_base::_timeOutCacheFile() |
---|
string
Cache file to be removed, includes path
\number
apply_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() |
---|
string
The templatable string.
string
The 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() |
---|
string
The static template type. e.g. prefix or suffix.
array
Array of options which may contain a template name.
string
Template 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.
string
The validation rules formatted as a class.get_help_text(array $options, string $pos) : string
inherited_from | \helper_base::get_help_text() |
---|
array
Control's options array. Can specify the class for the help text item using option helpTextClass.
string
Either before or after. Defines the position that is being requested.
string
Templated help text, or nothing.internal_dump_resources(array $resources)
access | private |
---|---|
inherited_from | \helper_base::internal_dump_resources() |
array
List of resources to include.
jq_esc(string $name) : string
inherited_from | \helper_base::jq_esc() |
---|
string
The string to be escaped.
string
escaped name.send_file_to_warehouse(string $path, boolean $persist_auth, array $readAuth, string $service) : string
inherited_from | \helper_base::send_file_to_warehouse() |
---|
string
Path to the file to upload, relative to the interim image path folder (normally the client_helpers/upload folder.
boolean
Allows the write nonce to be preserved after sending the file, useful when several files are being uploaded.
array
readAuth Read authorisation tokens, if not supplied then the $_POST array should contain them.
string
Path to the service URL used. Default is data/handle_media, but could be import/upload_csv.
string
Error message, or true if successful.addFeaturesLoadingJs(string $addFeaturesJs, string $defsettings, string $selsettings, string $styleFns, boolean $zoomToExtent)
string
JavaScript which creates the list of features.
string
Default style settings.
string
Selected item style settings.
string
JavaScript snippet which places any style functions required into the context parameter when creating a Style.
boolean
If 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
array
Report options array.
array
Current parameters for the page and sort order.
array
Response from the call to reporting services, which we are paginating.
string
The basic URL used to construct page reload links in the pager.
string
The HTML for the advanced paginator.apply_error_template(string $error, string $fieldname)
inherited_from | \helper_base::apply_error_template() |
---|
string
The error message.
string
The 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.
Array
Chart control's options array
get_direct_mode_params_form(array $options)
array
Options 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() |
---|
string
The unique identifier of this control.
array
Configuration options for the parameter as defined in the report, including the description, display (label), default and datatype.
array
Control options array
array
Any tools to be embedded in the map toolbar are returned in this parameter rather than as the return result of the function.
string
The 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() |
---|
array
The options array, containing a presetParams entry that the parameter should be found in.
string
The 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.
\$options
Control options array
array
Contains 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)
array
List of the action definitions to convert to HTML.
array
The content of the row loaded from the database.
string
Set 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
Array
Associative array of parameters.get_report_grid_parameters_form($response, $options, $params) : string
If the autoParamsForm is false then an empty string is returned.
string
HTML for the form.get_report_grid_sort_page_url_params(\$options $options) : array
\$options
Control options array
array
Contains 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 |
---|
string
The fieldname for the report_picker control (=HTML form value)
string
Name of the report to be initially selected
array
Array of the reports and folders within the level to be output.
\HTML
for 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.
string
Snippet of URL containing the required URL parameters.output_pager(array $options, string $pageUrl, array $sortAndPageUrlParams, array $response) : string
array
Report options array.
string
The URL of the page to reload when paginating (normally the current page). Only used when JavaScript is disabled.
array
Current parameters for the page and sort order.
array
Response from the call to reporting services, which we are paginating.
string
The HTML for the paginator.params_form_if_required(array $response, array $options, string $currentParamValues)
array
Response from the call to the report services, which may contain a parameter request.
array
Array of report options.
string
Array 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.
array
List pagination parameters which should be excluded.
string
report_calendar_summary_initLocation(array $records, integer $locationID)
array
Records to scan through.
integer
ID 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_type
report_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.
array
List of the sorting and pagination parameters which should be excluded.
\unknown_type
request_report(array $response, array $options, array $currentParamValues, boolean $wantCount, string $extras)
array
Data to be returned.
array
Options array defining the report request.
array
Array of current parameter values, e.g. the contents of parameters form.
boolean
Set to true if a count of total results (ignoring limit) is required in the response.
string
Set 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
array
Report options array.
array
Current parameters for the page and sort order.
array
Response from the call to reporting services, which we are paginating.
string
The basic URL used to construct page reload links in the pager.
string
The 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 |
---|