reinstalled all contribs with composer
need to run : drush ev 'drupal_flush_all_caches();' drush cr and restart nginx and php-fpm before loading the website
This commit is contained in:
@@ -0,0 +1 @@
|
||||
node_modules
|
||||
@@ -0,0 +1,14 @@
|
||||
# @Author: Bachir Soussi Chiadmi <bach>
|
||||
# @Date: 13-12-2017
|
||||
# @Email: bachir@figureslibres.io
|
||||
# @Filename: edlp_admin.info.yml
|
||||
# @Last modified by: bach
|
||||
# @Last modified time: 20-12-2017
|
||||
# @License: GPL-V3
|
||||
|
||||
|
||||
name: Edlp Admin
|
||||
type: module
|
||||
description: Admin helpers for edlp d8.
|
||||
core: 8.x
|
||||
package: Edlp
|
||||
@@ -0,0 +1,56 @@
|
||||
edlp_admin.add_enregistrement:
|
||||
route_name: 'node.add'
|
||||
route_parameters:
|
||||
node_type: 'enregistrement'
|
||||
title: 'New Document'
|
||||
appears_on:
|
||||
- view.content.page_2
|
||||
edlp_admin.add_fil:
|
||||
route_name: 'node.add'
|
||||
route_parameters:
|
||||
node_type: 'fil'
|
||||
title: 'New Fil'
|
||||
appears_on:
|
||||
- view.content.page_4
|
||||
edlp_admin.add_page:
|
||||
route_name: 'node.add'
|
||||
route_parameters:
|
||||
node_type: 'page'
|
||||
title: 'New Page'
|
||||
appears_on:
|
||||
- view.content.page_1
|
||||
edlp_admin.edit_prod_menu:
|
||||
route_name: 'entity.menu.edit_form'
|
||||
route_parameters:
|
||||
menu: 'productions'
|
||||
title: 'Edit Production Menu'
|
||||
appears_on:
|
||||
- view.content.page_1
|
||||
edlp_admin.add_evenement:
|
||||
route_name: 'node.add'
|
||||
route_parameters:
|
||||
node_type: 'evenement'
|
||||
title: 'New Événement'
|
||||
appears_on:
|
||||
- view.content.page_3
|
||||
edlp_admin.add_entry:
|
||||
route_name: 'entity.taxonomy_term.add_form'
|
||||
route_parameters:
|
||||
taxonomy_vocabulary: 'entrees'
|
||||
title: 'New Entry'
|
||||
appears_on:
|
||||
- view.entree_s_.page_1
|
||||
edlp_admin.add_genre:
|
||||
route_name: 'entity.taxonomy_term.add_form'
|
||||
route_parameters:
|
||||
taxonomy_vocabulary: 'genres'
|
||||
title: 'New Genre'
|
||||
appears_on:
|
||||
- view.entree_s_.page_2
|
||||
edlp_admin.add_langue:
|
||||
route_name: 'entity.taxonomy_term.add_form'
|
||||
route_parameters:
|
||||
taxonomy_vocabulary: 'langues'
|
||||
title: 'New Langue'
|
||||
appears_on:
|
||||
- view.entree_s_.page_3
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
# @Author: Bachir Soussi Chiadmi <bach>
|
||||
# @Date: 13-12-2017
|
||||
# @Email: bachir@figureslibres.io
|
||||
# @Filename: edlp_admin.module
|
||||
# @Last modified by: bach
|
||||
# @Last modified time: 20-12-2017
|
||||
# @License: GPL-V3
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\edlp_admin\Plugin\Filter;
|
||||
|
||||
use Drupal\Component\Utility\Html;
|
||||
// use Drupal\Component\Utility\Unicode;
|
||||
// use Drupal\Component\Utility\Xss;
|
||||
use Drupal\filter\FilterProcessResult;
|
||||
use Drupal\filter\Plugin\FilterBase;
|
||||
// use Drupal\Core\Url;
|
||||
// use Drupal\Core\Template\Attribute;
|
||||
|
||||
/**
|
||||
* Provides a filter to convert audio links.
|
||||
*
|
||||
* @Filter(
|
||||
* id = "css",
|
||||
* title = @Translation("Css remove filter"),
|
||||
* description = @Translation("Remove all style attributes"),
|
||||
* type = Drupal\filter\Plugin\FilterInterface::TYPE_TRANSFORM_REVERSIBLE
|
||||
* )
|
||||
*/
|
||||
class CssFilter extends FilterBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function process($text, $langcode) {
|
||||
$result = new FilterProcessResult($text);
|
||||
|
||||
$cleaned_text = preg_replace('/style="[^"]*"/i', '', $text);
|
||||
|
||||
$result->setProcessedText($cleaned_text);
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
# @Author: Bachir Soussi Chiadmi <bach>
|
||||
# @Date: 13-12-2017
|
||||
# @Email: bachir@figureslibres.io
|
||||
# @Filename: edlp_corpus.routing.yml
|
||||
# @Last modified by: bach
|
||||
# @Last modified time: 20-12-2017
|
||||
# @License: GPL-V3
|
||||
|
||||
|
||||
name: Edlp Agenda
|
||||
type: module
|
||||
description: Manage agenda for edlp d8.
|
||||
core: 8.x
|
||||
package: Edlp
|
||||
# dependencies:
|
||||
# - migrate_drupal
|
||||
# - migrate_plus
|
||||
# - migrate_tools
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
# @Author: Bachir Soussi Chiadmi <bach>
|
||||
# @Date: 13-12-2017
|
||||
# @Email: bachir@figureslibres.io
|
||||
# @Filename: edlp_corpus.routing.yml
|
||||
# @Last modified by: bach
|
||||
# @Last modified time: 20-12-2017
|
||||
# @License: GPL-V3
|
||||
|
||||
/**
|
||||
* Implements hook_theme().
|
||||
*/
|
||||
function edlp_agenda_theme($existing, $type, $theme, $path) {
|
||||
// @see https://www.drupal.org/docs/8/theming/twig/create-custom-twig-templates-from-custom-module
|
||||
return array(
|
||||
'edlp_agenda' => array(
|
||||
// 'render element' => '',
|
||||
'file' => 'includes/edlp_agenda.inc',
|
||||
'variables' => array(
|
||||
'next_event_node' => NULL,
|
||||
'coming_events_nodes' => NULL,
|
||||
'past_events_nodes' => NULL
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
# @Author: Bachir Soussi Chiadmi <bach>
|
||||
# @Date: 13-12-2017
|
||||
# @Email: bachir@figureslibres.io
|
||||
# @Filename: edlp_corpus.routing.yml
|
||||
# @Last modified by: bach
|
||||
# @Last modified time: 20-12-2017
|
||||
# @License: GPL-V3
|
||||
|
||||
edlp_agenda.agenda:
|
||||
path: '/agenda'
|
||||
defaults:
|
||||
_controller: '\Drupal\edlp_agenda\Controller\AgendaController::agenda'
|
||||
_title: 'Agenda'
|
||||
requirements:
|
||||
_permission: 'access content'
|
||||
|
||||
edlp_agenda.agendaajax:
|
||||
path: '/agenda/ajax'
|
||||
defaults:
|
||||
_controller: '\Drupal\edlp_agenda\Controller\AgendaController::agendajson'
|
||||
_title: 'Agenda'
|
||||
requirements:
|
||||
_permission: 'access content'
|
||||
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
// use Drupal\Core\Url;
|
||||
|
||||
function template_preprocess_edlp_agenda(&$vars){
|
||||
// dpm($vars);
|
||||
/*
|
||||
@see https://www.drupal8.ovh/index.php/en/tutoriels/339/render-a-node-or-an-entity
|
||||
*/
|
||||
$view_builder = \Drupal::entityTypeManager()->getViewBuilder('node');
|
||||
|
||||
// if(isset($vars['next_event_node'])){
|
||||
// $vars['next_event'] = array(
|
||||
// "#markup"=>"<h3>Prochaine Date</h3>",
|
||||
// "event"=>$view_builder->view($vars['next_event_node'], 'default')
|
||||
// );
|
||||
// }
|
||||
|
||||
if(count($vars['coming_events_nodes'])){
|
||||
$future_list = array (
|
||||
'#theme' => 'item_list',
|
||||
'#items' => [],
|
||||
);
|
||||
foreach($vars['coming_events_nodes'] as $node){
|
||||
$future_list['#items'][] = $view_builder->view($node, 'teaser');
|
||||
}
|
||||
|
||||
$vars['coming_events'] = array(
|
||||
"#type"=>"container",
|
||||
"#attributes"=>array(
|
||||
"class"=>['future-events']
|
||||
),
|
||||
"#markup"=>"<h3>".t("Upcoming Events")."</h3>",
|
||||
"future_events"=>$future_list
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
$past_list = array (
|
||||
'#theme' => 'item_list',
|
||||
'#items' => [],
|
||||
);
|
||||
foreach($vars['past_events_nodes'] as $node){
|
||||
$past_list['#items'][] = $view_builder->view($node, 'teaser');
|
||||
}
|
||||
|
||||
$vars['past_events'] = array(
|
||||
"#type"=>"container",
|
||||
"#attributes"=>array(
|
||||
"class"=>['past-events']
|
||||
),
|
||||
"#markup"=>"<h3>".t("Past Events")."</h3>",
|
||||
"past_events"=>$past_list
|
||||
);
|
||||
|
||||
// return array(
|
||||
// "#type" => "container",
|
||||
// "#attributes"=>array(
|
||||
// "id"=>['agenda']
|
||||
// ),
|
||||
// "future_past"=>array(
|
||||
// "#type"=>"container",
|
||||
// "#attributes"=>array(
|
||||
// "class"=>['future-past-events', 'column', 'os-scroll']
|
||||
// ),
|
||||
// "future"=>,
|
||||
// "past"=>
|
||||
// )
|
||||
// );
|
||||
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\edlp_agenda\Controller;
|
||||
|
||||
use Drupal\Core\Controller\ControllerBase;
|
||||
use Drupal\Core\Datetime\DrupalDateTime;
|
||||
use Drupal\Core\Url;
|
||||
use Drupal\Core\Language\LanguageInterface;
|
||||
// use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Drupal\Core\Cache\CacheableJsonResponse;
|
||||
use Drupal\Core\Cache\CacheableMetadata;
|
||||
use Drupal\core\render\RenderContext;
|
||||
|
||||
class AgendaController extends ControllerBase {
|
||||
|
||||
|
||||
private function query() {
|
||||
// @see https://www.webomelette.com/query-entities-using-dates-drupal-8
|
||||
|
||||
$now = new DrupalDateTime('now');
|
||||
$now->setTimezone(new \DateTimeZone(DATETIME_STORAGE_TIMEZONE));
|
||||
|
||||
$query = \Drupal::entityQuery('node')
|
||||
->condition('status', 1)
|
||||
->condition('type', 'evenement')
|
||||
->condition('field_date', $now->format(DATETIME_DATETIME_STORAGE_FORMAT), '>=')
|
||||
->sort('field_date');
|
||||
|
||||
$this->future_nids = $query->execute();
|
||||
$this->future_nodes = entity_load_multiple('node', $this->future_nids);
|
||||
|
||||
// $this->next_event_node = array_shift($this->future_nodes);
|
||||
|
||||
$query = \Drupal::entityQuery('node')
|
||||
->condition('status', 1)
|
||||
->condition('type', 'evenement')
|
||||
->condition('field_date', $now->format(DATETIME_DATETIME_STORAGE_FORMAT), '<')
|
||||
->sort('field_date', 'DESC');
|
||||
|
||||
$this->past_nids = $query->execute();
|
||||
$this->past_nodes = entity_load_multiple('node', $this->past_nids);
|
||||
}
|
||||
|
||||
private function toRenderable(){
|
||||
$this->query();
|
||||
// dpm($this->next_event_node);
|
||||
|
||||
return array(
|
||||
"#theme"=>'edlp_agenda',
|
||||
// '#next_event_node' => $this->next_event_node,
|
||||
"#coming_events_nodes" => $this->future_nodes,
|
||||
"#past_events_nodes" => $this->past_nodes,
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Display agenda as a page.
|
||||
*
|
||||
* @return renderable array
|
||||
*/
|
||||
public function agenda() {
|
||||
return $this->toRenderable();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get agenda data as json through ajax.
|
||||
*
|
||||
* @return json
|
||||
*/
|
||||
public function agendajson() {
|
||||
|
||||
$renderable = $this->toRenderable();
|
||||
// $rendered = render($renderable);
|
||||
// We can't render directly the entity as it throw an exception with cachable data
|
||||
//http://blog.dcycle.com/blog/2018-01-24/caching-drupal-8-rest-resource/#the-dreaded-leaked-metadata-error
|
||||
$rendered = \Drupal::service('renderer')->executeInRenderContext(new RenderContext(), function () use ($renderable) {
|
||||
return render($renderable);
|
||||
});
|
||||
|
||||
$data = [
|
||||
'rendered'=> $rendered,
|
||||
'title'=>'Agenda',
|
||||
];
|
||||
|
||||
// translations links
|
||||
// use Drupal\Core\Url;
|
||||
// use Drupal\Core\Language\LanguageInterface;
|
||||
$route_name = 'edlp_agenda.agenda';
|
||||
$links = \Drupal::languageManager()->getLanguageSwitchLinks(LanguageInterface::TYPE_URL, Url::fromRoute($route_name));
|
||||
if (isset($links->links)) {
|
||||
$translations_build = [
|
||||
'#theme' => 'links__language_block',
|
||||
'#links' => $links->links,
|
||||
'#attributes' => ['class' => ["language-switcher-{$links->method_id}",],],
|
||||
'#set_active_class' => TRUE,
|
||||
];
|
||||
$translations_rendered = \Drupal::service('renderer')->executeInRenderContext(new RenderContext(), function () use ($translations_build) {return render($translations_build);});
|
||||
|
||||
$data['translations_links'] = $translations_rendered;
|
||||
}
|
||||
|
||||
$data['#cache'] = [
|
||||
'max-age' => \Drupal\Core\Cache\Cache::PERMANENT,
|
||||
'tags' => ['edlp-agenda-cache'],
|
||||
'contexts' => [
|
||||
'languages:language_content'
|
||||
]
|
||||
];
|
||||
// $response = new JsonResponse();
|
||||
// $response->setData($data);
|
||||
$response = new CacheableJsonResponse($data);
|
||||
$response->addCacheableDependency(CacheableMetadata::createFromRenderArray($data));
|
||||
$response->addCacheableDependency(CacheableMetadata::createFromRenderArray($renderable));
|
||||
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
{# next_event #}
|
||||
{{ coming_events }}
|
||||
{{ past_events }}
|
||||
@@ -0,0 +1,11 @@
|
||||
# @Author: Bachir Soussi Chiadmi <bach>
|
||||
# @Email: bachir@figureslibres.io
|
||||
# @Filename: edlp_ajax.info.yml
|
||||
# @License: GPL-V3
|
||||
|
||||
|
||||
name: Edlp Ajax
|
||||
type: module
|
||||
description: Manage ajax entity loading for edlp d8.
|
||||
core: 8.x
|
||||
package: Edlp
|
||||
@@ -0,0 +1,128 @@
|
||||
<?php
|
||||
|
||||
# @Author: Bachir Soussi Chiadmi <bach>
|
||||
# @Email: bachir@figureslibres.io
|
||||
# @Filename: edlp_ajax.module
|
||||
# @License: GPL-V3
|
||||
|
||||
use Drupal\Core\Url;
|
||||
|
||||
|
||||
/**
|
||||
* Implements hook_page_attachments().
|
||||
* @param array $attachments
|
||||
*/
|
||||
function edlp_ajax_page_attachments(array &$attachments) {
|
||||
$url = Url::fromRoute('edlp_ajax.entityjson');
|
||||
$attachments['#attached']['drupalSettings']['edlp_ajax']['entityjson_path'] = $url->getInternalPath();
|
||||
$url = Url::fromRoute('edlp_ajax.blocksjson');
|
||||
$attachments['#attached']['drupalSettings']['edlp_ajax']['blocksjson_path'] = $url->getInternalPath();
|
||||
|
||||
$redirect = false;
|
||||
|
||||
$current_path = \Drupal::service('path.current')->getPath();
|
||||
$current_language = \Drupal::languageManager()->getCurrentLanguage()->getId();
|
||||
$is_front = \Drupal::service('path.matcher')->isFrontPage();
|
||||
|
||||
$entity_type = null;
|
||||
$entity_bundle = null;
|
||||
$entity_id = null;
|
||||
$audio_url = null;
|
||||
foreach (['node', 'taxonomy_term'] as $type) {
|
||||
$entity = \Drupal::routeMatch()->getParameter($type);
|
||||
if($entity){
|
||||
$entity_type = $type;
|
||||
$entity_bundle = $entity->bundle();
|
||||
$entity_id = $entity->id();
|
||||
if($entity_bundle == 'enregistrement'){
|
||||
$field_son_values = $entity->get('field_son')->getValue();
|
||||
$audio_fid = count($field_son_values) ? $field_son_values[0]['target_id'] : null;
|
||||
if($audio_fid){
|
||||
$audio_file = \Drupal\file\Entity\File::load($audio_fid);
|
||||
$son_uri = $audio_file->getFileUri();
|
||||
$audio_url = file_create_url($son_uri);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// do not redirect if not node, term, or custom routing
|
||||
// FIXME: check with routes instead of path as path can change !!!
|
||||
if(preg_match('/^\/?node\/\d+/', $current_path)
|
||||
|| preg_match('/^\/?taxonomy\/term\/\d+/', $current_path)
|
||||
|| preg_match('/^\/?productions/', $current_path)
|
||||
|| preg_match('/^\/?agenda/', $current_path)
|
||||
|| preg_match('/^\/?studio/', $current_path)
|
||||
|| preg_match('/^\/?search/', $current_path)
|
||||
|| preg_match('/^\/?lastdocs/', $current_path)
|
||||
|| preg_match('/^\/?articles/', $current_path)){
|
||||
$redirect = true;
|
||||
}
|
||||
|
||||
// $redirect = false;
|
||||
$js_str = "var edlp = {\n
|
||||
sys_path:'".$current_path."',\n
|
||||
is_front:".($is_front ? 'true':'false').",\n
|
||||
redirect:".($redirect ? 'true':'false').",\n
|
||||
lang_code:'".$current_language."',\n
|
||||
entity_type:'".$entity_type."',\n
|
||||
entity_bundle:'".$entity_bundle."',\n
|
||||
entity_id:'".$entity_id."',\n
|
||||
audio_url:'".$audio_url."',\n
|
||||
};";
|
||||
|
||||
$attachments['#attached']['html_head'][] = [
|
||||
[
|
||||
'#type' => 'html_tag',
|
||||
'#tag' => 'script',
|
||||
'#value' => $js_str,
|
||||
'#weight' => -999,
|
||||
'#group' => 'edlp'
|
||||
],
|
||||
// A key, to make it possible to recognize this HTML element when altering.
|
||||
'edlp',
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Implements hook_theme().
|
||||
*/
|
||||
function edlp_ajax_theme($existing, $type, $theme, $path) {
|
||||
// @see https://www.drupal.org/docs/8/theming/twig/create-custom-twig-templates-from-custom-module
|
||||
return array(
|
||||
'edlp_ajax' => array(
|
||||
'file' => 'includes/edlp_ajax.inc',
|
||||
'variables' => array(
|
||||
'entity_type' => null,
|
||||
'bundle' => null,
|
||||
'entity' => null,
|
||||
'view_mode' => 'default',
|
||||
'aside' => array(),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_theme_suggestions_HOOK().
|
||||
*/
|
||||
function edlp_ajax_theme_suggestions_edlp_ajax(array $vars) {
|
||||
// dpm($vars);
|
||||
$suggestions = [];
|
||||
// $node = $variables['elements']['#node'];
|
||||
$sanitized_view_mode = strtr($vars['view_mode'], '.', '_');
|
||||
// $entity = $vars['entity'];
|
||||
//
|
||||
$suggestions[] = 'edlp_ajax__' . $vars['entity_type'];
|
||||
$suggestions[] = 'edlp_ajax__' . $vars['entity_type'] . '__' . $sanitized_view_mode;
|
||||
// $suggestions[] = 'node__' . $node->bundle() . '__' . $sanitized_view_mode;
|
||||
$suggestions[] = 'edlp_ajax__' . $vars['entity_type'] . '__' . $vars['entity']->id();
|
||||
$suggestions[] = 'edlp_ajax__' . $vars['entity_type'] . '__' . $vars['entity']->id() . '__' . $sanitized_view_mode;
|
||||
|
||||
$suggestions[] = 'edlp_ajax__' . $vars['entity_type'] . '__' . $vars['bundle'];
|
||||
$suggestions[] = 'edlp_ajax__' . $vars['entity_type'] . '__' . $vars['bundle'] . '__' . $sanitized_view_mode;
|
||||
|
||||
return $suggestions;
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
# @Author: Bachir Soussi Chiadmi <bach>
|
||||
# @Date: 13-12-2017
|
||||
# @Email: bachir@figureslibres.io
|
||||
# @Filename: edlp_corpus.routing.yml
|
||||
# @Last modified by: bach
|
||||
# @Last modified time: 20-12-2017
|
||||
# @License: GPL-V3
|
||||
|
||||
edlp_ajax.entityjson:
|
||||
path: '/edlp/ajax/entity/json/{entity_type}/{id}/{viewmode}'
|
||||
defaults:
|
||||
_controller: '\Drupal\edlp_ajax\Controller\EdlpAjaxController::entityjson'
|
||||
_title: 'EdlpAjaxEntityJson'
|
||||
entity_type : null
|
||||
id: null
|
||||
viewmode: 'default'
|
||||
requirements:
|
||||
_permission: 'access content'
|
||||
|
||||
# NOT USED (YET)
|
||||
edlp_ajax.blocksjson:
|
||||
path: '/edlp/ajax/blocks/json/{blockid}'
|
||||
defaults:
|
||||
_controller: '\Drupal\edlp_ajax\Controller\EdlpAjaxController::blocksjson'
|
||||
_title: 'EdlpAjaxBlockJson'
|
||||
blockid: null
|
||||
requirements:
|
||||
_permission: 'access content'
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
// use Drupal\Core\Url;
|
||||
|
||||
function template_preprocess_edlp_ajax(&$vars){
|
||||
// dpm($vars);
|
||||
/*
|
||||
@see https://www.drupal8.ovh/index.php/en/tutoriels/339/render-a-node-or-an-entity
|
||||
*/
|
||||
$view_builder = \Drupal::entityTypeManager()->getViewBuilder($vars['entity_type']);
|
||||
$vars['content'] = $view_builder->view($vars['entity'], $vars['view_mode']);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,340 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\edlp_ajax\Controller;
|
||||
|
||||
use Drupal\Core\Controller\ControllerBase;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Drupal\Core\Url;
|
||||
use Drupal\Core\Language\LanguageInterface;
|
||||
use Drupal\menu_link_content\Entity\MenuLinkContent;
|
||||
use Drupal\Core\Datetime\DrupalDateTime;
|
||||
|
||||
// use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use \Drupal\block\Entity\Block;
|
||||
use Drupal\Core\Cache\CacheableJsonResponse;
|
||||
use Drupal\Core\Cache\CacheableMetadata;
|
||||
use Drupal\core\render\RenderContext;
|
||||
|
||||
|
||||
class EdlpAjaxController extends ControllerBase {
|
||||
|
||||
private function query() {
|
||||
$this->langcode = \Drupal::languageManager()->getCurrentLanguage()->getId();
|
||||
|
||||
|
||||
$entity = entity_load($this->entity_type, $this->id);
|
||||
|
||||
if ($entity->hasTranslation($this->langcode)){
|
||||
$this->entity = $entity->getTranslation($this->langcode);
|
||||
}else{
|
||||
$this->entity = $entity;
|
||||
}
|
||||
|
||||
|
||||
if($this->entity){
|
||||
switch($this->entity_type){
|
||||
case 'node':
|
||||
$this->bundle = $this->entity->getType();
|
||||
$this->title = $this->entity->getTitle();
|
||||
break;
|
||||
case 'taxonomy_term':
|
||||
$this->bundle = $this->entity->bundle();
|
||||
$this->title = $this->entity->getName();
|
||||
break;
|
||||
default:
|
||||
$this->bundle = NULL;
|
||||
$this->title = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function getProductionDatesAside(){
|
||||
|
||||
$now = new DrupalDateTime('now');
|
||||
$now->setTimezone(new \DateTimeZone(DATETIME_STORAGE_TIMEZONE));
|
||||
|
||||
$future_dates_query = \Drupal::entityQuery('node')
|
||||
->condition('status', 1)
|
||||
->condition('type', 'evenement')
|
||||
->condition('field_page_liee.target_id', $this->entity->id(), 'IN')
|
||||
->condition('field_date', $now->format(DATETIME_DATETIME_STORAGE_FORMAT), '>=')
|
||||
->sort('field_date');
|
||||
$future_nids = $future_dates_query->execute();
|
||||
|
||||
$past_dates_query = \Drupal::entityQuery('node')
|
||||
->condition('status', 1)
|
||||
->condition('type', 'evenement')
|
||||
->condition('field_page_liee.target_id', $this->entity->id(), 'IN')
|
||||
->condition('field_date', $now->format(DATETIME_DATETIME_STORAGE_FORMAT), '<')
|
||||
->sort('field_date', 'DESC');
|
||||
$past_nids = $past_dates_query->execute();
|
||||
|
||||
if(count($future_nids) || count($past_nids)){
|
||||
|
||||
$aside = array(
|
||||
'#type'=>'container',
|
||||
"#attributes"=>array(
|
||||
"class"=>['agenda']
|
||||
)
|
||||
);
|
||||
|
||||
$node_view_builder = \Drupal::entityTypeManager()->getViewBuilder('node');
|
||||
|
||||
if(count($future_nids)){
|
||||
$future_nodes = entity_load_multiple('node', $future_nids);
|
||||
$future_list = array (
|
||||
'#theme' => 'item_list',
|
||||
'#items' => [],
|
||||
);
|
||||
foreach($future_nodes as $node){
|
||||
$future_list['#items'][] = $node_view_builder->view($node, 'aside');
|
||||
}
|
||||
$aside['future_events'] = array(
|
||||
"#type"=>"container",
|
||||
"#attributes"=>array(
|
||||
"class"=>['future-events']
|
||||
),
|
||||
"#markup"=>"<h3>" . t("Upcoming events") . "</h3>",
|
||||
"future_events"=>$future_list
|
||||
);
|
||||
}
|
||||
|
||||
if(count($past_nids)){
|
||||
$past_nodes = entity_load_multiple('node', $past_nids);
|
||||
$past_list = array (
|
||||
'#theme' => 'item_list',
|
||||
'#items' => [],
|
||||
);
|
||||
foreach($past_nodes as $node){
|
||||
$past_list['#items'][] = $node_view_builder->view($node, 'aside');
|
||||
}
|
||||
$aside['past_events'] = array(
|
||||
"#type"=>"container",
|
||||
"#attributes"=>array(
|
||||
"class"=>['past-events']
|
||||
),
|
||||
"#markup"=>"<h3>" . t("Past events") . "</h3>",
|
||||
"past_events"=>$past_list
|
||||
);
|
||||
}
|
||||
}else{
|
||||
$aside = null;
|
||||
}
|
||||
return $aside;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* return a renderable array
|
||||
*/
|
||||
private function getAside() {
|
||||
if($this->bundle == 'page'){
|
||||
$aside = $this->getProductionDatesAside();
|
||||
}else{
|
||||
$aside = null;
|
||||
}
|
||||
return $aside;
|
||||
}
|
||||
|
||||
private function toRenderable(){
|
||||
$this->query();
|
||||
|
||||
if($this->entity){
|
||||
return array(
|
||||
"#theme"=>'edlp_ajax',
|
||||
"#entity_type" => $this->entity_type,
|
||||
'#entity' => $this->entity,
|
||||
'#view_mode' => $this->viewmode,
|
||||
'#aside' => $this->getAside(),
|
||||
'#bundle' => $this->bundle,
|
||||
);
|
||||
}else{
|
||||
return array(
|
||||
'#markup'=>'404! '.$this->entity_type.' '.$this->id." not found!"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get entity as json through ajax.
|
||||
*
|
||||
* @return json
|
||||
*/
|
||||
public function entityjson($entity_type, $id, $viewmode) {
|
||||
$this->entity_type = $entity_type;
|
||||
$this->id = $id;
|
||||
$this->viewmode = $viewmode;
|
||||
|
||||
$renderable = $this->toRenderable();
|
||||
// $rendered = render($renderable);
|
||||
// We can't render directly the entity as it throw an exception with cachable data
|
||||
// see http://blog.dcycle.com/blog/2018-01-24/caching-drupal-8-rest-resource/#the-dreaded-leaked-metadata-error
|
||||
$rendered = \Drupal::service('renderer')->executeInRenderContext(new RenderContext(), function () use ($renderable) {
|
||||
return render($renderable);
|
||||
});
|
||||
|
||||
$title = $this->title;
|
||||
$title .= $this->viewmode != '' && $this->viewmode != 'default' ? ' | ' . $this->viewmode : '';
|
||||
|
||||
$data = [
|
||||
'date' => time(),
|
||||
'id' => $this->id,
|
||||
'title' => $title,
|
||||
'view_mode' => $this->viewmode,
|
||||
'bundle' => $this->bundle,
|
||||
'entity_type' => $this->entity_type,
|
||||
'rendered'=> $rendered,
|
||||
'language' => $this->langcode
|
||||
];
|
||||
|
||||
// if content type page (productions) :
|
||||
// -- get the menu items and linked dates
|
||||
// -- get the linked documents for corpus map
|
||||
if($this->bundle == "page"){
|
||||
$menuLinkManager = \Drupal::service('plugin.manager.menu.link');
|
||||
$links = $menuLinkManager->loadLinksByRoute('entity.node.canonical', array('node' => $this->id), 'productions');
|
||||
// dpm($links, 'links');
|
||||
$menu_parents = array();
|
||||
foreach ($links as $link) {
|
||||
$parents = $menuLinkManager->getParentIds($link->getPluginId());
|
||||
// dpm($parents, 'parents');
|
||||
foreach ($parents as $parent_id) {
|
||||
$parent = $menuLinkManager->getInstance(array('id'=>$parent_id));
|
||||
// dpm($parent, 'parent');
|
||||
$url = $parent->getUrlObject();
|
||||
$sys_path = $url->getInternalPath();
|
||||
// dpm($sys_path);
|
||||
$menu_parents[] = $sys_path;
|
||||
}
|
||||
}
|
||||
$data['menu_parents'] = $menu_parents;
|
||||
|
||||
// Documents liés
|
||||
$documents_lies = $this->entity->get('field_documents_lies')->getValue();
|
||||
if(count($documents_lies)){
|
||||
foreach ($documents_lies as $key => $field) {
|
||||
$data['documents_lies'][] = $field['target_id'];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// translations links
|
||||
$links = \Drupal::languageManager()->getLanguageSwitchLinks(LanguageInterface::TYPE_URL, $this->entity->toUrl());
|
||||
if (isset($links->links)) {
|
||||
$translations_build = [
|
||||
'#theme' => 'links__language_block',
|
||||
'#links' => $links->links,
|
||||
'#attributes' => ['class' => ["language-switcher-{$links->method_id}"]],
|
||||
'#set_active_class' => TRUE,
|
||||
];
|
||||
$translations_rendered = \Drupal::service('renderer')->executeInRenderContext(new RenderContext(), function () use ($translations_build) {return render($translations_build);});
|
||||
// dpm($links);
|
||||
$data['translations_links'] = $translations_rendered;
|
||||
}
|
||||
|
||||
$data['#cache'] = [
|
||||
'max-age' => \Drupal\Core\Cache\Cache::PERMANENT,
|
||||
'tags' => [
|
||||
'edlp-ajax-cache',
|
||||
// $this->entity_type.':'.$this->id // not necessary as we add $renderable as CacheableMetadata to the response
|
||||
],
|
||||
'contexts' => [
|
||||
'languages:language_content',
|
||||
'user'
|
||||
]
|
||||
];
|
||||
|
||||
// $response = new JsonResponse();
|
||||
// $response->setData($data);
|
||||
$response = new CacheableJsonResponse($data);
|
||||
$response->addCacheableDependency(CacheableMetadata::createFromRenderArray($renderable));
|
||||
$response->addCacheableDependency(CacheableMetadata::createFromRenderArray($data));
|
||||
|
||||
return $response;
|
||||
|
||||
// dpm($response);
|
||||
|
||||
// return array(
|
||||
// '#markup'=>'hello'
|
||||
// );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all visisble blocks from edlptheme as json through ajax.
|
||||
*
|
||||
* @return json
|
||||
*/
|
||||
// NOT USED (YET)
|
||||
public function blocksjson($blockid) {
|
||||
$block_viewbuilder = \Drupal::entityTypeManager()->getViewBuilder('block');
|
||||
//
|
||||
$blocksids = [];
|
||||
if(!$blockid){
|
||||
// TODO: get all blocks definition from edlptheme
|
||||
$block_storage = \Drupal::entityTypeManager()->getStorage('block');
|
||||
// dpm($block_storage, '$block_storage');
|
||||
$allblocks = $block_storage->loadMultiple();
|
||||
// dpm($blocks, 'blocks');
|
||||
foreach ($allblocks as $block) {
|
||||
// dpm($block->id(), 'block');
|
||||
// dpm($block->getTheme(), 'theme');
|
||||
// $visibility = $block->getVisibility();
|
||||
if($block->getTheme() == "edlptheme"){
|
||||
// dpm($block, $block->id());
|
||||
$blocksids[] = $block->id();
|
||||
}
|
||||
}
|
||||
// $block_listbuilder = \Drupal::entityTypeManager()->getListBuilder('block');
|
||||
// dpm($block_listbuilder, '$block_listbuilder');
|
||||
// // foreach ($blocks as $key => $value) {
|
||||
// // $block = \Drupal\block\Entity\Block::load('productions');
|
||||
// // }
|
||||
}
|
||||
else{
|
||||
$blocksids[] = $blockid;
|
||||
}
|
||||
// dpm($blocksids, 'blockids');
|
||||
//
|
||||
$blocks = [];
|
||||
foreach ($blocksids as $id) {
|
||||
$block = Block::load($id);
|
||||
$block_render = $block_viewbuilder->view($block);
|
||||
$rendered = \Drupal::service('renderer')->executeInRenderContext(new RenderContext(), function () use ($block_render) {
|
||||
return render($block_render);
|
||||
});
|
||||
$blocks[$id] = array(
|
||||
'rendered'=> $rendered,
|
||||
'region'=> str_replace('_', '-', $block->getRegion()),
|
||||
'id'=> preg_replace('/^[^:]+:(.+)$/', 'block-$1', $block->getPluginId())
|
||||
);
|
||||
}
|
||||
// dpm($blocks, 'blocks');
|
||||
//
|
||||
$data = [
|
||||
'blockid'=>$blockid,
|
||||
'blocks' => $blocks,
|
||||
'#cache' => [
|
||||
'max-age' => \Drupal\Core\Cache\Cache::PERMANENT,
|
||||
'tags' => [
|
||||
'edlp-ajax-blocks-cache',
|
||||
// $this->entity_type.':'.$this->id // not necessary as we add $renderable as CacheableMetadata to the response
|
||||
]
|
||||
]
|
||||
];
|
||||
// dpm($data);
|
||||
//
|
||||
$response = new CacheableJsonResponse($data);
|
||||
// $response->addCacheableDependency(CacheableMetadata::createFromRenderArray($renderable));
|
||||
$response->addCacheableDependency(CacheableMetadata::createFromRenderArray($data));
|
||||
//
|
||||
return $response;
|
||||
|
||||
// dpm($response);
|
||||
//
|
||||
return array(
|
||||
'#markup'=>'hello'
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
+131
@@ -0,0 +1,131 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\edlp_ajax\Plugin\Field\FieldFormatter;
|
||||
|
||||
use Drupal\Component\Utility\Html;
|
||||
use Drupal\Core\Field\FieldItemInterface;
|
||||
use Drupal\Core\Field\FieldItemListInterface;
|
||||
use Drupal\Core\Field\FormatterBase;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
use Drupal\Core\Field\Plugin\Field\FieldFormatter\EntityReferenceLabelFormatter;
|
||||
/**
|
||||
* Plugin implementation of the 'entity_reference_label_formatter_ajax' formatter.
|
||||
*
|
||||
* @FieldFormatter(
|
||||
* id = "entity_reference_label_formatter_ajax",
|
||||
* label = @Translation("Label link ajax ready"),
|
||||
* field_types = {
|
||||
* "entity_reference"
|
||||
* }
|
||||
* )
|
||||
*/
|
||||
class EntityReferenceLabelFormatterAjax extends EntityReferenceLabelFormatter {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function defaultSettings() {
|
||||
return [
|
||||
// Implement default settings.
|
||||
] + parent::defaultSettings();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function settingsForm(array $form, FormStateInterface $form_state) {
|
||||
return [
|
||||
// Implement settings form.
|
||||
] + parent::settingsForm($form, $form_state);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
// public function settingsSummary() {
|
||||
// $summary = [];
|
||||
// // Implement settings summary.
|
||||
//
|
||||
// return $summary;
|
||||
// }
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function viewElements(FieldItemListInterface $items, $langcode) {
|
||||
$elements = [];
|
||||
$output_as_link = $this->getSetting('link');
|
||||
$current_langcode = \Drupal::languageManager()->getCurrentLanguage()->getId();
|
||||
|
||||
foreach ($this->getEntitiesToView($items, $langcode) as $delta => $entity) {
|
||||
|
||||
if ($entity->hasTranslation($current_langcode)) {
|
||||
$entity = $entity->getTranslation($current_langcode);
|
||||
}
|
||||
|
||||
$label = $entity->label();
|
||||
// If the link is to be displayed and the entity has a uri, display a
|
||||
// link.
|
||||
if ($output_as_link && !$entity->isNew()) {
|
||||
try {
|
||||
$uri = $entity->urlInfo();
|
||||
$options = $uri->getOptions();
|
||||
$options += array(
|
||||
'attributes' => array(
|
||||
'class' => ['ajax-link'],
|
||||
'nid'=>$entity->id(),
|
||||
'data-drupal-link-system-path' => $uri->getInternalPath()
|
||||
)
|
||||
);
|
||||
$uri->setOptions($options);
|
||||
}
|
||||
catch (UndefinedLinkTemplateException $e) {
|
||||
// This exception is thrown by \Drupal\Core\Entity\Entity::urlInfo()
|
||||
// and it means that the entity type doesn't have a link template nor
|
||||
// a valid "uri_callback", so don't bother trying to output a link for
|
||||
// the rest of the referenced entities.
|
||||
$output_as_link = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if ($output_as_link && isset($uri) && !$entity->isNew()) {
|
||||
$elements[$delta] = [
|
||||
'#type' => 'link',
|
||||
'#title' => $label,
|
||||
'#url' => $uri,
|
||||
'#options' => $uri->getOptions(),
|
||||
];
|
||||
|
||||
if (!empty($items[$delta]->_attributes)) {
|
||||
$elements[$delta]['#options'] += ['attributes' => []];
|
||||
$elements[$delta]['#options']['attributes'] += $items[$delta]->_attributes;
|
||||
// Unset field item attributes since they have been included in the
|
||||
// formatter output and shouldn't be rendered in the field template.
|
||||
unset($items[$delta]->_attributes);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$elements[$delta] = ['#plain_text' => $label];
|
||||
}
|
||||
$elements[$delta]['#cache']['tags'] = $entity->getCacheTags();
|
||||
}
|
||||
|
||||
return $elements;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the output appropriate for one field item.
|
||||
*
|
||||
* @param \Drupal\Core\Field\FieldItemInterface $item
|
||||
* One field item.
|
||||
*
|
||||
* @return string
|
||||
* The textual output generated.
|
||||
*/
|
||||
protected function viewValue(FieldItemInterface $item) {
|
||||
// The text value has no text format assigned to it, so the user input
|
||||
// should equal the output, including newlines.
|
||||
return nl2br(Html::escape($item->value));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
{{ content }}
|
||||
{{ aside }}
|
||||
@@ -0,0 +1,4 @@
|
||||
node_modules/
|
||||
.npm-debug-log
|
||||
package-lock.json
|
||||
bower_components/
|
||||
@@ -0,0 +1,42 @@
|
||||
|
||||
(function($,Drupal,drupalSettings){EdlpCorpus=function(){var _activated=true;var _$body=$('body');var _$container=_$body;var _$canvas=$('<canvas id="corpus-map">').appendTo(_$container);var _canvas=_$canvas[0];var _ctx=_canvas.getContext('2d');var _dpi=window.devicePixelRatio;var _scene_props={width:window.innerWidth,height:window.innerHeight,'margin_top':75,'margin_right':0,'margin_bottom':65,'margin_left':0};var _evolution_zone={left:_scene_props.width/4,right:_scene_props.width-_scene_props.width/4,center:_scene_props.width/2,};var _physics=new Physics();var _nodes=[];var _articles_nodes=[];var _no_articles_nodes=[];var _nodes_by_entries={};var _nodes_by_nid={};var _nodes_Nid_Id={};var _nodes_centered=[];var _nodes_centered_attractions=[];var _loaded=false;var _playlist=[];var _p_velocity_factor=0.5;var _mouse_in=true;var _m_pos={x:0,y:0};var _node_hover_id=-1;var _node_opened_id=-1;var _$entrees_block=$('#block-edlpentreesblock');var _$entrees_block_termlinks=$('a.term-link',_$entrees_block);var _$articles_link;var _node_pop_up;var _settings=drupalSettings.edlp_corpus;var _ecolors=_settings.colors;var _attracter;var check_parts_colid_frq=2;var check_parts_colid_tick=1;function init(){initCanvas();if(_activated){loadCorpus();}else{_$canvas.addClass('de-activated');}};function initCanvas(){window.addEventListener('resize',onResizeCanvas,false);onResizeCanvas();};function onResizeCanvas(){_scene_props.width=window.innerWidth;_scene_props.height=window.innerHeight;_canvas.style.width=_scene_props.width+'px';_canvas.style.height=_scene_props.height+'px';_canvas.width=_scene_props.width*_dpi;_canvas.height=_scene_props.height*_dpi;_ctx.scale(_dpi,_dpi);moveEvolutionZone();if(_loaded){for(var i=0;i<_nodes.length;i++){_nodes[i].onResizeCanvas();}}};function loadCorpus(){var ajax_path=_settings.load_corpus_ajax_url;var path=window.location.origin+Drupal.url(ajax_path);$.getJSON(path,{}).done(function(data){onCorpusLoaded(data);}).fail(function(jqxhr,textStatus,error){onCorpusLoadError(jqxhr,textStatus,error);});};function onCorpusLoadError(jqxhr,textStatus,error){void 0;};function onCorpusLoaded(data){void 0;initPhysics();buildNodes(data.nodes);initArtilesLink();initNodePopup();initEvents();checkPreOpenedEntry();startAnime();_loaded=true;};function initPhysics(){_attracter=_physics.makeParticle(1000);_attracter.fixed=true;resizePhysics();};function resizePhysics(){if(typeof _attracter!='undefined'){_attracter.position={x:_evolution_zone.center,y:_scene_props.height/2};}};function buildNodes(nodes){var d;for(var i in nodes){d=i<1?true:false;new Node(i,nodes[i],d);_playlist.push({'id':i,'nid':nodes[i].nid,'audio_url':nodes[i].audio_url,'document_url':nodes[i].document_url,});}};function Node(i,node,d){this.id=i;for(key in node)
|
||||
this[key]=node[key];_nodes.push(this);_nodes_by_nid[this.nid]=this;_nodes_Nid_Id[this.nid]=this.id;if(this.has_article==1){_articles_nodes.push(this);}else{_no_articles_nodes.push(this);}
|
||||
for(var j=0;j<this.entrees.length;j++){if(typeof _nodes_by_entries[this.entrees[j]]=='undefined')
|
||||
_nodes_by_entries[this.entrees[j]]=[];_nodes_by_entries[this.entrees[j]].push(this);}
|
||||
this.debug=d;this.mass=Math.max(1,this.entrees.length);this.velocity_threshold=0.01;switch(true){case this.entrees.length>3:this.r=8;break;case this.entrees.length>1&&this.entrees.length<=3:this.r=5;break;default:this.r=3;break;}
|
||||
this.d=this.r*2;this.e_color='e_col_'+this.entrees[Math.floor(Math.random(this.entrees.length))];this.canvas=document.createElement('canvas');this.canvas_ctx=this.canvas.getContext('2d');this.line_width=1;this.w=this.r*2+this.line_width*2;this.w_2=this.w/2;this.canvas.width=this.w;this.canvas.height=this.w;this.canvas_ctx.fillStyle='rgb(255,255,255)';this.canvas_ctx.lineWidth=this.line_width;this.wall_bouncing_elasticity=0.75;this.hover=false;this.opened=false;this.faded=false;this.center=false;this.aside=false;this.scrambling=false;if(typeof Node.initialized=="undefined"){Node.prototype.init=function(){this.calcWallLimits();this.x=this.wall_limits.left+Math.random()*(this.wall_limits.right-this.wall_limits.left);this.y=this.wall_limits.top+Math.random()*(this.wall_limits.bottom-this.wall_limits.top);this.ori_pos={x:this.x,y:this.y};this.initPhysics();};Node.prototype.initPhysics=function(){this.p=_physics.makeParticle(this.mass,this.x,this.y);this.p.velocity=new Physics.Vector((Math.random()-0.5)*_p_velocity_factor,(Math.random()-0.5)*_p_velocity_factor);this.ori_p=_physics.makeParticle(1000,this.ori_pos.x,this.ori_pos.y);this.ori_p.fixed=true;this.ori_p_attract=_physics.makeAttraction(this.ori_p,this.p,1000,_scene_props.width*2);this.ori_p_attract.on=false;this.attract=_physics.makeAttraction(_attracter,this.p,1000,_scene_props.width*2);this.attract.on=false;};Node.prototype.calcWallLimits=function(){this.wall_limits={top:_scene_props.margin_top+this.r,right:_scene_props.width-_scene_props.margin_right-this.r,bottom:_scene_props.height-_scene_props.margin_bottom-this.r,left:_scene_props.margin_left+this.r}};Node.prototype.onResizeCanvas=function(){this.calcWallLimits();this.shuffleOriP();};Node.prototype.shuffleOriP=function(){this.ori_pos.x=this.wall_limits.left+Math.random()*(this.wall_limits.right-this.wall_limits.left);this.ori_pos.y=this.wall_limits.top+Math.random()*(this.wall_limits.bottom-this.wall_limits.top);this.scramble();};Node.prototype.onUpdate=function(){if(this.hover||this.opened){this.p.fixed=true;}else{this.p.fixed=false;if(this.center)
|
||||
this.limitEvolutionZone();this.checkWallBouncing();this.updatePos();if(this.scrambling){this.checkOriPDist();}}
|
||||
if(_mouse_in&&!this.aside&&!this.faded)
|
||||
this.checkMouse();this.redraw();};Node.prototype.checkVelocityThreshold=function(){if(!this.centered||!this.aside){if(Math.abs(this.p.velocity.x)<this.velocity_threshold&&Math.abs(this.p.velocity.y)<this.velocity_threshold){this.p.velocity.multiplyScalar(0);}}};Node.prototype.checkWallBouncing=function(){switch(true){case this.x<this.wall_limits.left&&this.p.velocity.x<0:this.p.position.x=this.wall_limits.left;this.p.velocity.multiplyScalarXY(-1,1).multiplyScalar(this.wall_bouncing_elasticity);break;case this.x>this.wall_limits.right&&this.p.velocity.x>0:this.p.position.x=this.wall_limits.right;this.p.velocity.multiplyScalarXY(-1,1).multiplyScalar(this.wall_bouncing_elasticity);break;case this.y<this.wall_limits.top&&this.p.velocity.y<0:this.p.position.y=this.wall_limits.top;this.p.velocity.multiplyScalarXY(1,-1).multiplyScalar(this.wall_bouncing_elasticity);break;case this.y>this.wall_limits.bottom&&this.p.velocity.y>0:this.p.position.y=this.wall_limits.bottom;this.p.velocity.multiplyScalarXY(1,-1).multiplyScalar(this.wall_bouncing_elasticity);break;}};Node.prototype.updatePos=function(){this.x=this.p.position.x;this.y=this.p.position.y;};Node.prototype.checkMouse=function(){if(_m_pos.x>this.x-this.r&&_m_pos.x<this.x+this.r&&_m_pos.y>this.y-this.r&&_m_pos.y<this.y+this.r){if(_node_hover_id==-1||_node_hover_id!==this.id){this.setHover();}}else{this.unsetHover();}};Node.prototype.setHover=function(){this.hover=true;_node_hover_id=this.id;_node_pop_up.setNode(this);};Node.prototype.unsetHover=function(){this.hover=false;if(_node_hover_id==this.id){_node_hover_id=-1;_node_pop_up.removeNode();}};Node.prototype.open=function(){this.opened=true;_node_opened_id=this.id;};Node.prototype.close=function(){this.opened=false;};Node.prototype.fade=function(){this.faded=true;};Node.prototype.unFade=function(){this.faded=false;};Node.prototype.setCenteredOnEntree=function(tid){this.e_color='e_col_'+tid;this.setCentered();};Node.prototype.setCentered=function(){this.center=true;this.stopScrambling();this.unsetAside();this.attract.on=true;}
|
||||
Node.prototype.unsetCentered=function(){this.center=false;this.attract.on=false;}
|
||||
Node.prototype.limitEvolutionZone=function(){this.dist_to_attracter=this.p.distanceTo(_attracter);if(this.dist_to_attracter<_scene_props.width/4){if(this.p.velocity.length()>0.4){this.p.velocity.multiplyScalar(0.99);}}
|
||||
if(this.x<_evolution_zone.left||this.x>_evolution_zone.right||Math.abs(_attracter.position.y-this.y)>_scene_props.height/4){this.attract.on=true;}else{this.attract.on=false;}}
|
||||
Node.prototype.setAside=function(){this.aside=true;this.stopScrambling();this.unsetCentered();this.ori_p.position.x=this.x<_scene_props.width/2?this.wall_limits.left:this.wall_limits.right;this.ori_p_attract.on=true;this.wall_bouncing_elasticity=0.15;}
|
||||
Node.prototype.unsetAside=function(){this.aside=false;this.ori_p_attract.on=false;this.ori_p.position.x=this.ori_pos.x;this.wall_bouncing_elasticity=0.75;}
|
||||
Node.prototype.resolveNormalPos=function(){switch(true){case this.center:this.unsetCentered();break;case this.aside:this.unsetAside();break;}};Node.prototype.scramble=function(){this.scrambling=true;this.unsetCentered();this.unsetAside();this.ori_p.position.x=this.ori_pos.x;this.ori_p.position.y=this.ori_pos.y;this.ori_p_attract.on=true;}
|
||||
Node.prototype.checkOriPDist=function(){if(this.p.distanceTo(this.ori_p)<50){this.stopScrambling();}};Node.prototype.stopScrambling=function(){this.scrambling=false;this.ori_p_attract.on=false;}
|
||||
Node.prototype.move=function(){_ctx.drawImage(this.canvas,this.x-this.w_2,this.y-this.w_2);};Node.prototype.redraw=function(){_ctx.beginPath();_ctx.fillStyle='rgb(255,255,255)';_ctx.fillRect(this.x-this.r,this.y-this.r,this.d,this.d);_ctx.globalAlpha=this.faded?0.15:1;if(this.opened){_ctx.fillStyle=_ecolors[this.e_color];_ctx.fillRect(this.x-this.r,this.y-this.r,this.d,this.d);}
|
||||
_ctx.strokeStyle=_ecolors[this.e_color];_ctx.strokeRect(this.x-this.r,this.y-this.r,this.d,this.d);_ctx.closePath();};Node.initialized=true;}
|
||||
this.init();};function checkParticulesCollisions(){if(check_parts_colid_tick<check_parts_colid_frq){check_parts_colid_tick++;return;}
|
||||
check_parts_colid_tick=1;var na,nb,ma,mb,w,h,dx,dy,makeup,newVelX1,newVelY1,newVelX2,newVelY2,Smamb;for(var n=0,l=_nodes.length;n<l;n++){na=_nodes[n];if(na.scrambling||na.aside)continue;ma=na.p.mass;for(var q=n+1;q<l;q++){nb=_nodes[q];if(nb.aside)
|
||||
continue;if(na.center&&nb.center){if(Math.min(na.p.distanceTo(_attracter),nb.p.distanceTo(_attracter))>300){if(Math.random()>0.3)continue;}}
|
||||
w=h=(na.r+nb.r);w=h+=4;dx=na.p.position.x-nb.p.position.x;if(Math.abs(dx)>w)continue;dy=na.p.position.y-nb.p.position.y;if(Math.abs(dy)>h)continue
|
||||
mb=nb.p.mass;Smamb=ma+mb;if(Math.abs(dx)<Math.abs(dy)){makeup=(h-Math.abs(dy))/2;if(dy>0){na.p.position.y+=makeup;nb.p.position.y-=makeup;}else{na.p.position.y-=makeup;nb.p.position.y+=makeup;}
|
||||
newVelY1=(ma-mb)/Smamb*na.p.velocity.y+2*mb/Smamb*nb.p.velocity.y;newVelY2=(mb-ma)/Smamb*nb.p.velocity.y+2*ma/Smamb*na.p.velocity.y;na.p.velocity.y=newVelY1;nb.p.velocity.y=newVelY2;}else{makeup=(w-Math.abs(dx))/2;if(dx>0){na.p.position.x+=makeup;nb.p.position.x-=makeup;}else{na.p.position.x-=makeup;nb.p.position.x+=makeup;}
|
||||
newVelX1=(ma-mb)/Smamb*na.p.velocity.x+2*mb/Smamb*nb.p.velocity.x;newVelX2=(mb-ma)/Smamb*nb.p.velocity.x+2*ma/Smamb*na.p.velocity.x;na.p.velocity.x=newVelX1;nb.p.velocity.x=newVelX2;}
|
||||
na.p.velocity.multiplyScalar(0.90);nb.p.velocity.multiplyScalar(0.90);}}};function openNodeByNid(nid){closeNode();if(typeof _nodes_Nid_Id[nid]!='undefined'){_node_opened_id=_nodes_Nid_Id[nid];_nodes[_nodes_Nid_Id[nid]].open();}}
|
||||
function closeNode(){if(_node_opened_id!=-1){_nodes[_node_opened_id].close();_node_opened_id=-1;}}
|
||||
function createNodesRepulsions(){purgeNodesRepulsions();for(var n=0;n<_nodes_centered.length;n++){for(var q=n+1;q<_nodes_centered.length;q++){_physics.makeAttraction(_nodes_centered[n].p,_nodes_centered[q].p,-0.4,10);}}};function purgeNodesRepulsions(){for(var a=_physics.attractions.length-1;a>=0;a--){if(Math.abs(_physics.attractions[a].constant)<1){_physics.attractions.splice(a,1);}else{break;}}};function moveEvolutionZone(l,r){var left=l||0;var right=r||0;_evolution_zone.left=Math.max(_scene_props.width/5,left+20);_evolution_zone.right=Math.min(_scene_props.width-_scene_props.width/5,_scene_props.width-right+20);_evolution_zone.center=_evolution_zone.left+(_evolution_zone.right-_evolution_zone.left)/2;resizePhysics();}
|
||||
function updateRandomPlaylist(p){_$canvas.trigger({type:'update-random-playlist',playlist:p})};function toggleEntree(tid,bubbling){var $link=_$entrees_block_termlinks.filter('[tid="'+tid+'"]');var $li=$link.parents('li');var sys_path=$link.attr('data-drupal-link-system-path');var url=$link.attr('href');var title=$link.text();if(!$li.is('.opened')){_$entrees_block_termlinks.parents('li').removeClass('opened');$li.addClass('opened');$li.parents('.item-list').addClass('opened')
|
||||
filterEntree(tid);if(bubbling){_$body.trigger({'type':'open_entree','tid':tid,'url':url,'sys_path':sys_path,'title':title});}}else if(bubbling){$li.removeClass('opened');$li.parents('.item-list').removeClass('opened')
|
||||
scrambleCollection();_$body.trigger({'type':'close_entree','tid':tid});}};function filterEntree(t){_nodes_centered=[];for(var n=0;n<_nodes.length;n++){if(_nodes[n].entrees.indexOf(t)==-1){_nodes[n].setAside();}else{_nodes[n].setCenteredOnEntree(t);_nodes_centered.push(_nodes[n]);}}
|
||||
updateRandomPlaylist(_nodes_centered);createNodesRepulsions();};function highlightEntries(){_$entrees_block_termlinks.parents('li').removeClass('highlighted').parents('.item-list').removeClass('highlighted');var id=-1;if(_node_hover_id!=-1){id=_node_hover_id;}else if(_node_opened_id!=-1){id=_node_opened_id;}
|
||||
var entree;if(id!=-1){for(var i=0;i<_nodes[id].entrees.length;i++){entree=_nodes[id].entrees[i];_$entrees_block_termlinks.filter(function(){return $(this).attr('tid')==entree;}).parents('li').addClass('highlighted').parents('.item-list').addClass('highlighted');}}};function filterByNids(nids){_nodes_centered=[];for(var n=0;n<_nodes.length;n++){if(nids.indexOf(_nodes[n].nid)==-1){_nodes[n].setAside();}else{_nodes[n].setCentered();_nodes_centered.push(_nodes[n]);}}
|
||||
updateRandomPlaylist(_nodes_centered);createNodesRepulsions();};function scrambleCollection(){for(var i=0;i<_nodes.length;i++){_nodes[i].scramble();}
|
||||
updateRandomPlaylist(_playlist);};function closeAllEntries(){_$entrees_block_termlinks.each(function(index,el){if($(this).parents('li').is('.opened')){$(this).trigger('click');return false;}});};function initArtilesLink(){var href=window.location.origin+drupalSettings.path.baseUrl+_settings.articlesindex_url;_$articles_link=$('<a>').html('Articles').attr("href",href).attr("data-drupal-link-system-path",_settings.articlesindex_url).addClass('articles-link ajax-link');$('.item-list ul',_$entrees_block).append($('<li>').append($('<span class="oblique-wrapper">').append(_$articles_link)));};function initEvents(){void 0;_$canvas.on('mousemove',function(event){event.preventDefault();_m_pos.x=event.originalEvent.clientX;_m_pos.y=event.originalEvent.clientY;}).on('mouseenter',function(event){_mouse_in=true;}).on('mouseout',function(event){_mouse_in=false;_node_pop_up.removeNode();}).on('click',function(event){if(event.target.tagName!="A"&&event.target.tagName!="INPUT"){event.preventDefault();if(_node_hover_id!=-1){var event={'type':'corpus-cliked-on-node','target_node':_nodes[_node_hover_id],};_$canvas.trigger(event);}else{_$canvas.trigger('corpus-cliked-on-map');}}}).on('mouseover-audio-link',function(e){void 0;_nodes_by_nid[e.nid].setHover();}).on('mouseout-audio-link',function(e){void 0;_nodes_by_nid[e.nid].unsetHover();}).on('audio-node-opened',function(e){openNodeByNid(e.nid);}).on('audio-node-closed',function(e){closeNode();}).on('open-entree',function(e){toggleEntree(e.tid);}).on('close-all-entree',function(e){closeAllEntries();}).on('scramble-collection',function(e){void 0;scrambleCollection();}).on('shuffle-collection',function(e){void 0;onResizeCanvas();});_$entrees_block_termlinks.on('click',function(event){event.preventDefault();toggleEntree($(this).attr('tid'),true);return false;});_$body.on('chutier-action-done',function(e){_nodes_by_nid[e.target_id].chutier_action=e.new_action;}).on('ajax-node-loaded-linked-documents',function(e){void 0;filterByNids(e.nids);}).on('search-results-loaded',function(e){filterByNids(e.results);}).on('search-closed',function(e){scrambleCollection();}).on('new-content-not-entree-ajax-loaded',function(e){if(_$entrees_block_termlinks.parents('li.opened').length){_$entrees_block_termlinks.parents('li').removeClass('opened').parents('.item-list').removeClass('opened');scrambleCollection();}}).on('visible-space-changed',function(e){moveEvolutionZone(e.left_limit,e.right_limit);});};function checkPreOpenedEntry(){_$entrees_block.find('li.entree').each(function(index,el){var $li=$(this);if($('a.is-active',$li).length){$li.addClass('opened').parents('.item-list').addClass('opened');filterEntree($li.attr('tid'));return false;}});};function initNodePopup(){_node_pop_up=new NodePopUp();};function NodePopUp(){this.visible=false;this.node;this.$dom=$('<div>').addClass('node-popup').attr('pos','top-right').appendTo('body');this.$content=$('<div>').addClass('inner').appendTo(this.$dom);if(typeof NodePopUp.initialized=="undefined"){NodePopUp.prototype.setNode=function(n){this.node=n;this.setPositioning();this.setContent();};NodePopUp.prototype.setPositioning=function(){switch(true){case this.node.x>this.node.wall_limits.right-350&&this.node.y<this.node.wall_limits.top+200:this.$dom.attr('pos','bottom-left');break;case this.node.x>this.node.wall_limits.right-350:this.$dom.attr('pos','top-left');break;case this.node.y<this.node.wall_limits.top+200:this.$dom.attr('pos','bottom-right');break;default:this.$dom.attr('pos','top-right');}};NodePopUp.prototype.setContent=function(){this.$content.html('');var $entrees=$('<div>').addClass('entrees');for(var i=0;i<this.node.entrees.length;i++){var tid=this.node.entrees[i];$entrees.append($('<span>').addClass('entree').attr('tid',tid));}
|
||||
var $chutier_action=$('<span>').addClass('chutier-icon').attr('action',this.node.chutier_action);this.$content.append($entrees).append('<h2 class="title">'+this.node.title+'</h2>').append('<section class="description">'+this.node.description+'</section>').append($chutier_action);};NodePopUp.prototype.removeNode=function(){this.node=false;};NodePopUp.prototype.draw=function(){if(this.node){this.$dom.css({'display':"block",'left':this.node.x+"px",'top':this.node.y+"px",});}else{this.$dom.css({'display':"none",});}};NodePopUp.initialized=true;}}
|
||||
function render(){_ctx.clearRect(0,0,_scene_props.width,_scene_props.height);checkParticulesCollisions();for(var i=0;i<_nodes.length;i++){_nodes[i].onUpdate();}
|
||||
_node_pop_up.draw();if(_node_hover_id!=-1){_canvas.style.cursor='pointer';}else{_canvas.style.cursor='auto';}
|
||||
highlightEntries();};function startAnime(){_physics.onUpdate(render);_physics.play()
|
||||
$('body').attr('corpus','map-ready').trigger({'type':'corpus-map-ready','playlist':_playlist});};init();}
|
||||
$(document).ready(function($){if(drupalSettings.path.isFront&&!edlp_mobile.device_is_mobile){var edlpcorpus=new EdlpCorpus();}});})(jQuery,Drupal,drupalSettings);
|
||||
@@ -0,0 +1,38 @@
|
||||
|
||||
require=(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){var _=require('./common'),Vector=require('./vector');function Attraction(a,b,k,d){this.a=a;this.b=b;this.constant=k;this.on=true;this.distanceMin=d;this.distanceMinSquared=d*d;}
|
||||
_.extend(Attraction.prototype,{update:function(){var a=this.a,b=this.b;if(!this.on||(a.fixed&&b.fixed)){return;}
|
||||
var a2bx=a.position.x-b.position.x;var a2by=a.position.y-b.position.y;var a2b=new Vector().sub(a.position,b.position);var a2bdistanceSquared=Math.max(a2b.lengthSquared(),this.distanceMinSquared);var force=(this.constant*a.mass*b.mass)/a2bdistanceSquared;var length=Math.sqrt(a2bdistanceSquared);if(force===0||length===0){a2b.clear();}else{a2b.divideScalar(length).multiplyScalar(force);}
|
||||
if(!a.fixed){a.force.subSelf(a2b);}
|
||||
if(!b.fixed){b.force.addSelf(a2b);}
|
||||
return this;},resting:function(){var a=this.a;var b=this.b;var l=this.distanceMin;return!this.on||(a.fixed&&b.fixed)||(a.fixed&&b.position.distanceTo(a.position)<=l&&b.resting())||(b.fixed&&a.position.distanceTo(b.position)<=l&&a.resting());}});module.exports=Attraction;},{"./common":8,"./vector":12}],2:[function(require,module,exports){var _=require('./common'),Vector=require('./vector');function Integrator(s){this.s=s;this.originalPositions=[];this.originalVelocities=[];this.k1Forces=[];this.k1Velocities=[];this.k2Forces=[];this.k2Velocities=[];this.k3Forces=[];this.k3Velocities=[];this.k4Forces=[];this.k4Velocities=[];}
|
||||
_.extend(Integrator.prototype,{allocateParticles:function(){while(this.s.particles.length>this.originalPositions.length){this.originalPositions.push(new Vector());this.originalVelocities.push(new Vector());this.k1Forces.push(new Vector());this.k1Velocities.push(new Vector());this.k2Forces.push(new Vector());this.k2Velocities.push(new Vector());this.k3Forces.push(new Vector());this.k3Velocities.push(new Vector());this.k4Forces.push(new Vector());this.k4Velocities.push(new Vector());}
|
||||
return this;},step:function(dt){var s=this.s;var p,x,y;this.allocateParticles();_.each(s.particles,function(p,i){if(!p.fixed){this.originalPositions[i].copy(p.position);this.originalVelocities[i].copy(p.velocity);}
|
||||
p.force.clear();},this);s.applyForces();_.each(s.particles,function(p,i){if(!p.fixed){this.k1Forces[i].copy(p.force);this.k1Velocities[i].copy(p.velocity);}
|
||||
p.force.clear();},this);_.each(s.particles,function(p,i){if(!p.fixed){var op=this.originalPositions[i];var k1v=this.k1Velocities[i];x=op.x+k1v.x*0.5*dt;y=op.y+k1v.y*0.5*dt;p.position.set(x,y);var ov=this.originalVelocities[i];var k1f=this.k1Forces[i];x=ov.x+k1f.x*0.5*dt/p.mass;y=ov.y+k1f.y*0.5*dt/p.mass;p.velocity.set(x,y);}},this);s.applyForces();_.each(s.particles,function(p,i){if(!p.fixed){this.k2Forces[i].copy(p.force);this.k2Velocities[i].copy(p.velocity);}
|
||||
p.force.clear();},this);_.each(s.particles,function(p,i){if(!p.fixed){var op=this.originalPositions[i];var k2v=this.k2Velocities[i];p.position.set(op.x+k2v.x*0.5*dt,op.y+k2v.y*0.5*dt);var ov=this.originalVelocities[i];var k2f=this.k2Forces[i];p.velocity.set(ov.x+k2f.x*0.5*dt/p.mass,ov.y+k2f.y*0.5*dt/p.mass);}},this);s.applyForces();_.each(s.particles,function(p,i){if(!p.fixed){this.k3Forces[i].copy(p.force);this.k3Velocities[i].copy(p.velocity);}
|
||||
p.force.clear();},this);_.each(s.particles,function(p,i){if(!p.fixed){var op=this.originalPositions[i];var k3v=this.k3Velocities[i];p.position.set(op.x+k3v.x*dt,op.y+k3v.y*dt)
|
||||
var ov=this.originalVelocities[i];var k3f=this.k3Forces[i];p.velocity.set(ov.x+k3f.x*dt/p.mass,ov.y+k3f.y*dt/p.mass);}},this);s.applyForces();_.each(s.particles,function(p,i){if(!p.fixed){this.k4Forces[i].copy(p.force);this.k4Velocities[i].copy(p.velocity);}},this);_.each(s.particles,function(p,i){p.age+=dt;if(!p.fixed){var op=this.originalPositions[i];var k1v=this.k1Velocities[i];var k2v=this.k2Velocities[i];var k3v=this.k3Velocities[i];var k4v=this.k4Velocities[i];var x=op.x+dt/6.0*(k1v.x+2.0*k2v.x+2.0*k3v.x+k4v.x);var y=op.y+dt/6.0*(k1v.y+2.0*k2v.y+2.0*k3v.y+k4v.y);p.position.set(x,y);var ov=this.originalVelocities[i];var k1f=this.k1Forces[i];var k2f=this.k2Forces[i];var k3f=this.k3Forces[i];var k4f=this.k4Forces[i];x=ov.x+dt/(6.0*p.mass)*(k1f.x+2.0*k2f.x+2.0*k3f.x+k4f.x);y=ov.y+dt/(6.0*p.mass)*(k1f.y+2.0*k2f.y+2.0*k3f.y+k4f.y);p.velocity.set(x,y);}},this);return this;}});module.exports=Integrator;},{"./common":8,"./vector":12}],3:[function(require,module,exports){var _=require('./common'),Vector=require('./vector');function Particle(mass){this.position=new Vector();this.velocity=new Vector();this.force=new Vector();this.mass=mass;this.fixed=false;this.age=0;this.dead=false;}
|
||||
_.extend(Particle.prototype,{distanceTo:function(p){return this.position.distanceTo(p.position);},makeFixed:function(){this.fixed=true;this.velocity.clear();return this;},reset:function(){this.age=0;this.dead=false;this.position.clear();this.velocity.clear();this.force.clear();this.mass=1.0;return this;},resting:function(){return this.fixed||this.velocity.isZero()&&this.force.isZero();}});module.exports=Particle;},{"./common":8,"./vector":12}],4:[function(require,module,exports){var _=require('./common'),Vector=require('./Vector'),Particle=require('./Particle'),Spring=require('./Spring'),Attraction=require('./Attraction'),Integrator=require('./Integrator');function ParticleSystem(){this.__equilibriumCriteria={particles:true,springs:true,attractions:true};this.__equilibrium=false;this.__optimized=false;this.particles=[];this.springs=[];this.attractions=[];this.forces=[];this.integrator=new Integrator(this);this.hasDeadParticles=false;var args=arguments.length;if(args===1){this.gravity=new Vector(0,arguments[0]);this.drag=ParticleSystem.DEFAULT_DRAG;}else if(args===2){this.gravity=new Vector(0,arguments[0]);this.drag=arguments[1];}else if(args===3){this.gravity=new Vector(arguments[0],arguments[1]);this.drag=arguments[3];}else{this.gravity=new Vector(0,ParticleSystem.DEFAULT_GRAVITY);this.drag=ParticleSystem.DEFAULT_DRAG;}}
|
||||
_.extend(ParticleSystem,{DEFAULT_GRAVITY:0,DEFAULT_DRAG:0.001,Attraction:Attraction,Integrator:Integrator,Particle:Particle,Spring:Spring,Vector:Vector});_.extend(ParticleSystem.prototype,{optimize:function(b){this.__optimized=!!b;return this;},setGravity:function(x,y){this.gravity.set(x,y);return this;},setEquilibriumCriteria:function(particles,springs,attractions){this.__equilibriumCriteria.particles=!!particles;this.__equilibriumCriteria.springs=!!springs;this.__equilibriumCriteria.attractions=!!attractions;},tick:function(){this.integrator.step(arguments.length===0?1:arguments[0]);if(this.__optimized){this.__equilibrium=!this.needsUpdate();}
|
||||
return this;},needsUpdate:function(){var i=0;if(this.__equilibriumCriteria.particles){for(i=0,l=this.particles.length;i<l;i++){if(!this.particles[i].resting()){return true;}}}
|
||||
if(this.__equilibriumCriteria.springs){for(i=0,l=this.springs.length;i<l;i++){if(!this.springs[i].resting()){return true;}}}
|
||||
if(this.__equilibriumCriteria.attractions){for(i=0,l=this.attractions.length;i<l;i++){if(!this.attractions[i].resting()){return true;}}}
|
||||
return false;},addParticle:function(p){this.particles.push(p);return this;},addSpring:function(s){this.springs.push(s);return this;},addAttraction:function(a){this.attractions.push(a);return this;},makeParticle:function(m,x,y){var mass=_.isNumber(m)?m:1.0;var x=x||0;var y=y||0;var p=new Particle(mass);p.position.set(x,y);this.addParticle(p);return p;},makeSpring:function(a,b,k,d,l){var s=new Spring(a,b,k,d,l);this.addSpring(s);return s;},makeAttraction:function(a,b,k,d){var a=new Attraction(a,b,k,d);this.addAttraction(a);return a;},clear:function(){this.particles.length=0;this.springs.length=0;this.attractions.length=0;},applyForces:function(){if(!this.gravity.isZero()){_.each(this.particles,function(p){p.force.addSelf(this.gravity);},this);}
|
||||
var t=new Vector();_.each(this.particles,function(p){t.set(p.velocity.x*-1*this.drag,p.velocity.y*-1*this.drag);p.force.addSelf(t);},this);_.each(this.springs,function(s){s.update();});_.each(this.attractions,function(a){a.update();});_.each(this.forces,function(f){f.update();});return this;},clearForces:function(){_.each(this.particles,function(p){p.clear();});return this;}});module.exports=ParticleSystem;},{"./Attraction":1,"./Integrator":2,"./Particle":3,"./Spring":6,"./Vector":7,"./common":8}],5:[function(require,module,exports){var _=require('./common'),raf=require('./requestAnimationFrame'),ParticleSystem=require('./ParticleSystem');var updates=[];function Physics(){var _this=this;this.playing=false;ParticleSystem.apply(this,arguments);this.animations=[];this.equilibriumCallbacks=[];update.call(this);}
|
||||
_.extend(Physics,ParticleSystem,{superclass:ParticleSystem});_.extend(Physics.prototype,ParticleSystem.prototype,{play:function(){if(this.playing){return this;}
|
||||
this.playing=true;this.__equilibrium=false;update.call(this);return this;},pause:function(){this.playing=false;return this;},toggle:function(){if(this.playing){this.pause();}else{this.play();}
|
||||
return this;},onUpdate:function(func){if(_.indexOf(this.animations,func)>=0||!_.isFunction(func)){return this;}
|
||||
this.animations.push(func);return this;},onEquilibrium:function(func){if(_.indexOf(this.equilibriumCallbacks,func)>=0||!_.isFunction(func)){return this;}
|
||||
this.equilibriumCallbacks.push(func);return this;},update:function(){if(!this.__equilibrium){return this;}
|
||||
this.__equilibrium=false;if(this.playing){update.call(this);}
|
||||
return this;}});function update(){var _this=this;this.tick();_.each(this.animations,function(a){a();});if((this.__optimized&&!this.__equilibrium||!this.__optimized)&&this.playing){raf(function(){update.call(_this);});}
|
||||
if(this.__optimized&&this.__equilibrium){_.each(this.equilibriumCallbacks,function(a){a();});}}
|
||||
module.exports=Physics;},{"./ParticleSystem":4,"./common":8,"./requestAnimationFrame":11}],6:[function(require,module,exports){var _=require('./common'),Vector=require('./vector');function Spring(a,b,k,d,l){this.constant=k;this.damping=d;this.length=l;this.a=a;this.b=b;this.on=true;}
|
||||
_.extend(Spring.prototype,{currentLength:function(){return this.a.position.distanceTo(this.b.position);},update:function(){var a=this.a;var b=this.b;if(!(this.on&&(!a.fixed||!b.fixed)))return this;var a2b=new Vector().sub(a.position,b.position);var d=a2b.length();if(d===0){a2b.clear();}else{a2b.divideScalar(d);}
|
||||
var fspring=-1*(d-this.length)*this.constant;var va2b=new Vector().sub(a.velocity,b.velocity);var fdamping=-1*this.damping*va2b.dot(a2b);var fr=fspring+fdamping;a2b.multiplyScalar(fr);if(!a.fixed){a.force.addSelf(a2b);}
|
||||
if(!b.fixed){b.force.subSelf(a2b);}
|
||||
return this;},resting:function(){var a=this.a;var b=this.b;var l=this.length;return!this.on||(a.fixed&&b.fixed)||(a.fixed&&(l===0?b.position.equals(a.position):b.position.distanceTo(a.position)<=l)&&b.resting())||(b.fixed&&(l===0?a.position.equals(b.position):a.position.distanceTo(b.position)<=l)&&a.resting());}});module.exports=Spring;},{"./common":8,"./vector":12}],7:[function(require,module,exports){var _=require('./common');function Vector(x,y){this.x=x||0;this.y=y||0;}
|
||||
_.extend(Vector.prototype,{set:function(x,y){this.x=x;this.y=y;return this;},copy:function(v){this.x=v.x;this.y=v.y;return this;},clear:function(){this.x=0;this.y=0;return this;},clone:function(){return new Vector(this.x,this.y);},add:function(v1,v2){this.x=v1.x+v2.x;this.y=v1.y+v2.y;return this;},addSelf:function(v){this.x+=v.x;this.y+=v.y;return this;},sub:function(v1,v2){this.x=v1.x-v2.x;this.y=v1.y-v2.y;return this;},subSelf:function(v){this.x-=v.x;this.y-=v.y;return this;},multiplySelf:function(v){this.x*=v.x;this.y*=v.y;return this;},multiplyScalar:function(s){this.x*=s;this.y*=s;return this;},multiplyScalarXY:function(sx,sy){this.x*=sx;this.y*=sy;return this;},divideScalar:function(s){if(s){this.x/=s;this.y/=s;}else{this.set(0,0);}
|
||||
return this;},negate:function(){return this.multiplyScalar(-1);},dot:function(v){return this.x*v.x+this.y*v.y;},lengthSquared:function(){return this.x*this.x+this.y*this.y;},length:function(){return Math.sqrt(this.lengthSquared());},normalize:function(){return this.divideScalar(this.length());},distanceTo:function(v){return Math.sqrt(this.distanceToSquared(v));},distanceToSquared:function(v){var dx=this.x-v.x,dy=this.y-v.y;return dx*dx+dy*dy;},setLength:function(l){return this.normalize().multiplyScalar(l);},equals:function(v){return(this.distanceTo(v)<0.0001);},lerp:function(v,t){var x=(v.x-this.x)*t+this.x;var y=(v.y-this.y)*t+this.y;return this.set(x,y);},isZero:function(){return(this.length()<0.0001);}});module.exports=Vector;},{"./common":8}],8:[function(require,module,exports){var breaker={};var ArrayProto=Array.prototype;var ObjProto=Object.prototype;var hasOwnProperty=ObjProto.hasOwnProperty;var slice=ArrayProto.slice;var nativeForEach=ArrayProto.forEach;var nativeIndexOf=ArrayProto.indexOf;var toString=ObjProto.toString;var has=function(obj,key){return hasOwnProperty.call(obj,key);};var each=function(obj,iterator,context){if(obj==null)return;if(nativeForEach&&obj.forEach===nativeForEach){obj.forEach(iterator,context);}else if(obj.length===+obj.length){for(var i=0,l=obj.length;i<l;i++){if(i in obj&&iterator.call(context,obj[i],i,obj)===breaker)return;}}else{for(var key in obj){if(_.has(obj,key)){if(iterator.call(context,obj[key],key,obj)===breaker)return;}}}};var identity=function(value){return value;};var sortedIndex=function(array,obj,iterator){iterator||(iterator=identity);var low=0,high=array.length;while(low<high){var mid=(low+high)>>1;iterator(array[mid])<iterator(obj)?low=mid+1:high=mid;}
|
||||
return low;};module.exports={has:has,each:each,extend:function(obj){each(slice.call(arguments,1),function(source){for(var prop in source){obj[prop]=source[prop];}});return obj;},indexOf:function(array,item,isSorted){if(array==null)return-1;var i,l;if(isSorted){i=sortedIndex(array,item);return array[i]===item?i:-1;}
|
||||
if(nativeIndexOf&&array.indexOf===nativeIndexOf)return array.indexOf(item);for(i=0,l=array.length;i<l;i++)if(i in array&&array[i]===item)return i;return-1;},sortedIndex:sortedIndex,identity:identity,isNumber:function(obj){return toString.call(obj)=='[object Number]';},isFunction:function(obj){return toString.call(obj)=='[object Function]'||typeof obj=='function';},isUndefined:function(obj){return obj===void 0;},isNull:function(obj){return obj===null;}};},{}],"H99CHA":[function(require,module,exports){var root=(function(){return this;})(),previousShortcut=root.Physics;module.exports=root.Physics=require('./Physics');},{"./Physics":5}],"physics":[function(require,module,exports){module.exports=require('H99CHA');},{}],11:[function(require,module,exports){module.exports=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(callback){window.setTimeout(callback,1000/60);};},{}],12:[function(require,module,exports){module.exports=require(7)},{"./common":8}]},{},["H99CHA"])
|
||||
@@ -0,0 +1 @@
|
||||
canvas#corpus-map{position:absolute;-webkit-box-sizing:border-box;box-sizing:border-box;top:0;left:0;z-index:0}canvas#corpus-map.de-activated{background-color:#f4f4f4}div.node-popup{z-index:10;position:absolute;-webkit-box-sizing:content-box;box-sizing:content-box;width:300px;min-height:30px;top:60%;left:30%;pointer-events:none}div.node-popup .inner{padding:.6em;outline:red solid 1px;background-color:#fff}div.node-popup:before{content:"";position:absolute;width:60px;height:0;border-top:1px solid red}div.node-popup[pos=bottom-right]{-webkit-transform:translateY(42px) translateX(42px);transform:translateY(42px) translateX(42px)}div.node-popup[pos=bottom-right]:before{top:-1px;left:-61px;-webkit-transform-origin:bottom right;transform-origin:bottom right;-webkit-transform:rotateZ(45deg);transform:rotateZ(45deg)}div.node-popup[pos=bottom-left]{-webkit-transform:translateX(-100%) translateY(42px) translateX(-42px);transform:translateX(-100%) translateY(42px) translateX(-42px)}div.node-popup[pos=bottom-left]:before{top:calc(100% +1px);left:100%;-webkit-transform-origin:top left;transform-origin:top left;-webkit-transform:rotateZ(-45deg);transform:rotateZ(-45deg)}div.node-popup[pos=top-left]{-webkit-transform:translateY(-100%) translateX(-100%) translateY(-42px) translateX(-42px);transform:translateY(-100%) translateX(-100%) translateY(-42px) translateX(-42px)}div.node-popup[pos=top-left]:before{bottom:0;left:100%;-webkit-transform-origin:top left;transform-origin:top left;-webkit-transform:rotateZ(45deg);transform:rotateZ(45deg)}div.node-popup[pos=top-right]{-webkit-transform:translateY(-100%) translateY(-42px) translateX(42px);transform:translateY(-100%) translateY(-42px) translateX(42px)}div.node-popup[pos=top-right]:before{top:calc(100% + 1px);left:-61px;-webkit-transform-origin:top right;transform-origin:top right;-webkit-transform:rotateZ(-45deg);transform:rotateZ(-45deg)}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,87 @@
|
||||
// @Author: Bachir Soussi Chiadmi <bach>
|
||||
// @Date: 18-12-2017
|
||||
// @Email: bachir@figureslibres.io
|
||||
// @Filename: corpus.scss
|
||||
// @Last modified by: bach
|
||||
// @Last modified time: 20-12-2017
|
||||
// @License: GPL-V3
|
||||
|
||||
canvas#corpus-map{
|
||||
&.de-activated{
|
||||
background-color: rgb(244, 244, 244);
|
||||
}
|
||||
position: absolute;
|
||||
box-sizing: border-box;
|
||||
top:0; left:0;
|
||||
// width:100%; height:100%;
|
||||
z-index:0;
|
||||
}
|
||||
|
||||
|
||||
// _ _ _ ___ _ _
|
||||
// | \| |___ __| |___| _ \___ _ __| | | |_ __
|
||||
// | .` / _ \/ _` / -_) _/ _ \ '_ \ |_| | '_ \
|
||||
// |_|\_\___/\__,_\___|_| \___/ .__/\___/| .__/
|
||||
// |_| |_|
|
||||
div.node-popup{
|
||||
// display:none;
|
||||
z-index: 10;
|
||||
position: absolute;
|
||||
box-sizing: content-box;
|
||||
width:300px; min-height: 30px;
|
||||
pointer-events: none;
|
||||
top:60%; left:30%;
|
||||
pointer-events: none;
|
||||
|
||||
.inner{
|
||||
padding:0.6em;
|
||||
outline: 1px solid red;
|
||||
background-color: white;
|
||||
}
|
||||
|
||||
$w:60px; // diagonal length
|
||||
$s:($w *1.4)*0.5; // side given the diagonal (1.4 is the square root of 2)
|
||||
&:before{
|
||||
content:"";
|
||||
position: absolute;
|
||||
width: $w; height:0;
|
||||
border-top: 1px solid red;
|
||||
}
|
||||
// pos attributes refers to where the popup appears
|
||||
&[pos="bottom-right"]{
|
||||
transform: translateY($s) translateX($s);
|
||||
&:before{
|
||||
top:-1px;
|
||||
left: -$w - 1px;
|
||||
transform-origin: bottom right;
|
||||
transform: rotateZ(45deg);
|
||||
}
|
||||
}
|
||||
&[pos="bottom-left"]{
|
||||
transform: translateX(-100%) translateY($s) translateX(-$s);
|
||||
&:before{
|
||||
top:calc(100% +1px);
|
||||
left: 100%;
|
||||
transform-origin: top left;
|
||||
transform: rotateZ(-45deg);
|
||||
}
|
||||
}
|
||||
&[pos="top-left"]{
|
||||
transform: translateY(-100%) translateX(-100%) translateY(-$s) translateX(-$s);
|
||||
&:before{
|
||||
bottom:0;
|
||||
left: 100%;
|
||||
transform-origin: top left;
|
||||
transform: rotateZ(45deg);
|
||||
}
|
||||
}
|
||||
&[pos="top-right"]{
|
||||
transform: translateY(-100%) translateY(-$s) translateX($s);
|
||||
&:before{
|
||||
top:calc(100% + 1px);
|
||||
left: - ($w +1px);
|
||||
transform-origin: top right;
|
||||
transform: rotateZ(-45deg);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"name": "edlp_d8_corpus",
|
||||
"version": "1.0.0",
|
||||
"authors": [
|
||||
"Bachir Soussi Chiadmi <bachir@figureslibres.io>"
|
||||
],
|
||||
"license": "MIT",
|
||||
"homepage": "http://encyclopediedelaparole.org",
|
||||
"ignore": [
|
||||
"**/.*",
|
||||
"node_modules",
|
||||
"bower_components",
|
||||
"test",
|
||||
"tests"
|
||||
],
|
||||
"dependencies": {
|
||||
"physics": "latest"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
# @Author: Bachir Soussi Chiadmi <bach>
|
||||
# @Date: 13-12-2017
|
||||
# @Email: bachir@figureslibres.io
|
||||
# @Filename: edlp_corpus.routing.yml
|
||||
# @Last modified by: bach
|
||||
# @Last modified time: 20-12-2017
|
||||
# @License: GPL-V3
|
||||
|
||||
name: Edlp Corpus
|
||||
type: module
|
||||
description: Creates interactive map of corpus for edlp d8.
|
||||
core: 8.x
|
||||
package: Edlp
|
||||
# dependencies:
|
||||
# - migrate_drupal
|
||||
# - migrate_plus
|
||||
# - migrate_tools
|
||||
@@ -0,0 +1,21 @@
|
||||
# @Author: Bachir Soussi Chiadmi <bach>
|
||||
# @Date: 20-12-2017
|
||||
# @Email: bachir@figureslibres.io
|
||||
# @Filename: edlp_corpus.libraries.yml
|
||||
# @Last modified by: bach
|
||||
# @Last modified time: 20-12-2017
|
||||
# @License: GPL-V3
|
||||
|
||||
corpus:
|
||||
version: VERSION
|
||||
css:
|
||||
base:
|
||||
assets/dist/styles/corpus.min.css: {}
|
||||
|
||||
version: VERSION
|
||||
js:
|
||||
assets/dist/scripts/physics.min.js: { scope: footer }
|
||||
assets/dist/scripts/corpus.min.js: { scope: footer }
|
||||
dependencies:
|
||||
- core/drupalSettings
|
||||
- core/jquery
|
||||
@@ -0,0 +1,313 @@
|
||||
<?php
|
||||
# @Author: Bachir Soussi Chiadmi <bach>
|
||||
# @Date: 13-12-2017
|
||||
# @Email: bachir@figureslibres.io
|
||||
# @Filename: edlp_corpus.routing.yml
|
||||
# @Last modified by: bach
|
||||
# @Last modified time: 20-12-2017
|
||||
# @License: GPL-V3
|
||||
|
||||
use Drupal\Core\Entity\EntityInterface;
|
||||
use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
|
||||
use Drupal\Core\Url;
|
||||
use Drupal\Core\Link;
|
||||
use Drupal\workflow\Entity\WorkflowManager;
|
||||
|
||||
|
||||
/**
|
||||
* Implements hook_theme().
|
||||
*/
|
||||
function edlp_corpus_theme($existing, $type, $theme, $path) {
|
||||
// @see https://www.drupal.org/docs/8/theming/twig/create-custom-twig-templates-from-custom-module
|
||||
|
||||
return array(
|
||||
'blockentrees' => array(
|
||||
// 'render element' => '',
|
||||
'file' => 'includes/blockentrees.inc',
|
||||
'variables' => array(
|
||||
'entrees_items' => array(),
|
||||
),
|
||||
),
|
||||
'edlp_corpus_lastdocs' => array(
|
||||
// 'render element' => '',
|
||||
'file' => 'includes/edlp_corpus_lastdocs.inc',
|
||||
'variables' => array(
|
||||
'lastdocs_nodes' => NULL,
|
||||
),
|
||||
),
|
||||
'edlp_corpus_articlesindex' => array(
|
||||
// 'render element' => '',
|
||||
'file' => 'includes/edlp_corpus_articlesindex.inc',
|
||||
'variables' => array(
|
||||
'articles_nodes' => NULL,
|
||||
),
|
||||
),
|
||||
'edlp_corpus_collection' => array(
|
||||
// 'render element' => '',
|
||||
'file' => 'includes/edlp_corpus_collection.inc',
|
||||
'variables' => array(
|
||||
'entrees_terms' => NULL,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* hook_entity_extra_field_info()
|
||||
*/
|
||||
function edlp_corpus_entity_extra_field_info(){
|
||||
$extra = [];
|
||||
$extra['taxonomy_term']['entrees']['display']['index'] = [
|
||||
'label' => t('Index'),
|
||||
'description' => 'Display index of all documents tagued with the term',
|
||||
'weight' => 99,
|
||||
// 'visible' => FALSE,
|
||||
];
|
||||
$extra['taxonomy_term']['entrees']['display']['index-home'] = [
|
||||
'label' => t('Index Home'),
|
||||
'description' => 'Display index of all documents tagued with the term (form home mobile)',
|
||||
'weight' => 99,
|
||||
// 'visible' => FALSE,
|
||||
];
|
||||
$extra['node']['enregistrement']['display']['relations'] = [
|
||||
'label' => t('Relations'),
|
||||
'description' => 'Display enregistrement relations with other content types',
|
||||
'weight' => 99,
|
||||
];
|
||||
return $extra;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_ENTITY_TYPE_view().
|
||||
* @see https://www.amazeelabs.com/en/render-menu-tree-custom-code-drupal-8
|
||||
*/
|
||||
function edlp_corpus_taxonomy_term_view(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display, $view_mode) {
|
||||
$index_display_settings = $display->getComponent('index');
|
||||
$index_home_display_settings = $display->getComponent('index-home');
|
||||
if (!empty($index_display_settings) || !empty($index_home_display_settings)) {
|
||||
// dpm($entity);
|
||||
// dpm($entity->id());
|
||||
$view_builder = \Drupal::entityTypeManager()->getViewBuilder('node');
|
||||
|
||||
$query = \Drupal::entityQuery('node')
|
||||
->condition('status', 1)
|
||||
->condition('type', 'enregistrement')
|
||||
->sort('title')
|
||||
->condition('field_entrees', $entity->id());
|
||||
|
||||
$documents_nids = $query->execute();
|
||||
$documents = entity_load_multiple('node', $documents_nids);
|
||||
|
||||
$documents_list = array (
|
||||
'#theme' => 'item_list',
|
||||
'#items' => [],
|
||||
);
|
||||
if(!empty($index_home_display_settings)){
|
||||
$view_mode = 'index_home';
|
||||
}else{
|
||||
$view_mode = 'index';
|
||||
}
|
||||
foreach($documents as $doc){
|
||||
// remove masqué
|
||||
$sid = WorkflowManager::getCurrentStateId($doc, 'field_workflow');
|
||||
if($sid != 'corpus_documents_publie') continue;
|
||||
// TODO: instead of workflow, just check access
|
||||
// TODO: get the view mode of document nodes from field settings
|
||||
$documents_list['#items'][] = $view_builder->view($doc, $view_mode);
|
||||
}
|
||||
|
||||
// And the last step is to actually build the tree.
|
||||
$build['index'] = array(
|
||||
'#type'=>"container",
|
||||
'#attributes'=>array(
|
||||
'class'=>'index'
|
||||
),
|
||||
'label'=>array(
|
||||
'#type' => 'container',
|
||||
"#markup"=> t("Index"),
|
||||
'#attributes'=>array(
|
||||
'class'=>'field__label'
|
||||
),
|
||||
),
|
||||
'documents'=> $documents_list
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function edlp_corpus_node_view(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display, $view_mode) {
|
||||
if($entity->bundle() == "enregistrement"){
|
||||
$relations_display_settings = $display->getComponent('relations');
|
||||
if(!empty($relations_display_settings)){
|
||||
|
||||
// querying all productions page that have this document in their entity reference "field_documents_liés"
|
||||
$query = \Drupal::entityQuery('node')
|
||||
->condition('status', 1)
|
||||
->condition('type', 'page') // page (production)
|
||||
->exists('field_page_type')
|
||||
->condition('field_documents_lies.target_id', $entity->id(), 'IN');
|
||||
|
||||
$nids = $query->execute();
|
||||
$nodes = entity_load_multiple('node', $nids);
|
||||
// dpm($nodes, '$nodes');
|
||||
|
||||
// build the array of relateds classified by page_type (taxonomy)
|
||||
$relateds = array();
|
||||
foreach ($nodes as $nid => $node) {
|
||||
// $page_type = $node->get('field_page_type')->get(0)->getValue();
|
||||
// dpm($page_type, 'page_type');
|
||||
// $term = entity_load('taxonomy_term', $page_type['target_id']);
|
||||
// dpm($term, 'term');
|
||||
// $relateds[$term->getName()][] = $node->getTitle();
|
||||
$url = Url::fromRoute('entity.node.canonical', ['node'=>$node->id()]);
|
||||
$url->setOptions(array(
|
||||
'attributes' => array(
|
||||
'class' => ['ajax-link'],
|
||||
'data-drupal-link-system-path' => $url->getInternalPath()
|
||||
)
|
||||
));
|
||||
$link = Link::fromTextAndUrl(trim($node->getTitle()), $url);
|
||||
// $relateds[$term->getName()][] = $link;
|
||||
$relateds[] = $link->toRenderable();
|
||||
}
|
||||
// dpm($relateds, 'relateds');
|
||||
|
||||
// if relateds, build the sentence for display and the render array
|
||||
if(count($relateds)){
|
||||
// $relations = '<h3>' . t('This sound is about :') . '</h3>';
|
||||
|
||||
// foreach ($relateds as $cat => $titles) {
|
||||
// // $relations .= '<span class="cat">' . $cat . ' :</span> ' . implode(', ', $titles) . ' | ';
|
||||
// $relations[] =
|
||||
// }
|
||||
|
||||
// $relations = preg_replace('/\s\|\s$/', '', $relations);
|
||||
// $relations .= '</p>';
|
||||
|
||||
$build['relations'] = array(
|
||||
'#type'=>"container",
|
||||
'#attributes'=>array(
|
||||
'class'=>'relations'
|
||||
),
|
||||
'title' => array(
|
||||
"#markup"=> '<h3>' . t('This sound is about :') . '</h3>',
|
||||
),
|
||||
'content' => array (
|
||||
'#theme' => 'item_list',
|
||||
'#items' => $relateds,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Implements hook_page_attachments().
|
||||
* @param array $attachments
|
||||
*/
|
||||
function edlp_corpus_page_attachments(array &$attachments) {
|
||||
|
||||
// css class
|
||||
// :root{
|
||||
// --e-col-130:#4B8F7E;
|
||||
// }
|
||||
|
||||
// javascript list
|
||||
// drupalSettings edlp_corpus{
|
||||
// "e_col_130": "rgb(75, 143, 126)",
|
||||
// }
|
||||
|
||||
|
||||
// get all entries
|
||||
$query = \Drupal::entityQuery('taxonomy_term')
|
||||
->condition('vid', 'entrees');
|
||||
|
||||
$tids = $query->execute();
|
||||
$terms = entity_load_multiple('taxonomy_term', $tids);
|
||||
|
||||
$js_list = [];
|
||||
$css_str = ":root{\n";
|
||||
foreach ($terms as $term) {
|
||||
$tid = $term->id();
|
||||
// get the color value
|
||||
$color = $term->get('field_color')->color;
|
||||
// build colors list
|
||||
$css_str .= "\t".'--e-col-'.$tid.':'.$color.";\n";
|
||||
$js_list['e_col_'.$tid] = $color;
|
||||
}
|
||||
$css_str .= '}';
|
||||
|
||||
// attache css
|
||||
// we should find a better way
|
||||
// https://www.drupal.org/docs/8/creating-custom-modules/adding-stylesheets-css-and-javascript-js-to-a-drupal-8-module
|
||||
$attachments['#attached']['html_head'][] = [
|
||||
[
|
||||
'#type' => 'html_tag',
|
||||
'#tag' => 'style',
|
||||
'#value' => $css_str,
|
||||
],
|
||||
// A key, to make it possible to recognize this HTML element when altering.
|
||||
'edlp_colors',
|
||||
];
|
||||
|
||||
$attachments['#attached']['drupalSettings']['edlp_corpus']['colors'] = $js_list;
|
||||
|
||||
// load corpus
|
||||
$url = Url::fromRoute('edlp_corpus.corpusjson');
|
||||
$attachments['#attached']['drupalSettings']['edlp_corpus']['load_corpus_ajax_url'] = $url->getInternalPath();
|
||||
|
||||
// load articles
|
||||
$url = Url::fromRoute('edlp_corpus.articlesindex');
|
||||
$attachments['#attached']['drupalSettings']['edlp_corpus']['articlesindex_url'] = $url->getInternalPath();
|
||||
|
||||
// random btn link title
|
||||
$attachments['#attached']['drupalSettings']['edlp_corpus']['random_link_title'] = t('Shuffle the selection');
|
||||
}
|
||||
|
||||
|
||||
function _edlp_corpus_invalidate_corpus_cache($node){
|
||||
if($node->getType() == 'enregistrement'){
|
||||
$sid = WorkflowManager::getCurrentStateId($node, 'field_workflow');
|
||||
if($sid == 'corpus_documents_publie'){
|
||||
\Drupal::service('cache_tags.invalidator')->invalidateTags(['rebuild-corpus-cache']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Acts when creating a new entity of a specific type.
|
||||
* This hook runs after a new entity object has just been instantiated.
|
||||
* @param \Drupal\Core\Entity\EntityInterface $entity
|
||||
* The entity object.
|
||||
* @ingroup entity_crud
|
||||
* @see hook_entity_create()
|
||||
*/
|
||||
function edlp_corpus_node_create(EntityInterface $node) {
|
||||
_edlp_corpus_invalidate_corpus_cache($node);
|
||||
}
|
||||
/**
|
||||
* Respond to updates to an entity of a particular type.
|
||||
* This hook runs once the entity storage has been updated. Note that hook
|
||||
* implementations may not alter the stored entity data. Get the original entity
|
||||
* object from $entity->original.
|
||||
* @param \Drupal\Core\Entity\EntityInterface $entity
|
||||
* The entity object.
|
||||
* @ingroup entity_crud
|
||||
* @see hook_entity_update()
|
||||
*/
|
||||
function edlp_corpus_node_update(EntityInterface $node) {
|
||||
_edlp_corpus_invalidate_corpus_cache($node);
|
||||
}
|
||||
/**
|
||||
* Respond to entity deletion.
|
||||
* This hook runs once the entity has been deleted from the storage.
|
||||
* @param \Drupal\Core\Entity\EntityInterface $entity
|
||||
* The entity object for the entity that has been deleted.
|
||||
* @ingroup entity_crud
|
||||
* @see hook_ENTITY_TYPE_delete()
|
||||
*/
|
||||
function edlp_corpus_node_delete(EntityInterface $node) {
|
||||
_edlp_corpus_invalidate_corpus_cache($node);
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
# @Author: Bachir Soussi Chiadmi <bach>
|
||||
# @Date: 13-12-2017
|
||||
# @Email: bachir@figureslibres.io
|
||||
# @Filename: edlp_corpus.routing.yml
|
||||
# @Last modified by: bach
|
||||
# @Last modified time: 20-12-2017
|
||||
# @License: GPL-V3
|
||||
|
||||
edlp_corpus.corpusjson:
|
||||
path: '/edlp/corpus'
|
||||
defaults:
|
||||
_controller: '\Drupal\edlp_corpus\Controller\CorpusController::contentjson'
|
||||
_title: 'Corpus'
|
||||
requirements:
|
||||
_permission: 'access content'
|
||||
|
||||
|
||||
edlp_corpus.lastdocs:
|
||||
path: '/lastdocs'
|
||||
defaults:
|
||||
_controller: '\Drupal\edlp_corpus\Controller\CorpusController::lastdocs'
|
||||
_title: 'Last Docs'
|
||||
requirements:
|
||||
_permission: 'access content'
|
||||
|
||||
edlp_corpus.lastdocsajax:
|
||||
path: '/lastdocs/ajax'
|
||||
defaults:
|
||||
_controller: '\Drupal\edlp_corpus\Controller\CorpusController::lastdocsjson'
|
||||
_title: 'Last docs'
|
||||
requirements:
|
||||
_permission: 'access content'
|
||||
|
||||
edlp_corpus.articlesindex:
|
||||
path: '/articles'
|
||||
defaults:
|
||||
_controller: '\Drupal\edlp_corpus\Controller\CorpusController::articlesindex'
|
||||
_title: 'Articles Index'
|
||||
requirements:
|
||||
_permission: 'access content'
|
||||
|
||||
edlp_corpus.articlesindexajax:
|
||||
path: '/articles/ajax'
|
||||
defaults:
|
||||
_controller: '\Drupal\edlp_corpus\Controller\CorpusController::articlesindexjson'
|
||||
_title: 'Articles Index'
|
||||
requirements:
|
||||
_permission: 'access content'
|
||||
|
||||
edlp_corpus.collection:
|
||||
path: '/collection'
|
||||
defaults:
|
||||
_controller: '\Drupal\edlp_corpus\Controller\CorpusController::collection'
|
||||
_title: 'Collection'
|
||||
requirements:
|
||||
_permission: 'access content'
|
||||
|
||||
edlp_corpus.collectionajax:
|
||||
path: '/collection/ajax'
|
||||
defaults:
|
||||
_controller: '\Drupal\edlp_corpus\Controller\CorpusController::collectionjson'
|
||||
_title: 'Collection'
|
||||
requirements:
|
||||
_permission: 'access content'
|
||||
@@ -0,0 +1,84 @@
|
||||
/**
|
||||
* @Author: Bachir Soussi Chiadmi <bach>
|
||||
* @Date: 20-12-2017
|
||||
* @Email: bachir@figureslibres.io
|
||||
* @Filename: gulpfile.js
|
||||
* @Last modified by: bach
|
||||
* @Last modified time: 20-12-2017
|
||||
* @License: GPL-V3
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
var gulp = require('gulp');
|
||||
var util = require('gulp-util');
|
||||
var sass = require('gulp-sass');
|
||||
var watch = require('gulp-watch');
|
||||
var autoprefixer = require('gulp-autoprefixer');
|
||||
var jsmin = require('gulp-jsmin');
|
||||
var cssmin = require('gulp-cssmin');
|
||||
var rename = require('gulp-rename');
|
||||
var mainBowerFiles = require('main-bower-files');
|
||||
|
||||
function handleError(err) {
|
||||
console.log(err.toString());
|
||||
}
|
||||
|
||||
var config = {
|
||||
production: !!util.env.production
|
||||
}
|
||||
|
||||
gulp.task('scripts', function () {
|
||||
gulp.src('./assets/scripts/corpus.js')
|
||||
// .pipe(config.production ? jsmin() : util.noop())
|
||||
.pipe(jsmin())
|
||||
.pipe(rename({suffix: '.min'}))
|
||||
.pipe(gulp.dest('./assets/dist/scripts/'));
|
||||
});
|
||||
|
||||
gulp.task('styles', function () {
|
||||
gulp.src('./assets/styles/corpus.scss')
|
||||
.pipe(sass().on('error', sass.logError))
|
||||
.pipe(autoprefixer({
|
||||
browsers: ['last 2 versions'],
|
||||
cascade: false
|
||||
})).on('error', handleError)
|
||||
// .pipe(config.production ? cssmin() : util.noop())
|
||||
.pipe(cssmin())
|
||||
.pipe(rename({suffix: '.min'}))
|
||||
.pipe(gulp.dest('./assets/dist/styles/'));
|
||||
});
|
||||
|
||||
gulp.task('bower', function() {
|
||||
gulp.src(mainBowerFiles({
|
||||
"overrides":{
|
||||
"jquery":{
|
||||
"ignore":true
|
||||
},
|
||||
"physics": {
|
||||
"main": [
|
||||
'./build/physics.js'
|
||||
]
|
||||
},
|
||||
"EaselJS":{
|
||||
"ignore":true
|
||||
// "main": [
|
||||
// './lib/easeljs.js'
|
||||
// ]
|
||||
}
|
||||
}
|
||||
}))
|
||||
.pipe(config.production ? jsmin() : util.noop())
|
||||
.pipe(rename({suffix: '.min'}))
|
||||
.pipe(gulp.dest('./assets/dist/bower/'));
|
||||
});
|
||||
|
||||
// default gulp task
|
||||
// gulp.task('default', ['bower', 'scripts', 'styles'], function() {
|
||||
// gulp.watch('./assets/styles/*.scss', ['styles']);
|
||||
// // gulp.watch('./assets/styles/*/*.scss', ['styles']);
|
||||
// gulp.watch('./assets/scripts/*.js', ['scripts']);
|
||||
// });
|
||||
gulp.task('default', function() {
|
||||
console.log('Not used anymore, use the global, multi module gulp file one folder ahead');
|
||||
});
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
|
||||
function template_preprocess_blockentrees(&$vars){
|
||||
|
||||
$entrees = array (
|
||||
'#theme' => 'item_list',
|
||||
'#items' => array(),
|
||||
);
|
||||
|
||||
foreach ($vars['entrees_items'] as $entree) {
|
||||
|
||||
$tid = $entree['tid'];
|
||||
|
||||
$term_link = $entree['term_link']->toRenderable();
|
||||
$term_link['#prefix'] = '<span class="oblique-wrapper">';
|
||||
$term_link['#suffix'] = "</span>";
|
||||
|
||||
$index_link = $entree['index_link']->toRenderable();
|
||||
$index_link['#prefix'] = '<span class="oblique-wrapper">';
|
||||
$index_link['#suffix'] = "</span>";
|
||||
|
||||
$notice_link = $entree['notice_link']->toRenderable();
|
||||
$notice_link['#prefix'] = '<span class="oblique-wrapper">';
|
||||
$notice_link['#suffix'] = "</span>";
|
||||
|
||||
$entree = array(
|
||||
'#wrapper_attributes' => array(
|
||||
'class' => array('term-'.$tid, 'entree'),
|
||||
'tid' => $tid
|
||||
),
|
||||
'term_link' => $term_link,
|
||||
'entree_content' => array(
|
||||
'#type' => 'container',
|
||||
'#attributes' => array(
|
||||
'class' => 'entree-content'
|
||||
),
|
||||
'index_link' => $index_link,
|
||||
'notice_link' => $notice_link,
|
||||
'description' => array(
|
||||
'#type' => 'container',
|
||||
'#markup' => $entree['description'],
|
||||
'#attributes' => array('class'=>'term-description')
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
// if (isset($entrees) && count($entrees) == count($terms)-3) {
|
||||
// $entree['#wrapper_attributes']['class'][] = 'opened';
|
||||
// }
|
||||
|
||||
// dpm($entree);
|
||||
|
||||
$entrees['#items'][] = $entree;
|
||||
}
|
||||
|
||||
$vars['entrees'] = render($entrees);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
// use Drupal\Core\Url;
|
||||
|
||||
function template_preprocess_edlp_corpus_articlesindex(&$vars){
|
||||
// dpm($vars);
|
||||
/*
|
||||
@see https://www.drupal8.ovh/index.php/en/tutoriels/339/render-a-node-or-an-entity
|
||||
*/
|
||||
$view_builder = \Drupal::entityTypeManager()->getViewBuilder('node');
|
||||
|
||||
if(count($vars['articles_nodes'])){
|
||||
$articles_list = array (
|
||||
'#theme' => 'item_list',
|
||||
'#items' => [],
|
||||
);
|
||||
foreach($vars['articles_nodes'] as $node){
|
||||
$articles_list['#items'][] = $view_builder->view($node, 'index');
|
||||
}
|
||||
|
||||
$vars['articles'] = array(
|
||||
"#type"=>"container",
|
||||
"#attributes"=>array(
|
||||
"class"=>['articles']
|
||||
),
|
||||
"#markup"=>"<h3>".t("Articles")."</h3>",
|
||||
"articles"=>$articles_list
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
use Drupal\Core\Url;
|
||||
|
||||
function template_preprocess_edlp_corpus_collection(&$vars){
|
||||
$term_view_builder = \Drupal::entityTypeManager()->getViewBuilder('taxonomy_term');
|
||||
|
||||
if(isset($vars['entrees_terms'])){
|
||||
$entrees = array(
|
||||
'#type'=>"container",
|
||||
// '#attributes' => array(
|
||||
// 'id' => array('collection'),
|
||||
// ),
|
||||
'#prefix' => '<div id="collection"></div>',
|
||||
'title'=>array(
|
||||
'#markup'=>"<h3>".t("Collection")."</h3>",
|
||||
),
|
||||
'list'=> array(
|
||||
'#theme' => 'item_list',
|
||||
'#items' => [],
|
||||
),
|
||||
);
|
||||
foreach($vars['entrees_terms'] as $term){
|
||||
$entrees['list']['#items'][] = $term_view_builder->view($term, 'home_mobile');
|
||||
}
|
||||
$vars['entrees'] = render($entrees);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
// use Drupal\Core\Url;
|
||||
|
||||
function template_preprocess_edlp_corpus_lastdocs(&$vars){
|
||||
// dpm($vars);
|
||||
/*
|
||||
@see https://www.drupal8.ovh/index.php/en/tutoriels/339/render-a-node-or-an-entity
|
||||
*/
|
||||
$view_builder = \Drupal::entityTypeManager()->getViewBuilder('node');
|
||||
|
||||
if(count($vars['lastdocs_nodes'])){
|
||||
$lastdocs_list = array (
|
||||
'#theme' => 'item_list',
|
||||
'#items' => [],
|
||||
);
|
||||
foreach($vars['lastdocs_nodes'] as $node){
|
||||
$lastdocs_list['#items'][] = $view_builder->view($node, 'lastdocs');
|
||||
}
|
||||
|
||||
$vars['lastdocs'] = array(
|
||||
"#type"=>"container",
|
||||
"#attributes"=>array(
|
||||
"class"=>['lastdocs']
|
||||
),
|
||||
"#markup"=>"<h3>".t("Recently uploaded")."</h3>",
|
||||
"lastdocs"=>$lastdocs_list
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"name": "edlpd8theme",
|
||||
"version": "0.0.1",
|
||||
"description": "A theme for drupal.",
|
||||
"main": "gulpfile.js",
|
||||
"author": "Bachir Soussi Chiadmi",
|
||||
"license": "GPLv3",
|
||||
"homepage": "https://encyclopediedelaparole.org",
|
||||
"devDependencies": {
|
||||
"gulp": "latest",
|
||||
"gulp-autoprefixer": "latest",
|
||||
"gulp-cssmin": "latest",
|
||||
"gulp-jsmin": "latest",
|
||||
"gulp-json-to-sass": "0.0.4",
|
||||
"gulp-rename": "latest",
|
||||
"gulp-sass": "latest",
|
||||
"gulp-strip-debug": "latest",
|
||||
"gulp-util": "latest",
|
||||
"gulp-watch": "latest",
|
||||
"main-bower-files": "^2.13.1"
|
||||
},
|
||||
"dependencies": {}
|
||||
}
|
||||
@@ -0,0 +1,472 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\edlp_corpus\Controller;
|
||||
|
||||
use Drupal\Core\Controller\ControllerBase;
|
||||
use Drupal\Core\Language\LanguageInterface;
|
||||
use Drupal\workflow\Entity\WorkflowManager;
|
||||
use Drupal\Core\Url;
|
||||
use Drupal\File\Entity\File;
|
||||
use Drupal\taxonomy\Entity\Term;
|
||||
// use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Drupal\Core\Cache\CacheableJsonResponse;
|
||||
use Drupal\Core\Cache\CacheableMetadata;
|
||||
use Drupal\core\render\RenderContext;
|
||||
use Drupal\Core\Ajax\AjaxResponse;
|
||||
|
||||
|
||||
class CorpusController extends ControllerBase {
|
||||
|
||||
|
||||
/**
|
||||
* Display the markup.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function contentjson() {
|
||||
|
||||
|
||||
// @see https://www.droptica.com/blog/drupal-8-restjson-integration-simple-javascript-application/
|
||||
// @see https://www.sitepoint.com/drupal-8-version-entityfieldquery/
|
||||
// @see https://www.frobiovox.com/posts/2016/03/28/simplify-drupal-8-field-value-calls.html
|
||||
// @see https://chromatichq.com/blog/dependency-injection-drupal-8-plugins
|
||||
|
||||
// Get a node storage object.
|
||||
// $file_storage = \Drupal::entityManager()->getStorage('node');
|
||||
|
||||
$current_langcode = \Drupal::languageManager()->getCurrentLanguage()->getId();
|
||||
|
||||
$config = \Drupal::config('system.site');
|
||||
|
||||
$query = \Drupal::entityQuery('node')
|
||||
->condition('status', 1)
|
||||
->condition('type', 'enregistrement');
|
||||
|
||||
$nids = $query->execute();
|
||||
$nodes = entity_load_multiple('node', $nids);
|
||||
|
||||
$view_builder = \Drupal::entityTypeManager()->getViewBuilder('node');
|
||||
|
||||
$nodes_data = [];
|
||||
foreach ($nodes as $node) {
|
||||
// this would be ideal but it's too heavy to load : the whole ajax json goes from 138kb to 1.23Md (even optimized)...
|
||||
// $node_builder = $view_builder->view($node, 'popup');
|
||||
// $node = $n->getTranslation($current_langcode);
|
||||
|
||||
// remove masqué
|
||||
$sid = WorkflowManager::getCurrentStateId($node, 'field_workflow');
|
||||
if($sid != 'corpus_documents_publie') continue;
|
||||
|
||||
$entrees = [];
|
||||
foreach ($node->get('field_entrees')->getValue() as $key => $term) {
|
||||
$entrees[] = $term['target_id'];
|
||||
}
|
||||
// remove if no entries
|
||||
if(!count($entrees)) continue;
|
||||
|
||||
if ($node->hasTranslation($current_langcode)
|
||||
&& !$node->getTranslation($current_langcode)->field_description->isEmpty()) {
|
||||
$description_values = $node->getTranslation($current_langcode)->get('field_description')->getValue();
|
||||
}else{
|
||||
$description_values = $node->get('field_description')->getValue();
|
||||
}
|
||||
$description = count($description_values) ? $description_values[0]['value'] : "";
|
||||
// dpm($description);
|
||||
|
||||
$field_son_values = $node->get('field_son')->getValue();
|
||||
$audio_fid = count($field_son_values) ? $field_son_values[0]['target_id'] : "";
|
||||
$audio_file = \Drupal\file\Entity\File::load($audio_fid);
|
||||
$audio_url = null;
|
||||
// if node don't have a sound file atteched, skip it
|
||||
if(!$audio_file) continue;
|
||||
|
||||
$son_uri = $audio_file->getFileUri();
|
||||
$audio_url = file_create_url($son_uri);
|
||||
|
||||
// has article ?
|
||||
$article_value = $node->body->getValue();
|
||||
$has_article = count($article_value);
|
||||
// if($has_article && $article_value[0]['value'] == "")
|
||||
// dpm($article_value);
|
||||
|
||||
$document_url = \Drupal::service('renderer')->executeInRenderContext(new RenderContext(), function () use ($node, $current_langcode) {
|
||||
if ($node->hasTranslation($current_langcode)){
|
||||
return $node->getTranslation($current_langcode)->toUrl()->toString();
|
||||
}else{
|
||||
return $node->toUrl()->toString();
|
||||
}
|
||||
});
|
||||
|
||||
// favoris marker
|
||||
$nodes_data[] = array(
|
||||
"nid" => $node->get('nid')->getString(),
|
||||
"title" => $node->get('title')->getString(),
|
||||
"description" => $description,
|
||||
"entrees" => $entrees,
|
||||
// "son_fid" => $audio_fid,
|
||||
"audio_url" => $audio_url,
|
||||
"has_article" => $has_article,
|
||||
"chutier_action" => 'add',
|
||||
"document_url" => $document_url,
|
||||
);
|
||||
}
|
||||
|
||||
$query = \Drupal::entityQuery('taxonomy_term')
|
||||
->condition('vid', 'entrees');
|
||||
|
||||
$tids = $query->execute();
|
||||
// $nodes = entity_load_multiple('node', $nids);
|
||||
foreach ($tids as $tid) {
|
||||
$entrees[] = $tid;
|
||||
}
|
||||
|
||||
$data = array(
|
||||
'date' => time(),
|
||||
'site_name' => $config->get('name'),
|
||||
'count' => count($nodes),
|
||||
'nodes' => $nodes_data,
|
||||
'entrees' => $entrees,
|
||||
'language' => $current_langcode,
|
||||
);
|
||||
|
||||
// https://spinningcode.org/2017/05/cached-json-responses-in-drupal-8/
|
||||
// cache is invalidated in edlp_corpus.module by tags
|
||||
$data['#cache'] = [
|
||||
'max-age' => \Drupal\Core\Cache\Cache::PERMANENT,
|
||||
'tags' => ['rebuild-corpus-cache'],
|
||||
'contexts' => ['languages:language_content'],
|
||||
];
|
||||
|
||||
// $response = new JsonResponse();
|
||||
// $response->setData($data);
|
||||
$response = new CacheableJsonResponse($data);
|
||||
$response->addCacheableDependency(CacheableMetadata::createFromRenderArray($data));
|
||||
|
||||
return $response;
|
||||
|
||||
return array(
|
||||
'#markup'=>'Hello Corpus'
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// _ _ _
|
||||
// | | __ _ __| |_ __| |___ __ ___
|
||||
// | |__/ _` (_-< _/ _` / _ \/ _(_-<
|
||||
// |____\__,_/__/\__\__,_\___/\__/__/
|
||||
|
||||
private function query() {
|
||||
$query = \Drupal::entityQuery('node')
|
||||
->condition('status', 1)
|
||||
->condition('type', 'enregistrement')
|
||||
->sort('created', 'DESC')
|
||||
->range(0,50);
|
||||
|
||||
$nids = $query->execute();
|
||||
$nodes = entity_load_multiple('node', $nids);
|
||||
|
||||
// $current_langcode = \Drupal::languageManager()->getCurrentLanguage()->getId();
|
||||
|
||||
$this->lastdocs_nodes = [];
|
||||
$this->lastdocs_nids = [];
|
||||
foreach ($nodes as $node) {
|
||||
// remove masqué
|
||||
$sid = WorkflowManager::getCurrentStateId($node, 'field_workflow');
|
||||
if($sid != 'corpus_documents_publie') continue;
|
||||
|
||||
$this->lastdocs_nodes[] = $node;
|
||||
// record an array of nids for corpus map filtering
|
||||
$this->lastdocs_nids[] = $node->get('nid')->getString();
|
||||
}
|
||||
|
||||
// // record an array of nids for corpus map filtering
|
||||
// $this->lastdocs_nids = [];
|
||||
// foreach($nids as $key => $nid){
|
||||
// $this->lastdocs_nids[] = $nid;
|
||||
// }
|
||||
}
|
||||
|
||||
private function toRenderable(){
|
||||
$this->query();
|
||||
// dpm($this->next_event_node);
|
||||
|
||||
return array(
|
||||
"#theme"=>'edlp_corpus_lastdocs',
|
||||
'#lastdocs_nodes' => $this->lastdocs_nodes
|
||||
);
|
||||
|
||||
}
|
||||
/**
|
||||
* Display lastdocs as a page.
|
||||
*
|
||||
* @return renderable array
|
||||
*/
|
||||
public function lastdocs() {
|
||||
return $this->toRenderable();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get lastdocs data as json through ajax.
|
||||
*
|
||||
* @return json
|
||||
*/
|
||||
public function lastdocsjson() {
|
||||
|
||||
$renderable = $this->toRenderable();
|
||||
// $rendered = render($renderable);
|
||||
// We can't render directly the entity as it throw an exception with cachable data
|
||||
//http://blog.dcycle.com/blog/2018-01-24/caching-drupal-8-rest-resource/#the-dreaded-leaked-metadata-error
|
||||
$rendered = \Drupal::service('renderer')->executeInRenderContext(new RenderContext(), function () use ($renderable) {
|
||||
return render($renderable);
|
||||
});
|
||||
|
||||
$data = [
|
||||
'rendered'=> $rendered,
|
||||
'title'=>t('Recently uploaded'),
|
||||
'documents_lies' => $this->lastdocs_nids,
|
||||
];
|
||||
|
||||
// translations links
|
||||
// use Drupal\Core\Url;
|
||||
// use Drupal\Core\Language\LanguageInterface;
|
||||
$route_name = 'edlp_corpus.lastdocs';
|
||||
$links = \Drupal::languageManager()->getLanguageSwitchLinks(LanguageInterface::TYPE_URL, Url::fromRoute($route_name));
|
||||
if (isset($links->links)) {
|
||||
$translations_build = [
|
||||
'#theme' => 'links__language_block',
|
||||
'#links' => $links->links,
|
||||
'#attributes' => ['class' => ["language-switcher-{$links->method_id}",],],
|
||||
'#set_active_class' => TRUE,
|
||||
];
|
||||
$translations_rendered = \Drupal::service('renderer')->executeInRenderContext(new RenderContext(), function () use ($translations_build) {return render($translations_build);});
|
||||
|
||||
$data['translations_links'] = $translations_rendered;
|
||||
}
|
||||
|
||||
$data['#cache'] = [
|
||||
'max-age' => \Drupal\Core\Cache\Cache::PERMANENT,
|
||||
'tags' => ['edlp-lastdocs-cache'],
|
||||
'contexts' => [
|
||||
'languages:language_content'
|
||||
]
|
||||
];
|
||||
|
||||
// $response = new JsonResponse();
|
||||
// $response->setData($data);
|
||||
$response = new CacheableJsonResponse($data);
|
||||
$response->addCacheableDependency(CacheableMetadata::createFromRenderArray($data));
|
||||
$response->addCacheableDependency(CacheableMetadata::createFromRenderArray($renderable));
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// _ _ _ _ ___ _
|
||||
// /_\ _ _| |_(_)__| |___ ___ |_ _|_ _ __| |_____ __
|
||||
// / _ \| '_| _| / _| / -_|_-< | || ' \/ _` / -_) \ /
|
||||
// /_/ \_\_| \__|_\__|_\___/__/ |___|_||_\__,_\___/_\_\
|
||||
|
||||
|
||||
private function articlesQuery() {
|
||||
$query = \Drupal::entityQuery('node')
|
||||
->condition('status', 1)
|
||||
->condition('type', 'enregistrement')
|
||||
->condition('body', '', "<>")
|
||||
->sort('created', 'DESC');
|
||||
// ->range(0,20);
|
||||
|
||||
$nids = $query->execute();
|
||||
$nodes = entity_load_multiple('node', $nids);
|
||||
|
||||
$current_langcode = \Drupal::languageManager()->getCurrentLanguage()->getId();
|
||||
|
||||
$this->articles_nodes = [];
|
||||
$this->articles_nids = [];
|
||||
foreach ($nodes as $node) {
|
||||
// remove masqué
|
||||
$sid = WorkflowManager::getCurrentStateId($node, 'field_workflow');
|
||||
if($sid != 'corpus_documents_publie') continue;
|
||||
|
||||
// TODO: check if article is translated
|
||||
if ($node->getTranslation($current_langcode)->body->isEmpty()) continue;
|
||||
|
||||
$this->articles_nodes[] = $node;
|
||||
// record an array of nids for corpus map filtering
|
||||
$this->articles_nids[] = $node->get('nid')->getString();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private function articlesToRenderable(){
|
||||
$this->articlesQuery();
|
||||
// dpm($this->next_event_node);
|
||||
|
||||
return array(
|
||||
"#theme"=>'edlp_corpus_articlesindex',
|
||||
'#articles_nodes' => $this->articles_nodes
|
||||
);
|
||||
|
||||
}
|
||||
/**
|
||||
* Display lastdocs as a page.
|
||||
*
|
||||
* @return renderable array
|
||||
*/
|
||||
public function articlesindex() {
|
||||
return $this->articlesToRenderable();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get lastdocs data as json through ajax.
|
||||
*
|
||||
* @return json
|
||||
*/
|
||||
public function articlesindexjson() {
|
||||
|
||||
$renderable = $this->articlesToRenderable();
|
||||
// $rendered = render($renderable);
|
||||
// We can't render directly the entity as it throw an exception with cachable data
|
||||
//http://blog.dcycle.com/blog/2018-01-24/caching-drupal-8-rest-resource/#the-dreaded-leaked-metadata-error
|
||||
$rendered = \Drupal::service('renderer')->executeInRenderContext(new RenderContext(), function () use ($renderable) {
|
||||
return render($renderable);
|
||||
});
|
||||
|
||||
$data = [
|
||||
'rendered'=> $rendered,
|
||||
'title'=>'Articles',
|
||||
'articles' => $this->articles_nids,
|
||||
'documents_lies' => $this->articles_nids,
|
||||
];
|
||||
|
||||
// translations links
|
||||
// use Drupal\Core\Url;
|
||||
// use Drupal\Core\Language\LanguageInterface;
|
||||
$route_name = 'edlp_corpus.articlesindex';
|
||||
$links = \Drupal::languageManager()->getLanguageSwitchLinks(LanguageInterface::TYPE_URL, Url::fromRoute($route_name));
|
||||
if (isset($links->links)) {
|
||||
$translations_build = [
|
||||
'#theme' => 'links__language_block',
|
||||
'#links' => $links->links,
|
||||
'#attributes' => ['class' => ["language-switcher-{$links->method_id}",],],
|
||||
'#set_active_class' => TRUE,
|
||||
];
|
||||
$translations_rendered = \Drupal::service('renderer')->executeInRenderContext(new RenderContext(), function () use ($translations_build) {return render($translations_build);});
|
||||
|
||||
$data['translations_links'] = $translations_rendered;
|
||||
}
|
||||
|
||||
$data['#cache'] = [
|
||||
'max-age' => \Drupal\Core\Cache\Cache::PERMANENT,
|
||||
'tags' => ['edlp-articlesindex-cache'],
|
||||
'contexts' => [
|
||||
'languages:language_content'
|
||||
]
|
||||
];
|
||||
|
||||
// $response = new JsonResponse();
|
||||
// $response->setData($data);
|
||||
$response = new CacheableJsonResponse($data);
|
||||
$response->addCacheableDependency(CacheableMetadata::createFromRenderArray($data));
|
||||
$response->addCacheableDependency(CacheableMetadata::createFromRenderArray($renderable));
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ___ _ _ _ _
|
||||
// / __|___| | |___ __| |_(_)___ _ _
|
||||
// | (__/ _ \ | / -_) _| _| / _ \ ' \
|
||||
// \___\___/_|_\___\__|\__|_\___/_||_|
|
||||
|
||||
private function collectionQuery(){
|
||||
$language = \Drupal::languageManager()->getCurrentLanguage()->getId();
|
||||
|
||||
$query = \Drupal::entityQuery('taxonomy_term')
|
||||
// ->sort('weight', 'DESC')
|
||||
// ->sort('name', 'DESC')
|
||||
->condition('vid', 'entrees');
|
||||
|
||||
$tids = $query->execute();
|
||||
// $terms = entity_load_multiple('taxonomy_term', $tids);
|
||||
// $terms = \Drupal::entityManager()->getStorage('taxonomy_term')->loadMultiple($terms);
|
||||
$terms = Term::loadMultiple($tids);
|
||||
|
||||
$ordered_terms = [];
|
||||
foreach ($terms as $term) {
|
||||
// remove masqué
|
||||
$sid = WorkflowManager::getCurrentStateId($term, 'field_workflow');
|
||||
if($sid == 'generique_masque') continue;
|
||||
// translate the term
|
||||
$term = \Drupal::service('entity.repository')->getTranslationFromContext($term, $language);
|
||||
$name = $term->getName();
|
||||
$ordered_trans_terms[$name] = $term;
|
||||
}
|
||||
ksort($ordered_trans_terms);
|
||||
$this->entrees_terms = $ordered_trans_terms;
|
||||
|
||||
}
|
||||
|
||||
private function collectionToRenderable(){
|
||||
$this->collectionQuery();
|
||||
|
||||
return array(
|
||||
"#theme"=>'edlp_corpus_collection',
|
||||
'#entrees_terms' => $this->entrees_terms
|
||||
);
|
||||
}
|
||||
|
||||
public function collection(){
|
||||
return $this->collectionToRenderable();
|
||||
}
|
||||
|
||||
public function collectionjson(){
|
||||
$renderable = $this->collectionToRenderable();
|
||||
// $rendered = render($renderable);
|
||||
// We can't render directly the entity as it throw an exception with cachable data
|
||||
//http://blog.dcycle.com/blog/2018-01-24/caching-drupal-8-rest-resource/#the-dreaded-leaked-metadata-error
|
||||
$rendered = \Drupal::service('renderer')->executeInRenderContext(new RenderContext(), function () use ($renderable) {
|
||||
return render($renderable);
|
||||
});
|
||||
|
||||
$data = [
|
||||
'rendered'=> $rendered,
|
||||
'title'=>'Collection'
|
||||
];
|
||||
|
||||
// translations links
|
||||
// use Drupal\Core\Url;
|
||||
// use Drupal\Core\Language\LanguageInterface;
|
||||
$route_name = 'edlp_corpus.collection';
|
||||
$links = \Drupal::languageManager()->getLanguageSwitchLinks(LanguageInterface::TYPE_URL, Url::fromRoute($route_name));
|
||||
if (isset($links->links)) {
|
||||
$translations_build = [
|
||||
'#theme' => 'links__language_block',
|
||||
'#links' => $links->links,
|
||||
'#attributes' => ['class' => ["language-switcher-{$links->method_id}",],],
|
||||
'#set_active_class' => TRUE,
|
||||
];
|
||||
$translations_rendered = \Drupal::service('renderer')->executeInRenderContext(new RenderContext(), function () use ($translations_build) {return render($translations_build);});
|
||||
|
||||
$data['translations_links'] = $translations_rendered;
|
||||
}
|
||||
|
||||
$data['#cache'] = [
|
||||
'max-age' => \Drupal\Core\Cache\Cache::PERMANENT,
|
||||
'tags' => ['edlp-articlesindex-cache'],
|
||||
'contexts' => [
|
||||
'languages:language_content'
|
||||
]
|
||||
];
|
||||
|
||||
// $response = new JsonResponse();
|
||||
// $response->setData($data);
|
||||
$response = new CacheableJsonResponse($data);
|
||||
$response->addCacheableDependency(CacheableMetadata::createFromRenderArray($data));
|
||||
$response->addCacheableDependency(CacheableMetadata::createFromRenderArray($renderable));
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
*/
|
||||
namespace Drupal\edlp_corpus\Plugin\Block;
|
||||
|
||||
use Drupal\Core\Block\BlockBase;
|
||||
use Drupal\Core\Link;
|
||||
use Drupal\Core\Url;
|
||||
use Drupal\taxonomy\Entity\Term;
|
||||
use Drupal\workflow\Entity\WorkflowManager;
|
||||
|
||||
/**
|
||||
* Creates a 'Entrees' Block
|
||||
* @Block(
|
||||
* id = "block_edlp_entrees",
|
||||
* admin_label = @Translation("Edlp entrees block"),
|
||||
* )
|
||||
*/
|
||||
class BlockEntrees extends BlockBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function build() {
|
||||
|
||||
$language = \Drupal::languageManager()->getCurrentLanguage()->getId();
|
||||
|
||||
$query = \Drupal::entityQuery('taxonomy_term')
|
||||
// ->sort('weight', 'DESC')
|
||||
// ->sort('name', 'DESC')
|
||||
->condition('vid', 'entrees');
|
||||
|
||||
$tids = $query->execute();
|
||||
// $terms = entity_load_multiple('taxonomy_term', $tids);
|
||||
// $terms = \Drupal::entityManager()->getStorage('taxonomy_term')->loadMultiple($terms);
|
||||
$terms = Term::loadMultiple($tids);
|
||||
|
||||
$ordered_terms = [];
|
||||
foreach ($terms as $term) {
|
||||
// remove masqué
|
||||
$sid = WorkflowManager::getCurrentStateId($term, 'field_workflow');
|
||||
if($sid == 'generique_masque') continue;
|
||||
// translate the term
|
||||
$term = \Drupal::service('entity.repository')->getTranslationFromContext($term, $language);
|
||||
$name = $this->stripAccent($term->getName());
|
||||
$ordered_trans_terms[$name] = $term;
|
||||
}
|
||||
|
||||
ksort($ordered_trans_terms);
|
||||
|
||||
// dsm($terms);
|
||||
foreach ($ordered_trans_terms as $name => $term) {
|
||||
$tid = $term->id();
|
||||
|
||||
$entree = array(
|
||||
'tid'=>$tid
|
||||
);
|
||||
|
||||
// term link
|
||||
$url = Url::fromRoute('entity.taxonomy_term.canonical', ['taxonomy_term'=>$tid]);
|
||||
$url->setOptions(array(
|
||||
'attributes' => array(
|
||||
'class' => ['term-'.$tid, 'term-link'],
|
||||
'tid'=>$tid,
|
||||
'selector' => 'entree-term-link-'.$tid,
|
||||
'data-drupal-link-system-path' => $url->getInternalPath()
|
||||
)
|
||||
));
|
||||
$entree['term_link'] = Link::fromTextAndUrl($term->getName(), $url);
|
||||
|
||||
// index link
|
||||
$url = Url::fromRoute('entity.taxonomy_term.canonical', ['taxonomy_term'=>$tid]);
|
||||
$url->setOptions(array(
|
||||
'attributes' => array(
|
||||
'class' => ['index-link', 'ajax-link'],
|
||||
'viewmode'=>'index',
|
||||
'tid'=>$tid,
|
||||
'selector' => 'entree-index-link-'.$tid,
|
||||
'data-drupal-link-system-path' => $url->getInternalPath()
|
||||
)
|
||||
));
|
||||
$entree['index_link'] = Link::fromTextAndUrl('index', $url);
|
||||
|
||||
// notice-link
|
||||
$url = Url::fromRoute('entity.taxonomy_term.canonical', ['taxonomy_term'=>$tid]);
|
||||
$url->setOptions(array(
|
||||
'attributes' => array(
|
||||
'class' => ['notice-link', 'ajax-link'],
|
||||
'viewmode'=>'notice',
|
||||
'tid'=>$tid,
|
||||
'selector' => 'entree-notice-link-'.$tid,
|
||||
'data-drupal-link-system-path' => $url->getInternalPath()
|
||||
)
|
||||
));
|
||||
$entree['notice_link'] = Link::fromTextAndUrl('notice', $url);
|
||||
|
||||
$entree['description'] = $term->get('description')->value;
|
||||
|
||||
$entrees[] = $entree;
|
||||
}
|
||||
|
||||
return array (
|
||||
'#theme' => 'blockentrees',
|
||||
'#entrees_items' => $entrees,
|
||||
'#attached'=>array(
|
||||
'library' => array('edlp_corpus/corpus'),
|
||||
'drupalSettings' => array(
|
||||
'basepath' => base_path()
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
private function stripAccent($str){
|
||||
return strtr(
|
||||
utf8_decode($str),
|
||||
utf8_decode('àáâãäçèéêëìíîïñòóôõöùúûüýÿÀÁÂÃÄÇÈÉÊËÌÍÎÏÑÒÓÔÕÖÙÚÛÜÝ'),
|
||||
'aaaaaceeeeiiiinooooouuuuyyAAAAACEEEEIIIINOOOOOUUUUY');
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\edlp_corpus\Plugin\Filter;
|
||||
|
||||
use Drupal\Component\Utility\Html;
|
||||
// use Drupal\Component\Utility\Unicode;
|
||||
// use Drupal\Component\Utility\Xss;
|
||||
use Drupal\filter\FilterProcessResult;
|
||||
use Drupal\filter\Plugin\FilterBase;
|
||||
use Drupal\Core\Url;
|
||||
// use Drupal\Core\Template\Attribute;
|
||||
|
||||
/**
|
||||
* Provides a filter to convert audio links.
|
||||
*
|
||||
* @Filter(
|
||||
* id = "audio_links",
|
||||
* title = @Translation("Audio Links"),
|
||||
* description = @Translation("Convert enregistrement links to audio links"),
|
||||
* type = Drupal\filter\Plugin\FilterInterface::TYPE_TRANSFORM_REVERSIBLE
|
||||
* )
|
||||
*/
|
||||
class AudioLinksFilter extends FilterBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function process($text, $langcode) {
|
||||
$result = new FilterProcessResult($text);
|
||||
|
||||
$dom = Html::load($text);
|
||||
$xpath = new \DOMXPath($dom);
|
||||
foreach ($xpath->query('//a[contains(@href, "node/")]') as $link) {
|
||||
$href = $link->getAttribute('href');
|
||||
preg_match('/^\/?node\/(\d+)$/', $href, $matches);
|
||||
// dpm($matches[1]);
|
||||
$node = entity_load('node', $matches[1]);
|
||||
|
||||
if(!$node) continue;
|
||||
if($node->getType() != "enregistrement") continue;
|
||||
|
||||
// dpm($node->getTitle());
|
||||
|
||||
$options = ['absolute' => TRUE];
|
||||
$url = Url::fromRoute('entity.node.canonical', ['node' => $node->id()], $options);
|
||||
$system_path = $url->getInternalPath();
|
||||
// get the audio file url
|
||||
$field_son_values = $node->get('field_son')->getValue();
|
||||
$son_fid = count($field_son_values) ? $field_son_values[0]['target_id'] : "";
|
||||
$son_file = \Drupal\file\Entity\File::load($son_fid);
|
||||
$son_url = null;
|
||||
if($son_file){
|
||||
$son_uri = $son_file->getFileUri();
|
||||
$son_url = file_create_url($son_uri);
|
||||
}
|
||||
// set the link classes
|
||||
$class = $link->getAttribute('class');
|
||||
$class .= $class == '' ? '':' ';
|
||||
$class .= 'audio-link ajax-link';
|
||||
|
||||
// finnally add all the attributes
|
||||
$link->SetAttribute('data-drupal-link-system-path', $system_path);
|
||||
$link->SetAttribute('audio_url', $son_url);
|
||||
$link->SetAttribute('nid', $node->id());
|
||||
$link->SetAttribute('class', $class);
|
||||
}
|
||||
|
||||
$result->setProcessedText(Html::serialize($dom));
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
|
||||
{{ entrees }}
|
||||
@@ -0,0 +1 @@
|
||||
{{ articles }}
|
||||
@@ -0,0 +1,3 @@
|
||||
{% if entrees %}
|
||||
{{ entrees }}
|
||||
{% endif %}
|
||||
@@ -0,0 +1 @@
|
||||
{{ lastdocs }}
|
||||
@@ -0,0 +1,14 @@
|
||||
# @Author: Bachir Soussi Chiadmi <bach>
|
||||
# @Date: 13-12-2017
|
||||
# @Email: bachir@figureslibres.io
|
||||
# @Filename: edlp_fils.info.yml
|
||||
# @Last modified by: bach
|
||||
# @Last modified time: 20-12-2017
|
||||
# @License: GPL-V3
|
||||
|
||||
|
||||
name: Edlp Fils
|
||||
type: module
|
||||
description: Manage fils for edlp d8.
|
||||
core: 8.x
|
||||
package: Edlp
|
||||
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
# @Author: Bachir Soussi Chiadmi <bach>
|
||||
# @Date: 13-12-2017
|
||||
# @Email: bachir@figureslibres.io
|
||||
# @Filename: edlp_admin.module
|
||||
# @Last modified by: bach
|
||||
# @Last modified time: 20-12-2017
|
||||
# @License: GPL-V3
|
||||
@@ -0,0 +1,23 @@
|
||||
# @Author: Bachir Soussi Chiadmi <bach>
|
||||
# @Date: 13-12-2017
|
||||
# @Email: bachir@figureslibres.io
|
||||
# @Filename: edlp_corpus.routing.yml
|
||||
# @Last modified by: bach
|
||||
# @Last modified time: 20-12-2017
|
||||
# @License: GPL-V3
|
||||
|
||||
edlp_fils.fils:
|
||||
path: '/fils'
|
||||
defaults:
|
||||
_controller: '\Drupal\edlp_fils\Controller\FilsController::fils'
|
||||
_title: 'Fils'
|
||||
requirements:
|
||||
_permission: 'access content'
|
||||
|
||||
edlp_fils.filsajax:
|
||||
path: '/fils/ajax'
|
||||
defaults:
|
||||
_controller: '\Drupal\edlp_fils\Controller\FilsController::filsjson'
|
||||
_title: 'Fils'
|
||||
requirements:
|
||||
_permission: 'access content'
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\edlp_fils\Controller;
|
||||
|
||||
use Drupal\Core\Controller\ControllerBase;
|
||||
// use Drupal\Core\Datetime\DrupalDateTime;
|
||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
|
||||
|
||||
class FilsController extends ControllerBase {
|
||||
|
||||
/**
|
||||
* Display productions as a page.
|
||||
*
|
||||
* @return renderable array
|
||||
*/
|
||||
public function fils() {
|
||||
return array(
|
||||
"#markup"=>"Edlp Fils"
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get agenda data as json through ajax.
|
||||
*
|
||||
* @return json
|
||||
*/
|
||||
public function filsjson() {
|
||||
|
||||
$response = new JsonResponse();
|
||||
$renderable = array(
|
||||
"#markup"=>"Edlp Fils"
|
||||
);
|
||||
$rendered = render($renderable);
|
||||
|
||||
$response->setData([
|
||||
'test'=>'hello',
|
||||
'rendered'=> $rendered
|
||||
]);
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
# @Author: Bachir Soussi Chiadmi <bach>
|
||||
# @Date: 13-12-2017
|
||||
# @Email: bachir@figureslibres.io
|
||||
# @Filename: edlp_home.info.yml
|
||||
# @Last modified by: bach
|
||||
# @Last modified time: 20-12-2017
|
||||
# @License: GPL-V3
|
||||
|
||||
|
||||
name: Edlp Home
|
||||
type: module
|
||||
description: Manage home for edlp d8.
|
||||
core: 8.x
|
||||
package: Edlp
|
||||
# dependencies:
|
||||
# - migrate_drupal
|
||||
# - migrate_plus
|
||||
# - migrate_tools
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
# @Author: Bachir Soussi Chiadmi <bach>
|
||||
# @Date: 13-12-2017
|
||||
# @Email: bachir@figureslibres.io
|
||||
# @Filename: edlp_home.module
|
||||
# @Last modified by: bach
|
||||
# @Last modified time: 20-12-2017
|
||||
# @License: GPL-V3
|
||||
|
||||
|
||||
/**
|
||||
* Implements hook_theme().
|
||||
*/
|
||||
function edlp_home_theme($existing, $type, $theme, $path) {
|
||||
// @see https://www.drupal.org/docs/8/theming/twig/create-custom-twig-templates-from-custom-module
|
||||
|
||||
return array(
|
||||
'edlp_home' => array(
|
||||
// 'render element' => '',
|
||||
'file' => 'includes/edlp_home.inc',
|
||||
'variables' => array(
|
||||
// 'presentation_node' => NULL,
|
||||
// 'last_fil_node' => NULL,
|
||||
// 'last_production_node' => NULL,
|
||||
'promoted_nodes' => array(),
|
||||
'lastdocs_items' => NULL,
|
||||
'agenda_items' => NULL,
|
||||
// 'entrees_items' => NULL,
|
||||
'collection_link' => NULL,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
# @Author: Bachir Soussi Chiadmi <bach>
|
||||
# @Date: 13-12-2017
|
||||
# @Email: bachir@figureslibres.io
|
||||
# @Filename: edlp_home.routing.yml
|
||||
# @Last modified by: bach
|
||||
# @Last modified time: 20-12-2017
|
||||
# @License: GPL-V3
|
||||
|
||||
edlp_home.home:
|
||||
path: '/home'
|
||||
defaults:
|
||||
_controller: '\Drupal\edlp_home\Controller\HomeController::home'
|
||||
_title: 'Home'
|
||||
requirements:
|
||||
_permission: 'access content'
|
||||
|
||||
edlp_home.home_mobile:
|
||||
path: '/home_m'
|
||||
defaults:
|
||||
_controller: '\Drupal\edlp_home\Controller\HomeController::home_mobile'
|
||||
_title: 'Home'
|
||||
requirements:
|
||||
_permission: 'access content'
|
||||
|
||||
edlp_home.home_mobileajax:
|
||||
path: '/home_m/ajax'
|
||||
defaults:
|
||||
_controller: '\Drupal\edlp_home\Controller\HomeController::home_mobilejson'
|
||||
_title: 'Home'
|
||||
requirements:
|
||||
_permission: 'access content'
|
||||
@@ -0,0 +1,175 @@
|
||||
<?php
|
||||
|
||||
use Drupal\Core\Url;
|
||||
|
||||
function template_preprocess_edlp_home(&$vars){
|
||||
$node_view_builder = \Drupal::entityTypeManager()->getViewBuilder('node');
|
||||
// $term_view_builder = \Drupal::entityTypeManager()->getViewBuilder('taxonomy_term');
|
||||
// dpm($vars);
|
||||
|
||||
// render the promoted_nodes
|
||||
$vars['nodes'] = array();
|
||||
if(isset($vars['promoted_nodes'])){
|
||||
foreach($vars['promoted_nodes'] as $node){
|
||||
if($node->hasField('field_view_mode')){
|
||||
switch($node->get('field_view_mode')->value){
|
||||
case "1":
|
||||
$vm = "image_2_columns";
|
||||
break;
|
||||
case "2":
|
||||
$vm = "image_1_columns";
|
||||
break;
|
||||
case "3":
|
||||
$vm = "text_1_column";
|
||||
break;
|
||||
};
|
||||
}else{
|
||||
$vm = 'default';
|
||||
}
|
||||
|
||||
$vars['nodes'][] = array(
|
||||
'vm'=>$vm,
|
||||
'build'=>$node_view_builder->view($node, $vm)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// render the last fil column
|
||||
// $vars["last_fil"] = array(
|
||||
// "#type" => "container",
|
||||
// // 'fil' => $node_view_builder->view($vars['last_fil_node'], 'teaser'),
|
||||
// 'title'=> array("#markup" => "<h2 class='title'>Dernier Fil</h2>"),
|
||||
// 'fil' => $vars['last_fil_node'],
|
||||
// // 'links' => array(
|
||||
// // '#theme' => 'item_list',
|
||||
// // '#items' => array(
|
||||
// // 'link_all' => array(
|
||||
// // '#title' => t("Voir tous les fils de l'EP."),
|
||||
// // '#type' => 'link',
|
||||
// // '#url' => Url::fromRoute('edlp_fils.fils', [], array(
|
||||
// // 'attributes' => array(
|
||||
// // 'class' => ['fils-link', 'ajax-link']
|
||||
// // )
|
||||
// // ))
|
||||
// // ),
|
||||
// // // TODO: link posdcast fils
|
||||
// // 'link_podcast' => array(
|
||||
// // '#title' => t("S'abonner au podcast des fils."),
|
||||
// // '#type' => 'link',
|
||||
// // '#url' => Url::fromRoute('<front>', [], array(
|
||||
// // 'attributes' => array(
|
||||
// // 'class' => ['fils-link']
|
||||
// // )
|
||||
// // ))
|
||||
// // )
|
||||
// // )
|
||||
// // )
|
||||
// );
|
||||
|
||||
|
||||
// render the lasts documents of collection as list
|
||||
if(isset($vars['lastdocs_items'])){
|
||||
$lastdocs_url = Url::fromRoute('edlp_corpus.lastdocs');
|
||||
$lastdocs = array(
|
||||
'#type'=>"container",
|
||||
'title'=>array(
|
||||
'#prefix'=> '<h3>',
|
||||
'#title' => t("Recently uploaded"),
|
||||
'#suffix' => '</h3>',
|
||||
'#type' => 'link',
|
||||
'#url' => $lastdocs_url,
|
||||
'#options'=>array(
|
||||
'attributes' => array(
|
||||
'data-drupal-link-system-path' => $lastdocs_url->getInternalPath(),
|
||||
'class' => array('ajax-link'),
|
||||
)
|
||||
)
|
||||
),
|
||||
'list'=> array(
|
||||
'#theme' => 'item_list',
|
||||
'#items' => [],
|
||||
),
|
||||
'seeall'=>array(
|
||||
'#type' => 'link',
|
||||
'#prefix'=> '<nav>',
|
||||
'#title' => t("See all"),
|
||||
'#suffix'=> '</nav>',
|
||||
'#url' => $lastdocs_url,
|
||||
'#options'=>array(
|
||||
'attributes' => array(
|
||||
'data-drupal-link-system-path' => $lastdocs_url->getInternalPath(),
|
||||
'class' => array('ajax-link'),
|
||||
)
|
||||
)
|
||||
),
|
||||
);
|
||||
foreach($vars['lastdocs_items'] as $node){
|
||||
$lastdocs['list']['#items'][] = $node_view_builder->view($node, 'search_index');
|
||||
}
|
||||
$vars['lastdocs'] = render($lastdocs);
|
||||
}
|
||||
|
||||
// render the next events of agenda as list
|
||||
if(isset($vars['agenda_items'])){
|
||||
$agenda_url = Url::fromRoute('edlp_agenda.agenda');
|
||||
$agenda = array(
|
||||
'#type'=>"container",
|
||||
'title'=>array(
|
||||
'#prefix'=> '<h3>',
|
||||
'#title' => t("Agenda"),
|
||||
'#suffix' => '</h3>',
|
||||
'#type' => 'link',
|
||||
'#url' => $agenda_url,
|
||||
'#options'=>array(
|
||||
'attributes' => array(
|
||||
'data-drupal-link-system-path' => $agenda_url->getInternalPath(),
|
||||
'class' => array('ajax-link'),
|
||||
)
|
||||
)
|
||||
),
|
||||
'list'=> array(
|
||||
'#theme' => 'item_list',
|
||||
'#items' => [],
|
||||
),
|
||||
'seeall'=>array(
|
||||
'#type' => 'link',
|
||||
'#prefix'=> '<nav>',
|
||||
'#title' => t("See all"),
|
||||
'#suffix'=> '</nav>',
|
||||
'#url' => $agenda_url,
|
||||
'#options'=>array(
|
||||
'attributes' => array(
|
||||
'data-drupal-link-system-path' => $agenda_url->getInternalPath(),
|
||||
'class' => array('ajax-link'),
|
||||
)
|
||||
)
|
||||
),
|
||||
);
|
||||
|
||||
foreach($vars['agenda_items'] as $node){
|
||||
$agenda['list']['#items'][] = $node_view_builder->view($node, 'teaser');
|
||||
}
|
||||
$vars['agenda'] = render($agenda);
|
||||
}
|
||||
|
||||
if(isset($vars['collection_link'])){
|
||||
$collection = array(
|
||||
'#type'=>"container",
|
||||
'title'=>array(
|
||||
'#prefix'=> '<h3>',
|
||||
'#title' => t("Collection"),
|
||||
'#suffix' => '</h3>',
|
||||
'#type' => 'link',
|
||||
'#url' => $vars['collection_link']['url'],
|
||||
'#options'=>array(
|
||||
'attributes' => array(
|
||||
'data-drupal-link-system-path' => $vars['collection_link']['internal_path'],
|
||||
'class' => array('ajax-link'),
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
$vars['collection'] = render($collection);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,249 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\edlp_home\Controller;
|
||||
|
||||
use Drupal\Core\Controller\ControllerBase;
|
||||
use Drupal\Core\Datetime\DrupalDateTime;
|
||||
use Drupal\taxonomy\Entity\Term;
|
||||
use Drupal\workflow\Entity\WorkflowManager;
|
||||
use Drupal\Core\Url;
|
||||
use Drupal\Core\Language\LanguageInterface;
|
||||
// use Symfony\Component\HttpFoundation\JsonResponse;
|
||||
use Drupal\Core\Cache\CacheableJsonResponse;
|
||||
use Drupal\Core\Cache\CacheableMetadata;
|
||||
use Drupal\core\render\RenderContext;
|
||||
|
||||
|
||||
|
||||
class HomeController extends ControllerBase {
|
||||
|
||||
/**
|
||||
* Display home as a page.
|
||||
*
|
||||
* @return renderable array
|
||||
*/
|
||||
public function home() {
|
||||
|
||||
// $view_builder = \Drupal::entityTypeManager()->getViewBuilder('node');
|
||||
|
||||
$contents = array("#theme"=>'edlp_home');
|
||||
|
||||
// first get static pages
|
||||
$query = \Drupal::entityQuery('node')
|
||||
->condition('status', 1)
|
||||
->condition('field_afficher_en_page_d_acceuil', 1)
|
||||
->condition('type', 'static');
|
||||
|
||||
$promoted_nids = $query->execute();
|
||||
$contents["#promoted_nodes"] = entity_load_multiple('node', $promoted_nids);
|
||||
|
||||
// then get production pages
|
||||
$query = \Drupal::entityQuery('node')
|
||||
->condition('status', 1)
|
||||
->condition('field_afficher_en_page_d_acceuil', 1)
|
||||
->condition('type', 'page');
|
||||
|
||||
$promoted_nids = $query->execute();
|
||||
$contents["#promoted_nodes"] += entity_load_multiple('node', $promoted_nids);
|
||||
|
||||
// presentation
|
||||
// $query = \Drupal::entityQuery('node')
|
||||
// ->condition('status', 1)
|
||||
// ->condition('nid', 12242);
|
||||
// // TODO: présentation nid should be a setting
|
||||
//
|
||||
// $pres_nid = $query->execute();
|
||||
// $contents["#presentation_node"] = entity_load('node', array_pop($pres_nid));
|
||||
|
||||
// last fil
|
||||
// $query = \Drupal::entityQuery('node')
|
||||
// ->condition('status', 1)
|
||||
// ->condition('type', 'fil')
|
||||
// ->sort('created', 'DESC')
|
||||
// ->range(0,1);
|
||||
//
|
||||
// $fil = $query->execute();
|
||||
// $contents["#last_fil_node"] = entity_load('node', array_pop($fil));
|
||||
// $contents["#last_fil_node"] = array('#markup'=>'En développement.');
|
||||
|
||||
|
||||
// last production
|
||||
// $query = \Drupal::entityQuery('node')
|
||||
// ->condition('status', 1)
|
||||
// ->condition('type', 'page')
|
||||
// ->condition('field_page_type', array('1168'), 'NOT IN')
|
||||
// ->sort('created', 'DESC')
|
||||
// ->range(0,1);
|
||||
//
|
||||
// $prod = $query->execute();
|
||||
// $contents["#last_production_node"] = entity_load('node', array_pop($prod));
|
||||
|
||||
// last documents
|
||||
$query = \Drupal::entityQuery('node')
|
||||
->condition('status', 1)
|
||||
->condition('type', 'enregistrement')
|
||||
->sort('created', 'DESC')
|
||||
->range(0,50);
|
||||
|
||||
$nids = $query->execute();
|
||||
$nodes = entity_load_multiple('node', $nids);
|
||||
|
||||
$lastdocs = [];
|
||||
$i = 0;
|
||||
foreach ($nodes as $node) {
|
||||
// remove masqué
|
||||
$sid = WorkflowManager::getCurrentStateId($node, 'field_workflow');
|
||||
if($sid != 'corpus_documents_publie') continue;
|
||||
$lastdocs[] = $node;
|
||||
$i++;
|
||||
if($i>9) break;
|
||||
}
|
||||
// $contents["#lastdocs_items"] = entity_load_multiple('node', $lastdocs);
|
||||
$contents["#lastdocs_items"] = $lastdocs;
|
||||
// dsm($contents["#lastdocs_items"], "#lastdocs_items");
|
||||
|
||||
// agenda
|
||||
$now = new DrupalDateTime('now');
|
||||
$now->setTimezone(new \DateTimeZone(DATETIME_STORAGE_TIMEZONE));
|
||||
|
||||
$query = \Drupal::entityQuery('node')
|
||||
->condition('status', 1)
|
||||
->condition('type', 'evenement')
|
||||
->condition('field_date', $now->format(DATETIME_DATETIME_STORAGE_FORMAT), '>=')
|
||||
->range(0,5)
|
||||
->sort('field_date');
|
||||
|
||||
$events = $query->execute();
|
||||
$contents['#agenda_items'] = entity_load_multiple('node', $events);
|
||||
|
||||
return $contents;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display home mobile as a page.
|
||||
*
|
||||
* @return renderable array
|
||||
*/
|
||||
public function toMobileHomeRenderable() {
|
||||
|
||||
// $view_builder = \Drupal::entityTypeManager()->getViewBuilder('node');
|
||||
|
||||
$renderable = array("#theme"=>'edlp_home');
|
||||
|
||||
// first get static pages
|
||||
$query = \Drupal::entityQuery('node')
|
||||
->condition('status', 1)
|
||||
->condition('field_afficher_en_page_d_acceuil', 1)
|
||||
->condition('type', 'static');
|
||||
|
||||
$promoted_nids = $query->execute();
|
||||
$renderable["#promoted_nodes"] = entity_load_multiple('node', $promoted_nids);
|
||||
|
||||
// then get production pages
|
||||
$query = \Drupal::entityQuery('node')
|
||||
->condition('status', 1)
|
||||
->condition('field_afficher_en_page_d_acceuil', 1)
|
||||
->condition('type', 'page');
|
||||
|
||||
$promoted_nids = $query->execute();
|
||||
$renderable["#promoted_nodes"] += entity_load_multiple('node', $promoted_nids);
|
||||
|
||||
// last fil
|
||||
// $query = \Drupal::entityQuery('node')
|
||||
// ->condition('status', 1)
|
||||
// ->condition('type', 'fil')
|
||||
// ->sort('created', 'DESC')
|
||||
// ->range(0,1);
|
||||
//
|
||||
// $fil = $query->execute();
|
||||
// $renderable["#last_fil_node"] = entity_load('node', array_pop($fil));
|
||||
// $renderable["#last_fil_node"] = array('#markup'=>'En développement.');
|
||||
|
||||
// agenda
|
||||
$now = new DrupalDateTime('now');
|
||||
$now->setTimezone(new \DateTimeZone(DATETIME_STORAGE_TIMEZONE));
|
||||
|
||||
$query = \Drupal::entityQuery('node')
|
||||
->condition('status', 1)
|
||||
->condition('type', 'evenement')
|
||||
->condition('field_date', $now->format(DATETIME_DATETIME_STORAGE_FORMAT), '>=')
|
||||
->range(0,5)
|
||||
->sort('field_date');
|
||||
|
||||
$events = $query->execute();
|
||||
$renderable['#agenda_items'] = entity_load_multiple('node', $events);
|
||||
|
||||
|
||||
// Collection
|
||||
// TODO: get the link to mobile collection page
|
||||
$collection_url = Url::fromRoute('edlp_corpus.collection');
|
||||
$renderable['#collection_link'] = array(
|
||||
'url' => $collection_url,
|
||||
'internal_path' => $collection_url->getInternalPath(),
|
||||
);
|
||||
|
||||
|
||||
|
||||
return $renderable;
|
||||
}
|
||||
|
||||
|
||||
public function home_mobile() {
|
||||
return $this->toMobileHomeRenderable();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get home mobile data as json through ajax.
|
||||
*
|
||||
* @return json
|
||||
*/
|
||||
// NOT NEEDED ANY MORE
|
||||
public function home_mobilejson() {
|
||||
|
||||
$renderable = $this->toMobileHomeRenderable();
|
||||
// $rendered = render($renderable);
|
||||
// We can't render directly the entity as it throw an exception with cachable data
|
||||
//http://blog.dcycle.com/blog/2018-01-24/caching-drupal-8-rest-resource/#the-dreaded-leaked-metadata-error
|
||||
$rendered = \Drupal::service('renderer')->executeInRenderContext(new RenderContext(), function () use ($renderable) {
|
||||
return render($renderable);
|
||||
});
|
||||
|
||||
$data = [
|
||||
'rendered'=> $rendered,
|
||||
'title'=>'Home Mobile',
|
||||
];
|
||||
|
||||
// translations links
|
||||
// use Drupal\Core\Url;
|
||||
// use Drupal\Core\Language\LanguageInterface;
|
||||
$route_name = 'edlp_home.home_mobile';
|
||||
$links = \Drupal::languageManager()->getLanguageSwitchLinks(LanguageInterface::TYPE_URL, Url::fromRoute($route_name));
|
||||
if (isset($links->links)) {
|
||||
$translations_build = [
|
||||
'#theme' => 'links__language_block',
|
||||
'#links' => $links->links,
|
||||
'#attributes' => ['class' => ["language-switcher-{$links->method_id}",],],
|
||||
'#set_active_class' => TRUE,
|
||||
];
|
||||
$translations_rendered = \Drupal::service('renderer')->executeInRenderContext(new RenderContext(), function () use ($translations_build) {return render($translations_build);});
|
||||
|
||||
$data['translations_links'] = $translations_rendered;
|
||||
}
|
||||
|
||||
$data['#cache'] = [
|
||||
'max-age' => \Drupal\Core\Cache\Cache::PERMANENT,
|
||||
'tags' => ['edlp-home-cache'],
|
||||
'contexts' => [
|
||||
'languages:language_content'
|
||||
]
|
||||
];
|
||||
// $response = new JsonResponse();
|
||||
// $response->setData($data);
|
||||
$response = new CacheableJsonResponse($data);
|
||||
$response->addCacheableDependency(CacheableMetadata::createFromRenderArray($data));
|
||||
$response->addCacheableDependency(CacheableMetadata::createFromRenderArray($renderable));
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
{# presentation #}
|
||||
{# last_fil #}
|
||||
{# last_production #}
|
||||
|
||||
{% if nodes %}
|
||||
{% for node in nodes %}
|
||||
{{ node.build }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
{% if lastdocs %}
|
||||
{{ lastdocs }}
|
||||
{% endif %}
|
||||
|
||||
{% if agenda %}
|
||||
{{ agenda }}
|
||||
{% endif %}
|
||||
|
||||
{% if collection %}
|
||||
{{ collection }}
|
||||
{% endif %}
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
# Every migration that references a file by Drupal 6 fid should specify this
|
||||
# migration as an optional dependency.
|
||||
id: d6_edlp_allfiles
|
||||
label: Edlp Drupal 6 mp3 migration
|
||||
migration_tags:
|
||||
- Drupal 6
|
||||
migration_group: d6_edlp
|
||||
source:
|
||||
plugin: d6_edlp_file
|
||||
constants:
|
||||
# The tool configuring this migration must set source_base_path. It
|
||||
# represents the fully qualified path relative to which URIs in the files
|
||||
# table are specified, and must end with a /. See source_full_path
|
||||
# configuration in this migration's process pipeline as an example.
|
||||
source_base_path: '../drupal6'
|
||||
|
||||
process:
|
||||
# If you are using both this migration and d6_user_picture_file in a custom
|
||||
# migration and executing migrations incrementally, it is strongly
|
||||
# recommended that you remove the fid mapping to avoid potential ID
|
||||
# conflicts. For that reason, this mapping is commented out by default.
|
||||
fid: fid
|
||||
filename: filename
|
||||
source_full_path:
|
||||
-
|
||||
plugin: concat
|
||||
delimiter: /
|
||||
source:
|
||||
- constants/source_base_path
|
||||
- filepath
|
||||
-
|
||||
plugin: urlencode
|
||||
destination_full_path:
|
||||
plugin: file_uri
|
||||
source:
|
||||
- filepath
|
||||
- file_directory_path
|
||||
- temp_directory_path
|
||||
- is_public
|
||||
uri:
|
||||
plugin: file_copy
|
||||
source:
|
||||
- '@source_full_path'
|
||||
- '@destination_full_path'
|
||||
filemime: filemime
|
||||
# No need to migrate filesize, it is computed when file entities are saved.
|
||||
# filesize: filesize
|
||||
status: status
|
||||
changed: timestamp
|
||||
uid: uid
|
||||
destination:
|
||||
plugin: entity:file
|
||||
+184
@@ -0,0 +1,184 @@
|
||||
id: d6_edlp_corpus
|
||||
label: Edlp Drupal 6 corpus
|
||||
migration_tags:
|
||||
- Drupal 6
|
||||
deriver: Drupal\node\Plugin\migrate\D6NodeDeriver
|
||||
migration_group: d6_edlp
|
||||
source:
|
||||
plugin: d6_edlp_corpus
|
||||
node_type: corpus
|
||||
process:
|
||||
# In D6, nodes always have a tnid, but it's zero for untranslated nodes.
|
||||
# We normalize it to equal the nid in that case.
|
||||
# @see \Drupal\node\Plugin\migrate\source\d6\Node::prepareRow().
|
||||
# If you are using this file to build a custom migration consider removing
|
||||
# the nid and vid fields to allow incremental migrations.
|
||||
# nid: tnid
|
||||
# vid: vid
|
||||
type:
|
||||
plugin: default_value
|
||||
default_value: enregistrement
|
||||
langcode:
|
||||
plugin: default_value
|
||||
source: language
|
||||
default_value: "und"
|
||||
title:
|
||||
-
|
||||
plugin: get
|
||||
source: title
|
||||
-
|
||||
plugin: skip_on_empty
|
||||
method: row
|
||||
|
||||
# this is not working :(
|
||||
uid:
|
||||
-
|
||||
plugin: migration_lookup
|
||||
migration: d6_edlp_users
|
||||
source: node_uid
|
||||
-
|
||||
plugin: default_value
|
||||
default_value: 1
|
||||
|
||||
# status: status
|
||||
created: created
|
||||
changed: changed
|
||||
promote: promote
|
||||
sticky: sticky
|
||||
revision_uid: revision_uid
|
||||
revision_log: log
|
||||
revision_timestamp: timestamp
|
||||
|
||||
'field_description/value': body
|
||||
'field_description/format':
|
||||
plugin: default_value
|
||||
default_value: wysiwyg
|
||||
|
||||
# ARTICLE (body)
|
||||
# node ref -> text
|
||||
'body/value': article
|
||||
'body/format':
|
||||
plugin: default_value
|
||||
default_value: wysiwyg
|
||||
|
||||
|
||||
# taxo term -> entity ref terms
|
||||
# use this one for fetchCol in plugin
|
||||
field_entrees:
|
||||
plugin: migration_lookup
|
||||
migration: d6_edlp_entrees
|
||||
source: entrees
|
||||
|
||||
# use this one for fetchAll in plugin
|
||||
# field_entrees:
|
||||
# -
|
||||
# plugin: iterator
|
||||
# source: entrees
|
||||
# process:
|
||||
# id: tid
|
||||
# -
|
||||
# plugin: flatten
|
||||
# -
|
||||
# plugin: migration_lookup
|
||||
# migration: d6_edlp_entrees
|
||||
# no_stub: true
|
||||
|
||||
# field_entrees:
|
||||
# plugin: iterator
|
||||
# source: entrees
|
||||
# process:
|
||||
# plugin: migration_lookup
|
||||
# migration: d6_edlp_entrees
|
||||
|
||||
|
||||
# field_genre -> field_genres
|
||||
field_genres:
|
||||
plugin: migration_lookup
|
||||
migration: d6_edlp_genres
|
||||
source: genres
|
||||
|
||||
# field_genres:
|
||||
# -
|
||||
# plugin: iterator
|
||||
# source: field_genre
|
||||
# process:
|
||||
# id: value
|
||||
# -
|
||||
# plugin: flatten
|
||||
# -
|
||||
# plugin: migration_lookup
|
||||
# migration: d6_edlp_genres
|
||||
|
||||
|
||||
# taxo term -> entity ref terms
|
||||
field_langues:
|
||||
plugin: migration_lookup
|
||||
migration: d6_edlp_langues
|
||||
source: langues
|
||||
|
||||
# field_artiste: field_locuteurs
|
||||
# text -> entity ref terms
|
||||
# instead of entity_generate, i create the term in prepareRow from plugin
|
||||
field_locuteurs: locuteurs
|
||||
# field_locuteurs:
|
||||
# plugin: entity_generate
|
||||
# entity_type: taxonomy_term
|
||||
# bundle_key: vid
|
||||
# bundle: locuteurs
|
||||
# source: locuteurs
|
||||
# # value_key: field_artiste_value
|
||||
|
||||
|
||||
# field_compositeur: field_collectionneurs
|
||||
# text -> entity ref terms
|
||||
# instead of entity_generate, i create the term in prepareRow from plugin
|
||||
field_collectionneurs: collectionneurs
|
||||
|
||||
|
||||
# # file
|
||||
# # field_mp3 -> field_son
|
||||
field_son:
|
||||
plugin: migration_lookup
|
||||
migration: d6_edlp_allfiles
|
||||
source: sons_fid
|
||||
# field_son:
|
||||
# # plugin: migration_lookup
|
||||
# # migration: d6_edlp_allfiles
|
||||
# # source: fid
|
||||
# plugin: iterator
|
||||
# source: field_mp3
|
||||
# process:
|
||||
# target_id:
|
||||
# plugin: migration_lookup
|
||||
# migration: d6_edlp_allfiles
|
||||
# source: fid
|
||||
|
||||
|
||||
|
||||
# workflow
|
||||
# status:
|
||||
# plugin: static_map
|
||||
# source: workflow
|
||||
# map:
|
||||
# 1: 0
|
||||
# 2: 0
|
||||
# 3: 1
|
||||
# 4: 1
|
||||
status:
|
||||
plugin: default_value
|
||||
default_value: 1
|
||||
|
||||
field_workflow:
|
||||
plugin: default_value
|
||||
default_value: "corpus_documents_publie"
|
||||
|
||||
|
||||
destination:
|
||||
plugin: entity:node
|
||||
migration_dependencies:
|
||||
required:
|
||||
- d6_edlp_users
|
||||
- d6_edlp_entrees
|
||||
- d6_edlp_genres
|
||||
- d6_edlp_langues
|
||||
- d6_edlp_allfiles
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
id: d6_edlp_entrees
|
||||
label: Edlp Drupal 6 entrees
|
||||
migration_tags:
|
||||
- Drupal 6
|
||||
migration_group: d6_edlp
|
||||
source:
|
||||
plugin: d6_edlp_taxonomy_term_entree
|
||||
bundle: 2
|
||||
process:
|
||||
name: name
|
||||
# get the node type entrée from source and add it to description field
|
||||
description/value:
|
||||
-
|
||||
plugin: get
|
||||
source: description
|
||||
-
|
||||
plugin: skip_on_empty
|
||||
method: row
|
||||
description/format:
|
||||
plugin: default_value
|
||||
default_value: wysiwyg
|
||||
|
||||
# get the node type page:notice from source and add it to notice field
|
||||
field_notice/value: notice
|
||||
field_notice/format:
|
||||
plugin: default_value
|
||||
default_value: wysiwyg
|
||||
|
||||
vid:
|
||||
plugin: default_value
|
||||
default_value: entrees
|
||||
weight: weight
|
||||
|
||||
destination:
|
||||
plugin: entity:taxonomy_term
|
||||
+93
@@ -0,0 +1,93 @@
|
||||
id: d6_edlp_evenements
|
||||
label: Edlp Drupal 6 evenement migration
|
||||
migration_tags:
|
||||
- Drupal 6
|
||||
deriver: Drupal\node\Plugin\migrate\D6NodeDeriver
|
||||
migration_group: d6_edlp
|
||||
source:
|
||||
plugin: d6_edlp_evenements
|
||||
node_type: event
|
||||
process:
|
||||
# In D6, nodes always have a tnid, but it's zero for untranslated nodes.
|
||||
# We normalize it to equal the nid in that case.
|
||||
# @see \Drupal\node\Plugin\migrate\source\d6\Node::prepareRow().
|
||||
# If you are using this file to build a custom migration consider removing
|
||||
# the nid and vid fields to allow incremental migrations.
|
||||
# nid: tnid
|
||||
# vid: vid
|
||||
type:
|
||||
plugin: default_value
|
||||
default_value: evenement
|
||||
langcode:
|
||||
plugin: default_value
|
||||
source: language
|
||||
default_value: "und"
|
||||
title:
|
||||
-
|
||||
plugin: get
|
||||
source: title
|
||||
-
|
||||
plugin: skip_on_empty
|
||||
method: row
|
||||
|
||||
# this is not working :(
|
||||
uid:
|
||||
-
|
||||
plugin: migration_lookup
|
||||
migration: d6_edlp_users
|
||||
source: node_uid
|
||||
-
|
||||
plugin: default_value
|
||||
default_value: 1
|
||||
|
||||
# status: status
|
||||
created: created
|
||||
changed: changed
|
||||
promote: promote
|
||||
sticky: sticky
|
||||
revision_uid: revision_uid
|
||||
revision_log: log
|
||||
revision_timestamp: timestamp
|
||||
|
||||
'body/value': body
|
||||
'body/format':
|
||||
plugin: default_value
|
||||
default_value: wysiwyg
|
||||
|
||||
|
||||
status:
|
||||
plugin: default_value
|
||||
default_value: 1
|
||||
|
||||
# status:
|
||||
# plugin: static_map
|
||||
# source: workflow
|
||||
# map:
|
||||
# 1: 0
|
||||
# 2: 0
|
||||
# 3: 1
|
||||
# 4: 1
|
||||
|
||||
# workflow
|
||||
# field_workflow_generic:
|
||||
# plugin: default_value
|
||||
# default_value: "generique_publie"
|
||||
|
||||
field_workflow_generic:
|
||||
plugin: static_map
|
||||
source: workflow
|
||||
map:
|
||||
1: "generique_masque"
|
||||
2: "generique_masque"
|
||||
3: "generique_publie"
|
||||
4: "generique_publie"
|
||||
|
||||
|
||||
field_date/value: date
|
||||
field_date/end_value: date
|
||||
|
||||
destination:
|
||||
plugin: entity:node
|
||||
migration_dependencies:
|
||||
required:
|
||||
- d6_edlp_users
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
id: d6_edlp_genres
|
||||
label: Edlp Drupal 6 genres
|
||||
migration_tags:
|
||||
- Drupal 6
|
||||
migration_group: d6_edlp
|
||||
source:
|
||||
plugin: d6_taxonomy_term
|
||||
bundle: 3
|
||||
process:
|
||||
name: name
|
||||
description: description
|
||||
vid:
|
||||
plugin: default_value
|
||||
default_value: genres
|
||||
|
||||
destination:
|
||||
plugin: entity:taxonomy_term
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
id: d6_edlp_langues
|
||||
label: Edlp Drupal 6 langues
|
||||
migration_tags:
|
||||
- Drupal 6
|
||||
migration_group: d6_edlp
|
||||
source:
|
||||
plugin: d6_taxonomy_term
|
||||
bundle: 4
|
||||
process:
|
||||
name: name
|
||||
description: description
|
||||
vid:
|
||||
plugin: default_value
|
||||
default_value: langues
|
||||
|
||||
destination:
|
||||
plugin: entity:taxonomy_term
|
||||
+133
@@ -0,0 +1,133 @@
|
||||
id: d6_edlp_pages
|
||||
label: Edlp Drupal 6 pages
|
||||
migration_tags:
|
||||
- Drupal 6
|
||||
deriver: Drupal\node\Plugin\migrate\D6NodeDeriver
|
||||
migration_group: d6_edlp
|
||||
source:
|
||||
plugin: d6_edlp_pages
|
||||
node_type: page
|
||||
process:
|
||||
# In D6, nodes always have a tnid, but it's zero for untranslated nodes.
|
||||
# We normalize it to equal the nid in that case.
|
||||
# @see \Drupal\node\Plugin\migrate\source\d6\Node::prepareRow().
|
||||
# If you are using this file to build a custom migration consider removing
|
||||
# the nid and vid fields to allow incremental migrations.
|
||||
# nid: tnid
|
||||
# vid: vid
|
||||
type:
|
||||
plugin: default_value
|
||||
default_value: page
|
||||
langcode:
|
||||
plugin: default_value
|
||||
source: language
|
||||
default_value: "und"
|
||||
title:
|
||||
-
|
||||
plugin: get
|
||||
source: title
|
||||
-
|
||||
plugin: skip_on_empty
|
||||
method: row
|
||||
|
||||
uid:
|
||||
-
|
||||
plugin: migration_lookup
|
||||
migration: d6_edlp_users
|
||||
source: node_uid
|
||||
-
|
||||
plugin: default_value
|
||||
default_value: 1
|
||||
|
||||
# status: status
|
||||
created: created
|
||||
changed: changed
|
||||
promote: promote
|
||||
sticky: sticky
|
||||
revision_uid: revision_uid
|
||||
revision_log: log
|
||||
revision_timestamp: timestamp
|
||||
|
||||
'body/value': body
|
||||
'body/format':
|
||||
plugin: default_value
|
||||
default_value: wysiwyg
|
||||
|
||||
# taxo term -> entity ref terms
|
||||
# use this one for fetchCol in plugin
|
||||
field_entrees:
|
||||
plugin: migration_lookup
|
||||
migration: d6_edlp_entrees
|
||||
source: entrees
|
||||
|
||||
# taxo term -> entity ref terms
|
||||
# use this one for fetchCol in plugin
|
||||
# field_page_type:
|
||||
# plugin: migration_lookup
|
||||
# migration: d6_edlp_pagetype
|
||||
# source: page_type
|
||||
|
||||
field_page_type:
|
||||
-
|
||||
plugin: skip_on_empty
|
||||
method: row
|
||||
message: 'Page type is missing, skiping row'
|
||||
source: page_type
|
||||
-
|
||||
plugin: migration_lookup
|
||||
migration: d6_edlp_pagetype
|
||||
|
||||
# TODO: exclude pages of type notice (will be incorporated directly into the entree taxo term)
|
||||
|
||||
# # file
|
||||
# # field_mp3 -> field_son
|
||||
# TODO: pour les pieces sonores les fichiers ne sont pas enregistrés dans le champ car trop lourd. Ils sont sous forme de lien dans le corps du texte. Comment normaliser ça ??
|
||||
field_son:
|
||||
plugin: migration_lookup
|
||||
migration: d6_edlp_allfiles
|
||||
source: sons_fid
|
||||
|
||||
# # field_visuel -> field_visuel
|
||||
field_visuel:
|
||||
plugin: migration_lookup
|
||||
migration: d6_edlp_allfiles
|
||||
source: visuels_fid
|
||||
|
||||
status:
|
||||
plugin: default_value
|
||||
default_value: 1
|
||||
|
||||
# status:
|
||||
# plugin: static_map
|
||||
# source: workflow
|
||||
# map:
|
||||
# 1: 0
|
||||
# 2: 0
|
||||
# 3: 1
|
||||
# 4: 1
|
||||
|
||||
# workflow
|
||||
# field_workflow_generic:
|
||||
# plugin: default_value
|
||||
# default_value: "generique_publie"
|
||||
|
||||
field_workflow_generic:
|
||||
plugin: static_map
|
||||
source: workflow
|
||||
map:
|
||||
1: "generique_masque"
|
||||
2: "generique_masque"
|
||||
3: "generique_publie"
|
||||
4: "generique_publie"
|
||||
|
||||
# fichiers attachés ??
|
||||
|
||||
destination:
|
||||
plugin: entity:node
|
||||
migration_dependencies:
|
||||
required:
|
||||
- d6_edlp_users
|
||||
- d6_edlp_entrees
|
||||
- d6_edlp_pagetype
|
||||
- d6_edlp_sons
|
||||
- d6_edlp_allfiles
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
id: d6_edlp_pagetype
|
||||
label: Edlp Drupal 6 type de page
|
||||
migration_tags:
|
||||
- Drupal 6
|
||||
migration_group: d6_edlp
|
||||
source:
|
||||
plugin: d6_taxonomy_term
|
||||
bundle: 1
|
||||
process:
|
||||
name: name
|
||||
description: description
|
||||
vid:
|
||||
plugin: default_value
|
||||
default_value: page_type
|
||||
|
||||
destination:
|
||||
plugin: entity:taxonomy_term
|
||||
+101
@@ -0,0 +1,101 @@
|
||||
id: d6_edlp_sons
|
||||
label: Edlp Drupal 6 sons
|
||||
migration_tags:
|
||||
- Drupal 6
|
||||
deriver: Drupal\node\Plugin\migrate\D6NodeDeriver
|
||||
migration_group: d6_edlp
|
||||
source:
|
||||
plugin: d6_edlp_sons
|
||||
node_type: son
|
||||
process:
|
||||
# In D6, nodes always have a tnid, but it's zero for untranslated nodes.
|
||||
# We normalize it to equal the nid in that case.
|
||||
# @see \Drupal\node\Plugin\migrate\source\d6\Node::prepareRow().
|
||||
# If you are using this file to build a custom migration consider removing
|
||||
# the nid and vid fields to allow incremental migrations.
|
||||
# nid: tnid
|
||||
# vid: vid
|
||||
type:
|
||||
plugin: default_value
|
||||
default_value: autre_son
|
||||
langcode:
|
||||
plugin: default_value
|
||||
source: language
|
||||
default_value: "und"
|
||||
title:
|
||||
-
|
||||
plugin: get
|
||||
source: title
|
||||
-
|
||||
plugin: skip_on_empty
|
||||
method: row
|
||||
|
||||
uid:
|
||||
-
|
||||
plugin: migration_lookup
|
||||
migration: d6_edlp_users
|
||||
source: node_uid
|
||||
-
|
||||
plugin: default_value
|
||||
default_value: 1
|
||||
|
||||
# status: status
|
||||
created: created
|
||||
changed: changed
|
||||
promote: promote
|
||||
sticky: sticky
|
||||
revision_uid: revision_uid
|
||||
revision_log: log
|
||||
revision_timestamp: timestamp
|
||||
|
||||
# body
|
||||
'body/value': body
|
||||
'body/format':
|
||||
plugin: default_value
|
||||
default_value: wysiwyg
|
||||
|
||||
# field_genre -> field_genres
|
||||
field_genres:
|
||||
plugin: migration_lookup
|
||||
migration: d6_edlp_genres
|
||||
source: genres
|
||||
|
||||
# field_artiste: field_locuteurs
|
||||
# text -> entity ref terms
|
||||
# instead of entity_generate, i create the term in prepareRow from plugin
|
||||
field_locuteurs: locuteurs
|
||||
|
||||
# field_compositeur: field_collectionneurs
|
||||
# text -> entity ref terms
|
||||
# instead of entity_generate, i create the term in prepareRow from plugin
|
||||
field_collectionneurs: collectionneurs
|
||||
|
||||
|
||||
# # file
|
||||
# # field_mp3 -> field_son
|
||||
field_son:
|
||||
plugin: migration_lookup
|
||||
migration: d6_edlp_allfiles
|
||||
source: sons_fid
|
||||
|
||||
# workflow
|
||||
status:
|
||||
plugin: static_map
|
||||
source: workflow
|
||||
map:
|
||||
1: 0
|
||||
2: 0
|
||||
3: 1
|
||||
4: 1
|
||||
|
||||
|
||||
|
||||
destination:
|
||||
plugin: entity:node
|
||||
migration_dependencies:
|
||||
required:
|
||||
- d6_edlp_users
|
||||
- d6_edlp_entrees
|
||||
- d6_edlp_genres
|
||||
- d6_edlp_langues
|
||||
- d6_edlp_allfiles
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
id: d6_edlp_users
|
||||
label: Edlp Drupal 6 User accounts
|
||||
migration_tags:
|
||||
- Drupal 6
|
||||
migration_group: d6_edlp
|
||||
source:
|
||||
plugin: d6_edlp_users
|
||||
process:
|
||||
# If you are using this file to build a custom migration consider removing
|
||||
# the uid field to allow incremental migrations.
|
||||
# uid: uid
|
||||
name: name
|
||||
pass: pass
|
||||
mail: mail
|
||||
created: created
|
||||
access: access
|
||||
login: login
|
||||
status: status
|
||||
timezone:
|
||||
plugin: user_update_7002
|
||||
source: timezone
|
||||
langcode:
|
||||
plugin: user_langcode
|
||||
source: language
|
||||
fallback_to_site_default: false
|
||||
preferred_langcode:
|
||||
plugin: user_langcode
|
||||
source: language
|
||||
fallback_to_site_default: true
|
||||
preferred_admin_langcode:
|
||||
plugin: user_langcode
|
||||
source: language
|
||||
fallback_to_site_default: true
|
||||
init: init
|
||||
roles:
|
||||
plugin: default_value
|
||||
default_value: "collectionneur"
|
||||
|
||||
destination:
|
||||
plugin: entity:user
|
||||
md5_passwords: true
|
||||
|
||||
migration_dependencies:
|
||||
# required:
|
||||
# - d6_user_role
|
||||
optional:
|
||||
- language
|
||||
- default_language
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
id: d6_edlp
|
||||
label: D6 Edlp
|
||||
description: Drupal 6 edlp content migration to Drupal 8.
|
||||
source_type: Drupal 6.
|
||||
shared_configuration:
|
||||
source:
|
||||
key: legacy
|
||||
@@ -0,0 +1,9 @@
|
||||
name: Edlp migration
|
||||
type: module
|
||||
description: Defines custom migration for edlp (from d6 to d8).
|
||||
core: 8.x
|
||||
package: Edlp
|
||||
dependencies:
|
||||
- migrate_drupal
|
||||
- migrate_plus
|
||||
- migrate_tools
|
||||
@@ -0,0 +1,27 @@
|
||||
https://www.drupaleasy.com/blogs/ultimike/2016/04/drupal-6-drupal-81x-custom-content-migration
|
||||
|
||||
https://thinkshout.com/blog/2017/05/skipping-a-version-migrating-from-drupal-6-to-drupal-8-with-drupal-migrate/
|
||||
|
||||
https://www.drupal.org/docs/8/upgrade/known-issues-when-upgrading-from-drupal-6-or-7-to-drupal-8
|
||||
|
||||
https://drupal.stackexchange.com/questions/164612/how-do-i-remove-a-configuration-object-from-the-active-configuration
|
||||
|
||||
https://www.metaltoad.com/blog/drupal-8-migrations-part-3-migrating-taxonomies-drupal-7
|
||||
|
||||
https://www.sitepoint.com/your-first-drupal-8-migration/
|
||||
|
||||
https://evolvingweb.ca/blog/drupal-8-migration-migrating-taxonomy-term-references-part-2
|
||||
|
||||
[text to taxonomy term](http://boylesoftware.com/blog/drupal-8-migration-taxonomy-term-lookups/)
|
||||
|
||||
[Upgrading Drupal 6 and i18n Content Translation to Drupal 8](https://www.dunix-data.de/blog/upgrading_drupal_6_and_i18n_content_translation_to_drupal_8)
|
||||
|
||||
[Migrating Drupal 7 File Entities to Drupal 8 Media Entities](https://www.previousnext.com.au/blog/migrating-drupal-7-file-entities-drupal-8-media-entities)
|
||||
|
||||
[D6 Taxonomy Term Reference Field is not migrated to D8 Field](https://www.drupal.org/node/2884240)
|
||||
|
||||
[Migrer un site Drupal 6 ou Drupal 7 vers Drupal 8](https://www.drupalfacile.org/sites/drupalfacile/files/blog/2016/06/dcnantes2016-migrerd6d7versd8.pdf)
|
||||
|
||||
[Migrating Aliases and Redirects to Drupal 8](https://evolvingweb.ca/blog/migrating-aliases-and-redirects-drupal-8)
|
||||
|
||||
[Migrating Drupal 7 redirects to Drupal 8](http://activelamp.com/blog/drupal/migrating-drupal-8-redirects/)
|
||||
@@ -0,0 +1,230 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\edlp_migrate\Plugin\migrate\source;
|
||||
|
||||
use Drupal\migrate\Row;
|
||||
use Drupal\node\Plugin\migrate\source\d6\Node as D6Node;
|
||||
|
||||
/**
|
||||
* Source plugin for edlp corpus migration.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d6_edlp_corpus"
|
||||
* )
|
||||
*/
|
||||
class D6EdlpCorpus extends D6Node {
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
$query = $this->select('node_revisions', 'nr');
|
||||
$query->innerJoin('node', 'n', static::JOIN);
|
||||
$this->handleTranslations($query);
|
||||
|
||||
$query->fields('n', [
|
||||
'nid',
|
||||
'type',
|
||||
'language',
|
||||
'status',
|
||||
'created',
|
||||
'changed',
|
||||
'comment',
|
||||
'promote',
|
||||
'moderate',
|
||||
'sticky',
|
||||
'tnid',
|
||||
'translate',
|
||||
])
|
||||
->fields('nr', [
|
||||
'title',
|
||||
'body',
|
||||
'teaser',
|
||||
'log',
|
||||
'timestamp',
|
||||
'format',
|
||||
'vid',
|
||||
]);
|
||||
$query->addField('n', 'uid', 'node_uid');
|
||||
$query->addField('nr', 'uid', 'revision_uid');
|
||||
|
||||
// If the content_translation module is enabled, get the source langcode
|
||||
// to fill the content_translation_source field.
|
||||
if ($this->moduleHandler->moduleExists('content_translation')) {
|
||||
$query->leftJoin('node', 'nt', 'n.tnid = nt.nid');
|
||||
$query->addField('nt', 'language', 'source_langcode');
|
||||
}
|
||||
|
||||
if (isset($this->configuration['node_type'])) {
|
||||
$query->condition('n.type', $this->configuration['node_type']);
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
|
||||
$fields = [
|
||||
'nid' => $this->t('Node ID'),
|
||||
'type' => $this->t('Type'),
|
||||
'title' => $this->t('Title'),
|
||||
'body' => $this->t('Body'),
|
||||
'format' => $this->t('Format'),
|
||||
'teaser' => $this->t('Teaser'),
|
||||
'node_uid' => $this->t('Node authored by (uid)'),
|
||||
'revision_uid' => $this->t('Revision authored by (uid)'),
|
||||
'created' => $this->t('Created timestamp'),
|
||||
'changed' => $this->t('Modified timestamp'),
|
||||
'status' => $this->t('Published'),
|
||||
'promote' => $this->t('Promoted to front page'),
|
||||
'sticky' => $this->t('Sticky at top of lists'),
|
||||
'revision' => $this->t('Create new revision'),
|
||||
'language' => $this->t('Language (fr, en, ...)'),
|
||||
'tnid' => $this->t('The translation set id for this node'),
|
||||
'timestamp' => $this->t('The timestamp the latest revision of this node was created.'),
|
||||
];
|
||||
return $fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function prepareRow(Row $row) {
|
||||
drush_print(' ');
|
||||
drush_print('- - - - - - - - - - - - - - - - - - - - - - - -');
|
||||
drush_print($row->getSourceProperty('title'));
|
||||
|
||||
|
||||
// format = 0 can happen when the body field is hidden. Set the format to 1
|
||||
// to avoid migration map issues (since the body field isn't used anyway).
|
||||
if ($row->getSourceProperty('format') === '0') {
|
||||
$row->setSourceProperty('format', $this->filterDefaultFormat);
|
||||
}
|
||||
|
||||
if ($this->moduleExists('content') && $this->getModuleSchemaVersion('content') >= 6001) {
|
||||
foreach ($this->getFieldValues($row) as $field => $values) {
|
||||
$row->setSourceProperty($field, $values);
|
||||
}
|
||||
}
|
||||
$row_nid = $row->getSourceProperty('nid');
|
||||
|
||||
|
||||
// Make sure we always have a translation set.
|
||||
if ($row->getSourceProperty('tnid') == 0) {
|
||||
$row->setSourceProperty('tnid', $row_nid);
|
||||
}
|
||||
// get the article content
|
||||
// drush_print_r($row->getSourceProperty('field_article'));
|
||||
$article_nid = $row->getSourceProperty('field_article')[0]['nid'];
|
||||
if($article_nid){
|
||||
// drush_print($article_nid);
|
||||
$query = $this->select('content_type_episode', 'ctp');
|
||||
// // $query->fields('cte', ['field_entree_value']);
|
||||
$query->condition('ctp.nid', $article_nid);
|
||||
$query->join('node_revisions', 'nr', 'nr.vid = ctp.vid');
|
||||
$query->addField('nr', 'body');
|
||||
$article = $query->execute()
|
||||
->fetchField();
|
||||
// drush_print_r($article);
|
||||
$row->setSourceProperty('article', $article);
|
||||
}
|
||||
|
||||
// get the entree values
|
||||
$query = $this->select('term_node', 'tn');
|
||||
// $query->fields('cte', ['field_entree_value']);
|
||||
$query->condition('tn.nid', $row_nid);
|
||||
$query->join('term_data', 'td', 'td.tid = tn.tid');
|
||||
$query->condition('td.vid', 2); // vid of voc entrees
|
||||
$query->addField('tn', 'tid');
|
||||
$query->distinct();
|
||||
$results = $query->execute()->fetchAll();
|
||||
|
||||
$entrees = [];
|
||||
foreach ($results as $key => $value) {
|
||||
$entrees[] = array($value['tid']);
|
||||
}
|
||||
$row->setSourceProperty('entrees', $entrees);
|
||||
|
||||
// Genres
|
||||
$genres = [];
|
||||
foreach ($row->getSourceProperty('field_genre') as $key => $value) {
|
||||
$genres[] = array($value['value']);
|
||||
}
|
||||
$row->setSourceProperty('genres', $genres);
|
||||
|
||||
$langues = [];
|
||||
foreach ($row->getSourceProperty('field_langue') as $key => $value) {
|
||||
$langues[] = array($value['value']);
|
||||
}
|
||||
$row->setSourceProperty('langues', $langues);
|
||||
|
||||
// locuteurs
|
||||
$locuteurs = [];
|
||||
foreach ($row->getSourceProperty('field_artiste') as $key => $value) {
|
||||
$term_name = $value['value'];
|
||||
// check if term already exists in configured vocabulary
|
||||
$term = array_shift(taxonomy_term_load_multiple_by_name($term_name, 'locuteurs'));
|
||||
if(!$term){
|
||||
// if not create the term and get the tid
|
||||
$term = \Drupal\taxonomy\Entity\Term::create([
|
||||
'vid' => 'locuteurs',
|
||||
'name' => $term_name,
|
||||
]);
|
||||
$term->save();
|
||||
}
|
||||
// record the tid in array
|
||||
$locuteurs[] = $term->get('tid')->value;
|
||||
}
|
||||
$row->setSourceProperty('locuteurs', $locuteurs);
|
||||
|
||||
// collectionneurs
|
||||
$collectionneurs = [];
|
||||
foreach ($row->getSourceProperty('field_compositeur') as $key => $value) {
|
||||
$term_name = $value['value'];
|
||||
// check if term already exists in configured vocabulary
|
||||
$term = array_shift(taxonomy_term_load_multiple_by_name($term_name, 'collectionneurs'));
|
||||
if(!$term){
|
||||
// if not create the term and get the tid
|
||||
$term = \Drupal\taxonomy\Entity\Term::create([
|
||||
'vid' => 'collectionneurs',
|
||||
'name' => $term_name,
|
||||
]);
|
||||
$term->save();
|
||||
}
|
||||
// record the tid in array
|
||||
$collectionneurs[] = $term->get('tid')->value;
|
||||
}
|
||||
$row->setSourceProperty('collectionneurs', $collectionneurs);
|
||||
|
||||
// son
|
||||
// drush_print('field_mp3 : ', 0, null, false);
|
||||
// drush_print_r($row->getSourceProperty('field_mp3'));
|
||||
$sons = [];
|
||||
foreach ($row->getSourceProperty('field_mp3') as $key => $value) {
|
||||
$sons[] = array($value['fid']);
|
||||
}
|
||||
$row->setSourceProperty('sons_fid', $sons);
|
||||
|
||||
// get the workflow state (will be converted on status)
|
||||
$query = $this->select('workflow_node', 'wn');
|
||||
$query->fields('wn', ['sid']);
|
||||
$query->condition('wn.nid', $row_nid);
|
||||
$results = $query->execute()->fetchField();
|
||||
|
||||
// drush_print('workflow query results : ', 0, null, false);
|
||||
// drush_print_r($results);
|
||||
|
||||
// $row->setSourceProperty('workflow', $results);
|
||||
|
||||
|
||||
$row = parent::prepareRow($row);
|
||||
return $row;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,144 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\edlp_migrate\Plugin\migrate\source;
|
||||
|
||||
use Drupal\migrate\Row;
|
||||
use Drupal\node\Plugin\migrate\source\d6\Node as D6Node;
|
||||
|
||||
/**
|
||||
* Source plugin for edlp corpus migration.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d6_edlp_evenements"
|
||||
* )
|
||||
*/
|
||||
class D6EdlpEvenements extends D6Node {
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
$query = $this->select('node_revisions', 'nr');
|
||||
$query->innerJoin('node', 'n', static::JOIN);
|
||||
$this->handleTranslations($query);
|
||||
|
||||
$query->fields('n', [
|
||||
'nid',
|
||||
'type',
|
||||
'language',
|
||||
'status',
|
||||
'created',
|
||||
'changed',
|
||||
'comment',
|
||||
'promote',
|
||||
'moderate',
|
||||
'sticky',
|
||||
'tnid',
|
||||
'translate',
|
||||
])
|
||||
->fields('nr', [
|
||||
'title',
|
||||
'body',
|
||||
'teaser',
|
||||
'log',
|
||||
'timestamp',
|
||||
'format',
|
||||
'vid',
|
||||
]);
|
||||
$query->addField('n', 'uid', 'node_uid');
|
||||
$query->addField('nr', 'uid', 'revision_uid');
|
||||
|
||||
// If the content_translation module is enabled, get the source langcode
|
||||
// to fill the content_translation_source field.
|
||||
if ($this->moduleHandler->moduleExists('content_translation')) {
|
||||
$query->leftJoin('node', 'nt', 'n.tnid = nt.nid');
|
||||
$query->addField('nt', 'language', 'source_langcode');
|
||||
}
|
||||
|
||||
if (isset($this->configuration['node_type'])) {
|
||||
$query->condition('n.type', $this->configuration['node_type']);
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
|
||||
$fields = [
|
||||
'nid' => $this->t('Node ID'),
|
||||
'type' => $this->t('Type'),
|
||||
'title' => $this->t('Title'),
|
||||
'body' => $this->t('Body'),
|
||||
'format' => $this->t('Format'),
|
||||
'teaser' => $this->t('Teaser'),
|
||||
'node_uid' => $this->t('Node authored by (uid)'),
|
||||
'revision_uid' => $this->t('Revision authored by (uid)'),
|
||||
'created' => $this->t('Created timestamp'),
|
||||
'changed' => $this->t('Modified timestamp'),
|
||||
'status' => $this->t('Published'),
|
||||
'promote' => $this->t('Promoted to front page'),
|
||||
'sticky' => $this->t('Sticky at top of lists'),
|
||||
'revision' => $this->t('Create new revision'),
|
||||
'language' => $this->t('Language (fr, en, ...)'),
|
||||
'tnid' => $this->t('The translation set id for this node'),
|
||||
'timestamp' => $this->t('The timestamp the latest revision of this node was created.'),
|
||||
];
|
||||
return $fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function prepareRow(Row $row) {
|
||||
drush_print(' ');
|
||||
drush_print('- - - - - - - - - - - - - - - - - - - - - - - -');
|
||||
drush_print($row->getSourceProperty('title'));
|
||||
|
||||
|
||||
// format = 0 can happen when the body field is hidden. Set the format to 1
|
||||
// to avoid migration map issues (since the body field isn't used anyway).
|
||||
if ($row->getSourceProperty('format') === '0') {
|
||||
$row->setSourceProperty('format', $this->filterDefaultFormat);
|
||||
}
|
||||
|
||||
if ($this->moduleExists('content') && $this->getModuleSchemaVersion('content') >= 6001) {
|
||||
foreach ($this->getFieldValues($row) as $field => $values) {
|
||||
$row->setSourceProperty($field, $values);
|
||||
}
|
||||
}
|
||||
$row_nid = $row->getSourceProperty('nid');
|
||||
|
||||
// Make sure we always have a translation set.
|
||||
if ($row->getSourceProperty('tnid') == 0) {
|
||||
$row->setSourceProperty('tnid', $row_nid);
|
||||
}
|
||||
|
||||
// date
|
||||
$date_field = $row->getSourceProperty('field_date');
|
||||
$date_value = $date_field[0]['value'];
|
||||
drush_print($date_value);
|
||||
|
||||
$row->setSourceProperty('date', $date_value);
|
||||
|
||||
// get the workflow status
|
||||
$query = $this->select('workflow_node', 'wn');
|
||||
$query->fields('wn', ['sid']);
|
||||
$query->condition('wn.nid', $row_nid);
|
||||
$results = $query->execute()->fetchField();
|
||||
// drush_print('workflow query results : ', 0, null, false);
|
||||
// drush_print_r($results);
|
||||
$row->setSourceProperty('workflow', $results);
|
||||
|
||||
// TODO: fichiers attachés ??
|
||||
|
||||
$row = parent::prepareRow($row);
|
||||
return $row;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,111 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\edlp_migrate\Plugin\migrate\source;
|
||||
|
||||
use Drupal\migrate\Row;
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
|
||||
|
||||
/**
|
||||
* Drupal 6 file source from database.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d6_edlp_file"
|
||||
* )
|
||||
*/
|
||||
class D6EdlpFile extends DrupalSqlBase {
|
||||
|
||||
/**
|
||||
* The file directory path.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $filePath;
|
||||
|
||||
/**
|
||||
* The temporary file path.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $tempFilePath;
|
||||
|
||||
/**
|
||||
* Flag for private or public file storage.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $isPublic;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
return $this->select('files', 'f')
|
||||
->fields('f')
|
||||
->orderBy('timestamp')
|
||||
// If two or more files have the same timestamp, they'll end up in a
|
||||
// non-deterministic order. Ordering by fid (or any other unique field)
|
||||
// will prevent this.
|
||||
->orderBy('f.fid');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function initializeIterator() {
|
||||
$site_path = isset($this->configuration['site_path']) ? $this->configuration['site_path'] : 'sites/default';
|
||||
// $filepath = $this->variableGet('file_directory_path', $site_path . '/files') . '/';
|
||||
// $filepath = str_replace('//', '/', $filepath);
|
||||
// drush_print('filepath : '.$filepath);
|
||||
$this->filePath = $this->variableGet('file_directory_path', $site_path . '/files') . '/';
|
||||
|
||||
$this->tempFilePath = $this->variableGet('file_directory_temp', '/tmp') . '/';
|
||||
|
||||
// FILE_DOWNLOADS_PUBLIC == 1 and FILE_DOWNLOADS_PRIVATE == 2.
|
||||
$this->isPublic = $this->variableGet('file_downloads', 1) == 1;
|
||||
return parent::initializeIterator();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function prepareRow(Row $row) {
|
||||
drush_print("D6EdlpFile");
|
||||
// drush_print_r($row);
|
||||
|
||||
$filepath = $row->getSourceProperty('filepath');
|
||||
$filepath = str_replace('//', '/', $filepath);
|
||||
$filepath = preg_replace('/^\//', '', $filepath);
|
||||
drush_print('filePath : '.$filepath);
|
||||
$row->setSourceProperty('filepath', $filepath);
|
||||
|
||||
$row->setSourceProperty('file_directory_path', $this->filePath);
|
||||
$row->setSourceProperty('temp_directory_path', $this->tempFilePath);
|
||||
$row->setSourceProperty('is_public', $this->isPublic);
|
||||
return parent::prepareRow($row);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
return [
|
||||
'fid' => $this->t('File ID'),
|
||||
'uid' => $this->t('The {users}.uid who added the file. If set to 0, this file was added by an anonymous user.'),
|
||||
'filename' => $this->t('File name'),
|
||||
'filepath' => $this->t('File path'),
|
||||
'filemime' => $this->t('File MIME Type'),
|
||||
'status' => $this->t('The published status of a file.'),
|
||||
'timestamp' => $this->t('The time that the file was added.'),
|
||||
'file_directory_path' => $this->t('The Drupal files path.'),
|
||||
'is_public' => $this->t('TRUE if the files directory is public otherwise FALSE.'),
|
||||
];
|
||||
}
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
$ids['fid']['type'] = 'integer';
|
||||
return $ids;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,232 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\edlp_migrate\Plugin\migrate\source;
|
||||
|
||||
use Drupal\Core\Database\Database;
|
||||
use Drupal\migrate\Row;
|
||||
use Drupal\node\Plugin\migrate\source\d6\Node as D6Node;
|
||||
|
||||
/**
|
||||
* Source plugin for edlp corpus migration.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d6_edlp_pages"
|
||||
* )
|
||||
*/
|
||||
class D6EdlpPages extends D6Node {
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
$query = $this->select('node_revisions', 'nr');
|
||||
$query->innerJoin('node', 'n', static::JOIN);
|
||||
$this->handleTranslations($query);
|
||||
|
||||
$query->fields('n', [
|
||||
'nid',
|
||||
'type',
|
||||
'language',
|
||||
'status',
|
||||
'created',
|
||||
'changed',
|
||||
'comment',
|
||||
'promote',
|
||||
'moderate',
|
||||
'sticky',
|
||||
'tnid',
|
||||
'translate',
|
||||
])
|
||||
->fields('nr', [
|
||||
'title',
|
||||
'body',
|
||||
'teaser',
|
||||
'log',
|
||||
'timestamp',
|
||||
'format',
|
||||
'vid',
|
||||
]);
|
||||
$query->addField('n', 'uid', 'node_uid');
|
||||
$query->addField('nr', 'uid', 'revision_uid');
|
||||
|
||||
// If the content_translation module is enabled, get the source langcode
|
||||
// to fill the content_translation_source field.
|
||||
if ($this->moduleHandler->moduleExists('content_translation')) {
|
||||
$query->leftJoin('node', 'nt', 'n.tnid = nt.nid');
|
||||
$query->addField('nt', 'language', 'source_langcode');
|
||||
}
|
||||
|
||||
if (isset($this->configuration['node_type'])) {
|
||||
$query->condition('n.type', $this->configuration['node_type']);
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
|
||||
$fields = [
|
||||
'nid' => $this->t('Node ID'),
|
||||
'type' => $this->t('Type'),
|
||||
'title' => $this->t('Title'),
|
||||
'body' => $this->t('Body'),
|
||||
'format' => $this->t('Format'),
|
||||
'teaser' => $this->t('Teaser'),
|
||||
'node_uid' => $this->t('Node authored by (uid)'),
|
||||
'revision_uid' => $this->t('Revision authored by (uid)'),
|
||||
'created' => $this->t('Created timestamp'),
|
||||
'changed' => $this->t('Modified timestamp'),
|
||||
'status' => $this->t('Published'),
|
||||
'promote' => $this->t('Promoted to front page'),
|
||||
'sticky' => $this->t('Sticky at top of lists'),
|
||||
'revision' => $this->t('Create new revision'),
|
||||
'language' => $this->t('Language (fr, en, ...)'),
|
||||
'tnid' => $this->t('The translation set id for this node'),
|
||||
'timestamp' => $this->t('The timestamp the latest revision of this node was created.'),
|
||||
];
|
||||
return $fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function prepareRow(Row $row) {
|
||||
drush_print(' ');
|
||||
drush_print('- - - - - - - - - - - - - - - - - - - - - - - -');
|
||||
drush_print($row->getSourceProperty('title'));
|
||||
|
||||
|
||||
// format = 0 can happen when the body field is hidden. Set the format to 1
|
||||
// to avoid migration map issues (since the body field isn't used anyway).
|
||||
if ($row->getSourceProperty('format') === '0') {
|
||||
$row->setSourceProperty('format', $this->filterDefaultFormat);
|
||||
}
|
||||
|
||||
if ($this->moduleExists('content') && $this->getModuleSchemaVersion('content') >= 6001) {
|
||||
foreach ($this->getFieldValues($row) as $field => $values) {
|
||||
$row->setSourceProperty($field, $values);
|
||||
}
|
||||
}
|
||||
$row_nid = $row->getSourceProperty('nid');
|
||||
|
||||
|
||||
// Make sure we always have a translation set.
|
||||
if ($row->getSourceProperty('tnid') == 0) {
|
||||
$row->setSourceProperty('tnid', $row_nid);
|
||||
}
|
||||
|
||||
// get the entree values
|
||||
$query = $this->select('term_node', 'tn');
|
||||
// $query->fields('cte', ['field_entree_value']);
|
||||
$query->condition('tn.nid', $row_nid);
|
||||
$query->join('term_data', 'td', 'td.tid = tn.tid');
|
||||
$query->condition('td.vid', 2); // vid of voc entrees
|
||||
$query->addField('tn', 'tid');
|
||||
$query->distinct();
|
||||
$results = $query->execute()->fetchAll();
|
||||
$entrees = [];
|
||||
foreach ($results as $key => $value) {
|
||||
$entrees[] = array($value['tid']);
|
||||
}
|
||||
$row->setSourceProperty('entrees', $entrees);
|
||||
|
||||
// Page type
|
||||
$query = $this->select('term_node', 'tn');
|
||||
$query->condition('tn.nid', $row_nid);
|
||||
$query->join('term_data', 'td', 'td.tid = tn.tid');
|
||||
$query->condition('td.vid', 1); // vid of voc page type
|
||||
$query->addField('tn', 'tid');
|
||||
$query->distinct();
|
||||
$results = $query->execute()->fetchAll();
|
||||
$pagetype = [];
|
||||
foreach ($results as $key => $value) {
|
||||
// avoid notice type (tid 8)
|
||||
// row will be skiped if empty
|
||||
if($value['tid'] !== "8"){
|
||||
drush_print('page type : '.$value['tid']);
|
||||
$pagetype[] = array($value['tid']);
|
||||
}else{
|
||||
drush_print('----- NOTICE -----');
|
||||
}
|
||||
}
|
||||
drush_print('pagetype empty : '.empty($pagetype));
|
||||
// if(count($pagetype) < 1){
|
||||
// $pagetype = FALSE;
|
||||
// }
|
||||
$row->setSourceProperty('page_type', !empty($pagetype) ? $pagetype : 0);
|
||||
|
||||
// son
|
||||
// TODO: pour les pieces sonores les fichiers ne sont pas enregistrés dans le champ car trop lourd. Ils sont sous forme de lien dans le corps du texte. Comment normaliser ça ??
|
||||
// $sons = [];
|
||||
// foreach ($row->getSourceProperty('field_mp3') as $key => $value) {
|
||||
// $sons[] = array($value['fid']);
|
||||
// }
|
||||
// $row->setSourceProperty('sons_fid', $sons);
|
||||
$body = $row->getSourceProperty('body');
|
||||
preg_match_all('/href="(\/?sons\/[^"]+)"/', $body, $links);
|
||||
if(isset($links[1][0])){
|
||||
// drush_print('links : ', 0, null, false);
|
||||
// drush_print_r($links);
|
||||
$path = preg_replace('/^\//', '', $links[1][0]);
|
||||
// find the source path
|
||||
$query = $this->select('url_alias', 'ua');
|
||||
$query->condition('dst', $path);
|
||||
$query->addField('ua', 'src');
|
||||
$src = $query->execute()->fetchField();
|
||||
// drush_print('src : ', 0, null, false);
|
||||
// drush_print_r($src);
|
||||
if($src){
|
||||
// get the nid
|
||||
$nid = str_replace('node/', '', $src);
|
||||
// drush_print('nid : ', 0, null, false);
|
||||
// drush_print_r($nid);
|
||||
// find the new nid of the enregistrement (corpus item) from migration map
|
||||
// get the d6_edlp_migration
|
||||
// TODO: is this working for both corpus and sons elements ??
|
||||
$new_nid = Database::getConnection('default', 'default')
|
||||
->select('migrate_map_d6_edlp_sons', 'm')
|
||||
->fields('m', ['destid1'])
|
||||
->condition('sourceid1', $nid)
|
||||
->execute()
|
||||
->fetchField();
|
||||
// drush_print('new_nid : ', 0, null, false);
|
||||
// drush_print_r($new_nid);
|
||||
if($new_nid){
|
||||
$body = str_replace($path, "node/".$new_nid, $body);
|
||||
}
|
||||
}else{
|
||||
// drush_print('no source for path : ', 0, null, false);
|
||||
// drush_print_r($path);
|
||||
}
|
||||
}
|
||||
$row->setSourceProperty('body', $body);
|
||||
|
||||
// visuel
|
||||
$visuels = [];
|
||||
foreach ($row->getSourceProperty('field_visuel') as $key => $value) {
|
||||
$visuels[] = array($value['fid']);
|
||||
}
|
||||
$row->setSourceProperty('visuels_fid', $visuels);
|
||||
|
||||
// get the workflow status
|
||||
$query = $this->select('workflow_node', 'wn');
|
||||
$query->fields('wn', ['sid']);
|
||||
$query->condition('wn.nid', $row_nid);
|
||||
$results = $query->execute()->fetchField();
|
||||
// drush_print('workflow query results : ', 0, null, false);
|
||||
// drush_print_r($results);
|
||||
$row->setSourceProperty('workflow', $results);
|
||||
|
||||
// fichiers attachés ??
|
||||
|
||||
$row = parent::prepareRow($row);
|
||||
return $row;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,193 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\edlp_migrate\Plugin\migrate\source;
|
||||
|
||||
use Drupal\migrate\Row;
|
||||
use Drupal\node\Plugin\migrate\source\d6\Node as D6Node;
|
||||
|
||||
/**
|
||||
* Source plugin for edlp corpus migration.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d6_edlp_sons"
|
||||
* )
|
||||
*/
|
||||
class D6EdlpSons extends D6Node {
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
$query = $this->select('node_revisions', 'nr');
|
||||
$query->innerJoin('node', 'n', static::JOIN);
|
||||
$this->handleTranslations($query);
|
||||
|
||||
$query->fields('n', [
|
||||
'nid',
|
||||
'type',
|
||||
'language',
|
||||
'status',
|
||||
'created',
|
||||
'changed',
|
||||
'comment',
|
||||
'promote',
|
||||
'moderate',
|
||||
'sticky',
|
||||
'tnid',
|
||||
'translate',
|
||||
])
|
||||
->fields('nr', [
|
||||
'title',
|
||||
'body',
|
||||
'teaser',
|
||||
'log',
|
||||
'timestamp',
|
||||
'format',
|
||||
'vid',
|
||||
]);
|
||||
$query->addField('n', 'uid', 'node_uid');
|
||||
$query->addField('nr', 'uid', 'revision_uid');
|
||||
|
||||
// If the content_translation module is enabled, get the source langcode
|
||||
// to fill the content_translation_source field.
|
||||
if ($this->moduleHandler->moduleExists('content_translation')) {
|
||||
$query->leftJoin('node', 'nt', 'n.tnid = nt.nid');
|
||||
$query->addField('nt', 'language', 'source_langcode');
|
||||
}
|
||||
|
||||
if (isset($this->configuration['node_type'])) {
|
||||
$query->condition('n.type', $this->configuration['node_type']);
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
|
||||
$fields = [
|
||||
'nid' => $this->t('Node ID'),
|
||||
'type' => $this->t('Type'),
|
||||
'title' => $this->t('Title'),
|
||||
'body' => $this->t('Body'),
|
||||
'format' => $this->t('Format'),
|
||||
'teaser' => $this->t('Teaser'),
|
||||
'node_uid' => $this->t('Node authored by (uid)'),
|
||||
'revision_uid' => $this->t('Revision authored by (uid)'),
|
||||
'created' => $this->t('Created timestamp'),
|
||||
'changed' => $this->t('Modified timestamp'),
|
||||
'status' => $this->t('Published'),
|
||||
'promote' => $this->t('Promoted to front page'),
|
||||
'sticky' => $this->t('Sticky at top of lists'),
|
||||
'revision' => $this->t('Create new revision'),
|
||||
'language' => $this->t('Language (fr, en, ...)'),
|
||||
'tnid' => $this->t('The translation set id for this node'),
|
||||
'timestamp' => $this->t('The timestamp the latest revision of this node was created.'),
|
||||
];
|
||||
return $fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function prepareRow(Row $row) {
|
||||
drush_print(' ');
|
||||
drush_print('- - - - - - - - - - - - - - - - - - - - - - - -');
|
||||
drush_print($row->getSourceProperty('title'));
|
||||
|
||||
|
||||
// format = 0 can happen when the body field is hidden. Set the format to 1
|
||||
// to avoid migration map issues (since the body field isn't used anyway).
|
||||
if ($row->getSourceProperty('format') === '0') {
|
||||
$row->setSourceProperty('format', $this->filterDefaultFormat);
|
||||
}
|
||||
|
||||
if ($this->moduleExists('content') && $this->getModuleSchemaVersion('content') >= 6001) {
|
||||
foreach ($this->getFieldValues($row) as $field => $values) {
|
||||
$row->setSourceProperty($field, $values);
|
||||
}
|
||||
}
|
||||
$row_nid = $row->getSourceProperty('nid');
|
||||
|
||||
|
||||
// Make sure we always have a translation set.
|
||||
if ($row->getSourceProperty('tnid') == 0) {
|
||||
$row->setSourceProperty('tnid', $row_nid);
|
||||
}
|
||||
|
||||
// Genres
|
||||
$genres = [];
|
||||
foreach ($row->getSourceProperty('field_genre') as $key => $value) {
|
||||
$genres[] = array($value['value']);
|
||||
}
|
||||
$row->setSourceProperty('genres', $genres);
|
||||
|
||||
// locuteurs
|
||||
$locuteurs = [];
|
||||
foreach ($row->getSourceProperty('field_artiste') as $key => $value) {
|
||||
$term_name = $value['value'];
|
||||
// check if term already exists in configured vocabulary
|
||||
$term = array_shift(taxonomy_term_load_multiple_by_name($term_name, 'locuteurs'));
|
||||
if(!$term){
|
||||
// if not create the term and get the tid
|
||||
$term = \Drupal\taxonomy\Entity\Term::create([
|
||||
'vid' => 'locuteurs',
|
||||
'name' => $term_name,
|
||||
]);
|
||||
$term->save();
|
||||
}
|
||||
// record the tid in array
|
||||
$locuteurs[] = $term->get('tid')->value;
|
||||
}
|
||||
$row->setSourceProperty('locuteurs', $locuteurs);
|
||||
|
||||
// collectionneurs
|
||||
$collectionneurs = [];
|
||||
foreach ($row->getSourceProperty('field_compositeur') as $key => $value) {
|
||||
$term_name = $value['value'];
|
||||
// check if term already exists in configured vocabulary
|
||||
$term = array_shift(taxonomy_term_load_multiple_by_name($term_name, 'collectionneurs'));
|
||||
if(!$term){
|
||||
// if not create the term and get the tid
|
||||
$term = \Drupal\taxonomy\Entity\Term::create([
|
||||
'vid' => 'collectionneurs',
|
||||
'name' => $term_name,
|
||||
]);
|
||||
$term->save();
|
||||
}
|
||||
// record the tid in array
|
||||
$collectionneurs[] = $term->get('tid')->value;
|
||||
}
|
||||
$row->setSourceProperty('collectionneurs', $collectionneurs);
|
||||
|
||||
// son
|
||||
// drush_print('field_mp3 : ', 0, null, false);
|
||||
// drush_print_r($row->getSourceProperty('field_mp3'));
|
||||
$sons = [];
|
||||
foreach ($row->getSourceProperty('field_mp3') as $key => $value) {
|
||||
$sons[] = array($value['fid']);
|
||||
}
|
||||
$row->setSourceProperty('sons_fid', $sons);
|
||||
|
||||
// get the workflow state (will be converted on status)
|
||||
$query = $this->select('workflow_node', 'wn');
|
||||
$query->fields('wn', ['sid']);
|
||||
$query->condition('wn.nid', $row_nid);
|
||||
$results = $query->execute()->fetchField();
|
||||
|
||||
// drush_print('workflow query results : ', 0, null, false);
|
||||
// drush_print_r($results);
|
||||
|
||||
$row->setSourceProperty('workflow', $results);
|
||||
|
||||
|
||||
$row = parent::prepareRow($row);
|
||||
return $row;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+169
@@ -0,0 +1,169 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\edlp_migrate\Plugin\migrate\source;
|
||||
|
||||
use Drupal\Core\Database\Database;
|
||||
use Drupal\migrate\Row;
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
|
||||
|
||||
/**
|
||||
* D6 Edlp Taxonomy Entree term source from database.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d6_edlp_taxonomy_term_entree"
|
||||
* )
|
||||
*/
|
||||
class D6EdlpTaxonomyTermEntree extends DrupalSqlBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
// drush_print('D6EdlpTaxonomyTermEntree query');
|
||||
|
||||
$query = $this->select('term_data', 'td')
|
||||
->fields('td')
|
||||
->distinct()
|
||||
->orderBy('td.tid');
|
||||
|
||||
if (isset($this->configuration['bundle'])) {
|
||||
$query->condition('td.vid', (array) $this->configuration['bundle'], 'IN');
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
$fields = [
|
||||
'tid' => $this->t('The term ID.'),
|
||||
'vid' => $this->t('Existing term VID'),
|
||||
'name' => $this->t('The name of the term.'),
|
||||
'description' => $this->t('The term description.'),
|
||||
'weight' => $this->t('Weight'),
|
||||
'parent' => $this->t("The Drupal term IDs of the term's parents."),
|
||||
'node_nid' => $this->t("The node's nid of entree's description."),
|
||||
];
|
||||
if (isset($this->configuration['translations'])) {
|
||||
$fields['language'] = $this->t('The term language.');
|
||||
$fields['trid'] = $this->t('Translation ID.');
|
||||
}
|
||||
// print_r($fields);
|
||||
// print_r("\n");
|
||||
|
||||
return $fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function prepareRow(Row $row) {
|
||||
// drush_print_r($row);
|
||||
// Find parents for this row.
|
||||
$parents = $this->select('term_hierarchy', 'th')
|
||||
->fields('th', ['parent', 'tid'])
|
||||
->condition('tid', $row->getSourceProperty('tid'))
|
||||
->execute()
|
||||
->fetchCol();
|
||||
$row->setSourceProperty('parent', $parents);
|
||||
|
||||
// find node attached to this term for description
|
||||
$query = $this->select('content_type_entree', 'cte');
|
||||
// $query->fields('cte', ['nid', 'vid', 'field_entree_value']);
|
||||
$query->condition('cte.field_entree_value', $row->getSourceProperty('tid'));
|
||||
$query->join('node_revisions', 'nr', 'cte.nid = nr.nid');
|
||||
$query->addField('nr', 'body');
|
||||
$description = $query->execute()
|
||||
->fetchField();
|
||||
// drush_print_r($node);
|
||||
// empty enties to keep migrate
|
||||
$empty_entries = array(267, 291, 309, 310);
|
||||
|
||||
if($description == "" && in_array($row->getSourceProperty('tid'), $empty_entries)){
|
||||
$description = "a remplir";
|
||||
}
|
||||
|
||||
$row->setSourceProperty('description', $description);
|
||||
|
||||
// get the node type page:notice from source and add it to notice field
|
||||
// find node attached to this term for description
|
||||
// get all notice
|
||||
$query = $this->select('term_node', 'tn');
|
||||
$query->condition('tn.tid', 8 ); // page type notice tid
|
||||
$query->addField('tn', 'nid');
|
||||
$notices_nids = $query->execute()->fetchCol();
|
||||
|
||||
// get all nodes taged with the current entree
|
||||
$query = $this->select('term_node', 'tn');
|
||||
$query->condition('tn.tid', $row->getSourceProperty('tid'));
|
||||
$query->addField('tn', 'nid');
|
||||
$nodes_nids = $query->execute()->fetchCol();
|
||||
|
||||
$notice_nid = array_shift(array_intersect($notices_nids, $nodes_nids));
|
||||
// drush_print('notice_nid : ', 0, null, false);
|
||||
// drush_print_r($notice_nid);
|
||||
$query = $this->select('node_revisions', 'nr');
|
||||
$query->condition('nr.nid', $notice_nid ); // page type notice tid
|
||||
$query->addField('nr', 'body');
|
||||
$notices_body = $query->execute()->fetchField();
|
||||
// drush_print('notices_body : ', 0, null, false);
|
||||
// drush_print_r($notices_body);
|
||||
|
||||
// convert inner text links to internal nodes to new url
|
||||
preg_match_all('/href="(\/?corpus\/[^"]+)"/', $notices_body, $links);
|
||||
// drush_print('links : ', 0, null, false);
|
||||
// drush_print_r($links);
|
||||
foreach ($links[1] as $key => $path) {
|
||||
$path = preg_replace('/^\//', '', $path);
|
||||
// drush_print('path : ', 0, null, false);
|
||||
// drush_print_r($path);
|
||||
|
||||
// find the source path
|
||||
$query = $this->select('url_alias', 'ua');
|
||||
$query->condition('dst', $path);
|
||||
$query->addField('ua', 'src');
|
||||
$src = $query->execute()->fetchField();
|
||||
// drush_print('src : ', 0, null, false);
|
||||
// drush_print_r($src);
|
||||
if($src){
|
||||
// get the nid
|
||||
$nid = str_replace('node/', '', $src);
|
||||
// drush_print('nid : ', 0, null, false);
|
||||
// drush_print_r($nid);
|
||||
// find the new nid of the enregistrement (corpus item) from migration map
|
||||
// get the d6_edlp_migration
|
||||
// drush_print_r($this->migration->getIdMap()->lookupDestinationId(array($nid)));
|
||||
$new_nid = Database::getConnection('default', 'default')
|
||||
->select('migrate_map_d6_edlp_corpus', 'm')
|
||||
->fields('m', ['destid1'])
|
||||
->condition('sourceid1', $nid)
|
||||
->execute()
|
||||
->fetchField();
|
||||
// drush_print('new_nid : ', 0, null, false);
|
||||
// drush_print_r($new_nid);
|
||||
if($new_nid){
|
||||
$notices_body = str_replace($path, "node/".$new_nid, $notices_body);
|
||||
}
|
||||
}else{
|
||||
drush_print('no source for path : ', 0, null, false);
|
||||
drush_print_r($path);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$row->setSourceProperty('notice', $notices_body);
|
||||
|
||||
return parent::prepareRow($row);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
$ids['tid']['type'] = 'integer';
|
||||
return $ids;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,132 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\edlp_migrate\Plugin\migrate\source;
|
||||
|
||||
use Drupal\migrate\Row;
|
||||
use Drupal\user\Plugin\migrate\source\d6\User as D6User;
|
||||
|
||||
/**
|
||||
* Source plugin for edlp user accounts.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d6_edlp_users"
|
||||
* )
|
||||
*/
|
||||
class D6EdlpUsers extends D6User {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
return $this->select('users', 'u')
|
||||
->fields('u', array_keys($this->baseFields()))
|
||||
->condition('u.uid', 0, '>');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
$fields = $this->baseFields();
|
||||
|
||||
// Add roles field.
|
||||
$fields['roles'] = $this->t('Roles');
|
||||
|
||||
// Profile fields.
|
||||
if ($this->moduleExists('profile')) {
|
||||
$fields += $this->select('profile_fields', 'pf')
|
||||
->fields('pf', ['name', 'title'])
|
||||
->execute()
|
||||
->fetchAllKeyed();
|
||||
}
|
||||
|
||||
return $fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function prepareRow(Row $row) {
|
||||
// User roles.
|
||||
$roles = $this->select('users_roles', 'ur')
|
||||
->fields('ur', ['rid'])
|
||||
->condition('ur.uid', $row->getSourceProperty('uid'))
|
||||
->execute()
|
||||
->fetchCol();
|
||||
$row->setSourceProperty('roles', $roles);
|
||||
|
||||
// We are adding here the Event contributed module column.
|
||||
// @see https://api.drupal.org/api/drupal/modules%21user%21user.install/function/user_update_7002/7
|
||||
if ($row->hasSourceProperty('timezone_id') && $row->getSourceProperty('timezone_id')) {
|
||||
if ($this->getDatabase()->schema()->tableExists('event_timezones')) {
|
||||
$event_timezone = $this->select('event_timezones', 'e')
|
||||
->fields('e', ['name'])
|
||||
->condition('e.timezone', $row->getSourceProperty('timezone_id'))
|
||||
->execute()
|
||||
->fetchField();
|
||||
if ($event_timezone) {
|
||||
$row->setSourceProperty('event_timezone', $event_timezone);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Unserialize Data.
|
||||
$row->setSourceProperty('data', unserialize($row->getSourceProperty('data')));
|
||||
|
||||
return parent::prepareRow($row);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
return [
|
||||
'uid' => [
|
||||
'type' => 'integer',
|
||||
'alias' => 'u',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the user base fields to be migrated.
|
||||
*
|
||||
* @return array
|
||||
* Associative array having field name as key and description as value.
|
||||
*/
|
||||
protected function baseFields() {
|
||||
$fields = [
|
||||
'uid' => $this->t('User ID'),
|
||||
'name' => $this->t('Username'),
|
||||
'pass' => $this->t('Password'),
|
||||
'mail' => $this->t('Email address'),
|
||||
'theme' => $this->t('Theme'),
|
||||
'signature' => $this->t('Signature'),
|
||||
'signature_format' => $this->t('Signature format'),
|
||||
'created' => $this->t('Registered timestamp'),
|
||||
'access' => $this->t('Last access timestamp'),
|
||||
'login' => $this->t('Last login timestamp'),
|
||||
'status' => $this->t('Status'),
|
||||
'timezone' => $this->t('Timezone'),
|
||||
'language' => $this->t('Language'),
|
||||
'picture' => $this->t('Picture'),
|
||||
'init' => $this->t('Init'),
|
||||
'data' => $this->t('User data'),
|
||||
];
|
||||
|
||||
// Possible field added by Date contributed module.
|
||||
// @see https://api.drupal.org/api/drupal/modules%21user%21user.install/function/user_update_7002/7
|
||||
if ($this->getDatabase()->schema()->fieldExists('users', 'timezone_name')) {
|
||||
$fields['timezone_name'] = $this->t('Timezone (Date)');
|
||||
}
|
||||
|
||||
// Possible field added by Event contributed module.
|
||||
// @see https://api.drupal.org/api/drupal/modules%21user%21user.install/function/user_update_7002/7
|
||||
if ($this->getDatabase()->schema()->fieldExists('users', 'timezone_id')) {
|
||||
$fields['timezone_id'] = $this->t('Timezone (Event)');
|
||||
}
|
||||
|
||||
return $fields;
|
||||
}
|
||||
|
||||
}
|
||||
+103
@@ -0,0 +1,103 @@
|
||||
uuid: c753bc0d-2afe-4551-a18c-807ff5dca454
|
||||
langcode: fr
|
||||
status: true
|
||||
dependencies: { }
|
||||
id: upgrade_d6_block
|
||||
class: Drupal\migrate\Plugin\Migration
|
||||
field_plugin_method: null
|
||||
cck_plugin_method: null
|
||||
migration_tags:
|
||||
- 'Drupal 6'
|
||||
migration_group: migrate_drupal_6
|
||||
label: Blocks
|
||||
source:
|
||||
plugin: block
|
||||
process:
|
||||
status:
|
||||
plugin: skip_on_empty
|
||||
method: row
|
||||
source: status
|
||||
id:
|
||||
plugin: make_unique_entity_field
|
||||
entity_type: block
|
||||
field: id
|
||||
postfix: _
|
||||
length: 32
|
||||
source: module
|
||||
plugin:
|
||||
-
|
||||
plugin: static_map
|
||||
bypass: true
|
||||
source:
|
||||
- module
|
||||
- delta
|
||||
map:
|
||||
book:
|
||||
- book_navigation
|
||||
comment:
|
||||
- 'views_block:comments_recent-block_1'
|
||||
forum:
|
||||
- forum_active_block
|
||||
- forum_new_block
|
||||
locale:
|
||||
- language_block
|
||||
node:
|
||||
- node_syndicate_block
|
||||
search:
|
||||
- search_form_block
|
||||
statistics:
|
||||
- statistics_popular_block
|
||||
system:
|
||||
- system_powered_by_block
|
||||
user:
|
||||
- user_login_block
|
||||
- 'system_menu_block:tools'
|
||||
- 'views_block:who_s_new-block_1'
|
||||
- 'views_block:who_s_online-who_s_online_block'
|
||||
-
|
||||
plugin: block_plugin_id
|
||||
-
|
||||
plugin: skip_on_empty
|
||||
method: row
|
||||
theme:
|
||||
plugin: block_theme
|
||||
source:
|
||||
- theme
|
||||
- default_theme
|
||||
- admin_theme
|
||||
region:
|
||||
plugin: block_region
|
||||
source:
|
||||
- theme
|
||||
- '@theme'
|
||||
- region
|
||||
map:
|
||||
garland:
|
||||
bartik:
|
||||
header: header
|
||||
footer: footer_fifth
|
||||
left: sidebar_first
|
||||
right: sidebar_second
|
||||
default_value: content
|
||||
weight: weight
|
||||
settings:
|
||||
plugin: block_settings
|
||||
source:
|
||||
- '@plugin'
|
||||
- delta
|
||||
- settings
|
||||
- title
|
||||
visibility:
|
||||
plugin: block_visibility
|
||||
source:
|
||||
- visibility
|
||||
- pages
|
||||
- roles
|
||||
skip_php: true
|
||||
destination:
|
||||
plugin: 'entity:block'
|
||||
migration_dependencies:
|
||||
required:
|
||||
- upgrade_menu
|
||||
- upgrade_d6_user_role
|
||||
optional: { }
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
uuid: 000c667a-afec-4496-ada0-872cdfdc11dd
|
||||
langcode: fr
|
||||
status: true
|
||||
dependencies: { }
|
||||
id: upgrade_d6_date_formats
|
||||
class: Drupal\migrate\Plugin\Migration
|
||||
field_plugin_method: null
|
||||
cck_plugin_method: null
|
||||
migration_tags:
|
||||
- 'Drupal 6'
|
||||
migration_group: migrate_drupal_6
|
||||
label: 'Date format configuration'
|
||||
source:
|
||||
plugin: variable_multirow
|
||||
variables:
|
||||
- date_format_long
|
||||
- date_format_medium
|
||||
- date_format_short
|
||||
source_module: system
|
||||
process:
|
||||
id:
|
||||
plugin: static_map
|
||||
source: name
|
||||
map:
|
||||
date_format_long: long
|
||||
date_format_short: short
|
||||
date_format_medium: medium
|
||||
pattern: value
|
||||
destination:
|
||||
plugin: 'entity:date_format'
|
||||
migration_dependencies:
|
||||
required: { }
|
||||
optional: { }
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
uuid: b39c0d9d-deef-477b-b90d-9f7c8e121050
|
||||
langcode: fr
|
||||
status: true
|
||||
dependencies: { }
|
||||
id: upgrade_d6_dblog_settings
|
||||
class: Drupal\migrate\Plugin\Migration
|
||||
field_plugin_method: null
|
||||
cck_plugin_method: null
|
||||
migration_tags:
|
||||
- 'Drupal 6'
|
||||
migration_group: migrate_drupal_6
|
||||
label: 'Database logging configuration'
|
||||
source:
|
||||
plugin: variable
|
||||
variables:
|
||||
- dblog_row_limit
|
||||
source_module: dblog
|
||||
process:
|
||||
row_limit: dblog_row_limit
|
||||
destination:
|
||||
plugin: config
|
||||
config_name: dblog.settings
|
||||
migration_dependencies:
|
||||
required: { }
|
||||
optional: { }
|
||||
+136
@@ -0,0 +1,136 @@
|
||||
uuid: b8ed99c1-7f9d-4558-b791-627e575505f0
|
||||
langcode: fr
|
||||
status: true
|
||||
dependencies: { }
|
||||
id: upgrade_d6_field
|
||||
class: Drupal\migrate_drupal\Plugin\migrate\FieldMigration
|
||||
field_plugin_method: null
|
||||
cck_plugin_method: null
|
||||
migration_tags:
|
||||
- 'Drupal 6'
|
||||
migration_group: migrate_drupal_6
|
||||
label: 'Field configuration'
|
||||
source:
|
||||
plugin: d6_field
|
||||
constants:
|
||||
entity_type: node
|
||||
langcode: en
|
||||
process:
|
||||
entity_type: constants/entity_type
|
||||
status: active
|
||||
langcode: constants/langcode
|
||||
field_name: field_name
|
||||
type:
|
||||
plugin: field_type
|
||||
source:
|
||||
- type
|
||||
- widget_type
|
||||
map:
|
||||
userreference:
|
||||
userreference_select: entity_reference
|
||||
userreference_buttons: entity_reference
|
||||
userreference_autocomplete: entity_reference
|
||||
nodereference:
|
||||
nodereference_select: entity_reference
|
||||
number_integer:
|
||||
number: integer
|
||||
optionwidgets_select: list_integer
|
||||
optionwidgets_buttons: list_integer
|
||||
optionwidgets_onoff: boolean
|
||||
number_decimal:
|
||||
number: decimal
|
||||
optionwidgets_select: list_float
|
||||
optionwidgets_buttons: list_float
|
||||
optionwidgets_onoff: boolean
|
||||
number_float:
|
||||
number: float
|
||||
optionwidgets_select: list_float
|
||||
optionwidgets_buttons: list_float
|
||||
optionwidgets_onoff: boolean
|
||||
email:
|
||||
email_textfield: email
|
||||
filefield:
|
||||
imagefield_widget: image
|
||||
filefield_widget: file
|
||||
fr_phone:
|
||||
phone_textfield: telephone
|
||||
be_phone:
|
||||
phone_textfield: telephone
|
||||
it_phone:
|
||||
phone_textfield: telephone
|
||||
el_phone:
|
||||
phone_textfield: telephone
|
||||
ch_phone:
|
||||
phone_textfield: telephone
|
||||
ca_phone:
|
||||
phone_textfield: telephone
|
||||
cr_phone:
|
||||
phone_textfield: telephone
|
||||
pa_phone:
|
||||
phone_textfield: telephone
|
||||
gb_phone:
|
||||
phone_textfield: telephone
|
||||
ru_phone:
|
||||
phone_textfield: telephone
|
||||
ua_phone:
|
||||
phone_textfield: telephone
|
||||
es_phone:
|
||||
phone_textfield: telephone
|
||||
au_phone:
|
||||
phone_textfield: telephone
|
||||
cs_phone:
|
||||
phone_textfield: telephone
|
||||
hu_phone:
|
||||
phone_textfield: telephone
|
||||
pl_phone:
|
||||
phone_textfield: telephone
|
||||
nl_phone:
|
||||
phone_textfield: telephone
|
||||
se_phone:
|
||||
phone_textfield: telephone
|
||||
za_phone:
|
||||
phone_textfield: telephone
|
||||
il_phone:
|
||||
phone_textfield: telephone
|
||||
nz_phone:
|
||||
phone_textfield: telephone
|
||||
br_phone:
|
||||
phone_textfield: telephone
|
||||
cl_phone:
|
||||
phone_textfield: telephone
|
||||
cn_phone:
|
||||
phone_textfield: telephone
|
||||
hk_phone:
|
||||
phone_textfield: telephone
|
||||
mo_phone:
|
||||
phone_textfield: telephone
|
||||
ph_phone:
|
||||
phone_textfield: telephone
|
||||
sg_phone:
|
||||
phone_textfield: telephone
|
||||
jo_phone:
|
||||
phone_textfield: telephone
|
||||
eg_phone:
|
||||
phone_textfield: telephone
|
||||
pk_phone:
|
||||
phone_textfield: telephone
|
||||
int_phone:
|
||||
phone_textfield: telephone
|
||||
cardinality:
|
||||
plugin: static_map
|
||||
bypass: true
|
||||
source: multiple
|
||||
map:
|
||||
- 1
|
||||
- -1
|
||||
settings:
|
||||
plugin: field_settings
|
||||
source:
|
||||
- '@type'
|
||||
- global_settings
|
||||
- type
|
||||
destination:
|
||||
plugin: 'entity:field_storage_config'
|
||||
migration_dependencies:
|
||||
required: { }
|
||||
optional: { }
|
||||
+287
@@ -0,0 +1,287 @@
|
||||
uuid: 523bf19a-6869-44e1-8fbf-fc77096c9281
|
||||
langcode: fr
|
||||
status: true
|
||||
dependencies: { }
|
||||
id: upgrade_d6_field_formatter_settings
|
||||
class: Drupal\migrate_drupal\Plugin\migrate\FieldMigration
|
||||
field_plugin_method: null
|
||||
cck_plugin_method: null
|
||||
migration_tags:
|
||||
- 'Drupal 6'
|
||||
migration_group: migrate_drupal_6
|
||||
label: 'Field formatter configuration'
|
||||
source:
|
||||
plugin: d6_field_instance_per_view_mode
|
||||
constants:
|
||||
entity_type: node
|
||||
third_party_settings: { }
|
||||
process:
|
||||
field_type_exists:
|
||||
-
|
||||
plugin: migration_lookup
|
||||
migration: upgrade_d6_field
|
||||
source:
|
||||
- field_name
|
||||
-
|
||||
plugin: skip_on_empty
|
||||
method: row
|
||||
-
|
||||
plugin: extract
|
||||
index:
|
||||
- 1
|
||||
entity_type: constants/entity_type
|
||||
bundle:
|
||||
-
|
||||
plugin: migration_lookup
|
||||
migration: upgrade_d6_node_type
|
||||
source: type_name
|
||||
-
|
||||
plugin: skip_on_empty
|
||||
method: row
|
||||
view_mode:
|
||||
-
|
||||
plugin: migration_lookup
|
||||
migration: upgrade_d6_view_modes
|
||||
source:
|
||||
- view_mode
|
||||
-
|
||||
plugin: skip_on_empty
|
||||
method: row
|
||||
-
|
||||
plugin: extract
|
||||
index:
|
||||
- 1
|
||||
-
|
||||
plugin: static_map
|
||||
bypass: true
|
||||
map:
|
||||
full: default
|
||||
field_name: field_name
|
||||
options/label: label
|
||||
options/weight: weight
|
||||
options/type:
|
||||
-
|
||||
plugin: static_map
|
||||
bypass: true
|
||||
source:
|
||||
- type
|
||||
- display_settings/format
|
||||
map:
|
||||
number_integer:
|
||||
default: number_integer
|
||||
us_0: number_integer
|
||||
be_0: number_integer
|
||||
fr_0: number_integer
|
||||
unformatted: number_unformatted
|
||||
number_float:
|
||||
default: number_decimal
|
||||
us_0: number_decimal
|
||||
us_1: number_decimal
|
||||
us_2: number_decimal
|
||||
be_0: number_decimal
|
||||
be_1: number_decimal
|
||||
be_2: number_decimal
|
||||
fr_0: number_decimal
|
||||
fr_1: number_decimal
|
||||
fr_2: number_decimal
|
||||
unformatted: number_unformatted
|
||||
number_decimal:
|
||||
default: number_decimal
|
||||
us_0: number_decimal
|
||||
us_1: number_decimal
|
||||
us_2: number_decimal
|
||||
be_0: number_decimal
|
||||
be_1: number_decimal
|
||||
be_2: number_decimal
|
||||
fr_0: number_decimal
|
||||
fr_1: number_decimal
|
||||
fr_2: number_decimal
|
||||
unformatted: number_unformatted
|
||||
email:
|
||||
default: email_mailto
|
||||
spamspan: email_mailto
|
||||
contact: email_mailto
|
||||
plain: basic_string
|
||||
fr_phone:
|
||||
default: basic_string
|
||||
be_phone:
|
||||
default: basic_string
|
||||
it_phone:
|
||||
default: basic_string
|
||||
el_phone:
|
||||
default: basic_string
|
||||
ch_phone:
|
||||
default: basic_string
|
||||
ca_phone:
|
||||
default: basic_string
|
||||
cr_phone:
|
||||
default: basic_string
|
||||
pa_phone:
|
||||
default: basic_string
|
||||
gb_phone:
|
||||
default: basic_string
|
||||
ru_phone:
|
||||
default: basic_string
|
||||
ua_phone:
|
||||
default: basic_string
|
||||
es_phone:
|
||||
default: basic_string
|
||||
au_phone:
|
||||
default: basic_string
|
||||
cs_phone:
|
||||
default: basic_string
|
||||
hu_phone:
|
||||
default: basic_string
|
||||
pl_phone:
|
||||
default: basic_string
|
||||
nl_phone:
|
||||
default: basic_string
|
||||
se_phone:
|
||||
default: basic_string
|
||||
za_phone:
|
||||
default: basic_string
|
||||
il_phone:
|
||||
default: basic_string
|
||||
nz_phone:
|
||||
default: basic_string
|
||||
br_phone:
|
||||
default: basic_string
|
||||
cl_phone:
|
||||
default: basic_string
|
||||
cn_phone:
|
||||
default: basic_string
|
||||
hk_phone:
|
||||
default: basic_string
|
||||
mo_phone:
|
||||
default: basic_string
|
||||
ph_phone:
|
||||
default: basic_string
|
||||
sg_phone:
|
||||
default: basic_string
|
||||
jo_phone:
|
||||
default: basic_string
|
||||
eg_phone:
|
||||
default: basic_string
|
||||
pk_phone:
|
||||
default: basic_string
|
||||
int_phone:
|
||||
default: basic_string
|
||||
nodereference:
|
||||
default: entity_reference_label
|
||||
plain: entity_reference_label
|
||||
full: entity_reference_entity_view
|
||||
teaser: entity_reference_entity_view
|
||||
userreference:
|
||||
default: entity_reference_label
|
||||
plain: entity_reference_label
|
||||
-
|
||||
plugin: field_type_defaults
|
||||
options/settings:
|
||||
-
|
||||
plugin: static_map
|
||||
bypass: true
|
||||
source:
|
||||
- module
|
||||
- display_settings/format
|
||||
map:
|
||||
nodereference:
|
||||
default: { }
|
||||
plain:
|
||||
link: false
|
||||
full:
|
||||
view_mode: full
|
||||
teaser:
|
||||
view_mode: teaser
|
||||
userreference:
|
||||
default: { }
|
||||
plain:
|
||||
link: false
|
||||
link:
|
||||
default:
|
||||
trim_length: '80'
|
||||
url_only: 0
|
||||
url_plain: 0
|
||||
rel: 0
|
||||
target: 0
|
||||
plain:
|
||||
trim_length: '80'
|
||||
url_only: 1
|
||||
url_plain: 1
|
||||
rel: 0
|
||||
target: 0
|
||||
absolute:
|
||||
trim_length: '80'
|
||||
url_only: 1
|
||||
url_plain: 1
|
||||
rel: 0
|
||||
target: 0
|
||||
title_plain:
|
||||
trim_length: '80'
|
||||
url_only: 1
|
||||
url_plain: 1
|
||||
rel: 0
|
||||
target: 0
|
||||
url:
|
||||
trim_length: '80'
|
||||
url_only: 1
|
||||
url_plain: 0
|
||||
rel: 0
|
||||
target: 0
|
||||
short:
|
||||
trim_length: '80'
|
||||
url_only: 0
|
||||
url_plain: 0
|
||||
rel: 0
|
||||
target: 0
|
||||
label:
|
||||
trim_length: '80'
|
||||
url_only: 0
|
||||
url_plain: 0
|
||||
rel: 0
|
||||
target: 0
|
||||
separate:
|
||||
trim_length: '80'
|
||||
rel: 0
|
||||
target: 0
|
||||
filefield:
|
||||
image_plain:
|
||||
image_style: ''
|
||||
image_link: ''
|
||||
image_nodelink:
|
||||
image_style: ''
|
||||
image_link: content
|
||||
image_imagelink:
|
||||
image_style: ''
|
||||
image_link: file
|
||||
date:
|
||||
default:
|
||||
format_type: fallback
|
||||
timezone_override: ''
|
||||
format_interval:
|
||||
format_type: fallback
|
||||
timezone_override: ''
|
||||
long:
|
||||
format_type: long
|
||||
timezone_override: ''
|
||||
medium:
|
||||
format_type: medium
|
||||
timezone_override: ''
|
||||
short:
|
||||
format_type: short
|
||||
timezone_override: ''
|
||||
text:
|
||||
trimmed:
|
||||
trim_length: 600
|
||||
string:
|
||||
default:
|
||||
link_to_entity: false
|
||||
-
|
||||
plugin: field_formatter_settings_defaults
|
||||
options/third_party_settings: constants/third_party_settings
|
||||
destination:
|
||||
plugin: component_entity_display
|
||||
migration_dependencies:
|
||||
required:
|
||||
- upgrade_d6_field_instance
|
||||
- upgrade_d6_view_modes
|
||||
optional: { }
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
uuid: 2a618d8d-6ac9-4ead-82bb-b320ad7a3cfb
|
||||
langcode: fr
|
||||
status: true
|
||||
dependencies: { }
|
||||
id: upgrade_d6_field_instance
|
||||
class: Drupal\migrate_drupal\Plugin\migrate\FieldMigration
|
||||
field_plugin_method: null
|
||||
cck_plugin_method: null
|
||||
migration_tags:
|
||||
- 'Drupal 6'
|
||||
migration_group: migrate_drupal_6
|
||||
label: 'Field instance configuration'
|
||||
source:
|
||||
plugin: d6_field_instance
|
||||
constants:
|
||||
entity_type: node
|
||||
process:
|
||||
field_type_exists:
|
||||
-
|
||||
plugin: migration_lookup
|
||||
migration: upgrade_d6_field
|
||||
source:
|
||||
- field_name
|
||||
-
|
||||
plugin: extract
|
||||
index:
|
||||
- 1
|
||||
-
|
||||
plugin: skip_on_empty
|
||||
method: row
|
||||
entity_type: constants/entity_type
|
||||
field_name: field_name
|
||||
bundle:
|
||||
-
|
||||
plugin: migration_lookup
|
||||
migration: upgrade_d6_node_type
|
||||
source: type_name
|
||||
-
|
||||
plugin: skip_on_empty
|
||||
method: row
|
||||
label: label
|
||||
description: description
|
||||
required: required
|
||||
status: active
|
||||
settings:
|
||||
plugin: d6_field_field_settings
|
||||
source:
|
||||
- widget_type
|
||||
- widget_settings
|
||||
- global_settings
|
||||
default_value_callback: ''
|
||||
default_value:
|
||||
plugin: d6_field_instance_defaults
|
||||
source:
|
||||
- widget_type
|
||||
- widget_settings
|
||||
destination:
|
||||
plugin: 'entity:field_config'
|
||||
migration_dependencies:
|
||||
required:
|
||||
- upgrade_d6_node_type
|
||||
- upgrade_d6_field
|
||||
optional: { }
|
||||
+75
@@ -0,0 +1,75 @@
|
||||
uuid: ac44a277-5cdd-4379-886d-102bc9d6ddea
|
||||
langcode: fr
|
||||
status: true
|
||||
dependencies: { }
|
||||
id: upgrade_d6_field_instance_widget_settings
|
||||
class: Drupal\migrate_drupal\Plugin\migrate\FieldMigration
|
||||
field_plugin_method: null
|
||||
cck_plugin_method: null
|
||||
migration_tags:
|
||||
- 'Drupal 6'
|
||||
migration_group: migrate_drupal_6
|
||||
label: 'Field instance widget configuration'
|
||||
source:
|
||||
plugin: d6_field_instance_per_form_display
|
||||
constants:
|
||||
entity_type: node
|
||||
form_mode: default
|
||||
third_party_settings: { }
|
||||
process:
|
||||
field_type_exists:
|
||||
-
|
||||
plugin: migration_lookup
|
||||
migration: upgrade_d6_field
|
||||
source:
|
||||
- field_name
|
||||
-
|
||||
plugin: extract
|
||||
index:
|
||||
- 1
|
||||
-
|
||||
plugin: skip_on_empty
|
||||
method: row
|
||||
bundle:
|
||||
-
|
||||
plugin: migration_lookup
|
||||
migration: upgrade_d6_node_type
|
||||
source: type_name
|
||||
-
|
||||
plugin: skip_on_empty
|
||||
method: row
|
||||
form_mode: constants/form_mode
|
||||
field_name: field_name
|
||||
entity_type: constants/entity_type
|
||||
options/weight: weight
|
||||
options/type:
|
||||
type:
|
||||
plugin: static_map
|
||||
bypass: true
|
||||
source: widget_type
|
||||
map:
|
||||
number: number
|
||||
email_textfield: email_default
|
||||
date_select: datetime_default
|
||||
date_text: datetime_default
|
||||
date_popup: datetime_default
|
||||
imagefield_widget: image_image
|
||||
phone_textfield: telephone_default
|
||||
optionwidgets_onoff: boolean_checkbox
|
||||
optionwidgets_buttons: options_buttons
|
||||
optionwidgets_select: options_select
|
||||
nodereference_select: options_select
|
||||
userreference_select: options_select
|
||||
options/settings:
|
||||
-
|
||||
plugin: field_instance_widget_settings
|
||||
source:
|
||||
- widget_type
|
||||
- widget_settings
|
||||
options/third_party_settings: constants/third_party_settings
|
||||
destination:
|
||||
plugin: component_entity_form_display
|
||||
migration_dependencies:
|
||||
required:
|
||||
- upgrade_d6_field_instance
|
||||
optional: { }
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
uuid: dcd1eb8d-512d-43b8-82ce-8ea888ca4ef1
|
||||
langcode: fr
|
||||
status: true
|
||||
dependencies: { }
|
||||
id: upgrade_d6_file
|
||||
class: Drupal\migrate\Plugin\Migration
|
||||
field_plugin_method: null
|
||||
cck_plugin_method: null
|
||||
migration_tags:
|
||||
- 'Drupal 6'
|
||||
migration_group: migrate_drupal_6
|
||||
label: 'Public files'
|
||||
source:
|
||||
plugin: d6_file
|
||||
constants:
|
||||
source_base_path: ../drupal6/
|
||||
process:
|
||||
filename: filename
|
||||
source_full_path:
|
||||
-
|
||||
plugin: concat
|
||||
delimiter: /
|
||||
source:
|
||||
- constants/source_base_path
|
||||
- filepath
|
||||
-
|
||||
plugin: urlencode
|
||||
destination_full_path:
|
||||
plugin: file_uri
|
||||
source:
|
||||
- filepath
|
||||
- file_directory_path
|
||||
- temp_directory_path
|
||||
- is_public
|
||||
uri:
|
||||
plugin: file_copy
|
||||
source:
|
||||
- '@source_full_path'
|
||||
- '@destination_full_path'
|
||||
filemime: filemime
|
||||
status: status
|
||||
changed: timestamp
|
||||
uid: uid
|
||||
destination:
|
||||
plugin: 'entity:file'
|
||||
migration_dependencies:
|
||||
required: { }
|
||||
optional: { }
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
uuid: 207557d6-7cdc-4c9a-976a-af89609a421a
|
||||
langcode: fr
|
||||
status: true
|
||||
dependencies: { }
|
||||
id: upgrade_d6_file_settings
|
||||
class: Drupal\migrate\Plugin\Migration
|
||||
field_plugin_method: null
|
||||
cck_plugin_method: null
|
||||
migration_tags:
|
||||
- 'Drupal 6'
|
||||
migration_group: migrate_drupal_6
|
||||
label: 'File configuration'
|
||||
source:
|
||||
plugin: variable
|
||||
variables:
|
||||
- file_description_type
|
||||
- file_description_length
|
||||
- file_icon_directory
|
||||
process:
|
||||
description/type: file_description_type
|
||||
description/length: file_description_length
|
||||
icon/directory: file_icon_directory
|
||||
destination:
|
||||
plugin: config
|
||||
config_name: file.settings
|
||||
migration_dependencies:
|
||||
required: { }
|
||||
optional: { }
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
uuid: 8a3a61b7-7578-4a00-aa6e-44455798d537
|
||||
langcode: fr
|
||||
status: true
|
||||
dependencies: { }
|
||||
id: upgrade_d6_filter_format
|
||||
class: Drupal\migrate\Plugin\Migration
|
||||
field_plugin_method: null
|
||||
cck_plugin_method: null
|
||||
migration_tags:
|
||||
- 'Drupal 6'
|
||||
migration_group: migrate_drupal_6
|
||||
label: 'Filter format configuration'
|
||||
source:
|
||||
plugin: d6_filter_format
|
||||
process:
|
||||
format:
|
||||
plugin: machine_name
|
||||
source: name
|
||||
name: name
|
||||
cache: cache
|
||||
filters:
|
||||
plugin: sub_process
|
||||
source: filters
|
||||
key: '@id'
|
||||
process:
|
||||
id:
|
||||
plugin: filter_id
|
||||
source:
|
||||
- module
|
||||
- delta
|
||||
bypass: true
|
||||
map:
|
||||
filter:
|
||||
- filter_html
|
||||
- filter_autop
|
||||
- filter_url
|
||||
- filter_htmlcorrector
|
||||
- filter_html_escape
|
||||
settings:
|
||||
plugin: filter_settings
|
||||
source: settings
|
||||
status:
|
||||
plugin: default_value
|
||||
default_value: true
|
||||
destination:
|
||||
plugin: 'entity:filter_format'
|
||||
no_stub: true
|
||||
migration_dependencies:
|
||||
required: { }
|
||||
optional: { }
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
uuid: 32ad2920-6ee1-4387-9cea-30e86660c4fe
|
||||
langcode: fr
|
||||
status: true
|
||||
dependencies: { }
|
||||
id: upgrade_d6_imagecache_presets
|
||||
class: Drupal\migrate\Plugin\Migration
|
||||
field_plugin_method: null
|
||||
cck_plugin_method: null
|
||||
migration_tags:
|
||||
- 'Drupal 6'
|
||||
migration_group: migrate_drupal_6
|
||||
label: 'ImageCache Presets'
|
||||
source:
|
||||
plugin: d6_imagecache_presets
|
||||
process:
|
||||
name:
|
||||
-
|
||||
plugin: machine_name
|
||||
source: presetname
|
||||
-
|
||||
plugin: make_unique_entity_field
|
||||
entity_type: image_style
|
||||
field: name
|
||||
length: 32
|
||||
label: presetname
|
||||
effects:
|
||||
plugin: d6_imagecache_actions
|
||||
source:
|
||||
- '@plugin'
|
||||
- data
|
||||
destination:
|
||||
plugin: 'entity:image_style'
|
||||
migration_dependencies:
|
||||
required: { }
|
||||
optional: { }
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
uuid: c59681b6-5eb5-49da-bca7-865657e9587d
|
||||
langcode: fr
|
||||
status: true
|
||||
dependencies: { }
|
||||
id: upgrade_d6_language_content_settings
|
||||
class: Drupal\migrate\Plugin\Migration
|
||||
field_plugin_method: null
|
||||
cck_plugin_method: null
|
||||
migration_tags:
|
||||
- 'Drupal 6'
|
||||
migration_group: migrate_drupal_6
|
||||
label: 'Drupal 6 language content settings'
|
||||
source:
|
||||
plugin: d6_language_content_settings
|
||||
constants:
|
||||
target_type: node
|
||||
process:
|
||||
target_bundle: type
|
||||
target_entity_type_id: constants/target_type
|
||||
default_langcode:
|
||||
-
|
||||
plugin: static_map
|
||||
source: language_content_type
|
||||
map:
|
||||
- null
|
||||
- current_interface
|
||||
- current_interface
|
||||
-
|
||||
plugin: skip_on_empty
|
||||
method: row
|
||||
language_alterable:
|
||||
plugin: static_map
|
||||
source: i18n_lock_node
|
||||
map:
|
||||
- true
|
||||
- false
|
||||
third_party_settings/content_translation/enabled:
|
||||
plugin: static_map
|
||||
source: language_content_type
|
||||
map:
|
||||
- null
|
||||
- false
|
||||
- true
|
||||
destination:
|
||||
plugin: 'entity:language_content_settings'
|
||||
content_translation_update_definitions:
|
||||
- node
|
||||
migration_dependencies:
|
||||
required:
|
||||
- upgrade_d6_node_type
|
||||
optional: { }
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
uuid: 387200f7-aeb9-4d35-9640-66d556f89a67
|
||||
langcode: fr
|
||||
status: true
|
||||
dependencies: { }
|
||||
id: upgrade_d6_language_negotiation_settings
|
||||
class: Drupal\migrate\Plugin\Migration
|
||||
field_plugin_method: null
|
||||
cck_plugin_method: null
|
||||
migration_tags:
|
||||
- 'Drupal 6'
|
||||
migration_group: migrate_drupal_6
|
||||
label: 'Language negotiation settings'
|
||||
source:
|
||||
plugin: variable
|
||||
variables:
|
||||
- language_negotiation
|
||||
source_module: language
|
||||
process:
|
||||
session/parameter:
|
||||
plugin: default_value
|
||||
default_value: language
|
||||
selected_langcode:
|
||||
plugin: default_value
|
||||
default_value: site_default
|
||||
url/source:
|
||||
plugin: static_map
|
||||
source: language_negotiation
|
||||
default_value: path_prefix
|
||||
map:
|
||||
- path_prefix
|
||||
- path_prefix
|
||||
- path_prefix
|
||||
- domain
|
||||
destination:
|
||||
plugin: config
|
||||
config_name: language.negotiation
|
||||
migration_dependencies:
|
||||
required:
|
||||
- upgrade_language
|
||||
optional: { }
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
uuid: 96b26caf-fec1-409f-92b4-f01153a26e3f
|
||||
langcode: fr
|
||||
status: true
|
||||
dependencies: { }
|
||||
id: upgrade_d6_language_types
|
||||
class: Drupal\migrate\Plugin\Migration
|
||||
field_plugin_method: null
|
||||
cck_plugin_method: null
|
||||
migration_tags:
|
||||
- 'Drupal 6'
|
||||
migration_group: migrate_drupal_6
|
||||
label: 'Language types'
|
||||
source:
|
||||
plugin: variable
|
||||
variables:
|
||||
- language_negotiation
|
||||
source_module: language
|
||||
process:
|
||||
all:
|
||||
plugin: default_value
|
||||
default_value:
|
||||
- language_interface
|
||||
- language_content
|
||||
- language_url
|
||||
configurable:
|
||||
plugin: default_value
|
||||
default_value:
|
||||
- language_interface
|
||||
negotiation/language_content/enabled:
|
||||
plugin: default_value
|
||||
default_value:
|
||||
language-interface: 0
|
||||
negotiation/language_url/enabled:
|
||||
plugin: default_value
|
||||
default_value:
|
||||
language-url: 0
|
||||
language-url-fallback: 1
|
||||
negotiation/language_interface/enabled:
|
||||
plugin: static_map
|
||||
source: language_negotiation
|
||||
map:
|
||||
-
|
||||
language-selected: 0
|
||||
-
|
||||
language-url: 0
|
||||
language-selected: 1
|
||||
-
|
||||
language-url: 0
|
||||
language-user: 1
|
||||
language-browser: 2
|
||||
language-selected: 3
|
||||
-
|
||||
language-url: 0
|
||||
language-selected: 1
|
||||
destination:
|
||||
plugin: config
|
||||
config_name: language.types
|
||||
migration_dependencies:
|
||||
required: { }
|
||||
optional: { }
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
uuid: 6da82ded-3e16-4b0d-bcc0-897140a1055e
|
||||
langcode: fr
|
||||
status: true
|
||||
dependencies: { }
|
||||
id: upgrade_d6_menu
|
||||
class: Drupal\migrate\Plugin\Migration
|
||||
field_plugin_method: null
|
||||
cck_plugin_method: null
|
||||
migration_tags:
|
||||
- 'Drupal 6'
|
||||
migration_group: migrate_drupal_6
|
||||
label: Menus
|
||||
source:
|
||||
plugin: menu
|
||||
process:
|
||||
id: menu_name
|
||||
label: title
|
||||
description: description
|
||||
destination:
|
||||
plugin: 'entity:menu'
|
||||
migration_dependencies:
|
||||
required: { }
|
||||
optional: { }
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
uuid: a4bfa7da-f050-4522-8d4f-135acccba433
|
||||
langcode: fr
|
||||
status: true
|
||||
dependencies: { }
|
||||
id: upgrade_d6_menu_links
|
||||
class: Drupal\migrate\Plugin\Migration
|
||||
field_plugin_method: null
|
||||
cck_plugin_method: null
|
||||
migration_tags:
|
||||
- 'Drupal 6'
|
||||
migration_group: migrate_drupal_6
|
||||
label: 'Menu links'
|
||||
source:
|
||||
plugin: menu_link
|
||||
process:
|
||||
id: mlid
|
||||
title: link_title
|
||||
description: description
|
||||
menu_name:
|
||||
-
|
||||
plugin: migration_lookup
|
||||
migration: upgrade_d6_menu
|
||||
source: menu_name
|
||||
-
|
||||
plugin: skip_on_empty
|
||||
method: row
|
||||
-
|
||||
plugin: static_map
|
||||
map:
|
||||
management: admin
|
||||
bypass: true
|
||||
link/uri:
|
||||
plugin: link_uri
|
||||
source:
|
||||
- link_path
|
||||
link/options: options
|
||||
route:
|
||||
plugin: route
|
||||
source:
|
||||
- link_path
|
||||
- options
|
||||
route_name: '@route/route_name'
|
||||
route_parameters: '@route/route_parameters'
|
||||
url: '@route/url'
|
||||
options: '@route/options'
|
||||
external: external
|
||||
weight: weight
|
||||
expanded: expanded
|
||||
enabled: enabled
|
||||
parent:
|
||||
plugin: menu_link_parent
|
||||
source:
|
||||
- plid
|
||||
- '@menu_name'
|
||||
- parent_link_path
|
||||
changed: updated
|
||||
destination:
|
||||
plugin: 'entity:menu_link_content'
|
||||
default_bundle: menu_link_content
|
||||
no_stub: true
|
||||
migration_dependencies:
|
||||
required:
|
||||
- upgrade_d6_menu
|
||||
optional: { }
|
||||
+109
@@ -0,0 +1,109 @@
|
||||
uuid: 63e5d50d-22d5-40a5-88f0-cbc813307c64
|
||||
langcode: fr
|
||||
status: true
|
||||
dependencies: { }
|
||||
id: upgrade_d6_node_corpus
|
||||
class: Drupal\migrate\Plugin\Migration
|
||||
field_plugin_method: null
|
||||
cck_plugin_method: null
|
||||
migration_tags:
|
||||
- 'Drupal 6'
|
||||
migration_group: migrate_drupal_6
|
||||
label: 'Nodes (corpus)'
|
||||
source:
|
||||
plugin: d6_node
|
||||
node_type: corpus
|
||||
process:
|
||||
nid: tnid
|
||||
vid: vid
|
||||
langcode:
|
||||
plugin: default_value
|
||||
source: language
|
||||
default_value: und
|
||||
title: title
|
||||
uid: node_uid
|
||||
status: status
|
||||
created: created
|
||||
changed: changed
|
||||
promote: promote
|
||||
sticky: sticky
|
||||
body/format:
|
||||
plugin: migration_lookup
|
||||
migration: upgrade_d6_filter_format
|
||||
source: format
|
||||
body/value: body
|
||||
body/summary: teaser
|
||||
revision_uid: revision_uid
|
||||
revision_log: log
|
||||
revision_timestamp: timestamp
|
||||
field_mp3:
|
||||
plugin: d6_field_file
|
||||
source: field_mp3
|
||||
field_artiste:
|
||||
plugin: iterator
|
||||
source: field_artiste
|
||||
process:
|
||||
value: value
|
||||
format:
|
||||
-
|
||||
plugin: static_map
|
||||
bypass: true
|
||||
source: format
|
||||
map:
|
||||
- null
|
||||
-
|
||||
plugin: skip_on_empty
|
||||
method: process
|
||||
-
|
||||
plugin: migration
|
||||
migration:
|
||||
- upgrade_d6_filter_format
|
||||
- upgrade_d7_filter_format
|
||||
source: format
|
||||
field_compositeur:
|
||||
plugin: iterator
|
||||
source: field_compositeur
|
||||
process:
|
||||
value: value
|
||||
format:
|
||||
-
|
||||
plugin: static_map
|
||||
bypass: true
|
||||
source: format
|
||||
map:
|
||||
- null
|
||||
-
|
||||
plugin: skip_on_empty
|
||||
method: process
|
||||
-
|
||||
plugin: migration
|
||||
migration:
|
||||
- upgrade_d6_filter_format
|
||||
- upgrade_d7_filter_format
|
||||
source: format
|
||||
field_genre: field_genre
|
||||
field_ordre: field_ordre
|
||||
field_langue: field_langue
|
||||
field_article:
|
||||
plugin: iterator
|
||||
source: field_article
|
||||
process:
|
||||
target_id:
|
||||
plugin: migration_lookup
|
||||
migration: upgrade_d6_node
|
||||
source: nid
|
||||
destination:
|
||||
plugin: 'entity:node'
|
||||
default_bundle: corpus
|
||||
migration_dependencies:
|
||||
required:
|
||||
- upgrade_d6_user
|
||||
- upgrade_d6_node_type
|
||||
- upgrade_d6_node_settings
|
||||
- upgrade_d6_filter_format
|
||||
optional:
|
||||
- upgrade_d6_field_instance_widget_settings
|
||||
- upgrade_d6_field_formatter_settings
|
||||
- upgrade_d6_upload_field_instance
|
||||
- upgrade_d6_filter_format
|
||||
- upgrade_d7_filter_format
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
uuid: e07ade2a-75cb-4ffd-a070-d0b1205e24df
|
||||
langcode: fr
|
||||
status: true
|
||||
dependencies: { }
|
||||
id: upgrade_d6_node_entree
|
||||
class: Drupal\migrate\Plugin\Migration
|
||||
field_plugin_method: null
|
||||
cck_plugin_method: null
|
||||
migration_tags:
|
||||
- 'Drupal 6'
|
||||
migration_group: migrate_drupal_6
|
||||
label: 'Nodes (entree)'
|
||||
source:
|
||||
plugin: d6_node
|
||||
node_type: entree
|
||||
process:
|
||||
nid: tnid
|
||||
vid: vid
|
||||
langcode:
|
||||
plugin: default_value
|
||||
source: language
|
||||
default_value: und
|
||||
title: title
|
||||
uid: node_uid
|
||||
status: status
|
||||
created: created
|
||||
changed: changed
|
||||
promote: promote
|
||||
sticky: sticky
|
||||
body/format:
|
||||
plugin: migration_lookup
|
||||
migration: upgrade_d6_filter_format
|
||||
source: format
|
||||
body/value: body
|
||||
body/summary: teaser
|
||||
revision_uid: revision_uid
|
||||
revision_log: log
|
||||
revision_timestamp: timestamp
|
||||
field_entree: field_entree
|
||||
destination:
|
||||
plugin: 'entity:node'
|
||||
default_bundle: entree
|
||||
migration_dependencies:
|
||||
required:
|
||||
- upgrade_d6_user
|
||||
- upgrade_d6_node_type
|
||||
- upgrade_d6_node_settings
|
||||
- upgrade_d6_filter_format
|
||||
optional:
|
||||
- upgrade_d6_field_instance_widget_settings
|
||||
- upgrade_d6_field_formatter_settings
|
||||
- upgrade_d6_upload_field_instance
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
uuid: 96519d79-9201-44d4-b321-d0d011bb45d2
|
||||
langcode: fr
|
||||
status: true
|
||||
dependencies: { }
|
||||
id: upgrade_d6_node_episode
|
||||
class: Drupal\migrate\Plugin\Migration
|
||||
field_plugin_method: null
|
||||
cck_plugin_method: null
|
||||
migration_tags:
|
||||
- 'Drupal 6'
|
||||
migration_group: migrate_drupal_6
|
||||
label: 'Nodes (episode)'
|
||||
source:
|
||||
plugin: d6_node
|
||||
node_type: episode
|
||||
process:
|
||||
nid: tnid
|
||||
vid: vid
|
||||
langcode:
|
||||
plugin: default_value
|
||||
source: language
|
||||
default_value: und
|
||||
title: title
|
||||
uid: node_uid
|
||||
status: status
|
||||
created: created
|
||||
changed: changed
|
||||
promote: promote
|
||||
sticky: sticky
|
||||
body/format:
|
||||
plugin: migration_lookup
|
||||
migration: upgrade_d6_filter_format
|
||||
source: format
|
||||
body/value: body
|
||||
body/summary: teaser
|
||||
revision_uid: revision_uid
|
||||
revision_log: log
|
||||
revision_timestamp: timestamp
|
||||
field_related_sound:
|
||||
plugin: iterator
|
||||
source: field_related_sound
|
||||
process:
|
||||
target_id:
|
||||
plugin: migration_lookup
|
||||
migration: upgrade_d6_node
|
||||
source: nid
|
||||
destination:
|
||||
plugin: 'entity:node'
|
||||
default_bundle: episode
|
||||
migration_dependencies:
|
||||
required:
|
||||
- upgrade_d6_user
|
||||
- upgrade_d6_node_type
|
||||
- upgrade_d6_node_settings
|
||||
- upgrade_d6_filter_format
|
||||
optional:
|
||||
- upgrade_d6_field_instance_widget_settings
|
||||
- upgrade_d6_field_formatter_settings
|
||||
- upgrade_d6_upload_field_instance
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
uuid: 2defad48-393a-4262-9869-523fd44315d5
|
||||
langcode: fr
|
||||
status: true
|
||||
dependencies: { }
|
||||
id: upgrade_d6_node_event
|
||||
class: Drupal\migrate\Plugin\Migration
|
||||
field_plugin_method: null
|
||||
cck_plugin_method: null
|
||||
migration_tags:
|
||||
- 'Drupal 6'
|
||||
migration_group: migrate_drupal_6
|
||||
label: 'Nodes (event)'
|
||||
source:
|
||||
plugin: d6_node
|
||||
node_type: event
|
||||
process:
|
||||
nid: tnid
|
||||
vid: vid
|
||||
langcode:
|
||||
plugin: default_value
|
||||
source: language
|
||||
default_value: und
|
||||
title: title
|
||||
uid: node_uid
|
||||
status: status
|
||||
created: created
|
||||
changed: changed
|
||||
promote: promote
|
||||
sticky: sticky
|
||||
body/format:
|
||||
plugin: migration_lookup
|
||||
migration: upgrade_d6_filter_format
|
||||
source: format
|
||||
body/value: body
|
||||
body/summary: teaser
|
||||
revision_uid: revision_uid
|
||||
revision_log: log
|
||||
revision_timestamp: timestamp
|
||||
field_date:
|
||||
plugin: iterator
|
||||
source: field_date
|
||||
process:
|
||||
value:
|
||||
plugin: format_date
|
||||
from_format: 'Y-m-d\TH:i:s'
|
||||
to_format: 'Y-m-d\TH:i:s'
|
||||
source: value
|
||||
destination:
|
||||
plugin: 'entity:node'
|
||||
default_bundle: event
|
||||
migration_dependencies:
|
||||
required:
|
||||
- upgrade_d6_user
|
||||
- upgrade_d6_node_type
|
||||
- upgrade_d6_node_settings
|
||||
- upgrade_d6_filter_format
|
||||
optional:
|
||||
- upgrade_d6_field_instance_widget_settings
|
||||
- upgrade_d6_field_formatter_settings
|
||||
- upgrade_d6_upload_field_instance
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
uuid: 56aa279c-a52f-4c39-9ba6-3dcf4005beb2
|
||||
langcode: fr
|
||||
status: true
|
||||
dependencies: { }
|
||||
id: upgrade_d6_node_home
|
||||
class: Drupal\migrate\Plugin\Migration
|
||||
field_plugin_method: null
|
||||
cck_plugin_method: null
|
||||
migration_tags:
|
||||
- 'Drupal 6'
|
||||
migration_group: migrate_drupal_6
|
||||
label: 'Nodes (home)'
|
||||
source:
|
||||
plugin: d6_node
|
||||
node_type: home
|
||||
process:
|
||||
nid: tnid
|
||||
vid: vid
|
||||
langcode:
|
||||
plugin: default_value
|
||||
source: language
|
||||
default_value: und
|
||||
title: title
|
||||
uid: node_uid
|
||||
status: status
|
||||
created: created
|
||||
changed: changed
|
||||
promote: promote
|
||||
sticky: sticky
|
||||
body/format:
|
||||
plugin: migration_lookup
|
||||
migration: upgrade_d6_filter_format
|
||||
source: format
|
||||
body/value: body
|
||||
body/summary: teaser
|
||||
revision_uid: revision_uid
|
||||
revision_log: log
|
||||
revision_timestamp: timestamp
|
||||
destination:
|
||||
plugin: 'entity:node'
|
||||
default_bundle: home
|
||||
migration_dependencies:
|
||||
required:
|
||||
- upgrade_d6_user
|
||||
- upgrade_d6_node_type
|
||||
- upgrade_d6_node_settings
|
||||
- upgrade_d6_filter_format
|
||||
optional:
|
||||
- upgrade_d6_field_instance_widget_settings
|
||||
- upgrade_d6_field_formatter_settings
|
||||
- upgrade_d6_upload_field_instance
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
uuid: d1836be0-94fb-4853-b801-7be06964a238
|
||||
langcode: fr
|
||||
status: true
|
||||
dependencies: { }
|
||||
id: upgrade_d6_node_page
|
||||
class: Drupal\migrate\Plugin\Migration
|
||||
field_plugin_method: null
|
||||
cck_plugin_method: null
|
||||
migration_tags:
|
||||
- 'Drupal 6'
|
||||
migration_group: migrate_drupal_6
|
||||
label: 'Nodes (page)'
|
||||
source:
|
||||
plugin: d6_node
|
||||
node_type: page
|
||||
process:
|
||||
nid: tnid
|
||||
vid: vid
|
||||
langcode:
|
||||
plugin: default_value
|
||||
source: language
|
||||
default_value: und
|
||||
title: title
|
||||
uid: node_uid
|
||||
status: status
|
||||
created: created
|
||||
changed: changed
|
||||
promote: promote
|
||||
sticky: sticky
|
||||
body/format:
|
||||
plugin: migration_lookup
|
||||
migration: upgrade_d6_filter_format
|
||||
source: format
|
||||
body/value: body
|
||||
body/summary: teaser
|
||||
revision_uid: revision_uid
|
||||
revision_log: log
|
||||
revision_timestamp: timestamp
|
||||
field_mp3:
|
||||
plugin: d6_field_file
|
||||
source: field_mp3
|
||||
field_visuel:
|
||||
plugin: d6_field_file
|
||||
source: field_visuel
|
||||
destination:
|
||||
plugin: 'entity:node'
|
||||
default_bundle: page
|
||||
migration_dependencies:
|
||||
required:
|
||||
- upgrade_d6_user
|
||||
- upgrade_d6_node_type
|
||||
- upgrade_d6_node_settings
|
||||
- upgrade_d6_filter_format
|
||||
optional:
|
||||
- upgrade_d6_field_instance_widget_settings
|
||||
- upgrade_d6_field_formatter_settings
|
||||
- upgrade_d6_upload_field_instance
|
||||
+103
@@ -0,0 +1,103 @@
|
||||
uuid: 95382fb2-194e-4757-a1a7-69841faebdd3
|
||||
langcode: fr
|
||||
status: true
|
||||
dependencies: { }
|
||||
id: upgrade_d6_node_revision_corpus
|
||||
class: Drupal\migrate\Plugin\Migration
|
||||
field_plugin_method: null
|
||||
cck_plugin_method: null
|
||||
migration_tags:
|
||||
- 'Drupal 6'
|
||||
migration_group: migrate_drupal_6
|
||||
label: 'Node revisions (corpus)'
|
||||
source:
|
||||
plugin: d6_node_revision
|
||||
node_type: corpus
|
||||
process:
|
||||
nid: nid
|
||||
vid: vid
|
||||
langcode:
|
||||
plugin: default_value
|
||||
source: language
|
||||
default_value: und
|
||||
title: title
|
||||
uid: node_uid
|
||||
status: status
|
||||
created: created
|
||||
changed: changed
|
||||
promote: promote
|
||||
sticky: sticky
|
||||
body/format:
|
||||
plugin: migration_lookup
|
||||
migration: upgrade_d6_filter_format
|
||||
source: format
|
||||
body/value: body
|
||||
body/summary: teaser
|
||||
revision_uid: revision_uid
|
||||
revision_log: log
|
||||
revision_timestamp: timestamp
|
||||
field_mp3:
|
||||
plugin: d6_field_file
|
||||
source: field_mp3
|
||||
field_artiste:
|
||||
plugin: iterator
|
||||
source: field_artiste
|
||||
process:
|
||||
value: value
|
||||
format:
|
||||
-
|
||||
plugin: static_map
|
||||
bypass: true
|
||||
source: format
|
||||
map:
|
||||
- null
|
||||
-
|
||||
plugin: skip_on_empty
|
||||
method: process
|
||||
-
|
||||
plugin: migration
|
||||
migration:
|
||||
- upgrade_d6_filter_format
|
||||
- upgrade_d7_filter_format
|
||||
source: format
|
||||
field_compositeur:
|
||||
plugin: iterator
|
||||
source: field_compositeur
|
||||
process:
|
||||
value: value
|
||||
format:
|
||||
-
|
||||
plugin: static_map
|
||||
bypass: true
|
||||
source: format
|
||||
map:
|
||||
- null
|
||||
-
|
||||
plugin: skip_on_empty
|
||||
method: process
|
||||
-
|
||||
plugin: migration
|
||||
migration:
|
||||
- upgrade_d6_filter_format
|
||||
- upgrade_d7_filter_format
|
||||
source: format
|
||||
field_genre: field_genre
|
||||
field_ordre: field_ordre
|
||||
field_langue: field_langue
|
||||
field_article:
|
||||
plugin: iterator
|
||||
source: field_article
|
||||
process:
|
||||
target_id:
|
||||
plugin: migration_lookup
|
||||
migration: upgrade_d6_node
|
||||
source: nid
|
||||
destination:
|
||||
plugin: 'entity_revision:node'
|
||||
default_bundle: corpus
|
||||
migration_dependencies:
|
||||
required:
|
||||
- upgrade_d6_node_corpus
|
||||
optional:
|
||||
- upgrade_d6_filter_format
|
||||
- upgrade_d7_filter_format
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
uuid: 985370e5-cb22-4312-9e1b-4e159857f420
|
||||
langcode: fr
|
||||
status: true
|
||||
dependencies: { }
|
||||
id: upgrade_d6_node_revision_entree
|
||||
class: Drupal\migrate\Plugin\Migration
|
||||
field_plugin_method: null
|
||||
cck_plugin_method: null
|
||||
migration_tags:
|
||||
- 'Drupal 6'
|
||||
migration_group: migrate_drupal_6
|
||||
label: 'Node revisions (entree)'
|
||||
source:
|
||||
plugin: d6_node_revision
|
||||
node_type: entree
|
||||
process:
|
||||
nid: nid
|
||||
vid: vid
|
||||
langcode:
|
||||
plugin: default_value
|
||||
source: language
|
||||
default_value: und
|
||||
title: title
|
||||
uid: node_uid
|
||||
status: status
|
||||
created: created
|
||||
changed: changed
|
||||
promote: promote
|
||||
sticky: sticky
|
||||
body/format:
|
||||
plugin: migration_lookup
|
||||
migration: upgrade_d6_filter_format
|
||||
source: format
|
||||
body/value: body
|
||||
body/summary: teaser
|
||||
revision_uid: revision_uid
|
||||
revision_log: log
|
||||
revision_timestamp: timestamp
|
||||
field_entree: field_entree
|
||||
destination:
|
||||
plugin: 'entity_revision:node'
|
||||
default_bundle: entree
|
||||
migration_dependencies:
|
||||
required:
|
||||
- upgrade_d6_node_entree
|
||||
optional: { }
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
uuid: e14cc576-ff51-447e-9f16-dfc2eeb87ac9
|
||||
langcode: fr
|
||||
status: true
|
||||
dependencies: { }
|
||||
id: upgrade_d6_node_revision_episode
|
||||
class: Drupal\migrate\Plugin\Migration
|
||||
field_plugin_method: null
|
||||
cck_plugin_method: null
|
||||
migration_tags:
|
||||
- 'Drupal 6'
|
||||
migration_group: migrate_drupal_6
|
||||
label: 'Node revisions (episode)'
|
||||
source:
|
||||
plugin: d6_node_revision
|
||||
node_type: episode
|
||||
process:
|
||||
nid: nid
|
||||
vid: vid
|
||||
langcode:
|
||||
plugin: default_value
|
||||
source: language
|
||||
default_value: und
|
||||
title: title
|
||||
uid: node_uid
|
||||
status: status
|
||||
created: created
|
||||
changed: changed
|
||||
promote: promote
|
||||
sticky: sticky
|
||||
body/format:
|
||||
plugin: migration_lookup
|
||||
migration: upgrade_d6_filter_format
|
||||
source: format
|
||||
body/value: body
|
||||
body/summary: teaser
|
||||
revision_uid: revision_uid
|
||||
revision_log: log
|
||||
revision_timestamp: timestamp
|
||||
field_related_sound:
|
||||
plugin: iterator
|
||||
source: field_related_sound
|
||||
process:
|
||||
target_id:
|
||||
plugin: migration_lookup
|
||||
migration: upgrade_d6_node
|
||||
source: nid
|
||||
destination:
|
||||
plugin: 'entity_revision:node'
|
||||
default_bundle: episode
|
||||
migration_dependencies:
|
||||
required:
|
||||
- upgrade_d6_node_episode
|
||||
optional: { }
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
uuid: f6c2d9bc-f977-423e-94a2-59cd24b84c85
|
||||
langcode: fr
|
||||
status: true
|
||||
dependencies: { }
|
||||
id: upgrade_d6_node_revision_event
|
||||
class: Drupal\migrate\Plugin\Migration
|
||||
field_plugin_method: null
|
||||
cck_plugin_method: null
|
||||
migration_tags:
|
||||
- 'Drupal 6'
|
||||
migration_group: migrate_drupal_6
|
||||
label: 'Node revisions (event)'
|
||||
source:
|
||||
plugin: d6_node_revision
|
||||
node_type: event
|
||||
process:
|
||||
nid: nid
|
||||
vid: vid
|
||||
langcode:
|
||||
plugin: default_value
|
||||
source: language
|
||||
default_value: und
|
||||
title: title
|
||||
uid: node_uid
|
||||
status: status
|
||||
created: created
|
||||
changed: changed
|
||||
promote: promote
|
||||
sticky: sticky
|
||||
body/format:
|
||||
plugin: migration_lookup
|
||||
migration: upgrade_d6_filter_format
|
||||
source: format
|
||||
body/value: body
|
||||
body/summary: teaser
|
||||
revision_uid: revision_uid
|
||||
revision_log: log
|
||||
revision_timestamp: timestamp
|
||||
field_date:
|
||||
plugin: iterator
|
||||
source: field_date
|
||||
process:
|
||||
value:
|
||||
plugin: format_date
|
||||
from_format: 'Y-m-d\TH:i:s'
|
||||
to_format: 'Y-m-d\TH:i:s'
|
||||
source: value
|
||||
destination:
|
||||
plugin: 'entity_revision:node'
|
||||
default_bundle: event
|
||||
migration_dependencies:
|
||||
required:
|
||||
- upgrade_d6_node_event
|
||||
optional: { }
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
uuid: 547bb71a-efbb-4776-9180-6a6d16493eca
|
||||
langcode: fr
|
||||
status: true
|
||||
dependencies: { }
|
||||
id: upgrade_d6_node_revision_home
|
||||
class: Drupal\migrate\Plugin\Migration
|
||||
field_plugin_method: null
|
||||
cck_plugin_method: null
|
||||
migration_tags:
|
||||
- 'Drupal 6'
|
||||
migration_group: migrate_drupal_6
|
||||
label: 'Node revisions (home)'
|
||||
source:
|
||||
plugin: d6_node_revision
|
||||
node_type: home
|
||||
process:
|
||||
nid: nid
|
||||
vid: vid
|
||||
langcode:
|
||||
plugin: default_value
|
||||
source: language
|
||||
default_value: und
|
||||
title: title
|
||||
uid: node_uid
|
||||
status: status
|
||||
created: created
|
||||
changed: changed
|
||||
promote: promote
|
||||
sticky: sticky
|
||||
body/format:
|
||||
plugin: migration_lookup
|
||||
migration: upgrade_d6_filter_format
|
||||
source: format
|
||||
body/value: body
|
||||
body/summary: teaser
|
||||
revision_uid: revision_uid
|
||||
revision_log: log
|
||||
revision_timestamp: timestamp
|
||||
destination:
|
||||
plugin: 'entity_revision:node'
|
||||
default_bundle: home
|
||||
migration_dependencies:
|
||||
required:
|
||||
- upgrade_d6_node_home
|
||||
optional: { }
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user