/[drupal]/contributions/modules/views_fastsearch/contrib/vfs_ranking_nodetype/vfs_ranking_nodetype.module
ViewVC logotype

Diff of /contributions/modules/views_fastsearch/contrib/vfs_ranking_nodetype/vfs_ranking_nodetype.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.1.2.3, Thu Jan 17 11:19:02 2008 UTC revision 1.1.2.4, Tue Mar 4 18:28:12 2008 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: vfs_ranking_nodetype.module,v 1.1.2.2 2008/01/17 05:06:56 jacobsingh Exp $  // $Id: vfs_ranking_nodetype.module,v 1.1.2.3 2008/01/17 11:19:02 jacobsingh Exp $
3    
4  /**  /**
5   * Implement the search_ranking callback   * Implement the search_ranking callback
# Line 10  Line 10 
10   */   */
11  function vfs_ranking_nodetype_search_ranking() {  function vfs_ranking_nodetype_search_ranking() {
12    $ranking = array();    $ranking = array();
13    
14    // get the type weight    // get the type weight
15    $ranking['node_rank_type'] = array(    $ranking['node_rank_type'] = array(
16      'join' => 'LEFT JOIN {vfs_ranking_nodetype} nt ON nt.type = n.type',      'join' => 'LEFT JOIN {vfs_ranking_nodetype} nt ON nt.type = n.type',
17      'score' => 'i.score * nt.search_weight',      'score' => 'i.score * nt.search_weight',
18    );    );
19    
20    return $ranking;    return $ranking;
21  }  }
22    
# Line 41  function vfs_ranking_nodetype_settings_f Line 41  function vfs_ranking_nodetype_settings_f
41    $form['#tree'] = true;    $form['#tree'] = true;
42    $weights = vfs_ranking_nodetype_get_weights();    $weights = vfs_ranking_nodetype_get_weights();
43    foreach (node_get_types() as $type) {    foreach (node_get_types() as $type) {
44      $form['types'][$type->type] = $field = array (      $form['types'][$type->type] = $field = array(
45        '#title' => $type->name,        '#title' => $type->name,
46        '#default_value' => ($weights[$type->type]) ? $weights[$type->type]: 1,        '#default_value' => ($weights[$type->type]) ? $weights[$type->type]: 1,
47        '#type' => 'select',        '#type' => 'select',
48        '#options' => array_combine(range(0,10),range(0,10)),        '#options' => array_combine(range(0, 10), range(0, 10)),
49      );      );
50    }    }
51    
52    $form['submit'] = array ('#type' => 'submit','#value' => 'submit');    $form['submit'] = array('#type' => 'submit','#value' => 'submit');
53    return $form;    return $form;
54  }  }
55    
56  function vfs_ranking_nodetype_settings_form_submit($form_id,$form_values) {  function vfs_ranking_nodetype_settings_form_submit($form_id, $form_values) {
57    foreach ($form_values['types'] as $type => $weight) {    foreach ($form_values['types'] as $type => $weight) {
58      db_query("INSERT INTO {vfs_ranking_nodetype} (type,search_weight) VALUES ('%s',%d)      db_query("INSERT INTO {vfs_ranking_nodetype} (type, search_weight) VALUES ('%s',%d) ON DUPLICATE KEY UPDATE search_weight = %d", $type, $weight, $weight);
     ON DUPLICATE KEY  
     UPDATE search_weight = %d", $type,$weight,$weight);  
59    }    }
60  }  }
61    
# Line 72  function vfs_ranking_nodetype_get_weight Line 70  function vfs_ranking_nodetype_get_weight
70    
71  function theme_vfs_ranking_nodetype_settings_form($form) {  function theme_vfs_ranking_nodetype_settings_form($form) {
72    $output = drupal_render($form['info']);    $output = drupal_render($form['info']);
73    
74    $header = array(t('Type'), t('Weight'));    $header = array(t('Type'), t('Weight'));
75    foreach (element_children($form['types']) as $key) {    foreach (element_children($form['types']) as $key) {
76      $row = array();      $row = array();

Legend:
Removed from v.1.1.2.3  
changed lines
  Added in v.1.1.2.4

  ViewVC Help
Powered by ViewVC 1.1.2