Static helper class that provides methods for dealing with imports.
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.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_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).importer(array $options)
The csv file to be imported should be available in the $_POST data, unless the existing_file option is specified. Additionally, if there are any preset values which apply to each row in the import data then you can pass these to the importer in the $_POST data. For example, you could set taxa_taxon_list:taxon_list_id=3 in the $_POST data when importing species data to force it to go into list 3.
arrayOptions array with the following possibilities:
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() |
|---|
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.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.
auto_detection_rules(string $column, string $lowerCaseCaption, string $strippedScreenCaption, string $prefix, array $labelList, integer $itWasSaved, boolean $saveDetectedMode) : array
It has two modes: When $saveDetectedMode is false, the method uses several rules in an attempt to automatically determine a value for one of the csv column drop-downs on the import page. When $saveDetectedMode is true, the method uses the same rules to see if the system would have retrieved the same drop-down value as the one that was saved by the user. If this is the case, the system acts as if the value had been automatically determined rather than saved.
stringThe CSV column we are currently working with from the import file.
stringA version of an item in the column selection drop-down that is all lowercase.
stringA version of an item in the column selection drop-down that has 'lookup existing record'stripped
stringCaption prefix each item having a list of regexes to match against
arrayA list of captions and the number of times they occur.
integerThis is set to 1 if the system detects that the user has a custom saved preference for a csv column drop-down.
booleanDetermines the mode the method is running in
arrayDepending on the mode, we either are interested in the $selected value or the $itWasSaved value.clear_website_survey_fields(array $array, array $settings)
arrayArray of fields.
arrayGlobal settings which apply to every row, which may include the website_id and survey_id.
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_uploaded_file(array $options)
| access | private |
|---|
arrayOptions array passed to the import control.
import_settings_form(array $options)
If none available, then outputs the upload mappings form.
arrayOptions array passed to the import control.
items_to_draw_once_per_import_column(string $r, string $column, integer $itWasSaved, array $savedFieldMappings, integer $multiMatch) : string
These are the checkboxes, the warning the drop-down setting was saved and also the non-unique match warning
stringThe HTML to be returned.
stringColumn from the import CSV file we are currently working with
integerThis is 1 if a setting is saved for the column and the column would not have been automatically calculated as that value anyway.
arrayAn array containing the user' preferences for the import page.
integerArray of columns where there are multiple matches for the column and this cannot be resolved.
stringHTMl stringleadingCaps(string $text) : \The
stringThe text to alter.
\Thealtered string.make_clean_caption(\type $caption, \type $prefix, \type $fieldname, \type $model) : string
\typeThe drop-down item currently being worked on
\typeCaption prefix
\typeThe database field that the caption relates to.
\typeName of the model
string$caption A caption for the column drop-down on the import page.model_field_option(string $field, string $caption, boolean $selected, string $optionID)
Option is selected if selected=caption (case insensitive).
stringName of the field being output.
stringCaption of the field being output.
booleanSet to true if outputing the currently selected option.
stringId of the current option.
run_upload(array $options)
Adds JavaScript to the page which performs the chunked upload.
arrayArray of options passed to the import control.
translate_field(string $field, string $caption) : string
If not found returns the original caption.
stringName of the field being output.
stringUntranslated caption of the field being output.
stringTranslated caption.upload_form()
upload_mappings_form(array $options)
arrayOptions array passed to the import control.
upload_result(array $options)
arrayArray of options passed to the import control.
$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 |
|---|
$rememberingMappings : boolean