ds.module

  1. cis7 sites/all/modules/ulmus/ds/ds.module
  2. cle7 sites/all/modules/ulmus/ds/ds.module
  3. ecd7 sites/all/modules/ulmus/ds/ds.module
  4. elmsmedia7 sites/all/modules/ulmus/ds/ds.module
  5. harmony7 sites/all/modules/ulmus/ds/ds.module
  6. icor7 sites/all/modules/ulmus/ds/ds.module
  7. meedjum_blog7 sites/all/modules/ulmus/ds/ds.module
  8. mooc7 sites/all/modules/ulmus/ds/ds.module

Display Suite core functions.

Functions

Namesort descending Description
ds_contextual_links_view_alter Implements hook_contextual_links_view_alter().
ds_create_entity_context Create entity context.
ds_ctools_plugin_api Implements hook_ctools_plugin_api().
ds_ctools_plugin_directory Implements hook_ctools_plugin_directory().
ds_ds_layout_info Implements hook_ds_layout_info().
ds_edit_support Support for edit module.
ds_entity_info_alter Implements hook_entity_info_alter().
ds_entity_variables Add variables to an entity.
ds_entity_view_modes Get entity view modes.
ds_features_api Implements hook_features_api().
ds_field_attach_view_alter Implements hook_field_attach_view_alter().
ds_field_formatter_info Implements hook_field_formatter_info().
ds_field_formatter_view Implements hook_field_formatter_view().
ds_form_field_ui_display_overview_form_alter Implements hook_form_FORM_ID_alter().
ds_get_fields Get all fields.
ds_get_field_settings Get the field settings.
ds_get_field_value Get the value for a Display Suite field.
ds_get_layout Get a layout for a given entity.
ds_get_layout_info Get Display Suite layouts.
ds_hook_info Implements hook_hook_info().
ds_kill_switch Function to check if we go on with Display Suite.
ds_menu Implements hook_menu().
ds_menu_alter Implements hook_menu_alter().
ds_module_implements_alter Implements hook_module_implements_alter().
ds_node_type_delete Implements hook_node_type_delete().
ds_node_type_update Implements hook_node_type_update().
ds_permission Implements hook_permission().
ds_render_author_field Render an author field.
ds_render_block_field Render a block field.
ds_render_code_field Render a code field.
ds_render_ctools_field Render a CTools field.
ds_render_date_field Render a date field.
ds_render_field Render a field.
ds_render_markup Render a markup field.
ds_render_submitted_by Render a "Submitted by"-line.
ds_render_user_picture Render a user picture.
ds_return_picture Return the picture.
ds_theme Implements hook_theme().
ds_theme_registry_alter Implements hook_theme_registry_alter().
ds_views_api Implements hook_views_api().

Constants

File

sites/all/modules/ulmus/ds/ds.module
View source
  1. <?php
  2. /**
  3. * @file
  4. * Display Suite core functions.
  5. */
  6. /**
  7. * Constants for field types.
  8. */
  9. define('DS_FIELD_TYPE_THEME', 1);
  10. define('DS_FIELD_TYPE_FUNCTION', 2);
  11. define('DS_FIELD_TYPE_PREPROCESS', 3);
  12. define('DS_FIELD_TYPE_IGNORE', 4);
  13. define('DS_FIELD_TYPE_CODE', 5);
  14. define('DS_FIELD_TYPE_BLOCK', 6);
  15. define('DS_FIELD_TYPE_CTOOLS', 7);
  16. /**
  17. * Constants for block fields rendering.
  18. */
  19. define('DS_BLOCK_TEMPLATE', 1);
  20. define('DS_BLOCK_TITLE_CONTENT', 2);
  21. define('DS_BLOCK_CONTENT', 3);
  22. /**
  23. * Implements hook_permission().
  24. */
  25. function ds_permission() {
  26. return array(
  27. 'admin_display_suite' => array(
  28. 'title' => t('Administer Display Suite'),
  29. 'description' => t('General permission for Display Suite settings pages.')
  30. ),
  31. );
  32. }
  33. /**
  34. * Implements hook_hook_info().
  35. */
  36. function ds_hook_info() {
  37. $hooks['ds_fields_info'] = array(
  38. 'group' => 'ds_fields_info',
  39. );
  40. return $hooks;
  41. }
  42. /**
  43. * Implements hook_menu().
  44. */
  45. function ds_menu() {
  46. module_load_include('inc', 'ds', 'includes/ds.registry');
  47. return _ds_menu();
  48. }
  49. /**
  50. * Implements hook_menu_alter().
  51. */
  52. function ds_menu_alter(&$items) {
  53. module_load_include('inc', 'ds', 'includes/ds.registry');
  54. return _ds_menu_alter($items);
  55. }
  56. /**
  57. * Implements hook_theme().
  58. */
  59. function ds_theme() {
  60. module_load_include('inc', 'ds', 'includes/ds.registry');
  61. return _ds_theme();
  62. }
  63. /**
  64. * Implements hook_ds_layout_info().
  65. */
  66. function ds_ds_layout_info() {
  67. module_load_include('inc', 'ds', 'includes/ds.registry');
  68. return _ds_ds_layout_info();
  69. }
  70. /**
  71. * Implements hook_ctools_plugin_api().
  72. */
  73. function ds_ctools_plugin_api($owner, $api) {
  74. if ($owner == 'ds' && ($api == 'ds' || $api == 'plugins')) {
  75. return array('version' => 1);
  76. }
  77. }
  78. /**
  79. * Implements hook_ctools_plugin_directory().
  80. */
  81. function ds_ctools_plugin_directory($owner, $plugin_type) {
  82. if ($owner == 'ctools' && $plugin_type == 'content_types') {
  83. return 'plugins/' . $plugin_type;
  84. }
  85. }
  86. /**
  87. * Implements hook_views_api().
  88. */
  89. function ds_views_api() {
  90. return array('api' => 3);
  91. }
  92. /**
  93. * Implements hook_node_type_update().
  94. */
  95. function ds_node_type_update($info) {
  96. if (!empty($info->old_type) && $info->old_type != $info->type) {
  97. module_load_include('inc', 'ds', 'includes/ds.registry');
  98. _ds_entity_type_update('node', $info, 'update');
  99. }
  100. }
  101. /**
  102. * Implements hook_node_type_delete().
  103. */
  104. function ds_node_type_delete($info) {
  105. module_load_include('inc', 'ds', 'includes/ds.registry');
  106. _ds_entity_type_update('node', $info, 'delete');
  107. }
  108. /**
  109. * Implements hook_theme_registry_alter().
  110. */
  111. function ds_theme_registry_alter(&$theme_registry) {
  112. module_load_include('inc', 'ds', 'includes/ds.registry');
  113. _ds_theme_registry_alter($theme_registry);
  114. }
  115. /**
  116. * Implements hook_entity_info_alter().
  117. */
  118. function ds_entity_info_alter(&$entity_info) {
  119. module_load_include('inc', 'ds', 'includes/ds.registry');
  120. _ds_entity_info_alter($entity_info);
  121. }
  122. /**
  123. * Implements hook_form_FORM_ID_alter().
  124. */
  125. function ds_form_field_ui_display_overview_form_alter(&$form, &$form_state) {
  126. form_load_include($form_state, 'inc', 'ds', 'includes/ds.field_ui');
  127. // Also load admin on behalf of DS extras when enabled.
  128. if (module_exists('ds_extras')) {
  129. form_load_include($form_state, 'inc', 'ds_extras', 'includes/ds_extras.admin');
  130. }
  131. ds_field_ui_fields_layouts($form, $form_state);
  132. }
  133. /**
  134. * Implements hook_module_implements_alter().
  135. */
  136. function ds_module_implements_alter(&$implementations, $hook) {
  137. // node_field_display_module_alter() disables all labels on all fields
  138. // when the view mode is 'search_index'. If you set display modes for
  139. // this view mode by hand, then the hook isn't needed. Since this
  140. // may be called hundreds of times on some pages, it's worth disabling it.
  141. // See http://drupal.org/node/834278
  142. // This code is also in Performance hacks module, but it's not bad to
  143. // disable this too in Display Suite by default.
  144. if ($hook == 'field_display_node_alter') {
  145. unset($implementations['node']);
  146. }
  147. }
  148. /**
  149. * Implements hook_features_api().
  150. */
  151. function ds_features_api() {
  152. module_load_include('inc', 'ds', 'includes/ds.registry');
  153. return _ds_features_api();
  154. }
  155. /**
  156. * Function to check if we go on with Display Suite.
  157. */
  158. function ds_kill_switch() {
  159. if (variable_get('ds_disable', FALSE)) {
  160. return TRUE;
  161. }
  162. return FALSE;
  163. }
  164. /**
  165. * Get entity view modes.
  166. *
  167. * @param $entity_type
  168. * The name of the entity type.
  169. */
  170. function ds_entity_view_modes($entity_type = NULL) {
  171. if (!empty($entity_type)) {
  172. switch ($entity_type) {
  173. // For taxonomy terms the base table and the entity type are different
  174. case 'taxonomy_term_data':
  175. $entity_info = entity_get_info('taxonomy_term');
  176. break;
  177. default:
  178. $entity_info = entity_get_info($entity_type);
  179. break;
  180. }
  181. return $entity_info['view modes'];
  182. }
  183. }
  184. /**
  185. * Get Display Suite layouts.
  186. */
  187. function ds_get_layout_info() {
  188. static $layouts = FALSE;
  189. if (!$layouts) {
  190. $errors = array();
  191. $layouts = module_invoke_all('ds_layout_info');
  192. // Give modules a chance to alter the layouts information.
  193. drupal_alter('ds_layout_info', $layouts);
  194. // Check that there is no 'content' region, but ignore panel layouts.
  195. // Because when entities are rendered, the field items are stored into a
  196. // 'content' key so fields would be overwritten before they're all moved.
  197. foreach ($layouts as $key => $info) {
  198. if (isset($info['panels'])) {
  199. continue;
  200. }
  201. if (isset($info['regions']['content'])) {
  202. $errors[] = $key;
  203. }
  204. }
  205. if (!empty($errors)) {
  206. drupal_set_message(t('Following layouts have a "content" region key which is invalid: %layouts.', array('%layouts' => implode(', ', $errors))), 'error');
  207. }
  208. }
  209. return $layouts;
  210. }
  211. /**
  212. * Get a layout for a given entity.
  213. *
  214. * @param $entity_type
  215. * The name of the entity.
  216. * @param $bundle
  217. * The name of the bundle.
  218. * @param $view_mode
  219. * The name of the view mode.
  220. * @param $fallback
  221. * Whether to fallback to default or not.
  222. *
  223. * @return $layout
  224. * Array of layout variables for the regions.
  225. */
  226. function ds_get_layout($entity_type, $bundle, $view_mode, $fallback = TRUE) {
  227. static $layouts = array();
  228. $layout_key = $entity_type . '_' . $bundle . '_' . $view_mode;
  229. if (!isset($layouts[$layout_key])) {
  230. $entity_info = entity_get_info();
  231. $overridden = TRUE;
  232. if ($view_mode != 'form') {
  233. $view_mode_settings = field_view_mode_settings($entity_type, $bundle);
  234. $overridden = (!empty($view_mode_settings[$view_mode]['custom_settings']) ? TRUE : FALSE);
  235. }
  236. // Check if a layout is configured.
  237. if (isset($entity_info[$entity_type]['bundles'][$bundle]['layouts'][$view_mode]) && ($overridden || $view_mode == 'default')) {
  238. $layouts[$layout_key] = $entity_info[$entity_type]['bundles'][$bundle]['layouts'][$view_mode];
  239. $layouts[$layout_key]['view_mode'] = $view_mode;
  240. }
  241. // In case $view_mode is not found, check if we have a default layout,
  242. // but only if the view mode settings aren't overridden for this view mode.
  243. if ($view_mode != 'default' && !$overridden && $fallback && isset($entity_info[$entity_type]['bundles'][$bundle]['layouts']['default'])) {
  244. $layouts[$layout_key] = $entity_info[$entity_type]['bundles'][$bundle]['layouts']['default'];
  245. $layouts[$layout_key]['view_mode'] = 'default';
  246. }
  247. // Register the false return value as well.
  248. if (!isset($layouts[$layout_key])) {
  249. $layouts[$layout_key] = FALSE;
  250. }
  251. }
  252. return $layouts[$layout_key];
  253. }
  254. /**
  255. * Get all fields.
  256. *
  257. * @param $entity_type
  258. * The name of the entity.
  259. * @param $cache
  260. * Whether we need to get the fields from cache or not.
  261. * @return
  262. * Collection of fields.
  263. */
  264. function ds_get_fields($entity_type, $cache = TRUE) {
  265. global $language;
  266. static $static_fields, $fields_cached = array();
  267. static $loaded = FALSE;
  268. // Get fields from cache.
  269. if (!$loaded) {
  270. $loaded = TRUE;
  271. if ($cache && $cached_fields = cache_get('ds_fields:' . $language->language)) {
  272. $fields_cached = $static_fields = $cached_fields->data;
  273. }
  274. }
  275. if (!isset($static_fields[$entity_type])) {
  276. // Do we have them cached or not ?
  277. if (!isset($fields_cached[$entity_type])) {
  278. // Get all fields for this entity type.
  279. $fields = array();
  280. foreach (module_implements('ds_fields_info') as $module) {
  281. $function = $module . '_ds_fields_info';
  282. $all_fields = $function($entity_type);
  283. if (!empty($all_fields)) {
  284. foreach ($all_fields as $key => $field_results) {
  285. if ($key === $entity_type) {
  286. // Add module key to field definition.
  287. foreach ($field_results as $f => $d) {
  288. $field_results[$f]['module'] = $module;
  289. }
  290. $fields = array_merge($field_results, $fields);
  291. }
  292. }
  293. }
  294. }
  295. // Give modules a change to alter fields.
  296. drupal_alter('ds_fields_info', $fields, $entity_type);
  297. $fields_cached[$entity_type] = $fields;
  298. // Cache the fields.
  299. if ($cache) {
  300. cache_set('ds_fields:' . $language->language, $fields_cached, 'cache');
  301. }
  302. }
  303. else {
  304. $fields = $fields_cached[$entity_type];
  305. }
  306. // Store the fields statically.
  307. $static_fields[$entity_type] = $fields;
  308. }
  309. return isset($static_fields[$entity_type]) ? $static_fields[$entity_type] : array();
  310. }
  311. /**
  312. * Get the field settings.
  313. *
  314. * @param $entity_type
  315. * The name of the entity.
  316. * @param $bundle
  317. * The name of bundle (ie, page or story for node types, profile for users)
  318. * @param $view_mode
  319. * The name of view mode.
  320. */
  321. function ds_get_field_settings($entity_type, $bundle, $view_mode, $default = TRUE) {
  322. static $field_settings = NULL;
  323. if (!isset($field_settings)) {
  324. if ($cache = cache_get('ds_field_settings')) {
  325. $field_settings = $cache->data;
  326. }
  327. else {
  328. ctools_include('export');
  329. $ds_field_settings = ctools_export_crud_load_all('ds_field_settings');
  330. foreach ($ds_field_settings as $layout => $layout_settings) {
  331. // Do not store configuration when the field settings is disabled.
  332. if (!empty($layout_settings->disabled)) {
  333. continue;
  334. }
  335. // Do not store configuration if settings key is not set.
  336. if (!isset($layout_settings->settings)) {
  337. continue;
  338. }
  339. foreach ($layout_settings->settings as $field => $settings) {
  340. $field_settings[$layout_settings->entity_type][$layout_settings->bundle][$layout_settings->view_mode][$field] = $settings;
  341. }
  342. }
  343. cache_set('ds_field_settings', $field_settings, 'cache');
  344. }
  345. }
  346. return (isset($field_settings[$entity_type][$bundle][$view_mode])) ? $field_settings[$entity_type][$bundle][$view_mode] : (isset($field_settings[$entity_type][$bundle]['default']) && $default ? $field_settings[$entity_type][$bundle]['default'] : array());
  347. }
  348. /**
  349. * Get the value for a Display Suite field.
  350. *
  351. * @param $key
  352. * The key of the field.
  353. * @param $field
  354. * The configuration of a DS field.
  355. * @param $entity
  356. * The current entity.
  357. * @param $entity_type
  358. * The name of the entity.
  359. * @param $bundle
  360. * The name of the bundle.
  361. * @param $view_mode
  362. * The name of the view mode.
  363. * @param $build
  364. * The current built of the entity.
  365. * @return $markup
  366. * The markup of the field used for output.
  367. */
  368. function ds_get_field_value($key, $field, $entity, $entity_type, $bundle, $view_mode, $build = array()) {
  369. $field['field_name'] = $key;
  370. $field['entity'] = $entity;
  371. $field['entity_type'] = $entity_type;
  372. $field['bundle'] = $bundle;
  373. $field['view_mode'] = $view_mode;
  374. $field['build'] = $build;
  375. // Special case for ds_views which can handle custom fields now.
  376. if ($field['field_type'] != DS_FIELD_TYPE_PREPROCESS && $entity_type == 'ds_views') {
  377. $entity->preprocess_fields[] = $key;
  378. }
  379. switch ($field['field_type']) {
  380. case DS_FIELD_TYPE_PREPROCESS:
  381. $entity->preprocess_fields[] = $key;
  382. break;
  383. case DS_FIELD_TYPE_FUNCTION:
  384. if (isset($field['file'])) {
  385. include_once $field['file'];
  386. }
  387. return $field['function']($field);
  388. case DS_FIELD_TYPE_THEME:
  389. $format = (isset($field['formatter'])) ? $field['formatter'] : key($field['properties']['formatters']);
  390. return theme($format, $field);
  391. case DS_FIELD_TYPE_CODE:
  392. return ds_render_code_field($field);
  393. case DS_FIELD_TYPE_CTOOLS:
  394. return ds_render_ctools_field($field);
  395. case DS_FIELD_TYPE_BLOCK:
  396. return ds_render_block_field($field);
  397. }
  398. }
  399. /**
  400. * Implements hook_field_attach_view_alter().
  401. */
  402. function ds_field_attach_view_alter(&$build, $context) {
  403. static $loaded_css = array();
  404. // Global kill switch. In some edge cases, a view might
  405. // be inserted into the view of an entity, in which the
  406. // same entity is available as well. This is simply not
  407. // possible, so you can temporarily disable DS completely
  408. // by setting this variable, either from code or via
  409. // the UI through admin/structure/ds/
  410. if (ds_kill_switch()) {
  411. return;
  412. }
  413. // If views and core doesn't send information along on the entity,
  414. // Display Suite doesn't have a context to render the fields.
  415. if (!isset($build['#entity_type']) && !isset($build['#bundle'])) {
  416. return;
  417. }
  418. // If no layout is configured, stop as well.
  419. if (!ds_get_layout($build['#entity_type'], $build['#bundle'], $context['view_mode'])) {
  420. return;
  421. }
  422. $entity_type = $build['#entity_type'];
  423. $bundle = $build['#bundle'];
  424. $view_mode = $context['view_mode'];
  425. $entity = $context['entity'];
  426. $layout = ds_get_layout($entity_type, $bundle, $view_mode);
  427. // Check on field/delta limit.
  428. if (isset($layout['settings']['limit'])) {
  429. foreach ($layout['settings']['limit'] as $field => $limit) {
  430. if (isset($build[$field])) {
  431. if ($limit === 'delta' && isset($entity->ds_delta) && isset($entity->ds_delta[$field])) {
  432. $delta = $entity->ds_delta[$field];
  433. foreach ($build[$field]['#items'] as $key => $item) {
  434. if ($key != $delta) {
  435. unset($build[$field][$key]);
  436. }
  437. }
  438. }
  439. else {
  440. $count = count($build[$field]['#items']);
  441. if ($count > $limit) {
  442. $build[$field]['#items'] = array_slice($build[$field]['#items'], 0, $limit);
  443. }
  444. }
  445. }
  446. }
  447. }
  448. // Add Display Suite display fields.
  449. $fields = ds_get_fields($entity_type);
  450. $field_values = ds_get_field_settings($entity_type, $bundle, $layout['view_mode']);
  451. foreach ($field_values as $key => $field) {
  452. // Ignore if this field is not a DS field.
  453. if (!isset($fields[$key])) {
  454. continue;
  455. }
  456. $field = $fields[$key];
  457. if (isset($field_values[$key]['format'])) {
  458. $field['formatter'] = $field_values[$key]['format'];
  459. }
  460. if (isset($field_values[$key]['formatter_settings'])) {
  461. $field['formatter_settings'] = $field_values[$key]['formatter_settings'];
  462. }
  463. $field_value = ds_get_field_value($key, $field, $entity, $entity_type, $bundle, $view_mode, $build);
  464. // Title label.
  465. if ($key == 'title' && $entity_type == 'node') {
  466. $node_type = node_type_get_type($entity);
  467. $field['title'] = function_exists('i18n_node_translate_type') ? i18n_node_translate_type($node_type->type, 'title_label', $node_type->title_label) : $node_type->title_label;
  468. }
  469. if (!empty($field_value) || (string) $field_value === '0') {
  470. // Special case for views.
  471. if (!empty($build['render_code_fields'])) {
  472. $build[$key] = $field_value;
  473. }
  474. else {
  475. $build[$key] = array(
  476. '#theme' => 'field',
  477. '#field_type' => 'ds',
  478. '#skip_edit' => TRUE,
  479. '#title' => $field['title'],
  480. '#weight' => isset($field_values[$key]['weight']) ? $field_values[$key]['weight'] : 0,
  481. '#label_display' => isset($field_values[$key]['label']) ? $field_values[$key]['label'] : 'inline',
  482. '#field_name' => $key,
  483. '#bundle' => $bundle,
  484. '#object' => $entity,
  485. '#entity_type' => $entity_type,
  486. '#view_mode' => $view_mode,
  487. '#access' => (variable_get('ds_extras_field_permissions', FALSE) && function_exists('ds_extras_ds_field_access')) ? ds_extras_ds_field_access($key, $entity_type) : TRUE,
  488. '#items' => array(
  489. 0 => array(
  490. 'value' => $field_value,
  491. ),
  492. ),
  493. 0 => array(
  494. '#markup' => $field_value,
  495. ),
  496. );
  497. }
  498. }
  499. }
  500. // Add path to css file for this layout and disable block regions if necessary.
  501. if (isset($layout['css']) && !isset($loaded_css[$layout['path'] . '/' . $layout['layout'] . '.css'])) {
  502. // Register css file.
  503. $loaded_css[$layout['path'] . '/' . $layout['layout'] . '.css'] = TRUE;
  504. // Add css file.
  505. if (isset($layout['module']) && $layout['module'] == 'panels') {
  506. $build['#attached']['css'][] = $layout['path'] . '/' . $layout['panels']['css'];
  507. }
  508. else {
  509. $build['#attached']['css'][] = $layout['path'] . '/' . $layout['layout'] . '.css';
  510. }
  511. }
  512. }
  513. /**
  514. * Add variables to an entity.
  515. *
  516. * This function is added in ds_theme_registry_alter().
  517. */
  518. function ds_entity_variables(&$vars) {
  519. if (isset($vars['elements']) && isset($vars['elements']['#bundle']) && $layout = ds_get_layout($vars['elements']['#entity_type'], $vars['elements']['#bundle'], $vars['elements']['#view_mode'])) {
  520. $render_container = 'content';
  521. // User uses user_profile as container.
  522. if ($vars['elements']['#entity_type'] == 'user') {
  523. $render_container = 'user_profile';
  524. }
  525. // Move any preprocess fields to render container.
  526. // Inconsitency in taxonomy term naming.
  527. $object = $vars['elements']['#entity_type'];
  528. if ($vars['elements']['#entity_type'] == 'taxonomy_term') {
  529. $object = 'term';
  530. }
  531. if (isset($vars[$object]->preprocess_fields)) {
  532. foreach ($vars[$object]->preprocess_fields as $field) {
  533. // Process RDF if the module is enabled before moving preprocess fields.
  534. if (module_exists('rdf')) {
  535. rdf_process($vars, $field);
  536. // Remove it so we can unset the field later on.
  537. unset($vars['rdf_template_variable_attributes_array'][$field]);
  538. }
  539. // Move the field to content so it renders, remove it
  540. // because we don't need it anymore.
  541. if (isset($vars[$field])) {
  542. $vars[$render_container][$field] = array('#markup' => $vars[$field]);
  543. if (!isset($vars['preprocess_keep'])) {
  544. unset($vars[$field]);
  545. }
  546. }
  547. }
  548. }
  549. // Check if this is a flexible panels layout.
  550. if (!empty($layout['flexible'])) {
  551. ctools_include('plugins', 'panels');
  552. $vars['css_id'] = $vars['settings'] = $vars['display'] = $vars['renderer'] = '';
  553. $vars['layout'] = panels_get_layout($layout['panels']['name']);
  554. $vars['theme_hook_suggestion'] = 'panels_flexible';
  555. }
  556. else {
  557. // Template layout.
  558. if (!isset($vars['classes_array'])) {
  559. $vars['classes_array'] = array();
  560. }
  561. // Add view-mode-{name} to classes.
  562. if (!in_array('view-mode-' . $vars['elements']['#view_mode'], $vars['classes_array'])) {
  563. $vars['classes_array'][] = 'view-mode-' . $vars['elements']['#view_mode'];
  564. }
  565. // In case this is a panels layout, use panels info array.
  566. if (isset($layout['module']) && $layout['module'] == 'panels') {
  567. $layout['layout'] = $layout['panels']['theme'];
  568. }
  569. $vars['theme_hook_suggestions'][] = $layout['layout'];
  570. $vars['theme_hook_suggestions'][] = $layout['layout'] . '__' . $vars['elements']['#entity_type'];
  571. $vars['theme_hook_suggestions'][] = $layout['layout'] . '__' . $vars['elements']['#entity_type'] . '_' . $vars['elements']['#view_mode'];
  572. $vars['theme_hook_suggestions'][] = $layout['layout'] . '__' . $vars['elements']['#entity_type'] . '_' . $vars['elements']['#bundle'];
  573. $vars['theme_hook_suggestions'][] = $layout['layout'] . '__' . $vars['elements']['#entity_type'] . '_' . $vars['elements']['#bundle'] . '_' . $vars['elements']['#view_mode'];
  574. }
  575. // If the layout has wrapper class lets add it.
  576. if (isset($layout['settings']['classes']['layout_class'])) {
  577. foreach ($layout['settings']['classes']['layout_class'] as $layout_class) {
  578. $vars['classes_array'][] = $layout_class;
  579. }
  580. }
  581. // Create region variables based on the layout settings.
  582. foreach ($layout['regions'] as $region_name => $region) {
  583. // Create the region content.
  584. $layout_render_array[$region_name] = array();
  585. if (isset($layout['settings']['regions'][$region_name])) {
  586. foreach ($layout['settings']['regions'][$region_name] as $key => $field) {
  587. // Make sure the field exists.
  588. if (!isset($vars[$render_container][$field])) {
  589. continue;
  590. }
  591. if (!isset($vars[$render_container][$field]['#weight'])) {
  592. $vars[$render_container][$field]['#weight'] = $key;
  593. }
  594. $layout_render_array[$region_name][$key] = $vars[$render_container][$field];
  595. }
  596. }
  597. // Add extras classes to the region.
  598. if (empty($layout['flexible'])) {
  599. $vars[$region_name . '_classes'] = !empty($layout['settings']['classes'][$region_name]) ? ' ' . implode(' ', $layout['settings']['classes'][$region_name]) : '';
  600. }
  601. // Add a wrapper to the region.
  602. if (empty($layout['flexible'])) {
  603. $vars[$region_name . '_wrapper'] = isset($layout['settings']['wrappers'][$region_name]) ? $layout['settings']['wrappers'][$region_name] : 'div';
  604. }
  605. }
  606. // Let other modules know we have rendered.
  607. $vars['rendered_by_ds'] = TRUE;
  608. // Add a layout wrapper.
  609. $vars['layout_wrapper'] = isset($layout['settings']['layout_wrapper']) ? $layout['settings']['layout_wrapper'] : 'div';
  610. // Add layout attributes if any.
  611. $vars['layout_attributes'] = '';
  612. if (!empty($layout['settings']['layout_attributes'])) {
  613. $vars['layout_attributes'] .= ' ' . $layout['settings']['layout_attributes'];
  614. }
  615. // Merge in other attributes which were passed to the template.
  616. if (!empty($layout['settings']['layout_attributes_merge'])) {
  617. // Handle classes separately.
  618. if (isset($vars['attributes_array']['class'])) {
  619. $vars['classes_array'] += $vars['attributes_array']['class'];
  620. unset($vars['attributes_array']['class']);
  621. }
  622. $vars['layout_attributes'] .= ' ' . drupal_attributes($vars['attributes_array']);
  623. }
  624. // Add an onclick attribute on the wrapper.
  625. if (!empty($layout['settings']['layout_link_attribute'])) {
  626. $url = '';
  627. switch ($layout['settings']['layout_link_attribute']) {
  628. case 'content':
  629. $uri = entity_uri($vars['elements']['#entity_type'], $vars[$object]);
  630. if (!empty($uri)) {
  631. $url = $uri['path'];
  632. }
  633. break;
  634. case 'custom':
  635. $url = $layout['settings']['layout_link_custom'];
  636. break;
  637. case 'tokens':
  638. $url = token_replace($layout['settings']['layout_link_custom'], array($vars['elements']['#entity_type'] => $vars[$object]));
  639. break;
  640. }
  641. if (!empty($url)) {
  642. $vars['layout_attributes'] .= ' onclick="location.href=\'' . url($url) . '\'"';
  643. }
  644. }
  645. // Let other modules alter the ds array before creating the region variables.
  646. $context = array('entity' => isset($vars[$object]) ? $vars[$object] : (isset($vars['elements']['#' . $object]) ? $vars['elements']['#' . $object] : ''), 'entity_type' => $vars['elements']['#entity_type'], 'bundle' => $vars['elements']['#bundle'], 'view_mode' => $vars['elements']['#view_mode']);
  647. drupal_alter('ds_pre_render', $layout_render_array, $context);
  648. foreach ($layout_render_array as $region_name => $content) {
  649. // In case this is a panels layout, add the region to the $content variable.
  650. if (isset($layout['module']) && $layout['module'] == 'panels') {
  651. $vars['content'][$region_name] = drupal_render($content);
  652. }
  653. else {
  654. $vars[$region_name] = drupal_render($content);
  655. }
  656. }
  657. }
  658. }
  659. /**
  660. * Create entity context.
  661. */
  662. function ds_create_entity_context($entity_type, $entity, &$contexts, $context_arguments = array()) {
  663. ctools_include('context');
  664. if (empty($context_arguments)) {
  665. $context_arguments = array(array(
  666. 'keyword' => $entity_type,
  667. 'identifier' => drupal_ucfirst($entity_type) . ' being viewed',
  668. 'id' => 1,
  669. 'name' => 'entity_id:' . $entity_type,
  670. 'settings' => array(),
  671. ));
  672. }
  673. ctools_context_get_context_from_arguments($context_arguments, $contexts, array($entity));
  674. }
  675. /**
  676. * Render a code field.
  677. */
  678. function ds_render_code_field($field) {
  679. if (isset($field['properties']['code'])) {
  680. $format = (isset($field['properties']['code']['format'])) ? $field['properties']['code']['format'] : 'plain_text';
  681. if ($format == 'ds_code' && module_exists('ds_format')) {
  682. $value = ds_format_php_eval($field['properties']['code']['value'], $field['entity'], isset($field['build']) ? $field['build'] : array());
  683. }
  684. else {
  685. $value = check_markup($field['properties']['code']['value'], $format);
  686. }
  687. // Token support - check on token property so we don't run every single field through token.
  688. if (isset($field['properties']['use_token']) && $field['properties']['use_token'] == TRUE) {
  689. $value = token_replace($value, array($field['entity_type'] => $field['entity']), array('clear' => TRUE));
  690. }
  691. return $value;
  692. }
  693. }
  694. /**
  695. * Render a CTools field.
  696. */
  697. function ds_render_ctools_field($field) {
  698. if (isset($field['formatter_settings']['ctools'])) {
  699. // Extreme use case where a taxonomy_term object is not
  700. // loaded on the entity and triggers notices if a view is embedded
  701. // with taxonomy term fields from the same object.
  702. // see http://drupal.org/node/1238132 - To reproduce:
  703. // 1) add 2 taxonomy field instances on a bundle
  704. // 2) configure a ds layout showing only one
  705. // 3) embed a view with the 2 taxonomies as fields.
  706. if (isset($field['formatter_settings']['load_terms']) && $field['formatter_settings']['load_terms']) {
  707. static $terms_loaded = array();
  708. $language = $field['entity']->language;
  709. $instances = field_info_instances($field['entity_type'], $field['bundle']);
  710. foreach ($instances as $key => $instance) {
  711. $info = field_info_field($key);
  712. if ($info['module'] == 'taxonomy') {
  713. if (empty($field['entity']->{$key})) {
  714. continue;
  715. }
  716. if (!isset($field['entity']->{$key}[$language])) {
  717. $language = LANGUAGE_NONE;
  718. }
  719. foreach ($field['entity']->{$key}[$language] as $tkey => $item) {
  720. if (isset($item['tid']) && !isset($item['taxonomy_term'])) {
  721. if (!isset($terms_loaded[$item['tid']])) {
  722. $terms_loaded[$item['tid']] = taxonomy_term_load($item['tid']);
  723. }
  724. $field['entity']->{$key}[$language][$tkey]['taxonomy_term'] = $terms_loaded[$item['tid']];
  725. }
  726. }
  727. }
  728. }
  729. }
  730. ctools_include('content');
  731. ctools_include('context');
  732. // Get variables.
  733. $show_title = $field['formatter_settings']['show_title'];
  734. $title_wrapper = trim($field['formatter_settings']['title_wrapper']);
  735. $ctools = unserialize($field['formatter_settings']['ctools']);
  736. $type = $ctools['type'];
  737. $subtype = $ctools['subtype'];
  738. $conf = $ctools['conf'];
  739. $entity_type = $field['entity_type'];
  740. $keywords = $arguments = $contexts = array();
  741. // Create entity context.
  742. ds_create_entity_context($entity_type, $field['entity'], $contexts);
  743. // Build the content.
  744. $data = ctools_content_render($type, $subtype, $conf, $keywords, $arguments, $contexts);
  745. // Return content.
  746. if (!empty($data->content)) {
  747. $content = '';
  748. if ($show_title) {
  749. if (empty($title_wrapper)) $title_wrapper = 'div';
  750. $content .= '<' . check_plain($title_wrapper) . '>' . $data->title . '</' . check_plain($title_wrapper) . '>';
  751. }
  752. if (is_array($data->content)) {
  753. $content .= drupal_render($data->content);
  754. }
  755. else {
  756. $content .= $data->content;
  757. }
  758. return $content;
  759. }
  760. }
  761. }
  762. /**
  763. * Render a block field.
  764. */
  765. function ds_render_block_field($field) {
  766. // Invoke the block_view hook of the module.
  767. list($module, $delta) = explode('|', $field['properties']['block']);
  768. $block = module_invoke($module, 'block_view', $delta);
  769. // Get contextual links.
  770. $contextual_links = array();
  771. $contextual = module_exists('contextual') && user_access('access contextual links');
  772. if ($contextual) {
  773. if (is_array($block['content']) && isset($block['content']['#contextual_links'])) {
  774. $contextual_links = $block['content']['#contextual_links'];
  775. }
  776. }
  777. // Render the block content.
  778. if (isset($block['content']) && is_array($block['content'])) {
  779. $block['content'] = drupal_render($block['content']);
  780. }
  781. // Go through in case we have actual content.
  782. if (!empty($block['content'])) {
  783. // Make sure subject is set.
  784. if (!isset($block['subject'])) {
  785. $block['subject'] = '';
  786. }
  787. global $theme_key;
  788. $full_block = db_query("SELECT * FROM {block} WHERE module = :module AND delta = :delta AND theme = :theme", array(':module' => $module, ':delta' => $delta, ':theme' => $theme_key))->fetchObject();
  789. if (!empty($full_block)) {
  790. if ($full_block->title == '<none>') {
  791. $block['subject'] = '';
  792. }
  793. elseif (!empty($full_block->title)) {
  794. $block['subject'] = $full_block->title;
  795. }
  796. }
  797. // i18n support.
  798. if (function_exists('i18n_block_block_view_alter')) {
  799. // Check language visibility.
  800. global $language;
  801. static $block_languages = FALSE;
  802. if (!$block_languages) {
  803. $block_languages = array();
  804. $result = db_query('SELECT module, delta, language FROM {i18n_block_language}');
  805. foreach ($result as $record) {
  806. $block_languages[$record->module][$record->delta][$record->language] = TRUE;
  807. }
  808. }
  809. if (isset($block_languages[$module][$delta]) && !isset($block_languages[$module][$delta][$language->language])) {
  810. return;
  811. }
  812. // Translate.
  813. if (!empty($full_block->i18n_mode)) {
  814. i18n_block_block_view_alter($block, $full_block);
  815. if (!empty($block['title'])) {
  816. $block['subject'] = $block['title'];
  817. }
  818. }
  819. }
  820. $block = (object) $block;
  821. switch ($field['properties']['block_render']) {
  822. case DS_BLOCK_TEMPLATE:
  823. $block->region = NULL;
  824. $block->module = $module;
  825. $block->delta = $delta;
  826. $elements = array('elements' => array('#block' => $block, '#children' => $block->content));
  827. // Add contextual links.
  828. if ($contextual) {
  829. $elements['elements'] += array('#contextual_links' => array_merge($contextual_links, array('block' => array('admin/structure/block/manage', array($block->module, $block->delta)))));
  830. }
  831. return theme('block', $elements);
  832. break;
  833. case DS_BLOCK_TITLE_CONTENT:
  834. return '<h2 class="block-title">' . $block->subject . '</h2>' . $block->content;
  835. break;
  836. case DS_BLOCK_CONTENT:
  837. return $block->content;
  838. break;
  839. }
  840. }
  841. }
  842. /**
  843. * Render a field.
  844. */
  845. function ds_render_field($field) {
  846. $title_field = FALSE;
  847. $output = '';
  848. $settings = isset($field['formatter_settings']) ? $field['formatter_settings'] : array();
  849. $settings += $field['properties']['default'];
  850. // Basic string.
  851. if (isset($settings['link text'])) {
  852. $output = t($settings['link text']);
  853. }
  854. elseif (isset($field['properties']['entity_render_key']) && isset($field['entity']->{$field['properties']['entity_render_key']})) {
  855. if ($field['entity_type'] == 'user' && $field['properties']['entity_render_key'] == 'name') {
  856. $output = format_username($field['entity']);
  857. }
  858. else {
  859. $title_field = $field['properties']['entity_render_key'] == 'title' && $field['entity_type'] == 'node';
  860. $output = $field['entity']->{$field['properties']['entity_render_key']};
  861. }
  862. }
  863. if (empty($output)) {
  864. return;
  865. }
  866. // Link.
  867. if ($settings['link']) {
  868. if (isset($field['entity']->uri['path'])) {
  869. $path = $field['entity']->uri['path'];
  870. }
  871. else {
  872. $uri_info = entity_uri($field['entity_type'], $field['entity']);
  873. $path = $uri_info['path'];
  874. }
  875. $output = l($output, $path);
  876. if ($title_field) {
  877. $output = ds_edit_support('title', $output, $field);
  878. }
  879. }
  880. else {
  881. $output = check_plain($output);
  882. if ($title_field) {
  883. $output = ds_edit_support('title', $output, $field);
  884. }
  885. }
  886. // Wrapper and class.
  887. if (!empty($settings['wrapper'])) {
  888. $wrapper = check_plain($settings['wrapper']);
  889. $class = (!empty($settings['class'])) ? ' class="' . check_plain($settings['class']) . '"' : '';
  890. $output = '<' . $wrapper . $class . '>' . $output . '</' . $wrapper . '>';
  891. }
  892. return $output;
  893. }
  894. /**
  895. * Support for edit module.
  896. *
  897. * @param $field_name
  898. * The name of the field.
  899. * @param $output
  900. * The output of the field.
  901. * @param $field
  902. * The complete field array.
  903. *
  904. * @return
  905. * The field ready for edit module or the same value in case
  906. * the edit module is not enabled.
  907. */
  908. function ds_edit_support($field_name, $output, $field) {
  909. if (module_exists('edit')) {
  910. $edit_id = "node/" . $field['entity']->nid . "/" . $field_name . "/" . $field['entity']->language . "/" . $field['view_mode'];
  911. $output = edit_wrap_pseudofield($output, $edit_id);
  912. }
  913. return $output;
  914. }
  915. /**
  916. * Render an author field.
  917. */
  918. function ds_render_author_field($field) {
  919. // Users without a user name are anonymous users. These are never linked.
  920. if (empty($field['entity']->name)) {
  921. $output = check_plain(variable_get('anonymous', t('Anonymous')));
  922. }
  923. if ($field['formatter'] == 'author') {
  924. $output = format_username($field['entity']);
  925. }
  926. if ($field['formatter'] == 'author_linked') {
  927. $output = theme('username', array('account' => $field['entity']));
  928. }
  929. return ds_edit_support('author', $output, $field);
  930. }
  931. /**
  932. * Render a markup field.
  933. */
  934. function ds_render_markup($field) {
  935. if (isset($field['entity']->{$field['properties']['key']})) {
  936. // Check for format, and let's take filtered_html as a sane default.
  937. $format = isset($field['entity']->{$field['properties']['format']}) ? $field['entity']->{$field['properties']['format']} : 'filtered_html';
  938. return check_markup($field['entity']->{$field['properties']['key']}, $format, '', TRUE);;
  939. }
  940. }
  941. /**
  942. * Return the picture.
  943. */
  944. function ds_return_picture($entity) {
  945. // Gravatar support.
  946. if (module_exists('gravatar')) {
  947. $entity = _gravatar_load_account($entity);
  948. $entity->picture = _gravatar_get_account_user_picture($entity);
  949. }
  950. if (!empty($entity->picture)) {
  951. if (is_numeric($entity->picture)) {
  952. return file_load($entity->picture);
  953. }
  954. else {
  955. return $entity->picture;
  956. }
  957. }
  958. elseif (variable_get('user_picture_default', '')) {
  959. return variable_get('user_picture_default', '');
  960. }
  961. }
  962. /**
  963. * Render a user picture.
  964. */
  965. function ds_render_user_picture($field) {
  966. $picture = ds_return_picture($field['entity']);
  967. if (!empty($picture)) {
  968. $vars = array();
  969. $filepath = (isset($picture->uri)) ? $picture->uri : $picture;
  970. $name = !empty($field['entity']->name) ? $field['entity']->name : variable_get('anonymous', t('Anonymous'));
  971. $alt = t("@user's picture", array('@user' => $name));
  972. $vars = array('path' => $filepath, 'alt' => $alt, 'title' => $alt);
  973. // If the image does not have a valid Drupal scheme (for eg. HTTP),
  974. // don't load image styles.
  975. if (module_exists('image') && file_valid_uri($filepath)) {
  976. $vars['style_name'] = str_replace('ds_picture_', '', $field['formatter']);
  977. $image = theme('image_style', $vars);
  978. }
  979. else {
  980. $image = theme('image', $vars);
  981. }
  982. if (!empty($field['entity']->uid) && user_access('access user profiles')) {
  983. return l($image, 'user/' . $field['entity']->uid, array('html' => TRUE));
  984. }
  985. else {
  986. return $image;
  987. }
  988. }
  989. }
  990. /**
  991. * Render a date field.
  992. */
  993. function ds_render_date_field($field) {
  994. $date_format = str_replace('ds_post_date_', '', $field['formatter']);
  995. return ds_edit_support($field['properties']['entity_render_key'], format_date($field['entity']->{$field['properties']['entity_render_key']}, $date_format), $field);
  996. }
  997. /**
  998. * Render a "Submitted by"-line.
  999. */
  1000. function ds_render_submitted_by($field) {
  1001. $account = user_load($field['entity']->uid);
  1002. switch ($field['formatter']) {
  1003. case 'ds_time_ago':
  1004. $interval = REQUEST_TIME - $field['entity']->created;
  1005. return t('Submitted !interval ago by !user.', array('!interval' => format_interval($interval), '!user' => theme('username', array('account' => $account))));
  1006. default:
  1007. $date_format = str_replace('ds_post_date_', '', $field['formatter']);
  1008. return t('Submitted by !user on !date.', array('!user' => theme('username', array('account' => $account)), '!date' => format_date($field['entity']->created, $date_format)));
  1009. }
  1010. }
  1011. /**
  1012. * Implements hook_field_formatter_info().
  1013. */
  1014. function ds_field_formatter_info() {
  1015. $formatters = array();
  1016. if (module_exists('taxonomy')) {
  1017. $formatters['ds_taxonomy_view_mode'] = array(
  1018. 'label' => t('Rendered taxonomy term'),
  1019. 'description' => t('Display the referenced term in a specific view mode'),
  1020. 'field types' => array('taxonomy_term_reference'),
  1021. 'settings' => array('taxonomy_term_reference_view_mode' => 'full'),
  1022. );
  1023. $formatters['ds_taxonomy_separator'] = array(
  1024. 'label' => t('Separated'),
  1025. 'description' => t('Display the referenced term with a separator.'),
  1026. 'field types' => array('taxonomy_term_reference'),
  1027. 'settings' => array(
  1028. 'taxonomy_term_link' => TRUE,
  1029. 'taxonomy_term_separator' => ', ',
  1030. ),
  1031. );
  1032. if (module_exists('i18n_taxonomy')) {
  1033. $formatters['ds_taxonomy_separator_localized'] = array(
  1034. 'label' => t('Separated (localized)'),
  1035. 'description' => t('Display the referenced term with a separator. Use this with the "localize" translation mode for vocabularies.'),
  1036. 'field types' => array('taxonomy_term_reference'),
  1037. 'settings' => array(
  1038. 'taxonomy_term_link' => TRUE,
  1039. 'taxonomy_term_separator' => ', ',
  1040. ),
  1041. );
  1042. }
  1043. }
  1044. return $formatters;
  1045. }
  1046. /**
  1047. * Implements hook_field_formatter_view().
  1048. */
  1049. function ds_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
  1050. global $language;
  1051. $element = array();
  1052. if ($display['type'] === 'ds_taxonomy_view_mode') {
  1053. $view_mode = $display['settings']['taxonomy_term_reference_view_mode'];
  1054. foreach ($items as $delta => $item) {
  1055. if ($item['tid'] == 'autocreate') {
  1056. // We don't necessarily have a link when this is
  1057. // an autocreated term, usually in preview.
  1058. // So just send the term as check plained markup.
  1059. $build['#markup'] = check_plain($item['name']);
  1060. }
  1061. else {
  1062. $term = taxonomy_term_load($item['tid']);
  1063. if (!empty($term)) {
  1064. $build = taxonomy_term_view($term, $view_mode, $langcode);
  1065. }
  1066. else {
  1067. $build['#markup'] = '';
  1068. }
  1069. }
  1070. $element[$delta] = $build;
  1071. }
  1072. }
  1073. if ($display['type'] === 'ds_taxonomy_separator' || $display['type'] == 'ds_taxonomy_separator_localized') {
  1074. $linked = $display['settings']['taxonomy_term_link'];
  1075. $terms = array();
  1076. foreach ($items as $delta => $item) {
  1077. if ($item['tid'] == 'autocreate') {
  1078. // We don't necessarily have a link when this is
  1079. // an autocreated term, usually in preview.
  1080. // So just send the term as check plained markup.
  1081. $item_display = check_plain($item['name']);
  1082. }
  1083. else {
  1084. $term = taxonomy_term_load($item['tid']);
  1085. if ($display['type'] == 'ds_taxonomy_separator_localized' && function_exists('i18n_taxonomy_term_name')) {
  1086. $term->name = i18n_taxonomy_term_name($term, $language->language);
  1087. }
  1088. $item_display = check_plain($term->name);
  1089. if ($linked) {
  1090. $uri = entity_uri('taxonomy_term', $term);
  1091. $item_display = l($term->name, $uri['path']);
  1092. }
  1093. }
  1094. $terms[] = $item_display;
  1095. }
  1096. if (!empty($terms)) {
  1097. $output = '';
  1098. $separator = $display['settings']['taxonomy_term_separator'];
  1099. $output = implode($separator, $terms);
  1100. $element[0] = array('#markup' => $output);
  1101. }
  1102. }
  1103. return $element;
  1104. }
  1105. /**
  1106. * Implements hook_contextual_links_view_alter().
  1107. */
  1108. function ds_contextual_links_view_alter(&$element, $items) {
  1109. if (!empty($element['#element']['#entity_type']) && !empty($element['#element']['#bundle']) && module_exists('field_ui') && user_access('administer content types')) {
  1110. $entity_type = $element['#element']['#entity_type'];
  1111. $bundle = $element['#element']['#bundle'];
  1112. $view_mode = isset($element['#element']['#view_mode']) ? $element['#element']['#view_mode'] : 'default';
  1113. // Get the manage display URI.
  1114. $admin_path = _field_ui_bundle_admin_path($entity_type, $bundle);
  1115. // Check view mode settings.
  1116. $view_mode_settings = field_view_mode_settings($entity_type, $bundle);
  1117. $overridden = (!empty($view_mode_settings[$view_mode]['custom_settings']) ? TRUE : FALSE);
  1118. if (!$overridden) {
  1119. $admin_path .= '/display';
  1120. }
  1121. else {
  1122. $admin_path .= '/display/' . $view_mode;
  1123. }
  1124. $element['#links']['manage-display'] = array(
  1125. 'title' => t('Manage display'),
  1126. 'href' => $admin_path,
  1127. 'query' => drupal_get_destination(),
  1128. );
  1129. }
  1130. }