8ac59801be
Update commons modules to release 7.12, and move the codebase under modules/commons instead of constant fetching from remote repository. The commons.make file removed so it is not required to rebuild groups distribution. Change-Id: I3be393ba1af34427e2915b18ab1ad718fd4e54db
98 lines
2.8 KiB
Plaintext
98 lines
2.8 KiB
Plaintext
<?php
|
|
/**
|
|
* @file
|
|
* Code for the Commons Documents feature.
|
|
*/
|
|
|
|
include_once 'commons_documents.features.inc';
|
|
|
|
/**
|
|
* Implements hook_commons_entity_integration().
|
|
*/
|
|
function commons_documents_commons_entity_integration() {
|
|
return array(
|
|
'node' => array(
|
|
'document' => array(
|
|
'is_group_content' => TRUE,
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Implements hook_commons_bw_group_widget().
|
|
*/
|
|
function commons_documents_commons_bw_group_widget() {
|
|
return array(
|
|
'commons_documents' => array(
|
|
'title' => t('Docs'),
|
|
'type' => 'view',
|
|
'vid' => 'commons_bw_documents',
|
|
'display' => 'default',
|
|
'weight' => 6,
|
|
'bundle' => 'document',
|
|
),
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Implements hook_form_FROM_ID_alter().
|
|
*/
|
|
function commons_documents_form_commons_bw_partial_node_form_alter(&$form, &$form_state) {
|
|
if (empty($form['#entity']) || $form['#entity']->type != 'document') {
|
|
return;
|
|
}
|
|
|
|
$language = $form['body']['#language'];
|
|
$form['body'][$language][0]['#title_display'] = 'invisible';
|
|
$form['body'][$language][0]['#required'] = TRUE;
|
|
$form['body'][$language][0]['#placeholder'] = t('Describe the document');
|
|
$form['body'][$language][0]['#resizable'] = FALSE;
|
|
|
|
// Set fields as hideable so the forms can be compacted.
|
|
$form['body']['#attributes']['class'][] = 'trigger-field';
|
|
foreach (array('field_image', 'og_group_ref', 'field_document_file', 'actions') as $field) {
|
|
if (isset($form[$field])) {
|
|
$form[$field]['#attributes']['class'][] = 'hideable-field';
|
|
}
|
|
}
|
|
|
|
$form['#pre_render'][] = 'commons_documents_form_commons_bw_partial_node_form_after_build';
|
|
}
|
|
|
|
/**
|
|
* After-build call-back.
|
|
* See commons_documents_form_commons_bw_partial_node_form_alter().
|
|
*/
|
|
function commons_documents_form_commons_bw_partial_node_form_after_build($form) {
|
|
$language = $form['body']['#language'];
|
|
$form['body'][$language][0]['#pre_render'] = array();
|
|
$form['body'][$language][0]['format']['#access'] = FALSE;
|
|
$form['body'][$language][0]['value']['#rows'] = 3;
|
|
|
|
return $form;
|
|
}
|
|
|
|
/**
|
|
* Implements hook_views_default_views_alter().
|
|
*
|
|
* Display documents on the browsing widget main view.
|
|
*/
|
|
function commons_documents_views_default_views_alter(&$views) {
|
|
if (!empty($views['commons_bw_all'])) {
|
|
$views['commons_bw_all']->display['default']->display_options['filters']['type']['value']['document'] = 'document';
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Implements hook_views_pre_render().
|
|
*/
|
|
function commons_documents_views_pre_render(&$view) {
|
|
// Improve the browsing widget empty text when displayed outside of a group.
|
|
// TODO: Enable og_context and check group context instead of looking for an
|
|
// empty first argument.
|
|
if (empty($view->args[0]) && $view->name == 'commons_bw_documents') {
|
|
$view->display_handler->handlers['empty']['area']->options['content'] = t('No documents have been created.');
|
|
}
|
|
}
|