CVS edit link for jonathan_hunt

I've been working with Drupal for four years now and wish to contribute back to the community, starting with a module that introduces metadata search via the DigitalNZ API (see http://digitalnz.org/developer ).

DigitalNZ is a great cultural and educational resource. This module introduces a basic search function, including sorting. Future plans would be to add more data into the search result template, add faceted search and additional API functions. Making this module available may help Drupal in the education and cultural heritage markets in NZ.

Code can be downloaded from
http://huntdesign.co.nz/digitalnz-api-module

I have not located evidence of any other Drupal development for the DigitalNZ API. If approved, I'll seek listing with other code at http://digitalnz.org/developer/code-samples/

Thanks for your consideration.

Comments

jonathan_hunt’s picture

Status: Postponed (maintainer needs more info) » Needs review
StatusFileSize
new9.72 KB

BTW, to properly test this code, you need a Developer API key
http://digitalnz.org/developer/getting-started/

avpaderno’s picture

Issue tags: +Module review
avpaderno’s picture

Status: Needs review » Needs work
  1. See the Drupal coding standards to understand how a module code should be written; there is a part of the coding standards that reports which functions a module should call.
  2.   static $_digitalnz_searched = FALSE;
    

    Static variables doesn't need to be prefixed with the module name; that is how global variables used by a module should be named.

jonathan_hunt’s picture

Status: Needs work » Needs review
StatusFileSize
new9.54 KB

I've added a revised module archive.

Re 1, I'm not sure what you are referring to. Can you please relate your comment to specific lines of my module?

FYI, I discovered hook_search_page() #171317: hook_search_page not appearing on api.drupal.org, so I've used that instead of a phptemplate_search_results() call in the module.

Re 2, I've renamed the static variables per your advice.

avpaderno’s picture

  1.     '#title' => t('DigitalNZ API URL'),
        '#description' => t('URL of DigitalNZ API including version but not response format, e.g. '. l(DIGITALNZ_API_URL, DIGITALNZ_API_URL)),
    

    Together t() you should use url(), as reported in the documentation for t().

  2. The coding standards report also which functions should be called from a module; the report is for a specific group of functions, but it is also generally valid.
  3.       if (isset($sort) && preg_match('/^([a-z0-9_]+ (asc|desc)(,)?)+$/i', $sort)) {
            $sort = $sort;
          }
    

    The code assigns to $sort the value it already has; which value would the variable have if preg_match() returns 0? I guess it would have the same value, and that mean the IF-statement doesn't do anything.

avpaderno’s picture

Status: Needs review » Needs work

I forgot to change status.

jonathan_hunt’s picture

Status: Needs work » Needs review
StatusFileSize
new11.72 KB

1. Adjusted per your comment.
2. I don't know what you are referring to. What functions do think I should be calling? Coder reports 'No Problems Found' (except for the date processing, but that is a special case).
3. I've removed the sort validation.

avpaderno’s picture

See digitalnz_api.module. Between a Drupal function and a PHP function with the same purpose, which function would you use?

coder.module doesn't report anything about that because it doesn't have the code to check that; the only way to know if the code is compliant with that point of the coding standards is to read the coding standards.

avpaderno’s picture

Status: Needs review » Needs work

I keep to forget to change the status.

jonathan_hunt’s picture

Status: Needs work » Needs review

It would help me a great deal if you could refer to a specific function or a line within the module. Are you referring to digitalnz_api_convert_date()? I need that function because I am not on PHP 5.3, and I expect most people using this module are not on PHP5.3 either.

I've read the coding standards, several times.

avpaderno’s picture

Status: Needs review » Needs work

See the part of the coding standards that refers to the Unicode string functions.

jonathan_hunt’s picture

Status: Needs work » Needs review
StatusFileSize
new26.85 KB

I don't see why the unicode string functions are relevant when the string they are working on is a date string that won't include unicode characters.

I've uploaded a new version with the following changes:
- Added README.txt
- If no API key, don't attempt search and display error.
- Move defines to higher-level module.
- Show link to settings per Embedded documentation style guideline http://drupal.org/node/24566.
- Make URL and API key required on settings form.

avpaderno’s picture

  1.   if (empty($key)) {
        drupal_set_message(t('DigitalNZ API needs an API key. Settings are available at <strong class="drupal_link_admin_settings">!link</strong>.', array(
          '!link' => l(DIGITALNZ_SETTINGS_MENU_PATH, DIGITALNZ_SETTINGS_PATH),
        )), 'error');
        return;
      }
    

    See my previous point #5.1.

  2.       if ($delta != 'sort') {
          //  return apachesolr_facetcount_form($delta);
          }
    

    What is that code supposed to do?

  3.       // Load results.
          /*    <result>
          <category>Images</category>
          <metadata-url>http://api.digitalnz.org/records/v1/1189771</metadata-url>
          <title>Mountain scene</title>
          <date></date>
          <source-url>http://api.digitalnz.org/records/v1/1189771/source</source-url>
          <content-provider>University of Canterbury Library</content-provider>
          <id>1189771</id>
          <description></description>
          <syndication-date>2009-08-12T02:10:49.344Z</syndication-date>
          <display-url>http://132.181.2.68/Data/Collection9/photographs/phg_4933.jpg</display-url>
          <thumbnail-url>http://132.181.2.68/Data/Collection9/photographs/thumbnail/phg_4933.jpg</thumbnail-url>
        </result>*/
    
avpaderno’s picture

Status: Needs review » Needs work
jonathan_hunt’s picture

Status: Needs work » Needs review
StatusFileSize
new26.24 KB

#13.1 Oops, old habits. Fixed.

#13.2 There are various apachesolr placeholders around the code because I hope to introduce support for faceted search at a later date, in line with the apachesolr approach.

#13.3 Removed.

avpaderno’s picture

Status: Needs review » Fixed

I should have approved the CVS application before; I am sorry for the delay.

jonathan_hunt’s picture

Thanks for your review.

dman’s picture

Looking forward to playing with the code. Looks like it may tie in with some stuff I'm doing. Watching the repository :-)

Status: Fixed » Closed (fixed)
Issue tags: -Module review

Automatically closed -- issue fixed for 2 weeks with no activity.

avpaderno’s picture

Component: Miscellaneous » new project application
Assigned: Unassigned » avpaderno
Issue summary: View changes
Status: Closed (fixed) » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.