112 lines
3.0 KiB
Plaintext
112 lines
3.0 KiB
Plaintext
<?php
|
|
|
|
/**
|
|
* @file
|
|
* Functions to support theming in the edlp theme.
|
|
*/
|
|
|
|
use Drupal\Core\Url;
|
|
use Drupal\Core\Form\FormStateInterface;
|
|
use Drupal\Core\Template\Attribute;
|
|
|
|
// function edlptheme_preprocess_input(&$vars){
|
|
// dsm($vars, 'vars');
|
|
// $vars['attributes']['placeholder'] = "salut";
|
|
// }
|
|
|
|
function edlptheme_preprocess_node(&$vars){
|
|
$node = $vars['elements']['#node'];
|
|
$options = ['absolute' => TRUE];
|
|
$url = Url::fromRoute('entity.node.canonical', ['node' => $node->id()], $options);
|
|
$system_path = $url->getInternalPath();
|
|
$vars['link_attributes'] = new Attribute(array(
|
|
'data-drupal-link-system-path' => $system_path=='' ? '<front>' : $system_path
|
|
));
|
|
}
|
|
|
|
/**
|
|
* Implements hook_form_alter
|
|
*/
|
|
function edlptheme_form_user_login_form_alter(&$form, FormStateInterface $form_state, $form_id) {
|
|
// dpm($form_id, 'form_id');
|
|
// dpm($form, 'form');
|
|
$form['name']['#attributes']['placeholder'] = (string) $form['name']['#title'];
|
|
unset($form['name']['#title']);
|
|
$form['pass']['#attributes']['placeholder'] = (string) $form['pass']['#title'];
|
|
unset($form['pass']['#title']);
|
|
}
|
|
|
|
function edlptheme_preprocess_edlp_productions(&$vars){
|
|
foreach($vars['nodes'] as &$node){
|
|
switch($node['vm']){
|
|
case "image_2_columns":
|
|
$cols = 4;
|
|
break;
|
|
case "image_1_columns":
|
|
$cols = 2;
|
|
break;
|
|
case "text_1_column":
|
|
$cols = 2;
|
|
break;
|
|
};
|
|
$node['cols'] = $cols;
|
|
}
|
|
// dpm($vars);
|
|
}
|
|
|
|
function edlptheme_preprocess_node__player_cartel(&$vars){
|
|
// dpm($vars);
|
|
// if transcript not empty
|
|
$url = Url::fromRoute('entity.node.canonical', ['node'=>$vars['node']->id()], array(
|
|
'attributes' => array(
|
|
'class' => ['link-transcript', 'ajax-link'],
|
|
'viewmode'=>'transcript'
|
|
)
|
|
));
|
|
$vars['link_transcript'] = array(
|
|
'#title' => t("Lire le text."),
|
|
'#type' => 'link',
|
|
'#url' => $url,
|
|
'#options'=>array(
|
|
'attributes' => array(
|
|
'data-drupal-link-system-path' => $url->getInternalPath()
|
|
)
|
|
)
|
|
);
|
|
// TODO: refacorize the link generator as following :
|
|
// $url = Url::fromRoute('entity.taxonomy_term.canonical', ['taxonomy_term'=>$tid]);
|
|
// $url->setOptions(array(
|
|
// 'attributes' => array(
|
|
// 'class' => ['index-link', 'ajax-link'],
|
|
// 'viewmode'=>'index',
|
|
// 'tid'=>$tid,
|
|
// 'data-drupal-link-system-path' => $url->getInternalPath()
|
|
// )
|
|
// ));
|
|
// $entree['index_link'] = Link::fromTextAndUrl('index', $url);
|
|
|
|
// if article not empty
|
|
$url = Url::fromRoute('entity.node.canonical', ['node'=>$vars['node']->id()], array(
|
|
'attributes' => array(
|
|
'class' => ['link-article', 'ajax-link'],
|
|
'viewmode'=>'article'
|
|
)
|
|
));
|
|
$vars['link_article'] = array(
|
|
'#title' => t("Lire l'article."),
|
|
'#type' => 'link',
|
|
'#url' => $url,
|
|
'#options' => array(
|
|
'attributes'=>array(
|
|
'data-drupal-link-system-path' => $url->getInternalPath()
|
|
)
|
|
)
|
|
);
|
|
// if article or transcript
|
|
$vars['col_left'] = true;
|
|
|
|
// if
|
|
$vars['col_right'] = true;
|
|
|
|
}
|