You are here

function recommender_default_view_template in Recommender API 6.3

Same name and namespace in other branches
  1. 7.3 recommender.module \recommender_default_view_template()
  2. 7.4 recommender.module \recommender_default_view_template()
  3. 7.5 recommender.module \recommender_default_view_template()

Provide default views template for helper modules. Helper modules can choose either to use "export views" or use this function to generate default views.

Parameters

$view_name:

$view_description:

$base_table either recommender_similarity or recommender_prediction.:

$base_entity_type usually either 'node' or 'users':

$base_entity_field if 'node' then 'title', if 'users' then 'name':

$argument_type either 'node' or 'current_user':

$app_name:

Return value

\view

File

./recommender.module, line 213
Providing generic recommender system algorithms.

Code

function recommender_default_view_template($view_name, $view_description, $base_table, $base_entity_type, $base_entity_field, $argument_type, $app_name) {
  $view = new view();
  $view->name = $view_name;
  $view->description = $view_description;
  $view->tag = 'recommendation';
  $view->view_php = '';
  $view->base_table = $base_table;
  $view->is_cacheable = TRUE;
  $view->api_version = 2;
  $view->disabled = FALSE;

  /* Edit this to true to make a default view disabled initially */
  $handler = $view
    ->new_display('default', 'Defaults', 'default');
  $handler
    ->override_option('relationships', array(
    'target_eid' => array(
      'label' => 'Recommended entity',
      'required' => 1,
      'base_entity_type' => $base_entity_type,
      'id' => 'target_eid',
      'table' => $base_table,
      'field' => 'target_eid',
      'relationship' => 'none',
    ),
  ));
  $handler
    ->override_option('fields', array(
    'title' => array(
      'label' => '',
      'alter' => array(
        'alter_text' => 0,
        'text' => '',
        'make_link' => 0,
        'path' => '',
        'link_class' => '',
        'alt' => '',
        'prefix' => '',
        'suffix' => '',
        'target' => '',
        'help' => '',
        'trim' => 0,
        'max_length' => '',
        'word_boundary' => 1,
        'ellipsis' => 1,
        'html' => 0,
        'strip_tags' => 0,
      ),
      'empty' => '',
      'hide_empty' => 1,
      'empty_zero' => 0,
      'link_to_node' => 1,
      'exclude' => 0,
      'id' => $base_entity_field,
      'table' => $base_entity_type,
      'field' => $base_entity_field,
      'relationship' => 'target_eid',
    ),
  ));
  $handler
    ->override_option('sorts', array(
    'score' => array(
      'order' => 'DESC',
      'id' => 'score',
      'table' => $base_table,
      'field' => 'score',
      'relationship' => 'none',
    ),
  ));
  $handler
    ->override_option('arguments', array(
    'source_eid' => array(
      'default_action' => 'default',
      'style_plugin' => 'default_summary',
      'style_options' => array(),
      'wildcard' => 'all',
      'wildcard_substitution' => 'All',
      'title' => '',
      'breadcrumb' => '',
      'default_argument_type' => $argument_type,
      'default_argument' => '',
      'validate_type' => 'none',
      'validate_fail' => 'not found',
      'break_phrase' => 0,
      'not' => 0,
      'id' => 'source_eid',
      'table' => $base_table,
      'field' => 'source_eid',
      'validate_user_argument_type' => 'uid',
      'validate_user_roles' => array(
        '2' => 0,
      ),
      'relationship' => 'none',
      'default_options_div_prefix' => '',
      'default_argument_fixed' => '',
      'default_argument_user' => 0,
      'default_argument_php' => '',
      'validate_argument_node_type' => array(
        'example_node_type_1' => 0,
        'page' => 0,
        'story' => 0,
      ),
      'validate_argument_node_access' => 0,
      'validate_argument_nid_type' => 'nid',
      'validate_argument_vocabulary' => array(),
      'validate_argument_type' => 'tid',
      'validate_argument_transform' => 0,
      'validate_user_restrict_roles' => 0,
      'validate_argument_php' => '',
    ),
  ));
  $handler
    ->override_option('filters', array(
    'name' => array(
      'operator' => 'in',
      'value' => array(
        $app_name => $app_name,
      ),
      'group' => '0',
      'exposed' => FALSE,
      'expose' => array(
        'operator' => FALSE,
        'label' => '',
      ),
      'id' => 'name',
      'table' => 'recommender_app',
      'field' => 'name',
      'relationship' => 'none',
    ),
    'score' => array(
      'operator' => '>',
      'value' => array(
        'value' => '0',
        'min' => '',
        'max' => '',
      ),
      'group' => '0',
      'exposed' => FALSE,
      'expose' => array(
        'operator' => FALSE,
        'label' => '',
      ),
      'id' => 'score',
      'table' => $base_table,
      'field' => 'score',
      'relationship' => 'none',
    ),
  ));
  $handler
    ->override_option('access', array(
    'type' => 'none',
  ));
  $handler
    ->override_option('cache', array(
    'type' => 'none',
  ));
  $handler
    ->override_option('items_per_page', 5);
  $handler
    ->override_option('distinct', 1);
  $handler
    ->override_option('style_plugin', 'list');
  $handler
    ->override_option('style_options', array(
    'grouping' => '',
    'type' => 'ul',
  ));
  return $view;
}