diff --git a/README.md b/README.md
index 20737a9..79c339b 100644
--- a/README.md
+++ b/README.md
@@ -1,11 +1,11 @@
# Tripal Fancy Fields
-This module provides additional fields for use with Tripal 3. The current version provides a single-series chart field that can be displayed as a pie, donut, or bar chart, as well as, a simple table. Future versions will provide support for multi-series datasets, pedigree's, hierarchy/relationship diagrams, and quick searches. These fields are highly configurable and use your existing materialized views as the datasource which allows them to be fast and flexible.
+This module provides additional fields for use with Tripal 4. The current version provides a single-series chart field that can be displayed as a pie, donut, or bar chart, as well as, a simple table. Future versions will provide support for multi-series datasets, pedigree's, hierarchy/relationship diagrams, and quick searches. These fields are highly configurable and use your existing materialized views as the datasource which allows them to be fast and flexible.
## Installation
This module is installed the same as any Drupal module.
### Dependencies
-1. [Tripal 3.x](https://github.com/tripal/tripal)
+1. [Tripal 4.x](https://github.com/tripal/tripal)
2. [Tripal D3](https://github.com/tripal/tripald3)
## How To Use this Module
@@ -18,7 +18,7 @@ If you simply want to use the existing charts, you can add these fields through
### Extend the Base Classes
If you would like even more control over the field then is provided through the UI, you can extend the ChadoChart base classes in your own custom module.
-1. Create a custom module. See the [Drupal Documentation](https://www.drupal.org/docs/7/creating-custom-modules) for how to do this.
+1. Create a custom module. See the [Drupal Documentation](https://www.drupal.org/docs/creating-custom-modules) for how to do this.
2. Create your child class extending the base class of your choice in `[your module]/includes/TripalFields/[field name]/[field name].inc`
3. Set the various settings under `EDITABLE STATIC CONSTANTS`.
4. Implement hook_bundle_fields_info() and hook_bundle_instances_info() to attach your field to a Tripal Content Type or add it through the UI just like you would a regular Tripal Fancy Field.
diff --git a/config/install/trpfancy_fields.settings.yml b/config/install/trpfancy_fields.settings.yml
new file mode 100644
index 0000000..9ff644b
--- /dev/null
+++ b/config/install/trpfancy_fields.settings.yml
@@ -0,0 +1,7 @@
+# @file
+# Tripal Fancy Fields module variables/configuration.
+
+# FIELD IDENTIFIER CONFIGURATIONS:
+tripal_fancyfields_identifier_config:
+ prefix: 'KP:GERM'
+
\ No newline at end of file
diff --git a/css/tripal-fancyfields-config.css b/css/tripal-fancyfields-config.css
new file mode 100644
index 0000000..c3a0645
--- /dev/null
+++ b/css/tripal-fancyfields-config.css
@@ -0,0 +1,17 @@
+/*
+ * @file
+ * Style Tripal Fancy Fields Configuration.
+ */
+
+ #tripal-fancyfields-box-id {
+ border: 1px solid #CCCCCC;
+ display: inline-block;
+ font-family: courier, serif;
+ font-size: 2em;
+ margin: 5px 0 20px 0;
+ padding: 10px;
+ }
+
+ #tripal-fancyfields-box-id span {
+ color: #666666;
+ }
\ No newline at end of file
diff --git a/includes/TripalFields/ChadoChartField.inc b/includes/TripalFields/ChadoChartField.inc
index a4a4ecb..f505c31 100644
--- a/includes/TripalFields/ChadoChartField.inc
+++ b/includes/TripalFields/ChadoChartField.inc
@@ -44,7 +44,7 @@ class ChadoChartField extends TripalField {
// Drupal will automatically change these settings for all fields.
// Once instances exist for a field type then these settings cannot be
// changed.
- public static $default_settings = array(
+ public static $default_settings = [
'storage' => 'tripal_no_storage',
// It is expected that all fields set a 'value' in the load() function.
// In many cases, the value may be an associative array of key/value pairs.
@@ -52,8 +52,8 @@ class ChadoChartField extends TripalField {
// be a controlled vocabulary term (e.g. rdfs:type). Keys in the load()
// function that are supported by the query() function should be
// listed here.
- 'searchable_keys' => array(),
- );
+ 'searchable_keys' => [],
+ ];
// Provide a list of instance specific settings. These can be access within
// the instanceSettingsForm. When the instanceSettingsForm is submitted
@@ -62,7 +62,7 @@ class ChadoChartField extends TripalField {
// If you override this variable in a child class be sure to replicate the
// term_name, term_vocab, term_accession and term_fixed keys as these are
// required for all TripalFields.
- public static $default_instance_settings = array(
+ public static $default_instance_settings = [
// The short name for the vocabulary (e.g. shcema, SO, GO, PATO, etc.).
'term_vocabulary' => NULL,
// The name of the term.
@@ -86,7 +86,7 @@ class ChadoChartField extends TripalField {
// features. This is done using a combination of the filter_field (Drupal)
// and filter_column (Materialized View).
//-----------------------------------------------------
- 'data_options' => array(
+ 'data_options' => [
// The following relate to the materialized view:
//-----------------------------------------------------
@@ -99,8 +99,8 @@ class ChadoChartField extends TripalField {
// To Filter the materialized view for a specific page:
//-----------------------------------------------------
- 'filters' => array(
- array(
+ 'filters' => [
+ [
// Use this setting to specify the Drupal/Tripal/Chado field containing the
// value to filter the materialized view on. For example, if you want
// `organism_feature_count.species = taxrank__species` then you set the
@@ -114,10 +114,10 @@ class ChadoChartField extends TripalField {
// The column to filter the materialized view based on. This is usually
// a foreign key but doesn't have to be.
'filter_column' => NULL,
- )
- ),
- ),
- );
+ ]
+ ],
+ ],
+ ];
// A boolean specifying that users should not be allowed to create
// fields and instances of this field type through the UI. Such
@@ -155,11 +155,8 @@ class ChadoChartField extends TripalField {
* The array may contain as many other keys at the same level as 'value'
* but those keys are for internal field use and are not considered the
* value of the field.
- *
- *
*/
public function load($entity) {
-
// We need the field name to ensure we save the data in the correct field!
$field_name = $this->instance['field_name'];
@@ -171,11 +168,11 @@ class ChadoChartField extends TripalField {
// Backwards compatible filters.
// Originally, we only supported a single filter.
if (isset($this->instance['settings']['data_options']['filter_column'])) {
- $this->instance['settings']['data_options']['filters'] = array( array(
+ $this->instance['settings']['data_options']['filters'] = [[
'filter_column' => $this->instance['settings']['data_options']['filter_column'],
'filter_field' => $this->instance['settings']['data_options']['filter_field'],
'use_record_id' => $this->instance['settings']['data_options']['use_record_id'],
- ));
+ ]];
unset(
$this->instance['settings']['data_options']['filter_column'],
@@ -185,8 +182,8 @@ class ChadoChartField extends TripalField {
}
// Fill in the filters.
- $where_clause = array();
- $where_args = array();
+ $where_clause = [];
+ $where_args = [];
foreach ($this->instance['settings']['data_options']['filters'] as $k => $filter_info) {
$where_clause[$k] = $filter_info['filter_column'] . '=:filter_value' . $k;
@@ -205,8 +202,9 @@ class ChadoChartField extends TripalField {
'trpfancy_fields',
TRIPAL_ERROR,
'Attempted to display %field but there was no value to filter on. Specifically, either field %filter_field had no value or a filter field was not specified.',
- array('%field' => $field_name, '%filter_field' => $filter_info['filter_field'])
+ ['%field' => $field_name, '%filter_field' => $filter_info['filter_field']]
);
+
return FALSE;
}
}
@@ -228,13 +226,13 @@ class ChadoChartField extends TripalField {
}
// Interate through results, adding them to the value.
- $entity->{$field_name}['und'][0]['value'] = array();
- $entity->{$field_name}['und'][0]['value']['hydra:member'] = array();
+ $entity->{$field_name}['und'][0]['value'] = [];
+ $entity->{$field_name}['und'][0]['value']['hydra:member'] = [];
foreach ($results as $r) {
- $entity->{$field_name}['und'][0]['value']['hydra:member'][] = array(
+ $entity->{$field_name}['und'][0]['value']['hydra:member'][] = [
'rdfs:label' => $r->{$label_column},
'local:count' => $r->{$count_column},
- );
+ ];
}
// Ensure we don't return markup if there is no data.
@@ -273,20 +271,21 @@ class ChadoChartField extends TripalField {
// Allow the parent Tripal Field to set up the form element for us.
$element = parent::instanceSettingsForm();
- $element['data_options'] = array(
+ $element['data_options'] = [
'#type' => 'fieldset',
'#title' => 'Chart Data Source',
'#description' => 'The data for this chart will be pulled from the materialized view specified below. Additonally you must configure which columns in the materialized view should be the source of the data and which should be used to filter the results.',
- );
+ ];
// The following relate to the materialized view:
//-----------------------------------------------------
// The table name of the materialized view to pull data from.
- $options = array();
+ $options = [];
foreach (tripal_get_mviews() as $mview) {
$options[ $mview->name ] = $mview->name;
}
- $element['data_options']['materialized_view'] = array(
+
+ $element['data_options']['materialized_view'] = [
'#type' => 'select',
'#required' => TRUE,
'#options' => $options,
@@ -294,21 +293,21 @@ class ChadoChartField extends TripalField {
'#description' => 'The materialized view you would like to pull the data for the chart from.',
'#default_value' => $settings['data_options']['materialized_view'],
'#weight' => -10,
- );
+ ];
// Supports unlimited filters, although the form needs to be saved to make
// another filter available.
// @todo support AJAX.
- $element['data_options']['filters'] = array(
+ $element['data_options']['filters'] = [
'#type' => 'fieldset',
'#title' => 'Filters',
'#description' => 'The materialized view indicated likely has data for multiple Tripal Content Pages. Thus, to ensure the chart is specific to the current page, we must filter the materialized view. This is done by indicated a column in the materialized view (the filter column) that should equal the value of a Drupal/Tripal/Chado field (the filter field) for the current page.',
'#weight' => 100,
- );
+ ];
// Drupal/Tripal/Chado field to filter the materialized view on.
$fields = field_info_instances($this->instance['entity_type'], $this->instance['bundle']);
- $options = array();
+ $options = [];
foreach ($fields as $f) {
$options[ $f['field_name'] ] = $f['field_name'];
}
@@ -320,12 +319,12 @@ class ChadoChartField extends TripalField {
}
$filter_queue = $settings['data_options']['filters'];
- $element['data_options']['filters']['m1'] = array(
+ $element['data_options']['filters']['m1'] = [
'#type' => 'markup',
'#markup' => '
Filter Column | Filter Field | OR use Record ID |
'
- );
+ ];
// Now, we want elements for all the current filters +1 :-).
for ($i=0; $i< ($num_filters+1); $i++) {
@@ -335,30 +334,30 @@ class ChadoChartField extends TripalField {
$current_element = array_shift($filter_queue);
}
else {
- $current_element = array(
+ $current_element = [
'filter_column' => NULL,
'filter_field' => ' ',
'use_record_id' => FALSE,
- );
+ ];
}
- $element['data_options']['filters'][$i]['m1'] = array(
+ $element['data_options']['filters'][$i]['m1'] = [
'#type' => 'markup',
'#markup' => ''
- );
+ ];
// The column to filter the materialized view based on. This is usually
// a foreign key but doesn't have to be.
- $element['data_options']['filters'][$i]['filter_column'] = array(
+ $element['data_options']['filters'][$i]['filter_column'] = [
'#type' => 'textfield',
'#title' => 'Filter Column',
'#title_display' => 'invisible',
'#default_value' => $current_element['filter_column'],
'#prefix' => '',
'#suffix' => ' | ',
- );
+ ];
- $element['data_options']['filters'][$i]['filter_field'] = array(
+ $element['data_options']['filters'][$i]['filter_field'] = [
'#type' => 'select',
'#title' => 'Filter Field',
'#title_display' => 'invisible',
@@ -367,26 +366,26 @@ class ChadoChartField extends TripalField {
'#options' => $options,
'#prefix' => '',
'#suffix' => ' | ',
- );
+ ];
// Use the chado primary key instead of the filter field above.
- $element['data_options']['filters'][$i]['use_record_id'] = array(
+ $element['data_options']['filters'][$i]['use_record_id'] = [
'#type' => 'checkbox',
'#title' => 'Use Chado Record ID',
'#title_display' => 'invisible',
'#default_value' => $current_element['use_record_id'],
'#prefix' => '',
'#suffix' => ' | ',
- );
+ ];
- $element['data_options']['filters'][$i]['m2'] = array(
+ $element['data_options']['filters'][$i]['m2'] = [
'#type' => 'markup',
'#markup' => '
'
- );
+ ];
}
// Add in help text
- $element['data_options']['filters']['m2'] = array(
+ $element['data_options']['filters']['m2'] = [
'#type' => 'markup',
'#markup' => ''
// Filter Column
@@ -396,12 +395,12 @@ class ChadoChartField extends TripalField {
// Use Record ID
. 'Filter on the primary key of the chado record being displayed on the page (e.g. organism_id). | '
. '
'
- );
+ ];
- $element['data_options']['filters']['m3'] = array(
+ $element['data_options']['filters']['m3'] = [
'#type' => 'markup',
'#markup' => '
'
- );
+ ];
return $element;
}
@@ -439,19 +438,19 @@ class ChadoChartField extends TripalField {
if ($has_filter_column && !$has_drupal_field_or_pkey) {
form_set_error('instance][settings][data_options][filters]['.$k.'][filter_field',
t('Filter #:k: You must indicate the Filter Field to filter the materialized view based on.',
- array(':k' => $readable_k)));
+ [':k' => $readable_k]));
}
if (!$has_filter_column && $has_drupal_field_or_pkey) {
form_set_error('instance][settings][data_options][filters]['.$k.'][filter_column',
t('Filter #:k: You must indicate the Filter Column to filter the materialized view based on.',
- array(':k' => $readable_k)));
+ [':k' => $readable_k]));
}
// Check the filter column exists.
if (!chado_column_exists($values['materialized_view'], $current_filter['filter_column'])) {
form_set_error('instance][settings][data_options][filters]['.$k.'][filter_column',
t('Filter #:k: The Filter Column must exist in the %mview materialized view.',
- array('%mview' => $values['materialized_view'], ':k' => $readable_k)));
+ ['%mview' => $values['materialized_view'], ':k' => $readable_k]));
}
// Retrieve the field info for the filter field chosen.
@@ -460,12 +459,12 @@ class ChadoChartField extends TripalField {
// Check that the field exists.
if (!$field) {
form_set_error('instance][settings][data_options][filters]['.$k.'][filter_field',
- t('Filter #:k: The Filter Field must exist.', array(':k' => $readable_k)));
+ t('Filter #:k: The Filter Field must exist.', [':k' => $readable_k]));
}
elseif (!isset($field['bundles']['TripalEntity'])) {
form_set_error('instance][settings][data_options][filters]['.$k.'][filter_field',
t('Filter #:k: The Filter Field must be attached to the current Tripal Content Type.',
- array(':k' => $readable_k)));
+ [':k' => $readable_k]));
}
else {
// Check that this field is attached to the current Tripal Entity type.
@@ -473,10 +472,10 @@ class ChadoChartField extends TripalField {
if (array_search($bundle, $field['bundles']['TripalEntity']) === FALSE) {
form_set_error('instance][settings][data_options][filters]['.$k.'][filter_field',
t('Filter #:k: The Filter Field must be attached to the current Tripal Content Type.',
- array(':k' => $readable_k)));
+ [':k' => $readable_k]));
}
}
}
}
}
-}
+}
\ No newline at end of file
diff --git a/includes/TripalFields/ChadoChartFormatter.inc b/includes/TripalFields/ChadoChartFormatter.inc
index 3369b49..4e6bd0e 100644
--- a/includes/TripalFields/ChadoChartFormatter.inc
+++ b/includes/TripalFields/ChadoChartFormatter.inc
@@ -16,16 +16,16 @@ class ChadoChartFormatter extends ChadoFieldFormatter {
public static $default_label = 'Chado Chart';
// The list of field types for which this formatter is appropriate.
- public static $field_types = array();
+ public static $field_types = [];
// The list of default settings for this formatter.
// Due to the different charts available and the dependance upon the data,
// it is too difficult to make a good default for the title and legend.
// As such I am making a horrible one in the hopes of making admin change it ;-p.
- public static $default_settings = array(
+ public static $default_settings = [
'title' => 'Fancy Chart summarizing Stuff',
'legend' => 'This should describe the chart including the data that goes into it and how to interpret that data. Furthermore, it is always a good idea to highlight how users can interact with this chart.',
- );
+ ];
/**
* Provides the field's setting form.
@@ -60,7 +60,7 @@ class ChadoChartFormatter extends ChadoFieldFormatter {
* A Drupal Form array containing the settings form for this field.
*/
public function settingsForm($view_mode, $form, &$form_state) {
- $element = array();
+ $element = [];
// Retrieve the current settings.
$settings = $this->instance['display'][$view_mode]['settings'];
@@ -68,27 +68,27 @@ class ChadoChartFormatter extends ChadoFieldFormatter {
if (!isset($settings['legend'])) { $settings['legend'] = self::$default_settings['legend']; }
// This has caught me a couple of times so I'm going to remind both myself and others ;-p.
- $element['msg'] = array(
+ $element['msg'] = [
'#type' => 'markup',
'#markup' => 'Settings are only saved after you click "Update" within this box
AND "Save" at the bottom of the page!
',
- );
+ ];
// Add in all the general settings
// which can be passed to TripalD3.drawFigure().
//-------------------------------------------
- $element['title'] = array(
+ $element['title'] = [
'#type' => 'textfield',
'#title' => 'Figure Title',
'#default_value' => $settings['title'],
'#description' => 'A breif title for the figure.',
- );
+ ];
- $element['legend'] = array(
+ $element['legend'] = [
'#type' => 'textarea',
'#title' => 'Figure Legend',
'#default_value' => $settings['legend'],
'#description' => 'Should describe the figure to the user.',
- );
+ ];
return $element;
}
@@ -137,7 +137,7 @@ class ChadoChartFormatter extends ChadoFieldFormatter {
// 2. Transform the data in $items to the format required by your chart
// and make it available to the chart via drupal_add_js as "settings".
if (!empty($items[0]['value'])) {
- $data = array();
+ $data = [];
foreach ($items as $key => $value) {
// Add it to the data array.
}
@@ -221,5 +221,4 @@ class ChadoChartFormatter extends ChadoFieldFormatter {
$settings = $this->instance['display'][$view_mode]['settings'];
return 'Title: ' . $settings['title'];
}
-
}
diff --git a/includes/TripalFields/co_010__parentage_of_pedigree/co_010__parentage_of_pedigree.inc b/includes/TripalFields/co_010__parentage_of_pedigree/co_010__parentage_of_pedigree.inc
index e6c7d17..5d65530 100644
--- a/includes/TripalFields/co_010__parentage_of_pedigree/co_010__parentage_of_pedigree.inc
+++ b/includes/TripalFields/co_010__parentage_of_pedigree/co_010__parentage_of_pedigree.inc
@@ -30,7 +30,7 @@ class co_010__parentage_of_pedigree extends TripalField {
// Drupal will automatically change these settings for all fields.
// Once instances exist for a field type then these settings cannot be
// changed.
- public static $default_settings = array(
+ public static $default_settings = [
'storage' => 'tripal_no_storage',
// It is expected that all fields set a 'value' in the load() function.
// In many cases, the value may be an associative array of key/value pairs.
@@ -38,8 +38,8 @@ class co_010__parentage_of_pedigree extends TripalField {
// be a controlled vocabulary term (e.g. rdfs:type). Keys in the load()
// function that are supported by the query() function should be
// listed here.
- 'browseable_keys' => array(),
- );
+ 'browseable_keys' => [],
+ ];
// Provide a list of instance specific settings. These can be access within
// the instanceSettingsForm. When the instanceSettingsForm is submitted
@@ -48,7 +48,7 @@ class co_010__parentage_of_pedigree extends TripalField {
// If you override this variable in a child class be sure to replicate the
// term_name, term_vocab, term_accession and term_fixed keys as these are
// required for all TripalFields.
- public static $default_instance_settings = array(
+ public static $default_instance_settings = [
// The short name for the vocabulary (e.g. schema, SO, GO, PATO, etc.).
'term_vocabulary' => 'CO_010',
// The name of the term.
@@ -70,7 +70,7 @@ class co_010__parentage_of_pedigree extends TripalField {
'option_storage' => '',
// A list of browser types this field intends to provide.
'browser_types' => '',
- );
+ ];
// A boolean specifying that users should not be allowed to create
// fields and instances of this field type through the UI. Such
@@ -107,8 +107,6 @@ class co_010__parentage_of_pedigree extends TripalField {
* The array may contain as many other keys at the same level as 'value'
* but those keys are for internal field use and are not considered the
* value of the field.
- *
- *
*/
public function load($entity) {
// The record.
@@ -122,7 +120,7 @@ class co_010__parentage_of_pedigree extends TripalField {
// Chart configuration:
- $chart = array(
+ $chart = [
// Whether to put figure key legend or not.
// TRUE of FALSE;
'draw_key_legend' => TRUE,
@@ -138,18 +136,18 @@ class co_010__parentage_of_pedigree extends TripalField {
'wrapper' => 'tripald3-pedigree-wrapper',
// Append svg to.
'element' => 'tripald3-pedigree'
- );
+ ];
// Data:
- $data = array(
+ $data = [
'name' => $entity->title,
- );
+ ];
// Source:
$path_base = $GLOBALS['base_url'];
- $path_to_module = drupal_get_path('module', 'trpfancy_fields');
+ $path_to_module = \Drupal::service('extension.list.module')->getPath('trpfancy_fields');
$path_to_tfield = $path_base . '/' . $path_to_module . '/includes/TripalFields';
$path_to_pedigree = $path_to_tfield . '/' . get_class($this);
$path_to_JSON = $path_base . '/ajax/tripal/d3-json/relationships/stock/' . $chado_record_id;
@@ -158,19 +156,17 @@ class co_010__parentage_of_pedigree extends TripalField {
$stock_type = $entity->chado_record->type_id->name;
$path_to_germpage = $path_base . '/' . strtolower($stock_type) . '/';
- $source = array(
+ $source = [
'path_JSON' => $path_to_JSON,
'path_T3field' => $path_to_pedigree,
'path_germpage' => $path_to_germpage,
- );
-
-
+ ];
- $entity->{$field_name}['und'][0]['vars'] = array(
+ $entity->{$field_name}['und'][0]['vars'] = [
'chart' => $chart,
'data' => $data,
'source' => $source,
- );
+ ];
}
/**
diff --git a/includes/TripalFields/co_010__parentage_of_pedigree/co_010__parentage_of_pedigree_formatter.inc b/includes/TripalFields/co_010__parentage_of_pedigree/co_010__parentage_of_pedigree_formatter.inc
index 952f9fe..c314a75 100644
--- a/includes/TripalFields/co_010__parentage_of_pedigree/co_010__parentage_of_pedigree_formatter.inc
+++ b/includes/TripalFields/co_010__parentage_of_pedigree/co_010__parentage_of_pedigree_formatter.inc
@@ -17,7 +17,7 @@ class co_010__parentage_of_pedigree_formatter extends TripalFieldFormatter {
public static $default_label = 'Parental Pedigree';
// The list of field types for which this formatter is appropriate.
- public static $field_types = array('co_010__parentage_of_pedigree');
+ public static $field_types = ['co_010__parentage_of_pedigree'];
/**
* Provides the display for a field
@@ -55,41 +55,73 @@ class co_010__parentage_of_pedigree_formatter extends TripalFieldFormatter {
// user_is_looged_in alwasy returns 1.
$pass = (user_is_logged_in()) ? 1 : 0;
- // Prepare settings:
- drupal_add_js(array('trpfancyFields' => array(
- // Stock name.
- 'name' => $display_vars['data']['name'],
- // JSON url.
- 'url' => $display_vars['source'],
- // Append SVG element and configurations.
- 'chart' => $display_vars['chart'],
- // Authenticate user.
- 'pass' => $pass),
-
- ), 'setting');
-
// Initialize chart:
// Load Tripal D3 API.
- tripald3_load_libraries();
+ // Load the Tripal D3 Libraries.
+ $element['#attached']['library'][] = 'tripald3/D3';
+ $element['#attached']['library'][] = 'tripald3/D3';
+
+ // CORE
+ $element['#attached']['library'][] = 'tripald3/D3';
+ $element['#attached']['library'][] = 'tripald3/tripalD3';
+
+ // CHARTS
+ // Pie
+ $element['#attached']['library'][] = 'tripald3/lib-pie';
+ $element['#attached']['library'][] = 'tripald3/lib-bar';
+ 'tripald3/lib-pedigree',
+
+ // CREATE
+ $element['#attached']['library'][] = 'tripald3/create-multidonut';
+ $element['#attached']['library'][] = 'tripald3/create-pie';
+ $element['#attached']['library'][] = 'tripald3/create-multiseriesdonut';
+ $element['#attached']['library'][] = 'tripald3/create-bar';
+ $element['#attached']['library'][] = 'tripald3/create-pedigree';
+
+ // STYLE
+ $element['#attached']['library'][] = 'tripald3/style-tripald3';
+
+ // SETTINGS
+ // Color scheme configuration.
+ $default_scheme = \Drupal::service('tripald3.TripalD3ColorScheme')
+ ->registerColorScheme();
+ $to_Drupalsettings['tripalD3']['vars']['colorScheme'] = $default_scheme;
+
+ // Auto resize configuration.
+ $default_resize = $this->config('tripald3.settings')
+ ->get('tripald3_autoResize');
+ $to_Drupalsettings['tripalD3']['vars']['autoResize'] = $default_resize;
+
+ $element['#attached']['drupalSettings'][] = $to_Drupalsettings;
+
+ // Prepare settings:
+ $field_settings = [
+ 'trpfancyFields' => [
+ // Stock name.
+ 'name' => $display_vars['data']['name'],
+ // JSON url.
+ 'url' => $display_vars['source'],
+ // Append SVG element and configurations.
+ 'chart' => $display_vars['chart'],
+ // Authenticate user.
+ 'pass' => $pass
+ ]
+ ];
+
+ $element['#attached']['drupalSettings'][] = $field_settings;
+ // FIELD SCRIPT.
+ $element['#attached']['library'][] = 'trpfancy_fields/tripal-fancyfields-co-010';
- drupal_add_js($display_vars['source']['path_T3field'] . '/theme/script.js',
- array(
- // An external file scrip.js in theme/
- 'type' => 'file',
- // At foot of DOM to ensure document is ready for width estimate.
- 'scope' => 'footer'
- )
- );
// Add element:
- $element[0] = array(
- '#type' => 'markup',
- '#markup' => '
+ $element[0] = [
+ '#type' => 'inline_template',
+ '#template' => '
Loading pedigree tree diagram. Please wait...
',
- );
+ ];
return $element;
diff --git a/includes/TripalFields/co_010__parentage_of_pedigree/co_010__parentage_of_pedigree_widget.inc b/includes/TripalFields/co_010__parentage_of_pedigree/co_010__parentage_of_pedigree_widget.inc
index a5696fd..97bb90b 100644
--- a/includes/TripalFields/co_010__parentage_of_pedigree/co_010__parentage_of_pedigree_widget.inc
+++ b/includes/TripalFields/co_010__parentage_of_pedigree/co_010__parentage_of_pedigree_widget.inc
@@ -13,7 +13,7 @@ class co_010__parentage_of_pedigree_widget extends TripalFieldWidget {
public static $default_label = 'No Edits';
// The list of field types for which this formatter is appropriate.
- public static $field_types = array('co_010__parentage_of_pedigree');
+ public static $field_types = ['co_010__parentage_of_pedigree'];
/**
* Provides the form for editing of this field.
diff --git a/includes/TripalFields/co_010__parentage_of_pedigree/theme/script.js b/includes/TripalFields/co_010__parentage_of_pedigree/theme/script.js
index abe8d37..e2bd0e8 100644
--- a/includes/TripalFields/co_010__parentage_of_pedigree/theme/script.js
+++ b/includes/TripalFields/co_010__parentage_of_pedigree/theme/script.js
@@ -2,6 +2,7 @@
* @file
* Manage parentage pedigree behavior
*/
+
(function ($) {
Drupal.behaviors.ParentagePedigree = {
attach: function(context, settings) {
@@ -71,7 +72,6 @@ Drupal.behaviors.ParentagePedigree = {
'pass' : Drupal.settings.trpfancyFields.pass,
});
-
$('#tripald3-pedigree-wait').remove();
});
}}}(jQuery));
diff --git a/includes/TripalFields/data__identifier/data__identifier_widget.inc b/includes/TripalFields/data__identifier/data__identifier_widget.inc
index 570814a..a002e57 100644
--- a/includes/TripalFields/data__identifier/data__identifier_widget.inc
+++ b/includes/TripalFields/data__identifier/data__identifier_widget.inc
@@ -1,4 +1,5 @@
FALSE));
+ // @see routing.yml.
+ $link = \Drupal::l(t('Upfate Prefix'), Url::fromRoute('tripal_fancyfields.configure_data_id'));
+ tripal_set_message('Administrators, you can set prefix used in uniquename field in ' . $link . '.', TRIPAL_INFO, ['return_html' => FALSE]);
// Pull system variable for configured prefix.
- $prefix = variable_get('trpfancy_field_identifier_prefix');
+ $prefix = \Drupal::config('trpfancy_fields.settings')
+ ->get('tripal_fancyfields_identifier_config.prefix');
+
// Dertermine if process is Create or Update. To test: check if chado_record_id
// were set to an id number.
@@ -101,10 +104,10 @@ class data__identifier_widget extends ChadoFieldWidget {
$desciption = '';
// Feed to this field the uniquename for this stock.
- $widget['value'] = array(
+ $widget['value'] = [
'#type' => 'value',
'#value' => $unique_name,
- );
+ ];
}
else {
// Create.
@@ -115,22 +118,22 @@ class data__identifier_widget extends ChadoFieldWidget {
// Use this to flag process that user is creating a new record
// and quick reference to the field.
- $form['trpfancy_fields_field_name'] = array(
+ $form['trpfancy_fields_field_name'] = [
'#type' => 'value',
'#value' => $field_name,
- );
+ ];
- $widget['table'] = array(
+ $widget['table'] = [
'#type' => 'value',
'#value' => $field_table,
- );
+ ];
$id = uniqid();
// What actually gets saved.
- $widget['value'] = array(
+ $widget['value'] = [
'#type' => 'value',
'#value' => $id,
- );
+ ];
}
}
@@ -139,18 +142,18 @@ class data__identifier_widget extends ChadoFieldWidget {
// information. As such, simply save it again.
// What user sees.
- $widget[$linker_field] = array(
+ $widget[$linker_field] = [
'#type' => 'textfield',
'#title' => 'Uniquename',
'#value' => $unique_name,
'#disabled' => TRUE,
'#description' => $desciption,
- );
+ ];
}
else {
// Text field but not identifier.
- drupal_set_message('This option is available only to Identifier (text field). Please restore field ' . $element['#title'] . ' to Text type.', 'error');
- tripal_set_message('Administrators, please ensure that you are adding this autocomplete uniquename field only to Identifier field.', TRIPAL_INFO, array('return_html' => FALSE));
+ \Drupal::messenger()->addError(t('This option is available only to Identifier (text field). Please restore field ' . $element['#title'] . ' to Text type.'));
+ tripal_set_message('Administrators, please ensure that you are adding this autocomplete uniquename field only to Identifier field.', TRIPAL_INFO, ['return_html' => FALSE]);
}
}
@@ -213,7 +216,8 @@ class data__identifier_widget extends ChadoFieldWidget {
$tmp_uniquename = $form_state['values'][$field_name]['und'][0]['value'];
- $prefix = variable_get('trpfancy_field_identifier_prefix');
+ $prefix = \Drupal::config('trpfancy_fields.settings')
+ ->get('tripal_fancyfields_identifier_config.prefix');
$form_state['values'][$field_name][$langcode][$delta][$linker_field] = $prefix . $tmp_uniquename;
}
@@ -235,15 +239,16 @@ class data__identifier_widget extends ChadoFieldWidget {
$data = $arr['und'][0];
$tmp_uniquename = $data['value'];
- $prefix = variable_get('trpfancy_field_identifier_prefix');
+ $prefix = \Drupal::config('trpfancy_fields.settings')
+ ->get('tripal_fancyfields_identifier_config.prefix');
// Find the primary key of the table this uniquename is attached to.
$pk = chado_query("SELECT column_name FROM information_schema.COLUMNS WHERE TABLE_NAME = :table",
- array(':table' => $data['table']))
+ [':table' => $data['table']])
->fetchField();
$sql = sprintf("SELECT %s FROM {%s} WHERE uniquename = :uniquename LIMIT 1", $pk, $data['table']);
- $id = chado_query($sql, array(':uniquename' => $prefix . $tmp_uniquename))
+ $id = chado_query($sql, [':uniquename' => $prefix . $tmp_uniquename])
->fetchField();
if ($id) {
@@ -251,8 +256,8 @@ class data__identifier_widget extends ChadoFieldWidget {
$new_uniquename = $prefix . $id;
chado_update_record($data['table'],
- array('uniquename' => $prefix . $tmp_uniquename),
- array('uniquename' => $new_uniquename)
+ ['uniquename' => $prefix . $tmp_uniquename],
+ ['uniquename' => $new_uniquename]
);
}
}
diff --git a/includes/TripalFields/local__quick_browse/local__quick_browse.inc b/includes/TripalFields/local__quick_browse/local__quick_browse.inc
index 77b1a4b..c2722da 100644
--- a/includes/TripalFields/local__quick_browse/local__quick_browse.inc
+++ b/includes/TripalFields/local__quick_browse/local__quick_browse.inc
@@ -31,7 +31,7 @@ class local__quick_browse extends TripalField {
// Drupal will automatically change these settings for all fields.
// Once instances exist for a field type then these settings cannot be
// changed.
- public static $default_settings = array(
+ public static $default_settings = [
'storage' => 'tripal_no_storage',
// It is expected that all fields set a 'value' in the load() function.
// In many cases, the value may be an associative array of key/value pairs.
@@ -39,8 +39,8 @@ class local__quick_browse extends TripalField {
// be a controlled vocabulary term (e.g. rdfs:type). Keys in the load()
// function that are supported by the query() function should be
// listed here.
- 'browseable_keys' => array(),
- );
+ 'browseable_keys' => [],
+ ];
// Provide a list of instance specific settings. These can be access within
// the instanceSettingsForm. When the instanceSettingsForm is submitted
@@ -49,7 +49,7 @@ class local__quick_browse extends TripalField {
// If you override this variable in a child class be sure to replicate the
// term_name, term_vocab, term_accession and term_fixed keys as these are
// required for all TripalFields.
- public static $default_instance_settings = array(
+ public static $default_instance_settings = [
// The short name for the vocabulary (e.g. schema, SO, GO, PATO, etc.).
'term_vocabulary' => 'local',
// The name of the term.
@@ -71,7 +71,7 @@ class local__quick_browse extends TripalField {
'option_storage' => 'trpfancy_browse_options',
// A list of browser types this field intends to provide.
'browser_types' => '',
- );
+ ];
// A boolean specifying that users should not be allowed to create
// fields and instances of this field type through the UI. Such
@@ -125,7 +125,8 @@ class local__quick_browse extends TripalField {
// when options are global to all entities for the given field.
if ($settings['option_storage'] == 'trpfancy_browse_options') {
$query = 'SELECT * FROM {trpfancy_browse_options} WHERE instance_id=:id';
- $results = db_query($query, array(':id' => $instance_id));
+ $results = chado_query($query, [':id' => $instance_id]);
+
foreach($results as $opt) {
$entity->{$field_name}['und'][0]['value'][$opt->category][$opt->key] = $opt->value;
}
@@ -168,22 +169,22 @@ class local__quick_browse extends TripalField {
// Simple radio buttons to select whether you want your options
// per entity or constant for this field.
- $element['option_storage'] = array(
+ $element['option_storage'] = [
'#type' => 'radios',
'#title' => 'Browser Option Source',
- '#options' => array(
+ '#options' => [
'trpfancy_browse_options' => 'A. Constant for this Field',
'trpfancy_browse_options_per_entity' => 'B. Dependant on the page shown',
- ),
+ ],
'#default_value' => $settings['option_storage'],
'#required' => TRUE,
'#description' => 'The browser field breaks down a set of options by
"Browser Type". Depending on your choice here, the options can be a) constant
for the field (e.g. same options for all organisms) or they can be
b) specific to the page being shown (e.g. Specific to a given organism).',
- );
+ ];
- $element['browser_types'] = array(
+ $element['browser_types'] = [
'#type' => 'textarea',
'#title' => 'Browser Types',
'#required' => TRUE,
@@ -195,12 +196,11 @@ class local__quick_browse extends TripalField {
Each Browser Type should be indicated on a seperate line using the
key=value format.',
'#default_value' => $settings['browser_types'],
- );
+ ];
- $element['options'] = array(
- '#type' => 'item',
- '#title' => 'Options',
- '#markup' => 'Currently there is no UI for setting the option for a given browser type.
+ $element['options'] = [
+ '#type' => 'inline_template',
+ '#template' => '
Options
Currently there is no UI for setting the option for a given browser type.
Instead it is recommended you add them to the database manually either via "psql" or "drush sql-query".
For example, the following query would insert 3 options for the browser type with
the key="type1". The browse field would create 3 links: "Exome Capture", "Genotype-by-Sequencing",
@@ -227,30 +227,39 @@ class local__quick_browse extends TripalField {
(5, '.$this->instance['id'].', "type1", "4567", "SCAR");
',
- );
+ ];
// Show the user what options they have already set.
$results = db_query('SELECT * FROM {trpfancy_browse_options} WHERE instance_id=:id ORDER BY category ASC, value ASC',
- array(':id' => $this->instance['id']));
- $rows = array();
+ [':id' => $this->instance['id']]);
+ $rows = [];
foreach($results as $r) {
- $rows[] = array(
+ $rows[] = [
$r->category,
$r->key,
$r->value
- );
+ ];
}
+
if ($rows) {
- $element['options']['#markup'] .= '
Current Options: This table shows the default options you have for this field stored in trpfancy_browse_options.
';
- $element['options']['#markup'] .= theme_table(array(
- 'header' => array('Browser Type', 'Key', 'Value'),
- 'rows' => $rows,
- 'attributes' => array(),
- ));
+ $element['options'] = [
+ '#type' => 'table',
+ '#header' => ['Browser Type', 'Key', 'Value'],
+ '#rows' => $rows,
+ '#empty' => t('0 Items in this table'),
+ ];
+
+ $element['options_markup'] = [
+ '#type' => 'inline_template',
+ '#template' => 'Current Options: This table shows the default options you have for this field stored in trpfancy_browse_options.
'
+ ];
}
else {
- $element['options']['#markup'] .= 'Current Options: You have no default options available for this field (instance_id: '.$this->instance['id'].'). Once you add them to the database following the instructions above, you will see them listed here.
';
+ $element['options_markup'] = [
+ '#type' => 'inline_template',
+ '#template' => 'Current Options: You have no default options available for this field (instance_id: '.$this->instance['id'].'). Once you add them to the database following the instructions above, you will see them listed here.
'
+ ];
}
return $element;
@@ -266,7 +275,7 @@ class local__quick_browse extends TripalField {
* An array of browser types where key: machine name, value: human-readable name.
*/
function local__quick_browse_get_browser_types($instance_settings) {
- $types = array();
+ $types = [];
$lines = explode("\n", $instance_settings['browser_types']);
foreach ($lines as $line) {
@@ -274,7 +283,7 @@ function local__quick_browse_get_browser_types($instance_settings) {
$line = trim($line);
// Extract the key and value to add to the types list.
- $matches = array();
+ $matches = [];
if (preg_match('/^(\w+)=(\w+)$/', $line, $matches)) {
$types[$matches[1]] = $matches[2];
}
diff --git a/includes/TripalFields/local__quick_browse/local__quick_browse_formatter.inc b/includes/TripalFields/local__quick_browse/local__quick_browse_formatter.inc
index 28d079b..ae9c89a 100644
--- a/includes/TripalFields/local__quick_browse/local__quick_browse_formatter.inc
+++ b/includes/TripalFields/local__quick_browse/local__quick_browse_formatter.inc
@@ -1,4 +1,6 @@
'Browse',
'help_text' => 'Choose what you would like to browse from the drop-down. Clicking one of the resulting links will take you to a listing for further browsing.',
- 'categories' => array(),
- );
+ 'categories' => [],
+ ];
/**
* Provides the field's setting form.
@@ -71,12 +73,12 @@ class local__quick_browse_formatter extends TripalFieldFormatter {
// Ensure each browser type has a config form in the categories.
foreach ($types as $k => $v) {
if (!isset($settings['categories'][$k])) {
- $settings['categories'][$k] = array(
+ $settings['categories'][$k] = [
'type' => $v,
'path' => NULL,
'key' => NULL,
'filter_qstring' => NULL,
- );
+ ];
}
else {
$settings['categories'][$k]['type'] = $v;
@@ -84,70 +86,70 @@ class local__quick_browse_formatter extends TripalFieldFormatter {
}
// This has caught me a couple of times so I'm going to remind both myself and others ;-p.
- $element['msg'] = array(
- '#type' => 'markup',
- '#markup' => 'Settings are only saved after you click "Update" within this box
AND "Save" at the bottom of the page!
',
- );
+ $element['msg'] = [
+ '#type' => 'inline_template',
+ '#template' => 'Settings are only saved after you click "Update" within this box
AND "Save" at the bottom of the page!
',
+ ];
- $element['categories'] = array(
- '#type' => 'fieldset',
+ $element['categories'] = [
+ '#type' => 'details',
'#title' => 'Browser Types',
'#description' => 'This field has a "Browse by [drop-down]" where the values in the
drop-down will be the "Browser Types" you configure here. There will be a dedicated
list of browse options for each "Browser Type" that will redirect the user to a
partially filtered search. For Example, where "Browser Type" is "Type" on an
organism page, the options might include "Gene","mRNA","Genetic Marker", "variant", etc.',
- );
+ ];
foreach ($settings['categories'] as $category => $category_settings) {
- $element['categories'][$category] = array(
+ $element['categories'][$category] = [
'#type' => 'fieldset',
'#title' => $category_settings['type'],
- );
+ ];
- $element['categories'][$category]['type'] = array(
+ $element['categories'][$category]['type'] = [
'#type' => 'hidden',
'#value' => $category_settings['type'],
- );
+ ];
- $element['categories'][$category]['path'] = array(
+ $element['categories'][$category]['path'] = [
'#type' => 'textfield',
'#title' => 'Browse Path',
'#required' => TRUE,
'#description' => 'This is the relative path of the browse page you would like to redirect the user to.',
'#default_value' => $category_settings['path'],
- );
+ ];
- $element['categories'][$category]['key'] = array(
+ $element['categories'][$category]['key'] = [
'#type' => 'textfield',
'#title' => 'Query Parameter Key',
'#required' => TRUE,
'#description' => 'This key is used in the query parameters to tell your full browse which filter to apply the value to.',
'#default_value' => $category_settings['key'],
- );
+ ];
- $element['categories'][$category]['filter_qstring'] = array(
+ $element['categories'][$category]['filter_qstring'] = [
'#type' => 'textarea',
'#title' => 'Additional Filter Criteria',
'#description' => 'Use this field to add additional filter criteria to the URL query string upon submimt. Each additional criteria should be indicated on a seperate line using the key=value format. Tokens of the format `[field machine name]` can be used to make these filter dynamic.',
'#default_value' => $category_settings['filter_qstring'],
- );
+ ];
}
- $element['button_text'] = array(
+ $element['button_text'] = [
'#type' => 'textfield',
'#title' => 'Button Text',
'#required' => TRUE,
'#description' => 'The text on the browse button.',
'#default_value' => $settings['button_text'],
- );
+ ];
- $element['help_text'] = array(
+ $element['help_text'] = [
'#type' => 'textarea',
'#title' => 'Help Text',
'#description' => 'Guidance to your users for how to use the quick browse form.',
'#default_value' => $settings['help_text'],
- );
+ ];
return $element;
}
@@ -186,7 +188,7 @@ class local__quick_browse_formatter extends TripalFieldFormatter {
'trpfancy_fields',
TRIPAL_ERROR,
'No Browser types available. Please configure the field, :field_name, here.',
- array(':field_name' => $this->instance['field_name'], '@url' => url('/admin/structure/bio_data/manage/'.$this->instance['bundle'].'/display'))
+ [':field_name' => $this->instance['field_name'], '@url' => url('/admin/structure/bio_data/manage/'.$this->instance['bundle'].'/display')]
);
return $element;
}
@@ -201,7 +203,7 @@ class local__quick_browse_formatter extends TripalFieldFormatter {
'trpfancy_fields',
TRIPAL_ERROR,
'No options available for :field_label (:field_name). Please add options by editing the field here.',
- array(':field_label' => $this->instance['label'], ':field_name' => $this->instance['field_name'], '@url' => url('/admin/structure/bio_data/manage/'.$this->instance['bundle'].'/fields/'.$this->instance['field_name']))
+ [':field_label' => $this->instance['label'], ':field_name' => $this->instance['field_name'], '@url' => url('/admin/structure/bio_data/manage/'.$this->instance['bundle'].'/fields/'.$this->instance['field_name'])]
);
}
// However, if there are options per entity then it may just be that this particular
@@ -211,7 +213,7 @@ class local__quick_browse_formatter extends TripalFieldFormatter {
'trpfancy_fields',
TRIPAL_NOTICE,
'No options available for :entity_title. Please add options by editing the entity, here, and filling out :field_label in the form.',
- array(':entity_title' => $entity->title, ':field_label' => $this->instance['label'], '@url' => url('/bio_data/'.$entity->id.'/edit'))
+ [':entity_title' => $entity->title, ':field_label' => $this->instance['label'], '@url' => url('/bio_data/'.$entity->id.'/edit')]
);
}
return $element;
@@ -220,7 +222,7 @@ class local__quick_browse_formatter extends TripalFieldFormatter {
// Save the options to be passed through to the form later.
$options = $items[0]['value'];
- $browser_types = array();
+ $browser_types = [];
foreach ($settings['categories'] as $type => $info) {
// If there are no options for the current browser type then don't add it.
@@ -234,7 +236,7 @@ class local__quick_browse_formatter extends TripalFieldFormatter {
// We do this here so we can fill in the values of the fields
// and so we don't increase time during the redirect.
// Start our main paramter which will later be entered by the user.
- $settings['categories'][$type]['qparams'] = array($info['key'] => '[value]');
+ $settings['categories'][$type]['qparams'] = [$info['key'] => '[value]'];
// Then, if there are any additional query params, we will process them line-by-line.
// @assumption: each additional query param is on it's own line.
@@ -246,14 +248,14 @@ class local__quick_browse_formatter extends TripalFieldFormatter {
$line = trim($line);
// Check if there's a field token & if so, replace it.
- $matches = array();
+ $matches = [];
if (preg_match('/\[(\w+)\]/', $line, $matches)) {
$key = '[' . $matches[1] . ']';
$values = field_get_items($entity_type, $entity, $matches[1]);
if ($values === FALSE) {
tripal_report_error('trpfancy_fields', TRIPAL_WARNING,
'Quick Browse Field %name: %token not found, replaced with empty string.',
- array('$name' => $this->instance['field_name'], '%token' => $key));
+ ['$name' => $this->instance['field_name'], '%token' => $key]);
}
foreach ($values as $v) {
@@ -263,7 +265,7 @@ class local__quick_browse_formatter extends TripalFieldFormatter {
}
// Extract the key and value to add to the params list.
- $matches = array();
+ $matches = [];
if (preg_match('/^(\w+\[*\]*)=(\w+)$/', $line, $matches)) {
$settings['categories'][$type]['qparams'][$matches[1]] = $matches[2];
}
@@ -274,18 +276,18 @@ class local__quick_browse_formatter extends TripalFieldFormatter {
// Retrieve my form (implemented below this class).
$form = drupal_get_form(
'local__quick_browse_field_view_form',
- array(
+ [
'settings' => $settings,
'options' => $options,
'browser_types' => $browser_types,
- )
+ ]
);
// Render it and pass it as the markup for this field.
- $element[0] = array(
+ $element[0] = [
'#type' => 'markup',
'#markup' => drupal_render($form),
- );
+ ];
return $element;
}
@@ -321,7 +323,7 @@ class local__quick_browse_formatter extends TripalFieldFormatter {
$settings = $this->instance['display'][$view_mode]['settings'];
- $types = array();
+ $types = [];
foreach ($settings['categories'] as $category => $values) {
$types[] = $values['type'];
}
@@ -350,7 +352,7 @@ function local__quick_browse_field_view_form($form, &$form_state) {
$options = $form_state['build_info']['args'][0]['options'];
$browser_types = $form_state['build_info']['args'][0]['browser_types'];
- $form['#attached']['css'][] = array(
+ $form['#attached']['css'][] = [
'type' => 'inline',
'data' => '
#local-quick-browse-field-view-form {
@@ -379,76 +381,80 @@ function local__quick_browse_field_view_form($form, &$form_state) {
width: 300px;
}
',
- );
+ ];
// Choose a default browser type ;-p.
reset($browser_types);
$default_type = key($browser_types);
- $form['type'] = array(
+ $form['type'] = [
'#type' => 'select',
'#title' => 'Browse',
'#options' => $browser_types,
'#empty_option' => ' - Select -',
'#description' => $settings['help_text'],
'#default_value' => $default_type,
- );
+ ];
- $form['path'] = array(
+ $form['path'] = [
'#type' => 'hidden',
'#value' => $settings['categories'][$current_type]['path'],
- );
+ ];
- $form['key'] = array(
+ $form['key'] = [
'#type' => 'hidden',
'#value' => $settings['categories'][$current_type]['key'],
- );
+ ];
- $form['qparams'] = array(
+ $form['qparams'] = [
'#type' => 'hidden',
'#value' => $settings['categories'][$current_type]['qparams'],
- );
+ ];
foreach (array_keys($browser_types) as $current_type) {
- $list = array();
+ $list = [];
foreach($options[$current_type] as $k => $v) {
$params = $settings['categories'][$current_type]['qparams'];
$params[ $settings['categories'][$current_type]['key'] ] = $k;
- $list[] = l(
- $v,
- $settings['categories'][$current_type]['path'],
- array( 'query' => $params )
- );
+
+ $link = \Drupal::l(t($v), Url::fromUri($settings['categories'][$current_type]['path'], ['query' => $params]));
+ $list[] = $link;
}
- $form['options'][$current_type] = array(
- '#type' => 'markup',
+ $form['options'][$current_type] = [
'#theme' => 'item_list',
+ '#list_type' => 'ul',
'#items' => $list,
'#prefix' => '',
'#suffix' => '
',
- );
+ ];
}
// Finally add javascript that will show/hide based on select box.
// Note: We used js here rather then ajax because drupal ajax had trouble finding the form.
- drupal_add_js('
- Drupal.behaviors.trpfancyFieldsQuickBrowse = {
- attach: function (context, settings) {
-
- // If the selectbox is set on page load, we should show the appropriate options.
- var selected = document.getElementById("edit-type").value;
- jQuery("#browse-options-"+selected).show();
-
- // Ensure that when the selectbox is changed, the options change.
- document.getElementById("edit-type").onchange = function (e) {
- // Hide all browser options
- jQuery(".browser-options").hide();
- // Show the browser options by removing display:none.
- jQuery("#browse-options-"+this.value).show();
- };
- }};
- ', 'inline');
+ $form['#attached']['html_head'][] = [
+ [
+ '#tag' => 'script',
+ '#attributes' => ['type' => 'text/javascript'],
+ '#value' => '
+ Drupal.behaviors.trpfancyFieldsQuickBrowse = {
+ attach: function (context, settings) {
+
+ // If the selectbox is set on page load, we should show the appropriate options.
+ var selected = document.getElementById("edit-type").value;
+ jQuery("#browse-options-"+selected).show();
+
+ // Ensure that when the selectbox is changed, the options change.
+ document.getElementById("edit-type").onchange = function (e) {
+ // Hide all browser options
+ jQuery(".browser-options").hide();
+ // Show the browser options by removing display:none.
+ jQuery("#browse-options-"+this.value).show();
+ };
+ }};
+ '
+ ],
+ ];
return $form;
}
@@ -464,5 +470,4 @@ function local__quick_browse_field_view_form($form, &$form_state) {
* @return
* Completed $form above.
*/
-function local__quick_browse_field_view_form_submit($form, &$form_state) { }
-
+function local__quick_browse_field_view_form_submit($form, &$form_state) { }
\ No newline at end of file
diff --git a/includes/TripalFields/local__quick_browse/local__quick_browse_widget.inc b/includes/TripalFields/local__quick_browse/local__quick_browse_widget.inc
index 271b5ae..63354bf 100644
--- a/includes/TripalFields/local__quick_browse/local__quick_browse_widget.inc
+++ b/includes/TripalFields/local__quick_browse/local__quick_browse_widget.inc
@@ -16,7 +16,7 @@ class local__quick_browse_widget extends TripalFieldWidget {
public static $default_label = 'Option Editor';
// The list of field types for which this formatter is appropriate.
- public static $field_types = array('local__quick_browse');
+ public static $field_types = ['local__quick_browse'];
/**
* Provides the form for editing of this field.
@@ -76,9 +76,8 @@ class local__quick_browse_widget extends TripalFieldWidget {
public function form(&$widget, &$form, &$form_state, $langcode, $items, $delta, $element) {
parent::form($widget, $form, $form_state, $langcode, $items, $delta, $element);
-
/**
- @todo: figure out how to save this!
+ @TODO: figure out how to save this!
I think I need to write a storage backend but there's currently no
documentation on how to do this. The validate method below gets called on the entity
edit form but the submit doesn't get called on either the entity or field edit form.
@@ -103,57 +102,61 @@ class local__quick_browse_widget extends TripalFieldWidget {
// If there are no types yet... tell the admin what to do.
if (empty($types)) {
- $widget['msg'] = array(
- '#type' => 'markup',
- '#markup' => ''
- .'You first need to set the Browser Types above, before you can set the default options for them.
'
- .'NOTE: You need to save the browser types first and then re-edit this field to set the options.'
- .'
'
- );
+ $widget['msg'] = [
+ '#type' => 'inline_template',
+ '#template' => ''
+ . 'You first need to set the Browser Types above, before you can set the default options for them.
'
+ . 'NOTE: You need to save the browser types first and then re-edit this field to set the options.'
+ . '
'
+ ];
}
else {
- $widget['value'] = array(
- '#type' => 'fieldset',
+ $widget['value'] = [
+ '#type' => 'details',
'#title' => ''.$this->instance['label'].' Options',
- '#tree' => TRUE,
+ '#open' => TRUE,
'#description' => 'Each section below corresponds to an option in the '.$this->instance['label'].' Browse drop-down. The options you provide will be used to create links for the user to browse.',
- );
+ ];
if (!$on_entity_edit_form) {
- $widget['value']['msg'] = array(
- '#type' => 'markup',
- '#markup' => ''
- .'The options you set below will become the default for all entities of this type. If you have selected "Dependant on the page shown" as the "option Source" above, then these options can be changed on the edit page.'
- .'
',
- '#weight' => -100,
- );
+ $widget['value']['msg'] = [
+ '#type' => 'inline_template',
+ '#template' => '
+
+
+
status message
+ The options you set below will become the default for all entities of this type. If you have selected "Dependant on the page shown" as the "option Source" above, then these options can be changed on the edit page.
+
+
'
+ ];
}
foreach ($types as $machine_name => $label) {
- $widget['value'][$machine_name] = array(
+ $widget['value'][$machine_name] = [
'#type' => 'textarea',
'#title' => '' . $label . ' Options',
'#description' => 'Enter the list of options you want to appear when the user selects "Browse '.$label.'". Each Option should be indicated on a seperate line using the key=value format
where the key is the value saved by the module and the value is the option shown to the user.',
- );
+ ];
if (isset($current_values[$machine_name])) {
$default_value = '';
+
foreach ($current_values[$machine_name] as $k => $v) {
$default_value .= "$k=$v\n";
}
- $widget['value'][$machine_name]['#value'] = $default_value;
+
+ $widget['value'][$machine_name]['#value'] = $default_value;
}
}
- $widget['value']['note'] = array(
- '#type' => 'markup',
- '#markup' => 'NOTE: It may be more efficient or perferrable to set the options via an SQL query
+ $widget['value']['note'] = [
+ '#type' => 'inline_template',
+ '#template' => 'NOTE: It may be more efficient or perferrable to set the options via an SQL query
(advanced users only). For options global to the field, insert into the trpfancy_browse_options table where the instance_id='.$this->instance['id'].'.
For options specific to each entity, insert into the trpfancy_browse_options_per_entity table where the instance_id='.$this->instance['id'].'.',
- '#weight' => 100,
- );
+ ];
}
*/
}
diff --git a/includes/TripalFields/local__quick_search/local__quick_search_formatter.inc b/includes/TripalFields/local__quick_search/local__quick_search_formatter.inc
index 8429a49..dface28 100644
--- a/includes/TripalFields/local__quick_search/local__quick_search_formatter.inc
+++ b/includes/TripalFields/local__quick_search/local__quick_search_formatter.inc
@@ -17,9 +17,9 @@ class local__quick_search_formatter extends TripalFieldFormatter {
// The default label for this field.
public static $default_label = 'Simple Quick Search';
// The list of field types for which this formatter is appropriate.
- public static $field_types = array('local__quick_search');
+ public static $field_types = ['local__quick_search'];
// The list of default settings for this formatter.
- public static $default_settings = array(
+ public static $default_settings = [
'path' => '',
'key' => 'value',
'help_text' => 'Enter your search terms below. On submit, a new page will be opened where additional search criteria are available.',
@@ -27,7 +27,7 @@ class local__quick_search_formatter extends TripalFieldFormatter {
'button_text' => 'Search',
'autocomplete_path' => '',
'filter_qstring' => '',
- );
+ ];
/**
* Provides the field's setting form.
@@ -68,68 +68,70 @@ class local__quick_search_formatter extends TripalFieldFormatter {
// Retrieve the current settings not handled by our parent.
$settings = $this->instance['display'][$view_mode]['settings'];
- $our_setting_keys = array('path', 'key', 'help_text', 'placeholder', 'button_text', 'autocomplete_path', 'filter_qstring');
+ $our_setting_keys = ['path', 'key', 'help_text', 'placeholder', 'button_text', 'autocomplete_path', 'filter_qstring'];
foreach ($our_setting_keys as $k) {
- if (!isset($settings[$k])) { $settings[$k] = self::$default_settings[$k]; }
+ if (!isset($settings[$k])) {
+ $settings[$k] = self::$default_settings[$k];
+ }
}
// This has caught me a couple of times so I'm going to remind both myself and others ;-p.
- $element['msg'] = array(
- '#type' => 'markup',
- '#markup' => 'Settings are only saved after you click "Update" within this box
AND "Save" at the bottom of the page!
',
- );
+ $element['msg'] = [
+ '#type' => 'inline_template',
+ '#template' => 'Settings are only saved after you click "Update" within this box
AND "Save" at the bottom of the page!
',
+ ];
- $element['path'] = array(
+ $element['path'] = [
'#type' => 'textfield',
'#title' => 'Search Path',
'#required' => TRUE,
'#description' => 'This is the relative path of the search page you would like to redirect the user to.',
'#default_value' => $settings['path'],
- );
+ ];
- $element['key'] = array(
+ $element['key'] = [
'#type' => 'textfield',
'#title' => 'Query Parameter Key',
'#required' => TRUE,
'#description' => 'This key is used in the query parameters to tell your full search which filter to apply the value to.',
'#default_value' => $settings['key'],
- );
+ ];
- $element['button_text'] = array(
+ $element['button_text'] = [
'#type' => 'textfield',
'#title' => 'Button Text',
'#required' => TRUE,
'#description' => 'The text on the search button.',
'#default_value' => $settings['button_text'],
- );
+ ];
- $element['placeholder'] = array(
+ $element['placeholder'] = [
'#type' => 'textfield',
'#title' => 'Placeholder Text',
'#description' => 'This will appear greyed out within the search textfield and should be used to tell your user the kinds of values they can enter.',
'#default_value' => $settings['placeholder'],
- );
+ ];
- $element['autocomplete_path'] = array(
+ $element['autocomplete_path'] = [
'#type' => 'textfield',
'#title' => 'Autocomplete Path',
'#description' => 'The path the AJAX autocomplete script uses as the source for autocompletion.',
'#default_value' => $settings['autocomplete_path'],
- );
+ ];
- $element['help_text'] = array(
+ $element['help_text'] = [
'#type' => 'textarea',
'#title' => 'Help Text',
'#description' => 'Guidance to your users for how to use the quick search form.',
'#default_value' => $settings['help_text'],
- );
+ ];
- $element['filter_qstring'] = array(
+ $element['filter_qstring'] = [
'#type' => 'textarea',
'#title' => 'Additional Filter Criteria',
'#description' => 'Use this field to add additional filter criteria to the URL query string upon submimt. Each additional criteria should be indicated on a seperate line using the key=value format. Tokens of the format `[field machine name]` can be used to make these filter dynamic.',
'#default_value' => $settings['filter_qstring'],
- );
+ ];
return $element;
}
@@ -166,7 +168,7 @@ class local__quick_search_formatter extends TripalFieldFormatter {
// We do this here so we can fill in the values of the fields
// and so we don't increase time during the redirect.
// Start our main paramter which will later be entered by the user.
- $settings['qparams'] = array($settings['key'] => '[value]');
+ $settings['qparams'] = [$settings['key'] => '[value]'];
// Then, if there are any additional query params, we will process them line-by-line.
// @assumption: each additional query param is on it's own line.
@@ -178,14 +180,14 @@ class local__quick_search_formatter extends TripalFieldFormatter {
$line = trim($line);
// Check if there's a field token & if so, replace it.
- $matches = array();
+ $matches = [];
if (preg_match('/\[(\w+)\]/', $line, $matches)) {
$key = '[' . $matches[1] . ']';
$values = field_get_items($entity_type, $entity, $matches[1]);
if ($values === FALSE) {
tripal_report_error('trpfancy_fields', TRIPAL_WARNING,
'Quick Search Field %name: %token not found, replaced with empty string.',
- array('$name' => $this->instance['field_name'], '%token' => $key));
+ ['$name' => $this->instance['field_name'], '%token' => $key]);
}
foreach ($values as $v) {
@@ -195,7 +197,7 @@ class local__quick_search_formatter extends TripalFieldFormatter {
}
// Extract the key and value to add to the params list.
- $matches = array();
+ $matches = [];
if (preg_match('/^(\w+\[*\]*)=(\w+)$/', $line, $matches)) {
$settings['qparams'][$matches[1]] = $matches[2];
}
@@ -206,10 +208,10 @@ class local__quick_search_formatter extends TripalFieldFormatter {
$form = drupal_get_form('local__quick_search_field_view_form', $settings);
// Render it and pass it as the markup for this field.
- $element[0] = array(
+ $element[0] = [
'#type' => 'markup',
'#markup' => drupal_render($form),
- );
+ ];
return $element;
}
@@ -271,7 +273,7 @@ function local__quick_search_field_view_form($form, &$form_state) {
// Retrieve the formatter settings from thr build info.
$settings = $form_state['build_info']['args'][0];
- $form['#attached']['css'][] = array(
+ $form['#attached']['css'][] = [
'type' => 'inline',
'data' => '
.field-type-local--quick-search .help-text {
@@ -290,48 +292,47 @@ function local__quick_search_field_view_form($form, &$form_state) {
width: 98%;
}
',
- );
+ ];
- $form['path'] = array(
+ $form['path'] = [
'#type' => 'hidden',
'#value' => $settings['path'],
- );
+ ];
- $form['key'] = array(
+ $form['key'] = [
'#type' => 'hidden',
'#value' => $settings['key'],
- );
+ ];
- $form['qparams'] = array(
+ $form['qparams'] = [
'#type' => 'hidden',
'#value' => $settings['qparams'],
- );
+ ];
- $form['help_text'] = array(
- '#type' => 'markup',
- '#markup' => '' . $settings['help_text'] . '',
- );
+ $form['help_text'] = [
+ '#type' => 'inline_template',
+ '#template' => '' . $settings['help_text'] . '',
+ ];
- $form['search'] = array(
- '#type' => 'markup',
+ $form['search'] = [
'#prefix' => '',
'#suffix' => '
',
- );
+ ];
- $form['search']['value'] = array(
+ $form['search']['value'] = [
'#type' => 'textfield',
'#title' => 'Search Terms',
'#title_display' => 'invisible',
- '#attributes' => array(
+ '#attributes' => [
'placeholder' => $settings['placeholder'],
- ),
+ ],
'#autocomplete_path' => $settings['autocomplete_path'],
- );
+ ];
- $form['search']['submit'] = array(
+ $form['search']['submit'] = [
'#type' => 'submit',
'#value' => $settings['button_text'],
- );
+ ];
return $form;
}
@@ -353,8 +354,8 @@ function local__quick_search_field_view_form_submit($form, &$form_state) {
$form_state['values']['qparams'][$form_state['values']['key']] = $form_state['values']['value'];
- $form_state['redirect'] = array(
+ $form_state['redirect'] = [
$form_state['values']['path'],
- array( 'query' => $form_state['values']['qparams'] ),
- );
+ ['query' => $form_state['values']['qparams']],
+ ];
}
diff --git a/includes/TripalFields/local__quick_search/local__quick_search_widget.inc b/includes/TripalFields/local__quick_search/local__quick_search_widget.inc
index 0e3ad35..209bfec 100644
--- a/includes/TripalFields/local__quick_search/local__quick_search_widget.inc
+++ b/includes/TripalFields/local__quick_search/local__quick_search_widget.inc
@@ -11,7 +11,7 @@ class local__quick_search_widget extends TripalFieldWidget {
public static $default_label = 'No Edits';
// The list of field types for which this formatter is appropriate.
- public static $field_types = array('local__quick_search');
+ public static $field_types = ['local__quick_search'];
/**
* Provides the form for editing of this field.
diff --git a/includes/TripalFields/local__single_series_bar_chart/local__single_series_bar_chart_formatter.inc b/includes/TripalFields/local__single_series_bar_chart/local__single_series_bar_chart_formatter.inc
index be7f213..027d442 100644
--- a/includes/TripalFields/local__single_series_bar_chart/local__single_series_bar_chart_formatter.inc
+++ b/includes/TripalFields/local__single_series_bar_chart/local__single_series_bar_chart_formatter.inc
@@ -16,7 +16,7 @@ class local__single_series_bar_chart_formatter extends ChadoChartFormatter {
public static $default_label = 'Single-Series Bar Chart';
// The list of field types for which this formatter is appropriate.
- public static $field_types = array('local__single_series_chart');
+ public static $field_types = ['local__single_series_chart'];
/**
* Provides the display for a field
@@ -59,56 +59,91 @@ class local__single_series_bar_chart_formatter extends ChadoChartFormatter {
if (!empty($items[0]['value'])) {
// Process items to expose to JS.
- $data = array();
+ $data = [];
foreach ($items as $key => $value) {
foreach ($value['value']['hydra:member'] as $part) {
- $data[] = array(
+ $data[] = [
'label' => $part['rdfs:label'],
'count' => $part['local:count'],
- );
+ ];
}
}
- // Expose the data & settings to JS.
- drupal_add_js(array('trpfancyFields' => array($field_name => $data)), 'setting');
-
- // Load the Tripal D3 API
- tripald3_load_libraries();
-
- drupal_add_js('
- Drupal.behaviors.'.$field_name.' = {
- attach: function (context, settings) {
-
- // Pull the data out of the javascript settings.
- var data = Drupal.settings.trpfancyFields.'.$field_name.';
-
- // Draw your chart.
- tripalD3.drawFigure(
- data,
- {
- "chartType" : "simplebar",
- "elementId": "trpfancy-'.$field_name.'",
- "height": 250,
- "width": 500,
- "keyPosition": "right",
- "title": "' . $settings['title'] . '",
- "legend": "' . $settings['legend'] . '",
+ // Load the Tripal D3 Libraries.
+ $element['#attached']['library'][] = 'tripald3/D3';
+ $element['#attached']['library'][] = 'tripald3/D3';
+
+ // CORE
+ $element['#attached']['library'][] = 'tripald3/D3';
+ $element['#attached']['library'][] = 'tripald3/tripalD3';
+
+ // CHARTS
+ // Pie
+ $element['#attached']['library'][] = 'tripald3/lib-pie';
+ $element['#attached']['library'][] = 'tripald3/lib-bar';
+ 'tripald3/lib-pedigree',
+
+ // CREATE
+ $element['#attached']['library'][] = 'tripald3/create-multidonut';
+ $element['#attached']['library'][] = 'tripald3/create-pie';
+ $element['#attached']['library'][] = 'tripald3/create-multiseriesdonut';
+ $element['#attached']['library'][] = 'tripald3/create-bar';
+ $element['#attached']['library'][] = 'tripald3/create-pedigree';
+
+ // STYLE
+ $element['#attached']['library'][] = 'tripald3/style-tripald3';
+
+ // SETTINGS
+ // Color scheme configuration.
+ $default_scheme = \Drupal::service('tripald3.TripalD3ColorScheme')
+ ->registerColorScheme();
+ $to_Drupalsettings['tripalD3']['vars']['colorScheme'] = $default_scheme;
+
+ // Auto resize configuration.
+ $default_resize = $this->config('tripald3.settings')
+ ->get('tripald3_autoResize');
+ $to_Drupalsettings['tripalD3']['vars']['autoResize'] = $default_resize;
+ $to_Drupalsettings['trpfancyFields'][ $field_name ] = $data;
+
+ $element['#attached']['drupalSettings'] = $to_Drupalsettings;
+
+ $element['#attached']['html_head'][] = [
+ [
+ '#tag' => 'script',
+ '#attributes' => ['type' => 'text/javascript'],
+ '#value' => '
+ Drupal.behaviors.'.$field_name.' = {
+ attach: function (context, settings) {
+
+ // Pull the data out of the javascript settings.
+ var data = drupalSettings.trpfancyFields.'.$field_name.';
+
+ // Draw your chart.
+ tripalD3.drawFigure(
+ data,
+ {
+ "chartType" : "simplebar",
+ "elementId": "trpfancy-'.$field_name.'",
+ "height": 250,
+ "width": 500,
+ "keyPosition": "right",
+ "title": "' . $settings['title'] . '",
+ "legend": "' . $settings['legend'] . '",
+ }
+ );
}
- );
- }
- };',
- array('type' => 'inline')
- );
+ };'
+ ],
+ ];
// Finally, add the markup.
- $element[0] = array(
- '#type' => 'markup',
- '#markup' => '
+ $element[0] = [
+ '#type' => 'inline_template',
+ '#template' => '
',
- );
-
+ ];
}
}
}
diff --git a/includes/TripalFields/local__single_series_chart/local__single_series_chart.inc b/includes/TripalFields/local__single_series_chart/local__single_series_chart.inc
index 34c0fa1..d1c1c66 100644
--- a/includes/TripalFields/local__single_series_chart/local__single_series_chart.inc
+++ b/includes/TripalFields/local__single_series_chart/local__single_series_chart.inc
@@ -66,28 +66,28 @@ class local__single_series_chart extends ChadoChartField {
// Allow the parent Tripal Field to set up the form element for us.
$element = parent::instanceSettingsForm();
- $element['data_options']['data_msg'] = array(
+ $element['data_options']['data_msg'] = [
'#type' => 'item',
'#markup' => 'Each series of data in this chart consists of multiple "categories" where each category has a label and a count. For example, a chart showing the types of features for a given organism would have labels such as "gene", "genetic marker", "SNP" and the counts would indicate the number of genes, genetic markers and SNPs available for the given organism.',
- );
+ ];
// The column whose value should be the category labels on the chart.
- $element['data_options']['label_column'] = array(
+ $element['data_options']['label_column'] = [
'#type' => 'textfield',
'#required' => TRUE,
'#title' => 'Label Column',
'#description' => 'The column from the materialized view whose value should be the category labels within a single series of data.',
'#default_value' => $settings['data_options']['label_column'],
- );
+ ];
// The column containing the numbers determining the category size.
- $element['data_options']['count_column'] = array(
+ $element['data_options']['count_column'] = [
'#type' => 'textfield',
'#required' => TRUE,
'#title' => 'Count Column',
'#description' => 'The column from the materialized view whose value should be the category count within a single series of data.',
'#default_value' => $settings['data_options']['count_column'],
- );
+ ];
return $element;
}
@@ -104,14 +104,14 @@ class local__single_series_chart extends ChadoChartField {
if (!chado_column_exists($values['materialized_view'], $values['label_column'])) {
form_set_error('instance][settings][data_options][label_column',
t('The Label Column must exist in the %mview materialized view',
- array('%mview' => $values['materialized_view'])));
+ ['%mview' => $values['materialized_view']]));
}
// Check the count column exists.
if (!chado_column_exists($values['materialized_view'], $values['count_column'])) {
form_set_error('instance][settings][data_options][count_column',
t('The Count Column must exist in the %mview materialized view',
- array('%mview' => $values['materialized_view'])));
+ ['%mview' => $values['materialized_view']]));
}
}
}
diff --git a/includes/TripalFields/local__single_series_chart/local__single_series_chart_formatter.inc b/includes/TripalFields/local__single_series_chart/local__single_series_chart_formatter.inc
index 67e608a..c81b38f 100644
--- a/includes/TripalFields/local__single_series_chart/local__single_series_chart_formatter.inc
+++ b/includes/TripalFields/local__single_series_chart/local__single_series_chart_formatter.inc
@@ -16,13 +16,13 @@ class local__single_series_chart_formatter extends ChadoChartFormatter {
public static $default_label = 'Single-Series Table';
// The list of field types for which this formatter is appropriate.
- public static $field_types = array('local__single_series_chart');
+ public static $field_types = ['local__single_series_chart'];
// The list of default settings for this formatter.
// Due to the different charts available and the dependance upon the data,
// it is too difficult to make a good default for the title and legend.
// As such I am making a horrible one in the hopes of making admin change it ;-p.
- public static $default_settings = array(
+ public static $default_settings = [
'title' => 'Fancy Chart summarizing Stuff',
'legend' => 'This should describe the chart including the data that goes into it and how to interpret that data. Furthermore, it is always a good idea to highlight how users can interact with this chart.',
// Supports either 'top' or 'bottom'. This refers to the legend only,
@@ -30,7 +30,7 @@ class local__single_series_chart_formatter extends ChadoChartFormatter {
'legend_pos' => 'top',
// Supports either 'data' or 'info'.
'table_type' => 'data',
- );
+ ];
/**
* Provides the field's setting form.
@@ -74,21 +74,21 @@ class local__single_series_chart_formatter extends ChadoChartFormatter {
if (!isset($settings['legend_pos'])) { $settings['legend_pos'] = self::$default_settings['legend_pos']; }
if (!isset($settings['table_type'])) { $settings['table_type'] = self::$default_settings['table_type']; }
- $element['legend_pos'] = array(
+ $element['legend_pos'] = [
'#type' => 'radios',
'#title' => 'Legend Postion',
'#description' => 'The position of the "Figure Legend" text filled out above in respect to the table itself.',
- '#options' => array('top' => 'top', 'bottom' => 'bottom'),
+ '#options' => ['top' => 'top', 'bottom' => 'bottom'],
'#default_value' => $settings['legend_pos'],
- );
+ ];
- $element['table_type'] = array(
+ $element['table_type'] = [
'#type' => 'radios',
'#title' => 'Table Type',
'#description' => 'The type of table to generate where data refers to the typical data table with header on top and info refers to the typical Tripal info tables where the header is down the side and consists of your category labels.',
- '#options' => array('data' => 'data', 'info' => 'info'),
+ '#options' => ['data' => 'data', 'info' => 'info'],
'#default_value' => $settings['table_type'],
- );
+ ];
return $element;
}
@@ -133,8 +133,43 @@ class local__single_series_chart_formatter extends ChadoChartFormatter {
if (isset($items[0]) && !empty($items[0]['value'])) {
- // Load the Tripal D3 API
- tripald3_load_libraries();
+ // Load the Tripal D3 Libraries.
+ $element['#attached']['library'][] = 'tripald3/D3';
+ $element['#attached']['library'][] = 'tripald3/D3';
+
+ // CORE
+ $element['#attached']['library'][] = 'tripald3/D3';
+ $element['#attached']['library'][] = 'tripald3/tripalD3';
+
+ // CHARTS
+ // Pie
+ $element['#attached']['library'][] = 'tripald3/lib-pie';
+ $element['#attached']['library'][] = 'tripald3/lib-bar';
+ 'tripald3/lib-pedigree',
+
+ // CREATE
+ $element['#attached']['library'][] = 'tripald3/create-multidonut';
+ $element['#attached']['library'][] = 'tripald3/create-pie';
+ $element['#attached']['library'][] = 'tripald3/create-multiseriesdonut';
+ $element['#attached']['library'][] = 'tripald3/create-bar';
+ $element['#attached']['library'][] = 'tripald3/create-pedigree';
+
+ // STYLE
+ $element['#attached']['library'][] = 'tripald3/style-tripald3';
+
+ // SETTINGS
+ // Color scheme configuration.
+ $default_scheme = \Drupal::service('tripald3.TripalD3ColorScheme')
+ ->registerColorScheme();
+ $to_Drupalsettings['tripalD3']['vars']['colorScheme'] = $default_scheme;
+
+ // Auto resize configuration.
+ $default_resize = $this->config('tripald3.settings')
+ ->get('tripald3_autoResize');
+ $to_Drupalsettings['tripalD3']['vars']['autoResize'] = $default_resize;
+
+ $element['#attached']['drupalSettings'] = $to_Drupalsettings;
+
// Defaults based on table type.
// -- Info.
@@ -143,12 +178,11 @@ class local__single_series_chart_formatter extends ChadoChartFormatter {
// our data includes the header (first column).
$header = NULL;
$column_is_header = TRUE;
-
-
}
+
// -- Data (default).
else {
- $header = array('label' => 'Category', 'count' => 'Amount');
+ $header = ['label' => 'Category', 'count' => 'Amount'];
$column_is_header = FALSE;
}
@@ -166,15 +200,15 @@ class local__single_series_chart_formatter extends ChadoChartFormatter {
}
// Format the data.
- $rows = array();
+ $rows = [];
foreach ($items as $key => $value) {
foreach ($value['value']['hydra:member'] as $part) {
// Compile the row.
- $row = array(
- 'label' => array('data' => $part['rdfs:label']),
+ $row = [
+ 'label' => ['data' => $part['rdfs:label']],
'count' => number_format($part['local:count']),
- );
+ ];
// Indicate if the first column should be a header.
if ($column_is_header) {
@@ -187,21 +221,20 @@ class local__single_series_chart_formatter extends ChadoChartFormatter {
}
// Finally, add the markup.
- $element[0] = array(
- '#type' => 'markup',
- '#theme' => 'table',
+ $element[0] = [
+ '#type' => 'table',
+ '#title' => $caption,
'#header' => $header,
'#rows' => $rows,
- '#attributes' => array(
- 'class' => array('tripald3-chart', $settings['table_type']),
- ),
- '#caption' => $caption,
- );
+ '#empty' => t('0 Items in this table'),
+ '#attributes' => [
+ 'class' => ['tripald3-chart', $settings['table_type']],
+ ]
+ ];
if ($footer) {
$element[0]['#suffix'] = '';
}
-
}
}
}
diff --git a/includes/TripalFields/local__single_series_donut_chart/local__single_series_donut_chart_formatter.inc b/includes/TripalFields/local__single_series_donut_chart/local__single_series_donut_chart_formatter.inc
index 1cf53cf..ede9984 100644
--- a/includes/TripalFields/local__single_series_donut_chart/local__single_series_donut_chart_formatter.inc
+++ b/includes/TripalFields/local__single_series_donut_chart/local__single_series_donut_chart_formatter.inc
@@ -16,7 +16,7 @@ class local__single_series_donut_chart_formatter extends ChadoChartFormatter {
public static $default_label = 'Single-Series Donut Chart';
// The list of field types for which this formatter is appropriate.
- public static $field_types = array('local__single_series_chart');
+ public static $field_types = ['local__single_series_chart'];
/**
* Provides the display for a field
@@ -59,56 +59,91 @@ class local__single_series_donut_chart_formatter extends ChadoChartFormatter {
if (!empty($items[0]['value'])) {
// Process items to expose to JS.
- $data = array();
+ $data = [];
foreach ($items as $key => $value) {
foreach ($value['value']['hydra:member'] as $part) {
- $data[] = array(
+ $data[] = [
'label' => $part['rdfs:label'],
'count' => $part['local:count'],
- );
+ ];
}
}
- // Expose the data & settings to JS.
- drupal_add_js(array('trpfancyFields' => array($field_name => $data)), 'setting');
-
- // Load the Tripal D3 API
- tripald3_load_libraries();
-
- drupal_add_js('
- Drupal.behaviors.'.$field_name.' = {
- attach: function (context, settings) {
-
- // Pull the data out of the javascript settings.
- var data = Drupal.settings.trpfancyFields.'.$field_name.';
-
- // Draw your chart.
- tripalD3.drawFigure(
- data,
- {
- "chartType" : "simpledonut",
- "elementId": "trpfancy-'.$field_name.'",
- "height": 250,
- "width": 500,
- "keyPosition": "right",
- "title": "' . $settings['title'] . '",
- "legend": "' . $settings['legend'] . '",
+ // Load the Tripal D3 Libraries.
+ $element['#attached']['library'][] = 'tripald3/D3';
+ $element['#attached']['library'][] = 'tripald3/D3';
+
+ // CORE
+ $element['#attached']['library'][] = 'tripald3/D3';
+ $element['#attached']['library'][] = 'tripald3/tripalD3';
+
+ // CHARTS
+ // Pie
+ $element['#attached']['library'][] = 'tripald3/lib-pie';
+ $element['#attached']['library'][] = 'tripald3/lib-bar';
+ 'tripald3/lib-pedigree',
+
+ // CREATE
+ $element['#attached']['library'][] = 'tripald3/create-multidonut';
+ $element['#attached']['library'][] = 'tripald3/create-pie';
+ $element['#attached']['library'][] = 'tripald3/create-multiseriesdonut';
+ $element['#attached']['library'][] = 'tripald3/create-bar';
+ $element['#attached']['library'][] = 'tripald3/create-pedigree';
+
+ // STYLE
+ $element['#attached']['library'][] = 'tripald3/style-tripald3';
+
+ // SETTINGS
+ // Color scheme configuration.
+ $default_scheme = \Drupal::service('tripald3.TripalD3ColorScheme')
+ ->registerColorScheme();
+ $to_Drupalsettings['tripalD3']['vars']['colorScheme'] = $default_scheme;
+
+ // Auto resize configuration.
+ $default_resize = $this->config('tripald3.settings')
+ ->get('tripald3_autoResize');
+ $to_Drupalsettings['tripalD3']['vars']['autoResize'] = $default_resize;
+ $to_Drupalsettings['trpfancyFields'][ $field_name ] = $data;
+
+ $element['#attached']['drupalSettings'] = $to_Drupalsettings;
+
+ $element['#attached']['html_head'][] = [
+ [
+ '#tag' => 'script',
+ '#attributes' => ['type' => 'text/javascript'],
+ '#value' => '
+ Drupal.behaviors.'.$field_name.' = {
+ attach: function (context, settings) {
+
+ // Pull the data out of the javascript settings.
+ var data = drupalSettings.trpfancyFields.'.$field_name.';
+
+ // Draw your chart.
+ tripalD3.drawFigure(
+ data,
+ {
+ "chartType" : "simpledonut",
+ "elementId": "trpfancy-'.$field_name.'",
+ "height": 250,
+ "width": 500,
+ "keyPosition": "right",
+ "title": "' . $settings['title'] . '",
+ "legend": "' . $settings['legend'] . '",
+ }
+ );
}
- );
- }
- };',
- array('type' => 'inline')
- );
+ };',
+ ],
+ ];
// Finally, add the markup.
- $element[0] = array(
- '#type' => 'markup',
- '#markup' => '
+ $element[0] = [
+ '#type' => 'inline_template',
+ '#template' => '
',
- );
-
+ ];
}
}
}
diff --git a/includes/TripalFields/local__single_series_pie_chart/local__single_series_pie_chart_formatter.inc b/includes/TripalFields/local__single_series_pie_chart/local__single_series_pie_chart_formatter.inc
index 09d4b91..3a86263 100644
--- a/includes/TripalFields/local__single_series_pie_chart/local__single_series_pie_chart_formatter.inc
+++ b/includes/TripalFields/local__single_series_pie_chart/local__single_series_pie_chart_formatter.inc
@@ -16,7 +16,7 @@ class local__single_series_pie_chart_formatter extends ChadoChartFormatter {
public static $default_label = 'Single-Series Pie Chart';
// The list of field types for which this formatter is appropriate.
- public static $field_types = array('local__single_series_chart');
+ public static $field_types = ['local__single_series_chart'];
/**
* Provides the display for a field
@@ -59,56 +59,91 @@ class local__single_series_pie_chart_formatter extends ChadoChartFormatter {
if (!empty($items[0]['value'])) {
// Process items to expose to JS.
- $data = array();
+ $data = [];
foreach ($items as $key => $value) {
foreach ($value['value']['hydra:member'] as $part) {
- $data[] = array(
+ $data[] = [
'label' => $part['rdfs:label'],
'count' => $part['local:count'],
- );
+ ];
}
}
- // Expose the data & settings to JS.
- drupal_add_js(array('trpfancyFields' => array($field_name => $data)), 'setting');
-
- // Load the Tripal D3 API
- tripald3_load_libraries();
-
- drupal_add_js('
- Drupal.behaviors.'.$field_name.' = {
- attach: function (context, settings) {
-
- // Pull the data out of the javascript settings.
- var data = Drupal.settings.trpfancyFields.'.$field_name.';
-
- // Draw your chart.
- tripalD3.drawFigure(
- data,
- {
- "chartType" : "simplepie",
- "elementId": "trpfancy-'.$field_name.'",
- "height": 250,
- "width": 500,
- "keyPosition": "right",
- "title": "' . $settings['title'] . '",
- "legend": "' . $settings['legend'] . '",
+ // Load the Tripal D3 Libraries.
+ $element['#attached']['library'][] = 'tripald3/D3';
+ $element['#attached']['library'][] = 'tripald3/D3';
+
+ // CORE
+ $element['#attached']['library'][] = 'tripald3/D3';
+ $element['#attached']['library'][] = 'tripald3/tripalD3';
+
+ // CHARTS
+ // Pie
+ $element['#attached']['library'][] = 'tripald3/lib-pie';
+ $element['#attached']['library'][] = 'tripald3/lib-bar';
+ 'tripald3/lib-pedigree',
+
+ // CREATE
+ $element['#attached']['library'][] = 'tripald3/create-multidonut';
+ $element['#attached']['library'][] = 'tripald3/create-pie';
+ $element['#attached']['library'][] = 'tripald3/create-multiseriesdonut';
+ $element['#attached']['library'][] = 'tripald3/create-bar';
+ $element['#attached']['library'][] = 'tripald3/create-pedigree';
+
+ // STYLE
+ $element['#attached']['library'][] = 'tripald3/style-tripald3';
+
+ // SETTINGS
+ // Color scheme configuration.
+ $default_scheme = \Drupal::service('tripald3.TripalD3ColorScheme')
+ ->registerColorScheme();
+ $to_Drupalsettings['tripalD3']['vars']['colorScheme'] = $default_scheme;
+
+ // Auto resize configuration.
+ $default_resize = $this->config('tripald3.settings')
+ ->get('tripald3_autoResize');
+ $to_Drupalsettings['tripalD3']['vars']['autoResize'] = $default_resize;
+ $to_Drupalsettings['trpfancyFields'][ $field_name ] = $data;
+
+ $element['#attached']['drupalSettings'] = $to_Drupalsettings;
+
+ $element['#attached']['html_head'][] = [
+ [
+ '#tag' => 'script',
+ '#attributes' => ['type' => 'text/javascript'],
+ '#value' => '
+ Drupal.behaviors.'.$field_name.' = {
+ attach: function (context, settings) {
+
+ // Pull the data out of the javascript settings.
+ var data = drupalSettings.trpfancyFields.'.$field_name.';
+
+ // Draw your chart.
+ tripalD3.drawFigure(
+ data,
+ {
+ "chartType" : "simplepie",
+ "elementId": "trpfancy-'.$field_name.'",
+ "height": 250,
+ "width": 500,
+ "keyPosition": "right",
+ "title": "' . $settings['title'] . '",
+ "legend": "' . $settings['legend'] . '",
+ }
+ );
}
- );
- }
- };',
- array('type' => 'inline')
- );
+ };',
+ ],
+ ];
// Finally, add the markup.
- $element[0] = array(
- '#type' => 'markup',
- '#markup' => '
+ $element[0] = [
+ '#type' => 'inline_template',
+ '#template' => '
',
- );
-
+ ];
}
}
diff --git a/includes/trpfancy_fields.fields.inc b/includes/trpfancy_fields.fields.inc
index 339edfe..15cfd0c 100644
--- a/includes/trpfancy_fields.fields.inc
+++ b/includes/trpfancy_fields.fields.inc
@@ -4,6 +4,9 @@
* Contains all field specific code outside the classes.
*/
+use Drupal\field\Entity\FieldStorageConfig;
+use Drupal\field\Entity\FieldConfig;
+
/**
* Implements hook_bundle_create_user_field().
*
@@ -17,50 +20,51 @@
* and that can be added dynamically will result in a call to this function.
*/
function trpfancy_fields_bundle_create_user_field($new_field, $bundle) {
-
$field_name = $new_field['field_name'];
$field_type = $new_field['type'];
+
// @todo: make the description depend on the field type.
// Currently there is only one field so this is fine.
$description = 'A type of graph in which all the data is part of a single series. Specifically, the dataset consists of labels and corresponding values.';
// Create the field.
- $field = array(
+ $field = [
'field_name' => $field_name,
'type' => $field_type,
'cardinality' => 1,
'locked' => FALSE,
- 'storage' => array(
- 'type' => 'tripal_no_storage',
- ),
- );
- field_create_field($field);
+ 'storage' => ['type' => 'tripal_no_storage'],
+ ];
+
+ $field_storage = FieldStorageConfig::create($field);
+ $field_storage->save();
// Then create the instance.
- $instance = array(
+ $instance = [
'field_name' => $field_name,
'entity_type' => $bundle->type,
'bundle' => $bundle->name,
'label' => $new_field['label'],
'description' => $description,
'required' => FALSE,
- 'settings' => array(
+ 'settings' =>[
'auto_attach' => FALSE,
- ),
- 'widget' => array(
+ ],
+ 'widget' =>[
// @ASSUMPTION: Assumes there is a widget that matches the field type.
'type' => $field_type . '_widget',
- 'settings' => array(),
- ),
- 'display' => array(
- 'default' => array(
+ 'settings' =>[],
+ ],
+ 'display' =>[
+ 'default' =>[
'label' => 'hidden',
// @ASSUMPTION: Assumes there is a formatter that matches the field type.
'type' => $field_name . '_formatter',
- 'settings' => array(),
- ),
- ),
+ 'settings' =>[],
+ ],
+ ],
);
- field_create_instance($instance);
-
+
+ $field_instance = FieldConfig::create($instance);
+ $field_instance->save();
}
\ No newline at end of file
diff --git a/src/Controller/TripalFancyFieldsConfigureController.php b/src/Controller/TripalFancyFieldsConfigureController.php
new file mode 100644
index 0000000..c857e93
--- /dev/null
+++ b/src/Controller/TripalFancyFieldsConfigureController.php
@@ -0,0 +1,25 @@
+ 'theme-tripal-fancyfields-configure',
+ '#attached' => []
+ ];
+ }
+}
\ No newline at end of file
diff --git a/src/Form/TripalFancyFieldsDataIdForm.php b/src/Form/TripalFancyFieldsDataIdForm.php
new file mode 100644
index 0000000..e87a533
--- /dev/null
+++ b/src/Form/TripalFancyFieldsDataIdForm.php
@@ -0,0 +1,88 @@
+config(static::SETTINGS);
+
+ // System variable used to store prefix value:
+ // NOTE: this variable is used by data__identifier field.
+ $cur_prefix = $config->get('tripal_fancyfields_identifier_config.prefix');
+
+ // Show an example of the prefix in action.
+ $form['preview_prefix'] = [
+ '#type' => 'inline_template',
+ '#template' => 'Example (Prefix + ID#):
+ ' . $cur_prefix . '' . mt_rand(7777, 9999) . '
',
+ ];
+
+ // Prefix field.
+ $form['fld_text_identifier_prefix'] = [
+ '#type' => 'textfield',
+ '#title' => $this->t('Prefix'),
+ '#description' => $this->t('Prefix used to generate uniquename for Identifier field.'),
+ '#default_value' => $cur_prefix,
+ '#required' => TRUE,
+ ];
+
+ return parent::buildForm($form, $form_state);
+ }
+
+ /**
+ * {@inheritdoc}
+ * Validate configuration.
+ */
+ public function validateForm(array &$form, FormStateInterface $form_state) {
+ }
+
+ /**
+ * {@inheritdoc}
+ * Save configuration.
+ */
+ public function submitForm(array &$form, FormStateInterface $form_state) {
+ $fld_value_prefix = $form_state->getValue('fld_text_identifier_prefix');
+
+ $this->configFactory->getEditable(static::SETTINGS)
+ ->set('tripal_fancyfields_identifier_config.prefix', $fld_value_prefix)
+ ->save();
+
+ return parent::submitForm($form, $form_state);
+ }
+}
\ No newline at end of file
diff --git a/templates/template-tripal-fancyfields-configure.html.twig b/templates/template-tripal-fancyfields-configure.html.twig
new file mode 100755
index 0000000..c91cc0c
--- /dev/null
+++ b/templates/template-tripal-fancyfields-configure.html.twig
@@ -0,0 +1,16 @@
+{#
+/**
+ * @file
+ * Default theme implementation of Tripal Fancy Fields Configure Field.
+ */
+#}
+
+
+ Configure Data Identifier Prefix
+
+
+ Provides interface for configuring prefix used to auto-generate uniquename/identifier.
+ {{ context_links.configure_dataid }}
+
+
+
diff --git a/trpfancy_fields.info b/trpfancy_fields.info
deleted file mode 100644
index b255e42..0000000
--- a/trpfancy_fields.info
+++ /dev/null
@@ -1,10 +0,0 @@
-name = Tripal Fancy Fields
-description = Provides additional fields to jazz up your Tripal Content Pages
-core = 7.x
-package = Tripal Extensions
-dependencies[] = tripal
-dependencies[] = tripald3
-
-files[] = includes/TripalFields/ChadoChartField.inc
-files[] = includes/TripalFields/ChadoChartFormatter.inc
-files[] = includes/TripalFields/local__single_series_chart/local__single_series_chart.inc
diff --git a/trpfancy_fields.info.yml b/trpfancy_fields.info.yml
new file mode 100644
index 0000000..6d1c1d1
--- /dev/null
+++ b/trpfancy_fields.info.yml
@@ -0,0 +1,11 @@
+name: 'Tripal Fancy Fields'
+description: 'Provides additional fields to jazz up your Tripal Content Pages'
+package: 'Tripal Extensions'
+
+type: module
+core: 8.x
+configure: tripal_blast.configure
+
+dependencies:
+ - tripal:tripal
+ - tripald3:tripald3
\ No newline at end of file
diff --git a/trpfancy_fields.install b/trpfancy_fields.install
index 1ede492..d3177e9 100644
--- a/trpfancy_fields.install
+++ b/trpfancy_fields.install
@@ -97,15 +97,4 @@ function trpfancy_fields_schema() {
);
return $schema;
-}
-
-/**
- * Add Quick Browse option tables.
- */
-function trpfancy_fields_update_7001(&$sandbox) {
-
- $schema = trpfancy_fields_schema();
- db_create_table('trpfancy_browse_options', $schema['trpfancy_browse_options']);
- db_create_table('trpfancy_browse_options_per_entity', $schema['trpfancy_browse_options_per_entity']);
-
-}
+}
\ No newline at end of file
diff --git a/trpfancy_fields.libraries.yml b/trpfancy_fields.libraries.yml
new file mode 100644
index 0000000..cf7b6e2
--- /dev/null
+++ b/trpfancy_fields.libraries.yml
@@ -0,0 +1,16 @@
+# @file
+# Tripal Fancy Fields libraries.
+
+# Library used in field configurations.
+tripal-fancyfields-config:
+ version: 1.x
+ css:
+ theme:
+ css/tripal-fancyfields-config.css: {}
+
+# co_010 Field library.
+tripal-fancyfields-co-010:
+ version: 1.x
+ js:
+ theme:
+ includes/TripalFields/co_010__parentage_of_pedigree/theme/js/script.js: {}
\ No newline at end of file
diff --git a/trpfancy_fields.module b/trpfancy_fields.module
old mode 100644
new mode 100755
index b021908..c522321
--- a/trpfancy_fields.module
+++ b/trpfancy_fields.module
@@ -1,89 +1,34 @@
'local',
- 'id' => 'local:quick_search',
- 'name' => 'Quick Search',
- 'definition' => 'Provide a quick search on entity pages which submits/redirects to a full search.',
- ),
- );
-
- // Now add each term.
- foreach ($terms as $term) {
- tripal_insert_cvterm($term);
- }
-}
-
-
-/**
- * Implements hook_menu().
- */
-function trpfancy_fields_menu() {
- // Menu home.
- $items['admin/tripal/extension/trpfancyfields'] = array(
- 'title' => 'Tripal Fancy Fields',
- 'description' => 'Tripal Fancy Fields.',
- 'access arguments' => array('administer tripal'),
- );
+function trpfancy_fields_theme($existing, $type, $theme, $path) {
+ $context_links = [
+ 'configure_dataid' => ['form' => 'tripal_fancyfields.configure_data_id']
+ ];
- // ADMISTRATIVE PAGE:
- // A page for changing prefix used to generate uniquename in Identifier field.
- // NOTE: this variable is used by data__identifier field.
- $items['admin/tripal/extension/trpfancyfields/prefix'] = array(
- 'title' => 'Configure Data Identifier Prefix',
- 'description' => t('Provides interface for configuring prefix used to auto-generate uniquename/identifier.'),
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('trpfancy_fields_config'),
- 'access arguments' => array('administer tripal'),
- 'type' => MENU_NORMAL_ITEM,
- 'weight' => 1,
- );
-
- return $items;
-}
-
-
-/**
- * Function callback:
- * Construct form interface to update prefix configuration.
- */
-function trpfancy_fields_config($form, &$form_state) {
- // System variable used to store prefix value:
- // NOTE: this variable is used by data__identifier field.
- $cur_prefix = variable_get('trpfancy_field_identifier_prefix');
-
- // Show an example of the prefix in action.
- $form['preview_prefix'] = array(
- '#type' => 'markup',
- '#markup' => 'Example (Prefix + ID#):
- '
- . $cur_prefix . '' . mt_rand(7777, 9999) . '
',
- );
-
- // Prefix field.
- $form['trpfancy_field_identifier_prefix'] = array(
- '#type' => 'textfield',
- '#title' => t('Prefix'),
- '#description' => t('Prefix used to generate uniquename for Identifier field.'),
- '#default_value' => $cur_prefix,
- '#required' => TRUE,
- );
-
- // This will add a save button to this form, thus
- // no hook_submit nor hook_validate is required.
- return system_settings_form($form);
-}
+ $link = Url::fromRoute($context_links['configure_dataid']['form']);
+ $links_ui[ 'configure_dataid' ] = \Drupal::l(t('Configure'), $link);
+
+ $variables = [
+ // Tripal Fancy Fields Configure Fields Page.
+ 'theme-tripal-fancyfields-configure' => [
+ 'variables' => [
+ 'context_links' => $links_ui
+ ],
+ 'template' => 'template-tripal-fancyfields-configure',
+ ],
+ ];
+
+ return $variables;
+}
\ No newline at end of file
diff --git a/trpfancy_fields.routing.yml b/trpfancy_fields.routing.yml
new file mode 100644
index 0000000..f673fa3
--- /dev/null
+++ b/trpfancy_fields.routing.yml
@@ -0,0 +1,25 @@
+# @file
+# Tripal Fancy Fields routes definition.
+
+
+# Configure Fields Route (currently - configure data identifier prefix).
+# Main switchboard to field with configuration interface.
+tripal_fancyfields.configure:
+ path: 'admin/tripal/extension/trpfancyfields/configure'
+ defaults:
+ _title: 'Tripal Fancy Fields - Configure Fields'
+ _controller: '\Drupal\trpfancy_fields\Controller\TripalFancyFieldsConfigureController::ui'
+ requirements:
+ _permission: 'administer tripal'
+
+
+# Routes below are used to reference forms for each field configuration.
+
+# Configure data identifier prefix).
+tripal_fancyfields.configure_data_id:
+ path: 'admin/tripal/extension/trpfancyfields/configure/data_id'
+ defaults:
+ _title: 'Tripal Fancy Fields - Configure Fields: Data Identifier Prefix'
+ _form: '\Drupal\trpfancy_fields\Form\TripalFancyFieldsDataIdForm'
+ requirements:
+ _permission: 'administer tripal'
\ No newline at end of file