Ver código fonte

big refactoring of mobile version xhich has now a hamburger menu and a link to collection

Bachir Soussi Chiadmi 5 anos atrás
pai
commit
e204a08202

+ 7 - 0
sites/all/modules/figli/edlp_corpus/edlp_corpus.module

@@ -42,6 +42,13 @@ function edlp_corpus_theme($existing, $type, $theme, $path) {
         'articles_nodes' => NULL,
       ),
     ),
+    'edlp_corpus_collection' => array(
+      // 'render element' => '',
+      'file' => 'includes/edlp_corpus_collection.inc',
+      'variables' => array(
+        'entrees_terms' => NULL,
+      ),
+    ),
   );
 }
 

+ 16 - 1
sites/all/modules/figli/edlp_corpus/edlp_corpus.routing.yml

@@ -31,7 +31,6 @@ edlp_corpus.lastdocsajax:
   requirements:
     _permission: 'access content'
 
-
 edlp_corpus.articlesindex:
   path: '/articles'
   defaults:
@@ -47,3 +46,19 @@ edlp_corpus.articlesindexajax:
     _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'

+ 29 - 0
sites/all/modules/figli/edlp_corpus/includes/edlp_corpus_collection.inc

@@ -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);
+  }
+
+}

+ 178 - 85
sites/all/modules/figli/edlp_corpus/src/Controller/CorpusController.php

@@ -7,6 +7,7 @@ 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;
@@ -251,107 +252,199 @@ class CorpusController extends ControllerBase {
   // /_/ \_\_|  \__|_\__|_\___/__/ |___|_||_\__,_\___/_\_\
 
 
-    private function articlesQuery() {
-      $query = \Drupal::entityQuery('node')
-      ->condition('status', 1)
-      ->condition('type', 'enregistrement')
-      ->condition('body', '', "<>")
-      ->sort('created', 'DESC');
-      // ->range(0,20);
+  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();
 
-      $nids = $query->execute();
-      $nodes = entity_load_multiple('node', $nids);
+    $this->articles_nodes = [];
+    $this->articles_nids = [];
+    foreach ($nodes as $node) {
+      // remove masqué
+      $sid = WorkflowManager::getCurrentStateId($node, 'field_workflow');
+      if($sid != 'corpus_documents_publie') continue;
 
-      $current_langcode = \Drupal::languageManager()->getCurrentLanguage()->getId();
+      // TODO: check if article is translated
+      if ($node->getTranslation($current_langcode)->body->isEmpty()) continue;
 
-      $this->articles_nodes = [];
-      $this->articles_nids = [];
-      foreach ($nodes as $node) {
-        // remove masqué
-        $sid = WorkflowManager::getCurrentStateId($node, 'field_workflow');
-        if($sid != 'corpus_documents_publie') continue;
+      $this->articles_nodes[] = $node;
+      // record an array of nids for corpus map filtering
+      $this->articles_nids[] = $node->get('nid')->getString();
+    }
 
-        // 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;
     }
 
-    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();
+    $data['#cache'] = [
+      'max-age' => \Drupal\Core\Cache\Cache::PERMANENT,
+      'tags' => ['edlp-articlesindex-cache']
+    ];
+
+    // $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($t‌​erms);
+    $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;
 
-    /**
-     * 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,
-      ];
+  private function collectionToRenderable(){
+    $this->collectionQuery();
 
-      // 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;
-      }
+    return array(
+      "#theme"=>'edlp_corpus_collection',
+      '#entrees_terms' => $this->entrees_terms
+    );
+  }
 
-      $data['#cache'] = [
-        'max-age' => \Drupal\Core\Cache\Cache::PERMANENT,
-        'tags' => ['edlp-articlesindex-cache']
-      ];
+  public function collection(){
+    return $this->collectionToRenderable();
+  }
 
-      // $response = new JsonResponse();
-      // $response->setData($data);
-      $response = new CacheableJsonResponse($data);
-      $response->addCacheableDependency(CacheableMetadata::createFromRenderArray($data));
-      $response->addCacheableDependency(CacheableMetadata::createFromRenderArray($renderable));
+  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'
+    ];
 
-      return $response;
+    // 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']
+    ];
+
+    // $response = new JsonResponse();
+    // $response->setData($data);
+    $response = new CacheableJsonResponse($data);
+    $response->addCacheableDependency(CacheableMetadata::createFromRenderArray($data));
+    $response->addCacheableDependency(CacheableMetadata::createFromRenderArray($renderable));
+
+    return $response;
+  }
 
 }

+ 3 - 0
sites/all/modules/figli/edlp_corpus/templates/edlp-corpus-collection.html.twig

@@ -0,0 +1,3 @@
+{% if entrees %}
+  {{ entrees }}
+{% endif %}

+ 2 - 1
sites/all/modules/figli/edlp_home/edlp_home.module

@@ -25,7 +25,8 @@ function edlp_home_theme($existing, $type, $theme, $path) {
         'promoted_nodes' => array(),
         'lastdocs_items' => NULL,
         'agenda_items' => NULL,
-        'entrees_items' => NULL,
+        // 'entrees_items' => NULL,
+        'collection_link' => NULL,
       ),
     ),
   );

+ 8 - 0
sites/all/modules/figli/edlp_home/edlp_home.routing.yml

@@ -21,3 +21,11 @@ edlp_home.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'

+ 16 - 47
sites/all/modules/figli/edlp_home/includes/edlp_home.inc

@@ -4,7 +4,7 @@ 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');
+  // $term_view_builder = \Drupal::entityTypeManager()->getViewBuilder('taxonomy_term');
   // dpm($vars);
 
   // render the promoted_nodes
@@ -34,21 +34,6 @@ function template_preprocess_edlp_home(&$vars){
     }
   }
 
-  // render the presentation column
-  // $vars["presentation"] = array(
-  //   "#type"=>"container",
-  //   "pres"=>$node_view_builder->view($vars["presentation_node"], 'default'),
-  //   "link"=> array(
-  //     '#title' => t('Visiter la collection sonore.'),
-  //     '#type' => 'link',
-  //     '#url' => Url::fromRoute('<front>', [], array(
-  //       'attributes' => array(
-  //         'class' => ['corpus-link', 'ajax-link']
-  //       )
-  //     ))
-  //   )
-  // );
-
   // render the last fil column
   // $vars["last_fil"] = array(
   //   "#type" => "container",
@@ -81,21 +66,6 @@ function template_preprocess_edlp_home(&$vars){
   //   // )
   // );
 
-  // render the last production column
-  // $vars["last_production"] = array(
-  //   '#type' => 'container',
-  //   'prod' => $node_view_builder->view($vars['last_production_node'], 'teaser'),
-  //   'link'=> array(
-  //     '#title' => t('Voir toutes les productions.'),
-  //     '#type' => 'link',
-  //     '#url' => Url::fromRoute('edlp_productions.productions', [], array(
-  //       'attributes' => array(
-  //         'class' => ['productions-link', 'ajax-link']
-  //       )
-  //     ))
-  //   )
-  // );
-
 
   // render the lasts documents of collection as list
   if(isset($vars['lastdocs_items'])){
@@ -156,25 +126,24 @@ function template_preprocess_edlp_home(&$vars){
     $vars['agenda'] = render($agenda);
   }
 
-  if(isset($vars['entrees_items'])){
-    $entrees = array(
+  if(isset($vars['collection_link'])){
+    $collection = 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' => [],
-      ),
+        '#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'),
+          )
+        )
+      )
     );
-    foreach($vars['entrees_items'] as $term){
-      $entrees['list']['#items'][] = $term_view_builder->view($term, 'home_mobile');
-    }
-    $vars['entrees'] = render($entrees);
+    $vars['collection'] = render($collection);
   }
 
 }

+ 80 - 94
sites/all/modules/figli/edlp_home/src/Controller/HomeController.php

@@ -6,7 +6,13 @@ use Drupal\Core\Controller\ControllerBase;
 use Drupal\Core\Datetime\DrupalDateTime;
 use Drupal\taxonomy\Entity\Term;
 use Drupal\workflow\Entity\WorkflowManager;
-use Symfony\Component\HttpFoundation\JsonResponse;
+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 {
@@ -99,16 +105,17 @@ class HomeController extends ControllerBase {
 
     return $contents;
   }
+
   /**
-   * Display agenda as a page.
+   * Display home mobile as a page.
    *
    * @return renderable array
    */
-  public function home_mobile() {
+  public function toMobileHomeRenderable() {
 
     // $view_builder = \Drupal::entityTypeManager()->getViewBuilder('node');
 
-    $contents = array("#theme"=>'edlp_home');
+    $renderable = array("#theme"=>'edlp_home');
 
     // first get static pages
     $query = \Drupal::entityQuery('node')
@@ -117,7 +124,7 @@ class HomeController extends ControllerBase {
       ->condition('type', 'static');
 
     $promoted_nids = $query->execute();
-    $contents["#promoted_nodes"] = entity_load_multiple('node', $promoted_nids);
+    $renderable["#promoted_nodes"] = entity_load_multiple('node', $promoted_nids);
 
     // then get production pages
     $query = \Drupal::entityQuery('node')
@@ -126,7 +133,7 @@ class HomeController extends ControllerBase {
       ->condition('type', 'page');
 
     $promoted_nids = $query->execute();
-    $contents["#promoted_nodes"] += entity_load_multiple('node', $promoted_nids);
+    $renderable["#promoted_nodes"] += entity_load_multiple('node', $promoted_nids);
 
     // last fil
     // $query = \Drupal::entityQuery('node')
@@ -136,8 +143,8 @@ class HomeController extends ControllerBase {
     //   ->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.');
+    // $renderable["#last_fil_node"] = entity_load('node', array_pop($fil));
+    // $renderable["#last_fil_node"] = array('#markup'=>'En développement.');
 
     // agenda
     $now = new DrupalDateTime('now');
@@ -151,100 +158,79 @@ class HomeController extends ControllerBase {
       ->sort('field_date');
 
     $events = $query->execute();
-    $contents['#agenda_items'] = entity_load_multiple('node', $events);
+    $renderable['#agenda_items'] = entity_load_multiple('node', $events);
 
 
-    // entrées
-    $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($t‌​erms);
-    $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;
-    }
+    // 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(),
+    );
 
-    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($name, $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'],
-      //     '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;
-    // }
 
-    $contents['#entrees_items'] = $ordered_trans_terms;
+    return $renderable;
+  }
 
-    // = array (
-    //   '#theme' => 'blockentrees',
-    //   '#entrees_items' => $entrees,
-    //   '#attached'=>array(
-    //     'library' => array('edlp_corpus/corpus'),
-    //     'drupalSettings' => array(
-    //       'basepath' => base_path()
-    //     )
-    //   )
-    // );
 
+  public function home_mobile() {
+    return $this->toMobileHomeRenderable();
+  }
 
-    return $contents;
+  /**
+   * 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;
   }
 
 }

+ 2 - 2
sites/all/modules/figli/edlp_home/templates/edlp-home.html.twig

@@ -16,6 +16,6 @@
   {{ agenda }}
 {% endif %}
 
-{% if entrees %}
-  {{ entrees }}
+{% if collection %}
+  {{ collection }}
 {% endif %}

+ 10 - 1
sites/all/modules/figli/edlp_mobile/edlp_mobile.module

@@ -116,7 +116,7 @@ function edlp_mobile_page_attachments(array &$attachments) {
       // we assume that there is only two alias by env (mobile or desktop)
       foreach ($env_aliases as $env_alias_id => $env_alias) {
         if($env_alias_id != $alias->id()){
-          // we found the desktop pattern
+          // we found the mobile pattern
           $mobile_url = $env_alias->getPattern();
           break;
         }
@@ -128,6 +128,13 @@ function edlp_mobile_page_attachments(array &$attachments) {
   $is_front = \Drupal::service('path.matcher')->isFrontPage();
   $current_language = \Drupal::languageManager()->getCurrentLanguage()->getId();
 
+  // $config->set($domain_id . '.site_frontpage', $site_frontpage);
+
+  // $mobile_home_path = "???";
+  $mobile_home_path = \Drupal::config('domain_site_settings.domainconfigsettings')->get('m_encyclopediedelaparole_org.site_frontpage', FALSE);
+  // $desktop_home_path = "???";
+  $desktop_home_path = \Drupal::config('domain_site_settings.domainconfigsettings')->get('encyclopediedelaparole_org.site_frontpage', FALSE);
+
   // $redirect = false;
   $js_str = "var edlp_mobile = {\n
     current_url:'".$base_root."',\n
@@ -136,7 +143,9 @@ function edlp_mobile_page_attachments(array &$attachments) {
     lang_code:'".$current_language."',\n
     is_mobile_domain:".($is_mobile_domain ? 'true':'false').",\n
     mobile_url:'".$mobile_url."',\n
+    mobile_home_path:'".$mobile_home_path."',\n
     desktop_url:'".$desktop_url."',\n
+    desktop_home_path:'".$desktop_home_path."',\n
   };";
 
   $attachments['#attached']['html_head'][] = [

Diferenças do arquivo suprimidas por serem muito extensas
+ 0 - 0
sites/all/themes/custom/edlptheme/assets/dist/scripts/main.min.js


Diferenças do arquivo suprimidas por serem muito extensas
+ 0 - 0
sites/all/themes/custom/edlptheme/assets/dist/styles/app.min.css


+ 136 - 52
sites/all/themes/custom/edlptheme/assets/scripts/main.js

@@ -29,23 +29,28 @@
       // if(!drupalSettings.path.isFront)
       //   return;
 
-      if(!_is_mobile){
-        initEvents();
+      if(_is_mobile){
+        initMobile();
+      }
 
-        _audioPlayer = new AudioPlayer();
-        _compoPlayer = new CompoPlayer();
+      initEvents();
 
-        checkLayout();
+      _audioPlayer = new AudioPlayer();
+      _compoPlayer = new CompoPlayer();
+      initAjaxLinks();
+      initHistory();
 
-        initAjaxLinks();
 
-        initHistory();
+      if(!_is_mobile){
+
+        checkLayout();
 
         initAudioLinksHover();
-      }else{
+      }
+
+      if(_is_mobile){
         if(drupalSettings.path.isFront){
           initHomeMobile();
-
         }
         _$body.attr('booted', 'booted');
       }
@@ -62,38 +67,48 @@
     // |  \/  |___| |__(_) |___
     // | |\/| / _ \ '_ \ | / -_)
     // |_|  |_\___/_.__/_|_\___|
-    function initHomeMobile(){
-      $('.field--name-field-notice, .index', '.entrees .taxonomy-term.vocabulary-entrees')
-        .addClass('closed');
-      $('[data-drupal-link-system-path="<front>"]','#block-mainnavigation')
-        .removeClass('is-active')
-        .attr('href', '#collection');
-      $('h2#block-mainnavigation-menu, a', '#block-mainnavigation')
+    function initMobile(){
+      // $('[data-drupal-link-system-path="<front>"]','#block-mainnavigation')
+      //   .removeClass('is-active')
+      //   .attr('href', '#collection');
+
+      // edlp_mobile.mobile_home_path.replace(/^\//, '')
+
+      // TODO: remove collection from mobile home
+      // TODO: replace ajax link to only collection for mobile
+
+
+      $('h2, a', '#block-mainnavigation')
+        .add('h2, a', '#block-mainnavigation-2')
         .on('click', onclickHomeMobileMenu);
-      // $('a', '#block-mainnavigation')
-      //   .on('click', onclickHomeMobileMenu);
-      $('.field--name-field-notice>.field__label', '.entrees .taxonomy-term.vocabulary-entrees')
-        .on('click', onClickHomeMobileNotice);
-      $('.index>.field__label', '.entrees .taxonomy-term.vocabulary-entrees')
-        .on('click', onClickHomeMobileIndex);
-    };
+    }
     function onclickHomeMobileMenu(e){
-      $('#block-mainnavigation').toggleClass('visible');
+      // $('#block-mainnavigation').toggleClass('opened');
+      $('#block-mainnavigation-2').toggleClass('opened');
     };
-    function onClickHomeMobileNotice(e){
-      // console.log('onClickHomeMobileNotice');
-      // var $part = $(this).parent();//parents('.taxonomy-term');
-      toggleEntreeOpening($(this).parent(), 'notice');
-    };
-    function onClickHomeMobileIndex(e){
-      // console.log('onClickHomeMobileIndex');
-      // var $part = $(this).parent();//parents('.taxonomy-term');
-      toggleEntreeOpening($(this).parent(), 'index');
+    function initHomeMobile(){
+      // taxonomy-term.vocabulary-entrees.home_mobile
+      // $('.field--name-field-notice, .index', '.entrees .taxonomy-term.vocabulary-entrees')
+      //   .addClass('closed');
+      // $('.field--name-field-notice>.field__label', '.entrees .taxonomy-term.vocabulary-entrees')
+      //   .on('click', onClickHomeMobileNotice);
+      // $('.index>.field__label', '.entrees .taxonomy-term.vocabulary-entrees')
+      //   .on('click', onClickHomeMobileIndex);
     };
-    function toggleEntreeOpening($e, part){
-      $e.toggleClass('closed')
-        .parents('.taxonomy-term.vocabulary-entrees.home_mobile').toggleClass(part+'-opened');
-    }
+    // function onClickHomeMobileNotice(e){
+    //   // console.log('onClickHomeMobileNotice');
+    //   // var $part = $(this).parent();//parents('.taxonomy-term');
+    //   toggleEntreeOpening($(this).parent(), 'notice');
+    // };
+    // function onClickHomeMobileIndex(e){
+    //   // console.log('onClickHomeMobileIndex');
+    //   // var $part = $(this).parent();//parents('.taxonomy-term');
+    //   toggleEntreeOpening($(this).parent(), 'index');
+    // };
+    // function toggleEntreeOpening($e, part){
+    //   $e.toggleClass('closed')
+    //     .parents('.taxonomy-term.vocabulary-entrees.home_mobile').toggleClass(part+'-opened');
+    // }
 
     //  ___             _
     // | __|_ _____ _ _| |_ ___
@@ -379,6 +394,11 @@
         addCloseModalBtnToCols();
       }
 
+      if(state.sys_path == "collection"){
+        // only for mobile version of collection
+        initCollectionNav();
+      }
+
       // enregistrement transcription
       if(data.entity_type == "node" && data.bundle == "enregistrement" && data.view_mode == "transcript"){
         // window.requestAnimationFrame(initEnregistrementTranscript);
@@ -481,6 +501,8 @@
     };
 
     function addCloseModalBtnToCols(){
+      if(_is_mobile) return;
+
       $('.col', _$row).each(function(index, el) {
 
         if($('span.close-col-btn', this).length)
@@ -682,6 +704,7 @@
 
       $('a.site-name', '#block-edlptheme-branding')
         .add('a', '#block-mainnavigation')
+        .add('a', '#block-mainnavigation-2')
         // .add('a', '.block.language-switcher-language-url')
         .add('a', '#block-footer.menu--footer')
         .add('a', '#block-productions')
@@ -695,8 +718,16 @@
 
       $('a[data-drupal-link-system-path="<front>"]', '#block-mainnavigation').removeClass('is-active');
 
-      _$ajaxLinks = $('.ajax-link:not(.ajax-enabled)')
-        .each(function(i,e){
+      _$ajaxLinks = $('.ajax-link');
+      activateAjaxLinks();
+    };
+    // function initAudioLinks(){
+    //   _$ajaxLinks = $('.ajax-link.audio-link');
+    //   activateAjaxLinks();
+    // };
+    function activateAjaxLinks(){
+      // $('.ajax-link:not(.ajax-enabled)')
+      _$ajaxLinks.each(function(i,e){
           var $this = $(this);
           // avoid already ajaxified links
           if($this.is('.ajax-enable')) return;
@@ -753,12 +784,17 @@
       // front page
       // just remove contents and stop here
       if(sys_path == '<front>'){
-        if($link.is('.is-active') && _corpus_ready){
-          _$corpus_canvas.trigger({'type':'shuffle-collection'});
-        }else{
-          backToFrontPage();
+        if(!_is_mobile){
+          if($link.is('.is-active') && _corpus_ready){
+            _$corpus_canvas.trigger({'type':'shuffle-collection'});
+          }else{
+            backToFrontPage();
+          }
+          return false;
         }
-        return false;
+        // else{
+        //   sys_path = edlp_mobile.mobile_home_path.replace(/^\//, '');
+        // }
       }
 
       var view_mode = $link.attr('viewmode');
@@ -993,7 +1029,7 @@
           this.currentHistoricIndex = historic_index;
         }
 
-        if(_$body.is('.path-frontpage') && caller !== 'lastdocs'){
+        if(_$body.is('.path-frontpage') && caller !== 'lastdocs' && !_is_mobile){
           closeAllModals();
         }
         // TODO: update language switcher for document url
@@ -1024,7 +1060,9 @@
         this.clearTimeOutToHide();
         this.clearIntervalAutoCartelSwitch();
         this.setSRC(this.historic[this.currentHistoricIndex].audio_url);
-        this.loadNode(this.historic[this.currentHistoricIndex].nid);
+        if(!_is_mobile){
+          this.loadNode(this.historic[this.currentHistoricIndex].nid);
+        }
         // emmit new playing doc (e.g.: corpus map nowing that audio played from RandomPlayer)
         try {
           _$corpus_canvas.trigger({
@@ -1677,8 +1715,10 @@
     //  \___|_| |_\__,_|
     function initGrid(){
       console.log('theme : initGrid');
-      checkGridBlockHeight();
-      _$row.find('.col').addClass('offfield');
+      if(!_is_mobile){
+        checkGridBlockHeight();
+        _$row.find('.col').addClass('offfield');
+      }
       if(false){
 
         var $grid = $('.grid',_$row).masonry({
@@ -1711,12 +1751,16 @@
 
       }else{
         // setTimeout(checkGridBlockVisible, 100);
-        checkGridBlockVisible();
+        if(!_is_mobile){
+          checkGridBlockVisible();
+        }
       }
     };
 
     function checkGridBlockHeight(){
       // console.log('checkGridBlockHeight');
+      // if(_is_mobile) return;
+
       var $r_h = _$row.height();
       var $this;
       // console.log($r_h);
@@ -1737,6 +1781,8 @@
 
     function checkGridBlockVisible(){
       // console.log('checkGridBlockVisible');
+      // if(_is_mobile) return;
+
       var $r_h = _$row.height();
       var $this,pos;
       $('.grid .col', _$row).each(function(i,e){
@@ -1803,6 +1849,40 @@
     // };
 
 
+
+    //   ___     _ _        _   _
+    //  / __|___| | |___ __| |_(_)___ _ _
+    // | (__/ _ \ | / -_) _|  _| / _ \ ' \
+    //  \___\___/_|_\___\__|\__|_\___/_||_|
+    // mobile version of collection
+    function initCollectionNav(){
+      console.log('initCollectionNav');
+      // taxonomy-term.vocabulary-entrees.home_mobile
+      $('.field--name-field-notice, .index', '.taxonomy-term.vocabulary-entrees.home_mobile')
+        .addClass('closed');
+      $('.field--name-field-notice>.field__label', '.taxonomy-term.vocabulary-entrees.home_mobile')
+        .on('click', onClickCollectionNotice);
+      $('.index>.field__label', '.taxonomy-term.vocabulary-entrees.home_mobile')
+        .on('click', onClickCollectionIndex);
+    };
+    function onClickCollectionNotice(e){
+      // console.log('onClickCollectionNotice');
+      // var $part = $(this).parent();//parents('.taxonomy-term');
+      toggleEntreeOpening($(this).parent(), 'notice');
+    };
+    function onClickCollectionIndex(e){
+      // console.log('onClickCollectionIndex');
+      // var $part = $(this).parent();//parents('.taxonomy-term');
+      toggleEntreeOpening($(this).parent(), 'index');
+    };
+    function toggleEntreeOpening($e, part){
+      $e.toggleClass('closed')
+        .parents('.taxonomy-term.vocabulary-entrees.home_mobile').toggleClass(part+'-opened');
+    }
+
+
+
+
     //  ___                  _
     // / __| ___ __ _ _ _ __| |_
     // \__ \/ -_) _` | '_/ _| ' \
@@ -1852,8 +1932,10 @@
       $('body').removeClass().addClass('path-frontpage');
       $('a[data-drupal-link-system-path="<front>"]').addClass('is-active');
       // close entrees
-      _$corpus_canvas.trigger({'type':'close-all-entree'});
-      _$corpus_canvas.trigger({'type':'scramble-collection'});
+      if(_corpus_ready){
+        _$corpus_canvas.trigger({'type':'close-all-entree'});
+        _$corpus_canvas.trigger({'type':'scramble-collection'});
+      }
 
       if(typeof pop_state == "undefined" || !pop_state){
         console.log('backToFrontPage push state');
@@ -1924,7 +2006,9 @@
             // }
           }else{
             // if we were on production page just scramble collection in case of map was filtered
-            _$corpus_canvas.trigger({'type':'scramble-collection'});
+            if(_corpus_ready){
+              _$corpus_canvas.trigger({'type':'scramble-collection'});
+            }
             // reload production home
             $('a[data-drupal-link-system-path="productions"]', '#block-mainnavigation')
               .removeClass('is-active').trigger('click');

+ 13 - 7
sites/all/themes/custom/edlptheme/assets/styles/app.scss

@@ -103,7 +103,7 @@ header[role="banner"]{
   }
 }
 
-#block-mainnavigation{
+#block-mainnavigation, #block-mainnavigation-2{
   float:right;
   margin-top: 25px;
   z-index: 21;
@@ -161,12 +161,14 @@ header[role="banner"]{
     width:50px; //height:25px;
     overflow: visible;
     $square-size:15px;
-    >h2#block-mainnavigation-menu.visually-hidden{
+    >h2#block-mainnavigation-menu.visually-hidden,
+    >h2{
       // outline: 1px solid green;
       right:0;
       clip: auto;
       margin:0;
       text-indent: 100px;
+      overflow: hidden;
       cursor: pointer;
       width:$square-size*2; height:$square-size*2;
       background-size:$square-size $square-size;
@@ -206,7 +208,7 @@ header[role="banner"]{
 
     }
 
-    &.visible ul.menu{
+    &.opened ul.menu{
       left:-130px;
     }
   }
@@ -579,11 +581,15 @@ main[role="main"]{
     }
   }
 
-  html.is-mobile & .entrees{
-    #collection{
-      margin-top: -80px;
-      margin-bottom: 80px;
+  .collection{
+    h3{
+      @include content_titles;
+      text-align: center;
+      padding-top: 0.5em;
     }
+  }
+
+  html.is-mobile & .col[sys_path="collection"]{
     h3{
       @include content_titles;
       text-align: center;

+ 117 - 63
sites/all/themes/custom/edlptheme/edlptheme.theme

@@ -128,78 +128,136 @@ function edlptheme_preprocess_edlp_productions(&$vars){
 }
 
 function edlptheme_preprocess_node__enregistrement__index(&$vars){
-  $node = $vars['elements']['#node'];
-  $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);
-  }
+  // $node = $vars['elements']['#node'];
+  // $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);
+  // }
+  //
+  // $vars['link_attributes'] = new Attribute(array(
+  //   'data-drupal-link-system-path' => $system_path=='' ? '<front>' : $system_path,
+  //   'audio_url' => $son_url,
+  //   'nid' => $node->id(),
+  //   'class' => array('audio-link', 'ajax-link')
+  // ));
+  edlptheme_prepare_audio_link($vars);
+  // dpm($vars['link_attributes']);
+}
 
-  $vars['link_attributes'] = new Attribute(array(
-    'data-drupal-link-system-path' => $system_path=='' ? '<front>' : $system_path,
-    'audio_url' => $son_url,
-    'nid' => $node->id(),
-    'class' => array('audio-link', 'ajax-link')
-  ));
+// forhome mobile index
+function edlptheme_preprocess_node__enregistrement__index_home(&$vars){
+  // $node = $vars['elements']['#node'];
+  // $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);
+  // }
+  //
+  // $vars['link_attributes'] = new Attribute(array(
+  //   'data-drupal-link-system-path' => $system_path=='' ? '<front>' : $system_path,
+  //   'audio_url' => $son_url,
+  //   'nid' => $node->id(),
+  //   'class' => array('audio-link', 'ajax-link')
+  // ));
+  edlptheme_prepare_audio_link($vars);
   // dpm($vars['link_attributes']);
 }
 
 function edlptheme_preprocess_node__enregistrement__search_index(&$vars){
-  $node = $vars['elements']['#node'];
-  $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);
-  }
-
-  $vars['link_attributes'] = new Attribute(array(
-    'data-drupal-link-system-path' => $system_path=='' ? '<front>' : $system_path,
-    'audio_url' => $son_url,
-    'nid' => $node->id(),
-    'class' => array('audio-link', 'ajax-link')
-  ));
+  // $node = $vars['elements']['#node'];
+  // $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);
+  // }
+  //
+  // $vars['link_attributes'] = new Attribute(array(
+  //   'data-drupal-link-system-path' => $system_path=='' ? '<front>' : $system_path,
+  //   'audio_url' => $son_url,
+  //   'nid' => $node->id(),
+  //   'class' => array('audio-link', 'ajax-link')
+  // ));
+  edlptheme_prepare_audio_link($vars);
   // dpm($vars['link_attributes']);
 }
 
 function edlptheme_preprocess_node__enregistrement__lastdocs(&$vars){
-  $node = $vars['elements']['#node'];
-  $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);
-  }
-
-  $vars['link_attributes'] = new Attribute(array(
-    'data-drupal-link-system-path' => $system_path=='' ? '<front>' : $system_path,
-    'audio_url' => $son_url,
-    'nid' => $node->id(),
-    'class' => array('audio-link', 'ajax-link')
-  ));
+  // $node = $vars['elements']['#node'];
+  // $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);
+  // }
+  //
+  // $vars['link_attributes'] = new Attribute(array(
+  //   'data-drupal-link-system-path' => $system_path=='' ? '<front>' : $system_path,
+  //   'audio_url' => $son_url,
+  //   'nid' => $node->id(),
+  //   'class' => array('audio-link', 'ajax-link')
+  // ));
+  edlptheme_prepare_audio_link($vars);
   // dpm($vars['link_attributes']);
 }
 
 function edlptheme_preprocess_node__enregistrement__compo(&$vars){
+  // $node = $vars['elements']['#node'];
+  // $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);
+  // }
+  //
+  // $vars['link_attributes'] = new Attribute(array(
+  //   'data-drupal-link-system-path' => $system_path=='' ? '<front>' : $system_path,
+  //   'audio_url' => $son_url,
+  //   'nid' => $node->id(),
+  //   'class' => array('audio-link', 'ajax-link')
+  // ));
+  edlptheme_prepare_audio_link($vars);
+
+  // dpm($vars);
+  $title = $vars['label'][0]['#context']['value'];
+  $vars['label'][0]['#context']['value'] = Unicode::truncate($title, 25, true, true);
+  // dpm($vars['link_attributes']);
+}
+
+function edlptheme_prepare_audio_link(&$vars){
   $node = $vars['elements']['#node'];
   $options = ['absolute' => TRUE];
   $url = Url::fromRoute('entity.node.canonical', ['node' => $node->id()], $options);
@@ -221,10 +279,6 @@ function edlptheme_preprocess_node__enregistrement__compo(&$vars){
     'class' => array('audio-link', 'ajax-link')
   ));
 
-  // dpm($vars);
-  $title = $vars['label'][0]['#context']['value'];
-  $vars['label'][0]['#context']['value'] = Unicode::truncate($title, 25, true, true);
-  // dpm($vars['link_attributes']);
 }
 
 function edlptheme_preprocess_node__enregistrement__player_cartel(&$vars){

+ 7 - 0
sites/all/themes/custom/edlptheme/templates/content/edlp-corpus-collection.html.twig

@@ -0,0 +1,7 @@
+{% if entrees %}
+<div class="col small-col-12 med-col-6 large-col-6">
+  <div class="wrapper">
+            {{ entrees }}
+  </div>
+</div>
+{% endif %}

+ 3 - 3
sites/all/themes/custom/edlptheme/templates/content/edlp-home.html.twig

@@ -43,10 +43,10 @@
     </div>
   {% endif %}
 
-  {% if entrees %}
-    <div class="entrees col small-col-12 med-col-4 large-col-3">
+  {% if collection %}
+    <div class="collection col small-col-12 med-col-4 large-col-3">
       <div class="wrapper">
-        {{ entrees }}
+        {{ collection }}
       </div>
     </div>
   {% endif %}

Alguns arquivos não foram mostrados porque muitos arquivos mudaram nesse diff