diff --git a/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationTestBase.php b/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationTestBase.php index b43d921..600033f 100644 --- a/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationTestBase.php +++ b/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationTestBase.php @@ -97,6 +97,9 @@ protected function setupLanguages() { language_save(new Language(array('id' => $langcode))); } array_unshift($this->langcodes, language_default()->id); + $prefixes = language_negotiation_url_prefixes(); + $prefixes['en'] = 'en'; + language_negotiation_url_prefixes_save($prefixes); } /** diff --git a/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationUITest.php b/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationUITest.php index 74b779b..4e627e3 100644 --- a/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationUITest.php +++ b/core/modules/content_translation/lib/Drupal/content_translation/Tests/ContentTranslationUITest.php @@ -65,8 +65,9 @@ protected function assertBasicTranslation() { $values[$langcode] = $this->getNewEntityValues($langcode); $base_path = $this->controller->getBasePath($entity); - $path = $langcode . '/' . $base_path . '/translations/add/' . $default_langcode . '/' . $langcode; - $this->drupalPost($path, $this->getEditValues($values, $langcode), $this->getFormSubmitAction($entity)); + $path = $base_path . '/translations/add/' . $default_langcode . '/' . $langcode; + $language = language_load($langcode); + $this->drupalPost($path, $this->getEditValues($values, $langcode), $this->getFormSubmitAction($entity), array('language' => $language)); if ($this->testLanguageSelector) { $this->assertNoFieldByXPath('//select[@id="edit-langcode"]', NULL, 'Language selector correclty disabled on translations.'); } @@ -76,8 +77,9 @@ protected function assertBasicTranslation() { $langcode = 'fr'; $source_langcode = 'it'; $edit = array('source_langcode[source]' => $source_langcode); - $path = $langcode . '/' . $base_path . '/translations/add/' . $default_langcode . '/' . $langcode; - $this->drupalPost($path, $edit, t('Change')); + $path = $base_path . '/translations/add/' . $default_langcode . '/' . $langcode; + $language = language_load($langcode); + $this->drupalPost($path, $edit, t('Change'), array('language' => $language)); $this->assertFieldByXPath("//input[@name=\"{$this->fieldName}[fr][0][value]\"]", $values[$source_langcode][$this->fieldName][0]['value'], 'Source language correctly switched.'); // Add another translation and mark the other ones as outdated. @@ -108,22 +110,24 @@ protected function assertOutdatedStatus() { // Mark translations as outdated. $edit = array('content_translation[retranslate]' => TRUE); - $this->drupalPost($langcode . '/' . $this->controller->getEditPath($entity), $edit, $this->getFormSubmitAction($entity)); + $options = array('language' => language_load($default_langcode)); + $this->drupalPost($this->controller->getEditPath($entity), $edit, $this->getFormSubmitAction($entity), $options); $entity = entity_load($this->entityType, $this->entityId, TRUE); // Check that every translation has the correct "outdated" status. foreach ($this->langcodes as $enabled_langcode) { - $prefix = $enabled_langcode != $default_langcode ? $enabled_langcode . '/' : ''; - $path = $prefix . $this->controller->getEditPath($entity); - $this->drupalGet($path); + $options = array('language' => language_load($enabled_langcode)); + $path = $this->controller->getEditPath($entity); + $this->drupalGet($path, $options); + if ($enabled_langcode == $langcode) { $this->assertFieldByXPath('//input[@name="content_translation[retranslate]"]', FALSE, 'The retranslate flag is not checked by default.'); } else { $this->assertFieldByXPath('//input[@name="content_translation[outdated]"]', TRUE, 'The translate flag is checked by default.'); $edit = array('content_translation[outdated]' => FALSE); - $this->drupalPost($path, $edit, $this->getFormSubmitAction($entity)); - $this->drupalGet($path); + $this->drupalPost($path, $edit, $this->getFormSubmitAction($entity), $options); + $this->drupalGet($path, $options); $this->assertFieldByXPath('//input[@name="content_translation[retranslate]"]', FALSE, 'The retranslate flag is now shown.'); $entity = entity_load($this->entityType, $this->entityId, TRUE); $this->assertFalse($entity->translation[$enabled_langcode]['outdated'], 'The "outdated" status has been correctly stored.'); @@ -142,7 +146,8 @@ protected function assertPublishedStatus() { foreach ($this->langcodes as $index => $langcode) { if ($index > 0) { $edit = array('content_translation[status]' => FALSE); - $this->drupalPost($langcode . '/' . $path, $edit, $this->getFormSubmitAction($entity)); + $options = array('language' => language_load($langcode)); + $this->drupalPost($langcode . '/' . $path, $edit, $this->getFormSubmitAction($entity), $options); $entity = entity_load($this->entityType, $this->entityId, TRUE); $this->assertFalse($entity->translation[$langcode]['status'], 'The translation has been correctly unpublished.'); } @@ -202,7 +207,7 @@ protected function assertTranslationDeletion() { // Confirm and delete a translation. $langcode = 'fr'; $entity = entity_load($this->entityType, $this->entityId, TRUE); - $this->drupalPost($langcode . '/' . $this->controller->getEditPath($entity), array(), t('Delete translation')); + $this->drupalPost($langcode . '/' . $this->controller->getEditPath($entity), array(), t('Delete translation'), $op); $this->drupalPost(NULL, array(), t('Delete')); $entity = entity_load($this->entityType, $this->entityId, TRUE); if ($this->assertTrue(is_object($entity), 'Entity found')) { diff --git a/core/modules/system/lib/Drupal/system/Plugin/Block/SystemHelpBlock.php b/core/modules/system/lib/Drupal/system/Plugin/Block/SystemHelpBlock.php index 23520a3..48ad76f 100644 --- a/core/modules/system/lib/Drupal/system/Plugin/Block/SystemHelpBlock.php +++ b/core/modules/system/lib/Drupal/system/Plugin/Block/SystemHelpBlock.php @@ -10,6 +10,10 @@ use Drupal\block\BlockBase; use Drupal\block\Annotation\Block; use Drupal\Core\Annotation\Translation; +use Drupal\Core\Extension\ModuleHandlerInterface; +use Drupal\Core\Plugin\ContainerFactoryPluginInterface; +use Symfony\Component\DependencyInjection\ContainerInterface; +use Symfony\Component\HttpFoundation\Request; /** * Provides a 'System Help' block. @@ -19,7 +23,7 @@ * admin_label = @Translation("System Help") * ) */ -class SystemHelpBlock extends BlockBase { +class SystemHelpBlock extends BlockBase implements ContainerFactoryPluginInterface { /** * Stores the help text associated with the active menu item. @@ -29,14 +33,83 @@ class SystemHelpBlock extends BlockBase { protected $help; /** + * The module handler. + * + * @var \Drupal\Core\Extension\ModuleHandlerInterface + */ + protected $moduleHandler; + + /** + * The current request. + * + * @var \Symfony\Component\HttpFoundation\Request + */ + protected $request; + + /** + * Creates a SystemHelpBlock instance. + * + * @param array $configuration + * A configuration array containing information about the plugin instance. + * @param string $plugin_id + * The plugin_id for the plugin instance. + * @param array $plugin_definition + * The plugin implementation definition. + * @param \Symfony\Component\HttpFoundation\Request $request + * The current request. + * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler + * The module handler. + */ + public function __construct(array $configuration, $plugin_id, array $plugin_definition, Request $request, ModuleHandlerInterface $module_handler) { + parent::__construct($configuration, $plugin_id, $plugin_definition); + + $this->request = $request; + $this->moduleHandler = $module_handler; + } + + /** + * {@inheritdoc} + */ + public static function create(ContainerInterface $container, array $configuration, $plugin_id, array $plugin_definition) { + return new static( + $configuration, $plugin_id, $plugin_definition, $container->get('request'), $container->get('module_handler')); + } + + /** * Overrides \Drupal\block\BlockBase::access(). */ public function access() { - $this->help = menu_get_active_help(); + $this->help = $this->getActiveHelp($this->request); return (bool) $this->help; } /** + * Returns the help associated with the active menu item. + * + * @param \Symfony\Component\HttpFoundation\Request $request + * The current request. + */ + protected function getActiveHelp(Request $request) { + $output = ''; + $router_path = menu_tab_root_path(); + // We will always have a path unless we are on a 403 or 404. + if (!$router_path) { + return ''; + } + + $arg = drupal_help_arg(explode('/', $request->attributes->get('_system_path'))); + + foreach ($this->moduleHandler->getImplementations('help') as $module) { + $function = $module . '_help'; + // Lookup help for this path. + if ($help = $function($router_path, $arg)) { + $output .= $help . "\n"; + } + } + return $output; + } + + /** * {@inheritdoc} */ public function build() {