]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/wikilens/CustomPrefs.php
Reformat code
[SourceForge/phpwiki.git] / lib / wikilens / CustomPrefs.php
1 <?php
2
3 /**
4  * Custom UserPreferences:
5  * A list of name => _UserPreference class pairs.
6  * Rationale: Certain themes should be able to extend the predefined list
7  * of preferences. Display/editing is done in the theme specific userprefs.tmpl
8  * but storage/sanification/update/... must be extended to the Get/SetPreferences methods.
9  *
10  * This is just at alpha stage, a recommendation to the wikilens group.
11  */
12
13 class _UserPreference_recengine // recommendation engine method
14     extends _UserPreference
15 {
16     var $valid_values = array('php', 'mysuggest', 'mymovielens', 'mycluto');
17     var $default_value = 'php';
18
19     function sanify($value)
20     {
21         if (!in_array($value, $this->valid_values)) return $this->default_value;
22         else return $value;
23     }
24 }
25
26 ;
27
28 class _UserPreference_recalgo // recommendation engine algorithm
29     extends _UserPreference
30 {
31     var $valid_values = array
32     (
33         'itemCos', // Item-based Top-N recommendation algorithm with cosine-based similarity function
34         'itemProb', // Item-based Top-N recommendation algorithm with probability-based similarity function.
35         // This algorithms tends to outperform the rest.
36         'userCos', // User-based Top-N recommendation algorithm with cosine-based similarity function.
37         'bayes'); // Naïve Bayesian Classifier
38     var $default_value = 'itemProb';
39
40     function sanify($value)
41     {
42         if (!in_array($value, $this->valid_values)) return $this->default_value;
43         else return $value;
44     }
45 }
46
47 ;
48
49 class _UserPreference_recnnbr // recommendation engine key clustering, neighborhood size
50     extends _UserPreference_numeric
51 {
52 }
53
54 ;
55
56 $WikiTheme->customUserPreferences
57 (array
58 (
59     'recengine' => new _UserPreference_recengine('php'),
60     'recalgo' => new _UserPreference_recalgo('itemProb'),
61     //recnnbr: typically 15-30 for item-based, 40-80 for user-based algos
62     'recnnbr' => new _UserPreference_recnnbr(10, 14, 80),
63 ));
64
65 // Local Variables:
66 // mode: php
67 // tab-width: 8
68 // c-basic-offset: 4
69 // c-hanging-comment-ender-p: nil
70 // indent-tabs-mode: nil
71 // End: