phpOpenTracker/phpOpenTracker/API Exception.php,NONE,1.1 Result.php,NONE,1.1 ResultIterator.php,NONE,1.1 Clickpath.php,1.15,1.16 Plugin.php,1.26,1.27
Sebastian Bergmann <[email protected]>
| Newsgroups | gmane.comp.web.phpopentracker.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/phpopencounter/phpOpenTracker/phpOpenTracker/API
In directory sc8-pr-cvs1:/tmp/cvs-serv16743/phpOpenTracker/API
Modified Files:
Clickpath.php Plugin.php
Added Files:
Exception.php Result.php ResultIterator.php
Log Message:
HEAD is 2.0.0-dev now.
--- NEW FILE: Result.php ---
<?php
//
// +---------------------------------------------------------------------+
// | phpOpenTracker - The Website Traffic and Visitor Analysis Solution |
// +---------------------------------------------------------------------+
// | Copyright (c) 2000-2003 Sebastian Bergmann. All rights reserved. |
// +---------------------------------------------------------------------+
// | This source file is subject to the phpOpenTracker Software License, |
// | Version 1.0, that is bundled with this package in the file LICENSE. |
// | If you did not receive a copy of this file, you may read it online |
// | at http://www.phpopentracker.de/license.html. |
// +---------------------------------------------------------------------+
//
// $Id: Result.php,v 1.1 2003/11/22 08:47:43 bergmann Exp $
//
class phpOpenTracker_API_Result implements IteratorAggregate {
protected $result;
protected $supportedFormats;
public function __construct($result, $supportedFormats = array()) {
$this->result = $result;
$this->supportedFormats = $supportedFormats;
}
public function getAsArray() {
return $this->result;
}
public function getAsCSV() {
$csv = implode(';', array_keys($this->result[0])) . "\n";
foreach ($this->result as $row) {
$csv .= implode(';', $row) . "\n";
}
return $csv;
}
public function getAsXML() {
}
public function getIterator() {
return new phpOpenTracker_API_ResultIterator($this->result);
}
}
//
// "phpOpenTracker essenya, gul meletya;
// Sebastian carneron PHP."
//
?>
Index: Clickpath.php
===================================================================
RCS file: /cvsroot/phpopencounter/phpOpenTracker/phpOpenTracker/API/Clickpath.php,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** Clickpath.php 19 Sep 2003 07:17:26 -0000 1.15
--- Clickpath.php 22 Nov 2003 08:47:43 -0000 1.16
***************
*** 22,182 ****
* @since phpOpenTracker 1.0.0
*/
! class phpOpenTracker_Clickpath {
! /**
! * Count
! *
! * @var integer $count
! */
! var $count;
!
! /**
! * Length
! *
! * @var integer $length
! */
! var $length;
!
! /**
! * documents
! *
! * @var array $documents
! */
! var $documents;
!
! /**
! * document_urls
! *
! * @var array $document_urls
! */
! var $document_urls;
!
! /**
! * Statistics
! *
! * @var array $statistics
! */
! var $statistics;
!
! /**
! * Constructor.
! *
! * @param array $documents
! * @param optional array $document_urls
! * @param optional array $statistics
! * @param optional integer $count
! * @access public
! */
! function phpOpenTracker_Clickpath($documents, $document_urls = array(), $statistics = array(), $count = 1) {
! $this->documents = $documents;
! $this->document_urls = $document_urls;
! $this->count = $count;
! $this->length = sizeof($documents);
! $this->statistics = $statistics;
! }
!
! /**
! * Returns GraphViz/dot markup for the graph.
! *
! * @param optional boolean $returnObject
! * @return mixed
! * @access public
! */
! function toGraph($returnObject = false) {
! if (!@include_once('Image/GraphViz.php')) {
! phpOpenTracker::handleError(
! 'Could not find PEAR Image_GraphViz package, exiting.',
! E_USER_ERROR
! );
! }
!
! $graph = new Image_GraphViz();
!
! for ($i = 0; $i < $this->length - 1; $i++) {
! $graph->addNode(
! $i,
! array(
! 'url' => $this->document_urls[$i],
! 'label' => $this->documents[$i],
! 'shape' => 'box'
! )
! );
!
! $graph->addNode(
! $i+1,
! array(
! 'url' => $this->document_urls[$i+1],
! 'label' => $this->documents[$i+1],
! 'shape' => 'box'
! )
! );
!
! if (isset($this->statistics[$i]['count'])) {
! $label = sprintf(
! 'count: %d\naverage time: %d seconds',
! $this->statistics[$i]['count'],
! $this->statistics[$i]['time_spent']
! );
! } else {
! $label = sprintf(
! 'time spent: %d seconds',
! $this->statistics[$i]
! );
! }
! $graph->addEdge(
! array(
! $i => $i+1
! ),
! array(
! 'label' => $label
! )
! );
! }
! if ($returnObject) {
! return $graph;
! } else {
! return $graph->parse();
! }
! }
! /**
! * Returns XML markup for the graph.
! *
! * @param optional boolean $returnObject
! * @return mixed
! * @access public
! */
! function toXML($returnObject = false) {
! if (!@include_once('XML/Tree.php')) {
! phpOpenTracker::handleError(
! 'Could not find PEAR XML_Tree package, exiting.',
! E_USER_ERROR
! );
}
! $tree = new XML_Tree;
! $root = &$tree->addRoot('clickpath');
!
! for ($i = 0; $i < $this->length; $i++) {
! $root->addChild('length', $this->length);
!
! $node = &$root->addChild('node');
!
! $node->addChild('document', $this->documents[$i]);
!
! if (!isset($this->statistics[$i]['count'])) {
! $node->addChild('timespent', $this->statistics[$i]);
! }
}
! if (!$returnObject) {
! return $root->get();
! } else {
! return $root;
}
- }
}
--- 22,102 ----
* @since phpOpenTracker 1.0.0
*/
! class phpOpenTracker_API_Clickpath {
! /**
! * Count
! *
! * @var integer $count
! * @access private
! */
! private $count;
! /**
! * Length
! *
! * @var integer $length
! * @access private
! */
! private $length;
! /**
! * documents
! *
! * @var array $documents
! * @access private
! */
! private $documents;
! /**
! * document_urls
! *
! * @var array $document_urls
! * @access private
! */
! private $document_urls;
! /**
! * Statistics
! *
! * @var array $statistics
! * @access private
! */
! private $statistics;
! /**
! * Constructor.
! *
! * @param array $documents
! * @param optional array $document_urls
! * @param optional array $statistics
! * @param optional integer $count
! * @access public
! */
! public function __construct($documents, $document_urls = array(), $statistics = array(), $count = 1) {
! $this->documents = $documents;
! $this->document_urls = $document_urls;
! $this->count = $count;
! $this->length = sizeof($documents);
! $this->statistics = $statistics;
}
! /**
! * Returns GraphViz/dot markup for the graph.
! *
! * @param optional boolean $returnObject
! * @return mixed
! * @access public
! */
! public function toGraph() {
}
! /**
! * Returns XML markup for the graph.
! *
! * @param optional boolean $returnObject
! * @return mixed
! * @access public
! */
! public function toXML() {
}
}
Index: Plugin.php
===================================================================
RCS file: /cvsroot/phpopencounter/phpOpenTracker/phpOpenTracker/API/Plugin.php,v
retrieving revision 1.26
retrieving revision 1.27
diff -C2 -d -r1.26 -r1.27
*** Plugin.php 13 Oct 2003 03:11:12 -0000 1.26
--- Plugin.php 22 Nov 2003 08:47:43 -0000 1.27
***************
*** 15,199 ****
//
! /**
! * Base Class for phpOpenTracker API plugins
! *
! * @author Sebastian Bergmann <[email protected]>
! * @version $Revision$
! * @since phpOpenTracker 1.0.0
! */
! class phpOpenTracker_API_Plugin {
! /**
! * Configuration
! *
! * @var array $config
! */
! var $config = array();
!
! /**
! * Container
! *
! * @var array $container
! */
! var $container = array();
!
! /**
! * DB
! *
! * @var object $db
! */
! var $db;
!
! /**
! * Constructor.
! *
! * @access public
! */
! function phpOpenTracker_API_Plugin() {
! $this->config = &phpOpenTracker_Config::getConfig();
! $this->container = &phpOpenTracker_Container::getInstance();
! $this->db = &phpOpenTracker_DB::getInstance();
! }
!
! /**
! * Builds constraint clause.
! *
! * @param array $constraints
! * @param optional boolean $selfJoinPossiblyRequired
! * @return mixed
! * @access protected
! * @since phpOpenTracker 1.1.0
! */
! function _constraint($constraints, $selfJoinPossiblyRequired = false) {
! $constraint = '';
! $selfJoinRequired = false;
!
! foreach ($constraints as $field => $value) {
! switch ($field) {
! case 'document': {
! $constraint .= sprintf(
! " AND accesslog%s.document_id = %d",
!
! ($selfJoinPossiblyRequired) ? '2' : '',
! $value,
! ($selfJoinPossiblyRequired) ? '2' : ''
! );
!
! if ($selfJoinPossiblyRequired) {
! $selfJoinRequired = true;
! }
! }
! break;
!
! case 'entry_document': {
! $constraint .= sprintf(
! " AND accesslog%s.document_id = %d AND accesslog%s.entry_document = 1",
!
! ($selfJoinPossiblyRequired) ? '2' : '',
! $value,
! ($selfJoinPossiblyRequired) ? '2' : ''
! );
!
! if ($selfJoinPossiblyRequired) {
! $selfJoinRequired = true;
! }
! }
! break;
!
! case 'exit_document': {
! $constraint .= sprintf(
! ' AND accesslog%s.document_id = %d AND accesslog%s.exit_target_id <> 0',
!
! ($selfJoinPossiblyRequired) ? '2' : '',
! $value,
! ($selfJoinPossiblyRequired) ? '2' : ''
! );
!
! if ($selfJoinPossiblyRequired) {
! $selfJoinRequired = true;
! }
! }
! break;
!
! case 'exit_target': {
! $constraint .= sprintf(
! ' AND accesslog%s.exit_target_id = %d',
!
! ($selfJoinPossiblyRequired) ? '2' : '',
! $value
! );
!
! if ($selfJoinPossiblyRequired) {
! $selfJoinRequired = true;
! }
! }
! break;
!
! case 'host':
! case 'operating_system':
! case 'referer':
! case 'user_agent': {
! $constraint .= sprintf(
! ' AND visitors.%s_id = %d',
!
! $field,
! $value
! );
! }
! break;
!
! case 'hour':
! case 'weekday': {
! $constraint .= sprintf(
! ' AND accesslog.%s = %d',
!
! $field,
! $value
! );
! }
! break;
! }
! }
!
! if ($selfJoinPossiblyRequired) {
! return array(
! $constraint,
! $selfJoinRequired
! );
! } else {
! return $constraint;
! }
! }
!
! /**
! * Builds timerange where clause for interval (start, end).
! *
! * @param integer start
! * @param integer end
! * @param optional string table
! * @return string
! * @access protected
! */
! function _whereTimerange($start, $end, $table = 'visitors') {
! $table .= '.';
! $timerange = ' AND ';
!
! if ($start && $end) {
! $timerange .= $table . "timestamp BETWEEN $start AND $end";
! }
! elseif ($start && !$end) {
! $timerange .= $table . "timestamp >= $start";
}
! elseif (!$start && $end) {
! $timerange .= $table . "timestamp <= $end";
}
! elseif (!$start && !$end) {
! return '';
}
! return $timerange;
! }
}
--- 15,36 ----
//
! abstract class phpOpenTracker_API_Plugin {
! protected $configuration;
! protected $container;
! protected $database;
! public function __construct() {
! $this->configuration = phpOpenTracker_Configuration::getInstance();
! $this->container = phpOpenTracker_Container::getInstance();
! $this->database = phpOpenTracker_Database::getInstance();
}
! protected function getConstraintClause() {
}
! protected function getWhereTimerange() {
}
! abstract public function run($parameters);
}
--- NEW FILE: ResultIterator.php ---
<?php
//
// +---------------------------------------------------------------------+
// | phpOpenTracker - The Website Traffic and Visitor Analysis Solution |
// +---------------------------------------------------------------------+
// | Copyright (c) 2000-2003 Sebastian Bergmann. All rights reserved. |
// +---------------------------------------------------------------------+
// | This source file is subject to the phpOpenTracker Software License, |
// | Version 1.0, that is bundled with this package in the file LICENSE. |
// | If you did not receive a copy of this file, you may read it online |
// | at http://www.phpopentracker.de/license.html. |
// +---------------------------------------------------------------------+
//
// $Id: ResultIterator.php,v 1.1 2003/11/22 08:47:43 bergmann Exp $
//
class phpOpenTracker_API_ResultIterator implements Iterator {
private $cursor = 0;
private $result;
public function __construct($result) {
$this->result = $result;
}
function rewind() {
$this->cursor = 0;
}
function hasMore() {
return $this->cursor < sizeof($this->result);
}
function key() {
return $this->cursor;
}
function current() {
return $this->result[$this->cursor];
}
function next() {
$this->cursor++;
}
}
//
// "phpOpenTracker essenya, gul meletya;
// Sebastian carneron PHP."
//
?>
--- NEW FILE: Exception.php ---
<?php
//
// +---------------------------------------------------------------------+
// | phpOpenTracker - The Website Traffic and Visitor Analysis Solution |
// +---------------------------------------------------------------------+
// | Copyright (c) 2000-2003 Sebastian Bergmann. All rights reserved. |
// +---------------------------------------------------------------------+
// | This source file is subject to the phpOpenTracker Software License, |
// | Version 1.0, that is bundled with this package in the file LICENSE. |
// | If you did not receive a copy of this file, you may read it online |
// | at http://www.phpopentracker.de/license.html. |
// +---------------------------------------------------------------------+
//
// $Id: Exception.php,v 1.1 2003/11/22 08:47:43 bergmann Exp $
//
class phpOpenTracker_API_Exception extends phpOpenTracker_Exception {
}
//
// "phpOpenTracker essenya, gul meletya;
// Sebastian carneron PHP."
//
?>
-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
Does SourceForge.net help you be more productive? Does it
help you create better code? SHARE THE LOVE, and help us help
YOU! Click Here: http://sourceforge.net/donate/