? ../faceted_search/translations Index: ../faceted_search/author_facet.info =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/faceted_search/author_facet.info,v retrieving revision 1.2 diff -u -p -r1.2 author_facet.info --- ../faceted_search/author_facet.info 15 Nov 2007 23:32:19 -0000 1.2 +++ ../faceted_search/author_facet.info 11 Jun 2008 07:16:08 -0000 @@ -1,6 +1,9 @@ ; $Id: author_facet.info,v 1.2 2007/11/15 23:32:19 davidlesieur Exp $ name = Author Facet description = "Provides a facet for content authors." -dependencies = faceted_search search +dependencies[] = faceted_search +dependencies[] = search package = Faceted Search +core = 6.x +version = 6.2 Index: ../faceted_search/content_type_facet.info =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/faceted_search/content_type_facet.info,v retrieving revision 1.5 diff -u -p -r1.5 content_type_facet.info --- ../faceted_search/content_type_facet.info 15 Nov 2007 23:32:19 -0000 1.5 +++ ../faceted_search/content_type_facet.info 11 Jun 2008 07:16:08 -0000 @@ -1,6 +1,9 @@ ; $Id: content_type_facet.info,v 1.5 2007/11/15 23:32:19 davidlesieur Exp $ name = Content Type Facet description = "Provides a facet for content types." -dependencies = faceted_search search +dependencies[] = faceted_search +dependencies[] = search package = Faceted Search +core = 6.x +version = 6.2 Index: ../faceted_search/content_type_facet.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/faceted_search/content_type_facet.module,v retrieving revision 1.18 diff -u -p -r1.18 content_type_facet.module --- ../faceted_search/content_type_facet.module 20 May 2008 01:55:00 -0000 1.18 +++ ../faceted_search/content_type_facet.module 11 Jun 2008 07:16:09 -0000 @@ -11,7 +11,7 @@ require_once('./'. drupal_get_path('modu /** * Implementation of hook_form_alter(). */ -function content_type_facet_form_alter($form_id, &$form) { +function content_type_facet_form_alter(&$form, &$form_state, $form_id) { if ($form_id == 'faceted_search_edit_form') { $env_id = $form['env_id']['#value']; Index: ../faceted_search/date_authored_facet.info =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/faceted_search/date_authored_facet.info,v retrieving revision 1.2 diff -u -p -r1.2 date_authored_facet.info --- ../faceted_search/date_authored_facet.info 15 Nov 2007 23:32:19 -0000 1.2 +++ ../faceted_search/date_authored_facet.info 11 Jun 2008 07:16:09 -0000 @@ -1,6 +1,9 @@ ; $Id: date_authored_facet.info,v 1.2 2007/11/15 23:32:19 davidlesieur Exp $ name = Date Authored Facet description = "Provides a facet for searching content by date of creation." -dependencies = faceted_search search +dependencies[] = faceted_search +dependencies[] = search package = Faceted Search +core = 6.x +version = 6.2 Index: ../faceted_search/date_facets_format.info =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/faceted_search/date_facets_format.info,v retrieving revision 1.1 diff -u -p -r1.1 date_facets_format.info --- ../faceted_search/date_facets_format.info 28 Feb 2008 18:14:33 -0000 1.1 +++ ../faceted_search/date_facets_format.info 11 Jun 2008 07:16:09 -0000 @@ -1,6 +1,8 @@ ; $Id: date_facets_format.info,v 1.1 2008/02/28 18:14:33 davidlesieur Exp $ name = Date Facets Format description = "Provides formatting options for date-based facets." -dependencies = faceted_search +dependencies[] = faceted_search package = Faceted Search +core = 6.x +version = 6.2 Index: ../faceted_search/date_facets_format.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/faceted_search/date_facets_format.module,v retrieving revision 1.1 diff -u -p -r1.1 date_facets_format.module --- ../faceted_search/date_facets_format.module 28 Feb 2008 18:14:33 -0000 1.1 +++ ../faceted_search/date_facets_format.module 11 Jun 2008 07:16:09 -0000 @@ -9,18 +9,15 @@ /** * Implementation of hook_menu(). */ -function date_facets_format_menu($may_cache) { +function date_facets_format_menu() { $items = array(); - if ($may_cache) { - $items[] = array( - 'path' => 'admin/settings/faceted_search/date_format', - 'title' => t('Date formats'), - 'callback' => 'drupal_get_form', - 'callback arguments' => array('date_facets_format_admin_settings_form'), - 'access' => user_access('administer site configuration'), - 'type' => MENU_LOCAL_TASK, - ); - } + $items['admin/settings/faceted_search/date_format'] = array( + 'title' => 'Date formats', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('date_facets_format_admin_settings_form'), + 'access arguments' => array('administer site configuration'), + 'type' => MENU_LOCAL_TASK, + ); return $items; } Index: ../faceted_search/faceted_search.info =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/faceted_search/faceted_search.info,v retrieving revision 1.3 diff -u -p -r1.3 faceted_search.info --- ../faceted_search/faceted_search.info 18 Jun 2007 22:53:42 -0000 1.3 +++ ../faceted_search/faceted_search.info 11 Jun 2008 07:16:09 -0000 @@ -1,5 +1,7 @@ ; $Id: faceted_search.info,v 1.3 2007/06/18 22:53:42 dww Exp $ name = Faceted Search description = "API for performing faceted searches." -dependencies = search +dependencies[] = search package = Faceted Search +core = 6.x +version = 6.2 Index: ../faceted_search/faceted_search.install =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/faceted_search/faceted_search.install,v retrieving revision 1.10 diff -u -p -r1.10 faceted_search.install --- ../faceted_search/faceted_search.install 20 May 2008 00:31:38 -0000 1.10 +++ ../faceted_search/faceted_search.install 11 Jun 2008 07:16:10 -0000 @@ -2,61 +2,114 @@ // $Id: faceted_search.install,v 1.10 2008/05/20 00:31:38 davidlesieur Exp $ /** + * Implementation of hook_schema(). + */ +function faceted_search_schema() { + $schema['faceted_search_variables'] = array( + 'description' => t(''), + 'fields' => array( + 'env_id' => array( + 'description' => t(''), + 'type' => 'int', + 'unsigned' => TRUE, + 'not null' => TRUE, + 'default' => 0, + 'disp-width' => '10' + ), + 'name' => array( + 'description' => t(''), + 'type' => 'varchar', + 'length' => '48', + 'not null' => TRUE, + 'default' => '' + ), + 'value' => array( + 'description' => t(''), + 'type' => 'text', + 'size' => 'big', + 'not null' => TRUE, + 'default' => '' + ) + ), + 'primary key' => array('env_id', 'name'), + ); + + $schema['faceted_search_filters'] = array( + 'description' => t(''), + 'fields' => array( + 'env_id' => array( + 'description' => t(''), + 'type' => 'int', + 'unsigned' => TRUE, + 'not null' => TRUE, + 'default' => 0, + 'disp-width' => '10' + ), + 'filter_key' => array( + 'description' => t(''), + 'type' => 'varchar', + 'length' => '32', + 'not null' => TRUE, + 'default' => '' + ), + 'filter_id' => array( + 'description' => t(''), + 'type' => 'varchar', + 'length' => '32', + 'not null' => TRUE, + 'default' => '' + ), + 'status' => array( + 'description' => t(''), + 'type' => 'int', + 'not null' => TRUE, + 'default' => 0, + 'disp-width' => '11' + ), + 'weight' => array( + 'description' => t(''), + 'type' => 'int', + 'not null' => TRUE, + 'default' => 0, + 'disp-width' => '11' + ), + 'sort' => array( + 'description' => t(''), + 'type' => 'varchar', + 'length' => '32', + 'not null' => TRUE, + 'default' => '' + ), + 'max_categories' => array( + 'description' => t(''), + 'type' => 'int', + 'not null' => TRUE, + 'default' => 0, + 'disp-width' => '11' + ) + ), + 'primary key' => array('env_id', 'filter_key', 'filter_id'), + 'indexes' => array( + 'status' => array('status') + ), + ); + + return $schema; +} + + +/** * Implementation of hook_install(). */ function faceted_search_install() { - switch ($GLOBALS['db_type']) { - case 'mysql': - case 'mysqli': - db_query("CREATE TABLE {faceted_search_filters} ( - env_id int(10) unsigned NOT NULL default '0', - filter_key varchar(32) NOT NULL default '', - filter_id varchar(32) NOT NULL default '', - status int(11) NOT NULL default '0', - weight int(11) NOT NULL default '0', - sort varchar(32) NOT NULL default '', - max_categories int(11) NOT NULL default '0', - PRIMARY KEY (env_id, filter_key, filter_id), - KEY status (status) - ) /*!40100 DEFAULT CHARACTER SET UTF8 */ "); - - db_query("CREATE TABLE {faceted_search_variables} ( - env_id int(10) unsigned NOT NULL default '0', - name varchar(48) NOT NULL default '', - value longtext NOT NULL default '', - PRIMARY KEY (env_id, name) - ) /*!40100 DEFAULT CHARACTER SET UTF8 */ "); - break; - - case 'pgsql': - db_query("CREATE TABLE {faceted_search_filters} ( - env_id int_unsigned NOT NULL default '0', - filter_key varchar(32) NOT NULL default '', - filter_id varchar(32) NOT NULL default '', - status smallint NOT NULL default '0', - weight smallint NOT NULL default '0', - sort varchar(32) NOT NULL default '', - max_categories int NOT NULL default '0', - PRIMARY KEY (env_id, filter_key, filter_id) - )"); - db_query("CREATE INDEX {faceted_search_filters}_status_idx ON {faceted_search_filters} (status)"); - - db_query("CREATE TABLE {faceted_search_variables} ( - env_id int_unsigned NOT NULL default '0', - name varchar(48) NOT NULL default '', - value text NOT NULL default '', - PRIMARY KEY (env_id, name) - )"); - break; - } + drupal_install_schema('faceted_search'); } /** * Implementation of hook_uninstall(). */ function faceted_search_uninstall() { - db_query('DROP TABLE {faceted_search_filters}'); - db_query('DROP TABLE {faceted_search_variables}'); + drupal_uninstall_schema('faceted_search'); } /** @@ -85,7 +138,7 @@ function faceted_search_update_1() { ) /*!40100 DEFAULT CHARACTER SET UTF8 */ "); // Move settings - $env_id = db_next_id('{faceted_search}_env_id'); // Adding new environment. + $env_id = db_last_insert_id('{faceted_search}_env_id'); // Adding new environment. $display_settings = variable_get('faceted_search_display', array()); // Old settings. foreach ($display_settings as $key => $settings) { $matches = array(); @@ -134,16 +187,12 @@ function faceted_search_update_2() { */ function faceted_search_update_3() { $ret = array(); - switch ($GLOBALS['db_type']) { - case 'mysql': - case 'mysqli': $ret[] = update_sql("ALTER TABLE {faceted_search_facets} RENAME TO {faceted_search_filters}, CHANGE COLUMN facet_key filter_key varchar(32) NOT NULL default '', CHANGE COLUMN facet_id filter_id varchar(32) NOT NULL default '', DROP PRIMARY KEY, ADD PRIMARY KEY (env_id, filter_key, filter_id)"); - break; - } + return $ret; } Index: ../faceted_search/faceted_search.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/faceted_search/faceted_search.module,v retrieving revision 1.42 diff -u -p -r1.42 faceted_search.module --- ../faceted_search/faceted_search.module 29 May 2008 21:08:56 -0000 1.42 +++ ../faceted_search/faceted_search.module 11 Jun 2008 07:16:11 -0000 @@ -16,8 +16,8 @@ $_faceted_search_variables = array(); /** * Implementation of hook_help(). */ -function faceted_search_help($section) { - switch ($section) { +function faceted_search_help($path, $arg) { + switch ($path) { case 'admin/help#faceted_search': return '
'. t('A faceted search interface allows users to browse content in such a way that they can rapidly get acquainted with the scope and nature of the content without ever feeling lost. Such system relies on metadata (such as !categories) usually built specifically for !classification.', array('!categories' => l(t('categories'), 'admin/help/taxonomy'), '!classification' => l(t('faceted classification'), 'http://en.wikipedia.org/wiki/Faceted_classification'))) .'
'. t('Introductory information is provided in !article about when to use — and how to build — a faceted classification.', array('!article' => l(t('this article'), 'http://www.miskatonic.org/library/facet-web-howto.html'))) .'
'; } @@ -26,51 +26,46 @@ function faceted_search_help($section) { /** * Implementation of hook_menu(). */ -function faceted_search_menu($may_cache) { +function faceted_search_menu() { $items = array(); - if ($may_cache) { - $items[] = array( - 'path' => 'admin/settings/faceted_search', - 'title' => t('Faceted search'), - 'callback' => 'faceted_search_list_page', - 'access' => user_access('administer site configuration'), // TODO: have an 'administer faceted search' permission. - 'description' => t('Administer faceted search environments.'), - 'type' => MENU_NORMAL_ITEM, - ); - $items[] = array( - 'path' => 'admin/settings/faceted_search/list', - 'title' => t('List'), - 'weight' => -10, - 'callback' => 'faceted_search_list_page', - 'access' => user_access('administer site configuration'), - 'type' => MENU_DEFAULT_LOCAL_TASK, - ); - $items[] = array( - 'path' => 'admin/settings/faceted_search/add', - 'title' => t('Add environment'), - 'callback' => 'faceted_search_add_page', - 'access' => user_access('administer site configuration'), - 'type' => MENU_LOCAL_TASK, - ); - foreach (faceted_search_get_env_ids() as $env_id) { - $items[] = array( - 'path' => 'admin/settings/faceted_search/delete/'. $env_id, - 'callback' => 'drupal_get_form', - 'callback arguments' => array('faceted_search_delete_form', $env_id), - 'access' => user_access('administer site configuration'), - 'type' => MENU_CALLBACK, - ); - $items[] = array( - 'path' => 'admin/settings/faceted_search/'. $env_id, - 'title' => t('Faceted search environment: @env', array('@env' => faceted_search_variable_get($env_id, 'name', $env_id))), - 'callback' => 'drupal_get_form', - 'callback arguments' => array('faceted_search_edit_form', $env_id), - 'access' => user_access('administer site configuration'), - 'type' => MENU_CALLBACK, - ); - } - } - + $items['admin/settings/faceted_search'] = array( + 'title' => 'Faceted search', + 'page callback' => 'faceted_search_list_page', + 'access callback' => 'user_access', + 'access arguments' => array('administer site configuration'), // TODO: have an 'administer faceted search' permission. + 'description' => 'Administer faceted search environments.', + 'type' => MENU_NORMAL_ITEM, + ); + $items['admin/settings/faceted_search/list'] = array( + 'title' => 'List', + 'weight' => -10, + 'page callback' => 'faceted_search_list_page', + 'access callback' => 'user_access', + 'access arguments' => array('administer site configuration'), + 'type' => MENU_DEFAULT_LOCAL_TASK, + ); + $items['admin/settings/faceted_search/add'] = array( + 'title' => 'Add environment', + 'page callback' => 'faceted_search_add_page', + 'access callback' => 'user_access', + 'access arguments' => array('administer site configuration'), + 'type' => MENU_LOCAL_TASK, + ); + + $items['admin/settings/faceted_search/delete/%'] = array( + 'page callback' => 'drupal_get_form', + 'page arguments' => array('faceted_search_delete_form', 2), + 'access arguments' => array('administer site configuration'), + 'type' => MENU_CALLBACK, + ); + $items['admin/settings/faceted_search/%'] = array( + 'load arguments' => array(4), + 'page callback' => 'drupal_get_form', + 'page arguments' => array('faceted_search_edit_form', 3), + 'access arguments' => array('administer site configuration'), + 'type' => MENU_CALLBACK, + ); + return $items; } @@ -189,16 +184,16 @@ function faceted_search_delete_form($env /** * Handle the submit button to delete an environment. */ -function faceted_search_delete_form_submit($form_id, $form_values) { - $env = faceted_search_variable_get($form_values['env_id'], 'name', $form_values['env_id']); +function faceted_search_delete_form_submit($form, &$form_state) { + $env = faceted_search_variable_get($form_state['values']['env_id'], 'name', $form_state['values']['env_id']); - faceted_search_variable_del_all($form_values['env_id']); - db_query('DELETE FROM {faceted_search_filters} WHERE env_id = %d', $form_values['env_id']); + faceted_search_variable_del_all($form_state['values']['env_id']); + db_query('DELETE FROM {faceted_search_filters} WHERE env_id = %d', $form_state['values']['env_id']); menu_rebuild(); drupal_set_message(t('Faceted search environment %env deleted.', array('%env' => $env))); - return 'admin/settings/faceted_search'; + $form_state['redirect'] = 'admin/settings/faceted_search'; } /** @@ -207,7 +202,8 @@ function faceted_search_delete_form_subm * @param $env_id * The id of the environment to edit, or null if adding a new one. */ -function faceted_search_edit_form($env_id = NULL) { +function faceted_search_edit_form($form_state, $env_id = NULL) { + drupal_set_title(t('Faceted search environment: @env', array('@env' => faceted_search_variable_get($env_id, 'name', $env_id)))); if (isset($env_id)) { $form['env_id'] = array( '#type' => 'value', @@ -272,7 +268,7 @@ function faceted_search_edit_form($env_i '#theme' => 'faceted_search_facets_settings', '#tree' => TRUE, ); - + // Gather every possible facet. $all_settings = faceted_search_load_filter_settings($env_id, TRUE); $facets = array(); @@ -339,24 +335,26 @@ function faceted_search_edit_form($env_i /** * Validation callback for the environment edit form. */ -function faceted_search_edit_form_validate($form_id, $form_values) { +function faceted_search_edit_form_validate($form, &$form_state) { // Name must be alphanumeric or underscores, no other punctuation. - if (preg_match('/[^a-zA-Z0-9_]/', $form_values['name'])) { + if (preg_match('/[^a-zA-Z0-9_]/', $form_state['values']['name'])) { form_set_error('name', t('Name must be alphanumeric or underscores only.')); } // Name must be unique. - if (db_result(db_query("SELECT COUNT(*) FROM {faceted_search_variables} WHERE name = 'name' AND value = '%s' AND env_id != %d", serialize($form_values['name']), isset($form_values['env_id']) ? $form_values['env_id'] : 0)) > 0) { - form_set_error('name', t('Name %name already in use.', array('%name' => $form_values['name']))); + if (db_result(db_query("SELECT COUNT(*) FROM {faceted_search_variables} WHERE name = 'name' AND value = '%s' AND env_id <> %d", serialize($form_state['values']['name']), isset($form_state['values']['env_id']) ? $form_state['values']['env_id'] : 0)) > 0) { + form_set_error('name', t('Name %name already in use.', array('%name' => $form_state['values']['name']))); } // Weights must be numeric. - foreach ($form_values['facets'] as $key => $settings) { - if (!is_numeric($settings['weight'])) { - form_set_error("facets][$key][weight", t('Weight must be a numeric value.')); + if($form_state['values']['facets']) { + foreach ($form_state['values']['facets'] as $key => $settings) { + if (!is_numeric($settings['weight'])) { + form_set_error("facets][$key][weight", t('Weight must be a numeric value.')); + } } } - foreach ($form_values['keyword_filters'] as $key => $settings) { + foreach ($form_state['values']['keyword_filters'] as $key => $settings) { if (!is_numeric($settings['weight'])) { form_set_error("keyword_filters][$key][weight", t('Weight must be a numeric value.')); } @@ -366,37 +364,42 @@ function faceted_search_edit_form_valida /** * Form callback for saving environment data. */ -function faceted_search_edit_form_submit($form_id, $form_values) { - if (isset($form_values['env_id'])) { - $env_id = $form_values['env_id']; +function faceted_search_edit_form_submit($form, &$form_state) { + if (isset($form_state['values']['env_id'])) { + $env_id = $form_state['values']['env_id']; } else { - $env_id = db_next_id('{faceted_search}_env_id'); // Adding new environment. + $ids = faceted_search_get_env_ids(); + sort($ids); + $env_id = $ids[0] + 1; + //$env_id = db_last_insert_id('faceted_search_filters','env_id'); // Adding new environment. } // Exclude elements that should not be saved as environment variables. $exclude = array('save', 'save_and_edit', 'form_id', 'op', 'form_token', 'env_id', 'facets', 'keyword_filters'); // Save form values as environment variables (except those excluded). - foreach ($form_values as $key => $value) { + foreach ($form_state['values'] as $key => $value) { if (!in_array($key, $exclude)) { faceted_search_variable_set($env_id, $key, $value); } } // Save filter settings. - faceted_search_save_filter_settings($env_id, array_merge($form_values['facets'], $form_values['keyword_filters'])); + if($form_state['values']['facets']) { + faceted_search_save_filter_settings($env_id, array_merge($form_state['values']['facets'], $form_state['values']['keyword_filters'])); + } // Rebuild the menus, if only for updating titles. menu_rebuild(); - drupal_set_message(t('The faceted search environment %env has been saved.', array('%env' => $form_values['name']))); + drupal_set_message(t('The faceted search environment %env has been saved.', array('%env' => $form_state['values']['name']))); - if ($form_values['op'] == t('Save')) { - return 'admin/settings/faceted_search'; + if ($form_state['values']['op'] == t('Save')) { + $form_state['redirect'] = 'admin/settings/faceted_search'; } else { - return 'admin/settings/faceted_search/'. $env_id; + $form_state['redirect'] = 'admin/settings/faceted_search'. $env_id; } } @@ -456,13 +459,14 @@ function _faceted_search_variables_init( * The value of the variable. */ function faceted_search_variable_get($env_id, $name, $default) { + global $_faceted_search_variables; if (!isset($_faceted_search_variables)) { _faceted_search_variables_init(); } - return isset($_faceted_search_variables[$env_id][$name]) ? $_faceted_search_variables[$env_id][$name] : $default; + return $_faceted_search_variables[$env_id][$name] ? $_faceted_search_variables[$env_id][$name] : $default ; } /** @@ -745,6 +749,30 @@ function faceted_search_prepare_filters( } } +function faceted_search_theme() { + return array( + 'faceted_search_facets_settings' => array( + 'arguments' => array('form' => NULL), + ), + 'faceted_search_keyword_filters_settings' => array( + 'arguments' => array('form' => NULL), + ), + 'faceted_search_keyword_and_label' => array( + 'arguments' => array('keyword' => NULL), + ), + 'faceted_search_keyword_phrase_label' => array( + 'arguments' => array('phrase' => NULL), + ), + 'faceted_search_keyword_or_label' => array( + 'arguments' => array('keywords' => NULL), + ), + 'faceted_search_keyword_not_label' => array( + 'arguments' => array('keyword' => NULL), + ), + ); +} + + function theme_faceted_search_facets_settings($form) { uasort($form, '_element_sort'); @@ -968,3 +996,15 @@ function _faceted_search_compare_filters return ($a->get_weight() < $b->get_weight()) ? -1 : 1; } +/** + * Function used by uasort in drupal_render() to sort structured arrays + * by weight. + */ +function _element_sort($a, $b) { + $a_weight = (is_array($a) && isset($a['#weight'])) ? $a['#weight'] : 0; + $b_weight = (is_array($b) && isset($b['#weight'])) ? $b['#weight'] : 0; + if ($a_weight == $b_weight) { + return 0; + } + return ($a_weight < $b_weight) ? -1 : 1; +} Index: ../faceted_search/faceted_search_ui.info =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/faceted_search/faceted_search_ui.info,v retrieving revision 1.4 diff -u -p -r1.4 faceted_search_ui.info --- ../faceted_search/faceted_search_ui.info 15 Nov 2007 23:32:19 -0000 1.4 +++ ../faceted_search/faceted_search_ui.info 11 Jun 2008 07:16:11 -0000 @@ -1,6 +1,9 @@ ; $Id: faceted_search_ui.info,v 1.4 2007/11/15 23:32:19 davidlesieur Exp $ name = Faceted Search UI description = "User interface for searching and browsing through multiple facets." -dependencies = faceted_search search +dependencies[] = faceted_search +dependencies[] = search package = Faceted Search +core = 6.x +version = 6.2 Index: ../faceted_search/faceted_search_ui.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/faceted_search/faceted_search_ui.module,v retrieving revision 1.74 diff -u -p -r1.74 faceted_search_ui.module --- ../faceted_search/faceted_search_ui.module 29 May 2008 21:08:56 -0000 1.74 +++ ../faceted_search/faceted_search_ui.module 11 Jun 2008 07:16:13 -0000 @@ -25,46 +25,40 @@ function faceted_search_ui_perm() { /** * Implementation of hook_menu(). */ -function faceted_search_ui_menu($may_cache) { +function faceted_search_ui_menu() { $items = array(); - if ($may_cache) { - foreach (faceted_search_get_env_ids() as $env_id) { - $base_path = faceted_search_variable_get($env_id, 'base_path', ''); - $items[] = array( - 'path' => $base_path, - 'title' => check_plain(faceted_search_variable_get($env_id, 'title', t('Search'))), // Needed for breadcrumb. - 'callback' => 'faceted_search_ui_stage_select', - 'callback arguments' => array($env_id), - 'access' => user_access('use faceted search'), - 'type' => MENU_CALLBACK, - ); - $items[] = array( - 'path' => $base_path .'/results', - 'callback' => 'faceted_search_ui_stage_results', - 'callback arguments' => array($env_id), - 'access' => user_access('use faceted search'), - 'type' => MENU_CALLBACK, - ); - $items[] = array( - 'path' => $base_path .'/facet', - 'callback' => 'faceted_search_ui_stage_facet', - 'callback arguments' => array($env_id), - 'access' => user_access('use faceted search'), - 'type' => MENU_CALLBACK, - ); - $items[] = array( - 'path' => $base_path .'/categories', - 'callback' => 'faceted_search_ui_stage_categories', - 'callback arguments' => array($env_id), - 'access' => user_access('use faceted search'), - 'type' => MENU_CALLBACK, - ); - } - - // TODO: Per-environment access control setting (à la Views). Then, will no - // longer need the 'use faceted search' permission. + foreach (faceted_search_get_env_ids() as $env_id) { + $base_path = faceted_search_variable_get($env_id, 'base_path', ''); + $items[$base_path] = array( + 'title' => check_plain(faceted_search_variable_get($env_id, 'title', 'Search')), // Needed for breadcrumb. + 'page callback' => 'faceted_search_ui_stage_select', + 'page arguments' => array($env_id), + 'access arguments' => array('use faceted search'), + 'type' => MENU_CALLBACK, + ); + $items[$base_path .'/results'] = array( + 'page callback' => 'faceted_search_ui_stage_results', + 'page arguments' => array($env_id), + 'access arguments' => array('use faceted search'), + 'type' => MENU_CALLBACK, + ); + $items[$base_path .'/facet'] = array( + 'page callback' => 'faceted_search_ui_stage_facet', + 'page arguments' => array($env_id), + 'access arguments' => array('use faceted search'), + 'type' => MENU_CALLBACK, + ); + $items[$base_path .'/categories'] = array( + 'page callback' => 'faceted_search_ui_stage_categories', + 'page arguments' => array($env_id), + 'access arguments' => array('use faceted search'), + 'type' => MENU_CALLBACK, + ); } - + + // TODO: Per-environment access control setting (à la Views). Then, will no + // longer need the 'use faceted search' permission. + return $items; } @@ -145,7 +139,7 @@ function faceted_search_ui_block($op = ' /** * Implementation of hook_form_alter(). */ -function faceted_search_ui_form_alter($form_id, &$form) { +function faceted_search_ui_form_alter(&$form, &$form_state, $form_id) { if ($form_id == 'faceted_search_edit_form') { $env_id = $form['env_id']['#value']; @@ -327,7 +321,7 @@ function faceted_search_ui_stage_results if ($text) { // Log the search text. $path = faceted_search_ui_build_path($env_id, $_faceted_search[$env_id]->ui_state, $text); - watchdog('faceted_search', t('%text.', array('%text' => $text)), WATCHDOG_NOTICE, l(t('results'), $path)); + watchdog('faceted_search', '%text.', array('%text' => $text), WATCHDOG_NOTICE, l(t('results'), $path)); } faceted_search_ui_add_robots_directive($_faceted_search[$env_id]); @@ -693,7 +687,7 @@ function faceted_search_ui_set_title($se /** * Render the search form. */ -function faceted_search_ui_form($search) { +function faceted_search_ui_form($form_state, $search) { $ui_state = $search->ui_state; $current_stage = $ui_state['stage']; @@ -846,50 +840,50 @@ function faceted_search_ui_form($search) /** * Process a search form submission. */ -function faceted_search_ui_form_submit($form_id, $form_values) { +function faceted_search_ui_form_submit($form, &$form_state) { $new_text = ''; - switch ($form_values['operator']) { + switch ($form_state['values']['operator']) { // The following cases are based on node_search_validate(). case 'and': - if (preg_match_all('/ ("[^"]+"|[^" ]+)/i', ' '. $form_values['keywords'], $matches)) { + if (preg_match_all('/ ("[^"]+"|[^" ]+)/i', ' '. $form_state['values']['keywords'], $matches)) { $new_text = implode(' ', $matches[1]); } break; case 'or': - if (preg_match_all('/ ("[^"]+"|[^" ]+)/i', ' '. $form_values['keywords'], $matches)) { + if (preg_match_all('/ ("[^"]+"|[^" ]+)/i', ' '. $form_state['values']['keywords'], $matches)) { $new_text = implode(' OR ', $matches[1]); } break; case 'not': - if (preg_match_all('/ ("[^"]+"|[^" ]+)/i', ' '. $form_values['keywords'], $matches)) { + if (preg_match_all('/ ("[^"]+"|[^" ]+)/i', ' '. $form_state['values']['keywords'], $matches)) { $new_text = '-'. implode(' -', $matches[1]); } break; case 'phrase': - $new_text .= ' "'. str_replace('"', ' ', $form_values['keywords']) .'"'; + $new_text .= ' "'. str_replace('"', ' ', $form_state['values']['keywords']) .'"'; break; } - if ($new_text != '' && $form_values['field'] != 'node') { + if ($new_text != '' && $form_state['values']['field'] != 'node') { $escape_char = variable_get('faceted_search_escape_char', '\\'); - $new_text = $form_values['field'] .':"'. faceted_search_quoted_query_escape($new_text) .'"'; + $new_text = $form_state['values']['field'] .':"'. faceted_search_quoted_query_escape($new_text) .'"'; } - if ($form_values['refine']) { + if ($form_state['values']['refine']) { // Combine pre-exiting text with new one - $text = trim($form_values['text'] .' '. $new_text); + $text = trim($form_state['values']['text'] .' '. $new_text); } else { // Search with new text. $text = $new_text; } - // Define resulting path. Note: $form_values has the same keys as the usual + // Define resulting path. Note: $form_state['values'] has the same keys as the usual // $ui_state argument. - return faceted_search_ui_build_path($form_values['env_id'], $form_values, $text); + return faceted_search_ui_build_path($form_state['values']['env_id'], $form_state['values'], $text); } /** @@ -1112,6 +1106,67 @@ function faceted_search_ui_add_tooltips( } } +function faceted_search_ui_theme() { + return array( + 'faceted_search_ui_page' => array( + 'arguments' => array('search' => NULL, 'content' => NULL), + ), + 'faceted_search_ui_facet_wrapper' => array( + 'arguments' => array('env_id' => NULL, 'facet' => NULL, 'context' => NULL, 'content' => NULL), + ), + 'faceted_search_ui_facet_heading' => array( + 'arguments' => array('env_id' => NULL, 'ui_state' => NULL, 'facets' => NULL, 'index' => NULL, 'context' => NULL, 'show_label' => NULL), + ), + 'faceted_search_ui_categories' => array( + 'arguments' => array('facet' => NULL, 'categories' => NULL, 'stage' => NULL), + ), + 'faceted_search_ui_facet_label' => array( + 'arguments' => array('facets' => NULL, 'index' => NULL, 'label' => NULL), + ), + 'faceted_search_ui_category' => array( + 'arguments' => array('category' => NULL, 'path' => NULL), + ), + 'faceted_search_ui_more' => array( + 'arguments' => array('path' => NULL), + ), + 'faceted_search_ui_remover_link_guided_search' => array( + 'arguments' => array('path' => NULL), + ), + 'faceted_search_ui_remover_link_current_search' => array( + 'arguments' => array('path' => NULL), + ), + 'faceted_search_ui_breadcrumb' => array( + 'arguments' => array('breadcrumb' => NULL), + ), + 'faceted_search_ui_sort_options' => array( + 'arguments' => array('options' => NULL), + ), + 'faceted_search_ui_stage_results' => array( + 'arguments' => array('results' => NULL, 'style' => NULL), + ), + 'faceted_search_ui_stage_select' => array( + 'arguments' => array('search' => NULL, 'keyword_block_content' => NULL, 'guided_block_content' => NULL), + ), + 'faceted_search_ui_stage_facet' => array( + 'arguments' => array('search' => NULL, 'index' => NULL, 'facet' => NULL, 'categories' => NULL), + ), + 'faceted_search_ui_guided_search' => array( + 'arguments' => array('search' => NULL, 'facets' => NULL), + ), + 'faceted_search_ui_related_list_ungrouped' => array( + 'arguments' => array('env_id' => NULL, 'node' => NULL, 'groups' => NULL), + ), + 'faceted_search_ui_related_list_grouped' => array( + 'arguments' => array('env_id' => NULL, 'node' => NULL, 'groups' => NULL), + ), + 'faceted_search_ui_related_table' => array( + 'arguments' => array('env_id' => NULL, 'node' => NULL, 'groups' => NULL), + ), + ); +} + + + /** * Render a faceted search page. * @@ -1275,7 +1330,10 @@ function theme_faceted_search_ui_remover function theme_faceted_search_ui_remover_link_current_search($path) { // TODO: nice default icon instead of 'x' - return l('[×]', $path, array('title' => t('Remove this term')), NULL, NULL, FALSE, TRUE); + $options = array(); + $options['html'] = TRUE; + $options['attribute'] = array('title' => t('Remove this term')); + return l('[×]', $path, $options); } function theme_faceted_search_ui_breadcrumb($breadcrumb) { Index: ../faceted_search/faceted_search_views.info =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/faceted_search/faceted_search_views.info,v retrieving revision 1.2 diff -u -p -r1.2 faceted_search_views.info --- ../faceted_search/faceted_search_views.info 22 Apr 2008 17:21:26 -0000 1.2 +++ ../faceted_search/faceted_search_views.info 11 Jun 2008 07:16:13 -0000 @@ -1,5 +1,10 @@ ; $Id: faceted_search_views.info,v 1.2 2008/04/22 17:21:26 davidlesieur Exp $ name = Faceted Search Views description = "Allows to use Views to display Faceted Search results." -dependencies = faceted_search faceted_search_ui search views +dependencies[] = faceted_search +dependencies[] = faceted_search_ui +dependencies[] = search +dependencies[] = views package = Faceted Search +core = 6.x +version = 6.2 Index: ../faceted_search/faceted_search_views.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/faceted_search/faceted_search_views.module,v retrieving revision 1.14 diff -u -p -r1.14 faceted_search_views.module --- ../faceted_search/faceted_search_views.module 20 May 2008 00:15:10 -0000 1.14 +++ ../faceted_search/faceted_search_views.module 11 Jun 2008 07:16:13 -0000 @@ -15,7 +15,8 @@ require_once('./'. drupal_get_path('modu */ function faceted_search_views_faceted_search_ui_style_info() { $styles = array(); - $results = db_query("SELECT v.name FROM {view_view} v INNER JOIN {view_argument} a ON a.vid = v.vid WHERE a.type = 'faceted_search_results' ORDER BY v.name"); + //$results = db_query("SELECT v.name FROM {views_view} v INNER JOIN {views_display} a ON a.vid = v.vid WHERE a.type = 'faceted_search_results' ORDER BY v.name"); + $results = db_query("SELECT v.name FROM {views_view} v INNER JOIN {views_display} a ON a.vid = v.vid ORDER BY v.name"); while ($view = db_fetch_object($results)) { $styles[$view->name] = new faceted_search_views_style($view->name); } Index: ../faceted_search/field_keyword_filter.info =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/faceted_search/field_keyword_filter.info,v retrieving revision 1.2 diff -u -p -r1.2 field_keyword_filter.info --- ../faceted_search/field_keyword_filter.info 29 May 2008 21:55:37 -0000 1.2 +++ ../faceted_search/field_keyword_filter.info 11 Jun 2008 07:16:13 -0000 @@ -1,5 +1,9 @@ ; $Id: field_keyword_filter.info,v 1.2 2008/05/29 21:55:37 davidlesieur Exp $ name = Field Keyword Filter description = "Allows users to perform keyword searches restricted by field." -dependencies = search faceted_search field_indexer -package = Faceted Search \ No newline at end of file +dependencies[] = search +dependencies[] = faceted_search +dependencies[] = field_indexer +package = Faceted Search +core = 6.x +version = 6.2 \ No newline at end of file Index: ../faceted_search/taxonomy_facets.info =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/faceted_search/taxonomy_facets.info,v retrieving revision 1.6 diff -u -p -r1.6 taxonomy_facets.info --- ../faceted_search/taxonomy_facets.info 10 Jan 2008 19:32:59 -0000 1.6 +++ ../faceted_search/taxonomy_facets.info 11 Jun 2008 07:16:13 -0000 @@ -1,6 +1,10 @@ ; $Id: taxonomy_facets.info,v 1.6 2008/01/10 19:32:59 davidlesieur Exp $ name = Taxonomy Facets description = "Provides facets based on taxonomy." -dependencies = taxonomy search faceted_search +dependencies[] = taxonomy +dependencies[] = search +dependencies[] = faceted_search package = Faceted Search +core = 6.x +version = 6.2 Index: ../faceted_search/taxonomy_facets.install =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/faceted_search/taxonomy_facets.install,v retrieving revision 1.11 diff -u -p -r1.11 taxonomy_facets.install --- ../faceted_search/taxonomy_facets.install 23 Apr 2008 14:14:25 -0000 1.11 +++ ../faceted_search/taxonomy_facets.install 11 Jun 2008 07:16:13 -0000 @@ -1,58 +1,74 @@ t(''), + 'fields' => array( + 'nid' => array( + 'description' => t(''), + 'type' => 'int', + 'unsigned' => TRUE, + 'not null' => TRUE, + 'default' => 0, + 'disp-width' => '10' + ), + 'tid' => array( + 'description' => t(''), + 'type' => 'int', + 'unsigned' => TRUE, + 'not null' => TRUE, + 'default' => 0, + 'disp-width' => '10' + ) + ), + 'primary key' => array('tid', 'nid'), + 'indexes' => array( + 'nid' => array('nid'), + 'tid' => array('tid') + ), + ); + $schema['taxonomy_facets_node'] = array( + 'description' => t(''), + 'fields' => array( + 'nid' => array( + 'description' => t(''), + 'type' => 'int', + 'unsigned' => TRUE, + 'not null' => TRUE, + 'default' => 0, + 'disp-width' => '10' + ), + 'changed' => array( + 'description' => t(''), + 'type' => 'int', + 'not null' => TRUE, + 'default' => 0, + 'disp-width' => '11' + ) + ), + 'primary key' => array('nid'), + ); + return $schema; +} + /** * Implementation of hook_install(). */ function taxonomy_facets_install() { - switch ($GLOBALS['db_type']) { - case 'mysql': - case 'mysqli': - // The taxonomy_facets_term_node table is used to store a (nid,tid) pair - // for each term that's associated to a node *and*, unlike the core - // term_node table, all ancestors of those terms. This ensures that - // browsing for any term will also return nodes associated with descendant - // terms. This table is Taxonomy Facets' "index". - db_query("CREATE TABLE {taxonomy_facets_term_node} ( - nid int unsigned NOT NULL default '0', - tid int unsigned NOT NULL default '0', - KEY nid (nid), - KEY tid (tid), - PRIMARY KEY (tid,nid) - ) /*!40100 DEFAULT CHARACTER SET UTF8 */ "); - - // This table is used to mark nodes needing an update (i.e. for refreshing - // the node's associations in the taxonomy_facets_term_node table). The - // 'changed' column stores the timestamp of the node's change. A zero - // timestamp means that no refresh of the node's term associations is needed. - db_query("CREATE TABLE {taxonomy_facets_node} ( - nid int unsigned NOT NULL default '0', - changed int NOT NULL default '0', - PRIMARY KEY (nid) - ) /*!40100 DEFAULT CHARACTER SET UTF8 */ "); - break; - - case 'pgsql': - db_query("CREATE TABLE {taxonomy_facets_term_node} ( - nid int_unsigned NOT NULL default '0', - tid int_unsigned NOT NULL default '0', - PRIMARY KEY (tid,nid) - )"); - db_query("CREATE TABLE {taxonomy_facets_node} ( - nid int_unsigned NOT NULL default '0', - changed int NOT NULL default '0', - PRIMARY KEY (nid) - )"); - break; - } + drupal_install_schema('taxonomy_facets'); } /** * Implementation of hook_uninstall(). */ function taxonomy_facets_uninstall() { - db_query("DROP TABLE {taxonomy_facets_node}"); - db_query("DROP TABLE {taxonomy_facets_term_node}"); + drupal_uninstall_schema('taxonomy_facets'); if (db_table_exists('faceted_search_filters')) { db_query("DELETE FROM {faceted_search_filters} WHERE filter_key = 'taxonomy'"); } Index: ../faceted_search/taxonomy_facets.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/faceted_search/taxonomy_facets.module,v retrieving revision 1.27 diff -u -p -r1.27 taxonomy_facets.module --- ../faceted_search/taxonomy_facets.module 20 May 2008 01:55:00 -0000 1.27 +++ ../faceted_search/taxonomy_facets.module 11 Jun 2008 07:16:15 -0000 @@ -8,7 +8,7 @@ require_once('./'. drupal_get_path('module', 'faceted_search') .'/faceted_search.inc'); -// TODO: Provide indexing status page à la search.module +// TODO: Provide indexing status page � la search.module /** * Implementation of hook_cron(). @@ -27,23 +27,19 @@ function taxonomy_facets_cron() { /** * Implementation of hook_menu(). */ -function taxonomy_facets_menu($may_cache) { +function taxonomy_facets_menu() { $items = array(); - if ($may_cache) { - $items[] = array( - 'path' => 'admin/settings/faceted_search/taxonomy_facets', - 'title' => t('Taxonomy index'), - 'callback' => 'taxonomy_facets_index_page', - 'access' => user_access('administer site configuration'), - 'type' => MENU_LOCAL_TASK, - ); - $items[] = array( - 'path' => 'admin/settings/faceted_search/taxonomy_facets/rebuild', - 'callback' => 'taxonomy_facets_rebuild', - 'access' => user_access('administer site configuration'), - 'type' => MENU_CALLBACK, - ); - } + $items['admin/settings/faceted_search/taxonomy_facets'] = array( + 'title' => 'Taxonomy index', + 'page callback' => 'taxonomy_facets_index_page', + 'access arguments' => array('administer site configuration'), + 'type' => MENU_LOCAL_TASK, + ); + $items['admin/settings/faceted_search/taxonomy_facets/rebuild'] = array( + 'page callback' => 'taxonomy_facets_rebuild', + 'access arguments' => array('administer site configuration'), + 'type' => MENU_CALLBACK, + ); return $items; }