You are here

function sarnia_schema_rule_list in Sarnia 7

1 call to sarnia_schema_rule_list()
sarnia_schema_page in ./sarnia.rules.inc
Faux menu router, since this admin page is nested too deeply in the menu.

File

./sarnia.rules.inc, line 15

Code

function sarnia_schema_rule_list($search_api_server) {
  $render = array();
  $render['help'] = array(
    '#type' => 'markup',
    '#markup' => '<p>' . t("This section can help configure the behavior of your Solr properties. Because the behavior of Solr properties is determined by a particular Solr core's <code>schema.xml</code> file, a particular Solr setup may customize property names, dynamic bases for aggregation, or property type names.") . '</p>' . '<p>' . t("Configuration on this page is not necessary; Sarnia can determine which properties are technically available for display, filter search, fulltext search, or sort. However, if you find that some properties are available to Sarnia Views handlers in the Views UI where they do not make sense, configuring the schema rules can help refine properties' behavior.") . '</p>' . '<p>' . t("Properties may be disabled, or may be replaced with another property. Disabling a property is useful for things like preventing sorting on fulltext search fields (which yield unpredicatble sort orders) or preventing the display of aggregated fields; replacing a property allows you to associate a sortable property with a displayable property, which makes click-sorting available on Views fields. These adjustments are not relevant to the end user, but they may be useful for sitebuilders working with Views who are not intimately familiar with the particulars of Solr.") . '</p>' . '<p>' . t("Sarnia comes with a basic set of rules which support some <code>schema.xml</code> conventions. These may be removed or overridden for a particular Search API server.") . '</p>',
  );
  $behavior_labels = array(
    'display' => t('display'),
    'filter' => t('filter search'),
    'fulltext' => t('fulltext search'),
    'sort' => t('sort'),
  );

  // Generate sections for each behavior.
  foreach ($behavior_labels as $key => $label) {
    $render[$key]['list'] = array(
      '#title' => ucfirst($label),
      '#theme' => 'item_list',
      '#items' => array(),
    );
  }

  // Generate a text description for each rule, and place the rule in a behavior section.
  $rules = sarnia_sarnia_solr_service_schema(array(
    'search_api_server' => array(
      '',
      $search_api_server->machine_name,
    ),
    'enabled' => TRUE,
  ));
  foreach ($rules as $rule) {
    $render[$rule->behavior]['list']['#items'][] = _sarnia_get_rule_text($rule);
  }

  // Add a 'more details' link to each section.
  foreach (element_children($render) as $key) {
    $render[$key]['list']['#items'][] = l(t('more details'), 'admin/config/search/search_api/server/' . $search_api_server->machine_name . '/sarnia/schema/' . $key);
  }
  return $render;
}