123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390 |
- <?php
- use Drupal\Core\Url;
- use Drupal\Core\Link;
- use Drupal\Core\Form\FormStateInterface;
- use Drupal\Core\Template\Attribute;
- use Drupal\Component\Utility\Unicode;
- use Drupal\Core\Render\Element;
-
- function materiotheme_preprocess_html(&$vars) {
-
-
- $site_config = \Drupal::config('system.site');
-
-
-
-
-
-
-
-
-
-
- global $base_url;
- $theme = \Drupal::theme()->getActiveTheme();
- $vars['#attached']['drupalSettings']['path']['themePath'] = $base_url .'/'. $theme->getPath();
- $description = [
- '#tag' => 'meta',
- '#attributes' => [
- 'name' => 'description',
- 'content' => $site_config->get('slogan'),
- ],
- ];
- $vars['page']['#attached']['html_head'][] = [$description, 'description'];
- $viewport = array(
- '#tag' => 'meta',
- '#attributes' => array(
- 'name' => 'viewport',
- 'content' => 'width=device-width, initial-scale=1, maximum-scale=1',
- ),
- );
- $vars['page']['#attached']['html_head'][] = [$viewport, 'viewport'];
-
-
-
- $content_security_policy = array(
- '#tag' => 'meta',
- '#attributes' => array(
- 'http-equiv' => 'Content-Security-Policy',
- 'content' => 'upgrade-insecure-requests',
- ),
- );
- $vars['page']['#attached']['html_head'][] = [$content_security_policy, 'content_security_policy'];
-
-
-
-
-
-
-
-
-
- $ati = array(
- '#tag' => 'meta',
- '#attributes' => array(
- 'rel' => 'apple-touch-icon',
- 'sizes' => "180x180",
- 'href' => '/apple-touch-icon.png',
- ),
- );
- $vars['page']['#attached']['html_head'][] = [$ati, 'ati'];
-
- $icon32 = array(
- '#tag' => 'meta',
- '#attributes' => array(
- 'rel' => 'icon',
- 'type' => "image/png",
- 'sizes' => "32x32",
- 'href' => '/favicon-32x32.png',
- ),
- );
- $vars['page']['#attached']['html_head'][] = [$icon32, 'icon32'];
-
- $icon16 = array(
- '#tag' => 'meta',
- '#attributes' => array(
- 'rel' => 'icon',
- 'type' => "image/png",
- 'sizes' => "16x16",
- 'href' => '/favicon-16x16.png',
- ),
- );
- $vars['page']['#attached']['html_head'][] = [$icon16, 'icon16'];
-
-
- $safaripinnedtab = array(
- '#tag' => 'meta',
- '#attributes' => array(
- 'rel' => 'mask-icon',
- 'href' => '/safari-pinned-tab.svg',
- 'color' => "#69ccce",
- ),
- );
- $vars['page']['#attached']['html_head'][] = [$safaripinnedtab, '$safaripinnedtab'];
-
- $ms = array(
- '#tag' => 'meta',
- '#attributes' => array(
- 'name' => 'msapplication-TileColor',
- 'content' => "#69ccce"
- ),
- );
- $vars['page']['#attached']['html_head'][] = [$ms, '$ms'];
-
- $tc = array(
- '#tag' => 'meta',
- '#attributes' => array(
- 'name' => 'theme-color',
- 'content' => "#69ccce"
- ),
- );
- $vars['page']['#attached']['html_head'][] = [$tc, '$tc'];
-
- $pragma = array(
- '#tag' => 'meta',
- '#attributes' => array(
- 'http-equiv' => 'pragma',
- 'content' => "no-cache"
- ),
- );
- $vars['page']['#attached']['html_head'][] = [$pragma, '$pragma'];
-
- $cachecontrol = array(
- '#tag' => 'meta',
- '#attributes' => array(
- 'http-equiv' => 'cache-control',
- 'content' => "no-cache, no-store, must-revalidate"
- ),
- );
- $vars['page']['#attached']['html_head'][] = [$cachecontrol, '$cachecontrol'];
- }
- function materiotheme_preprocess_page(&$vars){
-
- }
-
-
- function materiotheme_form_alter(&$form, FormStateInterface $form_state, $form_id) {
-
- preg_match('/commerce_order_item_variation_cart_form_form_commerce_product_variation_(\d+)/', $form_id, $matches);
- if ($matches && isset($matches[1]) && $variation_id = $matches[1]) {
-
-
-
-
-
- $form['actions']['submit']['#attributes'] += array(
- "@click.prevent.stop" => "checkaddtocart(\$event, $variation_id)"
- );
- }
-
- switch ($form_id) {
- case 'commerce_order_item_variation_cart_form_form_commerce_product_variation_3':
- $form['actions']['submit']['#value'] = t('Yeees!');
- break;
- case 'commerce_order_item_variation_cart_form_form_commerce_product_variation_4':
- $form['actions']['submit']['#value'] = t('Yay!');
- break;
- case 'commerce_order_item_variation_cart_form_form_commerce_product_variation_5':
- $form['actions']['submit']['#value'] = t('Great!');
- break;
- case 'commerce_order_item_variation_cart_form_form_commerce_product_variation_6':
- $form['actions']['submit']['#value'] = t('OKAY!');
- break;
- }
- }
- function materiotheme_form_user_login_form_alter(&$form, FormStateInterface $form_state, $form_id) {
-
-
- $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 materiotheme_theme_suggestions_taxonomy_term_alter(&$suggestions, &$vars){
-
-
- $original = $vars['theme_hook_original'];
- $bundle = $vars['elements']['#taxonomy_term']->bundle();
- $viewmode = $vars['elements']["#view_mode"];
- $suggestions[] = $original.'__'.$bundle.'__'.$viewmode;
-
- }
- function materiotheme_theme_suggestions_field_alter(&$suggestions, &$vars){
- if($vars['element']["#entity_type"] === "commerce_product_variation"
- && $vars['element']["#bundle"] === "materio_product_variation_type"
- && $vars['element']["#field_name"] === "title"){
- $test = 'test';
- $original = $vars['theme_hook_original'];
- $entity_type = $vars['element']["#entity_type"];
- $bundle = $vars['element']["#bundle"];
- $field_name = $vars['element']["#field_name"];
- $viewmode = $vars['element']['#view_mode'];
- $suggestions[] = $original.'__'.$entity_type.'__'.$bundle.'__'.$field_name.'__'.$viewmode;
- }
- }
- function materiotheme_theme_suggestions_image_alter(array &$suggestions, array $variables){
-
- $suggestions[] = 'image__'.$variables['style_name'];
- }
- function materiotheme_preprocess_commerce_product(array &$variables) {
- $test="test";
-
- if($variables['elements']['#view_mode'] === 'order_summary'
- || $variables['elements']['#view_mode'] === 'home_summary'){
- unset($variables['product']['variation_title']);
- unset($variables['product']['variation_field_description']);
- unset($variables['product']['variation_price']);
- unset($variables['product']['variation_field_multiple']);
- unset($variables['product']['variation_commerce_variation_cart_form']);
- }
- $language = \Drupal::languageManager()->getCurrentLanguage()->getId();
- $variables['language'] = $language;
- }
- function materiotheme_preprocess_printable(array &$variables) {
- $site_config = \Drupal::config('system.site');
- $variables['site_name'] = $site_config->get('name');
- $variables['slogan'] = $site_config->get('slogan');
- }
- function materiotheme_preprocess_field__node__field_a_database__frontpage(array &$variables) {
- if ($variables['logged_in']) {
- $variables['label_link'] = array(
- "href" => '/' . $variables['element']['#language'] . '/base'
- );
- }
- }
- function materiotheme_preprocess_field__node__field_blabla__frontpage(array &$variables) {
- $variables['label_link'] = array(
- "href" => '/' . $variables['element']['#language'] . '/blabla'
- );
- }
- function materiotheme_preprocess_field__node__field_showrooms__frontpage(array &$variables) {
- $variables['label_link'] = array(
- "href" => '/' . $variables['element']['#language'] . '/showrooms'
- );
- }
|