You are here

function oa_comment_theme in OA Comment 7.2

Implements hook_theme().

File

./oa_comment.theme.inc, line 10
Preprocess functions for comments.

Code

function oa_comment_theme($existing, $type, $theme, $path) {
  $path = drupal_get_path('module', 'oa_comment') . '/templates';
  $views = array(
    'oa_comment_topics' => array(
      'comment_topics',
      'comment_user_topics',
      'comment_user_topics_replied',
    ),
    'oa_comment_media' => array(
      'commentnode_attachments',
    ),
  );
  $theme = array();
  foreach ($views as $view_name => $displays) {
    $key = 'views_view_fields__' . $view_name;
    $filename = str_replace('_', '-', $key);
    if (file_exists($path . '/' . $filename . '.tpl.php')) {

      // We found a general template for this entire view.
      $theme[$key] = array(
        'template' => $filename,
        'base hook' => 'views_view_fields',
        'preprocess functions' => array(
          'template_preprocess',
          'template_preprocess_views_view_fields',
          'oa_core_preprocess_views_view_fields',
        ),
        'arguments' => array(
          'view' => NULL,
          'options' => NULL,
          'row' => NULL,
        ),
        'path' => $path,
      );
    }
    else {

      // Otherwise check for specific display templates.
      foreach ($displays as $display) {
        $key = 'views_view_fields__' . $view_name . '__' . $display;
        $filename = str_replace('_', '-', $key);
        if (file_exists($path . '/' . $filename . '.tpl.php')) {
          $theme[$key] = array(
            'template' => $filename,
            'base hook' => 'views_view_fields',
            'preprocess functions' => array(
              'template_preprocess',
              'template_preprocess_views_view_fields',
              'oa_core_preprocess_views_view_fields',
            ),
            'arguments' => array(
              'view' => NULL,
              'options' => NULL,
              'row' => NULL,
            ),
            'path' => $path,
          );
        }
      }
    }
  }

  // Provide theme implementation for comments.
  $theme['oa_comment__comment'] = array(
    'template' => 'oa-comment--comment',
    'render element' => 'elements',
    'path' => $path,
  );
  $theme['oa_comment__comment_wrapper'] = array(
    'template' => 'oa-comment--comment-wrapper',
    'render element' => 'elements',
    'path' => $path,
  );

  // Provide a theme implementation for the comment form.
  $theme['comment_form'] = array(
    'template' => 'oa-comment--comment-form',
    'render element' => 'form',
    'path' => $path,
  );
  return $theme;
}