You are here

function vud_pseudo_theming in Vote Up/Down 7

Same name and namespace in other branches
  1. 6.3 vud.theme.inc \vud_pseudo_theming()
  2. 6.2 vud.theme.inc \vud_pseudo_theming()
  3. 7.2 vud.theme.inc \vud_pseudo_theming()

Mimic some theming workflow.

We do this since we do not have standard theme overwrite because is not possible to decide dinamically the path where the template is located(in contrast with function names and template names).

@fixme: Reimplement theme suggestions.

2 calls to vud_pseudo_theming()
vud_votes_proxy in ./vud.theme.inc
Proxy votes display function, that hook_theme() calls.
vud_widget_proxy in ./vud.theme.inc
Proxy widget function that hook_theme() calls.

File

./vud.theme.inc, line 96
Theme functions

Code

function vud_pseudo_theming($vote_entity, $template_type, $plugin, &$variables) {

  // let modules modify variables passed to the template
  $variables_type = 'vud_' . $template_type . '_template_variables';
  drupal_alter($variables_type, $variables);

  // let widget modify variables passed to the template
  if ($function = ctools_plugin_get_function($plugin, 'alter template variables')) {
    $function($template_type, $variables);
  }

  // @fixme: Remove hardcode.
  $template_file = $plugin['path'] . '/' . $plugin[$template_type . ' template'] . $plugin['extension'];
  return $template_file;

  // and then provide template suggestions by hand
  $suggestions = module_invoke('vud_' . $vote_entity, 'template_suggestions', $template_type, $plugin, $variables['entity_id']);
  if (empty($suggestions)) {
    $template_file = $plugin['path'] . '/' . $plugin[$template_type . ' template'] . $plugin['extension'];
  }
  else {
    global $theme_key;
    $themes = list_themes();
    $current_theme = $themes[$theme_key];
    $paths = array(
      $plugin['path'],
      dirname($current_theme->filename),
    );

    // @fixme: drupal_discover_template() was removed from core.

    //$template_file = drupal_find_theme_templates($paths, $suggestions, $plugin['extension']);
  }
  return $template_file;
}