From 467f81a9c64fb22dbf3c131050a019c3c2d7ca19 Mon Sep 17 00:00:00 2001 From: voidtek Date: Thu, 17 Aug 2017 21:15:57 +0200 Subject: [PATCH] #9999: Add QA automatisation with grumphp and resolve all warnings and errors. --- .gitignore | 7 + composer.json | 11 + grumphp.yml.dist | 19 ++ scripts/ec.js | 3 +- scripts/ec_resp.js | 48 ++-- scripts/view-galleries.js | 6 +- scripts/view-medias-block.js | 6 +- template.php | 20 +- ...--easy-breadcrumb--easy-breadcrumb.tpl.php | 13 +- .../blocks/block--locale--language.tpl.php | 5 +- ...eate-button--create-content-button.tpl.php | 1 + ...ite-og-button--og-contextual-links.tpl.php | 1 + .../blocks/block--system--main-menu.tpl.php | 4 +- .../blocks/block--system--user-menu.tpl.php | 3 +- .../block--views--news-top-news.tpl.php | 15 +- .../blocks/block--workbench--block.tpl.php | 9 +- .../blocks/block-admin-display-form.tpl.php | 47 ++-- templates/blocks/block.tpl.php | 21 +- templates/comments/comment-wrapper.tpl.php | 1 + templates/comments/comment.tpl.php | 29 +-- ...xslider-views-slideshow-main-frame.tpl.php | 1 + .../features/om-maximenu-submenu.tpl.php | 42 ++-- .../features/simplenews-multi-block.tpl.php | 9 +- templates/fields/field--image.tpl.php | 7 +- templates/fields/field--registration.tpl.php | 9 +- templates/fields/field--video.tpl.php | 1 + templates/fields/file_entity.tpl.php | 6 +- templates/global/html.tpl.php | 19 +- .../global/maintenance-page--offline.tpl.php | 34 +-- templates/global/maintenance-page.tpl.php | 55 ++--- templates/global/page.tpl.php | 214 +++++++++--------- templates/node/node--gallerymedia.tpl.php | 29 +-- templates/node/node--idea.tpl.php | 33 +-- templates/node/node.tpl.php | 29 +-- templates/search/search-block-form.tpl.php | 13 +- templates/user/user-profile.tpl.php | 31 +-- templates/views/views-freepager.tpl.php | 2 +- templates/views/views-view--galleries.tpl.php | 1 + templates/views/views-view-grid.tpl.php | 84 +++---- templates/views/views-view-table.tpl.php | 35 +-- ...ews-view-unformatted--medias-block.tpl.php | 33 ++- theme-settings.php | 1 + 42 files changed, 505 insertions(+), 452 deletions(-) create mode 100644 .gitignore create mode 100644 composer.json create mode 100644 grumphp.yml.dist diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..45ef948 --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +vendor +composer.lock +grumphp.yml +phpunit.xml +bootstrap +scripts/*.min.js +.idea/ diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..12d1bff --- /dev/null +++ b/composer.json @@ -0,0 +1,11 @@ +{ + "name": "ec-europa/ec_europa", + "description": "EC Europa base theme.", + "git-version": "0.0.3", + "type": "drupal-theme", + "require-dev": { + "phpro/grumphp": "^0.11", + "composer/installers": "~1.0", + "ec-europa/qa-automation": "^3.0" + } +} \ No newline at end of file diff --git a/grumphp.yml.dist b/grumphp.yml.dist new file mode 100644 index 0000000..ba63768 --- /dev/null +++ b/grumphp.yml.dist @@ -0,0 +1,19 @@ +parameters: + git_dir: . + bin_dir: vendor/bin + tasks: + phpcs: + standard: vendor/ec-europa/qa-automation/phpcs/SubStandards/QA + ignore_patterns: + - vendor/ + - scripts/ec.js + triggered_by: + - php + - module + - inc + - js + git_commit_message: + matchers: + - '/^(#\d+|EUTHEME-\d+|NEPT-\d+): [A-Z].+\./' + case_insensitive: false + multiline: false diff --git a/scripts/ec.js b/scripts/ec.js index 4b3e11c..387d0f9 100644 --- a/scripts/ec.js +++ b/scripts/ec.js @@ -2,7 +2,8 @@ * @file * Duplicate of europa script */ -(function($){ + +(function ($) { Drupal.behaviors.ec_resp_test = { attach: function(context, settings) { var translations = { // All translations used in webservice diff --git a/scripts/ec_resp.js b/scripts/ec_resp.js index 90ab0a5..b8866cd 100644 --- a/scripts/ec_resp.js +++ b/scripts/ec_resp.js @@ -3,12 +3,12 @@ * Javascripts for ec_resp theme. */ -(function($){ +(function ($) { // Drupal.behaviours // https://drupal.org/node/304258 // http://blog.amazeelabs.com/en/drupal-behaviors-quick-how Drupal.behaviors.ec_resp = { - attach: function(context, settings) { + attach: function (context, settings) { // Gallery carrousel. $('.carousel').carousel({ @@ -19,7 +19,7 @@ $('[data-toggle="tooltip"]').tooltip(); // Back on top link. - $(window).scroll(function() { + $(window).scroll(function () { if ($(this).scrollTop() > 200) { $('.btn-back-top').fadeIn(200); } @@ -28,7 +28,7 @@ } }); - $('.btn-back-top').on("click", function(e) { + $('.btn-back-top').on("click", function (e) { e.preventDefault(); $('html,body').animate({scrollTop: 0}, 300); $(this).blur(); @@ -36,7 +36,7 @@ }); // Gallery add media form. - $('.node-gallerymedia #add_picture').click(function(e) { + $('.node-gallerymedia #add_picture').click(function (e) { e.preventDefault(); $('#add-media-form').slideToggle('slow'); return false; @@ -49,9 +49,9 @@ // News slider implementation. Drupal.behaviors.ec_resp_news_slider = { - attach: function(context) { + attach: function (context) { // News slider. - $('#slider').once('news-slider', function() { + $('#slider').once('news-slider', function () { // Init. $('.view-news > .view-content').addClass('news_content tab-content'); $('#slider .news_list li:first-child').addClass('active'); @@ -60,14 +60,14 @@ // Browse top news. var topNews = new Array(); var totalHeight = 0; - $('#slider .news_list li a').each(function() { + $('#slider .news_list li a').each(function () { topNews.push($(this)); totalHeight = totalHeight + $(this).height() + 21; }); var NbNews = topNews.length; var i = 1; - var interval = setInterval(function() { + var interval = setInterval(function () { if (i >= NbNews) { i = 0; } @@ -76,10 +76,10 @@ i++; },5000); - $('#slider').mouseover(function() { + $('#slider').mouseover(function () { clearInterval(interval); - }).mouseout(function() { - interval = setInterval(function() { + }).mouseout(function () { + interval = setInterval(function () { if (i >= NbNews) { i = 0; } @@ -89,7 +89,7 @@ },5000); }); - $('#slider .news_list li a').click(function(e) { + $('#slider .news_list li a').click(function (e) { e.preventDefault(); changeNews($(this)); return false; @@ -98,7 +98,7 @@ function changeNews(clicked) { var previous_id = ''; - $('#slider .news_list li a').each(function() { + $('#slider .news_list li a').each(function () { var previous_parent = $(this).parent('li'); if (previous_parent.is('.active')) { previous_parent.removeClass('active'); @@ -118,7 +118,7 @@ // Fancybox implementation. Drupal.behaviors.ec_resp_fancybox = { - attach: function(context) { + attach: function (context) { function stopPlayer() { var id = $('.fancybox-opened').find(".lightbox").children().attr('id'); @@ -143,10 +143,10 @@ title: { type : 'outside' }, buttons: {} }, - beforeClose: function() { + beforeClose: function () { stopPlayer(); }, - beforeLoad: function() { + beforeLoad: function () { stopPlayer(); } }); @@ -155,8 +155,8 @@ // Responsive menu implementation. Drupal.behaviors.ec_resp_responsive_menu = { - attach: function(context) { - $('#menu-button').on("click", function() { + attach: function (context) { + $('#menu-button').on("click", function () { $(this).toggleClass('menu-open'); $('#menu-button > div').toggleClass("arrow-down"); $('#menu-button > div').toggleClass("arrow-up"); @@ -166,13 +166,13 @@ // Responsive sidebar implementation. Drupal.behaviors.ec_resp_responsive_sidebar = { - attach: function(context) { - $('#responsive-sidebar').once('responsive-sidebar', function(){ + attach: function (context) { + $('#responsive-sidebar').once('responsive-sidebar', function () { // Hide the sidebar on load. $('#responsive-sidebar').addClass('reduced').removeClass('expanded'); - $('.sidebar-button').on("click", function() { + $('.sidebar-button').on("click", function () { $('.sidebar-button').toggleClass('sidebar-open'); if ($('#layout-body').is('.reduced')) { @@ -185,7 +185,7 @@ } }); - $(window).resize(function() { + $(window).resize(function () { if ($('#layout-body').is('.reduced')) { hide_sidebar(); } @@ -194,7 +194,7 @@ function hide_sidebar() { // Close responsive sidebars. $('#responsive-sidebar').addClass('reduced').removeClass('expanded'); - $('#layout-body').addClass('expanded').removeClass('reduced').delay(400).promise().done(function(){ + $('#layout-body').addClass('expanded').removeClass('reduced').delay(400).promise().done(function () { // Move left sidebar. $('#responsive-sidebar-left > div').detach().appendTo($('#sidebar-left')); diff --git a/scripts/view-galleries.js b/scripts/view-galleries.js index 81fafcc..6ac71c2 100644 --- a/scripts/view-galleries.js +++ b/scripts/view-galleries.js @@ -3,12 +3,12 @@ * Javascripts for gallery views. */ -(function($){ +(function ($) { Drupal.behaviors.ec_resp_view_galleries = { - attach: function(context) { + attach: function (context) { $row = $('div.galleries-item-wrapper'); // Hide the video thumbnails in galleries with pictur thumbnails. - $row.each(function() { + $row.each(function () { if ($(this).find('a').size() > 1) { $(this).find('a:last').hide(); } diff --git a/scripts/view-medias-block.js b/scripts/view-medias-block.js index 4952051..41b5710 100644 --- a/scripts/view-medias-block.js +++ b/scripts/view-medias-block.js @@ -3,12 +3,12 @@ * Javascripts for media block views. */ -(function($){ +(function ($) { Drupal.behaviors.ec_resp_view_medias_block = { - attach: function(context) { + attach: function (context) { $row = $('div.carousel-inner div.views-row'); // Hide the video thumbnails in galleries with pictur thumbnails. - $row.each(function() { + $row.each(function () { if ($(this).find('a').size() > 2) { $(this).find('a:last').hide(); } diff --git a/template.php b/template.php index 6313cdf..53e5f39 100644 --- a/template.php +++ b/template.php @@ -1,4 +1,5 @@ field_meta_title) && !empty($node->field_meta_title)) { - $title = strip_tags($node->field_meta_title['und'][0]['value']); + $title = strip_tags($node->field_meta_title[LANGUAGE_NONE][0]['value']); } else { $title = strip_tags($node->title); @@ -524,7 +525,7 @@ function ec_resp_page_alter(&$page) { if (!empty($node)) { // If the metatag title exists, it must be used to construct the title page. if (isset($node->field_meta_title) && !empty($node->field_meta_title)) { - $title = filter_xss($node->field_meta_title['und'][0]['value']); + $title = filter_xss($node->field_meta_title[LANGUAGE_NONE][0]['value']); } else { $title = $node_title . ' - ' . $title; @@ -535,7 +536,7 @@ function ec_resp_page_alter(&$page) { if (!empty($node) && !empty($node->field_tags)) { $tags = field_view_field('node', $node, 'field_tags'); if (isset($tags['#items'])) { - foreach ($tags['#items'] as $key => $value) { + foreach ($tags['#items'] as $value) { $keywords .= $value['taxonomy_term']->name . ', '; } } @@ -932,7 +933,7 @@ function ec_resp_menu_link__menu_breadcrumb_menu(array $variables) { // Check CSS classes. $last = FALSE; - foreach ($element['#attributes']['class'] as $key => $class) { + foreach ($element['#attributes']['class'] as $class) { if ($class == 'last') { $last = TRUE; break; @@ -1394,15 +1395,15 @@ function ec_resp_preprocess_block(&$variables) { $languages = language_list(); $items = array(); + $label = t("Current language"); $items[] = array( - 'data' => '' . t("Current language") . ': ' . $language->language, + 'data' => '' . $label . ': ' . $language->language, 'class' => array('selected'), 'title' => $language->native, 'lang' => $language->language, ); // Get path of translated content. $translations = translation_path_get_translations(current_path()); - $language_default = language_default(); foreach ($languages as $language_object) { $prefix = $language_object->language; @@ -1420,7 +1421,6 @@ function ec_resp_preprocess_block(&$variables) { // with suffix url is enabled. $language_negociation = variable_get('language_negotiation_language'); if (isset($language_negociation['locale-url-suffix'])) { - $delimiter = variable_get('language_suffix_delimiter', '_'); $alias = drupal_get_path_alias($path, $prefix); if ($alias == variable_get('site_frontpage', 'node')) { @@ -1618,7 +1618,7 @@ function ec_resp_table($variables) { // Format the table columns: if (count($colgroups)) { - foreach ($colgroups as $number => $colgroup) { + foreach ($colgroups as $colgroup) { $attributes = array(); // Check if we're dealing with a simple or complex column. @@ -1697,7 +1697,7 @@ function ec_resp_table($variables) { 'odd' => 'even', ); $class = 'even'; - foreach ($rows as $number => $row) { + foreach ($rows as $row) { // Check if we're dealing with a simple or complex row. if (isset($row['data'])) { foreach ($row as $key => $value) { @@ -1784,7 +1784,7 @@ function ec_resp_nexteuropa_multilingual_language_list(array $variables) { * @return string * Formatted HTML column displaying the list of provided languages. */ -function _ec_resp_nexteuropa_multilingual_language_list_column($languages, $path, $options) { +function _ec_resp_nexteuropa_multilingual_language_list_column(array $languages, $path, array $options) { $content = '
'; foreach ($languages as $language) { $options['attributes']['lang'] = $language->language; diff --git a/templates/blocks/block--easy-breadcrumb--easy-breadcrumb.tpl.php b/templates/blocks/block--easy-breadcrumb--easy-breadcrumb.tpl.php index 1646961..0bb800c 100644 --- a/templates/blocks/block--easy-breadcrumb--easy-breadcrumb.tpl.php +++ b/templates/blocks/block--easy-breadcrumb--easy-breadcrumb.tpl.php @@ -1,4 +1,5 @@
' . $separator . ' '; - endif; + if ($content): + $separator = variable_get('easy_breadcrumb-segments_separator'); + print ' ' . $separator . ' '; + endif; - print_r($content); + print_r($content); ?>
diff --git a/templates/blocks/block--locale--language.tpl.php b/templates/blocks/block--locale--language.tpl.php index ec0c45e..ac9103d 100644 --- a/templates/blocks/block--locale--language.tpl.php +++ b/templates/blocks/block--locale--language.tpl.php @@ -1,4 +1,5 @@ - diff --git a/templates/blocks/block--multisite-create-button--create-content-button.tpl.php b/templates/blocks/block--multisite-create-button--create-content-button.tpl.php index f93e67d..873942a 100644 --- a/templates/blocks/block--multisite-create-button--create-content-button.tpl.php +++ b/templates/blocks/block--multisite-create-button--create-content-button.tpl.php @@ -1,4 +1,5 @@ -