commons_topics.module in Drupal Commons 7.3
File
modules/commons/commons_topics/commons_topics.module
View source
<?php
include_once 'commons_topics.features.inc';
function commons_topics_system_info_alter(&$info, $file, $type) {
if ($file->name == 'commons_topics') {
$commons_topics_entity_types = commons_topics_get_entity_types_with_topics();
if (!empty($commons_topics_entity_types)) {
foreach ($commons_topics_entity_types as $entity_type => $bundles) {
foreach (array_keys($bundles) as $bundle) {
$info['features']['field_instance'][] = "{$entity_type}-{$bundle}-field_topics";
}
}
}
}
}
function commons_topics_form_node_form_alter(&$form, &$form_state) {
if (isset($form['field_topics'])) {
$form['topics_wrapper'] = array(
'#type' => 'fieldset',
'#title' => t('Topics'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
'#group' => 'additional_settings',
'#weight' => -15,
);
$form['topics_wrapper']['field_topics'] = $form['field_topics'];
$form['field_topics'] = array(
'#language' => NULL,
);
$form['#attached']['js'][] = drupal_get_path('module', 'commons_topics') . '/js/commons_topics.js';
}
}
function commons_topics_get_entity_types_with_topics() {
$commons_entity_integrations = commons_entity_integration_info();
if (empty($commons_entity_integrations)) {
return array();
}
foreach ($commons_entity_integrations as $entity_type => $integration) {
foreach ($integration as $bundle => $options) {
if (isset($options['exclude_topics']) && $options['exclude_topics'] == TRUE) {
unset($commons_entity_integrations[$entity_type][$bundle]);
}
}
if (empty($commons_entity_integrations[$entity_type])) {
unset($commons_entity_integrations[$entity_type]);
}
}
return $commons_entity_integrations;
}