Skip to content
Snippets Groups Projects
Commit 673180bd authored by Indra Patil's avatar Indra Patil Committed by Nikolay Lobachev
Browse files

Issue #2951400 by LOBsTerr: Found coding standard issues in superfish

parent 08142b5c
No related branches found
No related tags found
No related merge requests found
CONTENTS OF THIS FILE
###CONTENTS OF THIS FILE
---------------------
* Introduction
* Requirements
* Recommended Modules
* Installation
* Configuration
* Maintainers
- Introduction
- Requirements
- Recommended Modules
- Installation
- Configuration
- Maintainers
INTRODUCTION
###INTRODUCTION
------------
This module allows for integration of jQuery Superfish plug-in with Drupal CMS.
* For a full description of the module, visit the project page:
- For a full description of the module, visit the project page:
https://www.drupal.org/project/superfish
* To submit bug reports and feature suggestions, or to track changes:
- To submit bug reports and feature suggestions, or to track changes:
https://www.drupal.org/project/issues/superfish
REQUIREMENTS
###REQUIREMENTS
------------
This module requires the following outside of Drupal core:
* Superfish library - https://github.com/mehrpadin/Superfish-for-Drupal/
- Superfish library - https://github.com/mehrpadin/Superfish-for-Drupal/
RECOMMENDED MODULES
###RECOMMENDED MODULES
-------------------
* Libraries API - https://www.drupal.org/project/libraries
* jQuery Easing plugin - https://www.drupal.org/project/jqeasing
- Libraries API - https://www.drupal.org/project/libraries
- jQuery Easing plugin - https://www.drupal.org/project/jqeasing
INSTALLATION
###INSTALLATION
------------
* Install the Superfish module as you would normally install a contributed
- Install the Superfish module as you would normally install a contributed
Drupal module. Visit
https://www.drupal.org/node/1897420 for further information.
CONFIGURATION
###CONFIGURATION
-------------
1. Navigate to Administration > Extend and enable the module.
......@@ -63,9 +63,9 @@ How to style:
4. You are now ready to unleash your CSS artistry :)
Some design tips:
* Utilize a DOM inspector (such as Firefox Developer Tools) for temporarily
- Utilize a DOM inspector (such as Firefox Developer Tools) for temporarily
modifying live code in real time.
* Set the Mouse delay of the block settings to 99999999 so the sub-menus will
- Set the Mouse delay of the block settings to 99999999 so the sub-menus will
stay open for a longer time giving you more time to work with them in the
DOM inspector etc.
Useful links:
......@@ -73,7 +73,7 @@ Some design tips:
https://www.drupal.org/node/147789#web-browser-tools
MAINTAINERS
### MAINTAINERS
-----------
* mehrpadin - https://www.drupal.org/u/mehrpadin
- Nikolay Lobachev - https://www.drupal.org/u/lobsterr
......@@ -8,6 +8,16 @@
"name": "mehrpadin",
"homepage": "https://www.drupal.org/u/mehrpadin",
"role": "Maintainer"
},
{
"name": "Nikolay Lobachev",
"homepage": "https://www.drupal.org/u/lobsterr",
"role": "Maintainer"
},
{
"name": "Nick Dickinson-Wilde",
"homepage": "https://www.drupal.org/u/nickdickinsonwilde",
"role": "Maintainer"
}
],
"support": {
......
......@@ -2,12 +2,12 @@
namespace Drupal\superfish\Plugin\Block;
use Drupal\system\Plugin\Block\SystemMenuBlock;
use Drupal\Core\Menu\MenuTreeParameters;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Component\Utility\Html;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Menu\MenuActiveTrailInterface;
use Drupal\Core\Menu\MenuLinkTreeInterface;
use Drupal\Core\Menu\MenuTreeParameters;
use Drupal\system\Plugin\Block\SystemMenuBlock;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
......@@ -67,7 +67,6 @@ class SuperfishBlock extends SystemMenuBlock {
*/
public function blockForm($form, FormStateInterface $form_state) {
$form = parent::blockForm($form, $form_state);
$defaults = $this->defaultConfiguration();
$form['sf'] = [
'#type' => 'details',
'#title' => $this->t('Block settings'),
......@@ -833,41 +832,41 @@ class SuperfishBlock extends SystemMenuBlock {
]);
if (!is_numeric($speed) && !in_array($speed, ['slow', 'normal', 'fast'])) {
$form_state->setErrorByName('superfish_speed', t('Unacceptable value entered for the "Animation speed" option.'));
$form_state->setErrorByName('superfish_speed', $this->t('Unacceptable value entered for the "Animation speed" option.'));
}
if (!is_numeric($delay)) {
$form_state->setErrorByName('superfish_delay', t('Unacceptable value entered for the "Mouse delay" option.'));
$form_state->setErrorByName('superfish_delay', $this->t('Unacceptable value entered for the "Mouse delay" option.'));
}
if ($touch == 2 && $touchbp == '') {
$form_state->setErrorByName('superfish_touchbp', t('"sfTouchscreen Breakpoint" option cannot be empty.'));
$form_state->setErrorByName('superfish_touchbp', $this->t('"sfTouchscreen Breakpoint" option cannot be empty.'));
}
if (!is_numeric($touchbp)) {
$form_state->setErrorByName('superfish_touchbp', t('Unacceptable value enterd for the "sfTouchscreen Breakpoint" option.'));
$form_state->setErrorByName('superfish_touchbp', $this->t('Unacceptable value enterd for the "sfTouchscreen Breakpoint" option.'));
}
if ($touch == 3 && $touchua == 1 && $touchual == '') {
$form_state->setErrorByName('superfish_touchual', t('List of the touch-screen user agents cannot be empty.'));
$form_state->setErrorByName('superfish_touchual', $this->t('List of the touch-screen user agents cannot be empty.'));
}
if ($small == 2 && $smallbp == '') {
$form_state->setErrorByName('superfish_smallbp', t('"sfSmallscreen Breakpoint" option cannot be empty.'));
$form_state->setErrorByName('superfish_smallbp', $this->t('"sfSmallscreen Breakpoint" option cannot be empty.'));
}
if (!is_numeric($smallbp)) {
$form_state->setErrorByName('superfish_smallbp', t('Unacceptable value entered for the "sfSmallscreen Breakpoint" option.'));
$form_state->setErrorByName('superfish_smallbp', $this->t('Unacceptable value entered for the "sfSmallscreen Breakpoint" option.'));
}
if ($small == 3 && $smallua == 1 && $smallual == '') {
$form_state->setErrorByName('superfish_smallual', t('List of the small-screen user agents cannot be empty.'));
$form_state->setErrorByName('superfish_smallual', $this->t('List of the small-screen user agents cannot be empty.'));
}
$supersubs_error = FALSE;
if (!is_numeric($minwidth)) {
$form_state->setErrorByName('superfish_minwidth', t('Unacceptable value entered for the "Supersubs minimum width" option.'));
$form_state->setErrorByName('superfish_minwidth', $this->t('Unacceptable value entered for the "Supersubs minimum width" option.'));
$supersubs_error = TRUE;
}
if (!is_numeric($maxwidth)) {
$form_state->setErrorByName('superfish_maxwidth', t('Unacceptable value entered for the "Supersubs maximum width" option.'));
$form_state->setErrorByName('superfish_maxwidth', $this->t('Unacceptable value entered for the "Supersubs maximum width" option.'));
$supersubs_error = TRUE;
}
if ($supersubs_error !== TRUE && $minwidth > $maxwidth) {
$form_state->setErrorByName('superfish_maxwidth', t('Supersubs "maximum width" has to be bigger than the "minimum width".'));
$form_state->setErrorByName('superfish_maxwidth', $this->t('Supersubs "maximum width" has to be bigger than the "minimum width".'));
}
}
......
......@@ -2,5 +2,4 @@ name: 'Superfish'
type: module
description: 'Adds jQuery Superfish plugin to menu blocks.'
package: User interface
core: 8.x
core_version_requirement: ^8 || ^9 || ^10
......@@ -14,7 +14,10 @@ function superfish_install() {
$messenger->addMessage(t('In order to use Superfish, go to the <a href="@block">Block layout</a> page and use any of the "Place block" buttons to create a Superfish block.', ['@block' => 'structure/block']));
}
else {
$messenger->addWarning(t('Superfish library is missing. Please refer to the <a href="@documentation">plugin documentation</a> for how you can fix this issue; Once done, go to the <a href="@block">Block layout</a> page and use any of the "Place block" buttons to create a Superfish block.', ['@documentation' => 'https://www.drupal.org/node/1125896', '@block' => 'structure/block']));
$messenger->addWarning(t('Superfish library is missing. Please refer to the <a href="@documentation">plugin documentation</a> for how you can fix this issue; Once done, go to the <a href="@block">Block layout</a> page and use any of the "Place block" buttons to create a Superfish block.', [
'@documentation' => 'https://www.drupal.org/node/1125896',
'@block' => 'structure/block',
]));
}
$messenger->addMessage(t('If there was no Superfish block in the "Place block" form, go to the <a href="@performance">Performance</a> page and clear the cache once.', ['@performance' => 'config/development/performance']));
}
......@@ -24,40 +27,42 @@ function superfish_install() {
*/
function superfish_requirements($phase) {
$requirements = [];
if ($phase == 'runtime') {
$requirements['superfish']['title'] = t('Superfish library');
if ($phase !== 'runtime') {
return $requirements;
}
$requirements['superfish']['title'] = t('Superfish library');
if (superfish_library_check()) {
// Check the uploaded Superfish library version.
$version = superfish_library_version();
if (is_null($version)) {
$requirements['superfish']['value'] = t('Inaccessible');
if (superfish_library_check()) {
// Check the uploaded Superfish library version.
$version = superfish_library_version();
if (is_null($version)) {
$requirements['superfish']['value'] = t('Inaccessible');
$requirements['superfish']['severity'] = REQUIREMENT_ERROR;
$requirements['superfish']['description'] = t('Cannot access the Superfish library directory; perhaps because its permissions and/or ownership are not set up correctly.');
}
else {
$version = (integer) $version;
if (!$version || !is_numeric($version)) {
$requirements['superfish']['value'] = t('Unknown version');
$requirements['superfish']['severity'] = REQUIREMENT_ERROR;
$requirements['superfish']['description'] = t('Cannot access the Superfish library directory; perhaps because its permissions and/or ownership are not set up correctly.');
$requirements['superfish']['description'] = t('Cannot determine the version of your Superfish library.');
}
elseif (version_compare($version, 2, '<')) {
$requirements['superfish']['value'] = t('Not supported');
$requirements['superfish']['severity'] = REQUIREMENT_ERROR;
$requirements['superfish']['description'] = t('The Superfish library requires an update. You can find the update instructions on :url.', [':url' => 'https://www.drupal.org/project/superfish']);
}
else {
$version = (integer) $version;
if (!$version || !is_numeric($version)) {
$requirements['superfish']['value'] = t('Unknown version');
$requirements['superfish']['severity'] = REQUIREMENT_ERROR;
$requirements['superfish']['description'] = t('Cannot determine the version of your Superfish library.');
}
elseif (version_compare($version, 2, '<')) {
$requirements['superfish']['value'] = t('Not supported');
$requirements['superfish']['severity'] = REQUIREMENT_ERROR;
$requirements['superfish']['description'] = t('The Superfish library requires an update. You can find the update instructions on :url.', [':url' => 'https://www.drupal.org/project/superfish']);
}
else {
$requirements['superfish']['value'] = t('Installed; at @location', ['@location' => superfish_library_path()]);
$requirements['superfish']['severity'] = REQUIREMENT_OK;
}
$requirements['superfish']['value'] = t('Installed; at @location', ['@location' => superfish_library_path()]);
$requirements['superfish']['severity'] = REQUIREMENT_OK;
}
}
else {
$requirements['superfish']['value'] = t('Not installed');
$requirements['superfish']['severity'] = REQUIREMENT_ERROR;
$requirements['superfish']['description'] = t('Please download the Superfish library from :url.', [':url' => 'https://www.drupal.org/project/superfish']);
}
}
else {
$requirements['superfish']['value'] = t('Not installed');
$requirements['superfish']['severity'] = REQUIREMENT_ERROR;
$requirements['superfish']['description'] = t('Please download the Superfish library from :url.', [':url' => 'https://www.drupal.org/project/superfish']);
}
return $requirements;
}
......@@ -229,8 +229,8 @@ function superfish_library_path($library = 'superfish') {
elseif (file_exists('sites/default/libraries/' . $library)) {
$directory = 'sites/default/libraries/' . $library;
}
if (!$directory && ucfirst($library) !== $library) {
$directory = superfish_library_path(ucfirst($library));
if (!$directory && Unicode::ucfirst($library) !== $library) {
$directory = superfish_library_path(Unicode::ucfirst($library));
}
return $directory;
}
......
......@@ -5,12 +5,12 @@
* Preprocessors and theme functions of the Superfish module.
*/
use Drupal\Core\Url;
use Drupal\Core\Menu\InaccessibleMenuLink;
use Drupal\Core\Language\LanguageInterface;
use Drupal\Component\Utility\Html;
use Drupal\Component\Render\FormattableMarkup;
use Drupal\Component\Utility\Html;
use Drupal\Core\Language\LanguageInterface;
use Drupal\Core\Menu\InaccessibleMenuLink;
use Drupal\Core\Template\Attribute;
use Drupal\Core\Url;
/**
* Prepares variables for the Superfish menu template.
......@@ -85,7 +85,6 @@ function template_preprocess_superfish_menu_items(array &$variables) {
// Keep $sfsettings untouched as we need to pass it to the child menus.
$settings = $sfsettings = $element['#settings'];
$multicolumn = $multicolumn_below = $settings['multicolumn'];
$variables['menu_items'] = [];
......@@ -213,25 +212,10 @@ function template_preprocess_superfish_menu_items(array &$variables) {
// Multi-column sub-menus.
if ($settings['multicolumn']) {
if ($item['depth'] == $settings['multicolumn_depth']) {
$multicolumn_wrapper = TRUE;
}
else {
$multicolumn_wrapper = FALSE;
}
if ($item['depth'] == $settings['multicolumn_depth'] + 1) {
$multicolumn_column = TRUE;
}
else {
$multicolumn_column = FALSE;
}
if ($item['depth'] >= $settings['multicolumn_depth'] &&
$item['depth'] <= $settings['multicolumn_levels']) {
$multicolumn_content = TRUE;
}
else {
$multicolumn_content = FALSE;
}
$multicolumn_wrapper = $item['depth'] == $settings['multicolumn_depth'];
$multicolumn_column = $item['depth'] == $settings['multicolumn_depth'] + 1;
$multicolumn_content = $item['depth'] >= $settings['multicolumn_depth'] &&
$item['depth'] <= $settings['multicolumn_levels'];
}
// sfTouchscreen.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment