1

Topic: client_helpers as WordPress plugin

Hello,

We are looking through the client_helpers documentation with a view to building a WordPress plugin for a client. There are several approaches we can take, to choose the right direction it would be really useful to understand the following:

Is there documentation on the field types available from Indicia? Documentation at http://indicia-docs.readthedocs.io/en/l … index.html does not seem to show any detail on the field types available and their associated arguments.

e.g.

data_entry_helper::autocomplete, data_entry_helper::sref_and_system, data_entry_helper::text_input, data_entry_helper::map_panel...

Each of these functions returns a form field and accepts arguments e.g.

data_entry_helper::autocomplete(array(
    'label'=>'Species',
    'fieldname'=>'occurrence:taxa_taxon_list_id',
    'table'=>'taxa_taxon_list',
    'captionField'=>'taxon',
    'valueField'=>'id',
    'extraParams'=>$auth['read'] + array('taxon_list_id' => '34')
  ));

Some of these arguments are self explanatory when seen in an example like the one above, yet finding the right example and understanding what arguments are accepted for each field type by looking at the source code or interpreting examples could take some time, is there documentation that covers the accepted arguments for each field and their accepted structure/format?

Many thanks
Andy

2

Re: client_helpers as WordPress plugin

Hi Andy,

You need the Client Helpers API Documentation

E.g. Autocomplete. Click the item to expand and display options.

Jim Bacon.

3

Re: client_helpers as WordPress plugin

Hi Jim,

That's great, I knew there must be documentation somewhere but couldn't find it.

Thanks for your help!
Andy

4 (edited by awatson 24-05-2017 20:46:28)

Re: client_helpers as WordPress plugin

Hello Jim, during the course of our integration with WordPress we have the following code changes that have been made to two files helper_base.php and data_entry_helper.php. I would be interested to hear your thoughts on integrating these to the master files.  I haven't put this up as a merge request on the git, rather suggested these here first for discussion.

helper_base.php

Add to $indicia_templates:

'email_input' => '<input type="email" id="{id}" name="{fieldname}"{class} {disabled} {readonly} value="{default}" {title} {maxlength} />'."\n",
  'number_input' => '<input type="number" id="{id}" name="{fieldname}"{class} {disabled} {readonly} value="{default}" {title} {maxlength} />'."\n",

Edit: remove size="30":

'date_picker' => '<input type="text" placeholder="{placeholder}" size="30"{class} id="{id}" name="{fieldname}" value="{default}" {title}/>'."\n",

to:

'date_picker' => '<input type="text" placeholder="{placeholder}" {class} id="{id}" name="{fieldname}" value="{default}" {title}/>'."\n",

I've suggested this as I think size is better controlled via CSS.

Add to $indicia_templates:

'native_date_picker' => '<input type="date" placeholder="{placeholder}" {class} id="{id}" name="{fieldname}" value="{default}" {title}/>'."\n",

Google api key

public static $google_api_key = '';

I do not believe this should not be held in helper_base.php, it should be stored in helper_config, inclusion here causes problems for anyone including client_helpers if they are using google services elsewhere and requires the helper_base.php file to be edited in addition to the configuration file, interestingly there is a comment on this line to suggest it shouldn't be there but is due to it being new(?).

**********************

data_entry_helper.php

Add

  public static function email_input($options) {
    $options = array_merge(array(
      'default'=>''
    ), self::check_options($options));
    return self::apply_template('email_input', $options);
  }
  public static function number_input($options) {
    $options = array_merge(array(
      'default'=>''
    ), self::check_options($options));
    return self::apply_template('number_input', $options);
  }

Google maps inclusion - line 684

        'googlemaps' => array('javascript' => array("$protocol://maps.google.com/maps/api/js?v=3" .
            (empty(self::$google_maps_api_key) ? '' : '&key=' . self::$google_maps_api_key))),

I've had to comment this line out as it causes issues with our inclusion of google maps elsewhere. I think there should be an additional static variable to determine whether to include google maps or not. Something like the following should work and includes maps by default but allows for an override if a static variable is set in helper_config.php:

        'googlemaps' => (!empty($disable_indicia_gmaps_inclusion)?'':array('javascript' => array("$protocol://maps.google.com/maps/api/js?v=3" .
            (empty(self::$google_maps_api_key) ? '' : '&key=' . self::$google_maps_api_key)))),

Line 1200

*   google_places_api - uses the Google Places API text search service.

Should read

*   google_places - uses the Google Places API text search service.


When using the map function map($options) allows for no control over georeference_lookup, suggest a minimum of 'label' and 'driver':

    if ($options['locate']) {
      $r .= self::georeference_lookup(array(
        'label'=>(!empty($options['locateLabel'])?$options['locateLabel']:lang::get('search for place on map')),
        'driver'=>$options['locateDriver']
      ));
    }

5

Re: client_helpers as WordPress plugin

Hi Andy,

This looks pretty good to me from a fairly cursory glance.
If removing the size=30 from the datepicker then we should add something to the default CSS by way of compensation so we don't break existing layouts that depend on it.
John van Breda is the best authority on code changes and he would certainly look at a pull request.

Jim Bacon.

6

Re: client_helpers as WordPress plugin

Hi Jim,

OK thanks for this, we have the bones of a fully functioning wordpress plugin tested now and successfully submitting data to the test warehouse. We don't have all form fields available but we have most of them with all variables customisable and fields can be reordered by dragging and dropping.  Forms can be placed on any page and any post with a shortcode.

We're not ready for this to be used on sites outside of our immediate project, there are structural changes that would be required to get there but if there is interest in this then we'll certainly consider it.

Thanks
Andy

Post's attachments

Capture1.JPG 81.24 kb, file has never been downloaded. 

You don't have the permssions to download the attachments of this post.

7

Re: client_helpers as WordPress plugin

I like it :-)
Looks more user friendly than the Drupal module for creating recording forms.
Well done and thanks for sharing.

Jim Bacon.

8

Re: client_helpers as WordPress plugin

Thanks awatson - the plugin looks good. I've now added some comments to the associated pull request.
Best wishes
John

John van Breda
Biodiverse IT