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,40 @@
|
||||
<?php
|
||||
|
||||
use Drupal\Core\Render\Element;
|
||||
|
||||
|
||||
/**
|
||||
* Prepares variables for Composition templates.
|
||||
*
|
||||
* Default template: composition.html.twig.
|
||||
*
|
||||
* @param array $variables
|
||||
* An associative array containing:
|
||||
* - elements: An associative array containing the user information and any
|
||||
* - attributes: HTML attributes for the containing element.
|
||||
*/
|
||||
function template_preprocess_composition(array &$vars) {
|
||||
// dpm($variables);
|
||||
// Fetch Composition Entity Object.
|
||||
/** @var \Drupal\edlp_studio\CompositionInterface $composition */
|
||||
$composition = $vars['elements']['#composition'];
|
||||
|
||||
$vars['view_mode'] = $vars['elements']['#view_mode'];
|
||||
|
||||
// $vars['name'] = $composition->getName();
|
||||
// unset($vars['elements']['name']);
|
||||
|
||||
// $variables['page'] = $variables['view_mode'] == 'full' && taxonomy_term_is_page($term);
|
||||
|
||||
$vars['url'] = $composition->url();
|
||||
|
||||
$vars['attributes']['cid'] = $composition->id();
|
||||
$vars['attributes']['class'] = array('composition');
|
||||
|
||||
// Helpful $content variable for templates.
|
||||
foreach (Element::children($vars['elements']) as $key) {
|
||||
$vars['content'][$key] = $vars['elements'][$key];
|
||||
}
|
||||
|
||||
// dpm($vars);
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
use \Drupal\Core\Url;
|
||||
use Drupal\Component\Utility\Unicode;
|
||||
|
||||
use Drupal\edlp_studio\Entity\Chutier;
|
||||
|
||||
function template_preprocess_edlp_chutier_ui(&$vars){
|
||||
// dpm($vars);
|
||||
// $view_builder = \Drupal::entityTypeManager()->getViewBuilder('node');
|
||||
|
||||
$vars['documents'] = array (
|
||||
'#theme' => 'item_list',
|
||||
'#items' => [],
|
||||
);
|
||||
foreach($vars['document_nodes'] as $node){
|
||||
// get the url
|
||||
$url = Url::fromRoute('entity.node.canonical', ['node' => $node->id()], ['absolute' => TRUE]);
|
||||
// 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);
|
||||
}
|
||||
// get the title
|
||||
$title = $node->getTitle();
|
||||
if(!$title) continue;
|
||||
$trunc_title = Unicode::truncate($title, 25, true, true);
|
||||
// classes
|
||||
$classes = array('audio-link', 'ajax-link');
|
||||
// get the entries
|
||||
$entrees = '';
|
||||
foreach ($node->get('field_entrees')->getValue() as $key => $term) {
|
||||
$entrees .= '<span class="entree" tid="'.$term['target_id'].'"></span>';
|
||||
}
|
||||
//
|
||||
// get the remove url (obviously as we are in chutier all contents actions are remove ;)
|
||||
$remove_url = Chutier::getActionsUrl($node->id(), $vars['uid']);
|
||||
|
||||
// build the link
|
||||
$vars['documents']['#items'][] = array(
|
||||
'#type' => 'container',
|
||||
'entrees' => array(
|
||||
'#type' => 'container',
|
||||
'#attributes'=>['class'=>['entrees']],
|
||||
'#markup'=>$entrees,
|
||||
),
|
||||
'link'=>array(
|
||||
'#title' => $trunc_title,
|
||||
'#type' => 'link',
|
||||
'#url' => $url,
|
||||
'#options'=>array(
|
||||
'attributes' => array(
|
||||
'data-drupal-link-system-path' => $url->getInternalPath(),
|
||||
'audio_url' => $son_url,
|
||||
'nid' => $node->id(),
|
||||
// 'tid' => $entrees[mt_rand(0, count($entrees) - 1)],
|
||||
// 'entries_size' => count($entrees),
|
||||
'class' => $classes,
|
||||
'title'=>$title,
|
||||
),
|
||||
),
|
||||
),
|
||||
'remove_link' => array(
|
||||
'#title' => t("Chutier."),
|
||||
'#type' => 'link',
|
||||
'#url' => $remove_url,
|
||||
'#options'=>array(
|
||||
'attributes' => array(
|
||||
'data-drupal-link-system-path' => $remove_url->getInternalPath()
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
function template_preprocess_edlp_composition_ui(&$vars){
|
||||
// dpm($vars);
|
||||
|
||||
if($vars['lastcomposition']){
|
||||
$view_builder = \Drupal::entityTypeManager()->getViewBuilder('composition');
|
||||
$vars['composition'] = $view_builder->view($vars['lastcomposition'], 'studio_ui');
|
||||
}else{
|
||||
$vars['composition'] = null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
use \Drupal\Core\Url;
|
||||
use \Drupal\Component\Utility\Unicode;
|
||||
|
||||
function template_preprocess_edlp_compositions_list(&$vars){
|
||||
|
||||
$vars['compositions'] = array (
|
||||
'#theme' => 'item_list',
|
||||
'#items' => [],
|
||||
);
|
||||
$i = 0;
|
||||
foreach($vars['composition_entities'] as $entity){
|
||||
// get the url
|
||||
$url = Url::fromRoute('entity.composition.canonical',
|
||||
['composition' => $entity->id()], ['absolute' => TRUE]);
|
||||
// get the delete url
|
||||
$delete_url = Url::fromRoute('edlp_studio.composition_controller_action_ajax',
|
||||
['action' => 'delete', 'cid'=>$entity->id()], ['absolute' => TRUE]);
|
||||
|
||||
$title = $entity->getName();
|
||||
|
||||
$vars['compositions']['#items'][] = array(
|
||||
'compo_link' => array(
|
||||
'#title' => $title,
|
||||
'#type' => 'link',
|
||||
'#url' => $url,
|
||||
'#options'=>array(
|
||||
'attributes' => array(
|
||||
'data-drupal-link-system-path' => $url->getInternalPath(),
|
||||
'cid' => $entity->id(),
|
||||
'class' => ['composition-link', $i==0 ? 'is-active':''],
|
||||
'title'=>$title,
|
||||
),
|
||||
),
|
||||
),
|
||||
'delete_link' => array(
|
||||
'#title' => t("delete"),
|
||||
'#type' => 'link',
|
||||
'#url' => $delete_url,
|
||||
'#options'=>array(
|
||||
'attributes' => array(
|
||||
'data-drupal-link-system-path' => $delete_url->getInternalPath(),
|
||||
'cid' => $entity->id(),
|
||||
'class' => ['delete-composition-link'],
|
||||
'title'=> t('Delete @title', array('@title'=>$title)),
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
$i++;
|
||||
}
|
||||
|
||||
$vars['compositions']['#items'][] = array(
|
||||
'#title' => t('New composition'),
|
||||
'#type' => 'link',
|
||||
'#url' => $vars['new_composition_url'],
|
||||
'#options'=>array(
|
||||
'attributes' => array(
|
||||
'data-drupal-link-system-path' => $vars['new_composition_url']->getInternalPath(),
|
||||
'class' => ['new-composition-link']
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
function template_preprocess_edlp_studio_ui(&$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']);
|
||||
}
|
||||
Reference in New Issue
Block a user