summaryrefslogtreecommitdiff
path: root/modules/field/field.attach.inc
diff options
context:
space:
mode:
authorAngie Byron <webchick@24967.no-reply.drupal.org>2009-08-19 13:31:14 +0000
committerAngie Byron <webchick@24967.no-reply.drupal.org>2009-08-19 13:31:14 +0000
commite998857eb8a5ef4d2ebe381a57c19b1b355fe4ef (patch)
tree88517c7981c03300ea0dc575f72719c8d3468027 /modules/field/field.attach.inc
parent24289301aba2666edb5909edf63cdb6cdedf994e (diff)
downloadbrdo-e998857eb8a5ef4d2ebe381a57c19b1b355fe4ef.tar.gz
brdo-e998857eb8a5ef4d2ebe381a57c19b1b355fe4ef.tar.bz2
#516138 by yched, KarenS, quicksketch, bangpound, et al.: CC-FREAKING-K IN CORE! OH YEAH! :D
Diffstat (limited to 'modules/field/field.attach.inc')
-rw-r--r--modules/field/field.attach.inc30
1 files changed, 29 insertions, 1 deletions
diff --git a/modules/field/field.attach.inc b/modules/field/field.attach.inc
index 55241f5af..838c6d93c 100644
--- a/modules/field/field.attach.inc
+++ b/modules/field/field.attach.inc
@@ -457,6 +457,11 @@ function _field_invoke_multiple_default($op, $obj_type, $objects, &$a = NULL, &$
function field_attach_form($obj_type, $object, &$form, &$form_state) {
$form += (array) _field_invoke_default('form', $obj_type, $object, $form, $form_state);
+ // Add custom weight handling.
+ list($id, $vid, $bundle) = field_attach_extract_ids($obj_type, $object);
+ $form['#pre_render'][] = '_field_extra_weights_pre_render';
+ $form['#extra_fields'] = field_extra_fields($bundle);
+
// Let other modules make changes to the form.
foreach (module_implements('field_attach_form') as $module) {
$function = $module . '_field_attach_form';
@@ -1043,6 +1048,11 @@ function field_attach_view($obj_type, $object, $build_mode = 'full') {
$output = _field_invoke_default('view', $obj_type, $object, $build_mode);
+ // Add custom weight handling.
+ list($id, $vid, $bundle) = field_attach_extract_ids($obj_type, $object);
+ $output['#pre_render'][] = '_field_extra_weights_pre_render';
+ $output['#extra_fields'] = field_extra_fields($bundle);
+
// Let other modules make changes after rendering the view.
drupal_alter('field_attach_view', $output, $obj_type, $object, $build_mode);
@@ -1051,6 +1061,24 @@ function field_attach_view($obj_type, $object, $build_mode = 'full') {
}
/**
+ * Retrieve the user-defined weight for a 'pseudo-field' component.
+ *
+ * @param $bundle
+ * The bundle name.
+ * @param $pseudo_field
+ * The name of the 'pseudo-field'.
+ * @return
+ * The weight for the 'pseudo-field', respecting the user settings stored by
+ * field.module.
+ */
+function field_attach_extra_weight($bundle, $pseudo_field) {
+ $extra = field_extra_fields($bundle);
+ if (isset($extra[$pseudo_field])) {
+ return $extra[$pseudo_field]['weight'];
+ }
+}
+
+/**
* Implement hook_node_prepare_translation.
*
* TODO D7: We do not yet know if this really belongs in Field API.
@@ -1084,7 +1112,7 @@ function field_attach_create_bundle($bundle) {
// Clear the cache.
field_cache_clear();
-
+ menu_rebuild();
foreach (module_implements('field_attach_create_bundle') as $module) {
$function = $module . '_field_attach_create_bundle';
$function($bundle);