You are here

function advanced_forum_is_styled in Advanced Forum 6.2

Same name and namespace in other branches
  1. 7.2 includes/style.inc \advanced_forum_is_styled()
5 calls to advanced_forum_is_styled()
advanced_forum_link in ./advanced_forum.module
Implementation of hook_link().
advanced_forum_link_alter in ./advanced_forum.module
Implementation of hook_link_alter().
advanced_forum_preprocess_comment in includes/theme.inc
Preprocesses template variables for the comment template.
advanced_forum_preprocess_comment_wrapper in includes/theme.inc
advanced_forum_preprocess_node in includes/theme.inc
Preprocesses template variables for the node template.

File

includes/style.inc, line 139
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, the 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':
        if (!empty($content->comment_target_nid) && $content->comment_target_nid == $master_topic_id) {

          // This nodecomment is attached to a node we already know is styled.
          $topic_id = $master_topic_id;
        }
        else {

          // 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;
  }
}