Update to drupal 8.0.0-rc1. For more information, see https://www.drupal.org/node/2582663
This commit is contained in:
parent
eb34d130a8
commit
f32e58e4b1
8476 changed files with 211648 additions and 170042 deletions
|
@ -2,3 +2,4 @@ access_log:
|
|||
enabled: false
|
||||
max_lifetime: 259200
|
||||
count_content_views: 0
|
||||
display_max_age: 3600
|
||||
|
|
|
@ -17,6 +17,9 @@ statistics.settings:
|
|||
count_content_views:
|
||||
type: integer
|
||||
label: 'Count content views'
|
||||
display_max_age:
|
||||
type: integer
|
||||
label: 'How long any statistics may be cached, i.e. the refresh interval'
|
||||
|
||||
block.settings.statistics_popular_block:
|
||||
type: block_settings
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
id: d6_statistics_settings
|
||||
label: Drupal 6 statistics configuration
|
||||
label: Statistics configuration
|
||||
migration_tags:
|
||||
- Drupal 6
|
||||
source:
|
||||
|
|
|
@ -20,9 +20,7 @@ class MigrateStatisticsConfigsTest extends MigrateDrupal6TestBase {
|
|||
use SchemaCheckTestTrait;
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
* @var array
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = array('statistics');
|
||||
|
||||
|
|
|
@ -47,6 +47,9 @@ class StatisticsAdminTest extends WebTestBase {
|
|||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
// Set the max age to 0 to simplify testing.
|
||||
$this->config('statistics.settings')->set('display_max_age', 0)->save();
|
||||
|
||||
// Create Basic page node type.
|
||||
if ($this->profile != 'standard') {
|
||||
$this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page'));
|
||||
|
@ -89,6 +92,16 @@ class StatisticsAdminTest extends WebTestBase {
|
|||
$this->drupalGet('node/' . $this->testNode->id());
|
||||
$this->client->post($stats_path, array('form_params' => $post));
|
||||
$this->assertText('2 views', 'Node is viewed 2 times.');
|
||||
|
||||
// Increase the max age to test that nodes are no longer immediately
|
||||
// updated, visit the node once more to populate the cache.
|
||||
$this->config('statistics.settings')->set('display_max_age', 3600)->save();
|
||||
$this->drupalGet('node/' . $this->testNode->id());
|
||||
$this->assertText('3 views', 'Node is viewed 3 times.');
|
||||
|
||||
$this->client->post($stats_path, array('form_params' => $post));
|
||||
$this->drupalGet('node/' . $this->testNode->id());
|
||||
$this->assertText('3 views', 'Views counter was not updated.');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
62
core/modules/statistics/src/Tests/StatisticsAttachedTest.php
Normal file
62
core/modules/statistics/src/Tests/StatisticsAttachedTest.php
Normal file
|
@ -0,0 +1,62 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\statistics\Tests\StatisticsAttachedTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\statistics\Tests;
|
||||
|
||||
use Drupal\simpletest\WebTestBase;
|
||||
use Drupal\node\Entity\Node;
|
||||
|
||||
/**
|
||||
* Tests if statistics.js is loaded when content is not printed.
|
||||
*
|
||||
* @group statistics
|
||||
*/
|
||||
class StatisticsAttachedTest extends WebTestBase {
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('node', 'statistics');
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$this->drupalCreateContentType(['type' => 'page']);
|
||||
|
||||
// Install "statistics_test_attached" and set it as the default theme.
|
||||
$theme = 'statistics_test_attached';
|
||||
\Drupal::service('theme_handler')->install(array($theme));
|
||||
$this->config('system.theme')
|
||||
->set('default', $theme)
|
||||
->save();
|
||||
// Installing a theme will cause the kernel terminate event to rebuild the
|
||||
// router. Simulate that here.
|
||||
\Drupal::service('router.builder')->rebuildIfNeeded();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if statistics.js is loaded when content is not printed.
|
||||
*/
|
||||
public function testAttached() {
|
||||
|
||||
$node = Node::create([
|
||||
'type' => 'page',
|
||||
'title' => 'Page node',
|
||||
'body' => 'body text'
|
||||
]);
|
||||
$node->save();
|
||||
$this->drupalGet('node/' . $node->id());
|
||||
|
||||
$this->assertRaw('core/modules/statistics/statistics.js', 'Statistics library is available');
|
||||
}
|
||||
|
||||
}
|
|
@ -71,3 +71,11 @@ function statistics_update_8001() {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable the Statistics module if the node module is not enabled.
|
||||
*/
|
||||
function statistics_update_8002() {
|
||||
// Set the new configuration setting for max age to the initial value.
|
||||
\Drupal::configFactory()->getEditable('statistics.settings')->set('display_max_age', 3600)->save();
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
statistics.settings:
|
||||
title: Statistics
|
||||
description: 'Control details about what and how your site logs content statistics.'
|
||||
description: 'Configure the logging of content statistics.'
|
||||
route_name: statistics.settings
|
||||
parent: system.admin_config_system
|
||||
weight: -15
|
||||
|
|
|
@ -19,13 +19,13 @@ function statistics_help($route_name, RouteMatchInterface $route_match) {
|
|||
case 'help.page.statistics':
|
||||
$output = '';
|
||||
$output .= '<h3>' . t('About') . '</h3>';
|
||||
$output .= '<p>' . t('The Statistics module shows you how often content is viewed. This is useful in determining which pages of your site are most popular. For more information, see <a href="!statistics_do">the online documentation for the Statistics module</a>.', array('!statistics_do' => 'https://www.drupal.org/documentation/modules/statistics/')) . '</p>';
|
||||
$output .= '<p>' . t('The Statistics module shows you how often content is viewed. This is useful in determining which pages of your site are most popular. For more information, see the <a href=":statistics_do">online documentation for the Statistics module</a>.', array(':statistics_do' => 'https://www.drupal.org/documentation/modules/statistics/')) . '</p>';
|
||||
$output .= '<h3>' . t('Uses') . '</h3>';
|
||||
$output .= '<dl>';
|
||||
$output .= '<dt>' . t('Displaying popular content') . '</dt>';
|
||||
$output .= '<dd>' . t('The module includes a <em>Popular content</em> block that displays the most viewed pages today and for all time, and the last content viewed. To use the block, enable <em>Count content views</em> on the <a href="!statistics-settings">Statistics page</a>, and then you can enable and configure the block on the <a href="!blocks">Block layout page</a>.', array('!statistics-settings' => \Drupal::url('statistics.settings'), '!blocks' => (\Drupal::moduleHandler()->moduleExists('block')) ? \Drupal::url('block.admin_display') : '#')) . '</dd>';
|
||||
$output .= '<dd>' . t('The module includes a <em>Popular content</em> block that displays the most viewed pages today and for all time, and the last content viewed. To use the block, enable <em>Count content views</em> on the <a href=":statistics-settings">Statistics page</a>, and then you can enable and configure the block on the <a href=":blocks">Block layout page</a>.', array(':statistics-settings' => \Drupal::url('statistics.settings'), ':blocks' => (\Drupal::moduleHandler()->moduleExists('block')) ? \Drupal::url('block.admin_display') : '#')) . '</dd>';
|
||||
$output .= '<dt>' . t('Page view counter') . '</dt>';
|
||||
$output .= '<dd>' . t('The Statistics module includes a counter for each page that increases whenever the page is viewed. To use the counter, enable <em>Count content views</em> on the <a href="!statistics-settings">Statistics page</a>, and set the necessary <a href="!permissions">permissions</a> (<em>View content hits</em>) so that the counter is visible to the users.', array('!statistics-settings' => \Drupal::url('statistics.settings'), '!permissions' => \Drupal::url('user.admin_permissions', array(), array('fragment' => 'module-statistics')))) . '</dd>';
|
||||
$output .= '<dd>' . t('The Statistics module includes a counter for each page that increases whenever the page is viewed. To use the counter, enable <em>Count content views</em> on the <a href=":statistics-settings">Statistics page</a>, and set the necessary <a href=":permissions">permissions</a> (<em>View content hits</em>) so that the counter is visible to the users.', array(':statistics-settings' => \Drupal::url('statistics.settings'), ':permissions' => \Drupal::url('user.admin_permissions', array(), array('fragment' => 'module-statistics')))) . '</dd>';
|
||||
$output .= '</dl>';
|
||||
return $output;
|
||||
|
||||
|
@ -39,9 +39,9 @@ function statistics_help($route_name, RouteMatchInterface $route_match) {
|
|||
*/
|
||||
function statistics_node_view(array &$build, EntityInterface $node, EntityViewDisplayInterface $display, $view_mode) {
|
||||
if (!$node->isNew() && $view_mode == 'full' && node_is_page($node) && empty($node->in_preview)) {
|
||||
$build['statistics_content_counter']['#attached']['library'][] = 'statistics/drupal.statistics';
|
||||
$build['#attached']['library'][] = 'statistics/drupal.statistics';
|
||||
$settings = array('data' => array('nid' => $node->id()), 'url' => Url::fromUri('base:' . drupal_get_path('module', 'statistics') . '/statistics.php')->toString());
|
||||
$build['statistics_content_counter']['#attached']['drupalSettings']['statistics'] = $settings;
|
||||
$build['#attached']['drupalSettings']['statistics'] = $settings;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -50,6 +50,7 @@ function statistics_node_view(array &$build, EntityInterface $node, EntityViewDi
|
|||
*/
|
||||
function statistics_node_links_alter(array &$node_links, NodeInterface $entity, array &$context) {
|
||||
if ($context['view_mode'] != 'rss') {
|
||||
$node_links['#cache']['contexts'][] = 'user.permissions';
|
||||
if (\Drupal::currentUser()->hasPermission('view post access counter')) {
|
||||
$statistics = statistics_get($entity->id());
|
||||
if ($statistics) {
|
||||
|
@ -60,6 +61,7 @@ function statistics_node_links_alter(array &$node_links, NodeInterface $entity,
|
|||
'#attributes' => array('class' => array('links', 'inline')),
|
||||
);
|
||||
}
|
||||
$node_links['#cache']['max-age'] = \Drupal::config('statistics.settings')->get('display_max_age');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
<article{{ attributes }}>
|
||||
|
||||
{{ title_prefix }}
|
||||
{% if not page %}
|
||||
<h2{{ title_attributes }}>
|
||||
<a href="{{ url }}" rel="bookmark">{{ label }}</a>
|
||||
</h2>
|
||||
{% endif %}
|
||||
{{ title_suffix }}
|
||||
|
||||
{% if display_submitted %}
|
||||
<footer>
|
||||
{{ author_picture }}
|
||||
<div{{ author_attributes }}>
|
||||
{% trans %}Submitted by {{ author_name }} on {{ date }}{% endtrans %}
|
||||
{{ metadata }}
|
||||
</div>
|
||||
</footer>
|
||||
{% endif %}
|
||||
|
||||
<div{{ content_attributes }}>
|
||||
{{ content.body }}
|
||||
</div>
|
||||
</article>
|
|
@ -0,0 +1,5 @@
|
|||
name: 'Statistics test attached theme'
|
||||
type: theme
|
||||
description: 'Theme for testing attached library'
|
||||
version: VERSION
|
||||
core: 8.x
|
Reference in a new issue