comparison core/modules/node/src/Controller/NodeController.php @ 14:1fec387a4317

Update Drupal core to 8.5.2 via Composer
author Chris Cannam
date Mon, 23 Apr 2018 09:46:53 +0100
parents 4c8ae668cc8c
children c2387f117808
comparison
equal deleted inserted replaced
13:5fb285c0d0e3 14:1fec387a4317
171 $revert_permission = (($account->hasPermission("revert $type revisions") || $account->hasPermission('revert all revisions') || $account->hasPermission('administer nodes')) && $node->access('update')); 171 $revert_permission = (($account->hasPermission("revert $type revisions") || $account->hasPermission('revert all revisions') || $account->hasPermission('administer nodes')) && $node->access('update'));
172 $delete_permission = (($account->hasPermission("delete $type revisions") || $account->hasPermission('delete all revisions') || $account->hasPermission('administer nodes')) && $node->access('delete')); 172 $delete_permission = (($account->hasPermission("delete $type revisions") || $account->hasPermission('delete all revisions') || $account->hasPermission('administer nodes')) && $node->access('delete'));
173 173
174 $rows = []; 174 $rows = [];
175 $default_revision = $node->getRevisionId(); 175 $default_revision = $node->getRevisionId();
176 $current_revision_displayed = FALSE;
176 177
177 foreach ($this->getRevisionIds($node, $node_storage) as $vid) { 178 foreach ($this->getRevisionIds($node, $node_storage) as $vid) {
178 /** @var \Drupal\node\NodeInterface $revision */ 179 /** @var \Drupal\node\NodeInterface $revision */
179 $revision = $node_storage->loadRevision($vid); 180 $revision = $node_storage->loadRevision($vid);
180 // Only show revisions that are affected by the language that is being 181 // Only show revisions that are affected by the language that is being
185 '#account' => $revision->getRevisionUser(), 186 '#account' => $revision->getRevisionUser(),
186 ]; 187 ];
187 188
188 // Use revision link to link to revisions that are not active. 189 // Use revision link to link to revisions that are not active.
189 $date = $this->dateFormatter->format($revision->revision_timestamp->value, 'short'); 190 $date = $this->dateFormatter->format($revision->revision_timestamp->value, 'short');
190 if ($vid != $node->getRevisionId()) { 191
192 // We treat also the latest translation-affecting revision as current
193 // revision, if it was the default revision, as its values for the
194 // current language will be the same of the current default revision in
195 // this case.
196 $is_current_revision = $vid == $default_revision || (!$current_revision_displayed && $revision->wasDefaultRevision());
197 if (!$is_current_revision) {
191 $link = $this->l($date, new Url('entity.node.revision', ['node' => $node->id(), 'node_revision' => $vid])); 198 $link = $this->l($date, new Url('entity.node.revision', ['node' => $node->id(), 'node_revision' => $vid]));
192 } 199 }
193 else { 200 else {
194 $link = $node->link($date); 201 $link = $node->link($date);
202 $current_revision_displayed = TRUE;
195 } 203 }
196 204
197 $row = []; 205 $row = [];
198 $column = [ 206 $column = [
199 'data' => [ 207 'data' => [
208 ]; 216 ];
209 // @todo Simplify once https://www.drupal.org/node/2334319 lands. 217 // @todo Simplify once https://www.drupal.org/node/2334319 lands.
210 $this->renderer->addCacheableDependency($column['data'], $username); 218 $this->renderer->addCacheableDependency($column['data'], $username);
211 $row[] = $column; 219 $row[] = $column;
212 220
213 if ($vid == $default_revision) { 221 if ($is_current_revision) {
214 $row[] = [ 222 $row[] = [
215 'data' => [ 223 'data' => [
216 '#prefix' => '<em>', 224 '#prefix' => '<em>',
217 '#markup' => $this->t('Current revision'), 225 '#markup' => $this->t('Current revision'),
218 '#suffix' => '</em>', 226 '#suffix' => '</em>',