Location: PHPKode > projects > Obsessive Website Statistics > ows/include/filter.inc.php
	$Id: filter.inc.php 112 2007-11-21 14:27:19Z randomperson83 $

	Obsessive Web Statistics
    Copyright (C) 2007 Dustin Spicuzza <hide@address.com>

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.

	This code loads filters and runs them


require 'plugin.inc.php';
require 'filter_utility.inc.php';
require 'filter_output.inc.php';
require 'dimensions.inc.php';

// loads filters
function run_filters($table,$domain){
	global $cfg;
	$filter = get_get_var('filter');
	$filter_file = get_get_var('filter_file');		// makes it so we don't need to load all filters
													// for an ajax call
	// if no filters shown, give a selection
	if ($filter == "")
		return show_all_filters($table,$domain);
	// load the plugin
	if (!load_plugins($filter_file))

	if (!$plugin = get_plugin('filter',$filter))
		return show_error("Invalid filter identifier");
	echo "<p>Filter results retrieved " . date("F j, Y, g:i:s a") . "</p>";

function show_all_filters($table,$domain){

	this menu/filter display code needs to be more generic. Some ids and classes used:
	id		about_$id 	= filter about text
	id		option_$id 	= filter options
	id		return_$id 	= filter returned html
	cls 	filter		= a style used to show boxes for filter divs
	cls		filter_$id 	= filter class grabbed by menu to hide elements

	global $cfg;

	// add to head
'<script type="text/javascript" src="js/jquery.calendar.js"></script>
<script type="text/javascript" src="js/jquery.ajaxSubmit.js"></script>
<script type="text/javascript" src="js/filter.js"></script>
<style type="text/css">@import url("css/jquery.calendar.css");</style>

	$filters = array();
	if (!load_plugins(''))
	$plugins = get_plugins('filter');
	foreach ($plugins as $plugin){
		$id = htmlentities($plugin['plugin']->getPluginId());
		$displayName = htmlentities($plugin['plugin']->getDisplayName());
		add_to_menu("<li><a class=\"menu_a\" id=\"mmenu_$id\" onclick=\"return show_filter('$id');\" href=\"#\">$displayName</a></li>");

	$results = array();

	foreach ($plugins as $plugin){
		$id = htmlentities($plugin['plugin']->getPluginId());
		$results[] = $id;
		echo "\n<div id=\"container_$id\" class=\"container\">
			<div class=\"menu\">
					<li><a onclick=\"return switch_about('$id','option')\" class=\"menu_selected\" href=\"#\" id=\"smenu_option_$id\">Options</a></li>
					<li><a onclick=\"return switch_about('$id','about')\" href=\"#\" id=\"smenu_about_$id\">About This Plugin</a></li>
		echo "<div class=\"filter_option filter_$id\" id=\"option_$id\"><form class=\"filterform\" method=\"post\" action=\"async.php?domain=" . htmlentities($domain) . "&amp;filter=$id\">";
		echo "<p style=\"clear:both;\"><input type=\"submit\" value=\"Show Results\"/></p></form></div><div class=\"filter_about filter_$id\" id=\"about_$id\">";
		// echo plugin information
		if (!show_plugin_information_table($plugin))
			echo "No extended information available for this plugin.";
		echo "</div></div>\n";
	echo "<div id=\"optional_limits\"><p><u>Optional Limits:</u></p><table>";
	$plugins = get_plugins('limit');
	foreach ($plugins as $plugin)
	echo "</table><p><input id=\"ows_obsession\" type=\"checkbox\" onclick=\"show_obsessive();\" /> Enable excessively obsessive options";
	if ($cfg['explain_sql'])
		echo "<br/><input name=\"only_explain\" type=\"checkbox\" value=\"yes\" /> Do not execute query, only show EXPLAIN output";
	echo "</p></div></div><div id=\"loading\"></div>";
	foreach ($results as $result)
		echo "<div class=\"result\" id=\"result_$result\"></div>";
	echo "<div>";

Return current item: Obsessive Website Statistics