-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[gh-247] Merging test into staging -c1173
git-svn-id: file:///tmp/wdn_thm_drupal/branches/drupal-7.x/staging@1273 20a16fea-79d4-4915-8869-1ea9d5ebf173
- Loading branch information
Eric Rasmussen
committed
Nov 8, 2011
1 parent
7c3eeab
commit abd2ba0
Showing
4 changed files
with
280 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,129 +1,162 @@ | ||
<?php | ||
|
||
function unl_wdn_form($variables) | ||
{ | ||
if (!theme_get_setting('zen_forms')) { | ||
return theme_form($variables); | ||
} | ||
/** | ||
* @file | ||
* Hooks to support UNL_WDN zenform styling and markup | ||
*/ | ||
|
||
$output = <<<EOF | ||
/** | ||
* Implements theme_form(). | ||
*/ | ||
function unl_wdn_form($variables) { | ||
$output = <<<EOF | ||
<script type="text/javascript"> | ||
//<![CDATA[ | ||
WDN.jQuery(document).ready(function(){ | ||
WDN.initializePlugin('zenform'); | ||
}); | ||
//]]> | ||
// <![CDATA[ | ||
WDN.jQuery(document).ready(function(){WDN.initializePlugin('zenform');}); | ||
// ]]> | ||
</script> | ||
EOF; | ||
|
||
$element = $variables['element']; | ||
$element['#attributes']['class'][] = 'zenform'; | ||
$action = $element['#action'] ? 'action="' . check_url($element['#action']) . '" ' : ''; | ||
$output .= PHP_EOL . '<!-- FORM STARTS HERE -->' . PHP_EOL . PHP_EOL; | ||
$output .= '<form ' . $action . ' accept-charset="UTF-8" method="' . $element['#method'] . '" id="' . $element['#id'] . '"' . drupal_attributes($element['#attributes']) . ">\n" . $element['#children'] . "\n</form>\n"; | ||
$output .= PHP_EOL . PHP_EOL . '<!-- FORM ENDS HERE -->' . PHP_EOL; | ||
return $output; | ||
} | ||
|
||
function unl_wdn_fieldset($variables) | ||
{ | ||
if (!theme_get_setting('zen_forms')) { | ||
return theme_fieldset($variables); | ||
} | ||
|
||
$element = $variables['element']; | ||
|
||
$output = '<fieldset' . drupal_attributes($element['#attributes']) . '>'; | ||
if (!empty($element['#title'])) { | ||
// Always wrap fieldset legends in a SPAN for CSS positioning. | ||
$output .= '<legend>' . $element['#title'] . '</legend>'; | ||
} | ||
if (!empty($element['#description'])) { | ||
$output .= '<div>' . $element['#description'] . '</div>'; | ||
} | ||
$output .= '<ol>' . $element['#children'] . '</ol>'; | ||
if (isset($element['#value'])) { | ||
$output .= $element['#value']; | ||
} | ||
$output .= "</fieldset>\n"; | ||
return $output; | ||
$element = $variables['element']; | ||
$element['#attributes']['class'][] = 'zenform'; | ||
$action = $element['#action'] ? 'action="' . check_url($element['#action']) . '" ' : ''; | ||
$output .= PHP_EOL . '<!-- FORM STARTS HERE -->' . PHP_EOL . PHP_EOL; | ||
$output .= '<form ' . $action . ' accept-charset="UTF-8" method="' . $element['#method'] . '" id="' . $element['#id'] . '"' . drupal_attributes($element['#attributes']) . ">\n" . $element['#children'] . "\n</form>\n"; | ||
$output .= PHP_EOL . PHP_EOL . '<!-- FORM ENDS HERE -->' . PHP_EOL; | ||
return $output; | ||
} | ||
|
||
function unl_wdn_form_element($variables) | ||
{ | ||
if (!theme_get_setting('zen_forms')) { | ||
return theme_form_element($variables); | ||
} | ||
|
||
$element = $variables['element']; | ||
// This is also used in the installer, pre-database setup. | ||
$t = get_t(); | ||
|
||
// Add element #id for #type 'item'. | ||
if (isset($element['#markup']) && !empty($element['#id'])) { | ||
$attributes['id'] = $element['#id']; | ||
} | ||
// Add element's #type and #name as class to aid with JS/CSS selectors. | ||
$attributes['class'] = array(); | ||
$output = '<li' . drupal_attributes($attributes) . '>' . "\n"; | ||
|
||
// If #title is not set, we don't display any label or required marker. | ||
if (!isset($element['#title'])) { | ||
$element['#title_display'] = 'none'; | ||
} | ||
$prefix = isset($element['#field_prefix']) ? '<span class="field-prefix">' . $element['#field_prefix'] . '</span> ' : ''; | ||
$suffix = isset($element['#field_suffix']) ? ' <span class="field-suffix">' . $element['#field_suffix'] . '</span>' : ''; | ||
|
||
switch ($element['#title_display']) { | ||
case 'before': | ||
$output .= ' ' . theme('form_element_label', $variables); | ||
$output .= ' ' . $prefix . $element['#children'] . $suffix . "\n"; | ||
break; | ||
|
||
case 'invisible': | ||
case 'after': | ||
$output .= ' ' . $prefix . $element['#children'] . $suffix; | ||
$output .= ' ' . theme('form_element_label', $variables) . "\n"; | ||
break; | ||
|
||
case 'none': | ||
case 'attribute': | ||
// Output no label and no required marker, only the children. | ||
$output .= ' ' . $prefix . $element['#children'] . $suffix . "\n"; | ||
break; | ||
} | ||
|
||
/** | ||
* Implements theme_fieldset(). | ||
*/ | ||
function unl_wdn_fieldset($variables) { | ||
$element = $variables['element']; | ||
|
||
if (count($element['#parents']) > 2) { | ||
$output = '<li>'; | ||
} | ||
else { | ||
$output = ''; | ||
} | ||
|
||
$output .= '<fieldset' . drupal_attributes($element['#attributes']) . '>'; | ||
if (!empty($element['#title'])) { | ||
// Always wrap fieldset legends in a SPAN for CSS positioning. | ||
$output .= '<legend>' . $element['#title'] . '</legend>'; | ||
} | ||
if (!empty($element['#description'])) { | ||
$output .= '<div>' . $element['#description'] . '</div>'; | ||
} | ||
$output .= '<ol>' . $element['#children'] . '</ol>'; | ||
if (isset($element['#value'])) { | ||
$output .= $element['#value']; | ||
} | ||
$output .= "</fieldset>\n"; | ||
if (count($element['#parents']) > 2) { | ||
$output .= "</li>\n"; | ||
|
||
return $output; | ||
} | ||
return $output; | ||
} | ||
|
||
/** | ||
* Implements theme_form_element(). | ||
*/ | ||
function unl_wdn_form_element($variables) { | ||
$element = $variables['element']; | ||
// This is also used in the installer, pre-database setup. | ||
$t = get_t(); | ||
|
||
// Add element #id for #type 'item'. | ||
if (isset($element['#markup']) && !empty($element['#id'])) { | ||
$attributes['id'] = $element['#id']; | ||
} | ||
// Add element's #type and #name as class to aid with JS/CSS selectors. | ||
$attributes['class'] = array(); | ||
$output = '<li' . drupal_attributes($attributes) . '>' . "\n"; | ||
|
||
// If #title is not set, we don't display any label or required marker. | ||
if (!isset($element['#title'])) { | ||
$element['#title_display'] = 'none'; | ||
} | ||
$prefix = isset($element['#field_prefix']) ? '<span class="field-prefix">' . $element['#field_prefix'] . '</span> ' : ''; | ||
$suffix = isset($element['#field_suffix']) ? ' <span class="field-suffix">' . $element['#field_suffix'] . '</span>' : ''; | ||
|
||
switch ($element['#title_display']) { | ||
case 'before': | ||
$output .= ' ' . theme('form_element_label', $variables); | ||
$output .= ' ' . $prefix . $element['#children'] . $suffix . "\n"; | ||
break; | ||
|
||
case 'invisible': | ||
case 'after': | ||
$output .= ' ' . $prefix . $element['#children'] . $suffix; | ||
$output .= ' ' . theme('form_element_label', $variables) . "\n"; | ||
break; | ||
|
||
case 'none': | ||
case 'attribute': | ||
// Output no label and no required marker, only the children. | ||
$output .= ' ' . $prefix . $element['#children'] . $suffix . "\n"; | ||
break; | ||
} | ||
|
||
$output .= "</li>\n"; | ||
|
||
return $output; | ||
} | ||
|
||
/** | ||
* Implements theme_form_element_label(). | ||
*/ | ||
function unl_wdn_form_element_label($variables) { | ||
$element = $variables['element']; | ||
|
||
if (!$element['#title']) { | ||
return ''; | ||
} | ||
|
||
function unl_wdn_form_element_label($variables) | ||
{ | ||
if (!theme_get_setting('zen_forms')) { | ||
return theme_form_element_label($variables); | ||
} | ||
|
||
$element = $variables['element']; | ||
|
||
if (!$element['#title']) { | ||
return ''; | ||
} | ||
|
||
$attributes = array(); | ||
if (!empty($element['#id'])) { | ||
$attributes['for'] = $element['#id']; | ||
} | ||
|
||
$output = '<label ' . drupal_attributes($attributes) . '>' . PHP_EOL | ||
. ($element['#required'] ? '<span class="required">*</span>' . PHP_EOL : '') | ||
. filter_xss_admin($element['#title']) . PHP_EOL | ||
. (isset($element['#description']) ? '<span class="helper">' . $element['#description'] . '</span>' . PHP_EOL : '') | ||
.'</label>' . PHP_EOL; | ||
|
||
return $output; | ||
$attributes = array(); | ||
if (!empty($element['#id'])) { | ||
$attributes['for'] = $element['#id']; | ||
} | ||
|
||
$output = '<label ' . drupal_attributes($attributes) . '>' . PHP_EOL | ||
. ($element['#required'] ? '<span class="required">*</span>' . PHP_EOL : '') | ||
. filter_xss_admin($element['#title']) . PHP_EOL | ||
. (isset($element['#description']) ? '<span class="helper">' . $element['#description'] . '</span>' . PHP_EOL : '') | ||
.'</label>' . PHP_EOL; | ||
|
||
return $output; | ||
} | ||
|
||
/** | ||
* Implements theme_checkboxes(). | ||
*/ | ||
function unl_wdn_checkboxes($variables) { | ||
$element = $variables['element']; | ||
$attributes = array(); | ||
if (isset($element['#id'])) { | ||
$attributes['id'] = $element['#id']; | ||
} | ||
$attributes['class'][] = 'form-checkboxes'; | ||
if (!empty($element['#attributes']['class'])) { | ||
$attributes['class'] = array_merge($attributes['class'], $element['#attributes']['class']); | ||
} | ||
return '<ol ' . drupal_attributes($attributes) . '>' . (!empty($element['#children']) ? $element['#children'] : '') . '</ol>'; | ||
} | ||
|
||
/** | ||
* Implements theme_radios(). | ||
*/ | ||
function unl_wdn_radios($variables) { | ||
$element = $variables['element']; | ||
$attributes = array(); | ||
if (isset($element['#id'])) { | ||
$attributes['id'] = $element['#id']; | ||
} | ||
$attributes['class'] = 'form-radios'; | ||
if (!empty($element['#attributes']['class'])) { | ||
$attributes['class'] .= ' ' . implode(' ', $element['#attributes']['class']); | ||
} | ||
return '<ol ' . drupal_attributes($attributes) . '>' . (!empty($element['#children']) ? $element['#children'] : '') . '</ol>'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
<?php | ||
|
||
/** | ||
* @file | ||
* Hooks to support UNL_WDN zenform styling and markup | ||
*/ | ||
|
||
/** | ||
* Implements theme_webform_element(). | ||
*/ | ||
function unl_wdn_webform_element($variables) { | ||
// Ensure defaults. | ||
$variables['element'] += array( | ||
'#title_display' => 'before', | ||
); | ||
|
||
$element = $variables['element']; | ||
|
||
// All elements using this for display only are given the "display" type. | ||
if (isset($element['#format']) && $element['#format'] == 'html') { | ||
$type = 'display'; | ||
} | ||
else { | ||
$type = (isset($element['#type']) && !in_array($element['#type'], array('markup', 'textfield'))) ? $element['#type'] : $element['#webform_component']['type']; | ||
} | ||
$parents = str_replace('_', '-', implode('--', array_slice($element['#parents'], 1))); | ||
|
||
$wrapper_classes = array( | ||
'form-item', | ||
'webform-component', | ||
'webform-component-' . $type, | ||
); | ||
if (isset($element['#title_display']) && $element['#title_display'] == 'inline') { | ||
$wrapper_classes[] = 'webform-container-inline'; | ||
} | ||
$output = '<li class="' . implode(' ', $wrapper_classes) . '" id="webform-component-' . $parents . '">' . "\n"; | ||
$required = !empty($element['#required']) ? '<span class="form-required" title="' . t('This field is required.') . '">*</span>' : ''; | ||
|
||
// If #title is not set, we don't display any label or required marker. | ||
if (!isset($element['#title'])) { | ||
$element['#title_display'] = 'none'; | ||
} | ||
$prefix = isset($element['#field_prefix']) ? '<span class="field-prefix">' . _webform_filter_xss($element['#field_prefix']) . '</span> ' : ''; | ||
$suffix = isset($element['#field_suffix']) ? ' <span class="field-suffix">' . _webform_filter_xss($element['#field_suffix']) . '</span>' : ''; | ||
|
||
switch ($element['#title_display']) { | ||
case 'inline': | ||
case 'before': | ||
case 'invisible': | ||
$output .= ' ' . theme('form_element_label', $variables); | ||
$output .= ' ' . $prefix . $element['#children'] . $suffix . "\n"; | ||
break; | ||
|
||
case 'after': | ||
$output .= ' ' . $prefix . $element['#children'] . $suffix; | ||
$output .= ' ' . theme('form_element_label', $variables) . "\n"; | ||
break; | ||
|
||
case 'none': | ||
case 'attribute': | ||
// Output no label and no required marker, only the children. | ||
$output .= ' ' . $prefix . $element['#children'] . $suffix . "\n"; | ||
break; | ||
} | ||
|
||
if (!empty($element['#description'])) { | ||
$output .= ' <div class="description">' . $element['#description'] . "</div>\n"; | ||
} | ||
|
||
$output .= "</li>\n"; | ||
|
||
return $output; | ||
} | ||
|
||
/** | ||
* Implements theme_webform_date(). | ||
*/ | ||
function unl_wdn_webform_date($variables) { | ||
$element = $variables['element']; | ||
|
||
$element['year']['#attributes']['class'] = array('year'); | ||
$element['month']['#attributes']['class'] = array('month'); | ||
$element['day']['#attributes']['class'] = array('day'); | ||
|
||
// Add error classes to all items within the element. | ||
if (form_get_error($element)) { | ||
$element['year']['#attributes']['class'][] = 'error'; | ||
$element['month']['#attributes']['class'][] = 'error'; | ||
$element['day']['#attributes']['class'][] = 'error'; | ||
} | ||
|
||
$class = array('webform-container-inline'); | ||
|
||
// Add the JavaScript calendar if available (provided by Date module package). | ||
if (!empty($element['#datepicker'])) { | ||
$class[] = 'webform-datepicker'; | ||
$calendar_class = array('webform-calendar'); | ||
if ($element['#start_date']) { | ||
$calendar_class[] = 'webform-calendar-start-' . $element['#start_date']; | ||
} | ||
if ($element['#end_date']) { | ||
$calendar_class[] = 'webform-calendar-end-' . $element['#end_date']; | ||
} | ||
$calendar_class[] ='webform-calendar-day-' . variable_get('date_first_day', 0); | ||
|
||
$calendar = theme('webform_calendar', array('component' => $element['#webform_component'], 'calendar_classes' => $calendar_class)); | ||
} | ||
|
||
$output = ''; | ||
$output .= '<ol class="' . implode(' ', $class) . '">'; | ||
$output .= drupal_render_children($element); | ||
$output .= isset($calendar) ? $calendar : ''; | ||
$output .= '</ol>'; | ||
|
||
return $output; | ||
} |
Oops, something went wrong.