Skip to content
Snippets Groups Projects
Commit 9b7e4a44 authored by Eric Rasmussen's avatar Eric Rasmussen
Browse files

[gh-152] Merging testing into staging -c758

git-svn-id: file:///tmp/wdn_thm_drupal/branches/drupal-7.x/staging@839 20a16fea-79d4-4915-8869-1ea9d5ebf173
parent edbed235
No related branches found
No related tags found
No related merge requests found
......@@ -274,7 +274,89 @@ function unl_file_validate($file) {
return;
}
function unl_form_alter(&$form, $form_state, $form_id) {
/**
* Implementation of hook_form_BASE_FORM_ID_alter().
*/
function unl_form_node_form_alter(&$form, &$form_state, $form_id) {
/**
* On the node edit form, hide the "Provide a menu link" checkbox since we'll
* be using the menu to build a site hierarchy. Instead, add a button that will
* determine whether or not the menu link is visible or not.
*/
$form['menu']['#title'] = 'Site hierachy';
$form['menu']['enabled']['#default_value'] = TRUE;
$form['menu']['enabled']['#prefix'] = '<div style="display: none;">';
$form['menu']['enabled']['#suffix'] = '</div>';
$form['menu']['link']['link_title']['#required'] = TRUE;
$mlid = $form['menu']['link']['mlid']['#value'];
if ($mlid) {
$menu_link = menu_link_load($mlid);
$default_visible = ($menu_link['hidden'] ? 0 : 1);
}
else {
$default_visible = 0;
}
$form['menu']['visible'] = array(
'#type' => 'checkbox',
'#title' => 'Display in menu',
'#default_value' => $default_visible,
'#weight' => 0,
);
$form['actions']['submit']['#submit'][] = 'unl_node_form_submit';
// Also turn on revisioning by default
$form['revision_information']['revision']['#default_value'] = TRUE;
unset($form['revision_information']['revision']['#states']);
// Also hide the "Promoted to front page" option
$form['options']['promote']['#prefix'] = '<div style="display:none;">';
$form['options']['promote']['#suffix'] = '</div>';
// Also hide the "Sticky at top of lists" option
$form['options']['sticky']['#prefix'] = '<div style="display:none;">';
$form['options']['sticky']['#suffix'] = '</div>';
/*
* Add user-added menus to the Parent Item select box since sub-sites do not have access to edit Available Menus of shared/features Content types.
* @see menu_form_node_form_alter() for what this is replacing
*/
$type = $form['#node']->type;
// Get the menus selected in Available Menus from the Content Type edit form (admin/structure/types/manage/%)
$options = menu_parent_options(menu_get_menus(), $type);
// This line below is the addition to what menu_form_node_form_alter() does. Get only user-added menus and use them in their entirety.
$options_custom = menu_parent_options(menu_get_menus(FALSE), array('mlid' => 0));
$link = $form['#node']->menu;
$default = ($link['mlid'] ? $link['menu_name'] . ':' . $link['plid'] : variable_get('menu_parent_' . $type, 'main-menu:0'));
if (!isset($options[$default])) {
$default = 'navigation:0';
}
$form['menu']['link']['parent'] = array(
'#type' => 'select',
'#title' => t('Parent item'),
'#default_value' => $default,
'#options' => array_merge($options, $options_custom),
'#attributes' => array('class' => array('menu-parent-select')),
);
}
/**
* Implementation of hook_form_FORM_ID_alter() for field_ui_display_overview_form.
*/
function unl_form_field_ui_display_overview_form_alter(&$form, &$form_state, $form_id) {
// Add additional label display options in Manage Display section of content type editing (admin/structure/types/manage/content-type/display)
foreach ($form['#fields'] as $key => $field) {
$form['fields'][$field]['label']['#options'] += array('h2'=>'Block: h2','h3'=>'Block: h3','h4'=>'Block: h4','h5'=>'Block: h5','h6'=>'Block: h6');
}
}
/**
* Implementation of hook_form_alter().
*/
function unl_form_alter(&$form, &$form_state, $form_id) {
// Make new menu items expanded by default.
if ($form_id == 'menu_edit_item' && $form['mlid']['#value'] == 0) {
$form['expanded']['#default_value'] = TRUE;
......
<?php
/**
* @file field.tpl.php
* unl_wdn template implementation to display the value of a field.
*
* Available variables:
* - $items: An array of field values. Use render() to output them.
* - $label: The item label.
* - $label_hidden: Whether the label display is set to 'hidden'.
* - $label_html_tag: The html tag to use for the label, h2, h3, div, etc.
* - $classes: String of classes that can be used to style contextually through
* CSS. It can be manipulated through the variable $classes_array from
* preprocess functions. The default values can be one or more of the
* following:
* - field: The current template type, i.e., "theming hook".
* - field-name-[field_name]: The current field name. For example, if the
* field name is "field_description" it would result in
* "field-name-field-description".
* - field-type-[field_type]: The current field type. For example, if the
* field type is "text" it would result in "field-type-text".
* - field-label-[label_display]: The current label position. For example, if
* the label position is "above" it would result in "field-label-above".
*
* Other variables:
* - $element['#object']: The entity to which the field is attached.
* - $element['#view_mode']: View mode, e.g. 'full', 'teaser'...
* - $element['#field_name']: The field name.
* - $element['#field_type']: The field type.
* - $element['#field_language']: The field language.
* - $element['#field_translatable']: Whether the field is translatable or not.
* - $element['#label_display']: Position of label display, inline, above, or
* hidden.
* - $field_name_css: The css-compatible field name.
* - $field_type_css: The css-compatible field type.
* - $classes_array: Array of html class attribute values. It is flattened
* into a string within the variable $classes.
*
* @see template_preprocess_field()
* @see theme_field()
*/
?>
<div class="<?php print $classes; ?> clearfix"<?php print $attributes; ?>>
<?php if (!$label_hidden) : ?>
<<?php print $label_html_tag; ?> class="field-label"<?php print $title_attributes; ?>><?php print $label ?>:&nbsp;</<?php print $label_html_tag; ?>>
<?php endif; ?>
<div class="field-items"<?php print $content_attributes; ?>>
<?php foreach ($items as $delta => $item) : ?>
<div class="field-item <?php print $delta % 2 ? 'odd' : 'even'; ?>"<?php print $item_attributes[$delta]; ?>><?php print render($item); ?></div>
<?php endforeach; ?>
</div>
</div>
......@@ -11,6 +11,23 @@ function unl_wdn_css_alter(&$css) {
unset($css[$path.'/system.theme.css']);
}
/**
* Implements template_preprocess_field().
*/
function unl_wdn_preprocess_field(&$vars, $hook) {
$element = $vars['element'];
// Set the field label tag to a header or default to div
if (strlen($element['#label_display']) == 2 && substr($element['#label_display'], 0, 1) == 'h') {
$vars['label_html_tag'] = $element['#label_display'];
}
else {
$vars['label_html_tag'] = 'div';
}
}
/**
* Implements template_preprocess_html().
*/
function unl_wdn_preprocess_html(&$vars, $hook) {
/**
* Change the <title> tag to UNL format: UNL | Department | Section | Page
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment