| 1 |
<?php
|
| 2 |
// $Id: wforms.module,v 1.7 2006/06/02 15:34:18 nedjo Exp $
|
| 3 |
|
| 4 |
/**
|
| 5 |
* @file
|
| 6 |
* Enables dynamic forms. Based on the wForms library by Cedric Savarese (http://www.4213miles.com).
|
| 7 |
*/
|
| 8 |
|
| 9 |
/**
|
| 10 |
* Implementation of hook_help().
|
| 11 |
*/
|
| 12 |
function wforms_help($section) {
|
| 13 |
switch ($section) {
|
| 14 |
case 'admin/modules#description':
|
| 15 |
return t('Enables dynamic forms including client-side validation, multi-page forms, and more.');
|
| 16 |
}
|
| 17 |
}
|
| 18 |
|
| 19 |
/**
|
| 20 |
* Implementation of hook_menu().
|
| 21 |
*/
|
| 22 |
function wforms_form_alter($form_id, &$form) {
|
| 23 |
if($form_id == 'unit_node_form'){
|
| 24 |
$path = drupal_get_path('module', 'wforms');
|
| 25 |
drupal_set_html_head(theme('stylesheet_import', base_path() . $path .'/lib/wforms.css'));
|
| 26 |
// This stylesheet needs to be added as an alternate. It is activated on demand by js.
|
| 27 |
drupal_set_html_head('<link type="text/css" href="' . base_path() . $path . '/lib/wforms-jsonly.css" rel="alternate stylesheet" title="stylesheet activated by javascript" />');
|
| 28 |
drupal_add_js($path . '/lib/wforms.js');
|
| 29 |
// The customization file includes fixes to make wForms compatible
|
| 30 |
// with drupal js.
|
| 31 |
drupal_add_js($path . '/customization.js');
|
| 32 |
}
|
| 33 |
}
|
| 34 |
|
| 35 |
/**
|
| 36 |
* Declare wforms form element types and specify their default values.
|
| 37 |
*
|
| 38 |
* @return
|
| 39 |
* An array of element types
|
| 40 |
*/
|
| 41 |
function hook_elements() {
|
| 42 |
$types = array();
|
| 43 |
$types['wformspage'] = array();
|
| 44 |
return $types;
|
| 45 |
}
|
| 46 |
|
| 47 |
/**
|
| 48 |
* Format a page of a wform.
|
| 49 |
*
|
| 50 |
* @param $element
|
| 51 |
* An associative array containing the properties of the element.
|
| 52 |
* @return
|
| 53 |
* A themed HTML string representing the form page.
|
| 54 |
*/
|
| 55 |
function theme_wformspage($element) {
|
| 56 |
static $count = 0;
|
| 57 |
$count++;
|
| 58 |
return '<div class="wfPage" id="wfPgIndex-' . $count . '">' . ($element['#title'] ? '<span class="wforms-title">' . $element['#title'] . '</span>' : '') . $element['#children'] . '</div>';
|
| 59 |
}
|