Example #1
0
/**
 * Implements hook_theme_registry_alter().
 */
function omega_theme_registry_alter(&$registry)
{
    require_once dirname(__FILE__) . '/includes/registry.inc';
    // Fix for integration with the theme developer module.
    if (module_exists('devel_themer')) {
        foreach ($registry as $hook => $data) {
            if (isset($data['original'])) {
                $registry[$hook] = $data['original'];
            }
        }
    }
    // For maintainability reasons, some of this code lives in a class.
    $handler = new OmegaThemeRegistryHandler($registry, $GLOBALS['theme']);
    // Allows themers to split preprocess / process / theme code across separate
    // files to keep the main template.php file clean. This is really fast because
    // it uses the theme registry to cache the paths to the files that it finds.
    $trail = omega_theme_trail($GLOBALS['theme']);
    foreach ($trail as $theme => $name) {
        $handler->registerHooks($theme);
        $handler->registerThemeFunctions($theme, $trail);
    }
    // Override the default 'template_process_html' hook implementation.
    $handler->overrideHook('html', 'template_process_html', 'omega_template_process_html_override');
    // We prefer the attributes array instead of the plain classes array used by
    // many core and contrib modules. In Drupal 8, we are going to convert all
    // occurrences of that into an attributes object. For now, we simply
    // synchronize our attributes array with the classes array to encourage
    // themers to use it.
    foreach ($registry as $hook => $item) {
        if (empty($item['base hook']) && empty($item['function'])) {
            if (($index = array_search('template_preprocess', $registry[$hook]['preprocess functions'], TRUE)) !== FALSE) {
                // Make sure that omega_initialize_attributes() is invoked first.
                array_unshift($registry[$hook]['process functions'], 'omega_cleanup_attributes');
                // Add omega_cleanup_attributes() right after template_preprocess().
                array_splice($registry[$hook]['preprocess functions'], $index + 1, 0, 'omega_initialize_attributes');
            }
        }
    }
    // Add a preprocessor for initializing default variables to every layout.
    foreach (array_keys(_omega_theme_layouts()) as $hook) {
        $registry[$hook]['preprocess functions'] = array_diff($registry[$hook]['preprocess functions'], array('template_preprocess'));
        array_unshift($registry[$hook]['process functions'], '_omega_preprocess_default_layout_variables');
    }
    // Allow extensions to register hooks in the theme registry.
    foreach (omega_extensions() as $extension => $info) {
        // Invoke the according hooks for every enabled extension.
        if (omega_extension_enabled($extension)) {
            // Give every enabled extension a chance to alter the theme registry.
            $hook = $info['theme'] . '_extension_' . $extension . '_theme_registry_alter';
            if (function_exists($hook)) {
                $hook($registry);
            }
        }
    }
    // Fix for integration with the theme developer module.
    if (module_exists('devel_themer') && function_exists('devel_themer_theme_registry_alter')) {
        devel_themer_theme_registry_alter($registry);
    }
}
Example #2
0
/**
 * Implements hook_theme().
 */
function omega_theme()
{
    $info['omega_chrome'] = array('render element' => 'element');
    $info['omega_layout'] = array('base hook' => 'page');
    $info = array_merge($info, _omega_theme_layouts());
    return $info;
}