1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23:
24: $plugin_is_filter = 2|CLASS_PLUGIN;
25: $plugin_description = gettext("Collects and displays search criteria.");
26: $plugin_author = "Stephen Billard (sbillard)";
27:
28: $option_interface = 'search_statistics';
29:
30: zp_register_filter('search_statistics','search_statistics::handler');
31: zp_register_filter('admin_utilities_buttons', 'search_statistics::button');
32:
33: 34: 35: 36:
37: class search_statistics {
38: var $ratingstate;
39: 40: 41: 42: 43:
44: function __construct() {
45: setOptionDefault('search_statistics_threshold', 25);
46: setOptionDefault('search_statistics_terms_threshold', 25);
47: setOptionDefault('search_statistics_failed_threshold', 10);
48: setOptionDefault('search_statistics_ip_threshold', 10);
49: }
50:
51:
52: 53: 54: 55: 56:
57: function getOptionsSupported() {
58: return array( gettext('Threshold (success)') => array('key' => 'search_statistics_threshold', 'type' => OPTION_TYPE_TEXTBOX,
59: 'order' =>1,
60: 'desc' => gettext('Show the top <em>Threshold</em> criteria of successful searches. (Searches which returned at least one result.)')),
61: gettext('Threshold (failed)') => array('key' => 'search_statistics_failed_threshold', 'type' => OPTION_TYPE_TEXTBOX,
62: 'order' =>2,
63: 'desc' => gettext('Show the top <em>Threshold</em> criteria of searches that failed.')),
64: gettext('Threshold (terms)') => array('key' => 'search_statistics_terms_threshold', 'type' => OPTION_TYPE_TEXTBOX,
65: 'order' =>3,
66: 'desc' => gettext('Show the top <em>Threshold</em> terms used in searches.')),
67: gettext('Threshold (IP)') => array('key' => 'search_statistics_ip_threshold', 'type' => OPTION_TYPE_TEXTBOX,
68: 'order' =>4,
69: 'desc' => gettext('Show the top <em>Threshold</em> IPs that have performed searches.'))
70: );
71: }
72:
73: function handleOption($option, $currentValue) {
74: }
75:
76:
77: static function button($buttons) {
78: $buttons[] = array(
79: 'category'=>gettext('Info'),
80: 'enable'=>true,
81: 'button_text'=>gettext('Search statistics'),
82: 'formname'=>'search_statistics_button',
83: 'action'=>PLUGIN_FOLDER.'/search_statistics/search_analysis.php',
84: 'icon'=>'images/bar_graph.png',
85: 'title'=>gettext('Analyze searches'),
86: 'alt'=>'',
87: 'hidden'=> '',
88: 'rights'=> OVERVIEW_RIGHTS,
89: );
90: return $buttons;
91: }
92:
93: 94: 95: 96: 97: 98: 99: 100: 101:
102: static function handler($search_statistics, $type, $success, $dynamic, $iteration) {
103: if (!$dynamic) {
104: $store = array('type'=>$type, 'success'=>$success, 'iteration'=>$iteration, 'data'=>$search_statistics);
105: $sql = 'INSERT INTO '.prefix('plugin_storage').' (`type`, `aux`,`data`) VALUES ("search_statistics", '.db_quote(getUserIP()).','.db_quote(serialize($store)).')';
106: query($sql);
107: }
108: return $search_statistics;
109: }
110:
111: }
112: ?>