geshifilter-8.x-2.0-beta1/geshifield/geshifield.module

geshifield/geshifield.module
<?php

/**
 * @file
 * Defines a CCK field for source code with GeSHi syntax highlighting.
 *
 * @todo: is the GeSHi CSS file always loaded when needed?
 */

use Drupal\geshifilter\GeshiFilterProcess;

/**
 * Implements hook_theme().
 */
function geshifield_theme() {
  return [
    'geshifield_default' => [
      'render element' => 'geshifield',
      'variables' => [
        'language' => NULL,
        'sourcecode' => NULL
      ],
    ],
  ];
}

/**
 * Prepares variables for geshifield theme.
 *
 * Default template: geshifield_default.html.twig.
 *
 * @param array $variables
 *  An associative array containing the following keys:
 *   - entity: the entity the TOC belongs to.
 *   - title: the TOC title.
 *   - tag: the tag title.
 */
function template_preprocess_geshifield_default(&$variables) {
  $language = $variables['language'];
  $sourcecode = $variables['sourcecode'];
  $variables['geshicode'] = GeshiFilterProcess::geshiProcess($sourcecode, $language);
}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc