profile_fields.inc

  1. cis7 sites/all/modules/ulmus/ctools/plugins/content_types/user_context/profile_fields.inc
  2. cle7 sites/all/modules/ulmus/ctools/plugins/content_types/user_context/profile_fields.inc
  3. ecd7 sites/all/modules/ulmus/ctools/plugins/content_types/user_context/profile_fields.inc
  4. elmsmedia7 sites/all/modules/ulmus/ctools/plugins/content_types/user_context/profile_fields.inc
  5. harmony7 sites/all/modules/ulmus/ctools/plugins/content_types/user_context/profile_fields.inc
  6. icor7 sites/all/modules/ulmus/ctools/plugins/content_types/user_context/profile_fields.inc
  7. meedjum_blog7 sites/all/modules/ulmus/ctools/plugins/content_types/user_context/profile_fields.inc
  8. mooc7 sites/all/modules/ulmus/ctools/plugins/content_types/user_context/profile_fields.inc

Functions

Namesort descending Description
ctools_profile_fields_content_type_admin_title 'Title' callback for the 'profile fields' content type.
ctools_profile_fields_content_type_edit_form 'Edit' callback for the 'profile fields' content type.
ctools_profile_fields_content_type_edit_form_submit
ctools_profile_fields_content_type_render 'Render' callback for the 'profile fields' content type.
ctools_profile_fields_content_type_theme
_ctools_profile_fields_options Helper function : build the list of categories for the 'edit' form.

File

sites/all/modules/ulmus/ctools/plugins/content_types/user_context/profile_fields.inc
View source
  1. <?php
  2. if (module_exists('profile') && !(defined('MAINTENANCE_MODE') && MAINTENANCE_MODE == 'update') && !is_null(profile_user_categories())) {
  3. /**
  4. * Plugins are described by creating a $plugin array which will be used
  5. * by the system that includes this file.
  6. */
  7. $plugin = array(
  8. 'single' => TRUE,
  9. 'title' => t('Profile category'),
  10. 'icon' => 'icon_user.png',
  11. 'description' => t('Contents of a single profile category.'),
  12. 'required context' => new ctools_context_required(t('User'), 'user'),
  13. 'category' => t('User'),
  14. 'defaults' => array('category' => '', 'empty' => ''),
  15. 'hook theme' => 'ctools_profile_fields_content_type_theme',
  16. );
  17. }
  18. /**
  19. * 'Render' callback for the 'profile fields' content type.
  20. */
  21. function ctools_profile_fields_content_type_render($subtype, $conf, $panel_args, $context) {
  22. $account = isset($context->data) ? clone($context->data) : NULL;
  23. $block = new stdClass();
  24. $block->module = 'profile fields';
  25. if ($account) {
  26. // Get the category from the options
  27. $category = str_replace("_", " ", $conf['category']);
  28. // Set the subject to the name of the category
  29. $block->subject = $category;
  30. // Put all the fields in the category into an array
  31. profile_view_profile($account);
  32. if (is_array($account->content[$category])) {
  33. foreach ($account->content[$category] as $field) {
  34. if (is_array($field['#attributes'])) {
  35. // @todo 'class' is *always* an array now. 04/10/2009 sun
  36. $vars[$field['#attributes']['class']]['title'] = $field['#title'];
  37. $vars[$field['#attributes']['class']]['value'] = $field['#value'];
  38. }
  39. }
  40. }
  41. if (count($vars) == 0) {
  42. // Output the given empty text
  43. $output = $conf['empty'];
  44. }
  45. else {
  46. // Call the theme function with the field vars
  47. $output = theme('profile_fields_pane', $category, $vars);
  48. }
  49. $block->content = $output;
  50. $block->delta = $account->uid;
  51. }
  52. else {
  53. $block->subject = $conf['category'];
  54. $block->content = t('Profile content goes here.');
  55. $block->delta = 'unknown';
  56. }
  57. return $block;
  58. }
  59. /**
  60. * Helper function : build the list of categories for the 'edit' form.
  61. */
  62. function _ctools_profile_fields_options() {
  63. $cat_list = array();
  64. $categories = profile_categories();
  65. foreach ($categories as $key => $value) {
  66. $cat_list[str_replace(" ", "_", $value['name'])] = $value['title'];
  67. }
  68. return $cat_list;
  69. }
  70. /**
  71. * 'Edit' callback for the 'profile fields' content type.
  72. */
  73. function ctools_profile_fields_content_type_edit_form($form, &$form_state) {
  74. $conf = $form_state['conf'];
  75. $form['category'] = array(
  76. '#type' => 'radios',
  77. '#title' => t('Which category'),
  78. '#options' => _ctools_profile_fields_options(),
  79. '#default_value' => $conf['category'],
  80. '#prefix' => '<div class="clearfix no-float">',
  81. '#suffix' => '</div>',
  82. );
  83. $form['empty'] = array(
  84. '#type' => 'textarea',
  85. '#title' => 'Empty text',
  86. '#description' => t('Text to display if category has no data. Note that title will not display unless overridden.'),
  87. '#rows' => 5,
  88. '#default_value' => $conf['empty'],
  89. '#prefix' => '<div class="clearfix no-float">',
  90. '#suffix' => '</div>',
  91. );
  92. return $form;
  93. }
  94. function ctools_profile_fields_content_type_edit_form_submit($form, &$form_state) {
  95. // Copy everything from our defaults.
  96. foreach (array_keys($form_state['plugin']['defaults']) as $key) {
  97. $form_state['conf'][$key] = $form_state['values'][$key];
  98. }
  99. }
  100. /**
  101. * 'Title' callback for the 'profile fields' content type.
  102. */
  103. function ctools_profile_fields_content_type_admin_title($subtype, $conf, $context) {
  104. return t('"@s" profile fields', array('@s' => $conf['category']));
  105. }
  106. function ctools_profile_fields_content_type_theme(&$theme, $plugin) {
  107. $theme['profile_fields_pane'] = array(
  108. 'variables' => array('category' => NULL, 'vars' => NULL),
  109. 'path' => $plugin['path'],
  110. 'template' => 'profile_fields_pane',
  111. );
  112. }
Error | ELMSLN API

Error

×

Error message

  • Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/elmsln_community/api.elmsln.org/includes/common.inc:2791) in drupal_send_headers() (line 1499 of /var/www/html/elmsln_community/api.elmsln.org/includes/bootstrap.inc).
  • Error: Call to undefined function apc_delete() in DrupalAPCCache->clear() (line 289 of /var/www/html/elmsln_community/api.elmsln.org/sites/all/modules/apc/drupal_apc_cache.inc).
The website encountered an unexpected error. Please try again later.