View source
<?php
define('FACETAPI_TEST_FORM_TEXT', t('Facet API test form'));
function facetapi_test_menu() {
$items = array();
$items['admin/config/search/facetapi_test'] = array(
'title' => 'Facet API test',
'description' => 'Settings for the Facet API module.',
'page callback' => 'drupal_get_form',
'page arguments' => array(
'facetapi_test_admin_settings',
),
'access arguments' => array(
'administer search',
),
);
$items['admin/config/search/facetapi_test/settings'] = array(
'title' => 'Settings',
'weight' => -10,
'type' => MENU_DEFAULT_LOCAL_TASK,
);
$items['facetapi_test/search'] = array(
'title' => 'Search',
'description' => 'Fake search page callback.',
'page callback' => 'facetapi_test_search_callback',
'access arguments' => array(
'access content',
),
'type' => MENU_NORMAL_ITEM,
);
return $items;
}
function facetapi_test_ctools_plugin_api($owner, $api) {
if ($owner == 'current_search' && $api == 'current_search') {
return array(
'version' => 1,
);
}
}
function facetapi_test_facetapi_searcher_info() {
$info = array();
$info['facetapi_test'] = array(
'label' => t('Facet API Test'),
'adapter' => 'facetapi_test',
'types' => array(
'test',
),
'path' => 'admin/config/search/facetapi_test',
'supports facet missing' => FALSE,
);
$info['facetapi_test2'] = array(
'label' => t('Facet API Seond Searcher'),
'adapter' => 'facetapi_test',
'types' => array(
'test',
),
'supports facet missing' => FALSE,
);
return $info;
}
function facetapi_test_facetapi_translate_string($name, $string, $langcode = NULL) {
return serialize(array(
'name' => $name,
'string' => $string,
'langcode' => (string) $langcode,
'return' => 'translated',
));
}
function facetapi_test_admin_settings($form, &$form_state) {
$form['text'] = array(
'#markup' => FACETAPI_TEST_FORM_TEXT,
);
return $form;
}
function facetapi_test_facetapi_facet_info($searcher_info) {
$facets = array();
if ('test' == $searcher_info['type']) {
$facets['enabled'] = array(
'label' => t('Enabled facet'),
'description' => t('Facet that tests enabling.'),
'dependency plugins' => array(
'role',
),
);
$facets['disabled'] = array(
'label' => t('Disabled facet'),
'description' => t('Facet that tests disabling.'),
'dependency plugins' => array(
'role',
),
);
$facets['colon:test'] = array(
'label' => t('Colon test'),
'description' => t('Test facets names with colons.'),
'dependency plugins' => array(
'role',
),
);
$facets['defaults'] = array(
'label' => t('Default test'),
'description' => t('Tests query type and operator defaults stored in settings.'),
'dependency plugins' => array(
'role',
),
'query types' => array(
'nonterm',
),
'default widget' => 'nonterm',
'allowed operators' => array(
FACETAPI_OPERATOR_AND => FALSE,
FACETAPI_OPERATOR_OR => TRUE,
),
);
$facets['hierarchical'] = array(
'label' => t('Hierarchical test'),
'description' => t('Test hierarchical facets.'),
'dependency plugins' => array(
'role',
),
'hierarchy callback' => 'facetapi_test_process_hierarchy',
);
}
return $facets;
}
function facetapi_test_process_hierarchy(array $values) {
}
function facetapi_test_search_callback() {
$build = array();
if (!($adapter = facetapi_adapter_load('facetapi_test'))) {
throw new Exception(t('Error loading adapter.'));
}
if (isset($_GET['count'])) {
$adapter
->setResultCount((int) $_GET['count']);
}
$query = new stdClass();
$adapter
->addActiveFilters($query);
$keys = isset($_GET['keys']) ? $_GET['keys'] : arg(2);
$adapter
->setSearchKeys($keys);
$build['placeholder'] = array(
'#markup' => t('Placeholder'),
);
return $build;
}