diff --git a/core/includes/theme.inc b/core/includes/theme.inc index aaa48ff..b9438fb 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -1483,31 +1483,6 @@ function theme_settings_convert_to_config(array $theme_settings, Config $config) } /** - * Renders a system default template, which is essentially a PHP template. - * - * @param $template_file - * The filename of the template to render. - * @param $variables - * A keyed array of variables that will appear in the output. - * - * @return - * The output generated by the template. - */ -function theme_render_template($template_file, $variables) { - // Extract the variables to a local namespace - extract($variables, EXTR_SKIP); - - // Start output buffering - ob_start(); - - // Include the template file - include DRUPAL_ROOT . '/' . $template_file; - - // End buffering and return its contents - return ob_get_clean(); -} - -/** * Enables a given list of themes. * * @param $theme_list diff --git a/core/modules/system/lib/Drupal/system/Tests/Theme/ThemeTestPhpTemplate.php b/core/modules/system/lib/Drupal/system/Tests/Theme/ThemeTestPhpTemplate.php new file mode 100644 index 0000000..ff3fd03 --- /dev/null +++ b/core/modules/system/lib/Drupal/system/Tests/Theme/ThemeTestPhpTemplate.php @@ -0,0 +1,48 @@ + 'PHPTemplate Engine', + 'description' => 'Test theme functions with PHPTemplate.', + 'group' => 'Theme', + ); + } + + function setUp() { + parent::setUp(); + theme_enable(array('test_theme_phptemplate')); + } + + /** + * Ensures a theme's template is overrideable based on the 'template' filename. + */ + function testTemplateOverride() { + config('system.theme') + ->set('default', 'test_theme_phptemplate') + ->save(); + $this->drupalGet('theme-test/template-test'); + $this->assertText('Success: Template overridden.', t('Template overridden by defined \'template\' filename.')); + } + +} diff --git a/core/modules/system/lib/Drupal/system/Tests/Theme/ThemeTestTwig.php b/core/modules/system/lib/Drupal/system/Tests/Theme/ThemeTestTwig.php index 135a435..7860511 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Theme/ThemeTestTwig.php +++ b/core/modules/system/lib/Drupal/system/Tests/Theme/ThemeTestTwig.php @@ -24,7 +24,7 @@ class ThemeTestTwig extends WebTestBase { public static function getInfo() { return array( 'name' => 'Twig Engine', - 'description' => 'Test theme functions with twig.', + 'description' => 'Test Twig-specific theme functionality.', 'group' => 'Theme', ); } @@ -35,17 +35,6 @@ function setUp() { } /** - * Ensures a themes template is overrideable based on the 'template' filename. - */ - function testTemplateOverride() { - config('system.theme') - ->set('default', 'test_theme') - ->save(); - $this->drupalGet('theme-test/template-test'); - $this->assertText('Success: Template overridden.', t('Template overridden by defined \'template\' filename.')); - } - - /** * Tests that the Twig engine handles PHP data correctly. */ function testTwigVariableDataTypes() { diff --git a/core/modules/system/tests/themes/test_theme_phptemplate/theme_test.template_test.tpl.php b/core/modules/system/tests/themes/test_theme_phptemplate/theme_test.template_test.tpl.php index d4409bf..ada11e7 100644 --- a/core/modules/system/tests/themes/test_theme_phptemplate/theme_test.template_test.tpl.php +++ b/core/modules/system/tests/themes/test_theme_phptemplate/theme_test.template_test.tpl.php @@ -1,2 +1,2 @@ -Success: Template overridden. + diff --git a/core/themes/engines/phptemplate/phptemplate.engine b/core/themes/engines/phptemplate/phptemplate.engine index 88c09c7..718d460 100644 --- a/core/themes/engines/phptemplate/phptemplate.engine +++ b/core/themes/engines/phptemplate/phptemplate.engine @@ -23,3 +23,35 @@ function phptemplate_theme($existing, $type, $theme, $path) { $templates += drupal_find_theme_templates($existing, '.tpl.php', $path); return $templates; } + +/** + * Implements hook_extension(). + */ +function phptemplate_extension() { + return '.tpl.php'; +} + +/** + * Renders a system default template, which is essentially a PHP template. + * + * @param $template_file + * The filename of the template to render. + * @param $variables + * A keyed array of variables that will appear in the output. + * + * @return + * The output generated by the template. + */ +function phptemplate_render_template($template_file, $variables) { + // Extract the variables to a local namespace + extract($variables, EXTR_SKIP); + + // Start output buffering + ob_start(); + + // Include the template file + include DRUPAL_ROOT . '/' . $template_file; + + // End buffering and return its contents + return ob_get_clean(); +}