Commit 4cb66856 authored by webchick's avatar webchick
Browse files

Issue #2134909 by Xano, Wim Leers: Clean up editor.module to match coding standards.

parent d6cda570
......@@ -2,6 +2,7 @@
* @file
* Styles for text editors.
*/
.editor-dialog {
/* This !important is required to override inline CSS of jQuery UI. */
width: 80% !important;
......
......@@ -12,6 +12,7 @@
"use strict";
Drupal.editorConfiguration = {
/**
* Must be called by a specific text editor's configuration whenever a feature
* is added by the user.
......@@ -25,6 +26,7 @@ Drupal.editorConfiguration = {
addedFeature: function (feature) {
$(document).trigger('drupalEditorFeatureAdded', feature);
},
/**
* Must be called by a specific text editor's configuration whenever a feature
* is removed by the user.
......@@ -38,6 +40,7 @@ Drupal.editorConfiguration = {
removedFeature: function (feature) {
$(document).trigger('drupalEditorFeatureRemoved', feature);
},
/**
* Must be called by a specific text editor's configuration whenever a feature
* is modified, i.e. has different rules.
......@@ -54,6 +57,7 @@ Drupal.editorConfiguration = {
modifiedFeature: function (feature) {
$(document).trigger('drupalEditorFeatureModified', feature);
},
/**
* May be called by a specific text editor's configuration whenever a feature
* is being added, to check whether it would require the filter settings to be
......
......@@ -7,7 +7,6 @@
namespace Drupal\editor;
use Symfony\Component\DependencyInjection\ContainerAware;
use Drupal\Core\Ajax\AjaxResponse;
use Drupal\Core\Ajax\OpenModalDialogCommand;
use Drupal\Core\Ajax\CloseModalDialogCommand;
......@@ -16,6 +15,7 @@
use Drupal\editor\Form\EditorImageDialog;
use Drupal\editor\Form\EditorLinkDialog;
use Drupal\filter\Entity\FilterFormat;
use Symfony\Component\DependencyInjection\ContainerAware;
/**
* Returns responses for Editor module routes.
......
......@@ -2,7 +2,7 @@
/**
* @file
* Contains \Drupal\editor\Entity\EditPluginInterface.
* Contains \Drupal\editor\EditorInterface.
*/
namespace Drupal\editor;
......
......@@ -14,8 +14,8 @@
/**
* Defines a base class from which other modules providing editors may extend.
*
* This class provides default implementations of the EditPluginInterface so that
* classes extending this one do not need to implement every method.
* This class provides default implementations of the EditorPluginInterface so
* that classes extending this one do not need to implement every method.
*
* Plugins extending this class need to define a plugin definition array through
* annotation. These definition arrays may be altered through
......@@ -24,41 +24,43 @@
* - id: The unique, system-wide identifier of the text editor. Typically named
* the same as the editor library.
* - label: The human-readable name of the text editor, translated.
* - module: The name of the module providing the plugin.
* - supports_inline_editing: Whether the editor supports the inline editing
* provided by the Edit module.
*
* A complete sample plugin definition should be defined as in this example:
*
* @code
* @Editor(
* id = "myeditor",
* label = @Translation("My Editor")
* label = @Translation("My Editor"),
* supports_inline_editing = FALSE
* )
* @endcode
*/
abstract class EditorBase extends PluginBase implements EditorPluginInterface {
/**
* Implements \Drupal\editor\Plugin\EditPluginInterface::getDefaultSettings().
* {@inheritdoc}
*/
public function getDefaultSettings() {
return array();
}
/**
* Implements \Drupal\editor\Plugin\EditPluginInterface::settingsForm().
* {@inheritdoc}
*/
public function settingsForm(array $form, array &$form_state, Editor $editor) {
return $form;
}
/**
* Implements \Drupal\editor\Plugin\EditPluginInterface::settingsFormValidate().
* {@inheritdoc}
*/
public function settingsFormValidate(array $form, array &$form_state) {
}
/**
* Implements \Drupal\editor\Plugin\EditPluginInterface::settingsFormSubmit().
* {@inheritdoc}
*/
public function settingsFormSubmit(array $form, array &$form_state) {
}
......
......@@ -13,9 +13,8 @@
/**
* Defines an interface for configurable text editors.
*
* Modules implementing this interface may want to extend the EditorBase
* class, which provides default implementations of each method where
* appropriate.
* Modules implementing this interface may want to extend the EditorBase class,
* which provides default implementations of each method where appropriate.
*/
interface EditorPluginInterface extends PluginInspectionInterface {
......@@ -106,8 +105,8 @@ public function getJSSettings(Editor $editor);
* A configured text editor object.
*
* @return array
* An array of libraries that will be added to the page for use by this
* text editor.
* An array of libraries that will be added to the page for use by this text
* editor.
*
* @see drupal_process_attached()
* @see EditorManager::getAttachments()
......
......@@ -2,7 +2,7 @@
/**
* @file
* Definition of \Drupal\editor\Tests\EditIntegrationLoadingTest.
* Contains \Drupal\editor\Tests\EditIntegrationLoadingTest.
*/
namespace Drupal\editor\Tests;
......@@ -36,7 +36,7 @@ public static function getInfo() {
);
}
function setUp() {
public function setUp() {
parent::setUp();
// Create a text format.
......@@ -73,7 +73,7 @@ function setUp() {
/**
* Test loading of untransformed text when a user doesn't have access to it.
*/
function testUsersWithoutPermission() {
public function testUsersWithoutPermission() {
// Create 3 users, each with insufficient permissions, i.e. without either
// or both of the following permissions:
// - the 'access in-place editing' permission
......@@ -103,7 +103,7 @@ function testUsersWithoutPermission() {
/**
* Test loading of untransformed text when a user does have access to it.
*/
function testUserWithPermission() {
public function testUserWithPermission() {
$user = $this->drupalCreateUser(array_merge(static::$basic_permissions, array('edit any article content', 'access in-place editing')));
$this->drupalLogin($user);
$this->drupalGet('node/1');
......
......@@ -64,7 +64,7 @@ public static function getInfo() {
);
}
function setUp() {
public function setUp() {
parent::setUp();
// Install the Filter module.
......@@ -122,7 +122,7 @@ protected function getSelectedEditor($items, $field_name, $view_mode = 'default'
* always with a ProcessedTextEditor plug-in present, but with varying text
* format compatibility.
*/
function testEditorSelection() {
public function testEditorSelection() {
$this->editorManager = new InPlaceEditorManager($this->container->get('container.namespaces'));
$this->editorSelector = new EditorSelector($this->editorManager, $this->container->get('plugin.manager.field.formatter'));
......@@ -146,7 +146,7 @@ function testEditorSelection() {
/**
* Tests (custom) metadata when the formatted text editor is used.
*/
function testMetadata() {
public function testMetadata() {
$this->editorManager = new InPlaceEditorManager($this->container->get('container.namespaces'));
$this->accessChecker = new MockEditEntityFieldAccessCheck();
$this->editorSelector = new EditorSelector($this->editorManager, $this->container->get('plugin.manager.field.formatter'));
......@@ -178,7 +178,7 @@ function testMetadata() {
/**
* Tests GetUntransformedTextCommand AJAX command.
*/
function testGetUntransformedTextCommand() {
public function testGetUntransformedTextCommand() {
// Create an entity with values for the field.
$this->entity = entity_create('entity_test', array());
$this->entity->{$this->field_name}->value = 'Test';
......@@ -198,4 +198,5 @@ function testGetUntransformedTextCommand() {
);
$this->assertEqual(drupal_json_encode($expected), $response->prepare($request)->getContent(), 'The GetUntransformedTextCommand AJAX command works correctly.');
}
}
......@@ -2,7 +2,7 @@
/**
* @file
* Definition of \Drupal\editor\Tests\EditorAdminTest.
* Contains \Drupal\editor\Tests\EditorAdminTest.
*/
namespace Drupal\editor\Tests;
......@@ -29,7 +29,7 @@ public static function getInfo() {
);
}
function setUp() {
public function setUp() {
parent::setUp();
// Add text format.
......@@ -48,7 +48,7 @@ function setUp() {
/**
* Tests an existing format without any editors available.
*/
function testNoEditorAvailable() {
public function testNoEditorAvailable() {
$this->drupalLogin($this->admin_user);
$this->drupalGet('admin/config/content/formats/manage/filtered_html');
......@@ -72,7 +72,7 @@ function testNoEditorAvailable() {
/**
* Tests adding a text editor to an existing text format.
*/
function testAddEditorToExistingFormat() {
public function testAddEditorToExistingFormat() {
$this->enableUnicornEditor();
$this->drupalLogin($this->admin_user);
$this->drupalGet('admin/config/content/formats/manage/filtered_html');
......@@ -86,7 +86,7 @@ function testAddEditorToExistingFormat() {
/**
* Tests adding a text editor to a new text format.
*/
function testAddEditorToNewFormat() {
public function testAddEditorToNewFormat() {
$this->enableUnicornEditor();
$this->drupalLogin($this->admin_user);
$this->drupalGet('admin/config/content/formats/add');
......
......@@ -29,7 +29,7 @@ public static function getInfo() {
);
}
function setUp() {
public function setUp() {
parent::setUp();
$this->installSchema('node', array('node', 'node_access', 'node_field_data', 'node_field_revision', 'node_revision'));
$this->installSchema('file', array('file_managed', 'file_usage'));
......@@ -58,7 +58,7 @@ function setUp() {
/**
* Tests the configurable text editor manager.
*/
function testEditorEntityHooks() {
public function testEditorEntityHooks() {
$image = entity_create('file', array());
$image->setFileUri('core/misc/druplicon.png');
$image->setFilename(drupal_basename($image->getFileUri()));
......
......@@ -2,7 +2,7 @@
/**
* @file
* Definition of \Drupal\editor\Tests\EditorLoadingTest.
* Contains \Drupal\editor\Tests\EditorLoadingTest.
*/
namespace Drupal\editor\Tests;
......@@ -29,7 +29,7 @@ public static function getInfo() {
);
}
function setUp() {
public function setUp() {
parent::setUp();
// Add text formats.
......@@ -66,7 +66,7 @@ function setUp() {
/**
* Tests loading of text editors.
*/
function testLoading() {
public function testLoading() {
// Only associate a text editor with the "Full HTML" text format.
$editor = entity_create('editor', array(
'format' => 'full_html',
......@@ -169,4 +169,5 @@ protected function getThingsToCheck() {
$this->xpath('//select[contains(@class, "filter-list")]'),
);
}
}
......@@ -2,7 +2,7 @@
/**
* @file
* Definition of \Drupal\editor\Tests\EditorManagerTest.
* Contains \Drupal\editor\Tests\EditorManagerTest.
*/
namespace Drupal\editor\Tests;
......@@ -10,7 +10,6 @@
use Drupal\simpletest\DrupalUnitTestBase;
use Drupal\editor\Plugin\EditorManager;
/**
* Unit tests for the configurable text editor manager.
*/
......@@ -38,7 +37,7 @@ public static function getInfo() {
);
}
function setUp() {
public function setUp() {
parent::setUp();
// Install the Filter module.
......@@ -65,7 +64,7 @@ function setUp() {
/**
* Tests the configurable text editor manager.
*/
function testManager() {
public function testManager() {
$this->editorManager = $this->container->get('plugin.manager.editor');
// Case 1: no text editor available:
......
......@@ -24,14 +24,14 @@
class UnicornEditor extends EditorBase {
/**
* Implements \Drupal\editor\Plugin\EditPluginInterface::getDefaultSettings().
* {@inheritdoc}
*/
function getDefaultSettings() {
return array('ponies too' => TRUE);
}
/**
* Implements \Drupal\editor\Plugin\EditPluginInterface::settingsForm().
* {@inheritdoc}
*/
function settingsForm(array $form, array &$form_state, EditorEntity $editor) {
$form['foo'] = array(
......@@ -43,7 +43,7 @@ function settingsForm(array $form, array &$form_state, EditorEntity $editor) {
}
/**
* Implements \Drupal\editor\Plugin\EditPluginInterface::getJSSettings().
* {@inheritdoc}
*/
function getJSSettings(EditorEntity $editor) {
$settings = array();
......@@ -54,7 +54,7 @@ function getJSSettings(EditorEntity $editor) {
}
/**
* Implements \Drupal\editor\Plugin\EditPluginInterface::getLibraries().
* {@inheritdoc}
*/
public function getLibraries(EditorEntity $editor) {
return array(
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment