summaryrefslogtreecommitdiffstats
path: root/apachesolr_context_conditions.module
blob: 0a13cf2d0ebc3d28f505f950a6fb666c5970f3f8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php

/**
 * Implements hook_context_plugins.
 */
function apachesolr_context_conditions_context_plugins() {
  $plugins = array();
  $plugins['apachesolr_context_conditions_context_condition_max_results'] = array(
    'handler' => array(
      'path' => drupal_get_path('module', 'apachesolr_context_conditions') .'/plugins',
      'file' => 'apachesolr_context_conditions_context_condition_max_results.inc',
      'class' => 'apachesolr_context_conditions_context_condition_max_results',
      'parent' => 'context_condition',
    ),
  );
  return $plugins;
}

/**
 * Implements hook_context_registry.
 */
function apachesolr_context_conditions_context_registry() {
  return array(
    'conditions' => array(
      'apachesolr_max_results' => array(
        'title' => t('Apache Solr - Max results'),
        'plugin' => 'apachesolr_context_conditions_context_condition_max_results',
      ),
    ),
  );
}

/**
 * Implements hook_apachesolr_process_results
 */
function apachesolr_context_conditions_apachesolr_process_results($results, $query) {
  if ($plugin = context_get_plugin('condition', 'apachesolr_max_results')) {
    $plugin->execute(count($results));
  }
}