You are here

function _exclude_node_title in Exclude Node Title 7

Determine whether the node title should be excluded.

Parameters

object $param: Contains the node object.

string $view_mode: The view mode, e.g. 'full' or 'teaser'.

Return value

bool Returns TRUE if the title should be hidden, otherwise returns FALSE.

4 calls to _exclude_node_title()
exclude_node_title in ./exclude_node_title.module
Determine whether a user has privilege and whether to exclude the node title.
exclude_node_title_form_alter in ./exclude_node_title.module
Implements hook_form_alter().
_exclude_node_title_ds_render_field in ./exclude_node_title.module
Render the field obeying exclude node title settings.
_exclude_node_title_preprocess in ./exclude_node_title.module
Remove the title from the variables array.

File

./exclude_node_title.module, line 269
Primarily Drupal hooks and global API functions to exclude node titles.

Code

function _exclude_node_title($param, $view_mode = 'full') {
  if (!($node_info = _exclude_node_title_get_node($param))) {
    return FALSE;
  }

  // Get exclude settings.
  static $exclude_settings;
  if (!isset($exclude_settings)) {
    foreach (_node_types_build()->names as $key => $val) {
      $exclude_settings[$key] = array(
        'type' => variable_get('exclude_node_title_content_type_value_' . $key, 'none'),
        'modes' => variable_get('exclude_node_title_content_type_modes_' . $key, array()),
      );
    }
  }
  if (!isset($exclude_settings[$node_info['node_type']]['type'])) {
    return FALSE;
  }
  switch ($exclude_settings[$node_info['node_type']]['type']) {
    case 'all':
      return !empty($exclude_settings[$node_info['node_type']]['modes'][$view_mode]);
    case 'user':
      if (!$node_info['nid']) {
        return FALSE;
      }

      // Prepare a list of the node IDs to be excluded.
      $nid_exclude_list = variable_get('exclude_node_title_nid_list', array());
      $nid_list = array(
        $node_info['nid'] => $node_info['nid'],
      );
      if (module_exists('translation') && variable_get('exclude_node_title_translation_sync', TRUE) == TRUE && translation_supported_type($node_info['node_type'])) {

        // Get the translation source node ID.
        $tnid = db_select('node', 'n')
          ->fields('n', array(
          'tnid',
        ))
          ->condition('nid', $node_info['nid'])
          ->execute()
          ->fetchAssoc();
        $tlist = translation_node_get_translations($tnid['tnid']);
        if (is_array($tlist)) {
          foreach ($tlist as $tlang => $tnode) {
            $nid_list[$tnode->nid] = $tnode->nid;
          }
        }
      }
      foreach ($nid_list as $item_nid) {
        if (in_array($item_nid, $nid_exclude_list)) {
          return !empty($exclude_settings[$node_info['node_type']]['modes'][$view_mode]);
        }
      }
      return FALSE;
    case 'none':
    default:
      return FALSE;
  }
}