diff --git a/src/Controller/RevisionsController.php b/src/Controller/RevisionsController.php
index 5ad154b..4fd8995 100644
--- a/src/Controller/RevisionsController.php
+++ b/src/Controller/RevisionsController.php
@@ -23,8 +23,7 @@ use Drupal\Core\Language\LanguageManagerInterface;
* Returns responses for Node routes.
*/
class RevisionsController extends ControllerBase implements ContainerInjectionInterface {
-
- /**
+ /**
* The date formatter service.
*
* @var \Drupal\Core\Datetime\DateFormatterInterface
@@ -71,194 +70,190 @@ class RevisionsController extends ControllerBase implements ContainerInjectionIn
* @return array
* An array as expected by drupal_render().
*/
- public function revisionOverview($content_type = null,$uid = null) {
- $param = \Drupal::request()->query->all();
-
- $content_type = $param['content_type'];
- $uid = $param['uid'];
-
- $nodes = \Drupal\node\Entity\Node::loadMultiple();
-
- if(isset($content_type) && $content_type!='none' && isset($uid) && $uid!='none' && is_numeric($uid))
- {
- $nids = \Drupal::entityQuery('node')
- ->condition('type', $content_type)
- ->condition('uid',$uid)
- ->execute();
-
- $nodes = \Drupal::entityTypeManager()
- ->getStorage('node')
- ->loadMultiple($nids);
-
- }else if(isset($content_type) && $content_type!='none') {
- $nids = \Drupal::entityQuery('node')
- ->condition('type', $content_type)
- ->execute();
-
- $nodes = \Drupal::entityTypeManager()
- ->getStorage('node')
- ->loadMultiple($nids);
- }else if(isset($uid) && $uid!='none' && is_numeric($uid)) {
-
- $nids = \Drupal::entityQuery('node')
- ->condition('uid',$uid)
- ->execute();
-
- $nodes = \Drupal::entityTypeManager()
- ->getStorage('node')
- ->loadMultiple($nids);
-
- }
-
- // loads all nodes from db
-
- $row_count = 0;
- $rows = [];
-
-
- //$form = \Drupal::formBuilder()->getForm('Drupal\revisions\Form\RevisionForm');
-
- $form = \Drupal::formBuilder()->getForm('Drupal\revisions\Form\RevisionForm');
- $build['filter'] = $form;
-
- $build['#title'] = $this->t('Revisions List for All Nodes');
- foreach ($nodes as $node) {
- $account = $this->currentUser();
- $langcode = $node->language()->getId();
- $langname = $node->language()->getName();
- $languages = $node->getTranslationLanguages();
- $has_translations = (count($languages) > 1);
- $node_storage = $this->entityManager()->getStorage('node');
- $type = $node->getType();
-
- $header = [$this->t('Time'),$this->t('Created By'), $this->t('Difference Message'),$this->t('NodeType'),$this->t('NodeId'),$this->t('Operations')];
-
- $revert_permission = (($account->hasPermission("revert $type revisions") || $account->hasPermission('revert all revisions') || $account->hasPermission('administer nodes')) && $node->access('update'));
- $delete_permission = (($account->hasPermission("delete $type revisions") || $account->hasPermission('delete all revisions') || $account->hasPermission('administer nodes')) && $node->access('delete'));
-
-
- $default_revision = $node->getRevisionId();
-
- foreach ($this->getRevisionIds($node, $node_storage) as $vid) {
-
- /** @var \Drupal\node\NodeInterface $revision */
- $revision = $node_storage->loadRevision($vid);
- // Only show revisions that are affected by the language that is being
- // displayed.
-
- if ($revision->hasTranslation($langcode) && $revision->getTranslation($langcode)->isRevisionTranslationAffected()) {
- $username = [
- '#theme' => 'username',
- '#account' => $revision->getRevisionUser(),
- ];
-
- // Use revision link to link to revisions that are not active.
- $date = $this->dateFormatter->format($revision->revision_timestamp->value, 'short');
-
- if ($vid != $node->getRevisionId()) {
- $link = $this->l($date, new Url('entity.node.revision', ['node' => $node->id(), 'node_revision' => $vid]));
- }
- else {
- $link = $node->link($date);
- }
-
- $row = [];
-
- $name = $this->renderer->renderPlain($username);
- $row[] = [
- 'data' => [
- '#prefix' => '',
- '#markup' => $link ,
- '#suffix' => '',
- ],
- ];
- $row[] = [
- 'data' => [
- '#prefix' => '',
- '#markup' => $name,
- '#suffix' => '',
- ],
- ];
- $row[] = [
- 'data' => [
- '#prefix' => '',
- '#markup' => $revision->revision_log->value,
- '#suffix' => '',
- ],
- ];
- $row[] = [
- 'data' => [
- '#prefix' => '',
- '#markup' => $type,
- '#suffix' => '',
- ],
- ];
- $row[] = [
- 'data' => [
- '#prefix' => '',
- '#markup' => $node->id(),
- '#suffix' => '',
- ],
- ];
-
-
- if ($vid == $default_revision) {
- $row[] = [
- 'data' => [
- '#prefix' => '',
- '#markup' => $this->t('Current revision'),
- '#suffix' => '',
- ],
- ];
-
- $rows[$row_count++] = [
- 'data' => $row,
- 'class' => ['revision-current'],
- ];
- }
- else {
- $links = [];
- if ($revert_permission) {
- $links['revert'] = [
- 'title' => $vid < $node->getRevisionId() ? $this->t('Revert') : $this->t('Set as current revision'),
- 'url' => $has_translations ?
- Url::fromRoute('node.revision_revert_translation_confirm', ['node' => $node->id(), 'node_revision' => $vid, 'langcode' => $langcode]) :
- Url::fromRoute('node.revision_revert_confirm', ['node' => $node->id(), 'node_revision' => $vid]),
- ];
- }
-
- if ($delete_permission) {
- $links['delete'] = [
- 'title' => $this->t('Delete'),
- 'url' => Url::fromRoute('node.revision_delete_confirm', ['node' => $node->id(), 'node_revision' => $vid]),
- ];
- }
-
- $row[] = [
- 'data' => [
- '#type' => 'operations',
- '#links' => $links,
- ],
- ];
-
- $rows[$row_count++] = $row;
- }
- }
- }
- }
-
- $build['node_revisions_table'] = [
- '#theme' => 'table',
- '#rows' => $rows,
- '#header' => $header,
- '#attributes' => ['class' => 'node-revision-table'],
- ];
-
- $build['pager'] = ['#type' => 'pager'];
-
- return $build;
-
- }
+ public function revisionOverview($content_type = null,$uid = null) {
+ $param = \Drupal::request()->query->all();
+
+ $content_type = $param['content_type'];
+ $uid = $param['uid'];
+
+ $nodes = \Drupal\node\Entity\Node::loadMultiple();
+
+ if(isset($content_type) && $content_type!='none' && isset($uid) && $uid!='none' && is_numeric($uid)){
+ $nids = \Drupal::entityQuery('node')
+ ->condition('type', $content_type)
+ ->condition('uid',$uid)
+ ->execute();
+
+ $nodes = \Drupal::entityTypeManager()
+ ->getStorage('node')
+ ->loadMultiple($nids);
+ }
+ else if(isset($content_type) && $content_type!='none') {
+ $nids = \Drupal::entityQuery('node')
+ ->condition('type', $content_type)
+ ->execute();
+
+ $nodes = \Drupal::entityTypeManager()
+ ->getStorage('node')
+ ->loadMultiple($nids);
+ }
+ else if(isset($uid) && $uid!='none' && is_numeric($uid)) {
+
+ $nids = \Drupal::entityQuery('node')
+ ->condition('uid',$uid)
+ ->execute();
+
+ $nodes = \Drupal::entityTypeManager()
+ ->getStorage('node')
+ ->loadMultiple($nids);
+ }
+
+ // loads all nodes from db
+
+ $row_count = 0;
+ $rows = [];
+
+
+ //$form = \Drupal::formBuilder()->getForm('Drupal\revisions\Form\RevisionForm');
+
+ $form = \Drupal::formBuilder()->getForm('Drupal\revisions\Form\RevisionForm');
+ $build['filter'] = $form;
+
+ $build['#title'] = $this->t('Revisions List for All Nodes');
+ foreach ($nodes as $node) {
+ $account = $this->currentUser();
+ $langcode = $node->language()->getId();
+ $langname = $node->language()->getName();
+ $languages = $node->getTranslationLanguages();
+ $has_translations = (count($languages) > 1);
+ $node_storage = $this->entityManager()->getStorage('node');
+ $type = $node->getType();
+
+ $header = [$this->t('Time'),$this->t('Created By'), $this->t('Difference Message'),$this->t('NodeType'),$this->t('NodeId'),$this->t('Operations')];
+
+ $revert_permission = (($account->hasPermission("revert $type revisions") || $account->hasPermission('revert all revisions') || $account->hasPermission('administer nodes')) && $node->access('update'));
+ $delete_permission = (($account->hasPermission("delete $type revisions") || $account->hasPermission('delete all revisions') || $account->hasPermission('administer nodes')) && $node->access('delete'));
+
+ $default_revision = $node->getRevisionId();
+
+ foreach ($this->getRevisionIds($node, $node_storage) as $vid) {
+
+ /** @var \Drupal\node\NodeInterface $revision */
+ $revision = $node_storage->loadRevision($vid);
+ // Only show revisions that are affected by the language that is being
+ // displayed.
+
+ if ($revision->hasTranslation($langcode) && $revision->getTranslation($langcode)->isRevisionTranslationAffected()) {
+ $username = [
+ '#theme' => 'username',
+ '#account' => $revision->getRevisionUser(),
+ ];
+
+ // Use revision link to link to revisions that are not active.
+ $date = $this->dateFormatter->format($revision->revision_timestamp->value, 'short');
+
+ if ($vid != $node->getRevisionId()) {
+ $link = $this->l($date, new Url('entity.node.revision', ['node' => $node->id(), 'node_revision' => $vid]));
+ }
+ else {
+ $link = $node->link($date);
+ }
+
+ $row = [];
+
+ $name = $this->renderer->renderPlain($username);
+ $row[] = [
+ 'data' => [
+ '#prefix' => '',
+ '#markup' => $link ,
+ '#suffix' => '',
+ ],
+ ];
+ $row[] = [
+ 'data' => [
+ '#prefix' => '',
+ '#markup' => $name,
+ '#suffix' => '',
+ ],
+ ];
+ $row[] = [
+ 'data' => [
+ '#prefix' => '',
+ '#markup' => $revision->revision_log->value,
+ '#suffix' => '',
+ ],
+ ];
+ $row[] = [
+ 'data' => [
+ '#prefix' => '',
+ '#markup' => $type,
+ '#suffix' => '',
+ ],
+ ];
+ $row[] = [
+ 'data' => [
+ '#prefix' => '',
+ '#markup' => $node->id(),
+ '#suffix' => '',
+ ],
+ ];
+
+ if ($vid == $default_revision) {
+ $row[] = [
+ 'data' => [
+ '#prefix' => '',
+ '#markup' => $this->t('Current revision'),
+ '#suffix' => '',
+ ],
+ ];
+
+ $rows[$row_count++] = [
+ 'data' => $row,
+ 'class' => ['revision-current'],
+ ];
+ }
+ else {
+ $links = [];
+ if ($revert_permission) {
+ $links['revert'] = [
+ 'title' => $vid < $node->getRevisionId() ? $this->t('Revert') : $this->t('Set as current revision'),
+ 'url' => $has_translations ?
+ Url::fromRoute('node.revision_revert_translation_confirm', ['node' => $node->id(), 'node_revision' => $vid, 'langcode' => $langcode]) :
+ Url::fromRoute('node.revision_revert_confirm', ['node' => $node->id(), 'node_revision' => $vid]),
+ ];
+ }
+
+ if ($delete_permission) {
+ $links['delete'] = [
+ 'title' => $this->t('Delete'),
+ 'url' => Url::fromRoute('node.revision_delete_confirm', ['node' => $node->id(), 'node_revision' => $vid]),
+ ];
+ }
+
+ $row[] = [
+ 'data' => [
+ '#type' => 'operations',
+ '#links' => $links,
+ ],
+ ];
+
+ $rows[$row_count++] = $row;
+ }
+ }
+ }
+ }
+
+ $build['node_revisions_table'] = [
+ '#theme' => 'table',
+ '#rows' => $rows,
+ '#header' => $header,
+ '#attributes' => ['class' => 'node-revision-table'],
+ ];
+
+ $build['pager'] = ['#type' => 'pager'];
+
+ return $build;
+ }
/**
* Gets a list of node revision IDs for a specific node.
*
@@ -272,12 +267,11 @@ class RevisionsController extends ControllerBase implements ContainerInjectionIn
*/
protected function getRevisionIds(NodeInterface $node, NodeStorageInterface $node_storage) {
$result = $node_storage->getQuery()
- ->allRevisions()
- ->condition($node->getEntityType()->getKey('id'), $node->id())
- ->sort($node->getEntityType()->getKey('revision'), 'DESC')
- ->pager(50)
- ->execute();
+ ->allRevisions()
+ ->condition($node->getEntityType()->getKey('id'), $node->id())
+ ->sort($node->getEntityType()->getKey('revision'), 'DESC')
+ ->pager(50)
+ ->execute();
return array_keys($result);
}
-
}