Commit 21ae3ef2 authored by webchick's avatar webchick

Issue #2124377 by ellishettinga, Jelle_S, attiks, mdrummond, Schnitzel,...

Issue #2124377 by ellishettinga, Jelle_S, attiks, mdrummond, Schnitzel, InternetDevels: Rename "Picture" module to "Responsive Image" module.
parent 533ee3a1
......@@ -353,9 +353,6 @@ Path module
Phone module
- Dave Reid 'davereid' http://drupal.org/user/53892
Picture module
- Peter Droogmans 'attiks' http://drupal.org/user/105002
RDF module
- Stéphane Corlosquet 'scor' http://drupal.org/user/52142
......@@ -363,6 +360,9 @@ REST module
- Klaus Purer 'klausi' http://drupal.org/user/262198
- Larry Garfield 'Crell' http://drupal.org/user/26398
Responsive Image module
- Peter Droogmans 'attiks' http://drupal.org/user/105002
Search module
- Jennifer Hodgdon 'jhodgdon' https://drupal.org/user/155601
- Peter Wolanin 'pwolanin' https://drupal.org/user/49851
......
......@@ -35,7 +35,7 @@ class ConfigTranslationListUiTest extends WebTestBase {
'shortcut',
'taxonomy',
'image',
'picture',
'responsive_image',
'toolbar',
);
......@@ -73,7 +73,7 @@ public function setUp() {
'administer account settings',
'administer languages',
'administer image styles',
'administer pictures',
'administer responsive image',
'translate configuration',
);
......@@ -364,20 +364,20 @@ public function doImageStyleListTest() {
}
/**
* Tests the picture mapping listing for the translate operation.
* Tests the responsive image mapping listing for the translate operation.
*/
public function doPictureListTest() {
public function doResponsiveImageListTest() {
$edit = array();
$edit['label'] = $this->randomName();
$edit['id'] = strtolower($edit['label']);
$this->drupalPostForm('admin/config/media/picturemapping/add', $edit, t('Save'));
$this->assertRaw(t('Picture mapping %label saved.', array('%label' => $edit['label'])));
$this->drupalPostForm('admin/config/media/responsive-image-mapping/add', $edit, t('Save'));
$this->assertRaw(t('Responsive image mapping %label saved.', array('%label' => $edit['label'])));
// Get the picture mapping listing.
$this->drupalGet('admin/config/media/picturemapping');
// Get the responsive image mapping listing.
$this->drupalGet('admin/config/media/responsive-image-mapping');
$translate_link = 'admin/config/media/picturemapping/' . $edit['id'] . '/translate';
$translate_link = 'admin/config/media/responsive-image-mapping/' . $edit['id'] . '/translate';
// Test if the link to translate the style is on the page.
$this->assertLinkByHref($translate_link);
......@@ -474,7 +474,7 @@ public function testTranslateOperationInListUi() {
$this->doUserRoleListTest();
$this->doLanguageListTest();
$this->doImageStyleListTest();
$this->doPictureListTest();
$this->doResponsiveImageListTest();
$this->doDateFormatListTest();
$this->doFieldListTest();
......
picture.mapping_page_add:
route_name: picture.mapping_page_add
title: 'Add picture mapping'
appears_on:
- picture.mapping_page
picture.mapping_page_edit:
title: Edit
route_name: picture.mapping_page_edit
base_route: picture.mapping_page_edit
weight: -10
picture.mapping_page:
path: '/admin/config/media/picturemapping'
defaults:
_entity_list: 'picture_mapping'
_title: 'Picture mappings'
requirements:
_permission: 'administer pictures'
picture.mapping_page_add:
path: '/admin/config/media/picturemapping/add'
defaults:
_entity_form: 'picture_mapping.add'
_title: 'Add picture mapping'
requirements:
_permission: 'administer pictures'
picture.mapping_page_edit:
path: '/admin/config/media/picturemapping/{picture_mapping}'
defaults:
_entity_form: 'picture_mapping.edit'
_title: 'Edit picture mapping'
requirements:
_permission: 'administer pictures'
picture.mapping_page_duplicate:
path: '/admin/config/media/picturemapping/{picture_mapping}/duplicate'
defaults:
_entity_form: 'picture_mapping.duplicate'
_title: 'Duplicate picture mapping'
requirements:
_permission: 'administer pictures'
picture.mapping_action_confirm:
path: '/admin/config/media/picturemapping/{picture_mapping}/delete'
defaults:
_entity_form: 'picture_mapping.delete'
_title: 'Delete'
requirements:
_permission: 'administer pictures'
# Schema for the configuration files of the Picture module.
# Schema for the configuration files of the Responsive Image module.
picture.mappings.*:
responsive_image.mappings.*:
type: mapping
label: 'Picture mapping'
label: 'Responsive image mapping'
mapping:
id:
type: string
......@@ -38,17 +38,17 @@ picture.mappings.*:
type: string
label: 'Default language'
entity_view_display.field.picture:
entity_view_display.field.responsive_image:
type: entity_field_view_display_base
label: 'Picture list format settings'
label: 'Responsive image list format settings'
mapping:
settings:
type: mapping
label: 'Settings'
mapping:
picture_mapping:
responsive_image_mapping:
type: string
label: 'Picture mapping'
label: 'Responsive image mapping'
fallback_image_style:
type: string
label: 'Fallback image style'
......
......@@ -2,67 +2,67 @@
/**
* @file
* Definition of Drupal\picture\PictureMapping.
* Definition of Drupal\responsive_image\ResponsiveImageMapping.
*/
namespace Drupal\picture\Entity;
namespace Drupal\responsive_image\Entity;
use Drupal\Core\Config\Entity\ConfigEntityBase;
use Drupal\picture\PictureMappingInterface;
use Drupal\responsive_image\ResponsiveImageMappingInterface;
/**
* Defines the Picture entity.
* Defines the responsive image mapping entity.
*
* @ConfigEntityType(
* id = "picture_mapping",
* label = @Translation("Picture mapping"),
* id = "responsive_image_mapping",
* label = @Translation("Responsive image mapping"),
* controllers = {
* "list" = "Drupal\picture\PictureMappingListController",
* "list" = "Drupal\responsive_image\ResponsiveImageMappingListController",
* "form" = {
* "edit" = "Drupal\picture\PictureMappingFormController",
* "add" = "Drupal\picture\PictureMappingFormController",
* "delete" = "Drupal\picture\Form\PictureMappingDeleteForm",
* "duplicate" = "Drupal\picture\PictureMappingFormController"
* "edit" = "Drupal\responsive_image\ResponsiveImageMappingFormController",
* "add" = "Drupal\responsive_image\ResponsiveImageMappingFormController",
* "delete" = "Drupal\responsive_image\Form\ResponsiveImageMappingDeleteForm",
* "duplicate" = "Drupal\responsive_image\ResponsiveImageMappingFormController"
* }
* },
* list_path = "admin/config/media/picturemapping",
* admin_permission = "administer pictures",
* list_path = "admin/config/media/responsive-image-mapping",
* admin_permission = "administer responsive image",
* config_prefix = "mappings",
* entity_keys = {
* "id" = "id",
* "label" = "label"
* },
* links = {
* "edit-form" = "picture.mapping_page_edit",
* "duplicate-form" = "picture.mapping_page_duplicate"
* "edit-form" = "responsive_image.mapping_page_edit",
* "duplicate-form" = "responsive_image.mapping_page_duplicate"
* }
* )
*/
class PictureMapping extends ConfigEntityBase implements PictureMappingInterface {
class ResponsiveImageMapping extends ConfigEntityBase implements ResponsiveImageMappingInterface {
/**
* The picture ID (machine name).
* The responsive image ID (machine name).
*
* @var string
*/
public $id;
/**
* The picture label.
* The responsive image label.
*
* @var string
*/
public $label;
/**
* The picture mappings.
* The responsive image mappings.
*
* @var array
*/
public $mappings = array();
/**
* The picture breakpoint group.
* The responsive image breakpoint group.
*
* @var BreakpointGroup
*/
......@@ -104,7 +104,7 @@ public function save() {
* Implements \Drupal\Core\Entity\EntityInterface::createDuplicate().
*/
public function createDuplicate() {
return entity_create('picture_mapping', array(
return entity_create('responsive_image_mapping', array(
'id' => '',
'label' => t('Clone of !label', array('!label' => check_plain($this->label()))),
'mappings' => $this->mappings,
......
......@@ -2,20 +2,20 @@
/**
* @file
* Contains \Drupal\picture\Form\PictureMappingActionConfirm.
* Contains \Drupal\responsive_image\Form\ResponsiveImageMappingActionConfirm.
*/
namespace Drupal\picture\Form;
namespace Drupal\responsive_image\Form;
use Drupal\Core\Entity\EntityConfirmFormBase;
class PictureMappingDeleteForm extends EntityConfirmFormBase {
class ResponsiveImageMappingDeleteForm extends EntityConfirmFormBase {
/**
* {@inheritdoc}
*/
public function getQuestion() {
return t('Are you sure you want to delete the picture_mapping %title?', array('%title' => $this->entity->label()));
return t('Are you sure you want to delete the responsive image mapping %title?', array('%title' => $this->entity->label()));
}
/**
......@@ -23,7 +23,7 @@ public function getQuestion() {
*/
public function getCancelRoute() {
return array(
'route_name' => 'picture.mapping_page',
'route_name' => 'responsive_image.mapping_page',
);
}
......@@ -39,9 +39,9 @@ public function getConfirmText() {
*/
public function submit(array $form, array &$form_state) {
$this->entity->delete();
drupal_set_message(t('Picture mapping %label has been deleted.', array('%label' => $this->entity->label())));
watchdog('picture', 'Picture mapping %label has been deleted.', array('%label' => $this->entity->label()), WATCHDOG_NOTICE);
$form_state['redirect_route']['route_name'] = 'picture.mapping_page';
drupal_set_message(t('Responsive image mapping %label has been deleted.', array('%label' => $this->entity->label())));
watchdog('responsive_image', 'Responsive image mapping %label has been deleted.', array('%label' => $this->entity->label()), WATCHDOG_NOTICE);
$form_state['redirect_route']['route_name'] = 'responsive_image.mapping_page';
}
}
......@@ -2,52 +2,52 @@
/**
* @file
* Contains \Drupal\picture\Plugin\field\formatter\PictureFormatter.
* Contains \Drupal\responsive_image\Plugin\field\formatter\ResponsiveImageFormatter.
*/
namespace Drupal\picture\Plugin\Field\FieldFormatter;
namespace Drupal\responsive_image\Plugin\Field\FieldFormatter;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\image\Plugin\Field\FieldFormatter\ImageFormatterBase;
/**
* Plugin for picture formatter.
* Plugin for responsive image formatter.
*
* @FieldFormatter(
* id = "picture",
* label = @Translation("Picture"),
* id = "responsive_image",
* label = @Translation("Responsive image"),
* field_types = {
* "image",
* },
* settings = {
* "picture_mapping" = "",
* "responsive_image_mapping" = "",
* "fallback_image_style" = "",
* "image_link" = "",
* }
* )
*/
class PictureFormatter extends ImageFormatterBase {
class ResponsiveImageFormatter extends ImageFormatterBase {
/**
* {@inheritdoc}
*/
public function settingsForm(array $form, array &$form_state) {
$picture_options = array();
$picture_mappings = entity_load_multiple('picture_mapping');
if ($picture_mappings && !empty($picture_mappings)) {
foreach ($picture_mappings as $machine_name => $picture_mapping) {
if ($picture_mapping->hasMappings()) {
$picture_options[$machine_name] = $picture_mapping->label();
$responsive_image_options = array();
$responsive_image_mappings = entity_load_multiple('responsive_image_mapping');
if ($responsive_image_mappings && !empty($responsive_image_mappings)) {
foreach ($responsive_image_mappings as $machine_name => $responsive_image_mapping) {
if ($responsive_image_mapping->hasMappings()) {
$responsive_image_options[$machine_name] = $responsive_image_mapping->label();
}
}
}
$elements['picture_mapping'] = array(
'#title' => t('Picture mapping'),
$elements['responsive_image_mapping'] = array(
'#title' => t('Responsive image mapping'),
'#type' => 'select',
'#default_value' => $this->getSetting('picture_mapping'),
'#default_value' => $this->getSetting('responsive_image_mapping'),
'#required' => TRUE,
'#options' => $picture_options,
'#options' => $responsive_image_options,
);
$image_styles = image_style_options(FALSE);
......@@ -80,9 +80,9 @@ public function settingsForm(array $form, array &$form_state) {
public function settingsSummary() {
$summary = array();
$picture_mapping = entity_load('picture_mapping', $this->getSetting('picture_mapping'));
if ($picture_mapping) {
$summary[] = t('Picture mapping: @picture_mapping', array('@picture_mapping' => $picture_mapping->label()));
$responsive_image_mapping = entity_load('responsive_image_mapping', $this->getSetting('responsive_image_mapping'));
if ($responsive_image_mapping) {
$summary[] = t('Responsive image mapping: @responsive_image_mapping', array('@responsive_image_mapping' => $responsive_image_mapping->label()));
$image_styles = image_style_options(FALSE);
unset($image_styles['']);
......@@ -103,7 +103,7 @@ public function settingsSummary() {
}
}
else {
$summary[] = t('Select a picture mapping.');
$summary[] = t('Select a responsive image mapping.');
}
return $summary;
......@@ -117,7 +117,7 @@ public function viewElements(FieldItemListInterface $items) {
// Check if the formatter involves a link.
if ($this->getSetting('image_link') == 'content') {
$uri = $items->getEntity()->urlInfo();
// @todo Remove when theme_picture_formatter() has support for route name.
// @todo Remove when theme_responsive_image_formatter() has support for route name.
$uri['path'] = $items->getEntity()->getSystemPath();
}
elseif ($this->getSetting('image_link') == 'file') {
......@@ -127,15 +127,15 @@ public function viewElements(FieldItemListInterface $items) {
$breakpoint_styles = array();
$fallback_image_style = '';
$picture_mapping = entity_load('picture_mapping', $this->getSetting('picture_mapping'));
if ($picture_mapping) {
foreach ($picture_mapping->mappings as $breakpoint_name => $multipliers) {
$responsive_image_mapping = entity_load('responsive_image_mapping', $this->getSetting('responsive_image_mapping'));
if ($responsive_image_mapping) {
foreach ($responsive_image_mapping->mappings as $breakpoint_name => $multipliers) {
// Make sure there are multipliers.
if (!empty($multipliers)) {
// Make sure that the breakpoint exists and is enabled.
// @todo add the following when breakpoint->status is added again:
// $picture_mapping->breakpointGroup->breakpoints[$breakpoint_name]->status
$breakpoint = $picture_mapping->breakpointGroup->getBreakpointById($breakpoint_name);
// $responsive_image_mapping->breakpointGroup->breakpoints[$breakpoint_name]->status
$breakpoint = $responsive_image_mapping->breakpointGroup->getBreakpointById($breakpoint_name);
if ($breakpoint) {
// Determine the enabled multipliers.
$multipliers = array_intersect_key($multipliers, $breakpoint->multipliers);
......@@ -170,7 +170,7 @@ public function viewElements(FieldItemListInterface $items) {
);
}
$elements[$delta] = array(
'#theme' => 'picture_formatter',
'#theme' => 'responsive_image_formatter',
'#attached' => array('library' => array(
'core/picturefill',
)),
......
......@@ -2,17 +2,17 @@
/**
* @file
* Contains Drupal\picture\PictureFormController.
* Contains Drupal\responsive_image\ResponsiveImageFormController.
*/
namespace Drupal\picture;
namespace Drupal\responsive_image;
use Drupal\Core\Entity\EntityFormController;
/**
* Form controller for the picture edit/add forms.
* Form controller for the responsive image edit/add forms.
*/
class PictureMappingFormController extends EntityFormController {
class ResponsiveImageMappingFormController extends EntityFormController {
/**
* Overrides Drupal\Core\Entity\EntityFormController::form().
......@@ -21,7 +21,7 @@ class PictureMappingFormController extends EntityFormController {
* A nested array form elements comprising the form.
* @param array $form_state
* An associative array containing the current state of the form.
* @param \Drupal\picture\PictureMappingInterface $picture_mapping
* @param \Drupal\responsive_image\ResponsiveImageMappingInterface $responsive_image_mapping
* The entity being edited.
*
* @return array
......@@ -29,33 +29,33 @@ class PictureMappingFormController extends EntityFormController {
*/
public function form(array $form, array &$form_state) {
if ($this->operation == 'duplicate') {
$form['#title'] = $this->t('<em>Duplicate picture mapping</em> @label', array('@label' => $this->entity->label()));
$form['#title'] = $this->t('<em>Duplicate responsive image mapping</em> @label', array('@label' => $this->entity->label()));
$this->entity = $this->entity->createDuplicate();
}
if ($this->operation == 'edit') {
$form['#title'] = $this->t('<em>Edit picture mapping</em> @label', array('@label' => $this->entity->label()));
$form['#title'] = $this->t('<em>Edit responsive image mapping</em> @label', array('@label' => $this->entity->label()));
}
$picture_mapping = $this->entity;
$responsive_image_mapping = $this->entity;
$form['label'] = array(
'#type' => 'textfield',
'#title' => $this->t('Label'),
'#maxlength' => 255,
'#default_value' => $picture_mapping->label(),
'#default_value' => $responsive_image_mapping->label(),
'#description' => $this->t("Example: 'Hero image' or 'Author image'."),
'#required' => TRUE,
);
$form['id'] = array(
'#type' => 'machine_name',
'#default_value' => $picture_mapping->id(),
'#default_value' => $responsive_image_mapping->id(),
'#machine_name' => array(
'exists' => 'picture_mapping_load',
'exists' => 'responsive_image_mapping_load',
'source' => array('label'),
),
'#disabled' => (bool) $picture_mapping->id() && $this->operation != 'duplicate',
'#disabled' => (bool) $responsive_image_mapping->id() && $this->operation != 'duplicate',
);
if ((bool) $picture_mapping->id() && $this->operation != 'duplicate') {
if ((bool) $responsive_image_mapping->id() && $this->operation != 'duplicate') {
$description = $this->t('Select a breakpoint group from the enabled themes.') . ' ' . $this->t("Warning: if you change the breakpoint group you lose all your selected mappings.");
}
else {
......@@ -64,16 +64,16 @@ public function form(array $form, array &$form_state) {
$form['breakpointGroup'] = array(
'#type' => 'select',
'#title' => $this->t('Breakpoint group'),
'#default_value' => !empty($picture_mapping->breakpointGroup) ? $picture_mapping->breakpointGroup->id() : '',
'#default_value' => !empty($responsive_image_mapping->breakpointGroup) ? $responsive_image_mapping->breakpointGroup->id() : '',
'#options' => breakpoint_group_select_options(),
'#required' => TRUE,
'#description' => $description,
);
$image_styles = image_style_options(TRUE);
foreach ($picture_mapping->mappings as $breakpoint_id => $mapping) {
foreach ($responsive_image_mapping->mappings as $breakpoint_id => $mapping) {
foreach ($mapping as $multiplier => $image_style) {
$breakpoint = $picture_mapping->breakpointGroup->getBreakpointById($breakpoint_id);
$breakpoint = $responsive_image_mapping->breakpointGroup->getBreakpointById($breakpoint_id);
$label = $multiplier . ' ' . $breakpoint->name . ' [' . $breakpoint->mediaQuery . ']';
$form['mappings'][$breakpoint_id][$multiplier] = array(
'#type' => 'select',
......@@ -87,7 +87,7 @@ public function form(array $form, array &$form_state) {
$form['#tree'] = TRUE;
return parent::form($form, $form_state, $picture_mapping);
return parent::form($form, $form_state, $responsive_image_mapping);
}
/**
......@@ -113,11 +113,11 @@ protected function actions(array $form, array &$form_state) {
* Overrides Drupal\Core\Entity\EntityFormController::validate().
*/
public function validate(array $form, array &$form_state) {
$picture_mapping = $this->entity;
$responsive_image_mapping = $this->entity;
// Only validate on edit.
if (isset($form_state['values']['mappings'])) {
$picture_mapping->mappings = $form_state['values']['mappings'];
$responsive_image_mapping->mappings = $form_state['values']['mappings'];
// Check if another breakpoint group is selected.
if ($form_state['values']['breakpointGroup'] != $form_state['complete_form']['breakpointGroup']['#default_value']) {
......@@ -125,7 +125,7 @@ public function validate(array $form, array &$form_state) {
unset($form_state['values']['mappings']);
}
// Make sure at least one mapping is defined.
elseif (!$picture_mapping->isNew() && !$picture_mapping->hasMappings()) {
elseif (!$responsive_image_mapping->isNew() && !$responsive_image_mapping->hasMappings()) {
$this->setFormError('mappings', $form_state, $this->t('Please select at least one mapping.'));
}
}
......@@ -135,24 +135,24 @@ public function validate(array $form, array &$form_state) {
* Overrides Drupal\Core\Entity\EntityFormController::save().
*/
public function save(array $form, array &$form_state) {
$picture_mapping = $this->entity;
$picture_mapping->save();
$responsive_image_mapping = $this->entity;
$responsive_image_mapping->save();
watchdog('picture', 'Picture mapping @label saved.', array('@label' => $picture_mapping->label()), WATCHDOG_NOTICE);
drupal_set_message($this->t('Picture mapping %label saved.', array('%label' => $picture_mapping->label())));
watchdog('responsive_image', 'Responsive image mapping @label saved.', array('@label' => $responsive_image_mapping->label()), WATCHDOG_NOTICE);
drupal_set_message($this->t('Responsive image mapping %label saved.', array('%label' => $responsive_image_mapping->label())));
// Redirect to edit form after creating a new mapping or after selecting
// another breakpoint group.
if (!$picture_mapping->hasMappings()) {
if (!$responsive_image_mapping->hasMappings()) {
$form_state['redirect_route'] = array(
'route_name' => 'picture.mapping_page_edit',
'route_name' => 'responsive_image.mapping_page_edit',
'route_parameters' => array(
'picture_mapping' => $picture_mapping->id(),
'responsive_image_mapping' => $responsive_image_mapping->id(),
),
);
}
else {
$form_state['redirect_route']['route_name'] = 'picture.mapping_page';
$form_state['redirect_route']['route_name'] = 'responsive_image.mapping_page';
}
}
......
......@@ -2,17 +2,17 @@
/**
* @file
* Contains \Drupal\picture\Entity\PictureMappingInterface.
* Contains \Drupal\responsive_image\Entity\ResponsiveImageMappingInterface.
*/
namespace Drupal\picture;
namespace Drupal\responsive_image;
use Drupal\Core\Config\Entity\ConfigEntityInterface;
/**
* Provides an interface defining a picture mapping entity.
* Provides an interface defining a responsive image mapping entity.
*/
interface PictureMappingInterface extends ConfigEntityInterface {
interface ResponsiveImageMappingInterface extends ConfigEntityInterface {
/**
* Checks if there's at least one mapping defined.
......
......@@ -2,18 +2,18 @@
/**
* @file
* Contains Drupal\picture\PictureListController.
* Contains Drupal\responsive_image\ResponsiveImageListController.
*/
namespace Drupal\picture;
namespace Drupal\responsive_image;
use Drupal\Core\Config\Entity\ConfigEntityListController;
use Drupal\Core\Entity\EntityInterface;
/**
* Provides a listing of Pictures.
* Provides a listing of responsive image mappings.
*/
class PictureMappingListController extends ConfigEntityListController {
class ResponsiveImageMappingListController extends ConfigEntityListController {
/**
* {@inheritdoc}
......
......@@ -2,10 +2,10 @@
/**
* @file
* Definition of Drupal\picture\Tests\PictureAdminUITest.
* Definition of Drupal\responsive_image\Tests\ResponsiveImageAdminUITest.
*/
namespace Drupal\picture\Tests;
namespace Drupal\responsive_image\Tests;
use Drupal\simpletest\WebTestBase;
use Drupal\breakpoint\Entity\Breakpoint;
......@@ -13,23 +13,23 @@
/**
* Tests for breakpoint sets admin interface.
*/
class PictureAdminUITest extends WebTestBase {
class ResponsiveImageAdminUITest extends WebTestBase {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = array('picture');
public static $modules = array('responsive_image');
/**
* Drupal\simpletest\WebTestBase\getInfo().
*/
public static function getInfo() {
return array(
'name' => 'Picture administration functionality',
'description' => 'Thoroughly test the administrative interface of the picture module.',
'group' => 'Picture',
'name' => 'Responsive Image administration functionality',
'description' => 'Thoroughly test the administrative interface of the responsive image module.',
'group' => 'Responsive Image',
);
}
......@@ -41,7 +41,7 @@ public function setUp() {