t('Diff revision'), 'description' => t('Select type content, which will available for compare the revisions node and etc.'), 'page callback' => 'drupal_get_form', 'page arguments' => array('diff_revision_settings'), 'access arguments' => array('diff_revision settings') ); return $items; } /** * Callback function for form the settings */ function diff_revision_settings() { $form = array(); $get_types = node_get_types(); foreach($get_types as $key => $value) { $types[$key] = $value->name; } $form['diff_revision_type'] = array( '#type' => 'checkboxes', '#title' => t('Type node'), '#default_value' => variable_get('diff_revision_type', array()), '#options' => $types, '#description' => t('Tick type node for lighting changes.'), ); $form['diff_revision_type_mode'] = array( '#type' => 'radios', '#title' => t('Type mode'), '#default_value' => variable_get('diff_revision_type_mode', 2), '#options' => array( '0' => t('When update'), '1' => t('Count'), '2' => t('Always'), ), '#description' => t('Chose mode for view diff a revisions.'), ); $form['diff_revision_type_mode_count'] = array( '#type' => 'textfield', '#title' => t('Count day for type mode "Count"'), '#default_value' => variable_get('diff_revision_type_mode_count', 2), '#description' => t('If you selected mode "count", then you must enter number a repeates.'), ); return system_settings_form($form); } function diff_revision_nodeapi(&$node, $op) { global $user; if($op == 'view' && user_access('view diff revision') && in_array($node->type, variable_get('diff_revision_type', array()))) { $access = 0; //mode - show always if(variable_get('diff_revision_type_mode', '2') == 2) { $access = 1; } //mode - show "n" days if(variable_get('diff_revision_type_mode', '1') == 1 && $node->changed > (time() - variable_get('diff_revision_type_mode_count', 2) * 86400)) { $access = 1; } //mode - show if new version or updated if(variable_get('diff_revision_type_mode', '0') == 0 && node_mark($node->nid, $node->changed) == MARK_UPDATED) { $access = 1; } //access denied, then not show if(!$access) return; $body = db_result(db_query ("SELECT body FROM {node_revisions} WHERE nid = %d AND vid != %d ORDER BY timestamp DESC", $node->nid, $node->vid)); if($body) { drupal_add_css(drupal_get_path('module', 'diff_revision').'/diff_revision.css'); $PATH_TO_LIB_TEXT = drupal_get_path('module', 'diff_revision'); require_once 'daisydiff/src/HTMLDiff.php'; $diff = new HTMLDiffer(); $node->content['body']['#value'] = $diff->htmlDiff($body, $node->body); } } }