fixed entrees menu : translation and order

This commit is contained in:
2018-04-18 17:40:08 +02:00
parent 613ea5fc02
commit 6e56bf1799
7 changed files with 146 additions and 66 deletions
@@ -27,9 +27,11 @@
var _ctx = _canvas.getContext('2d');
var _canvas_props = {
// 'margin_top':90, // with red border on head
'margin_top':75, // without red border on head
// 'margin_top':75, // without red border on head
'margin_top':0,
'margin_right':0,
'margin_bottom':65,
// 'margin_bottom':65,
'margin_bottom':0,
'margin_left':0
};
var _physics = new Physics();
@@ -93,7 +95,7 @@
onResizeCanvas();
};
function onResizeCanvas() {
// https://medium.com/wdstack/fixing-html5-2d-canvas-blur-8ebe27db07da
_canvas.width = window.innerWidth*_dpi;
_canvas.height = window.innerHeight*_dpi;
@@ -27,9 +27,11 @@
var _ctx = _canvas.getContext('2d');
var _canvas_props = {
// 'margin_top':90, // with red border on head
'margin_top':75, // without red border on head
// 'margin_top':75, // without red border on head
'margin_top':0,
'margin_right':0,
'margin_bottom':65,
// 'margin_bottom':65,
'margin_bottom':0,
'margin_left':0
};
var _physics = new Physics();
@@ -93,7 +95,7 @@
onResizeCanvas();
};
function onResizeCanvas() {
// https://medium.com/wdstack/fixing-html5-2d-canvas-blur-8ebe27db07da
_canvas.width = window.innerWidth*_dpi;
_canvas.height = window.innerHeight*_dpi;
@@ -8,6 +8,7 @@ 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;
/**
@@ -24,26 +25,40 @@ class BlockEntrees extends BlockBase {
*/
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);
// dsm($terms);
foreach ($terms as $term) {
// dpm($term->toArray());
$tid = $term->id();
$name = $term->getName();
// $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);
// dsm($terms);
foreach ($ordered_trans_terms as $name => $term) {
$tid = $term->id();
$entree = array(
'tid'=>$tid
);
// term name
// term link
$url = Url::fromRoute('entity.taxonomy_term.canonical', ['taxonomy_term'=>$tid]);
$url->setOptions(array(
'attributes' => array(