node_content.inc

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

Functions

File

sites/all/modules/ulmus/ctools/plugins/content_types/node_context/node_content.inc
View source
  1. <?php
  2. /**
  3. * Plugins are described by creating a $plugin array which will be used
  4. * by the system that includes this file.
  5. */
  6. $plugin = array(
  7. 'single' => TRUE,
  8. 'title' => t('Node content'),
  9. 'icon' => 'icon_node.png',
  10. 'description' => t('The content of the referenced node.'),
  11. 'required context' => new ctools_context_required(t('Node'), 'node'),
  12. 'category' => t('Node'),
  13. 'defaults' => array(
  14. 'links' => TRUE,
  15. 'no_extras' => TRUE,
  16. 'override_title' => FALSE,
  17. 'override_title_text' => '',
  18. 'identifier' => '',
  19. 'link' => TRUE,
  20. 'leave_node_title' => FALSE,
  21. 'build_mode' => 'teaser',
  22. ),
  23. );
  24. /**
  25. * Render the node content.
  26. */
  27. function ctools_node_content_content_type_render($subtype, $conf, $panel_args, $context) {
  28. if (!empty($context) && empty($context->data)) {
  29. return;
  30. }
  31. $node = isset($context->data) ? clone($context->data) : NULL;
  32. $block = new stdClass();
  33. $block->module = 'node';
  34. $block->delta = $node->nid;
  35. if (empty($node)) {
  36. $block->delta = 'placeholder';
  37. $block->title = t('Node title.');
  38. $block->content = t('Node content goes here.');
  39. }
  40. else {
  41. if (!empty($conf['identifier'])) {
  42. $node->ctools_template_identifier = $conf['identifier'];
  43. }
  44. $block->title = $node->title;
  45. if (empty($conf['leave_node_title'])) {
  46. $node->title = NULL;
  47. }
  48. $block->content = ctools_node_content_render_node($node, $conf);
  49. }
  50. if (!empty($conf['link']) && $node) {
  51. $block->title_link = "node/$node->nid";
  52. }
  53. return $block;
  54. }
  55. function ctools_node_content_render_node($node, $conf) {
  56. if (empty($node->content)) {
  57. // Copied from node_build_content() so we can fiddle with it as we render.
  58. $node->content = array();
  59. // The 'view' hook can be implemented to overwrite the default function
  60. // to display nodes.
  61. if (node_hook($node, 'view')) {
  62. $node = node_invoke($node, 'view', $conf['build_mode']);
  63. }
  64. // Build fields content.
  65. // In case of a multiple view, node_view_multiple() already ran the
  66. // 'prepare_view' step. An internal flag prevents the operation from running
  67. // twice.
  68. field_attach_prepare_view('node', array($node->nid => $node), $conf['build_mode']);
  69. entity_prepare_view('node', array($node->nid => $node));
  70. $node->content += field_attach_view('node', $node, $conf['build_mode']);
  71. // Always display a read more link on teasers because we have no way
  72. // to know when a teaser view is different than a full view.
  73. $links = array();
  74. if ($conf['build_mode'] == 'teaser') {
  75. $links['node-readmore'] = array(
  76. 'title' => t('Read more'),
  77. 'href' => 'node/' . $node->nid,
  78. 'attributes' => array('rel' => 'tag', 'title' => strip_tags($node->title))
  79. );
  80. }
  81. $node->content['links'] = array(
  82. '#theme' => 'links__node',
  83. '#links' => $links,
  84. '#attributes' => array('class' => array('links', 'inline')),
  85. );
  86. if (empty($conf['no_extras'])) {
  87. // Allow modules to make their own additions to the node.
  88. $langcode = $GLOBALS['language_content']->language;
  89. module_invoke_all('node_view', $node, $conf['build_mode'], $langcode);
  90. module_invoke_all('entity_view', $node, 'node', $conf['build_mode'], $langcode);
  91. }
  92. }
  93. // Set the proper node part, then unset unused $node part so that a bad
  94. // theme can not open a security hole.
  95. $content = $node->content;
  96. $content += array(
  97. '#theme' => 'node',
  98. '#node' => $node,
  99. '#view_mode' => $conf['build_mode'],
  100. '#language' => NULL,
  101. );
  102. // Add contextual links for this node, except when the node is already being
  103. // displayed on its own page. Modules may alter this behavior (for example,
  104. // to restrict contextual links to certain view modes) by implementing
  105. // hook_node_view_alter().
  106. if (!empty($node->nid) && !($conf['build_mode'] == 'full' && node_is_page($node))) {
  107. $content['#contextual_links']['node'] = array('node', array($node->nid));
  108. }
  109. // Allow modules to modify the structured node.
  110. $type = 'node';
  111. drupal_alter(array('node_view', 'entity_view'), $content, $type);
  112. // Kill the links if not requested.
  113. if (!$conf['links']) {
  114. $content['links']['#access'] = FALSE;
  115. }
  116. return $content;
  117. }
  118. /**
  119. * Returns an edit form for the custom type.
  120. */
  121. function ctools_node_content_content_type_edit_form($form, &$form_state) {
  122. $conf = $form_state['conf'];
  123. $form['leave_node_title'] = array(
  124. '#type' => 'checkbox',
  125. '#default_value' => !empty($conf['leave_node_title']),
  126. '#title' => t('Leave node title'),
  127. '#description' => t('Advanced: if checked, do not touch the node title; this can cause the node title to appear twice unless your theme is aware of this.'),
  128. );
  129. $form['link'] = array(
  130. '#title' => t('Link title to node'),
  131. '#type' => 'checkbox',
  132. '#default_value' => $conf['link'],
  133. '#description' => t('Check here to make the title link to the node.'),
  134. );
  135. $form['links'] = array(
  136. '#type' => 'checkbox',
  137. '#default_value' => $conf['links'],
  138. '#title' => t('Include node links for "add comment", "read more" etc.'),
  139. );
  140. $form['no_extras'] = array(
  141. '#type' => 'checkbox',
  142. '#default_value' => $conf['no_extras'],
  143. '#title' => t('No extras'),
  144. '#description' => t('Check here to disable additions that modules might make to the node, such as file attachments and CCK fields; this should just display the basic teaser or body.'),
  145. );
  146. $form['identifier'] = array(
  147. '#type' => 'textfield',
  148. '#default_value' => $conf['identifier'],
  149. '#title' => t('Template identifier'),
  150. '#description' => t('This identifier will be added as a template suggestion to display this node: node--panel--IDENTIFIER.tpl.php. Please see the Drupal theming guide for information about template suggestions.'),
  151. );
  152. $entity = entity_get_info('node');
  153. $build_mode_options = array();
  154. foreach ($entity['view modes'] as $mode => $option) {
  155. $build_mode_options[$mode] = $option['label'];
  156. }
  157. $form['build_mode'] = array(
  158. '#title' => t('Build mode'),
  159. '#type' => 'select',
  160. '#description' => t('Select a build mode for this node.'),
  161. '#options' => $build_mode_options,
  162. '#default_value' => $conf['build_mode'],
  163. );
  164. return $form;
  165. }
  166. function ctools_node_content_content_type_edit_form_submit($form, &$form_state) {
  167. // Copy everything from our defaults.
  168. foreach (array_keys($form_state['plugin']['defaults']) as $key) {
  169. $form_state['conf'][$key] = $form_state['values'][$key];
  170. }
  171. }
  172. function ctools_node_content_content_type_admin_title($subtype, $conf, $context) {
  173. return t('"@s" content', array('@s' => $context->identifier));
  174. }
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.