You are here

function apachesolr_mlt_save_block in Apache Solr Search 6

Same name and namespace in other branches
  1. 5.2 apachesolr.admin.inc \apachesolr_mlt_save_block()
  2. 5 contrib/apachesolr_mlt/apachesolr_mlt.module \apachesolr_mlt_save_block()
  3. 6.2 apachesolr.admin.inc \apachesolr_mlt_save_block()

A helper function to save MLT block data.

If passed a block delta, the function will update block settings. If it is not passed a block delta, the function will create a new block.

Parameters

array $block_settings An array containing the settings required to form: a moreLikeThis request.

int $delta The id of the block you wish to update.:

4 calls to apachesolr_mlt_save_block()
apachesolr_block in ./apachesolr.module
Implementation of hook_block().
apachesolr_install in ./apachesolr.install
Implementation of hook_install().
apachesolr_mlt_add_block_form_submit in ./apachesolr.admin.inc
apachesolr_update_6004 in ./apachesolr.install
Subsume MLT functionality..

File

./apachesolr.admin.inc, line 672
Administrative pages for the Apache Solr framework.

Code

function apachesolr_mlt_save_block($block_settings = array(), $delta = NULL) {
  $blocks = variable_get('apachesolr_mlt_blocks', array());
  if (is_null($delta)) {
    $count = 0;
    ksort($blocks);

    // Construct a new array key.
    if (end($blocks)) {
      list(, $count) = explode('-', key($blocks));
    }
    $delta = sprintf('mlt-%03d', 1 + $count);
  }
  $defaults = apachesolr_mlt_block_defaults();

  // Remove stray form values.
  $blocks[$delta] = array_intersect_key($block_settings, $defaults) + $defaults;

  // Eliminate non-selected fields.
  $blocks[$delta]['mlt_fl'] = array_filter($blocks[$delta]['mlt_fl']);
  variable_set('apachesolr_mlt_blocks', $blocks);
}