1 |
85ad3d82
|
Assos Assos
|
<?php
|
2 |
|
|
|
3 |
|
|
/**
|
4 |
|
|
* @file
|
5 |
|
|
* Provide diff functions for the node module.
|
6 |
|
|
*/
|
7 |
|
|
|
8 |
|
|
/**
|
9 |
661d64c9
|
Assos Assos
|
* Private callback function to render the title field.
|
10 |
85ad3d82
|
Assos Assos
|
*/
|
11 |
661d64c9
|
Assos Assos
|
function _node_entity_diff_additional_options_title($old_node, $new_node, $context) {
|
12 |
|
|
$type = node_type_get_type($new_node);
|
13 |
|
|
$row = array(
|
14 |
|
|
'#name' => $type->title_label,
|
15 |
|
|
'#states' => array(),
|
16 |
|
|
'#weight' => -5,
|
17 |
|
|
'#settings' => array(
|
18 |
|
|
'show_header' => variable_get('diff_show_header_node', 1),
|
19 |
|
|
),
|
20 |
|
|
);
|
21 |
|
|
foreach ($context['states'] as $state) {
|
22 |
|
|
switch ($state) {
|
23 |
|
|
case 'rendered':
|
24 |
|
|
$row['#states'][$state] = array(
|
25 |
|
|
'#old' => l($old_node->title, 'node/' . $old_node->title),
|
26 |
|
|
'#new' => l($new_node->title, 'node/' . $new_node->title),
|
27 |
|
|
);
|
28 |
|
|
break;
|
29 |
|
|
|
30 |
|
|
// We specify a default so that the title is allows compared.
|
31 |
|
|
case 'raw':
|
32 |
|
|
default:
|
33 |
|
|
$row['#states'][$state] = array(
|
34 |
|
|
'#old' => array($old_node->title),
|
35 |
|
|
'#new' => array($new_node->title),
|
36 |
|
|
);
|
37 |
|
|
break;
|
38 |
85ad3d82
|
Assos Assos
|
}
|
39 |
|
|
}
|
40 |
661d64c9
|
Assos Assos
|
return $row;
|
41 |
|
|
}
|
42 |
|
|
|
43 |
|
|
/**
|
44 |
|
|
* Private callback function to render the type field.
|
45 |
|
|
*/
|
46 |
|
|
function _node_entity_diff_additional_options_type($old_node, $new_node, $context) {
|
47 |
|
|
$row = array(
|
48 |
|
|
'#name' => t('Content type'),
|
49 |
|
|
'#states' => array(),
|
50 |
|
|
'#weight' => -4,
|
51 |
|
|
'#settings' => array(),
|
52 |
|
|
);
|
53 |
|
|
$old_type = node_type_get_type($old_node);
|
54 |
|
|
$new_type = node_type_get_type($new_node);
|
55 |
|
|
|
56 |
|
|
foreach ($context['states'] as $state) {
|
57 |
|
|
$row['#states'][$state] = array(
|
58 |
|
|
'#old' => array($old_type ? $old_type->name : t('Deleted type !type', array('!type' => $old_node->type))),
|
59 |
|
|
'#new' => array($new_type ? $new_type->name : t('Deleted type !type', array('!type' => $new_node->type))),
|
60 |
|
|
);
|
61 |
|
|
}
|
62 |
|
|
return $row;
|
63 |
|
|
}
|
64 |
|
|
|
65 |
|
|
/**
|
66 |
|
|
* Private callback function to render the author field.
|
67 |
|
|
*/
|
68 |
|
|
function _node_entity_diff_additional_options_author($old_node, $new_node, $context) {
|
69 |
|
|
$old_author = user_load($old_node->uid);
|
70 |
|
|
$new_author = user_load($new_node->uid);
|
71 |
|
|
return _node_entity_diff_additional_options_account(t('Author'), $old_author, $new_author, $context, -4);
|
72 |
|
|
}
|
73 |
|
|
|
74 |
|
|
/**
|
75 |
|
|
* Private callback function to render the revision_author field.
|
76 |
|
|
*/
|
77 |
|
|
function _node_entity_diff_additional_options_revision_author($old_node, $new_node, $context) {
|
78 |
|
|
$old_author = user_load($old_node->revision_uid);
|
79 |
|
|
$new_author = user_load($new_node->revision_uid);
|
80 |
|
|
return _node_entity_diff_additional_options_account(t('Revision author'), $old_author, $new_author, $context, -3.9);
|
81 |
|
|
}
|
82 |
|
|
|
83 |
|
|
/**
|
84 |
|
|
* Private callback function to render the author field.
|
85 |
|
|
*/
|
86 |
|
|
function _node_entity_diff_additional_options_account($label, $old_author, $new_author, $context, $weight = 0) {
|
87 |
|
|
$row = array(
|
88 |
|
|
'#name' => $label,
|
89 |
|
|
'#states' => array(),
|
90 |
|
|
'#weight' => $weight,
|
91 |
|
|
'#settings' => array(),
|
92 |
|
|
);
|
93 |
|
|
foreach ($context['states'] as $state) {
|
94 |
|
|
$row['#states'][$state] = array(
|
95 |
|
|
'#old' => array($old_author ? format_username($old_author) : t('Deleted user')),
|
96 |
|
|
'#new' => array($new_author ? format_username($new_author) : t('Deleted user')),
|
97 |
|
|
);
|
98 |
|
|
}
|
99 |
|
|
return $row;
|
100 |
|
|
}
|
101 |
|
|
|
102 |
|
|
/**
|
103 |
|
|
* Private callback function to render the status, sticky and published field.
|
104 |
|
|
*/
|
105 |
|
|
function _node_entity_diff_additional_options_publishing_flags($old_node, $new_node, $context) {
|
106 |
|
|
$row = array(
|
107 |
|
|
'#name' => t('Publishing options'),
|
108 |
|
|
'#states' => array(),
|
109 |
|
|
'#weight' => -3,
|
110 |
|
|
'#settings' => array(),
|
111 |
|
|
);
|
112 |
|
|
$old_options = array($old_node->status ? t('Published') : t('Unpublished'));
|
113 |
|
|
if ($old_node->promote) {
|
114 |
|
|
$old_options[] = t('Promoted to front page');
|
115 |
|
|
}
|
116 |
|
|
if ($old_node->sticky) {
|
117 |
|
|
$old_options[] = t('Sticky at top of lists');
|
118 |
|
|
}
|
119 |
|
|
|
120 |
|
|
$new_options = array($new_node->status ? t('Published') : t('Unpublished'));
|
121 |
|
|
if ($new_node->promote) {
|
122 |
|
|
$new_options[] = t('Promoted to front page');
|
123 |
|
|
}
|
124 |
|
|
if ($new_node->sticky) {
|
125 |
|
|
$new_options[] = t('Sticky at top of lists');
|
126 |
|
|
}
|
127 |
|
|
|
128 |
|
|
foreach ($context['states'] as $state) {
|
129 |
|
|
$row['#states'][$state] = array(
|
130 |
|
|
'#old' => $old_options,
|
131 |
|
|
'#new' => $new_options,
|
132 |
|
|
);
|
133 |
|
|
}
|
134 |
|
|
return $row;
|
135 |
|
|
}
|
136 |
|
|
|
137 |
|
|
/**
|
138 |
|
|
* Private callback function to render the created field.
|
139 |
|
|
*/
|
140 |
|
|
function _node_entity_diff_additional_options_created($old_node, $new_node, $context) {
|
141 |
|
|
return _node_entity_diff_additional_options_date_field(t('Created timestamp'), $old_node->created, $new_node->created, $context, -1);
|
142 |
|
|
}
|
143 |
|
|
|
144 |
|
|
/**
|
145 |
|
|
* Private callback function to render the changed field.
|
146 |
|
|
*/
|
147 |
|
|
function _node_entity_diff_additional_options_changed($old_node, $new_node, $context) {
|
148 |
|
|
return _node_entity_diff_additional_options_date_field(t('Changed timestamp'), $old_node->changed, $new_node->changed, $context, -1);
|
149 |
|
|
}
|
150 |
|
|
|
151 |
|
|
/**
|
152 |
|
|
* Private callback function to render the revision_timestamp field.
|
153 |
|
|
*/
|
154 |
|
|
function _node_entity_diff_additional_options_revision_timestamp($old_node, $new_node, $context) {
|
155 |
|
|
return _node_entity_diff_additional_options_date_field(t('Revision timestamp'), $old_node->revision_timestamp, $new_node->revision_timestamp, $context, -1);
|
156 |
|
|
}
|
157 |
|
|
|
158 |
|
|
/**
|
159 |
|
|
* Helper function to render the date flags.
|
160 |
|
|
*/
|
161 |
|
|
function _node_entity_diff_additional_options_date_field($label, $old_date, $new_date, $context, $weight = 0) {
|
162 |
|
|
$row = array(
|
163 |
|
|
'#name' => $label,
|
164 |
|
|
'#states' => array(),
|
165 |
|
|
'#weight' => $weight,
|
166 |
|
|
'#settings' => array(),
|
167 |
|
|
);
|
168 |
|
|
|
169 |
|
|
foreach ($context['states'] as $state) {
|
170 |
|
|
$row['#states'][$state] = array(
|
171 |
|
|
'#old' => array(format_date($old_date)),
|
172 |
|
|
'#new' => array(format_date($new_date)),
|
173 |
|
|
);
|
174 |
|
|
}
|
175 |
|
|
return $row;
|
176 |
|
|
}
|
177 |
|
|
|
178 |
|
|
/**
|
179 |
|
|
* Private callback function to render the comment field.
|
180 |
|
|
*/
|
181 |
|
|
function _node_entity_diff_additional_options_comment($old_node, $new_node, $context) {
|
182 |
|
|
if (!module_exists('comment')) {
|
183 |
|
|
return array();
|
184 |
|
|
}
|
185 |
|
|
$row = array(
|
186 |
|
|
'#name' => t('Comment setting'),
|
187 |
|
|
'#states' => array(),
|
188 |
|
|
'#weight' => -1,
|
189 |
|
|
'#settings' => array(),
|
190 |
|
|
);
|
191 |
|
|
$options = array(
|
192 |
|
|
COMMENT_NODE_OPEN => t('Open'),
|
193 |
|
|
COMMENT_NODE_CLOSED => t('Closed'),
|
194 |
|
|
COMMENT_NODE_HIDDEN => t('Hidden'),
|
195 |
|
|
);
|
196 |
|
|
|
197 |
|
|
foreach ($context['states'] as $state) {
|
198 |
|
|
$row['#states'][$state] = array(
|
199 |
|
|
'#old' => array($options[$old_node->comment]),
|
200 |
|
|
'#new' => array($options[$new_node->comment]),
|
201 |
|
|
);
|
202 |
|
|
}
|
203 |
|
|
return $row;
|
204 |
85ad3d82
|
Assos Assos
|
} |