You are here

function advanced_forum_is_styled in Advanced Forum 7.2

Same name and namespace in other branches
  1. 6.2 includes/style.inc \advanced_forum_is_styled()

Returns whether forum is styled.

4 calls to advanced_forum_is_styled()
advanced_forum_links_alter in ./advanced_forum.module
Own link alteration implementation because there are no hook_link nor hook_link_alter in D7.
advanced_forum_preprocess_comment in includes/theme.inc
Preprocesses template variables for the comment template.
advanced_forum_preprocess_comment_wrapper in includes/theme.inc
Preprocess comment wrapper.
advanced_forum_preprocess_node in includes/theme.inc
Preprocesses template variables for the node template.

File

includes/style.inc, line 234
Functions relating to the style system, not including core hooks and preprocess / theme functions.

Code

function advanced_forum_is_styled($content, $teaser = FALSE, $type = 'node') {

  // This is the ID of the topic starting node.
  static $master_topic_id;

  // Give other modules a first crack at making the decision. To keep this
  // simple, he last one in the array wins.
  $topic_ids = module_invoke_all('advanced_forum_is_styled_alter', $content, $teaser, $type);
  $topic_id = end($topic_ids);
  if (!$topic_id) {

    // If no other modules made a decision on this, we look at it.
    switch ($type) {
      case 'node':

        // See if the node should be styled.
        $topic_id = advanced_forum_node_is_styled($content, $teaser);
        break;
      case 'comment':
        $topic_id = advanced_forum_comment_is_styled($content, $master_topic_id);
        break;
      case 'comment-wrapper':
        if ($content->nid == $master_topic_id) {

          // Use our comment wrapper only if we are on a styled node.
          $topic_id = $master_topic_id;
        }
        break;
    }
  }
  if ($topic_id > 0) {

    // If we have a positive number for the topic ID, then this item is styled.
    // We need to update the master ID, add the CSS/JS files, and tell the caller
    // our decision.
    $master_topic_id = $topic_id;
    _advanced_forum_add_files();
    return TRUE;
  }
  elseif ($topic_id == -42) {

    // A -42 means all the tests passed but the node is being previewed so there
    // is no node id, yet. Add the files and return true but don't update the
    // master topic ID.
    _advanced_forum_add_files();
    return TRUE;
  }
}