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