Skip to content

Commit

Permalink
Feature/thndr 92 (#8)
Browse files Browse the repository at this point in the history
* Added requirements for code style checking

* Applied auto formatting and simple changes
  • Loading branch information
dbosen authored Jul 4, 2016
1 parent 9d080d0 commit 67f98ab
Show file tree
Hide file tree
Showing 16 changed files with 289 additions and 172 deletions.
8 changes: 8 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
core/assets/vendor/**/*
core/modules/locale/tests/locale_test.js
vendor/**/*
sites/**/files/**/*
libraries/**/*
sites/**/libraries/**/*
profiles/**/libraries/**/*
**/js_test_files/**/*
95 changes: 95 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
{
"extends": "eslint:recommended",
"env": {
"browser": true
},
"globals": {
"Drupal": true,
"drupalSettings": true,
"drupalTranslations": true,
"domready": true,
"jQuery": true,
"_": true,
"matchMedia": true,
"Backbone": true,
"Modernizr": true,
"CKEDITOR": true
},
"rules": {
// Errors.
"array-bracket-spacing": [2, "never"],
"block-scoped-var": 2,
"brace-style": [2, "stroustrup", {"allowSingleLine": true}],
"comma-dangle": [2, "never"],
"comma-spacing": 2,
"comma-style": [2, "last"],
"computed-property-spacing": [2, "never"],
"curly": [2, "all"],
"eol-last": 2,
"eqeqeq": [2, "smart"],
"guard-for-in": 2,
"indent": [2, 2, {"SwitchCase": 1}],
"key-spacing": [2, {"beforeColon": false, "afterColon": true}],
"keyword-spacing": [2, {"before": true, "after": true}],
"linebreak-style": [2, "unix"],
"lines-around-comment": [2, {"beforeBlockComment": true, "afterBlockComment": false}],
"new-parens": 2,
"no-array-constructor": 2,
"no-caller": 2,
"no-catch-shadow": 2,
"no-eval": 2,
"no-extend-native": 2,
"no-extra-bind": 2,
"no-extra-parens": [2, "functions"],
"no-implied-eval": 2,
"no-iterator": 2,
"no-label-var": 2,
"no-labels": 2,
"no-lone-blocks": 2,
"no-loop-func": 2,
"no-multi-spaces": 2,
"no-multi-str": 2,
"no-native-reassign": 2,
"no-nested-ternary": 2,
"no-new-func": 2,
"no-new-object": 2,
"no-new-wrappers": 2,
"no-octal-escape": 2,
"no-process-exit": 2,
"no-proto": 2,
"no-return-assign": 2,
"no-script-url": 2,
"no-sequences": 2,
"no-shadow-restricted-names": 2,
"no-spaced-func": 2,
"no-trailing-spaces": 2,
"no-undef-init": 2,
"no-undefined": 2,
"no-unused-expressions": 2,
"no-unused-vars": [2, {"vars": "all", "args": "none"}],
"no-with": 2,
"object-curly-spacing": [2, "never"],
"one-var": [2, "never"],
"quote-props": [2, "consistent-as-needed"],
"quotes": [2, "single", "avoid-escape"],
"semi": [2, "always"],
"semi-spacing": [2, {"before": false, "after": true}],
"space-before-blocks": [2, "always"],
"space-before-function-paren": [2, {"anonymous": "always", "named": "never"}],
"space-in-parens": [2, "never"],
"space-infix-ops": 2,
"space-unary-ops": [2, { "words": true, "nonwords": false }],
"spaced-comment": [2, "always"],
"strict": 2,
"yoda": [2, "never"],
// Warnings.
"max-nested-callbacks": [1, 3],
"valid-jsdoc": [1, {
"prefer": {
"returns": "return",
"property": "prop"
},
"requireReturn": false
}]
}
}
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
.idea/
/.idea
/vendor
/composer.lock
16 changes: 11 additions & 5 deletions ad_integration.install
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
<?php

/**
* update field schema
* @file
* Contains updates.
*/

/**
* Update field schema.
*/
function ad_integration_update_8001() {
$database = \Drupal::database();
Expand All @@ -11,14 +16,14 @@ function ad_integration_update_8001() {
$schema = \Drupal::keyValue('entity.storage_schema.sql')->getAll();
$schema_copy = $schema;
foreach ($schema as $item_name => $item) {
list($entity_type_id, , ) = explode('.', $item_name);
list($entity_type_id, ,) = explode('.', $item_name);
if (!isset($entity_types[$entity_type_id])) {
continue;
}
foreach ($item as $table_name => $table_schema) {
foreach ($table_schema as $schema_key => $schema_data) {
if ($schema_key === 'fields') {
if(isset($schema_data['field_advertising_adsc_mode'])) {
if (isset($schema_data['field_advertising_adsc_mode'])) {
$field_name = 'field_advertising_adsc_keyword';
$field_definition = array(
'type' => 'varchar',
Expand All @@ -27,10 +32,11 @@ function ad_integration_update_8001() {
);
$schema_copy[$item_name][$table_name]['fields'][$field_name] = $field_definition;
if ($database->driver() == 'mysql') {
//$database_schema->addField();
// $database_schema->addField();
try {
$database_schema->addField($table_name, $field_name, $field_definition);
} catch (\Exception $e) {
}
catch (\Exception $e) {

}
}
Expand Down
43 changes: 23 additions & 20 deletions ad_integration.module
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
<?php

/**
* @file
* Contains module hooks.
*/

use Drupal\Core\Cache\Cache;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Form\FormStateInterface;

/**
Expand All @@ -13,16 +17,16 @@ function ad_integration_theme() {
'template' => 'ad-slot-inline',
'variables' => array(
'html_id' => NULL,
'ad_tag' => NULL
'ad_tag' => NULL,
),
),
'ad_slot_iframe' => array(
'template' => 'ad-slot-iframe',
'variables' => array(
'html_id' => NULL,
'ad_tag' => NULL
'ad_tag' => NULL,
),
)
),
);
}

Expand All @@ -33,7 +37,7 @@ function ad_integration_form_node_form_alter(&$form, FormStateInterface $form_st
/* Is there a better way to get the node? */
$entity = $form_state->getBuildInfo()['callback_object']->getEntity();

/**
/*
* Set group of all ad_integration_settings elements
*/
$has_settings = FALSE;
Expand Down Expand Up @@ -72,26 +76,25 @@ function ad_integration_form_taxonomy_term_form_alter(&$form, FormStateInterface
* Implements template_preprocess_html().
*/
function ad_integration_page_attachments(array &$page) {
/**
* @var Drupal\ad_integration\AdIntegration $advertisingService
*/
/* @var Drupal\ad_integration\AdIntegration $advertisingService */
$advertisingService = \Drupal::service('ad_integration');
$ad_provider = $advertisingService->getAdProvider();
$page['#cache']['tags'] = Cache::mergeTags(isset($page['#cache']['tags']) ? $page['#cache']['tags'] : [], $advertisingService->getCacheTags());
$page['#attached']['html_head'][] = [
[
'#tag' => 'script',
'#attributes' => [
'src' => '/' . drupal_get_path('module', 'ad_integration') . '/js/adHelper.js'
'src' => '/' . drupal_get_path('module', 'ad_integration') . '/js/adHelper.js',
],
],
'ad_helper'
'ad_helper',
];

switch ($ad_provider) {
case 'fag':
_attach_fag($page, $advertisingService);
break;

case 'orbyd':
_attach_orbyd($page, $advertisingService);
break;
Expand All @@ -108,7 +111,7 @@ function _attach_orbyd(array &$page, $advertisingService) {
[
'#tag' => 'script',
'#attributes' => [
'type' => 'text/javascript'
'type' => 'text/javascript',
],
'#value' => "var adunit1 = '" . $advertisingService->getAdUnit1() . "';
var adunit2 = '" . $advertisingService->getAdUnit2() . "';
Expand All @@ -118,7 +121,7 @@ function _attach_orbyd(array &$page, $advertisingService) {
var admobile = deviceIsMobile().toString();
var addevice = getDeviceType();",
],
'advertising_config'
'advertising_config',
];
$adengine = $advertisingService->getAdEngine();
if ($adengine) {
Expand All @@ -127,10 +130,10 @@ function _attach_orbyd(array &$page, $advertisingService) {
'#tag' => 'script',
'#attributes' => [
'src' => $adengine,
'type' => 'text/javascript'
'type' => 'text/javascript',
],
],
'ad_orbyd_head'
'ad_orbyd_head',
];
}
}
Expand All @@ -145,7 +148,7 @@ function _attach_fag(array &$page, $advertisingService) {
[
'#tag' => 'script',
'#attributes' => [
'type' => 'text/javascript'
'type' => 'text/javascript',
],
'#value' => "var adsc_adunit1 = '" . $advertisingService->getAdUnit1() . "';
var adsc_adunit2 = '" . $advertisingService->getAdUnit2() . "';
Expand All @@ -155,26 +158,26 @@ function _attach_fag(array &$page, $advertisingService) {
var adsc_mobile = deviceIsMobile().toString();
var adsc_device = getDeviceType();",
],
'advertising_config'
'advertising_config',
];

$page['#attached']['html_head'][] = [
[
'#tag' => 'script',
'#attributes' => [
'src' => $advertisingService->getAdContainerTag()
'src' => $advertisingService->getAdContainerTag(),
],
],
'container_tag'
'container_tag',
];
$page['#attached']['html_head'][] = [
[
'#tag' => 'script',
'#attributes' => [
'src' => $advertisingService->getAdEngine()
'src' => $advertisingService->getAdEngine(),
],
],
'ad_engine'
'ad_engine',
];
$page['#attached']['library'][] = 'ad_integration/id_integration';
return $page;
Expand Down
Loading

0 comments on commit 67f98ab

Please sign in to comment.