diff --git a/core/modules/node/config/views.view.frontpage.yml b/core/modules/node/config/views.view.frontpage.yml index a6a8be2059a..7d0e218ca3a 100644 --- a/core/modules/node/config/views.view.frontpage.yml +++ b/core/modules/node/config/views.view.frontpage.yml @@ -1,8 +1,9 @@ +langcode: en +status: '1' base_field: nid base_table: node core: 8.x description: 'A list of nodes marked for display on the front page.' -status: '1' display: default: display_options: diff --git a/core/modules/views/config/views.view.archive.yml b/core/modules/views/config/views.view.archive.yml index c30016dba18..660e4d1bf82 100644 --- a/core/modules/views/config/views.view.archive.yml +++ b/core/modules/views/config/views.view.archive.yml @@ -1,3 +1,4 @@ +langcode: en status: '0' module: node id: archive diff --git a/core/modules/views/config/views.view.backlinks.yml b/core/modules/views/config/views.view.backlinks.yml index a2372a92ffd..08fbe95d55e 100644 --- a/core/modules/views/config/views.view.backlinks.yml +++ b/core/modules/views/config/views.view.backlinks.yml @@ -1,3 +1,4 @@ +langcode: en status: '0' module: search id: backlinks diff --git a/core/modules/views/config/views.view.comments_recent.yml b/core/modules/views/config/views.view.comments_recent.yml index 2a5286d2b39..f71d6715da8 100644 --- a/core/modules/views/config/views.view.comments_recent.yml +++ b/core/modules/views/config/views.view.comments_recent.yml @@ -1,3 +1,4 @@ +langcode: en status: '0' module: comment id: comments_recent diff --git a/core/modules/views/config/views.view.glossary.yml b/core/modules/views/config/views.view.glossary.yml index 071ba33f30e..82f5c657f86 100644 --- a/core/modules/views/config/views.view.glossary.yml +++ b/core/modules/views/config/views.view.glossary.yml @@ -1,3 +1,4 @@ +langcode: en status: '0' module: node id: glossary diff --git a/core/modules/views/config/views.view.taxonomy_term.yml b/core/modules/views/config/views.view.taxonomy_term.yml index 652a6c06fbb..0cfeff225b4 100644 --- a/core/modules/views/config/views.view.taxonomy_term.yml +++ b/core/modules/views/config/views.view.taxonomy_term.yml @@ -1,3 +1,4 @@ +langcode: en status: '0' module: taxonomy id: taxonomy_term diff --git a/core/modules/views/config/views.view.tracker.yml b/core/modules/views/config/views.view.tracker.yml index 79b7d66c8e6..eb37ba76f1a 100644 --- a/core/modules/views/config/views.view.tracker.yml +++ b/core/modules/views/config/views.view.tracker.yml @@ -1,3 +1,4 @@ +langcode: en status: '0' module: node id: tracker diff --git a/core/modules/views/lib/Drupal/views/Plugin/Core/Entity/View.php b/core/modules/views/lib/Drupal/views/Plugin/Core/Entity/View.php index 71a69107ad2..11df1ab1de5 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/Core/Entity/View.php +++ b/core/modules/views/lib/Drupal/views/Plugin/Core/Entity/View.php @@ -365,6 +365,7 @@ class View extends ConfigEntityBase implements ViewStorageInterface { 'id', 'tag', 'uuid', + 'langcode', ); $properties = array(); foreach ($names as $name) { diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/wizard/WizardPluginBase.php b/core/modules/views/lib/Drupal/views/Plugin/views/wizard/WizardPluginBase.php index 50013dc2c21..9a7fd4b992a 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/views/wizard/WizardPluginBase.php +++ b/core/modules/views/lib/Drupal/views/Plugin/views/wizard/WizardPluginBase.php @@ -556,6 +556,7 @@ abstract class WizardPluginBase extends PluginBase implements WizardInterface { */ protected function build_filters(&$form, &$form_state) { // Find all the fields we are allowed to filter by. + module_load_include('inc', 'views_ui', 'admin'); $fields = views_fetch_fields($this->base_table, 'filter'); $bundles = entity_get_bundles($this->entity_type); @@ -625,6 +626,7 @@ abstract class WizardPluginBase extends PluginBase implements WizardInterface { 'human_name' => $form_state['values']['human_name'], 'description' => $form_state['values']['description'], 'base_table' => $this->base_table, + 'langcode' => language_default()->langcode, ); $view = entity_create('view', $values); @@ -821,6 +823,7 @@ abstract class WizardPluginBase extends PluginBase implements WizardInterface { // Figure out the table where $bundle_key lives. It may not be the same as // the base table for the view; the taxonomy vocabulary machine_name, for // example, is stored in taxonomy_vocabulary, not taxonomy_term_data. + module_load_include('inc', 'views_ui', 'admin'); $fields = views_fetch_fields($this->base_table, 'filter'); if (isset($fields[$this->base_table . '.' . $bundle_key])) { $table = $this->base_table; diff --git a/core/modules/views/lib/Drupal/views/Tests/UI/StorageTest.php b/core/modules/views/lib/Drupal/views/Tests/UI/StorageTest.php index c74013264e6..b124578827b 100644 --- a/core/modules/views/lib/Drupal/views/Tests/UI/StorageTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/UI/StorageTest.php @@ -7,6 +7,8 @@ namespace Drupal\views\Tests\UI; +use Drupal\Core\Language\Language; + /** * Tests the UI of storage properties of views. */ @@ -19,6 +21,13 @@ class StorageTest extends UITestBase { */ public static $testViews = array('test_view'); + /** + * Modules to enable. + * + * @var array + */ + public static $modules = array('views_ui', 'language'); + public static function getInfo() { return array( 'name' => 'Storage properties', @@ -34,19 +43,22 @@ class StorageTest extends UITestBase { */ public function testDetails() { $view_name = 'test_view'; - $view = views_get_view($view_name); + + $language = new Language(array('name' => 'French', 'langcode' => 'fr')); + language_save($language); $edit = array( 'human_name' => $this->randomName(), 'tag' => $this->randomName(), 'description' => $this->randomName(30), + 'langcode' => 'fr', ); $this->drupalPost("admin/structure/views/nojs/edit-details/$view_name/default", $edit, t('Apply')); $this->drupalPost(NULL, array(), t('Save')); $view = views_get_view($view_name); - foreach (array('human_name', 'tag', 'description') as $property) { + foreach (array('human_name', 'tag', 'description', 'langcode') as $property) { $this->assertEqual($view->storage->get($property), $edit[$property], format_string('Make sure the property @property got probably saved.', array('@property' => $property))); } } diff --git a/core/modules/views/lib/Drupal/views/Tests/Wizard/WizardPluginBaseUnitTest.php b/core/modules/views/lib/Drupal/views/Tests/Wizard/WizardPluginBaseUnitTest.php new file mode 100644 index 00000000000..6cae58f60f2 --- /dev/null +++ b/core/modules/views/lib/Drupal/views/Tests/Wizard/WizardPluginBaseUnitTest.php @@ -0,0 +1,90 @@ + 'Wizard Plugin Base', + 'description' => 'Test the wizard base plugin class', + 'group' => 'Views Wizard', + ); + } + + protected function setUp() { + parent::setUp(); + + $this->installSchema('language', 'language'); + $this->installSchema('system', 'variable'); + + $this->wizard = $this->container->get('plugin.manager.views.wizard')->createInstance('standard:views_test_data', array()); + } + + /** + * Tests the creating of a view. + * + * @see \Drupal\views\Plugin\views\wizard\WizardPluginBase + */ + public function testCreateView() { + $form = array(); + $form_state = array(); + $form = $this->wizard->build_form($form, $form_state); + $random_id = strtolower($this->randomName()); + $random_human_name = $this->randomName(); + $random_description = $this->randomName(); + + // Add a new language and mark it as default. + $language = new Language(array( + 'langcode' => 'it', + 'name' => 'Italian', + 'default' => TRUE, + )); + language_save($language); + + $form_state['values'] = array( + 'id' => $random_id, + 'human_name' => $random_human_name, + 'description' => $random_description, + 'base_table' => 'views_test_data', + ); + + $this->wizard->validateView($form, $form_state); + $view = $this->wizard->create_view($form, $form_state); + $this->assertTrue($view instanceof ViewUI, 'The created view is a ViewUI object.'); + $this->assertEqual($view->get('id'), $random_id); + $this->assertEqual($view->get('human_name'), $random_human_name); + $this->assertEqual($view->get('description'), $random_description); + $this->assertEqual($view->get('base_table'), 'views_test_data'); + $this->assertEqual($view->get('langcode'), 'it'); + } +} + diff --git a/core/modules/views/views_ui/lib/Drupal/views_ui/Form/Ajax/EditDetails.php b/core/modules/views/views_ui/lib/Drupal/views_ui/Form/Ajax/EditDetails.php index ad9a0562b2d..d98883ef572 100644 --- a/core/modules/views/views_ui/lib/Drupal/views_ui/Form/Ajax/EditDetails.php +++ b/core/modules/views/views_ui/lib/Drupal/views_ui/Form/Ajax/EditDetails.php @@ -47,6 +47,12 @@ class EditDetails extends ViewsFormBase { '#description' => t('A descriptive human-readable name for this view. Spaces are allowed'), '#default_value' => $view->getHumanName(), ); + $form['details']['langcode'] = array( + '#type' => 'language_select', + '#title' => t('View language'), + '#description' => t('Language of labels and other textual elements in this view.'), + '#default_value' => $view->get('langcode'), + ); $form['details']['tag'] = array( '#type' => 'textfield', '#title' => t('View tag'),