| 9 |
/** |
/** |
| 10 |
* Implementation of hook_help(). |
* Implementation of hook_help(). |
| 11 |
*/ |
*/ |
| 12 |
function formupdater_help($section) { |
function formupdater_help($path, $arg) { |
| 13 |
switch ($section) { |
switch ($path) { |
| 14 |
case 'formupdater': |
case 'formupdater': |
| 15 |
return t('<p>Form Updater will search through your old Drupal code to find calls to old form functions (such as form_textfield, form_radios, etc). It will then reformat these functions as arrays for use with the new <a href="http://api.drupal.org/api/file/developer/topics/forms_api_reference.html">Drupal Forms API</a>.</p>'); |
return t('<p>Form Updater will search through your old Drupal code to find calls to old form functions (such as form_textfield, form_radios, etc). It will then reformat these functions as arrays for use with the new <a href="http://api.drupal.org/api/file/developer/topics/forms_api_reference.html">Drupal Forms API</a>.</p>'); |
| 16 |
} |
} |
| 19 |
/** |
/** |
| 20 |
* Implementation of hook_menu(). |
* Implementation of hook_menu(). |
| 21 |
*/ |
*/ |
| 22 |
function formupdater_menu($may_cache) { |
function formupdater_menu() { |
| 23 |
$items = array(); |
$items = array(); |
| 24 |
if ($may_cache) { |
$items['formupdater'] = array( |
| 25 |
$items[] = array( |
'title' => 'Form updater', |
| 26 |
'path' => 'formupdater', |
'access callback' => 'user_access', |
| 27 |
'title' => t('Form updater'), |
'access arguments' => array('access content'), |
| 28 |
'access' => user_access('access content'), |
'page callback' => 'drupal_get_form', |
| 29 |
'callback' => 'drupal_get_form', |
'page arguments' => array('formupdater_form') |
| 30 |
'callback arguments' => array('formupdater_form') |
); |
|
); |
|
|
} |
|
| 31 |
return $items; |
return $items; |
| 32 |
} |
} |
| 33 |
|
|
| 45 |
return $form; |
return $form; |
| 46 |
} |
} |
| 47 |
|
|
| 48 |
function formupdater_form_submit($form_id, $form_values) { |
function formupdater_form_submit($form, &$form_state) { |
| 49 |
$code = $form_values['code']; |
$code = $form_state['values']['code']; |
| 50 |
$regex = '/\s(form_(.*?)|form())\(([\w\W]*?)\);/i'; |
$regex = '/\s(form_(.*?)|form())\(([\w\W]*?)\);/i'; |
| 51 |
preg_match_all($regex, $code, $matches, PREG_SET_ORDER); |
preg_match_all($regex, $code, $matches, PREG_SET_ORDER); |
| 52 |
$i = 1; |
$i = 1; |