Commit fdc92c16 authored by codycraven's avatar codycraven
Browse files

Issue #1410576 by jonhattan: Added Features export integration.

parent a29b2a78
Taxonomy Display 7.x-1.x, YYYY-MM-DD Taxonomy Display 7.x-1.x, YYYY-MM-DD
------------------------------------ ------------------------------------
Issue #1410576 by jonhattan: Added Features export integration.
Issue #1693978 by Saxxing: Fix ability for breadcrumbs to be translated. Issue #1693978 by Saxxing: Fix ability for breadcrumbs to be translated.
Issue #1425648 by codycraven: Added README.txt per user request. Issue #1425648 by codycraven: Added README.txt per user request.
Issue #1507632 by codycraven, hass: Display select option for views that do not Issue #1507632 by codycraven, hass: Display select option for views that do not
......
...@@ -68,7 +68,7 @@ function taxonomy_display_admin_form(&$form, &$form_state) { ...@@ -68,7 +68,7 @@ function taxonomy_display_admin_form(&$form, &$form_state) {
// Add selection for adding taxonomy term core feed to page // Add selection for adding taxonomy term core feed to page
$fieldset['add_feed'] = array( $fieldset['add_feed'] = array(
'#default_value' => $stored_settings['add_feed'], '#default_value' => $stored_settings->add_feed,
'#description' => t('Drupal, by default, includes a feed of content referencing the term, by unchecking this you can prevent the feed from being added.'), '#description' => t('Drupal, by default, includes a feed of content referencing the term, by unchecking this you can prevent the feed from being added.'),
'#title' => t('Include feed'), '#title' => t('Include feed'),
'#type' => 'checkbox', '#type' => 'checkbox',
...@@ -204,7 +204,7 @@ function taxonomy_display_field_ui_layouts_validate($form, &$form_state) { ...@@ -204,7 +204,7 @@ function taxonomy_display_field_ui_layouts_validate($form, &$form_state) {
* @param array|null $form_state * @param array|null $form_state
* The form state array. * The form state array.
* @param $stored_settings * @param $stored_settings
* Associated array from taxonomy_display_fetch_taxonomy_display(). * Object from taxonomy_display_fetch_taxonomy_display().
* *
* @return void * @return void
* *
...@@ -230,7 +230,7 @@ function _taxonomy_display_admin_form_build_plugin_form($type, &$fieldset, &$for ...@@ -230,7 +230,7 @@ function _taxonomy_display_admin_form_build_plugin_form($type, &$fieldset, &$for
$options = taxonomy_display_plugins($type); $options = taxonomy_display_plugins($type);
// Add support for missing plugins. // Add support for missing plugins.
if (isset($stored_settings[$type . '_plugin_missing'])) { if (isset($stored_settings->{$type . '_plugin_missing'})) {
$options = array_merge(array('missing' => t('- Missing plugin -')), $options); $options = array_merge(array('missing' => t('- Missing plugin -')), $options);
} }
...@@ -244,7 +244,7 @@ function _taxonomy_display_admin_form_build_plugin_form($type, &$fieldset, &$for ...@@ -244,7 +244,7 @@ function _taxonomy_display_admin_form_build_plugin_form($type, &$fieldset, &$for
$selected = 'missing'; $selected = 'missing';
} }
else { else {
$selected = $stored_settings[$type . '_display_plugin']; $selected = $stored_settings->{$type . '_display_plugin'};
} }
$fieldset[$type . '_display_select'] = array( $fieldset[$type . '_display_select'] = array(
'#ajax' => array( '#ajax' => array(
...@@ -284,8 +284,8 @@ function _taxonomy_display_admin_form_build_plugin_form($type, &$fieldset, &$for ...@@ -284,8 +284,8 @@ function _taxonomy_display_admin_form_build_plugin_form($type, &$fieldset, &$for
$plugin_class = new $selected; $plugin_class = new $selected;
// Set $options as null // Set $options as null
$display_options = NULL; $display_options = NULL;
if (!isset($stored_settings['no_record'])) { if (!isset($stored_settings->no_record)) {
$display_options = $stored_settings[$type . '_display_options']; $display_options = $stored_settings->{$type . '_display_options'};
} }
// If the handler wasn't the one used on the last form build then reset the // If the handler wasn't the one used on the last form build then reset the
// $form_state values for it. // $form_state values for it.
......
...@@ -15,7 +15,7 @@ function taxonomy_display_enable() { ...@@ -15,7 +15,7 @@ function taxonomy_display_enable() {
// Retrieve all the existing vocabularies. // Retrieve all the existing vocabularies.
$vocabularies = taxonomy_vocabulary_get_names(); $vocabularies = taxonomy_vocabulary_get_names();
// Select taxonomy displays we have in the DB. // Select taxonomy displays we have in the DB.
$taxonomy_displays = db_select('taxonomy_display', 'td') $taxonomy_displays = db_select('taxonomy_display', 'td')
->fields('td', array('machine_name')) ->fields('td', array('machine_name'))
...@@ -37,6 +37,22 @@ function taxonomy_display_enable() { ...@@ -37,6 +37,22 @@ function taxonomy_display_enable() {
function taxonomy_display_schema() { function taxonomy_display_schema() {
$schema['taxonomy_display'] = array( $schema['taxonomy_display'] = array(
'description' => 'Per vocabulary configuration for term pages.', 'description' => 'Per vocabulary configuration for term pages.',
// CTools export definitions.
'export' => array(
'key' => 'machine_name',
'primary key' => 'machine_name',
'default hook' => 'taxonomy_display_default_displays',
'load callback' => 'taxonomy_display_fetch_taxonomy_display',
'can disable' => FALSE,
'api' => array(
'owner' => 'taxonomy_display',
'api' => 'taxonomy_display',
'minimum_version' => 1,
'current_version' => 1,
),
),
'fields' => array( 'fields' => array(
'machine_name' => array( 'machine_name' => array(
'type' => 'varchar', 'type' => 'varchar',
......
...@@ -49,13 +49,13 @@ function taxonomy_display_delete_taxonomy_display($machine_name, $watchdog_messa ...@@ -49,13 +49,13 @@ function taxonomy_display_delete_taxonomy_display($machine_name, $watchdog_messa
} }
/** /**
* Helper function; retrieve taxonomy display settings from the database. * Helper function; retrieve taxonomy display settings.
* *
* @param string $machine_name * @param string $machine_name
* The machine name of the vocabulary's taxonomy display data to fetch. * The machine name of the vocabulary's taxonomy display data to fetch.
* *
* @return array * @return object
* Return associated array. * Return ctools export object with taxonomy display settings.
*/ */
function taxonomy_display_fetch_taxonomy_display($machine_name) { function taxonomy_display_fetch_taxonomy_display($machine_name) {
// Attempt to fetch cached settings for the machine name. // Attempt to fetch cached settings for the machine name.
...@@ -64,41 +64,37 @@ function taxonomy_display_fetch_taxonomy_display($machine_name) { ...@@ -64,41 +64,37 @@ function taxonomy_display_fetch_taxonomy_display($machine_name) {
return $cache->data; return $cache->data;
} }
$result = db_select('taxonomy_display', 'td')
->fields('td')
->condition('machine_name', $machine_name)
->execute()
->fetchAssoc();
$plugin_types = _taxonomy_display_plugin_types(); $plugin_types = _taxonomy_display_plugin_types();
// Set defaults if a result was not found ctools_include('export');
if (!$result) { $result = ctools_export_load_object('taxonomy_display', 'names', array($machine_name));
$defaults = array(
'machine_name' => $machine_name, // Set defaults if a result was not found.
'add_feed' => 1, if (!isset($result[$machine_name])) {
'no_record' => TRUE, $defaults = new stdClass();
); $defaults->machine_name = $machine_name;
$defaults->add_feed = TRUE;
$defaults->no_record = TRUE;
foreach($plugin_types as $k => $v) { foreach($plugin_types as $k => $v) {
$defaults[$k . '_display_plugin'] = 'TaxonomyDisplay' . ucfirst($k) . 'DisplayHandlerCore'; $defaults->{$k . '_display_plugin'} = 'TaxonomyDisplay' . ucfirst($k) . 'DisplayHandlerCore';
$defaults[$k . '_display_options'] = NULL; $defaults->{$k . '_display_options'} = NULL;
} }
return $defaults; return $defaults;
} }
$result = $result[$machine_name];
// Prepare plugins' data for use. // Prepare plugins' data for use.
foreach ($plugin_types as $k => $v) { foreach ($plugin_types as $k => $v) {
if (!class_exists($result[$k . '_display_plugin'])) { if (!class_exists($result->{$k . '_display_plugin'})) {
// Note that if providing translations for this module you must provide a // Note that if providing translations for this module you must provide a
// translation for this watchdog warning for each $value. // translation for this watchdog warning for each $value.
watchdog('taxonomy_display', 'The taxonomy ' . $v['short'] . ' plugin assigned to the %name vocabulary is missing, Drupal default settings were used instead.', array('%name' => $machine_name), WATCHDOG_WARNING); watchdog('taxonomy_display', 'The taxonomy ' . $v['short'] . ' plugin assigned to the %name vocabulary is missing, Drupal default settings were used instead.', array('%name' => $machine_name), WATCHDOG_WARNING);
$result[$k . '_display_plugin'] = 'TaxonomyDisplay' . ucfirst($k) . 'DisplayHandlerCore'; $result->{$k . '_display_plugin'} = 'TaxonomyDisplay' . ucfirst($k) . 'DisplayHandlerCore';
$result[$k . '_display_options'] = NULL; $result->{$k . '_display_options'} = NULL;
$result[$k . '_plugin_missing'] = TRUE; $result->{$k . '_plugin_missing'} = TRUE;
}
else {
$result[$k . '_display_options'] = unserialize($result[$k . '_display_options']);
} }
} }
...@@ -284,7 +280,7 @@ function taxonomy_display_save_taxonomy_display($machine_name, $save_data = arra ...@@ -284,7 +280,7 @@ function taxonomy_display_save_taxonomy_display($machine_name, $save_data = arra
// Perform our save // Perform our save
try { try {
// If update // If update
if (!isset($update['no_record'])) { if (!isset($update->no_record) && ($update->export_type & EXPORT_IN_DATABASE)) {
// Do not proceed if there are no fields to update. // Do not proceed if there are no fields to update.
if (empty($query_fields)) { if (empty($query_fields)) {
return; return;
...@@ -356,11 +352,11 @@ function taxonomy_display_taxonomy_term_page($term) { ...@@ -356,11 +352,11 @@ function taxonomy_display_taxonomy_term_page($term) {
$display_settings = taxonomy_display_fetch_taxonomy_display($term->vocabulary_machine_name); $display_settings = taxonomy_display_fetch_taxonomy_display($term->vocabulary_machine_name);
// Breadcrumb display // Breadcrumb display
$breadcrumb_display = new $display_settings['breadcrumb_display_plugin']; $breadcrumb_display = new $display_settings->breadcrumb_display_plugin;
$breadcrumb_display->buildBreadcrumb($term); $breadcrumb_display->buildBreadcrumb($term);
// Conditionally add core Drupal feed to page // Conditionally add core Drupal feed to page
if ($display_settings['add_feed']) { if ($display_settings->add_feed) {
drupal_add_feed('taxonomy/term/' . $term->tid . '/feed', 'RSS - ' . $term->name); drupal_add_feed('taxonomy/term/' . $term->tid . '/feed', 'RSS - ' . $term->name);
} }
...@@ -368,12 +364,12 @@ function taxonomy_display_taxonomy_term_page($term) { ...@@ -368,12 +364,12 @@ function taxonomy_display_taxonomy_term_page($term) {
$build = array(); $build = array();
// Term display // Term display
$term_display = new $display_settings['term_display_plugin']; $term_display = new $display_settings->term_display_plugin;
$build['term_heading'] = $term_display->displayTerm($term, $display_settings['term_display_options']); $build['term_heading'] = $term_display->displayTerm($term, $display_settings->term_display_options);
// Associated content display // Associated content display
$associated_display = new $display_settings['associated_display_plugin']; $associated_display = new $display_settings->associated_display_plugin;
$build = array_merge($build, $associated_display->displayAssociated($term, $display_settings['associated_display_options'])); $build = array_merge($build, $associated_display->displayAssociated($term, $display_settings->associated_display_options));
return $build; return $build;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment