Projet

Général

Profil

Paste
Télécharger (1,29 ko) Statistiques
| Branche: | Révision:

root / drupal7 / modules / simpletest / tests / themes / engines / nyan_cat / nyan_cat.engine @ c9e51f47

1
<?php
2

    
3
/**
4
 * @file
5
 * Handles integration of Nyan cat templates because we love kittens.
6
 */
7

    
8
/**
9
 * Includes .theme file from themes.
10
 */
11
function nyan_cat_init($template) {
12
  $file = dirname($template->filename) . '/template.theme';
13
  if (file_exists($file)) {
14
    include_once DRUPAL_ROOT . '/' . $file;
15
  }
16
}
17

    
18
/**
19
 * Implements hook_theme().
20
 */
21
function nyan_cat_theme($existing, $type, $theme, $path) {
22
  $templates = drupal_find_theme_functions($existing, array($theme));
23
  $templates += drupal_find_theme_templates($existing, '.nyan-cat.html', $path);
24
  return $templates;
25
}
26

    
27
/**
28
 * Implements hook_extension().
29
 */
30
function nyan_cat_extension() {
31
  return '.nyan-cat.html';
32
}
33

    
34
/**
35
 * Implements hook_render_template().
36
 *
37
 * @param string $template_file
38
 *   The filename of the template to render.
39
 * @param mixed[] $variables
40
 *   A keyed array of variables that will appear in the output.
41
 *
42
 * @return string
43
 *   The output generated by the template.
44
 */
45
function nyan_cat_render_template($template_file, $variables) {
46
  $output = str_replace('div', 'nyancat', file_get_contents(DRUPAL_ROOT . '/' . $template_file));
47
  foreach ($variables as $key => $variable) {
48
    if (strpos($output, '9' . $key) !== FALSE) {
49
      $output = str_replace('9' . $key, $variable, $output);
50
    }
51
  }
52
  return $output;
53
}