Move Quantity field collection, fields, taxonomy, and strongarm from Farm Log module.

This commit is contained in:
Michael Stenta 2016-03-21 11:57:31 -04:00
parent f10dd12208
commit 1365bbb8e2
8 changed files with 323 additions and 0 deletions

34
README.md Normal file
View File

@ -0,0 +1,34 @@
FARM LOG
========
Provides a framework for dealing with quantities.
This module is part of the [farmOS](http://drupal.org/project/farm)
distribution.
DEPENDENCIES
------------
This module depends on the following modules:
* Ctools (http://drupal.org/project/ctools)
* Features (http://drupal.org/project/features)
* Field Collection (http://drupal.org/project/field_collection)
* Fraction (http://drupal.org/project/fraction)
* Strongarm (http://drupal.org/project/strongarm)
INSTALLATION
------------
Install as you would normally install a contributed drupal module. See:
http://drupal.org/documentation/install/modules-themes/modules-7 for further
information.
MAINTAINERS
-----------
Current maintainers:
* Michael Stenta (m.stenta) - https://drupal.org/user/581414
This project has been sponsored by:
* [Farmier](http://farmier.com)

View File

@ -0,0 +1,77 @@
<?php
/**
* @file
* farm_quantity.features.field_base.inc
*/
/**
* Implements hook_field_default_field_bases().
*/
function farm_quantity_field_default_field_bases() {
$field_bases = array();
// Exported field_base: 'field_farm_quantity'.
$field_bases['field_farm_quantity'] = array(
'active' => 1,
'cardinality' => 1,
'deleted' => 0,
'entity_types' => array(),
'field_name' => 'field_farm_quantity',
'indexes' => array(
'revision_id' => array(
0 => 'revision_id',
),
),
'locked' => 0,
'module' => 'field_collection',
'settings' => array(
'hide_blank_items' => 1,
'path' => '',
),
'translatable' => 0,
'type' => 'field_collection',
);
// Exported field_base: 'field_farm_quantity_units'.
$field_bases['field_farm_quantity_units'] = array(
'active' => 1,
'cardinality' => 1,
'deleted' => 0,
'entity_types' => array(),
'field_name' => 'field_farm_quantity_units',
'indexes' => array(
'tid' => array(
0 => 'tid',
),
),
'locked' => 0,
'module' => 'taxonomy',
'settings' => array(
'allowed_values' => array(
0 => array(
'vocabulary' => 'farm_quantity_units',
'parent' => 0,
),
),
),
'translatable' => 0,
'type' => 'taxonomy_term_reference',
);
// Exported field_base: 'field_farm_quantity_value'.
$field_bases['field_farm_quantity_value'] = array(
'active' => 1,
'cardinality' => 1,
'deleted' => 0,
'entity_types' => array(),
'field_name' => 'field_farm_quantity_value',
'indexes' => array(),
'locked' => 0,
'module' => 'fraction',
'settings' => array(),
'translatable' => 0,
'type' => 'fraction',
);
return $field_bases;
}

View File

@ -0,0 +1,92 @@
<?php
/**
* @file
* farm_quantity.features.field_instance.inc
*/
/**
* Implements hook_field_default_field_instances().
*/
function farm_quantity_field_default_field_instances() {
$field_instances = array();
// Exported field_instance:
// 'field_collection_item-field_farm_quantity-field_farm_quantity_units'.
$field_instances['field_collection_item-field_farm_quantity-field_farm_quantity_units'] = array(
'bundle' => 'field_farm_quantity',
'default_value' => NULL,
'deleted' => 0,
'description' => '',
'display' => array(
'default' => array(
'label' => 'hidden',
'module' => 'taxonomy',
'settings' => array(),
'type' => 'taxonomy_term_reference_plain',
'weight' => 1,
),
),
'entity_type' => 'field_collection_item',
'field_name' => 'field_farm_quantity_units',
'label' => 'Units',
'required' => 1,
'settings' => array(
'user_register_form' => FALSE,
),
'widget' => array(
'active' => 0,
'module' => 'taxonomy',
'settings' => array(
'autocomplete_path' => 'taxonomy/autocomplete',
'size' => 60,
),
'type' => 'taxonomy_autocomplete',
'weight' => 1,
),
);
// Exported field_instance:
// 'field_collection_item-field_farm_quantity-field_farm_quantity_value'.
$field_instances['field_collection_item-field_farm_quantity-field_farm_quantity_value'] = array(
'bundle' => 'field_farm_quantity',
'default_value' => NULL,
'deleted' => 0,
'description' => '',
'display' => array(
'default' => array(
'label' => 'hidden',
'module' => 'fraction',
'settings' => array(
'auto_precision' => 1,
'precision' => 0,
),
'type' => 'fraction_decimal',
'weight' => 0,
),
),
'entity_type' => 'field_collection_item',
'field_name' => 'field_farm_quantity_value',
'label' => 'Value',
'required' => 1,
'settings' => array(
'user_register_form' => FALSE,
),
'widget' => array(
'active' => 1,
'module' => 'fraction',
'settings' => array(
'auto_precision' => 1,
'precision' => 0,
),
'type' => 'fraction_decimal',
'weight' => 0,
),
);
// Translatables
// Included for use with string extractors like potx.
t('Units');
t('Value');
return $field_instances;
}

View File

@ -0,0 +1,14 @@
<?php
/**
* @file
* farm_quantity.features.inc
*/
/**
* Implements hook_ctools_plugin_api().
*/
function farm_quantity_ctools_plugin_api($module = NULL, $api = NULL) {
if ($module == "strongarm" && $api == "strongarm") {
return array("version" => "1");
}
}

View File

@ -0,0 +1,36 @@
<?php
/**
* @file
* farm_quantity.features.taxonomy.inc
*/
/**
* Implements hook_taxonomy_default_vocabularies().
*/
function farm_quantity_taxonomy_default_vocabularies() {
return array(
'farm_quantity_units' => array(
'name' => 'Farm Quantity Units',
'machine_name' => 'farm_quantity_units',
'description' => 'A vocabulary of units for describing quantities.',
'hierarchy' => 0,
'module' => 'taxonomy',
'weight' => 0,
'rdf_mapping' => array(
'rdftype' => array(
0 => 'skos:ConceptScheme',
),
'name' => array(
'predicates' => array(
0 => 'dc:title',
),
),
'description' => array(
'predicates' => array(
0 => 'rdfs:comment',
),
),
),
),
);
}

View File

@ -2,3 +2,18 @@ name = Farm Quantity
description = Provides a framework for dealing with quantities.
core = 7.x
package = farmOS
dependencies[] = ctools
dependencies[] = features
dependencies[] = field_collection
dependencies[] = fraction
dependencies[] = strongarm
dependencies[] = taxonomy
features[ctools][] = strongarm:strongarm:1
features[features_api][] = api:2
features[field_base][] = field_farm_quantity
features[field_base][] = field_farm_quantity_units
features[field_base][] = field_farm_quantity_value
features[field_instance][] = field_collection_item-field_farm_quantity-field_farm_quantity_units
features[field_instance][] = field_collection_item-field_farm_quantity-field_farm_quantity_value
features[taxonomy][] = farm_quantity_units
features[variable][] = pathauto_taxonomy_term_farm_quantity_units_pattern

View File

@ -3,3 +3,37 @@
* @file
* Farm quantity module.
*/
// Include Features code.
include_once 'farm_quantity.features.inc';
/**
* Implements hook_farm_access_perms().
*/
function farm_quantity_farm_access_perms($role) {
// Assemble a list of entity types provided by this module.
$types = array(
'taxonomy' => array(
'farm_quantity_units',
),
);
// Grant different CRUD permissions based on the role.
$perms = array();
switch ($role) {
// Farm Manager and Worker
case 'Farm Manager':
case 'Farm Worker':
$perms = farm_access_entity_perms($types);
break;
// Farm Viewer
case 'Farm Viewer':
$perms = farm_access_entity_perms($types, array('view'));
break;
}
return $perms;
}

View File

@ -0,0 +1,21 @@
<?php
/**
* @file
* farm_quantity.strongarm.inc
*/
/**
* Implements hook_strongarm().
*/
function farm_quantity_strongarm() {
$export = array();
$strongarm = new stdClass();
$strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */
$strongarm->api_version = 1;
$strongarm->name = 'pathauto_taxonomy_term_farm_quantity_units_pattern';
$strongarm->value = 'farm/unit/[term:name]';
$export['pathauto_taxonomy_term_farm_quantity_units_pattern'] = $strongarm;
return $export;
}