2015-02-26 17:51:27 +01:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* @file
|
2015-02-26 20:28:05 +01:00
|
|
|
* Farm theme template.php
|
2015-02-26 17:51:27 +01:00
|
|
|
*/
|
2015-02-26 20:28:05 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Implements hook_form_alter().
|
|
|
|
*/
|
|
|
|
function farm_theme_form_alter(&$form, &$form_state, $form_id) {
|
|
|
|
|
2015-03-12 16:44:45 +01:00
|
|
|
// Views Exposed (filters and sort) form:
|
2015-02-26 20:28:05 +01:00
|
|
|
if ($form_id == 'views_exposed_form') {
|
|
|
|
|
|
|
|
/**
|
2015-03-12 16:44:45 +01:00
|
|
|
* Wrap the exposed form in a Bootstrap collapsed panel.
|
2015-02-26 20:28:05 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
// Form prefix HTML:
|
|
|
|
$form['#prefix'] = '
|
|
|
|
<div class="panel panel-default">
|
2015-03-19 22:56:57 +01:00
|
|
|
<div class="panel-heading" role="tab" id="' . $form['#id'] . '-panel-heading">
|
2015-02-26 20:28:05 +01:00
|
|
|
<h4 class="panel-title">
|
2015-03-19 22:56:57 +01:00
|
|
|
<a class="collapsed" data-toggle="collapse" href="#' . $form['#id'] . '-panel-body" aria-expanded="false" aria-controls="' . $form['#id'] . '-panel-body">
|
2015-02-26 20:28:05 +01:00
|
|
|
Filter/Sort
|
|
|
|
</a>
|
|
|
|
</h4>
|
|
|
|
</div>
|
2015-03-19 22:56:57 +01:00
|
|
|
<div id="' . $form['#id'] . '-panel-body" class="panel-collapse collapse" role="tabpanel" aria-labelledby="' . $form['#id'] . '-panel-heading" aria-expanded="false" style="height: 0px;">
|
2015-02-26 20:28:05 +01:00
|
|
|
<div class="panel-body">';
|
|
|
|
|
|
|
|
// Form suffix HTML:
|
|
|
|
$form['#suffix'] = '
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>';
|
|
|
|
}
|
2015-02-26 20:28:27 +01:00
|
|
|
|
2015-03-12 16:44:45 +01:00
|
|
|
// Views Bulk Operations form:
|
2015-02-26 20:28:27 +01:00
|
|
|
else if (strpos($form_id, 'views_form_') === 0 && !empty($form['select'])) {
|
2015-03-12 16:44:45 +01:00
|
|
|
|
|
|
|
// Add some JavaScript to hide the VBO buttons until items are selected.
|
|
|
|
drupal_add_js(drupal_get_path('theme', 'farm_theme') . '/js/vbo.js');
|
|
|
|
|
|
|
|
// Move VBO buttons to the bottom.
|
2015-02-26 20:28:27 +01:00
|
|
|
$form['select']['#weight'] = 100;
|
|
|
|
}
|
2015-02-26 20:28:05 +01:00
|
|
|
}
|
2015-03-21 15:02:53 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Implements hook_entity_view_alter().
|
|
|
|
*/
|
|
|
|
function farm_theme_entity_view_alter(&$build, $type) {
|
|
|
|
|
|
|
|
// If the entity is not a farm_asset, bail.
|
|
|
|
if ($type != 'farm_asset') {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If there is a farm images field, float it in the top left.
|
|
|
|
if (!empty($build['field_farm_images'])) {
|
|
|
|
|
|
|
|
// Wrap it in a floated div.
|
|
|
|
$build['field_farm_images']['#prefix'] = '<div class="col-md-6">';
|
|
|
|
$build['field_farm_images']['#suffix'] = '</div>';
|
|
|
|
|
|
|
|
// Put everything else into another div and move it to the top so it
|
|
|
|
// aligns left.
|
|
|
|
$build['fields'] = array(
|
|
|
|
'#prefix' => '<div class="col-md-6">',
|
|
|
|
'#suffix' => '</div>',
|
|
|
|
'#weight' => -100,
|
|
|
|
);
|
|
|
|
$elements = element_children($build);
|
|
|
|
foreach ($elements as $element) {
|
|
|
|
if (!in_array($element, array('field_farm_images', 'fields'))) {
|
|
|
|
$build['fields'][$element] = $build[$element];
|
|
|
|
unset($build[$element]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-03-21 15:03:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Implements hook_preprocess_page().
|
|
|
|
*/
|
|
|
|
function farm_theme_preprocess_page(&$vars) {
|
|
|
|
|
|
|
|
// Remove from taxonomy term pages:
|
|
|
|
// "There is currently no content classified with this term."
|
|
|
|
if (isset($vars['page']['content']['system_main']['no_content'])) {
|
|
|
|
unset($vars['page']['content']['system_main']['no_content']);
|
|
|
|
}
|
2015-03-27 16:15:47 +01:00
|
|
|
|
|
|
|
// Add "Powered by farmOS" to the footer.
|
|
|
|
$vars['page']['footer'][] = array(
|
|
|
|
'#type' => 'markup',
|
|
|
|
'#markup' => '<div style="text-align: center;"><small>' . t('Powered by') . ' ' . l('farmOS', 'http://farmos.org') . '</small></div>',
|
|
|
|
);
|
|
|
|
}
|