Merge branch '8.x' of git.drupal.org:project/drupal into 8.x

8.0.x
Dries 2013-02-18 17:00:21 -05:00
commit 395d3a6bf1
23 changed files with 79 additions and 359 deletions

View File

@ -6327,14 +6327,14 @@ function drupal_parse_info_format($data) {
*/
function watchdog_severity_levels() {
return array(
WATCHDOG_EMERGENCY => t('emergency'),
WATCHDOG_ALERT => t('alert'),
WATCHDOG_CRITICAL => t('critical'),
WATCHDOG_ERROR => t('error'),
WATCHDOG_WARNING => t('warning'),
WATCHDOG_NOTICE => t('notice'),
WATCHDOG_INFO => t('info'),
WATCHDOG_DEBUG => t('debug'),
WATCHDOG_EMERGENCY => t('Emergency'),
WATCHDOG_ALERT => t('Alert'),
WATCHDOG_CRITICAL => t('Critical'),
WATCHDOG_ERROR => t('Error'),
WATCHDOG_WARNING => t('Warning'),
WATCHDOG_NOTICE => t('Notice'),
WATCHDOG_INFO => t('Info'),
WATCHDOG_DEBUG => t('Debug'),
);
}

View File

@ -768,7 +768,7 @@ function drupal_retrieve_form($form_id, &$form_state) {
$callback = $form_state['build_info']['callback'];
}
elseif (!empty($form_state['build_info']['callback_object'])) {
$callback = array($form_state['build_info']['callback_object'], 'build');
$callback = array($form_state['build_info']['callback_object'], 'buildForm');
}
// We first check to see if there is a valid form builder callback defined.
@ -1078,7 +1078,7 @@ function drupal_prepare_form($form_id, &$form, &$form_state) {
// Ensure that modules can rely on #validate being set.
$form['#validate'] = array();
if (isset($form_state['build_info']['callback_object'])) {
$form['#validate'][] = array($form_state['build_info']['callback_object'], 'validate');
$form['#validate'][] = array($form_state['build_info']['callback_object'], 'validateForm');
}
// Check for a handler specific to $form_id.
elseif (function_exists($form_id . '_validate')) {
@ -1095,7 +1095,7 @@ function drupal_prepare_form($form_id, &$form, &$form_state) {
// Ensure that modules can rely on #submit being set.
$form['#submit'] = array();
if (isset($form_state['build_info']['callback_object'])) {
$form['#submit'][] = array($form_state['build_info']['callback_object'], 'submit');
$form['#submit'][] = array($form_state['build_info']['callback_object'], 'submitForm');
}
// Check for a handler specific to $form_id.
elseif (function_exists($form_id . '_submit')) {

View File

@ -31,7 +31,7 @@ interface FormInterface {
* @return array
* The form structure.
*/
public function build(array $form, array &$form_state);
public function buildForm(array $form, array &$form_state);
/**
* Form validation handler.
@ -41,7 +41,7 @@ interface FormInterface {
* @param array $form_state
* An associative array containing the current state of the form.
*/
public function validate(array &$form, array &$form_state);
public function validateForm(array &$form, array &$form_state);
/**
* Form submission handler.
@ -51,6 +51,6 @@ interface FormInterface {
* @param array $form_state
* An associative array containing the current state of the form.
*/
public function submit(array &$form, array &$form_state);
public function submitForm(array &$form, array &$form_state);
}

View File

@ -100,11 +100,11 @@ class BlockListController extends ConfigEntityListController implements FormInte
}
/**
* Implements \Drupal\Core\Form\FormInterface::build().
* Implements \Drupal\Core\Form\FormInterface::buildForm().
*
* Form constructor for the main block administration form.
*/
public function build(array $form, array &$form_state) {
public function buildForm(array $form, array &$form_state) {
$entities = $this->load();
$form['#attached']['css'][] = drupal_get_path('module', 'block') . '/block.admin.css';
$form['#attached']['library'][] = array('system', 'drupal.tableheader');
@ -190,18 +190,18 @@ class BlockListController extends ConfigEntityListController implements FormInte
}
/**
* Implements \Drupal\Core\Form\FormInterface::validate().
* Implements \Drupal\Core\Form\FormInterface::validateForm().
*/
public function validate(array &$form, array &$form_state) {
public function validateForm(array &$form, array &$form_state) {
// No validation.
}
/**
* Implements \Drupal\Core\Form\FormInterface::submit().
* Implements \Drupal\Core\Form\FormInterface::submitForm().
*
* Form submission handler for the main block administration form.
*/
public function submit(array &$form, array &$form_state) {
public function submitForm(array &$form, array &$form_state) {
$entities = entity_load_multiple('block', array_keys($form_state['values']['blocks']));
foreach ($entities as $entity_id => $entity) {
$entity->set('weight', $form_state['values']['blocks'][$entity_id]['weight']);

View File

@ -39,9 +39,9 @@ class DisplayOverview extends OverviewBase {
}
/**
* Implements \Drupal\Core\Form\FormInterface::build().
* Implements \Drupal\Core\Form\FormInterface::buildForm().
*/
public function build(array $form, array &$form_state) {
public function buildForm(array $form, array &$form_state) {
// Gather type information.
$instances = field_info_instances($this->entity_type, $this->bundle);
$field_types = field_info_field_types();
@ -407,9 +407,9 @@ class DisplayOverview extends OverviewBase {
}
/**
* Overrides \Drupal\field_ui\OverviewBase::submit().
* Overrides \Drupal\field_ui\OverviewBase::submitForm().
*/
public function submit(array &$form, array &$form_state) {
public function submitForm(array &$form, array &$form_state) {
$form_values = $form_state['values'];
$display = entity_get_display($this->entity_type, $this->bundle, $this->view_mode);

View File

@ -50,9 +50,9 @@ class FieldOverview extends OverviewBase {
}
/**
* Implements \Drupal\Core\Form\FormInterface::build().
* Implements \Drupal\Core\Form\FormInterface::buildForm().
*/
public function build(array $form, array &$form_state) {
public function buildForm(array $form, array &$form_state) {
// When displaying the form, make sure the list of fields is up-to-date.
if (empty($form_state['post'])) {
field_info_cache_clear();
@ -420,9 +420,9 @@ class FieldOverview extends OverviewBase {
}
/**
* Overrides \Drupal\field_ui\OverviewBase::validate().
* Implements \Drupal\Core\Form\FormInterface::validateForm().
*/
public function validate(array &$form, array &$form_state) {
public function validateForm(array &$form, array &$form_state) {
$this->validateAddNew($form, $form_state);
$this->validateAddExisting($form, $form_state);
}
@ -435,7 +435,7 @@ class FieldOverview extends OverviewBase {
* @param array $form_state
* A reference to a keyed array containing the current state of the form.
*
* @see Drupal\field_ui\FieldOverview::validate()
* @see Drupal\field_ui\FieldOverview::validateForm()
*/
protected function validateAddNew(array $form, array &$form_state) {
$field = $form_state['values']['fields']['_add_new_field'];
@ -524,9 +524,9 @@ class FieldOverview extends OverviewBase {
}
/**
* Overrides \Drupal\field_ui\OverviewBase::submit().
* Overrides \Drupal\field_ui\OverviewBase::submitForm().
*/
public function submit(array &$form, array &$form_state) {
public function submitForm(array &$form, array &$form_state) {
$form_values = $form_state['values']['fields'];
$bundle_settings = field_bundle_settings($this->entity_type, $this->bundle);

View File

@ -61,15 +61,15 @@ abstract class OverviewBase implements FormInterface {
}
/**
* Implements \Drupal\Core\Form\FormInterface::validate().
* Implements \Drupal\Core\Form\FormInterface::validateForm().
*/
public function validate(array &$form, array &$form_state) {
public function validateForm(array &$form, array &$form_state) {
}
/**
* Implements \Drupal\Core\Form\FormInterface::submit().
* Implements \Drupal\Core\Form\FormInterface::submitForm().
*/
public function submit(array &$form, array &$form_state) {
public function submitForm(array &$form, array &$form_state) {
}
/**

View File

@ -1,172 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\node\Tests\Views\RowPluginTest.
*/
namespace Drupal\node\Tests\Views;
/**
* Tests the node row plugin.
*
* @see \Drupal\node\Plugin\views\row\NodeRow
*/
class RowPluginTest extends NodeTestBase {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = array('node', 'comment');
/**
* Views used by this test.
*
* @var array
*/
public static $testViews = array('test_node_row_plugin');
/**
* Contains all comments keyed by node used by the test.
*
* @var array
*/
protected $comments;
/**
* Contains all nodes used by this test.
*
* @var array
*/
protected $nodes;
public static function getInfo() {
return array(
'name' => 'Node: Row plugin',
'description' => 'Tests the node row plugin.',
'group' => 'Views Modules',
);
}
protected function setUp() {
parent::setUp();
$this->drupalCreateContentType(array('type' => 'article'));
// Create two nodes, with 5 comments on all of them.
for ($i = 0; $i < 2; $i++) {
$this->nodes[] = $this->drupalCreateNode(
array(
'type' => 'article',
'body' => array(
LANGUAGE_NOT_SPECIFIED => array(
array(
'value' => $this->randomName(42),
'format' => filter_default_format(),
'summary' => $this->randomName(),
),
),
),
)
);
}
foreach ($this->nodes as $node) {
for ($i = 0; $i < 5; $i++) {
$this->comments[$node->id()][] = $this->drupalCreateComment(array('nid' => $node->id()));
}
}
}
/**
* Helper function to create a random comment.
*
* @param array $settings
* (optional) An associative array of settings for the comment, as used in
* entity_create().
*
* @return \Drupal\comment\Plugin\Core\Entity\Comment
* Returns the created and saved comment.
*/
public function drupalCreateComment(array $settings = array()) {
$node = node_load($settings['nid']);
$settings += array(
'subject' => $this->randomName(),
'node_type' => "comment_node_{$node->bundle()}",
'comment_body' => $this->randomName(40),
);
$comment = entity_create('comment', $settings);
$comment->save();
return $comment;
}
/**
* Tests the node row plugin.
*/
public function testRowPlugin() {
$view = views_get_view('test_node_row_plugin');
$view->initDisplay();
$view->setDisplay('page');
$view->initStyle();
$view->style_plugin->row_plugin->options['view_mode'] = 'full';
// Test with view_mode full.
$output = $view->preview();
foreach ($this->nodes as $node) {
$body = $node->body;
$teaser = $body[LANGUAGE_NOT_SPECIFIED][0]['summary'];
$full = $body[LANGUAGE_NOT_SPECIFIED][0]['value'];
$this->assertFalse(strpos($output, $teaser) !== FALSE, 'Make sure the teaser appears in the output of the view.');
$this->assertTrue(strpos($output, $full) !== FALSE, 'Make sure the full text appears in the output of the view.');
}
// Test with teasers.
$view->style_plugin->row_plugin->options['view_mode'] = 'teaser';
$output = $view->preview();
foreach ($this->nodes as $node) {
$body = $node->body;
$teaser = $body[LANGUAGE_NOT_SPECIFIED][0]['summary'];
$full = $body[LANGUAGE_NOT_SPECIFIED][0]['value'];
$this->assertTrue(strpos($output, $teaser) !== FALSE, 'Make sure the teaser appears in the output of the view.');
$this->assertFalse(strpos($output, $full) !== FALSE, 'Make sure the full text does not appears in the output of the view if teaser is set as viewmode.');
}
// Test with links disabled.
$view->style_plugin->row_plugin->options['links'] = FALSE;
$output = $view->preview();
$this->drupalSetContent($output);
foreach ($this->nodes as $node) {
$this->assertFalse($this->xpath('//li[contains(@class, :class)]/a[contains(@href, :href)]', array(':class' => 'node-readmore', ':href' => "node/{$node->id()}")), 'Make sure no readmore link appears.');
}
// Test with links enabled.
$view->style_plugin->row_plugin->options['links'] = TRUE;
$output = $view->preview();
$this->drupalSetContent($output);
foreach ($this->nodes as $node) {
$this->assertTrue($this->xpath('//li[contains(@class, :class)]/a[contains(@href, :href)]', array(':class' => 'node-readmore', ':href' => "node/{$node->id()}")), 'Make sure no readmore link appears.');
}
// Test with comments enabled.
$view->style_plugin->row_plugin->options['comments'] = TRUE;
$output = $view->preview();
foreach ($this->nodes as $node) {
foreach ($this->comments[$node->id()] as $comment) {
$this->assertTrue(strpos($output, $comment->comment_body->value) !== FALSE, 'Make sure the comment appears in the output.');
}
}
// Test with comments disabled.
$view->style_plugin->row_plugin->options['comments'] = FALSE;
$output = $view->preview();
foreach ($this->nodes as $node) {
foreach ($this->comments[$node->id()] as $comment) {
$this->assertFalse(strpos($output, $comment->comment_body->value) !== FALSE, 'Make sure the comment does not appears in the output when the comments option disabled.');
}
}
}
}

View File

@ -1,56 +0,0 @@
base_field: nid
base_table: node
core: 8
description: ''
status: '1'
display:
default:
display_options:
access:
type: perm
cache:
type: none
exposed_form:
type: basic
filters:
status:
expose:
operator: '0'
field: status
group: '1'
id: status
table: node
value: '1'
plugin_id: boolean
pager:
options:
items_per_page: '10'
type: full
query:
type: views_query
row:
options:
build_mode: teaser
comments: '0'
links: '1'
type: node
sorts: { }
style:
type: default
title: test_node_row_plugin
display_plugin: default
display_title: Master
id: default
position: { }
page:
display_options:
path: test-node-row-plugin
display_plugin: page
display_title: Page
id: page
position: { }
human_name: test_node_row_plugin
langcode: und
module: views
id: test_node_row_plugin
tag: default

View File

@ -34,12 +34,12 @@ class FormObjectTest extends WebTestBase {
*/
function testObjectFormCallback() {
$this->drupalGet('form-test/object-builder');
$this->assertText('The FormTestObject::build() method was used for this form.');
$this->assertText('The FormTestObject::buildForm() method was used for this form.');
$elements = $this->xpath('//form[@id="form-test-form-test-object"]');
$this->assertTrue(!empty($elements), 'The correct form ID was used.');
$this->drupalPost('form-test/object-builder', NULL, t('Save'));
$this->assertText('The FormTestObject::validate() method was used for this form.');
$this->assertText('The FormTestObject::submit() method was used for this form.');
$this->assertText('The FormTestObject::validateForm() method was used for this form.');
$this->assertText('The FormTestObject::submitForm() method was used for this form.');
}
}

View File

@ -3281,7 +3281,7 @@ function system_config_form($form, &$form_state) {
if (!isset($form['#submit'])) {
$form['#submit'] = array();
if (isset($form_state['build_info']['callback_object'])) {
$form['#submit'][] = array($form_state['build_info']['callback_object'], 'submit');
$form['#submit'][] = array($form_state['build_info']['callback_object'], 'submitForm');
}
elseif (function_exists($form_state['build_info']['form_id'] . '_submit')) {
$form['#submit'][] = $form_state['build_info']['form_id'] . '_submit';

View File

@ -22,10 +22,10 @@ class FormTestObject implements FormInterface {
}
/**
* Implements \Drupal\Core\Form\FormInterface::build().
* Implements \Drupal\Core\Form\FormInterface::buildForm().
*/
public function build(array $form, array &$form_state) {
$form['element'] = array('#markup' => 'The FormTestObject::build() method was used for this form.');
public function buildForm(array $form, array &$form_state) {
$form['element'] = array('#markup' => 'The FormTestObject::buildForm() method was used for this form.');
$form['actions']['#type'] = 'actions';
$form['actions']['submit'] = array(
@ -36,17 +36,17 @@ class FormTestObject implements FormInterface {
}
/**
* Implements \Drupal\Core\Form\FormInterface::validate().
* Implements \Drupal\Core\Form\FormInterface::validateForm().
*/
public function validate(array &$form, array &$form_state) {
drupal_set_message(t('The FormTestObject::validate() method was used for this form.'));
public function validateForm(array &$form, array &$form_state) {
drupal_set_message(t('The FormTestObject::validateForm() method was used for this form.'));
}
/**
* Implements \Drupal\Core\Form\FormInterface::submit().
* Implements \Drupal\Core\Form\FormInterface::submitForm().
*/
public function submit(array &$form, array &$form_state) {
drupal_set_message(t('The FormTestObject::submit() method was used for this form.'));
public function submitForm(array &$form, array &$form_state) {
drupal_set_message(t('The FormTestObject::submitForm() method was used for this form.'));
}
}

View File

@ -77,7 +77,7 @@ class Link extends FieldPluginBase {
* The acutal rendered text (without the link) of this field.
*/
public function render_link(EntityInterface $entity, \stdClass $values) {
$text = !empty($this->options['text']) ? $this->options['text'] : t('view');
$text = !empty($this->options['text']) ? $this->options['text'] : t('View');
$this->options['alter']['make_link'] = TRUE;
$uri = $entity->uri();

View File

@ -29,7 +29,7 @@ class LinkCancel extends Link {
if ($entity && $entity->access('delete')) {
$this->options['alter']['make_link'] = TRUE;
$text = !empty($this->options['text']) ? $this->options['text'] : t('cancel');
$text = !empty($this->options['text']) ? $this->options['text'] : t('Cancel');
$uri = $entity->uri();
$this->options['alter']['path'] = $uri['path'] . '/cancel';

View File

@ -29,7 +29,7 @@ class LinkEdit extends Link {
if ($entity && $entity->access('edit')) {
$this->options['alter']['make_link'] = TRUE;
$text = !empty($this->options['text']) ? $this->options['text'] : t('edit');
$text = !empty($this->options['text']) ? $this->options['text'] : t('Edit');
$uri = $entity->uri();
$this->options['alter']['path'] = $uri['path'] . '/edit';

View File

@ -45,7 +45,7 @@ class UserAdminTest extends WebTestBase {
$this->assertText($admin_user->name, 'Found Admin user on admin users page');
// Test for existence of edit link in table.
$link = l(t('edit'), "user/$user_a->uid/edit", array('query' => array('destination' => 'admin/people')));
$link = l(t('Edit'), "user/$user_a->uid/edit", array('query' => array('destination' => 'admin/people')));
$this->assertRaw($link, 'Found user A edit link on admin users page');
// Filter the users by permission 'administer taxonomy'.

View File

@ -228,13 +228,13 @@ function user_admin_account() {
);
$links = array();
$links['edit'] = array(
'title' => t('edit'),
'title' => t('Edit'),
'href' => 'user/' . $account->uid . '/edit',
'query' => $destination,
);
if (module_invoke('translation_entity', 'translate_access', $account)) {
$links['translate'] = array(
'title' => t('translate'),
'title' => t('Translate'),
'href' => 'user/' . $account->uid . '/translations',
'query' => $destination,
);
@ -865,12 +865,12 @@ function user_admin_roles($form, $form_state) {
'#attributes' => array('class' => array('role-weight')),
);
$links['edit'] = array(
'title' => t('edit role'),
'title' => t('Edit role'),
'href' => 'admin/people/roles/edit/' . $rid,
'weight' => 0,
);
$links['permissions'] = array(
'title' => t('edit permissions'),
'title' => t('Edit permissions'),
'href' => 'admin/people/permissions/' . $rid,
'weight' => 5,
);

View File

@ -2,11 +2,12 @@
/**
* @file
* Definition of Drupal\views\Analyzer.
* Contains \Drupal\views\Analyzer.
*/
namespace Drupal\views;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\views\ViewExecutable;
/**
@ -20,44 +21,36 @@ use Drupal\views\ViewExecutable;
class Analyzer {
/**
* The view to analyze.
* A module handler that invokes the 'views_analyze' hook.
*
* @var Drupal\views\ViewExecutable.
* @var \Drupal\Core\Extension\ModuleHandlerInterface
*/
protected $view;
protected $moduleHandler;
/**
* Constructs the analyzer object.
* Constructs an Analyzer object.
*
* @param Drupal\views\ViewExecutable $view
* (optional) The view to analyze.
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
* The module handler that invokes the 'views_analyze' hook.
*/
function __construct(ViewExecutable $view = NULL) {
if (isset($view)) {
$this->view = $view;
}
public function __construct(ModuleHandlerInterface $module_handler) {
$this->moduleHandler = $module_handler;
}
/**
* Sets the view which is analyzed by this analyzer.
*
* @param Drupal\views\ViewExecutable
* The view to analyze.
*/
public function setView(ViewExecutable $view = NULL) {
$this->view = $view;
}
/**
* Analyzes a review and return the results.
*
* @param \Drupal\views\ViewExecutable $view
* The view to analyze.
*
* @return array
* An array of analyze results organized into arrays keyed by 'ok',
* 'warning' and 'error'.
*/
public function getMessages() {
$this->view->initDisplay();
$messages = module_invoke_all('views_analyze', $this->view);
public function getMessages(ViewExecutable $view) {
$view->initDisplay();
$messages = $this->moduleHandler->invokeAll('views_analyze', array($view));
return $messages;
}
@ -70,7 +63,7 @@ class Analyzer {
*/
public function formatMessages(array $messages) {
if (empty($messages)) {
$messages = array($this->formatMessage(t('View analysis can find nothing to report.'), 'ok'));
$messages = array(static::formatMessage(t('View analysis can find nothing to report.'), 'ok'));
}
$types = array('ok' => array(), 'warning' => array(), 'error' => array());

View File

@ -7,7 +7,6 @@
namespace Drupal\views\Tests;
use DOMDocument;
use Drupal\simpletest\WebTestBase;
/**

View File

@ -37,6 +37,9 @@ class ViewsBundle extends Bundle {
->addArgument(new Reference('config.factory'));
$container->register('views.executable', 'Drupal\views\ViewExecutableFactory');
$container->register('views.analyzer', 'Drupal\views\Analyzer')
->addArgument(new Reference('module_handler'));
}
}

View File

@ -234,7 +234,6 @@ function views_plugin_list() {
* node portion of the theme registry.
*/
function views_preprocess_node(&$vars) {
module_load_include('inc', 'node', 'node.views');
// The 'view' attribute of the node is added in views_preprocess_node()
if (!empty($vars['node']->view) && $vars['node']->view->storage->id()) {
$vars['view'] = $vars['node']->view;
@ -251,7 +250,7 @@ function views_preprocess_node(&$vars) {
}
// Allow to alter comments and links based on the settings in the row plugin.
if (!empty($vars['view']->style_plugin->row_plugin) && $vars['view']->style_plugin->row_plugin->getPluginId() == 'node') {
if (!empty($vars['view']->style_plugin->row_plugin) && get_class($vars['view']->style_plugin->row_plugin) == 'views_plugin_row_node_view') {
node_row_node_view_preprocess_node($vars);
}
}

View File

@ -615,8 +615,8 @@ function views_ui_analyze_view_form($form, &$form_state) {
$form['#title'] = t('View analysis');
$form['#section'] = 'analyze';
$analyzer = new Analyzer($view->get('executable'));
$messages = $analyzer->getMessages();
$analyzer = drupal_container()->get('views.analyzer');
$messages = $analyzer->getMessages($view->get('executable'));
$form['analysis'] = array(
'#prefix' => '<div class="form-item">',

View File

@ -1,46 +0,0 @@
<?php
/**
* @file
* Template for the primary view editing window.
*/
?>
<div class="views-edit-view">
<?php if ($locked): ?>
<div class="view-locked">
<?php print t('This view is being edited by user !user, and is therefore locked from editing by others. This lock is !age old. Click here to <a href="!break">break this lock</a>.', array('!user' => $locked, '!age' => $lock_age, '!break' => $break)); ?>
</div>
<?php endif; ?>
<div class="views-basic-info clearfix<?php if (!empty($view->changed)) { print " changed"; }?>">
<?php if (!is_numeric($view->vid)): ?>
<div class="view-changed view-new"><?php print t('New view'); ?></div>
<?php else: ?>
<div class="view-changed"><?php print t('Changed view'); ?></div>
<?php endif; ?>
<div class="views-quick-links">
<?php print $quick_links ?>
</div>
<?php print t('View %name, displaying items of type <strong>@base</strong>.',
array('%name' => $view->id(), '@base' => $base_table)); ?>
</div>
<?php print $tabs; ?>
<div id="views-ajax-form">
<div id="views-ajax-title">
<?php // This is initially empty ?>
</div>
<div id="views-ajax-pad">
<?php /* This is sent in because it is also sent out through settings and
needs to be consistent. */ ?>
<?php print $message; ?>
</div>
</div>
<?php print $save_button ?>
<h2><?php print t('Live preview'); ?></h2>
<div id='views-live-preview'>
<?php print $preview ?>
</div>
</div>