]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - lib/wikilens/CustomPrefs.php
var --> public
[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     public $valid_values = array('php', 'mysuggest', 'mymovielens', 'mycluto');
17     public $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 class _UserPreference_recalgo // recommendation engine algorithm
27     extends _UserPreference
28 {
29     public $valid_values = array
30     (
31         'itemCos', // Item-based Top-N recommendation algorithm with cosine-based similarity function
32         'itemProb', // Item-based Top-N recommendation algorithm with probability-based similarity function.
33         // This algorithms tends to outperform the rest.
34         'userCos', // User-based Top-N recommendation algorithm with cosine-based similarity function.
35         'bayes'); // Naïve Bayesian Classifier
36     public $default_value = 'itemProb';
37
38     function sanify($value)
39     {
40         if (!in_array($value, $this->valid_values)) return $this->default_value;
41         else return $value;
42     }
43 }
44
45 class _UserPreference_recnnbr // recommendation engine key clustering, neighborhood size
46     extends _UserPreference_numeric
47 {
48 }
49
50 $WikiTheme->customUserPreferences
51 (array
52 (
53     'recengine' => new _UserPreference_recengine('php'),
54     'recalgo' => new _UserPreference_recalgo('itemProb'),
55     //recnnbr: typically 15-30 for item-based, 40-80 for user-based algos
56     'recnnbr' => new _UserPreference_recnnbr(10, 14, 80),
57 ));
58
59 // Local Variables:
60 // mode: php
61 // tab-width: 8
62 // c-basic-offset: 4
63 // c-hanging-comment-ender-p: nil
64 // indent-tabs-mode: nil
65 // End: