- <?php
-
- * Implements hook_theme().
- */
- function theme_test_theme($existing, $type, $theme, $path) {
- $base = array(
- 'file' => 'theme_test.theme.inc',
- );
-
- $items['theme_test'] = array(
- 'variables' => array('foo' => ''),
- ) + $base;
- $items['theme_test_template_test'] = array(
- 'template' => 'theme_test.template_test',
- ) + $base;
- $items['theme_test_template_test_2'] = array(
- 'template' => 'theme_test.template_test',
- ) + $base;
- $items['theme_test_foo'] = array(
- 'variables' => array('foo' => NULL),
- ) + $base;
-
- return $items;
- }
-
- * Implements hook_system_theme_info().
- */
- function theme_test_system_theme_info() {
- $themes['test_theme'] = backdrop_get_path('module', 'theme_test') . '/themes/test_theme/test_theme.info';
- $themes['test_basetheme'] = backdrop_get_path('module', 'theme_test') . '/themes/test_basetheme/test_basetheme.info';
- $themes['test_subtheme'] = backdrop_get_path('module', 'theme_test') . '/themes/test_subtheme/test_subtheme.info';
- $themes['test_theme_config'] = backdrop_get_path('module', 'theme_test') . '/themes/test_theme_config/test_theme_config.info';
- return $themes;
- }
-
- * Implements hook_menu().
- */
- function theme_test_menu() {
- $items['theme-test/suggestion'] = array(
- 'title' => 'Suggestion',
- 'page callback' => '_theme_test_suggestion',
- 'access callback' => TRUE,
- 'theme callback' => '_theme_custom_theme',
- 'type' => MENU_CALLBACK,
- );
- $items['theme-test/alter'] = array(
- 'title' => 'Suggestion',
- 'page callback' => '_theme_test_alter',
- 'access callback' => TRUE,
- 'theme callback' => '_theme_custom_theme',
- 'type' => MENU_CALLBACK,
- );
- $items['theme-test/hook-init'] = array(
- 'page callback' => 'theme_test_hook_init_page_callback',
- 'access callback' => TRUE,
- 'type' => MENU_CALLBACK,
- );
- $items['theme-test/template-test'] = array(
- 'page callback' => 'theme_test_template_test_page_callback',
- 'access callback' => TRUE,
- 'type' => MENU_CALLBACK,
- );
- return $items;
- }
-
- * Implements hook_init().
- */
- function theme_test_init() {
- if (arg(0) == 'theme-test' && arg(1) == 'hook-init') {
-
-
-
- backdrop_theme_rebuild();
-
-
-
-
- $GLOBALS['theme_test_output'] = theme('more_link', array('url' => 'user', 'title' => 'Themed output generated in hook_init()'));
- }
- }
-
- * Implements hook_exit().
- */
- function theme_test_exit() {
- if (arg(0) == 'user') {
-
-
- _theme_registry_callback('_theme_test_load_registry', array());
- print theme_get_registry() ? 'registry initialized' : 'registry not initialized';
- }
- }
-
- * Fake registry loading callback.
- */
- function _theme_test_load_registry() {
- return array();
- }
-
- * Menu callback for testing themed output generated in hook_init().
- */
- function theme_test_hook_init_page_callback() {
- return $GLOBALS['theme_test_output'];
- }
-
- * Menu callback for testing template overriding based on filename.
- */
- function theme_test_template_test_page_callback() {
- return theme('theme_test_template_test');
- }
-
- * Custom theme callback.
- */
- function _theme_custom_theme() {
- return 'test_theme';
- }
-
- * Page callback, calls backdrop_alter().
- *
- * This is for testing that the theme can have hook_*_alter() implementations
- * that run during page callback execution, even before theme() is called for
- * the first time.
- */
- function _theme_test_alter() {
- $data = 'foo';
- backdrop_alter('theme_test_alter', $data);
- return "The altered data is $data.";
- }
-
- * Page callback, calls a theme hook suggestion.
- */
- function _theme_test_suggestion() {
- return theme(array('theme_test__suggestion', 'theme_test'), array());
- }
-
- * Implements hook_preprocess_page().
- */
- function theme_test_preprocess_page(&$variables) {
- $variables['html_attributes']['theme_test_html_attribute'] = 'theme test html attribute value';
- $variables['body_attributes']['theme_test_body_attribute'] = 'theme test body attribute value';
- }
-
- * Implements hook_system_info_alter().
- */
- function theme_test_system_info_alter(&$info, $file, $type) {
- if ($type === 'theme' && $file->name === 'stark') {
- unset($info['hidden']);
- }
- }