View source
<?php
include_once 'enterprise_base.features.inc';
function enterprise_base_menu_alter(&$items) {
$items['admin/people/create']['page callback'] = 'user_admin';
$items['admin/people/create']['file'] = 'user.admin.inc';
}
function enterprise_base_update_projects_alter(&$projects) {
}
function enterprise_base_entity_info_alter(&$entity_info) {
$entity_info['taxonomy_term']['uri callback'] = 'enterprise_base_taxonomy_term_uri';
}
function enterprise_base_taxonomy_term_uri($term) {
$url = array(
'path' => 'taxonomy/term/' . $term->tid,
);
drupal_alter($term->vocabulary_machine_name . '_uri', $url, $term);
return $url;
}
function enterprise_base_create_machine_name($string, $replacement = '_') {
return preg_replace('/[^a-z0-9]+/', $replacement, strtolower($string));
}
function enterprise_base_menu_local_tasks_alter(&$data, $router_item, $root_path) {
global $user;
$active_type = FALSE;
if (arg(0) != 'admin' && isset($router_item['page_callback']) && $router_item['page_callback'] == 'views_page') {
$view = views_get_view($router_item['page_arguments'][0]);
$tfilter = FALSE;
if (isset($view->display['default']->display_options['filters']['type'])) {
$tfilter = $view->display['default']->display_options['filters']['type'];
}
$display = $router_item['page_arguments'][1];
if (is_array($display)) {
$display = array_shift($display);
}
if (isset($view->display[$display]->display_options['filters']['type'])) {
$tfilter = $view->display[$display]->display_options['filters']['type'];
}
if ($tfilter) {
if ($tfilter['table'] == 'node') {
if (!isset($tfilter['operator']) || $tfilter['operator'] == 'in') {
$active_type = array_shift($tfilter['value']);
}
}
}
}
if ($root_path == 'nodes' || $root_path == 'node') {
$active_type = arg(1);
}
if ($user->uid > 0 && $root_path == 'node/%') {
$node = node_load(arg(1));
$active_type = $node->type;
}
if ($active_type) {
$type = node_type_load($active_type);
if (!isset($type->name)) {
return;
}
$content_name = strtolower($type->name);
$item = menu_get_item('node/add/' . str_replace('_', '-', $active_type));
if ($item['access']) {
$item['title'] = t('Add @type_name', array(
'@type_name' => strtolower($content_name),
));
$item['localized_options'] = array(
'html' => TRUE,
'attributes' => array(
'class' => array(
'btn',
'btn-small',
),
),
);
$data['actions']['output'][] = array(
'#theme' => 'menu_local_action',
'#link' => $item,
);
}
$href = 'admin/content/node/' . $active_type;
$item = menu_get_item($href);
if ($item['access']) {
$item['href'] = $href;
$item['title'] = t('Manage @type_name', array(
'@type_name' => $content_name . 's',
));
$item['localized_options'] = array(
'html' => TRUE,
'attributes' => array(
'class' => array(
'btn',
'btn-small',
),
),
);
$data['actions']['output'][] = array(
'#theme' => 'menu_local_action',
'#link' => $item,
);
}
}
if ($root_path == 'admin/content' || strpos($root_path, 'admin/content/node') === 0) {
drupal_add_css(drupal_get_path('module', 'enterprise_base') . '/enterprise_base.content_admin.css');
$custom_view = $root_path != 'admin/content' ? TRUE : FALSE;
$active_type = arg(3);
if (isset($active_type)) {
unset($data['actions']['output'][0]);
}
$types = node_type_get_names();
if (isset($active_type) && $active_type) {
$type_name = strtolower($types[$active_type]);
$item = menu_get_item('node/add/' . str_replace('_', '-', $active_type));
$item['title'] = t('Add @type_name', array(
'@type_name' => $type_name,
));
$data['actions']['output'][] = array(
'#theme' => 'menu_local_action',
'#link' => $item,
);
}
$href = 'admin/content/node';
$item = menu_get_item($href);
if ($item['access']) {
$item['href'] = $href;
$item['title'] = ' ' . t('All');
$output = array(
'#theme' => 'menu_local_task',
'#link' => $item,
);
if (!isset($active_type)) {
$output['#active'] = TRUE;
}
$data['tabs'][1]['output'][] = $output;
}
$count = count($types) + 1;
$data['tabs'][1]['count'] = $count;
$i = 0;
foreach ($types as $type => $name) {
$href = 'admin/content/node/' . $type;
$item = menu_get_item($href);
if ($item['path'] != 'admin/content/node') {
continue;
}
if ($item['access']) {
$item['href'] = $href;
$item['title'] = $name;
$output = array(
'#theme' => 'menu_local_task',
'#link' => $item,
);
if ($type == $active_type) {
$output['#active'] = TRUE;
}
$data['tabs'][1]['output'][] = $output;
}
$i++;
}
usort($data['tabs'][1]['output'], '_enterprise_base_content_sort_tabs');
}
}
function _enterprise_base_content_sort_tabs($a, $b) {
return strnatcmp($a['#link']['title'], $b['#link']['title']);
}
function enterprise_base_form_alter(&$form, &$form_state, $form_id) {
if ($form_id == 'field_ui_field_edit_form') {
$options = array(
'' => t('Standard'),
'sidebar' => t('Sidebar'),
);
$field_name = $form['#field']['field_name'];
$default = '';
if (isset($form_state['build_info']['args'][0]['enterprise_edit_form_display'])) {
$default = $form_state['build_info']['args'][0]['enterprise_edit_form_display'];
}
$form['instance']['enterprise_edit_form_display'] = array(
'#type' => 'radios',
'#title' => t('Edit form display location'),
'#description' => t('Select where you want this field to display on the edit form. Sidebar is recommended for meta data.'),
'#default_value' => $default,
'#options' => $options,
);
}
elseif (isset($form['#node_edit_form'])) {
$theme = variable_get('admin_theme', 'bartik');
$node_admin = variable_get('node_admin_theme', 'bartik');
if ($theme != 'rubik' || !$node_admin) {
return;
}
drupal_add_js(drupal_get_path('module', 'enterprise_base') . '/js/enterprise_base.edit_form.js');
drupal_add_css(drupal_get_path('module', 'enterprise_base') . '/css/enterprise_base.edit_form.css');
if (isset($form_state['field']) && is_array($form_state['field'])) {
foreach ($form_state['field'] as $name => $field) {
if (!isset($field[LANGUAGE_NONE]['instance'])) {
continue;
}
$field[LANGUAGE_NONE]['instance'] += array(
'enterprise_edit_form_display' => '',
);
$display = $field[LANGUAGE_NONE]['instance']['enterprise_edit_form_display'];
if ($display == 'sidebar') {
$form[$name]['#attributes']['class'][] = 'display_sidebar';
if (isset($form[$name][LANGUAGE_NONE]['#type']) && in_array($form[$name][LANGUAGE_NONE]['#type'], array(
'checkboxes',
'radios',
))) {
$form[$name][LANGUAGE_NONE]['#attributes']['class'][] = 'scrollable';
}
}
$fdata = $form_state['field'][$name][LANGUAGE_NONE];
if ($fdata['field']['type'] == 'taxonomy_term_reference' && $fdata['instance']['widget']['type'] == 'options_buttons') {
$vocab_name = $fdata['field']['settings']['allowed_values'][0]['vocabulary'];
$item = menu_get_item("admin/structure/taxonomy/{$vocab_name}/add");
if ($item['access']) {
$form[$name][LANGUAGE_NONE]['#attributes']['class'][] = 'with-action-links';
$form[$name][LANGUAGE_NONE]['#field_suffix'] = '<ul class="action-linksx"><li>' . l('+ ' . t('Add term'), "admin/structure/taxonomy/{$vocab_name}/add", array(
'html' => TRUE,
'attributes' => array(
'target' => "_blank",
'class' => array(
'add-term-link',
),
),
)) . '</li></ul>';
}
}
}
}
if (isset($form['scheduler_settings'])) {
unset($form['scheduler_settings']['#group']);
unset($form['scheduler_settings']['#attached']);
$form['scheduler_settings']['#title'] = $form['scheduler_settings']['publish_on']['#title'];
unset($form['scheduler_settings']['publish_on']['#title']);
$form['scheduler_settings']['#attributes']['class'][] = 'display_sidebar';
$form['scheduler_settings']['#weight'] = -10;
}
if (isset($form['metatags'])) {
$form['metatags']['#weight'] = -20;
}
}
}
function enterprise_base_fivestar_widgets() {
$widgets = array(
drupal_get_path('module', 'enterprise_base') . '/css/oe_stars.css' => 'oe_stars',
);
return $widgets;
}