diff.module

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

Provides functionality to show a diff between two node revisions.

Functions

Namesort descending Description
diff_admin_paths_alter Implements hook_admin_paths_alter().
diff_available_states The various states that are available.
diff_block_configure Implements hook_block_configure().
diff_block_info Implements hook_block_info().
diff_block_save Implements hook_block_save().
diff_block_view Implements hook_block_view().
diff_build_attachments Helper function to load any CSS or JScript files required by a page or form.
diff_entity_info_alter Implements hook_entity_info_alter().
diff_filter_xss A wrapper function for filter_xss() to exclude all tags.
diff_form_node_form_alter Implements hook_form_BASE_FORM_ID_alter().
diff_form_node_type_form_alter Implements hook_form_BASE_FORM_ID_alter().
diff_get_inline Render and markup a diff of two strings into HTML markup.
diff_get_rows Render the table rows for theme('table').
diff_help Implements hook_help().
diff_hook_info Implements hook_hook_info().
diff_inline_ajax AHAH callback for rendering the inline diff of a node.
diff_inline_form Form builder: Inline diff controls.
diff_inline_form_submit Form submission handler for diff_inline_form() for JS-disabled clients.
diff_menu Implements hook_menu().
diff_menu_alter Implements hook_menu_alter().
diff_node_form_build_preview_changes Submit handler for the 'View changes' action.
diff_node_revision_access Access callback for the node revisions page.
diff_node_type_delete Implements hook_node_type_delete().
diff_node_type_update Implements hook_node_type_update().
diff_node_view_alter Implements hook_node_view_alter().
diff_normalise_text A helper function to normalise system differences.
diff_theme Implements hook_theme().

Constants

Namesort descending Description
DIFF_SORT_CUSTOM Exposed sorting options.
DIFF_SORT_NONE Exposed sorting options.
DIFF_SORT_VALUE Exposed sorting options.
REVISION_LIST_SIZE Number of items on one page of the revision list.

File

sites/all/modules/ulmus/diff/diff.module
View source
  1. <?php
  2. /**
  3. * @file
  4. * Provides functionality to show a diff between two node revisions.
  5. */
  6. /**
  7. * Number of items on one page of the revision list.
  8. */
  9. define('REVISION_LIST_SIZE', 50);
  10. /**
  11. * Exposed sorting options.
  12. *
  13. * No sorting means sorting by delta value for fields.
  14. */
  15. define('DIFF_SORT_NONE', '0');
  16. /**
  17. * Exposed sorting options.
  18. *
  19. * This normally sorts by the rendered comparison.
  20. */
  21. define('DIFF_SORT_VALUE', '1');
  22. /**
  23. * Exposed sorting options.
  24. *
  25. * It is up to the field / entity to decide how to handle the sort.
  26. */
  27. define('DIFF_SORT_CUSTOM', '-1');
  28. /**
  29. * Implements hook_help().
  30. */
  31. function diff_help($path, $arg) {
  32. switch ($path) {
  33. case 'admin/help#diff':
  34. $output = '<p>' . t('The Diff module replaces the normal <em>Revisions</em> node tab. Diff enhances the listing of revisions with an option to view the differences between any two content revisions. Access to this feature is controlled with the <em>View revisions</em> permission. The feature can be disabled for an entire content type on the content type configuration page. Diff also provides an optional <em>View changes</em> button while editing a node.') . '</p>';
  35. return $output;
  36. case 'node/%/revisions/%/view':
  37. // The translated strings should match node_help('node/%/revisions').
  38. return '<p>' . t('Revisions allow you to track differences between multiple versions of your content, and revert back to older versions.') . '</p>';
  39. case 'node/%/revisions/view/%/%':
  40. return '<p>' . t('Comparing two revisions:') . '</p>';
  41. }
  42. }
  43. /**
  44. * The various states that are available.
  45. */
  46. function diff_available_states($entity_type = NULL) {
  47. $states = array(
  48. 'raw' => t('Standard'),
  49. 'raw_plain' => t('Marked down'),
  50. );
  51. return $states;
  52. }
  53. /**
  54. * Implements hook_menu().
  55. *
  56. * @todo: Review this.
  57. */
  58. function diff_menu() {
  59. /*
  60. * By using MENU_LOCAL_TASK (and 'tab_parent') we can get the various
  61. * revision-views to show the View|Edit|Revision-tabs of the node on top,
  62. * and have the Revisions-tab open. To avoid creating/showing any extra tabs
  63. * or sub-tabs (tasks below top level) for the various paths (i.e. "Diff",
  64. * "Show latest" and "Show a specific revision") that need a revision-id (vid)
  65. * parameter, we make sure to set 'tab_parent' a bit odd. This solution may
  66. * not be the prettiest one, but by avoiding having two _LOCAL_TASKs sharing
  67. * a parent that can be accessed by its full path, it seems to work as
  68. * desired. Breadcrumbs work decently, at least the node link is among the
  69. * crumbs. For some reason any breadcrumbs "before/above" the node is only
  70. * seen at 'node/%node/revisions/%/view'.
  71. */
  72. // Not used directly, but was created to get the other menu items to work.
  73. $items['node/%node/revisions/list'] = array(
  74. 'title' => 'List revisions',
  75. 'page callback' => 'diff_diffs_overview',
  76. 'type' => MENU_DEFAULT_LOCAL_TASK,
  77. 'access callback' => 'diff_node_revision_access',
  78. 'access arguments' => array(1),
  79. 'file' => 'diff.pages.inc',
  80. );
  81. $items['node/%node/revisions/view'] = array(
  82. 'title' => 'Compare revisions',
  83. 'page callback' => 'diff_diffs_show',
  84. 'page arguments' => array(1, 4, 5, 6),
  85. 'type' => MENU_LOCAL_TASK,
  86. 'access callback' => 'diff_node_revision_access',
  87. 'access arguments' => array(1),
  88. 'tab_parent' => 'node/%/revisions/list',
  89. 'file' => 'diff.pages.inc',
  90. );
  91. $items['node/%node/revisions/view/latest'] = array(
  92. 'title' => 'Show latest difference',
  93. 'page callback' => 'diff_latest',
  94. 'page arguments' => array(1),
  95. 'type' => MENU_LOCAL_TASK,
  96. 'access callback' => 'diff_node_revision_access',
  97. 'access arguments' => array(1),
  98. 'tab_parent' => 'node/%/revisions/view',
  99. 'file' => 'diff.pages.inc',
  100. );
  101. // Administrative settings.
  102. $items['admin/config/content/diff'] = array(
  103. 'title' => 'Diff',
  104. 'description' => 'Diff settings.',
  105. 'file' => 'diff.admin.inc',
  106. 'page callback' => 'drupal_get_form',
  107. 'page arguments' => array('diff_admin_settings'),
  108. 'access arguments' => array('administer site configuration'),
  109. );
  110. $items['admin/config/content/diff/settings'] = array(
  111. 'title' => 'Settings',
  112. 'type' => MENU_DEFAULT_LOCAL_TASK,
  113. 'weight' => -10,
  114. );
  115. $items['admin/config/content/diff/fields'] = array(
  116. 'title' => 'Fields',
  117. 'description' => 'Field support and settings overview.',
  118. 'file' => 'diff.admin.inc',
  119. 'page callback' => 'diff_admin_field_overview',
  120. 'access arguments' => array('administer site configuration'),
  121. 'type' => MENU_LOCAL_TASK,
  122. );
  123. $items['admin/config/content/diff/fields/%'] = array(
  124. 'title' => 'Global field settings',
  125. 'page callback' => 'drupal_get_form',
  126. 'page arguments' => array('diff_admin_global_field_settings', 5),
  127. 'access arguments' => array('administer site configuration'),
  128. 'type' => MENU_VISIBLE_IN_BREADCRUMB,
  129. 'file' => 'diff.admin.inc',
  130. );
  131. $items['admin/config/content/diff/entities'] = array(
  132. 'title' => 'Entities',
  133. 'description' => 'Entity settings.',
  134. 'file' => 'diff.admin.inc',
  135. 'page callback' => 'drupal_get_form',
  136. 'page arguments' => array('diff_admin_global_entity_settings', 'node'),
  137. 'access arguments' => array('administer site configuration'),
  138. 'type' => MENU_LOCAL_TASK,
  139. );
  140. $items['admin/config/content/diff/entities/node'] = array(
  141. 'title' => 'Node',
  142. 'type' => MENU_DEFAULT_LOCAL_TASK,
  143. 'weight' => -10,
  144. );
  145. return $items;
  146. }
  147. /**
  148. * Implements hook_menu_alter().
  149. */
  150. function diff_menu_alter(&$callbacks) {
  151. // Overwrite the default 'Revisions' page.
  152. $callbacks['node/%node/revisions']['page callback'] = 'diff_diffs_overview';
  153. $callbacks['node/%node/revisions']['module'] = 'diff';
  154. $callbacks['node/%node/revisions']['file'] = 'diff.pages.inc';
  155. $callbacks['node/%node/revisions/%/view']['tab_parent'] = 'node/%/revisions/list';
  156. $callbacks['node/%node/revisions/%/revert']['tab_parent'] = 'node/%/revisions/%/view';
  157. $callbacks['node/%node/revisions/%/delete']['tab_parent'] = 'node/%/revisions/%/view';
  158. $callbacks['node/%node/revisions']['access callback']
  159. = $callbacks['node/%node/revisions/%/view']['access callback']
  160. = $callbacks['node/%node/revisions/%/revert']['access callback']
  161. = $callbacks['node/%node/revisions/%/delete']['access callback'] = 'diff_node_revision_access';
  162. }
  163. /**
  164. * Implements hook_admin_paths_alter().
  165. */
  166. function diff_admin_paths_alter(&$paths) {
  167. // By default, treat all diff pages as administrative.
  168. if (variable_get('diff_admin_path_node', 1)) {
  169. $paths['node/*/revisions/view/*/*'] = TRUE;
  170. }
  171. }
  172. /**
  173. * Access callback for the node revisions page.
  174. */
  175. function diff_node_revision_access($node, $op = 'view') {
  176. $may_revision_this_type = variable_get('diff_enable_revisions_page_node_' . $node->type, TRUE) || user_access('administer nodes');
  177. return $may_revision_this_type && _node_revision_access($node, $op);
  178. }
  179. /**
  180. * Implements hook_hook_info().
  181. */
  182. function diff_hook_info() {
  183. $hooks['entity_diff'] = array(
  184. 'group' => 'diff',
  185. );
  186. $hooks['diff'] = array(
  187. 'group' => 'diff',
  188. );
  189. $hooks['field_diff_view_prepare_alter'] = array(
  190. 'group' => 'diff',
  191. );
  192. $hooks['field_diff_view_alter'] = array(
  193. 'group' => 'diff',
  194. );
  195. return $hooks;
  196. }
  197. /**
  198. * Implements hook_entity_info_alter().
  199. *
  200. * Although the module only provides an UI for comparing nodes, it has an
  201. * extendable API for any entity, so we supply two view modes for all entities.
  202. * - diff_standard: This view mode is used to tell the module how to compare
  203. * individual fields. This is used on the revisions page.
  204. */
  205. function diff_entity_info_alter(&$entity_info) {
  206. foreach (array_keys($entity_info) as $entity_type) {
  207. if (!empty($entity_info[$entity_type]['view modes'])) {
  208. $entity_info[$entity_type]['view modes'] += array(
  209. 'diff_standard' => array(
  210. 'label' => t('Revision comparison'),
  211. 'custom settings' => FALSE,
  212. ),
  213. );
  214. }
  215. }
  216. }
  217. /**
  218. * Implements hook_block_info().
  219. */
  220. function diff_block_info() {
  221. return array(
  222. 'inline' => array(
  223. 'info' => t('Inline differences'),
  224. ),
  225. );
  226. }
  227. /**
  228. * Implements hook_block_configure().
  229. */
  230. function diff_block_configure($delta = '') {
  231. $form = array();
  232. switch ($delta) {
  233. case 'inline':
  234. $form['bundles'] = array(
  235. '#type' => 'checkboxes',
  236. '#title' => t('Enabled content types'),
  237. '#default_value' => variable_get('diff_show_diff_inline_node_bundles', array()),
  238. '#options' => node_type_get_names(),
  239. '#description' => t('Show this block only on pages that display content of the given type(s).'),
  240. );
  241. break;
  242. }
  243. return $form;
  244. }
  245. /**
  246. * Implements hook_block_save().
  247. */
  248. function diff_block_save($delta = '', $edit = array()) {
  249. switch ($delta) {
  250. case 'inline':
  251. variable_set('diff_show_diff_inline_node_bundles', $edit['bundles']);
  252. break;
  253. }
  254. }
  255. /**
  256. * Implements hook_block_view().
  257. */
  258. function diff_block_view($delta) {
  259. if ($delta === 'inline' && user_access('view revisions') && ($node = menu_get_object()) && arg(2) !== 'edit') {
  260. $enabled_types = variable_get('diff_show_diff_inline_node_bundles', array());
  261. if (!empty($enabled_types[$node->type])) {
  262. $block = array();
  263. $revisions = node_revision_list($node);
  264. if (count($revisions) > 1) {
  265. $block['subject'] = t('Highlight changes');
  266. $block['content'] = drupal_get_form('diff_inline_form', $node, $revisions);
  267. }
  268. return $block;
  269. }
  270. }
  271. }
  272. /**
  273. * Implements hook_node_view_alter().
  274. */
  275. function diff_node_view_alter(&$build) {
  276. $node = $build['#node'];
  277. if (user_access('view revisions') && in_array($node->type, variable_get('diff_show_diff_inline_node_bundles', array()))) {
  278. // Ugly but cheap way to check that we are viewing a node's revision page.
  279. if (arg(2) === 'revisions' && arg(3) === $node->vid) {
  280. module_load_include('inc', 'diff', 'diff.pages');
  281. $old_vid = _diff_get_previous_vid(node_revision_list($node), $node->vid);
  282. $build = array('#markup' => diff_inline_show($node, $old_vid));
  283. }
  284. $build['#prefix'] = isset($build['#prefix']) ? "<div id='diff-inline-{$node->nid}'>" . $build['#prefix'] : "<div id='diff-inline-{$node->nid}'>";
  285. $build['#suffix'] = isset($build['#suffix']) ? $build['#suffix'] . "</div>" : "</div>";
  286. }
  287. }
  288. /**
  289. * Implements hook_form_BASE_FORM_ID_alter().
  290. */
  291. function diff_form_node_form_alter(&$form, $form_state) {
  292. // Add a 'View changes' button on the node edit form.
  293. $node = $form['#node'];
  294. if (variable_get('diff_show_preview_changes_node_' . $node->type, TRUE) && !empty($node->nid)) {
  295. $form['actions']['preview_changes'] = array(
  296. '#type' => 'submit',
  297. '#value' => t('View changes'),
  298. '#weight' => 12,
  299. '#submit' => array('diff_node_form_build_preview_changes'),
  300. );
  301. }
  302. }
  303. /**
  304. * Implements hook_form_BASE_FORM_ID_alter().
  305. */
  306. function diff_form_node_type_form_alter(&$form, $form_state) {
  307. if (isset($form['type'])) {
  308. $type = $form['#node_type'];
  309. $form['diff'] = array(
  310. '#title' => t('Compare revisions'),
  311. '#type' => 'fieldset',
  312. '#group' => 'additional_settings',
  313. '#tree' => FALSE,
  314. );
  315. $form['diff']['diff_show_preview_changes_node'] = array(
  316. '#type' => 'checkbox',
  317. '#title' => t('Show <em>View changes</em> button on node edit form'),
  318. '#weight' => 10,
  319. '#default_value' => variable_get('diff_show_preview_changes_node_' . $type->type, TRUE),
  320. );
  321. $form['diff']['diff_enable_revisions_page_node'] = array(
  322. '#type' => 'checkbox',
  323. '#title' => t('Enable the <em>Revisions</em> page for this content type'),
  324. '#weight' => 11,
  325. '#default_value' => variable_get('diff_enable_revisions_page_node_' . $type->type, TRUE),
  326. );
  327. $options = array();
  328. $info = entity_get_info('node');
  329. foreach ($info['view modes'] as $view_mode => $view_mode_info) {
  330. $options[$view_mode] = $view_mode_info['label'];
  331. }
  332. $form['diff']['diff_view_mode_preview_node'] = array(
  333. '#type' => 'select',
  334. '#title' => t('Standard comparison preview'),
  335. '#description' => t('Governs the <em>Current revision</em> view mode when doing standard comparisons.'),
  336. '#options' => $options,
  337. '#weight' => 13,
  338. '#default_value' => variable_get('diff_view_mode_preview_node_' . $type->type, 'full'),
  339. '#empty_value' => '',
  340. '#empty_option' => t('- Do not display -'),
  341. );
  342. }
  343. }
  344. /**
  345. * Implements hook_node_type_update().
  346. *
  347. * This tracks the diff settings in case the node content type is renamed.
  348. */
  349. function diff_node_type_update($info) {
  350. if (!empty($info->old_type) && $info->old_type != $info->type) {
  351. $type_variables = array(
  352. 'diff_show_preview_changes_node',
  353. 'diff_enable_revisions_page_node',
  354. 'diff_view_mode_preview_node',
  355. );
  356. foreach ($type_variables as $prefix) {
  357. $setting = variable_get($prefix . '_' . $info->old_type, NULL);
  358. if (isset($setting)) {
  359. variable_del($prefix . '_' . $info->old_type);
  360. variable_set($prefix . '_' . $info->type, $setting);
  361. }
  362. }
  363. // Block settings are combined in a single variable.
  364. $inline_block_types = variable_get('diff_show_diff_inline_node_bundles', array());
  365. if (isset($inline_block_types[$info->old_type])) {
  366. if (!empty($inline_block_types[$info->old_type])) {
  367. $inline_block_types[$info->type] = $info->type;
  368. }
  369. unset($inline_block_types[$info->old_type]);
  370. variable_set('diff_show_diff_inline_node_bundles', $inline_block_types);
  371. }
  372. }
  373. }
  374. /**
  375. * Implements hook_node_type_delete().
  376. */
  377. function diff_node_type_delete($info) {
  378. variable_del('diff_show_preview_changes_node_' . $info->type);
  379. variable_del('diff_enable_revisions_page_node_' . $info->type);
  380. variable_del('diff_view_mode_preview_node_' . $info->type);
  381. }
  382. /**
  383. * Submit handler for the 'View changes' action.
  384. *
  385. * @see node_form_build_preview()
  386. */
  387. function diff_node_form_build_preview_changes($form, &$form_state) {
  388. module_load_include('inc', 'diff', 'diff.pages');
  389. $old_node = clone node_load($form_state['values']['nid']);
  390. $node = node_form_submit_build_node($form, $form_state);
  391. // Create diff of old node and edited node.
  392. $rows = _diff_body_rows($old_node, $node);
  393. $header = _diff_default_header(t('Original'), t('Changes'));
  394. $changes = theme('table__diff__preview', array(
  395. 'header' => $header,
  396. 'rows' => $rows,
  397. 'attributes' => array('class' => 'diff'),
  398. 'colgroups' => _diff_default_cols(),
  399. 'sticky' => FALSE,
  400. ));
  401. // Prepend diff to edit form.
  402. $form_state['node_preview'] = $changes;
  403. $form_state['rebuild'] = TRUE;
  404. }
  405. /**
  406. * Implements hook_theme().
  407. */
  408. function diff_theme() {
  409. return array(
  410. 'diff_node_revisions' => array(
  411. 'render element' => 'form',
  412. 'file' => 'diff.theme.inc',
  413. ),
  414. 'diff_header_line' => array(
  415. 'arguments' => array('lineno' => NULL),
  416. 'file' => 'diff.theme.inc',
  417. ),
  418. 'diff_content_line' => array(
  419. 'arguments' => array('line' => NULL),
  420. 'file' => 'diff.theme.inc',
  421. ),
  422. 'diff_empty_line' => array(
  423. 'arguments' => array('line' => NULL),
  424. 'file' => 'diff.theme.inc',
  425. ),
  426. 'diff_inline_form' => array(
  427. 'render element' => 'form',
  428. 'file' => 'diff.theme.inc',
  429. ),
  430. 'diff_inline_metadata' => array(
  431. 'arguments' => array('node' => NULL),
  432. 'file' => 'diff.theme.inc',
  433. ),
  434. 'diff_inline_chunk' => array(
  435. 'arguments' => array('text' => '', 'type' => NULL),
  436. 'file' => 'diff.theme.inc',
  437. ),
  438. );
  439. }
  440. /**
  441. * Render the table rows for theme('table').
  442. *
  443. * @param string $a
  444. * The source string to compare from.
  445. * @param string $b
  446. * The target string to compare to.
  447. * @param boolean $show_header
  448. * Display diff context headers. For example, "Line x".
  449. * @param array $line_stats
  450. * This structure tracks line numbers across multiple calls to DiffFormatter.
  451. *
  452. * @return array
  453. * Array of rows usable with theme('table').
  454. */
  455. function diff_get_rows($a, $b, $show_header = FALSE, &$line_stats = NULL) {
  456. $a = is_array($a) ? $a : explode("\n", $a);
  457. $b = is_array($b) ? $b : explode("\n", $b);
  458. if (!isset($line_stats)) {
  459. $line_stats = array(
  460. 'counter' => array('x' => 0, 'y' => 0),
  461. 'offset' => array('x' => 0, 'y' => 0),
  462. );
  463. }
  464. $formatter = new DrupalDiffFormatter();
  465. // Header is the line counter.
  466. $formatter->show_header = $show_header;
  467. $formatter->line_stats = &$line_stats;
  468. $diff = new Diff($a, $b);
  469. return $formatter->format($diff);
  470. }
  471. /**
  472. * Render and markup a diff of two strings into HTML markup.
  473. *
  474. * @param string $a
  475. * The source string to compare from.
  476. * @param string $b
  477. * The target string to compare to.
  478. *
  479. * @return string
  480. * String containing HTML markup.
  481. */
  482. function diff_get_inline($a, $b) {
  483. $diff = new DrupalDiffInline($a, $b);
  484. return $diff->render();
  485. }
  486. /**
  487. * Form builder: Inline diff controls.
  488. */
  489. function diff_inline_form($form, $form_state, $node, $revisions) {
  490. $form = array();
  491. $form['node'] = array(
  492. '#type' => 'value',
  493. '#value' => $node,
  494. );
  495. $form['revision'] = array(
  496. '#type' => 'select',
  497. '#options' => array(0 => t('- No highlighting -')),
  498. '#default_value' => (arg(2) === 'revisions' && arg(3) === $node->vid) ? $node->vid : 0,
  499. '#ajax' => array(
  500. 'callback' => 'diff_inline_ajax',
  501. 'wrapper' => "node-{$node->nid}",
  502. 'method' => 'replace',
  503. ),
  504. );
  505. foreach ($revisions as $revision) {
  506. $form['revision']['#options'][$revision->vid] = t('@revision by @name', array(
  507. '@revision' => format_date($revision->timestamp, 'short'),
  508. '@name' => format_username($revision),
  509. ));
  510. }
  511. $form['submit'] = array(
  512. '#type' => 'submit',
  513. '#value' => t('View'),
  514. '#submit' => array('diff_inline_form_submit'),
  515. '#attributes' => array('class' => array('diff-js-hidden')),
  516. );
  517. return $form;
  518. }
  519. /**
  520. * AHAH callback for rendering the inline diff of a node.
  521. */
  522. function diff_inline_ajax($form, $form_state) {
  523. module_load_include('inc', 'diff', 'diff.pages');
  524. $node = $form['node']['#value'];
  525. $vid = isset($form_state['values']['revision']) ? $form_state['values']['revision'] : 0;
  526. return "<div id='node-{$node->nid}'>" . diff_inline_show($node, $vid) . "</div>";
  527. }
  528. /**
  529. * Form submission handler for diff_inline_form() for JS-disabled clients.
  530. */
  531. function diff_inline_form_submit(&$form, &$form_state) {
  532. if (isset($form_state['values']['revision'], $form_state['values']['node'])) {
  533. $node = $form_state['values']['node'];
  534. $vid = $form_state['values']['revision'];
  535. $form_state['redirect'] = "node/{$node->nid}/revisions/{$vid}/view";
  536. }
  537. }
  538. /**
  539. * A helper function to normalise system differences.
  540. *
  541. * This handles differences in:
  542. * - line endings: Mac, Windows and UNIX all use different line endings.
  543. */
  544. function diff_normalise_text($text) {
  545. $text = str_replace(array("\r\n", "\r"), "\n", $text);
  546. return $text;
  547. }
  548. /**
  549. * A wrapper function for filter_xss() to exclude all tags.
  550. */
  551. function diff_filter_xss($string) {
  552. return filter_xss($string, array());
  553. }
  554. /**
  555. * Helper function to load any CSS or JScript files required by a page or form.
  556. */
  557. function diff_build_attachments($jscript = FALSE) {
  558. $attachments = array();
  559. $theme = variable_get('diff_theme', 'default');
  560. if ($theme) {
  561. $attachments['css'] = array(
  562. drupal_get_path('module', 'diff') . "/css/diff.{$theme}.css",
  563. );
  564. }
  565. $type = variable_get('diff_radio_behavior', 'simple');
  566. if ($jscript && $type) {
  567. $attachments['js'] = array(
  568. drupal_get_path('module', 'diff') . "/js/diff.js",
  569. array(
  570. 'data' => array('diffRevisionRadios' => $type),
  571. 'type' => 'setting',
  572. ),
  573. );
  574. }
  575. return $attachments;
  576. }
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.