summaryrefslogtreecommitdiff
path: root/modules/field/field.api.php
diff options
context:
space:
mode:
authorAngie Byron <webchick@24967.no-reply.drupal.org>2009-07-10 05:58:13 +0000
committerAngie Byron <webchick@24967.no-reply.drupal.org>2009-07-10 05:58:13 +0000
commitf6ccf978f6fc256ca1f17bd8e6b1ae5be4fe8df2 (patch)
treeff1b9dcdb4d8c64fea7470194b5c36d0253f4260 /modules/field/field.api.php
parente916edc798f891fdb08e2fae9684afc02e3de9d3 (diff)
downloadbrdo-f6ccf978f6fc256ca1f17bd8e6b1ae5be4fe8df2.tar.gz
brdo-f6ccf978f6fc256ca1f17bd8e6b1ae5be4fe8df2.tar.bz2
#488542 by yched: Allow field UI to be attached to any fieldable entity.
Diffstat (limited to 'modules/field/field.api.php')
-rw-r--r--modules/field/field.api.php96
1 files changed, 65 insertions, 31 deletions
diff --git a/modules/field/field.api.php b/modules/field/field.api.php
index 48eb5005e..76268b908 100644
--- a/modules/field/field.api.php
+++ b/modules/field/field.api.php
@@ -9,47 +9,81 @@
/**
* Inform the Field API about one or more fieldable types.
*
- * Inform the Field API about one or more fieldable types, (object
- * types to which fields can be attached).
+ * Inform the Field API about one or more fieldable types (object types to
+ * which fields can be attached).
*
* @return
* An array whose keys are fieldable object type names and
- * whose values identify properties of those types that the Field
- * system needs to know about:
- *
- * name: The human-readable name of the type.
- * id key: The object property that contains the primary id for the
- * object. Every object passed to the Field API must
- * have this property and its value must be numeric.
- * revision key: The object property that contains the revision id
- * for the object, or NULL if the object type is not
- * versioned. The Field API assumes that all revision ids are
- * unique across all instances of a type; this means, for example,
- * that every object's revision ids cannot be 0, 1, 2, ...
- * bundle key: The object property that contains the bundle name for
- * the object (bundle name is what nodes call "content type").
- * The bundle name defines which fields are connected to the object.
- * cacheable: A boolean indicating whether Field API should cache
+ * whose values are arrays with the following key/value pairs:
+ * - label: The human-readable name of the type.
+ * - object keys: An array describing how the Field API can extract the
+ * informations it needs from the objects of the type.
+ * - id: The name of the property that contains the primary id of the
+ * object. Every object passed to the Field API must have this property
+ * and its value must be numeric.
+ * - revision: The name of the property that contains the revision id of
+ * the object. The Field API assumes that all revision ids are unique
+ * across all objects of a type.
+ * This element can be omitted if the objects of this type are not
+ * versionable.
+ * - bundle: The name of the property that contains the bundle name for the
+ * object. The bundle name defines which set of fields are attached to
+ * the object (e.g. what nodes call "content type").
+ * This element can be omitted if this type has no bundles (all objects
+ * have the same fields).
+ * - bundle keys: An array describing how the Field API can extract the
+ * informations it needs from the bundle objects for this type (e.g
+ * $vocabulary objects for terms; not applicable for nodes).
+ * This element can be omitted if this type's bundles do not exist as
+ * standalone objects.
+ * - bundle: The name of the property that contains the name of the bundle
+ * object.
+ * - cacheable: A boolean indicating whether Field API should cache
* loaded fields for each object, reducing the cost of
* field_attach_load().
- * bundles: An array of all existing bundle names for this object
- * type. TODO: Define format. TODO: I'm unclear why we need
- * this.
+ * - bundles: An array describing all bundles for this object type.
+ * Keys are bundles machine names, as found in the objects' 'bundle'
+ * property (defined in the 'object keys' entry above).
+ * - label: The human-readable name of the bundle.
+ * - admin: An array of informations that allow Field UI pages (currently
+ * implemented in a contributed module) to attach themselves to the
+ * existing administration pages for the bundle.
+ * - path: the path of the bundle's main administration page, as defined
+ * in hook_menu(). If the path includes a placeholder for the bundle,
+ * the 'bundle argument', 'bundle helper' and 'real path' keys below
+ * are required.
+ * - bundle argument: The position of the placeholder in 'path', if any.
+ * - real path: The actual path (no placeholder) of the bundle's main
+ * administration page. This will be used to generate links.
+ * - access callback: As in hook_menu(). 'user_access' will be assumed if
+ * no value is provided.
+ * - access arguments: As in hook_menu().
*/
function hook_fieldable_info() {
$return = array(
- 'node' => array(
- 'name' => t('Node'),
- 'id key' => 'nid',
- 'revision key' => 'vid',
- 'bundle key' => 'type',
- // Node.module handles its own caching.
- 'cacheable' => FALSE,
- // Bundles must provide human readable name so
- // we can create help and error messages about them.
- 'bundles' => node_type_get_names(),
+ 'taxonomy_term' => array(
+ 'label' => t('Taxonomy term'),
+ 'object keys' => array(
+ 'id' => 'tid',
+ 'bundle' => 'vocabulary_machine_name',
+ ),
+ 'bundle keys' => array(
+ 'bundle' => 'machine_name',
+ ),
+ 'bundles' => array(),
),
);
+ foreach (taxonomy_get_vocabularies() as $vocabulary) {
+ $return['taxonomy_term']['bundles'][$vocabulary->machine_name] = array(
+ 'label' => $vocabulary->name,
+ 'admin' => array(
+ 'path' => 'admin/content/taxonomy/%taxonomy_vocabulary',
+ 'real path' => 'admin/content/taxonomy/' . $vocabulary->vid,
+ 'bundle argument' => 3,
+ 'access arguments' => array('administer taxonomy'),
+ ),
+ );
+ }
return $return;
}