summaryrefslogtreecommitdiff
path: root/kolab.org/www/drupal-7.26/sites/all/modules/ctools/plugins/content_types/entity_context
diff options
context:
space:
mode:
Diffstat (limited to 'kolab.org/www/drupal-7.26/sites/all/modules/ctools/plugins/content_types/entity_context')
-rw-r--r--kolab.org/www/drupal-7.26/sites/all/modules/ctools/plugins/content_types/entity_context/entity_field.inc18
-rw-r--r--kolab.org/www/drupal-7.26/sites/all/modules/ctools/plugins/content_types/entity_context/entity_field_extra.inc22
2 files changed, 29 insertions, 11 deletions
diff --git a/kolab.org/www/drupal-7.26/sites/all/modules/ctools/plugins/content_types/entity_context/entity_field.inc b/kolab.org/www/drupal-7.26/sites/all/modules/ctools/plugins/content_types/entity_context/entity_field.inc
index 2da4044..d7d6319 100644
--- a/kolab.org/www/drupal-7.26/sites/all/modules/ctools/plugins/content_types/entity_context/entity_field.inc
+++ b/kolab.org/www/drupal-7.26/sites/all/modules/ctools/plugins/content_types/entity_context/entity_field.inc
@@ -38,27 +38,33 @@ function ctools_entity_field_content_type_content_types() {
$context_types = array();
$entities = entity_get_info();
+ $description = t('Field on the referenced entity.');
+ $styles = t('Formatter Styles');
+ $categories = array();
foreach ($entities as $entity_type => $entity) {
+ $category = t(ucfirst($entity_type));
+ $categories[$entity_type] = $category;
foreach ($entity['bundles'] as $type => $bundle) {
foreach (field_info_instances($entity_type, $type) as $field_name => $field) {
if (!isset($types[$entity_type . ':' . $field_name])) {
+ $label = t($field['label']);
$types[$entity_type . ':' . $field_name] = array(
- 'category' => t(ucfirst($entity_type)),
+ 'category' => $category,
'icon' => 'icon_field.png',
'title' => t('Field: @widget_label (@field_name)', array(
- '@widget_label' => t($field['label']),
+ '@widget_label' => $label,
'@field_name' => $field_name,
)),
- 'description' => t('Field on the referenced entity.'),
+ 'description' => $description,
'edit form' => array(
'ctools_entity_field_content_type_formatter_options' => array(
'default' => TRUE,
'title' => t('Formatter options for: @widget_label (@field_name)', array(
- '@widget_label' => t($field['label']),
+ '@widget_label' => $label,
'@field_name' => $field_name,
)),
),
- 'ctools_entity_field_content_type_formatter_styles' => t('Formatter Styles'),
+ 'ctools_entity_field_content_type_formatter_styles' => $styles,
),
);
}
@@ -70,7 +76,7 @@ function ctools_entity_field_content_type_content_types() {
// Create the required context for each field related to the bundle types.
foreach ($types as $key => $field_content_type) {
list($entity_type, $field_name) = explode(':', $key, 2);
- $types[$key]['required context'] = new ctools_context_required(t(ucfirst($entity_type)), $entity_type, array(
+ $types[$key]['required context'] = new ctools_context_required($categories[$entity_type], $entity_type, array(
'type' => array_keys($context_types[$key]['types']),
));
unset($context_types[$key]['types']);
diff --git a/kolab.org/www/drupal-7.26/sites/all/modules/ctools/plugins/content_types/entity_context/entity_field_extra.inc b/kolab.org/www/drupal-7.26/sites/all/modules/ctools/plugins/content_types/entity_context/entity_field_extra.inc
index 807969c..6a59ed4 100644
--- a/kolab.org/www/drupal-7.26/sites/all/modules/ctools/plugins/content_types/entity_context/entity_field_extra.inc
+++ b/kolab.org/www/drupal-7.26/sites/all/modules/ctools/plugins/content_types/entity_context/entity_field_extra.inc
@@ -25,6 +25,11 @@ function ctools_entity_field_extra_content_type_content_type($subtype) {
*/
function ctools_entity_field_extra_content_type_content_types() {
// This will hold all the individual field content types.
+ $types = &drupal_static(__FUNCTION__);
+ if (isset($types)) {
+ return $types;
+ }
+
$types = array();
$context_types = array();
$entities = entity_get_info();
@@ -97,13 +102,20 @@ function ctools_entity_field_extra_content_type_render($subtype, $conf, $panel_a
$entity = clone $context->data;
list($entity_type, $field_name) = explode(':', $subtype, 2);
list($id, $vid, $bundle) = entity_extract_ids($entity_type, $entity);
-
- // Invoke the view-hook to get the extra field.
- $entity->content = array();
$langcode = $GLOBALS['language_content']->language;
- module_invoke_all($entity_type . '_view', $entity, $conf['view_mode'], $langcode);
- module_invoke_all('entity_view', $entity, $entity_type, $conf['view_mode'], $langcode);
+ $function = $entity_type . '_view';
+ if (in_array($entity_type, array('node', 'taxonomy_term', 'user')) && function_exists($function)) {
+ // Call known ENTITY_view() to get the extra field.
+ $entity->content = $function($entity, $conf['view_mode'], $langcode);
+ }
+ else {
+ // Invoke the view-hook to get the extra field.
+ $entity->content = array();
+
+ module_invoke_all($entity_type . '_view', $entity, $conf['view_mode'], $langcode);
+ module_invoke_all('entity_view', $entity, $entity_type, $conf['view_mode'], $langcode);
+ }
if (isset($entity->content[$field_name])) {
// Build the content type block.