diff --git a/hierarchical_select.admin.inc b/hierarchical_select.admin.inc index 9033c92..9e288c8 100644 --- a/hierarchical_select.admin.inc +++ b/hierarchical_select.admin.inc @@ -75,9 +75,12 @@ function hierarchical_select_admin_configs() { // Retrieve all information items $info_items = array(); + $mods = module_implements('hierarchical_select_config_info'); + file_put_contents('/tmp/hierarchical_select_config_info', print_r($mods, true)); foreach (module_implements('hierarchical_select_config_info') as $module) { $info_items = array_merge_recursive($info_items, module_invoke($module, 'hierarchical_select_config_info')); } + file_put_contents('/tmp/hierarchical_select_config_info_info_items', print_r($info_items, true)); // Process the retrieved information into rows. $rows = array(); @@ -113,7 +116,8 @@ function hierarchical_select_admin_implementations() { // Retrieve all information items $rows = array(); foreach (module_implements('hierarchical_select_root_level') as $module) { - $filename = db_result(db_query("SELECT filename FROM {system} WHERE type = 'module' AND name = '%s'", $module)); + //$filename = db_result(db_query("SELECT filename FROM {system} WHERE type = 'module' AND name = '%s'", $module)); + $filename = db_query("SELECT filename FROM {system} WHERE type = 'module' AND name = :name", array(':name' => $module))->fetchField(0); $module_info = drupal_parse_info_file(dirname($filename) ."/$module.info"); // Try to extract the hierarchy type from the optional hook_hierarchical_select_config_info(). $hierarchy_type = $entity_type = t('unknown'); diff --git a/hierarchical_select.info b/hierarchical_select.info index 698e761..c5ad672 100644 --- a/hierarchical_select.info +++ b/hierarchical_select.info @@ -2,4 +2,11 @@ name = Hierarchical Select description = Simplifies the selection of one or multiple items in a hierarchical tree. package = Form Elements -core = 6.x +core = 7.x + +files[] = hierarchical_select.module +files[] = hierarchical_select.admin.inc + +scripts[] = hierarchical_select.js +scripts[] = hierarchical_select_cache.js +scripts[] = hierarchical_select_formtoarray.js diff --git a/hierarchical_select.install b/hierarchical_select.install index fdb4940..d04e027 100644 --- a/hierarchical_select.install +++ b/hierarchical_select.install @@ -14,13 +14,12 @@ function hierarchical_select_install() { // Ensure the Hierarchical Select module runs after the Taxonomy and Content // Taxonomy modules! This should not be necessary to do, but apparently some // idiot module developer is changing the weight of the Taxonomy module... - $weight = db_result(db_query("SELECT weight FROM {system} WHERE name = 'taxonomy'")); - $weight = max($weight, db_result(db_query("SELECT weight FROM {system} WHERE name = 'content_taxonomy'"))); // Also ensure the Hierarchical Select module runs after the i18ntaxonomy // module. - $weight = max($weight, db_result(db_query("SELECT weight FROM {system} WHERE name = 'i18ntaxonomy'"))); // Also ensure the Hierarchical Select module runs after the og_vocab module. - $weight = max($weight, db_result(db_query("SELECT weight FROM {system} WHERE name = 'og_vocab'"))); + + $weight = db_query("SELECT max(weight) FROM {system} WHERE name='taxonomy' or name='content_taxonomy' or name='i18ntaxonomy' or name='og_vocab'")->fetchField(0); + // If none of these modules was already enabled, the weight will still be // incorrect. Therefore, let's make the minimum weight of Hierarchical // Select 15. @@ -30,17 +29,35 @@ function hierarchical_select_install() { // that Hierarchical Select will run after it. $weight++; - db_query("UPDATE {system} SET weight = %d WHERE name = '%s'", $weight, 'hierarchical_select'); - - drupal_install_schema('hierarchical_select'); + //db_query("UPDATE {system} SET weight = %d WHERE name = '%s'", array($weight), 'hierarchical_select'); + db_update('system') + ->fields(array( + 'weight' => $weight, + )) + ->condition('name', 'hierarchical_select', '=') + ->execute(); + + /* As of Drupal 7, a call to drupal_uninstall_schema() is no longer necessary. + See http://drupal.org/update/modules/6/7: "A module no longer should + explicitly install or uninstall its database schema in hook_install() or + hook_uninstall()." + drupal_install_schema('hierarchical_select'); */ } /** * Implementation of hook_uninstall(). */ function hierarchical_select_uninstall() { - drupal_uninstall_schema('hierarchical_select'); - db_query("DELETE FROM {variable} WHERE name LIKE 'hs_config_%'"); + /* As of Drupal 7, a call to drupal_uninstall_schema() is no longer necessary. + See http://drupal.org/update/modules/6/7: "A module no longer should + explicitly install or uninstall its database schema in hook_install() or + hook_uninstall()." + drupal_uninstall_schema('hierarchical_select'); */ + + //db_query("DELETE FROM {variable} WHERE name LIKE 'hs_config_%'"); + db_delete('variable') + ->condition('name', 'hs_config_%', 'LIKE') + ->execute(); } /** @@ -54,7 +71,11 @@ function hierarchical_select_schema() { //---------------------------------------------------------------------------- // Schema updates. +// TC: Should these be removed? Probably since 1) I don't want to update the +// SQL into DBTNG, and 2) Installing into D7, the schema should be up to +// date. Unknown how to do an update path. +/* // Update module weight. function hierarchical_select_update_1() { $ret = array(); @@ -62,8 +83,7 @@ function hierarchical_select_update_1() { // Ensure the Hierarchical Select module runs after the Taxonomy and Content // Taxonomy modules! This should not be necessary to do, but apparently some // idiot module developer is changing the weight of the Taxonomy module... - $weight = db_result(db_query("SELECT weight FROM {system} WHERE name = 'taxonomy'")); - $weight = max($weight, db_result(db_query("SELECT weight FROM {system} WHERE name = 'content_taxonomy'"))); + $weight = db_query("SELECT weight FROM {system} WHERE name='taxonomy' OR name='content_taxonomy'")->fetchColumn(0); $weight++; $ret[] = update_sql("UPDATE {system} SET weight = $weight WHERE name = 'hierarchical_select'"); @@ -74,9 +94,7 @@ function hierarchical_select_update_1() { function hierarchical_select_update_2() { $ret = array(); - $weight = db_result(db_query("SELECT weight FROM {system} WHERE name = 'taxonomy'")); - $weight = max($weight, db_result(db_query("SELECT weight FROM {system} WHERE name = 'content_taxonomy'"))); - $weight = max($weight, db_result(db_query("SELECT weight FROM {system} WHERE name = 'i18ntaxonomy'"))); + $weight = db_query("SELECT MAX(weight) FROM {system} WHERE name = 'taxonomy' OR name = 'content_taxonomy' OR name='i18ntaxonomy'")->fetchColumn(0); $weight++; $ret[] = update_sql("UPDATE {system} SET weight = $weight WHERE name = 'hierarchical_select'"); @@ -222,13 +240,10 @@ function hierarchical_select_update_8() { // Ensure the Hierarchical Select module runs after the Taxonomy and Content // Taxonomy modules! This should not be necessary to do, but apparently some // idiot module developer is changing the weight of the Taxonomy module... - $weight = db_result(db_query("SELECT weight FROM {system} WHERE name = 'taxonomy'")); - $weight = max($weight, db_result(db_query("SELECT weight FROM {system} WHERE name = 'content_taxonomy'"))); // Also ensure the Hierarchical Select module runs after the i18ntaxonomy // module. - $weight = max($weight, db_result(db_query("SELECT weight FROM {system} WHERE name = 'i18ntaxonomy'"))); // Also ensure the Hierarchical Select module runs after the og_vocab module. - $weight = max($weight, db_result(db_query("SELECT weight FROM {system} WHERE name = 'og_vocab'"))); + $weight = db_query("SELECT max(weight) FROM {system} WHERE name='taxonomy' or name='content_taxonomy' or name='i18ntaxonomy' or name='og_vocab'")->fetchColumn(0); // If none of these modules was already enabled, the weight will still be // incorrect. Therefore, let's make the minimum weight of Hierarchical // Select 15. @@ -256,3 +271,4 @@ function hierarchical_select_update_9() { return $ret; } +*/ diff --git a/hierarchical_select.module b/hierarchical_select.module index 00fa8c5..9193a57 100644 --- a/hierarchical_select.module +++ b/hierarchical_select.module @@ -26,7 +26,7 @@ function hierarchical_select_menu() { // of the form the Hierarchical Select was in. 'access callback' => TRUE, ); - $items['admin/settings/hierarchical_select'] = array( + $items['admin/config/hierarchical_select'] = array( 'title' => 'Hierarchical Select', 'description' => 'Configure site-wide settings for the Hierarchical Select form element.', 'access arguments' => array('administer site configuration'), @@ -35,14 +35,14 @@ function hierarchical_select_menu() { 'type' => MENU_NORMAL_ITEM, 'file' => 'hierarchical_select.admin.inc', ); - $items['admin/settings/hierarchical_select/settings'] = array( + $items['admin/config/hierarchical_select/settings'] = array( 'title' => 'Site-wide settings', 'access arguments' => array('administer site configuration'), 'weight' => -10, 'type' => MENU_DEFAULT_LOCAL_TASK, 'file' => 'hierarchical_select.admin.inc', ); - $items['admin/settings/hierarchical_select/configs'] = array( + $items['admin/config/hierarchical_select/configs'] = array( 'title' => 'Configurations', 'description' => 'All available Hierarchical Select configurations.', 'access arguments' => array('administer site configuration'), @@ -50,7 +50,7 @@ function hierarchical_select_menu() { 'type' => MENU_LOCAL_TASK, 'file' => 'hierarchical_select.admin.inc', ); - $items['admin/settings/hierarchical_select/implementations'] = array( + $items['admin/config/hierarchical_select/implementations'] = array( 'title' => 'Implementations', 'description' => 'Features of each Hierarchical Select implementation.', 'access arguments' => array('administer site configuration'), @@ -58,7 +58,7 @@ function hierarchical_select_menu() { 'type' => MENU_LOCAL_TASK, 'file' => 'hierarchical_select.admin.inc', ); - $items['admin/settings/hierarchical_select/export/%hierarchical_select_config_id'] = array( + $items['admin/config/hierarchical_select/export/%hierarchical_select_config_id'] = array( 'title' => 'Export', 'access arguments' => array('administer site configuration'), 'page callback' => 'drupal_get_form', @@ -66,7 +66,7 @@ function hierarchical_select_menu() { 'type' => MENU_LOCAL_TASK, 'file' => 'hierarchical_select.admin.inc', ); - $items['admin/settings/hierarchical_select/import/%hierarchical_select_config_id'] = array( + $items['admin/config/hierarchical_select/import/%hierarchical_select_config_id'] = array( 'title' => 'Import', 'access arguments' => array('administer site configuration'), 'page callback' => 'drupal_get_form', @@ -88,12 +88,12 @@ function hierarchical_select_form_alter(&$form, &$form_state, $form_id) { } /** - * Implementation of hook_elements(). + * Implementation of hook_element_info(). */ -function hierarchical_select_elements() { +function hierarchical_select_element_info() { $type['hierarchical_select'] = array( '#input' => TRUE, - '#process' => array('hierarchical_select_process'), + '#process' => array('hierarchical_select_process_notautohook'), '#config' => array( 'module' => 'some_module', 'params' => array(), @@ -140,25 +140,32 @@ function hierarchical_select_requirements($phase) { require_once('includes/install.inc'); drupal_load_updates(); $updates = drupal_get_schema_versions('hierarchical_select'); - $current = drupal_get_installed_schema_version('hierarchical_select'); + $up_to_date = true; + // There could be no updates + if ($updates) { + $current = drupal_get_installed_schema_version('hierarchical_select'); - $up_to_date = (end($updates) == $current); + $up_to_date = (end($updates) == $current); + } - $hierarchical_select_weight = db_result(db_query("SELECT weight FROM {system} WHERE type = 'module' AND name = 'hierarchical_select'")); + $hierarchical_select_weight = db_query("SELECT name FROM {system} WHERE type = 'module' AND name = 'hierarchical_select'")->fetchField(0); $core_overriding_modules = array('hs_book', 'hs_menu', 'hs_taxonomy'); $path_errors = array(); foreach ($core_overriding_modules as $module) { - $filename = db_result(db_query("SELECT filename FROM {system} WHERE type = 'module' AND name = '%s'", $module)); + $filename = db_query("SELECT filename FROM {system} WHERE type = 'module' AND name = ':name'", array(':name' => $module))->fetchField(0); if (strpos($filename, 'modules/') === 0) { $module_info = drupal_parse_info_file(dirname($filename) ."/$module.info"); + $fd = fopen('/tmp/modinfo', 'a'); + fprintf($fd, '%s\n', print_r($module_info, true)); + fclose($fd); $path_errors[] = t('!module', array('!module' => $module_info['name'])); } } $weight_errors = array(); foreach (module_implements('hierarchical_select_root_level') as $module) { - $weight = db_result(db_query("SELECT weight FROM {system} WHERE name = '%s'", $module)); + $weight = db_query("SELECT weight FROM {system} WHERE name = ':name'", array(':name' => $module))->fetchColumn(0); if (!($hierarchical_select_weight > $weight)) { - $filename = db_result(db_query("SELECT filename FROM {system} WHERE type = 'module' AND name = '%s'", $module)); + $filename = db_query("SELECT filename FROM {system} WHERE type = 'module' AND name = ':name'", array(':name' => $module))->fetchColumn(0); $module_info = drupal_parse_info_file(dirname($filename) ."/$module.info"); $weight_errors[] = t('!module (!weight)', array('!module' => $module_info['name'], '!weight' => $weight)); } @@ -374,7 +381,9 @@ function hierarchical_select_json() { /** * Hierarchical select form element type #process callback. */ -function hierarchical_select_process($element, $edit, &$form_state, $form) { +function hierarchical_select_process_notautohook($element, &$form_state, $form) { + // Needed to add _notautohook as apparently there's a hook_process that + // theme picks up on that was causing all sorts of errors. if (!is_array($element['#value']) || !isset($element['#value']['hsid'])) { // The HSID is stored in the session, to allow for multiple Hierarchical // Select form items on the same page of which at least one is added through @@ -1290,7 +1299,7 @@ function _hierarchical_select_process_calculate_return_value($hierarchy, $dropbo // Private functions. /** - * Inherit the default config from Hierarchical Selects' hook_elements(). + * Inherit the default config from Hierarchical Selects' hook_element_info(). * * @param $config * A config array with at least the following settings: @@ -1301,10 +1310,10 @@ function _hierarchical_select_process_calculate_return_value($hierarchy, $dropbo */ function _hierarchical_select_inherit_default_config($config, $defaults_override = array()) { // Set defaults for unconfigured settings. Get the defaults from our - // hook_elements() implementation. Default properties from this hook are + // hook_element_info() implementation. Default properties from this hook are // applied automatically, but properties inside properties, such as is the // case for Hierarchical Select's #config property, aren't applied. - $type = hierarchical_select_elements(); + $type = hierarchical_select_element_info(); $defaults = $type['hierarchical_select']['#config']; // Don't inherit the module and params settings. unset($defaults['module']); @@ -1352,7 +1361,7 @@ function _hierarchical_select_setup_js(&$form_state = NULL) { $url = str_replace('//', '/', '/' . $url); } - _hierarchical_select_add_js_settings(array('HierarchicalSelect' => array('basePath' => $url, 'getArguments' => drupal_query_string_encode($_GET, array('q')))), $form_state); + _hierarchical_select_add_js_settings(array('HierarchicalSelect' => array('basePath' => $url, 'getArguments' => drupal_get_query_parameters($_GET, array('q')))), $form_state); $js_settings_added = TRUE; } @@ -1783,7 +1792,7 @@ function _hierarchical_select_hierarchy_generate($config, $selection, $required, $third_case = $dropbox && count($dropbox->lineages) > 0; if (($first_case || $second_case || $third_case) && !count($special_items['none'])) { $option = theme('hierarchical_select_special_option', t('none')); - $hierarchy->levels[0] = array('none' => $option) + $hierarchy->levels[0]; + $hierarchy->levels[0] = array('none' => $option) + array( 0 => $hierarchy->levels[0]); } // Calculate the lineage's depth (starting from 0). diff --git a/modules/hs_content_taxonomy.info b/modules/hs_content_taxonomy.info index 7e43663..074c54f 100644 --- a/modules/hs_content_taxonomy.info +++ b/modules/hs_content_taxonomy.info @@ -5,4 +5,8 @@ dependencies[] = hierarchical_select dependencies[] = content_taxonomy dependencies[] = hs_taxonomy package = Form Elements -core = 6.x +core = 7.x + +files[] = hs_content_taxonomy.module +files[] = hs_content_taxonomy.admin.inc + diff --git a/modules/hs_flatlist.info b/modules/hs_flatlist.info index 0124a15..0a769f9 100644 --- a/modules/hs_flatlist.info +++ b/modules/hs_flatlist.info @@ -3,4 +3,6 @@ name = Hierarchical Select Flat List description = Allows Hierarchical Select's dropbox to be used for selecting multiple items in a flat list of options. dependencies[] = hierarchical_select package = Form Elements -core = 6.x +core = 7.x +files[] = hs_flatlist.module + diff --git a/modules/hs_menu.info b/modules/hs_menu.info index 8d4c452..a6ab519 100644 --- a/modules/hs_menu.info +++ b/modules/hs_menu.info @@ -4,4 +4,6 @@ description = Use Hierarchical Select for menu parent selection. dependencies[] = hierarchical_select dependencies[] = menu package = Form Elements -core = 6.x +core = 7.x +files[] = hs_menu.module + diff --git a/modules/hs_smallhierarchy.info b/modules/hs_smallhierarchy.info index 2e6d861..4c9cb27 100644 --- a/modules/hs_smallhierarchy.info +++ b/modules/hs_smallhierarchy.info @@ -3,4 +3,6 @@ name = Hierarchical Select Small Hierarchy description = Allows Hierarchical Select to be used for a hardcoded hierarchy. When it becomes to slow, you should move the hierarchy into the database and write a proper implementation. dependencies[] = hierarchical_select package = Form Elements -core = 6.x +core = 7.x +files[] = hs_smallhierarchy.module + diff --git a/modules/hs_taxonomy.info b/modules/hs_taxonomy.info index 5e3f543..b17102c 100644 --- a/modules/hs_taxonomy.info +++ b/modules/hs_taxonomy.info @@ -4,4 +4,7 @@ description = Use Hierarchical Select for Taxonomy. dependencies[] = hierarchical_select dependencies[] = taxonomy package = Form Elements -core = 6.x +core = 7.x + +files[] = hs_taxonomy.module +files[] = hs_taxonomy.install diff --git a/modules/hs_taxonomy.install b/modules/hs_taxonomy.install index f25aea5..7c72f5f 100644 --- a/modules/hs_taxonomy.install +++ b/modules/hs_taxonomy.install @@ -15,7 +15,14 @@ function hs_taxonomy_install() { // Update the module weight to -1 so it runs before other taxonomy related // modules. See http://drupal.org/node/601500. - $ret[] = update_sql("UPDATE {system} SET weight = -1 WHERE name = 'hs_taxonomy'"); + //$ret[] = update_sql("UPDATE {system} SET weight = -1 WHERE name = 'hs_taxonomy'"); + + db_update('system') + ->fields(array( + 'weight' => -1, + )) + ->condition('name', 'hs_taxonomy', '=') + ->execute(); return $ret; } @@ -25,8 +32,14 @@ function hs_taxonomy_install() { */ function hs_taxonomy_uninstall() { // Remove any saved variables. - db_query("DELETE FROM {variable} WHERE name = 'taxonomy_override_selector'"); - db_query("DELETE FROM {variable} WHERE name LIKE 'taxonomy_hierarchical_select_%'"); + //db_query("DELETE FROM {variable} WHERE name = 'taxonomy_override_selector'"); + db_delete('variable') + ->condition('name', 'taxonomy_override_selector', '=') + ->execute(); + //db_query("DELETE FROM {variable} WHERE name LIKE 'taxonomy_hierarchical_select_%'"); + db_delete('variable') + ->condition('name', 'taxonomy_hierarchical_select_%', 'LIKE') + ->execute(); } /** @@ -40,7 +53,7 @@ function hs_taxonomy_enable() { You can configure it to be used on node forms too!", array( - '!configure-url' => url('admin/settings/hierarchical_select/configs'), + '!configure-url' => url('admin/config/hierarchical_select/configs'), )), 'warning'); } @@ -58,7 +71,8 @@ function hs_taxonomy_disable() { //---------------------------------------------------------------------------- // Schema updates. - +// Again, these probably aren't needed now +/* // Update the module weight to 2 so hs_taxonomy runs after the forum module. // See http://drupal.org/node/475784. function hs_taxonomy_update_1() { @@ -78,3 +92,4 @@ function hs_taxonomy_update_6002() { return $ret; } +*/ diff --git a/modules/hs_taxonomy.module b/modules/hs_taxonomy.module index 31780d2..a68d89e 100644 --- a/modules/hs_taxonomy.module +++ b/modules/hs_taxonomy.module @@ -566,7 +566,7 @@ function hs_taxonomy_hierarchical_select_config_info() { if (!isset($config_info)) { $config_info = array(); - $content_types = node_get_types(); + $content_types = _node_types_build()->types; $vocabularies = taxonomy_get_vocabularies(); foreach ($vocabularies as $vid => $vocabulary) { diff --git a/modules/hs_taxonomy_views.info b/modules/hs_taxonomy_views.info index 9483f78..4c6fb0d 100644 --- a/modules/hs_taxonomy_views.info +++ b/modules/hs_taxonomy_views.info @@ -5,4 +5,8 @@ dependencies[] = hierarchical_select dependencies[] = hs_taxonomy dependencies[] = views package = Form Elements -core = 6.x \ No newline at end of file +core = 7.x + +files[] = hs_taxonomy_view.module +files[] = hs_taxonomy_views_handler_filter_term_node_tid.inc +