Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NEPT-1456: Add QA automatisation with grumphp and resolve all warnings and errors. #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
vendor
composer.lock
grumphp.yml
phpunit.xml
bootstrap
scripts/*.min.js
.idea/
11 changes: 11 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
19 changes: 19 additions & 0 deletions grumphp.yml.dist
Original file line number Diff line number Diff line change
@@ -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
3 changes: 2 additions & 1 deletion scripts/ec.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 24 additions & 24 deletions scripts/ec_resp.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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);
}
Expand All @@ -28,15 +28,15 @@
}
});

$('.btn-back-top').on("click", function(e) {
$('.btn-back-top').on("click", function (e) {
e.preventDefault();
$('html,body').animate({scrollTop: 0}, 300);
$(this).blur();
return false;
});

// 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;
Expand All @@ -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');
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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;
Expand All @@ -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');
Expand All @@ -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');
Expand All @@ -143,10 +143,10 @@
title: { type : 'outside' },
buttons: {}
},
beforeClose: function() {
beforeClose: function () {
stopPlayer();
},
beforeLoad: function() {
beforeLoad: function () {
stopPlayer();
}
});
Expand All @@ -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");
Expand All @@ -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')) {
Expand All @@ -185,7 +185,7 @@
}
});

$(window).resize(function() {
$(window).resize(function () {
if ($('#layout-body').is('.reduced')) {
hide_sidebar();
}
Expand All @@ -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'));

Expand Down
6 changes: 3 additions & 3 deletions scripts/view-galleries.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
6 changes: 3 additions & 3 deletions scripts/view-medias-block.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
20 changes: 10 additions & 10 deletions template.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* @file
* Default theme functions.
Expand Down Expand Up @@ -314,7 +315,7 @@ function ec_resp_preprocess_html(&$variables) {
// If the metatag title exists, it must be used
// to construct the title page.
if ($node && isset($node->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);
Expand Down Expand Up @@ -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;
Expand All @@ -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 . ', ';
}
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -1394,15 +1395,15 @@ function ec_resp_preprocess_block(&$variables) {
$languages = language_list();

$items = array();
$label = t("Current language");
$items[] = array(
'data' => '<span class="off-screen">' . t("Current language") . ':</span> ' . $language->language,
'data' => '<span class="off-screen">' . $label . ':</span> ' . $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;
Expand All @@ -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')) {
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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 = '<div class="col-sm-6">';
foreach ($languages as $language) {
$options['attributes']['lang'] = $language->language;
Expand Down
13 changes: 7 additions & 6 deletions templates/blocks/block--easy-breadcrumb--easy-breadcrumb.tpl.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* @file
* Default theme implementation to display a block.
Expand Down Expand Up @@ -46,14 +47,14 @@
<div id="path" class="hidden-xs">
<div class="container">
<?php
print drupal_render($menu_breadcrumb);
print drupal_render($menu_breadcrumb);

if ($content):
$separator = variable_get('easy_breadcrumb-segments_separator');
print '<span class="easy-breadcrumb_segment-separator"> ' . $separator . ' </span>';
endif;
if ($content):
$separator = variable_get('easy_breadcrumb-segments_separator');
print '<span class="easy-breadcrumb_segment-separator"> ' . $separator . ' </span>';
endif;

print_r($content);
print_r($content);
?>
</div>
</div>
5 changes: 3 additions & 2 deletions templates/blocks/block--locale--language.tpl.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* @file
* Default theme implementation to display a block.
Expand Down Expand Up @@ -43,6 +44,6 @@
* @ingroup themeable
*/
?>
<ul class="reset-list language-selector" id="language-selector">
<ul class="reset-list language-selector" id="language-selector">
<?php print $language_list; ?>
</ul>
</ul>
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* @file
* Default theme implementation to display a block.
Expand Down
Loading