diff --git a/core/modules/node/lib/Drupal/node/NodeListController.php b/core/modules/node/lib/Drupal/node/NodeListController.php new file mode 100644 index 0000000..b4ae3a0 --- /dev/null +++ b/core/modules/node/lib/Drupal/node/NodeListController.php @@ -0,0 +1,96 @@ + t('Title'), + 'type' => array( + 'data' => t('Content type'), + 'class' => array(RESPONSIVE_PRIORITY_MEDIUM), + ), + 'author' => array( + 'data' => t('Author'), + 'class' => array(RESPONSIVE_PRIORITY_LOW), + ), + 'status' => t('Status'), + 'changed' => array( + 'data' => t('Updated'), + 'class' => array(RESPONSIVE_PRIORITY_LOW) + ), + ); + if (language_multilingual()) { + $header['language_name'] = array('data' => t('Language'), 'class' => array(RESPONSIVE_PRIORITY_LOW)); + } + $header['operations'] = t('Operations'); + return $header; + } + + /** + * {@inheritdoc} + */ + public function buildRow(EntityInterface $entity) { + $mark = array( + '#theme' => 'mark', + '#mark_type' => node_mark($entity->id(), $entity->changed), + ); + $row['title']['data'] = array( + '#type' => 'link', + '#title' => $entity->label(), + '#href' => 'node/' . $entity->id(), + '#options' => $entity->langcode != Language::LANGCODE_NOT_SPECIFIED && isset($languages[$entity->langcode]) ? array('language' => $languages[$entity->langcode]) : array(), + '#suffix' => ' ' . drupal_render($mark), + ); + $row['type'] = check_plain(node_get_type_label($entity)); + $row['author']['data'] = array( + '#theme' => 'username', + '#account' => $entity, + ); + $row['status'] = $entity->status ? t('published') : t('not published'); + $row['changed'] = format_date($entity->changed, 'short'); + if (language_multilingual()) { + $row['language_name'] = language_name($entity->langcode); + } + $row['operations']['data'] = $this->buildOperations($entity); + return $row; + } + + /** + * {@inheritdoc} + */ + public function getOperations(EntityInterface $entity) { + $operations = parent::getOperations($entity); + if ($entity->isTranslatable()) { + $operations['translate'] = array( + 'title' => t('Translate'), + 'href' => 'node/' . $entity->id() . '/translations', + ); + } + + $destination = drupal_get_destination(); + foreach ($operations as $key => $operation) { + $operations[$key]['query'] = $destination; + + } + return $operations; + } + +} diff --git a/core/modules/node/lib/Drupal/node/Plugin/Core/Entity/Node.php b/core/modules/node/lib/Drupal/node/Plugin/Core/Entity/Node.php index 0791287..de101fd 100644 --- a/core/modules/node/lib/Drupal/node/Plugin/Core/Entity/Node.php +++ b/core/modules/node/lib/Drupal/node/Plugin/Core/Entity/Node.php @@ -26,6 +26,7 @@ * "storage" = "Drupal\node\NodeStorageController", * "render" = "Drupal\node\NodeRenderController", * "access" = "Drupal\node\NodeAccessController", + * "list" = "Drupal\node\NodeListController", * "form" = { * "default" = "Drupal\node\NodeFormController", * "edit" = "Drupal\node\NodeFormController" diff --git a/core/modules/node/node.admin.inc b/core/modules/node/node.admin.inc index 821f41a..dae2cd9 100644 --- a/core/modules/node/node.admin.inc +++ b/core/modules/node/node.admin.inc @@ -180,160 +180,3 @@ function _node_mass_update_batch_finished($success, $results, $operations) { drupal_set_message($message); } } - -/** - * Returns the admin form object to node_admin_content(). - * - * @ingroup forms - */ -function node_admin_nodes() { - // Enable language column and filter if multiple languages are enabled. - $multilingual = language_multilingual(); - - // Build the sortable table header. - $header = array( - 'title' => array( - 'data' => t('Title'), - 'field' => 'n.title', - ), - 'type' => array( - 'data' => t('Content type'), - 'field' => 'n.type', - 'class' => array(RESPONSIVE_PRIORITY_MEDIUM), - ), - 'author' => array( - 'data' => t('Author'), - 'class' => array(RESPONSIVE_PRIORITY_LOW), - ), - 'status' => array( - 'data' => t('Status'), - 'field' => 'n.status', - ), - 'changed' => array( - 'data' => t('Updated'), - 'field' => 'n.changed', - 'sort' => 'desc', - 'class' => array(RESPONSIVE_PRIORITY_LOW) - ,) - ); - if ($multilingual) { - $header['language_name'] = array('data' => t('Language'), 'field' => 'n.langcode', 'class' => array(RESPONSIVE_PRIORITY_LOW)); - } - $header['operations'] = array('data' => t('Operations')); - - $query = db_select('node_field_data', 'n') - ->extend('Drupal\Core\Database\Query\PagerSelectExtender') - ->extend('Drupal\Core\Database\Query\TableSortExtender'); - - if (!user_access('bypass node access')) { - // If the user is able to view their own unpublished nodes, allow them - // to see these in addition to published nodes. Check that they actually - // have some unpublished nodes to view before adding the condition. - if (user_access('view own unpublished content') && $own_unpublished = db_query('SELECT DISTINCT nid FROM {node_field_data} WHERE uid = :uid AND status = :status', array(':uid' => $GLOBALS['user']->uid, ':status' => 0))->fetchCol()) { - $query->condition(db_or() - ->condition('n.status', 1) - ->condition('n.nid', $own_unpublished, 'IN') - ); - } - else { - // If not, restrict the query to published nodes. - $query->condition('n.status', 1); - } - } - $nids = $query - ->distinct() - ->fields('n', array('nid')) - ->limit(50) - ->orderByHeader($header) - ->addTag('node_access') - ->execute() - ->fetchCol(); - $nodes = node_load_multiple($nids); - - // Prepare the list of nodes. - $languages = language_list(Language::STATE_ALL); - $destination = drupal_get_destination(); - $form['nodes'] = array( - '#type' => 'table', - '#header' => $header, - '#empty' => t('No content available.'), - ); - foreach ($nodes as $node) { - $l_options = $node->langcode != Language::LANGCODE_NOT_SPECIFIED && isset($languages[$node->langcode]) ? array('language' => $languages[$node->langcode]) : array(); - $mark = array( - '#theme' => 'mark', - '#mark_type' => node_mark($node->nid, $node->changed), - ); - $form['nodes'][$node->nid]['title'] = array( - '#type' => 'link', - '#title' => $node->label(), - '#href' => 'node/' . $node->nid, - '#options' => $l_options, - '#suffix' => ' ' . drupal_render($mark), - ); - $form['nodes'][$node->nid]['type'] = array( - '#markup' => check_plain(node_get_type_label($node)), - ); - $form['nodes'][$node->nid]['author'] = array( - '#theme' => 'username', - '#account' => $node, - ); - $form['nodes'][$node->nid]['status'] = array( - '#markup' => $node->status ? t('published') : t('not published'), - ); - $form['nodes'][$node->nid]['changed'] = array( - '#markup' => format_date($node->changed, 'short'), - ); - if ($multilingual) { - $form['nodes'][$node->nid]['language_name'] = array( - '#markup' => language_name($node->langcode), - ); - } - - // Build a list of all the accessible operations for the current node. - $operations = array(); - if (node_access('update', $node)) { - $operations['edit'] = array( - 'title' => t('Edit'), - 'href' => 'node/' . $node->nid . '/edit', - 'query' => $destination, - ); - } - if (node_access('delete', $node)) { - $operations['delete'] = array( - 'title' => t('Delete'), - 'href' => 'node/' . $node->nid . '/delete', - 'query' => $destination, - ); - } - if ($node->isTranslatable()) { - $operations['translate'] = array( - 'title' => t('Translate'), - 'href' => 'node/' . $node->nid . '/translations', - 'query' => $destination, - ); - } - $form['nodes'][$node->nid]['operations'] = array(); - if (count($operations) > 1) { - // Render an unordered list of operations links. - $form['nodes'][$node->nid]['operations'] = array( - '#type' => 'operations', - '#subtype' => 'node', - '#links' => $operations, - ); - } - elseif (!empty($operations)) { - // Render the first and only operation as a link. - $link = reset($operations); - $form['nodes'][$node->nid]['operations'] = array( - '#type' => 'link', - '#title' => $link['title'], - '#href' => $link['href'], - '#options' => array('query' => $link['query']), - ); - } - } - - $form['pager'] = array('#theme' => 'pager'); - return $form; -} diff --git a/core/modules/node/node.module b/core/modules/node/node.module index 3245f24..af79ae7 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -1595,10 +1595,8 @@ function node_menu() { $items['admin/content'] = array( 'title' => 'Content', 'description' => 'Find and manage content.', - 'page callback' => 'node_admin_nodes', - 'access arguments' => array('access content overview'), + 'route_name' => 'node_list', 'weight' => -10, - 'file' => 'node.admin.inc', ); $items['admin/content/node'] = array( 'title' => 'Content', diff --git a/core/modules/node/node.routing.yml b/core/modules/node/node.routing.yml index ce897f5..26e7330 100644 --- a/core/modules/node/node.routing.yml +++ b/core/modules/node/node.routing.yml @@ -4,9 +4,17 @@ node_multiple_delete_confirm: _form: '\Drupal\node\Form\DeleteMultiple' requirements: _permission: 'administer nodes' + node_page_edit: pattern: '/node/{node}/edit' defaults: _entity_form: 'node.edit' requirements: _entity_access: 'node.update' + +node_list: + pattern: '/admin/content' + defaults: + _entity_list: 'node' + requirements: + _permission: 'access content overview'