diff -up form_store/form_collect.info form_store_d6/form_collect.info --- form_store/form_collect.info Mon May 28 15:20:05 2007 +++ form_store_d6/form_collect.info Fri Nov 7 02:13:39 2008 @@ -1,9 +1,5 @@ ; $Id: form_collect.info,v 1.1 2007/03/21 21:32:06 heine Exp $ name = Form collect description = Collects form information while browsing the site. -dependencies = form_store -; Information added by drupal.org packaging script on 2007-05-28 -version = "5.x-1.0" -project = "form_store" -datestamp = "1180380005" - +dependencies[] = form_store +core = 6.x diff -up form_store/form_collect.module form_store_d6/form_collect.module --- form_store/form_collect.module Wed Mar 21 17:32:06 2007 +++ form_store_d6/form_collect.module Fri Nov 7 02:17:11 2008 @@ -3,18 +3,20 @@ // $Id: form_collect.module,v 1.1 2007/03/21 21:32:06 heine Exp $ /** + * @file * Collects form information while browsing. * * By Heine Deelstra (http://heine.familiedeelstra.com). + * Ported to Drupal 6 by jon r. luini (http://www.chime.com) * * Collection page is on admin/settings/form-store/collect * */ -function form_collect_help($section) { +function form_collect_help($path, $arg) { - switch ($section) { + switch ($path) { case 'admin/settings/form-store/collect': $txt = '
'. t('When you enable Collect forms while browsing the site, every form on your site will, when visited, be added to the Form store.', @@ -27,19 +29,16 @@ function form_collect_help($section) { /** * Define a Collect forms tab on admin/settings/form-store. */ -function form_collect_menu($may_cache) { - if ($may_cache) { - $items = array(); - $items[] = array( - 'path' => 'admin/settings/form-store/collect', - 'title' => 'Collect forms', - 'type' => MENU_LOCAL_TASK, - 'callback' => 'drupal_get_form', - 'callback arguments' => array('form_collect_form'), - 'access' => user_access('administer site configuration'), - ); - return $items; - } +function form_collect_menu() { + $items = array(); + $items['admin/settings/form-store/collect'] = array( + 'title' => 'Collect forms', + 'type' => MENU_LOCAL_TASK, + 'page callback' => 'drupal_get_form', + 'page arguments' => array('form_collect_form'), + 'access arguments' => array('administer site configuration'), + ); + return $items; } /** @@ -69,7 +68,7 @@ function form_collect_form() { * @param unknown_type $form_id * @param unknown_type $form */ -function form_collect_form_alter($form_id, &$form) { +function form_collect_form_alter(&$form, $form_state, $form_id) { if (variable_get('form_collect_enabled', 0) && !form_store_get($form_id)) { // Form store handles the addition form_store_add($form_id, $form); @@ -79,4 +78,4 @@ function form_collect_form_alter($form_i drupal_set_message(t('Form %form_id had been added to the store.', array('%form_id' => $form_id))); } } -} \ No newline at end of file +} diff -up form_store/form_store.info form_store_d6/form_store.info --- form_store/form_store.info Mon May 28 15:20:05 2007 +++ form_store_d6/form_store.info Fri Nov 7 01:11:02 2008 @@ -1,8 +1,4 @@ ; $Id: form_store.info,v 1.1 2007/03/21 21:32:06 heine Exp $ name = Form store description = Provides form information to other modules. -; Information added by drupal.org packaging script on 2007-05-28 -version = "5.x-1.0" -project = "form_store" -datestamp = "1180380005" - +core = 6.x diff -up form_store/form_store.install form_store_d6/form_store.install --- form_store/form_store.install Wed Mar 21 17:32:06 2007 +++ form_store_d6/form_store.install Fri Nov 7 02:10:14 2008 @@ -3,35 +3,43 @@ // $Id: form_store.install,v 1.1 2007/03/21 21:32:06 heine Exp $ /** + * @file * Creates database tables required by form_store.module * * By Heine Deelstra (http://heine.familiedeelstra.com). + * Ported to Drupal 6 by jon r. luini (http://www.chime.com). * */ -function form_store_install() { - switch ($GLOBALS['db_type']) { - // TODO: Test on PostgreSQL. - // TODO: Decide on TEXT/VARCHAR for description? - // TODO: Add indices. - - case 'pgsql': - drupal_set_message("Sorry, PostgreSQL is not yet support."); - break; - - case 'mysql': - case 'mysqli': - db_query("CREATE TABLE {form_store_forms} ( - fid int(10) auto_increment, - form_id varchar(255) NOT NULL default '', - description varchar(255), - preview TEXT, - PRIMARY KEY (fid), - KEY (form_id) - ) /*!40100 DEFAULT CHARACTER SET utf8 */;"); - break; +function form_store_schema() { + $schema['form_store_forms'] = array( + 'fields' => array( + 'fid' => array( + 'type' => 'serial', + 'unsigned' => TRUE, + 'not null' => TRUE), + 'form_id' => array( + 'type' => 'varchar', + 'length' => 255, + 'not null' => TRUE, + 'default' => ''), + 'description' => array( + 'type' => 'varchar', + 'length' => '255'), + 'preview' => array( + 'type' => 'text'), + ), + 'indexes' => array( + 'form_id' => array('form_id') + ), + 'primary key' => array('fid'), + ); - } + return $schema; +} + +function form_store_install() { + drupal_install_schema('form_store'); $forms = form_store_core_forms_list(); foreach ($forms as $form_id => $description) { db_query("INSERT INTO {form_store_forms} (form_id, description, preview) VALUES ('%s', '%s', '')", $form_id, $description); @@ -43,8 +51,8 @@ function form_store_install() { * */ function form_store_uninstall() { - db_query("DROP TABLE {form_store_forms}"); - db_query("DELETE FROM {sequences} WHERE name = '{form_store_forms}_id'"); + drupal_uninstall_schema('form_store'); + //db_query("DELETE FROM {sequences} WHERE name = '{form_store_forms}_id'"); } /** @@ -55,19 +63,11 @@ function form_store_uninstall() { */ function form_store_update_1() { $ret = array(); - switch ($GLOBALS['db_type']) { - - case 'pgsql': - break; - case 'mysql': - case 'mysqli': - // Add a field to keep the serialized form array for previews - $ret[] = update_sql("ALTER TABLE {form_store_forms} ADD preview TEXT"); - $ret[] = update_sql("ALTER TABLE {form_store_forms} CHANGE description description VARCHAR(255)"); - break; - } - return $ret; + // Add a field to keep the serialized form array for previews + db_add_field($ret, 'form_store_forms', 'preview', array('type' => 'text')); + db_change_field($ret, 'form_store_forms', 'description', 'description', array('type' => 'varchar', 'length' => 255)); + return $ret; } /** @@ -75,21 +75,13 @@ function form_store_update_1() { */ function form_store_update_2() { $ret = array(); - switch ($GLOBALS['db_type']) { - case 'pgsql': - break; + // Add a field to keep the serialized form array for previews + $max_fid = db_result(db_query("SELECT MAX(fid) FROM {form_store_forms}")); + db_change_field($ret, 'form_store_forms', 'fid', 'fid', array('type' => 'serial')); + $ret[] = update_sql("ALTER TABLE {form_store_forms} AUTO_INCREMENT = ". $max_fid); - case 'mysql': - case 'mysqli': - // Add a field to keep the serialized form array for previews - $max_fid = db_result(db_query("SELECT MAX(fid) FROM {form_store_forms}")); - $ret[] = update_sql("ALTER TABLE {form_store_forms} CHANGE fid fid int(10) auto_increment"); - $ret[] = update_sql("ALTER TABLE {form_store_forms} AUTO_INCREMENT = ". $max_fid); - break; - } - return $ret; - + return $ret; } /** @@ -103,4 +95,4 @@ function form_store_core_forms_list() { 'page_node_form' => t('create a page'), 'story_node_form' => t('create a story'), ); -} \ No newline at end of file +} diff -up form_store/form_store.module form_store_d6/form_store.module --- form_store/form_store.module Wed Mar 21 17:32:06 2007 +++ form_store_d6/form_store.module Fri Nov 7 01:50:59 2008 @@ -2,9 +2,11 @@ // $Id: form_store.module,v 1.1 2007/03/21 21:32:06 heine Exp $ /** + * @file * Provides an API for modules that need to know what forms to act on. * * By Heine Deelstra (http://heine.familiedeelstra.com). + * Ported to Drupal 6 by jon r. luini (http://www.chime.com). * */ @@ -14,9 +16,9 @@ */ -function form_store_help($section) { +function form_store_help($path, $arg) { - switch ($section) { + switch ($path) { case 'admin/settings/form-store': @@ -27,7 +29,7 @@ function form_store_help($section) { else { $txt = '
'. t('To add additional forms to the list below, enable the module Form collect, then visit the Form collect settings page.', array( - '@url' => url('admin/build/modules', NULL, 'edit-status-form-collect'), + '@url' => url('admin/build/modules', array('fragment' => 'edit-status-form-collect')), '@url_settings' => url('admin/settings/form-store/collect') )) .'
'; } @@ -41,45 +43,38 @@ function form_store_help($section) { * * All paths require the "adminster site configuration" permission. */ -function form_store_menu($may_cache) { +function form_store_menu() { + $items = array(); - if ($may_cache) { - $items = array(); - - $items[] = array( - 'path' => 'admin/settings/form-store', - 'title' => t('Form store'), - 'type' => MENU_NORMAL_ITEM, - 'callback' => 'form_store_page', - 'access' => user_access('administer site configuration'), - 'description' => t('View and collect forms in use on the site.') - ); + $items['admin/settings/form-store'] = array( + 'title' => 'Form store', + 'type' => MENU_NORMAL_ITEM, + 'page callback' => 'form_store_page', + 'access arguments' => array('administer site configuration'), + 'description' => 'View and collect forms in use on the site.' + ); - $items[] = array( - 'path' => 'admin/settings/form-store/store', - 'title' => t('Form store'), - 'type' => MENU_DEFAULT_LOCAL_TASK, - 'weight' => -1, - 'access' => user_access('administer site configuration'), - ); + $items['admin/settings/form-store/store'] = array( + 'title' => 'Form store', + 'type' => MENU_DEFAULT_LOCAL_TASK, + 'weight' => -1, + 'access arguments' => array('administer site configuration'), + ); - $items[] = array( - 'path' => 'form-store/show', - 'title' => t('Form store - form preview'), - 'type' => MENU_CALLBACK, - 'access' => user_access('administer site configuration'), - 'callback' => 'form_store_show_page', - ); + $items['form-store/show'] = array( + 'title' => 'Form store - form preview', + 'type' => MENU_CALLBACK, + 'access arguments' => array('administer site configuration'), + 'page callback' => 'form_store_show_page', + ); - $items[] = array( - 'path' => 'form-store/edit', - 'title' => t('Edit description'), - 'type' => MENU_CALLBACK, - 'access' => user_access('administer site configuration'), - 'callback' => 'form_store_edit_page', - ); - return $items; - } + $items['form-store/edit'] = array( + 'title' => 'Edit description', + 'type' => MENU_CALLBACK, + 'access arguments' => array('administer site configuration'), + 'page callback' => 'form_store_edit_page', + ); + return $items; } /** @@ -137,16 +132,16 @@ function form_store_edit_form($collected * When Save has been pressed, save the new description. * When Remove has been pressed, remove the form from the store. */ -function form_store_edit_form_submit($form_id, $form_values) { - if ($form_values['op'] == t('Save')) { - db_query("UPDATE {form_store_forms} f SET f.description = '%s' WHERE f.fid = %d", $form_values['description'], $form_values['fid']); - drupal_set_message(t('Changes to the %form_id description have been saved.', array('%form_id' => $form_values['collected_form_id']))); - } - else if ($form_values['op'] == t('Remove')) { - db_query("DELETE FROM {form_store_forms} WHERE fid = %d", $form_values['fid']); - drupal_set_message(t('%form_id has been removed from the list.', array('%form_id' => $form_values['collected_form_id']))); +function form_store_edit_form_submit($form, &$form_state) { + if ($form_state['values']['op'] == t('Save')) { + db_query("UPDATE {form_store_forms} f SET f.description = '%s' WHERE f.fid = %d", $form_state['values']['description'], $form_state['values']['fid']); + drupal_set_message(t('Changes to the %form_id description have been saved.', array('%form_id' => $form_state['values']['collected_form_id']))); + } + else if ($form_state['values']['op'] == t('Remove')) { + db_query("DELETE FROM {form_store_forms} WHERE fid = %d", $form_state['values']['fid']); + drupal_set_message(t('%form_id has been removed from the list.', array('%form_id' => $form_state['values']['collected_form_id']))); } - return 'admin/settings/form-store'; + $form_state['redirect'] = 'admin/settings/form-store'; } /** @@ -238,6 +233,17 @@ function form_store_page_form($collected } /** + * Implementation of hook_theme() + */ +function form_store_theme() { + return array( + 'form_store_page_form' => array( + 'arguments' => array('form' => NULL), + ), + ); +} + +/** * Theme the quick description + overview form into a table. * * Provide preview and edit links as well. @@ -260,9 +266,9 @@ function theme_form_store_page_form($for /** * Save new descriptions. */ -function form_store_page_form_submit($form_id, $form_values) { - if (is_array($form_values['forms'])) { - foreach ($form_values['forms'] as $fid => $data) { +function form_store_page_form_submit($form, &$form_state) { + if (is_array($form_state['values']['forms'])) { + foreach ($form_state['values']['forms'] as $fid => $data) { if (!empty($data['collected_description'])) { db_query("UPDATE {form_store_forms} f SET f.description = '%s' WHERE f.fid = %d", $data['collected_description'], $fid); } @@ -359,4 +365,4 @@ function form_store_get_all() { $forms[$form->form_id] = $form; } return $forms; -} \ No newline at end of file +}