You are here

function freelinking_prepopulate_list_fields in Freelinking 6.3

Same name in this branch
  1. 6.3 modules/freelinking_prepopulate/freelinking_prepopulate.utilities.inc \freelinking_prepopulate_list_fields()
  2. 6.3 modules/freelinking_prepopulate/freelinking_prepopulate.api.php \freelinking_prepopulate_list_fields()
Same name and namespace in other branches
  1. 7.3 modules/freelinking_prepopulate/freelinking_prepopulate.utilities.inc \freelinking_prepopulate_list_fields()
  2. 7.3 modules/freelinking_prepopulate/freelinking_prepopulate.api.php \freelinking_prepopulate_list_fields()

Build & retrieve the list of form fields for URL construction. This is made with Prepopulate in mind, but is not restricted to Prepopulate. You may add a $field to this list by calling this with the $field parameter set.

Predefines fields for taxonomy (tagging only), og audience, book parent, and locale. Taxonomy's 'prepopulate' must have [$vid] appended to it.

While you can do a lot with Prepopulate, this is not intended as a method of cloning an object. See modules such as http://drupal.org/project/node_clone for that kind of functionality. Maybe create a plugin to leverage it.

Parameters

$plugin: Specify the plugin name for which to collect relevant prepopulate fields.

$field : array:

  • 'field': The shorthand name for the form element within prepopulate.
  • 'title': Form title to active the field for processing.
  • 'prepopulate': The prepopulate URL 'edit' index for the field.

Return value

array Returns an array of all form field values for the given plugin. array('field' => array('prepopulate' => String, 'title' => String));

5 calls to freelinking_prepopulate_list_fields()
freelinking_prepopulate_fields_from_array in modules/freelinking_prepopulate/freelinking_prepopulate.utilities.inc
Extract arguments for Prepopulate from the array. Build a 'query' array suitable for use by Prepopulate.
freelinking_prepopulate_fields_from_array in modules/freelinking_prepopulate/freelinking_prepopulate.api.php
Extract arguments for Prepopulate from the array. Build a 'query' array suitable for use by Prepopulate.
freelinking_prepopulate_fields_from_page in modules/freelinking_prepopulate/freelinking_prepopulate.utilities.inc
Extract the specified array fields from the current or specified page. Build a l() 'query' array suitable for use by Prepopulate.
freelinking_prepopulate_fields_from_page in modules/freelinking_prepopulate/freelinking_prepopulate.api.php
Extract the specified array fields from the current or specified page. Build a l() 'query' array suitable for use by Prepopulate.
freelinking_prepopulate_node_settings in modules/freelinking_prepopulate/freelinking_prepopulate.module
Settings callback for "Create Node"

File

modules/freelinking_prepopulate/freelinking_prepopulate.api.php, line 134
Freelinking Prepopulate API

Code

function freelinking_prepopulate_list_fields($plugin = 'nodecreate', $field = NULL) {
  static $fields;
  static $plugins;

  // We have fields, and no new one to add.
  // Return all fields associated with the plugin.
  if ($fields && !$field) {
    return array_intersect_key($fields, $plugins[$plugin]);
  }
  if ($field) {

    // Define a field with prepopulate, or override.
    if ($field['prepopulate']) {
      $fields[$field['field']]['prepopulate'] = $field['prepopulate'];
    }

    //Define the title of a new field, or override.
    if ($field['title']) {
      $fields[$field['field']]['title'] = $field['title'];
    }

    // Add an entry for an existing field to the plugins array.
    // Uniqueness does not matter.
    if ($fields[$field['field']]['prepopulate']) {
      $plugins[$plugin][$field['field']] = TRUE;
    }
  }
  if (!$fields) {
    if (module_exists('taxonomy')) {
      $fields['taxonomy'] = array(
        'title' => t('Same taxonomy terms (for shared vocabularies)'),
        'prepopulate' => 'edit[taxonomy][tags]',
      );
      $plugins['nodecreate']['taxonomy'] = TRUE;
    }
    if (module_exists('book')) {
      $fields['book'] = array(
        'title' => t('Parent book page'),
        'prepopulate' => 'parent',
      );
      $plugins['nodecreate']['book'] = TRUE;
    }
    if (module_exists('og')) {
      $fields['og'] = array(
        'title' => t('Organic Group audience'),
        'prepopulate' => 'gids[]',
      );
      $plugins['nodecreate']['og'] = TRUE;
    }
    if (module_exists('locale')) {

      // To Be Implemented
    }
  }
  return array_intersect_key($fields, $plugins[$plugin]);
}