Merge branch 'cc-4661-listener-statistics' into devel
Conflicts: python_apps/api_clients/api_client.py
This commit is contained in:
commit
7300b608cf
|
@ -23,6 +23,7 @@ $ccAcl->add(new Zend_Acl_Resource('library'))
|
||||||
->add(new Zend_Acl_Resource('preference'))
|
->add(new Zend_Acl_Resource('preference'))
|
||||||
->add(new Zend_Acl_Resource('showbuilder'))
|
->add(new Zend_Acl_Resource('showbuilder'))
|
||||||
->add(new Zend_Acl_Resource('playouthistory'))
|
->add(new Zend_Acl_Resource('playouthistory'))
|
||||||
|
->add(new Zend_Acl_Resource('listenerstat'))
|
||||||
->add(new Zend_Acl_Resource('usersettings'))
|
->add(new Zend_Acl_Resource('usersettings'))
|
||||||
->add(new Zend_Acl_Resource('audiopreview'))
|
->add(new Zend_Acl_Resource('audiopreview'))
|
||||||
->add(new Zend_Acl_Resource('webstream'));
|
->add(new Zend_Acl_Resource('webstream'));
|
||||||
|
@ -43,6 +44,7 @@ $ccAcl->allow('G', 'index')
|
||||||
->allow('H', 'library')
|
->allow('H', 'library')
|
||||||
->allow('H', 'playlist')
|
->allow('H', 'playlist')
|
||||||
->allow('A', 'playouthistory')
|
->allow('A', 'playouthistory')
|
||||||
|
->allow('A', 'listenerstat')
|
||||||
->allow('A', 'user')
|
->allow('A', 'user')
|
||||||
->allow('A', 'systemstatus')
|
->allow('A', 'systemstatus')
|
||||||
->allow('A', 'preference');
|
->allow('A', 'preference');
|
||||||
|
|
|
@ -183,4 +183,18 @@ return array (
|
||||||
'BaseCcWebstreamMetadataPeer' => 'airtime/om/BaseCcWebstreamMetadataPeer.php',
|
'BaseCcWebstreamMetadataPeer' => 'airtime/om/BaseCcWebstreamMetadataPeer.php',
|
||||||
'BaseCcWebstreamMetadata' => 'airtime/om/BaseCcWebstreamMetadata.php',
|
'BaseCcWebstreamMetadata' => 'airtime/om/BaseCcWebstreamMetadata.php',
|
||||||
'BaseCcWebstreamMetadataQuery' => 'airtime/om/BaseCcWebstreamMetadataQuery.php',
|
'BaseCcWebstreamMetadataQuery' => 'airtime/om/BaseCcWebstreamMetadataQuery.php',
|
||||||
|
'CcTimestampTableMap' => 'airtime/map/CcTimestampTableMap.php',
|
||||||
|
'CcTimestampPeer' => 'airtime/CcTimestampPeer.php',
|
||||||
|
'CcTimestamp' => 'airtime/CcTimestamp.php',
|
||||||
|
'CcTimestampQuery' => 'airtime/CcTimestampQuery.php',
|
||||||
|
'BaseCcTimestampPeer' => 'airtime/om/BaseCcTimestampPeer.php',
|
||||||
|
'BaseCcTimestamp' => 'airtime/om/BaseCcTimestamp.php',
|
||||||
|
'BaseCcTimestampQuery' => 'airtime/om/BaseCcTimestampQuery.php',
|
||||||
|
'CcListenerCountTableMap' => 'airtime/map/CcListenerCountTableMap.php',
|
||||||
|
'CcListenerCountPeer' => 'airtime/CcListenerCountPeer.php',
|
||||||
|
'CcListenerCount' => 'airtime/CcListenerCount.php',
|
||||||
|
'CcListenerCountQuery' => 'airtime/CcListenerCountQuery.php',
|
||||||
|
'BaseCcListenerCountPeer' => 'airtime/om/BaseCcListenerCountPeer.php',
|
||||||
|
'BaseCcListenerCount' => 'airtime/om/BaseCcListenerCount.php',
|
||||||
|
'BaseCcListenerCountQuery' => 'airtime/om/BaseCcListenerCountQuery.php',
|
||||||
);
|
);
|
|
@ -85,6 +85,13 @@ $pages = array(
|
||||||
'controller' => 'playouthistory',
|
'controller' => 'playouthistory',
|
||||||
'action' => 'index',
|
'action' => 'index',
|
||||||
'resource' => 'playouthistory'
|
'resource' => 'playouthistory'
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'label' => 'Listener Stats',
|
||||||
|
'module' => 'default',
|
||||||
|
'controller' => 'listenerstat',
|
||||||
|
'action' => 'index',
|
||||||
|
'resource' => 'listenerstat'
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
|
|
|
@ -40,6 +40,8 @@ class ApiController extends Zend_Controller_Action
|
||||||
->addActionContext('get-files-without-replay-gain' , 'json')
|
->addActionContext('get-files-without-replay-gain' , 'json')
|
||||||
->addActionContext('reload-metadata-group' , 'json')
|
->addActionContext('reload-metadata-group' , 'json')
|
||||||
->addActionContext('notify-webstream-data' , 'json')
|
->addActionContext('notify-webstream-data' , 'json')
|
||||||
|
->addActionContext('get-stream-parameters' , 'json')
|
||||||
|
->addActionContext('push-stream-stats' , 'json')
|
||||||
->initContext();
|
->initContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -957,4 +959,22 @@ class ApiController extends Zend_Controller_Action
|
||||||
$this->view->media_id = $media_id;
|
$this->view->media_id = $media_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getStreamParametersAction() {
|
||||||
|
$streams = array("s1", "s2", "s3");
|
||||||
|
$stream_params = array();
|
||||||
|
foreach ($streams as $s) {
|
||||||
|
$stream_params[$s] =
|
||||||
|
Application_Model_StreamSetting::getStreamDataNormalized($s);
|
||||||
|
}
|
||||||
|
$this->view->stream_params = $stream_params;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function pushStreamStatsAction() {
|
||||||
|
$request = $this->getRequest();
|
||||||
|
$data = json_decode($request->getParam("data"), true);
|
||||||
|
|
||||||
|
Application_Model_ListenerStat::insertDataPoints($data);
|
||||||
|
$this->view->data = $data;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,69 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class ListenerstatController extends Zend_Controller_Action
|
||||||
|
{
|
||||||
|
public function init()
|
||||||
|
{
|
||||||
|
$ajaxContext = $this->_helper->getHelper('AjaxContext');
|
||||||
|
$ajaxContext
|
||||||
|
->addActionContext('get-data', 'json')
|
||||||
|
->initContext();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function indexAction()
|
||||||
|
{
|
||||||
|
global $CC_CONFIG;
|
||||||
|
|
||||||
|
$request = $this->getRequest();
|
||||||
|
$baseUrl = $request->getBaseUrl();
|
||||||
|
|
||||||
|
$this->view->headScript()->appendFile($baseUrl.'/js/flot/jquery.flot.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
||||||
|
$this->view->headScript()->appendFile($baseUrl.'/js/flot/jquery.flot.crosshair.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
||||||
|
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/listenerstat/listenerstat.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
||||||
|
|
||||||
|
$offset = date("Z") * -1;
|
||||||
|
$this->view->headScript()->appendScript("var serverTimezoneOffset = {$offset}; //in seconds");
|
||||||
|
$this->view->headScript()->appendFile($baseUrl.'/js/timepicker/jquery.ui.timepicker.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
||||||
|
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/buttons/buttons.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
||||||
|
$this->view->headScript()->appendFile($baseUrl.'/js/airtime/utilities/utilities.js?'.$CC_CONFIG['airtime_version'],'text/javascript');
|
||||||
|
|
||||||
|
$this->view->headLink()->appendStylesheet($baseUrl.'/css/jquery.ui.timepicker.css?'.$CC_CONFIG['airtime_version']);
|
||||||
|
|
||||||
|
//default time is the last 24 hours.
|
||||||
|
$now = time();
|
||||||
|
$from = $request->getParam("from", $now - (24*60*60));
|
||||||
|
$to = $request->getParam("to", $now);
|
||||||
|
|
||||||
|
$start = DateTime::createFromFormat("U", $from, new DateTimeZone("UTC"));
|
||||||
|
$start->setTimezone(new DateTimeZone(date_default_timezone_get()));
|
||||||
|
$end = DateTime::createFromFormat("U", $to, new DateTimeZone("UTC"));
|
||||||
|
$end->setTimezone(new DateTimeZone(date_default_timezone_get()));
|
||||||
|
|
||||||
|
$form = new Application_Form_DateRange();
|
||||||
|
$form->populate(array(
|
||||||
|
'his_date_start' => $start->format("Y-m-d"),
|
||||||
|
'his_time_start' => $start->format("H:i"),
|
||||||
|
'his_date_end' => $end->format("Y-m-d"),
|
||||||
|
'his_time_end' => $end->format("H:i")
|
||||||
|
));
|
||||||
|
|
||||||
|
$this->view->date_form = $form;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDataAction(){
|
||||||
|
$request = $this->getRequest();
|
||||||
|
$current_time = time();
|
||||||
|
|
||||||
|
$params = $request->getParams();
|
||||||
|
|
||||||
|
$starts_epoch = $request->getParam("startTimestamp", $current_time - (60*60*24));
|
||||||
|
$ends_epoch = $request->getParam("endTimestamp", $current_time);
|
||||||
|
$mountName = $request->getParam("mountName", null);
|
||||||
|
|
||||||
|
$startsDT = DateTime::createFromFormat("U", $starts_epoch, new DateTimeZone("UTC"));
|
||||||
|
$endsDT = DateTime::createFromFormat("U", $ends_epoch, new DateTimeZone("UTC"));
|
||||||
|
|
||||||
|
$data = Application_Model_ListenerStat::getDataPointsWithinRange($startsDT->format("Y-m-d H:i:s"), $endsDT->format("Y-m-d H:i:s"), $mountName);
|
||||||
|
die(json_encode($data));
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,101 @@
|
||||||
|
<?php
|
||||||
|
class Application_Model_ListenerStat
|
||||||
|
{
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getDataPointsWithinRange($p_start, $p_end) {
|
||||||
|
$sql = <<<SQL
|
||||||
|
SELECT mount_name, count(*)
|
||||||
|
FROM cc_listener_count AS lc
|
||||||
|
INNER JOIN cc_timestamp AS ts ON (lc.timestamp_id = ts.ID)
|
||||||
|
INNER JOIN cc_mount_name AS mn ON (lc.mount_name_id = mn.ID)
|
||||||
|
WHERE (ts.timestamp >=:p1 AND ts.timestamp <=:p2)
|
||||||
|
group by mount_name
|
||||||
|
SQL;
|
||||||
|
$data = Application_Common_Database::prepareAndExecute($sql,
|
||||||
|
array('p1'=>$p_start, 'p2'=>$p_end));
|
||||||
|
|
||||||
|
$out = array();
|
||||||
|
foreach ($data as $d) {
|
||||||
|
$jump = intval($d['count']/1000);
|
||||||
|
$jump = max(1, $jump);
|
||||||
|
$remainder = $jump == 1?0:1;
|
||||||
|
|
||||||
|
$sql = <<<SQL
|
||||||
|
SELECT *
|
||||||
|
FROM
|
||||||
|
(SELECT lc.id, ts.timestamp, lc.listener_count, mn.mount_name,
|
||||||
|
ROW_NUMBER() OVER (ORDER BY timestamp) as rownum
|
||||||
|
FROM cc_listener_count AS lc
|
||||||
|
INNER JOIN cc_timestamp AS ts ON (lc.timestamp_id = ts.ID)
|
||||||
|
INNER JOIN cc_mount_name AS mn ON (lc.mount_name_id = mn.ID)
|
||||||
|
WHERE (ts.timestamp >=:p1 AND ts.timestamp <= :p2) AND mount_name=:p3) as temp
|
||||||
|
WHERE (temp.rownum%:p4) = :p5;
|
||||||
|
SQL;
|
||||||
|
$result = Application_Common_Database::prepareAndExecute($sql,
|
||||||
|
array('p1'=>$p_start, 'p2'=>$p_end, 'p3'=>$d['mount_name'], 'p4'=>$jump, 'p5'=>$remainder));
|
||||||
|
foreach ($result as $r) {
|
||||||
|
$t = new DateTime($r['timestamp'], new DateTimeZone("UTC"));
|
||||||
|
$t->setTimezone(new DateTimeZone(date_default_timezone_get()));
|
||||||
|
// tricking javascript so it thinks the server timezone is in UTC
|
||||||
|
$dt = new DateTime($t->format("Y-m-d H:i:s"), new DateTimeZone("UTC"));
|
||||||
|
|
||||||
|
$r['timestamp'] = $dt->format("U");
|
||||||
|
$out[$r['mount_name']][] = $r;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $out;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function insertDataPoints($p_dataPoints) {
|
||||||
|
|
||||||
|
|
||||||
|
$timestamp_sql = "INSERT INTO cc_timestamp (timestamp) VALUES
|
||||||
|
(:ts::TIMESTAMP) RETURNING id;";
|
||||||
|
|
||||||
|
$mount_name_check_sql = "SELECT id from cc_mount_name WHERE
|
||||||
|
mount_name = :mn;";
|
||||||
|
|
||||||
|
$mount_name_insert_sql = "INSERT INTO cc_mount_name (mount_name) VALUES
|
||||||
|
(:mn) RETURNING id;";
|
||||||
|
|
||||||
|
$stats_sql = "INSERT INTO cc_listener_count (timestamp_id,
|
||||||
|
listener_count, mount_name_id) VALUES (:timestamp_id,
|
||||||
|
:listener_count, :mount_name_id)";
|
||||||
|
|
||||||
|
foreach ($p_dataPoints as $dp) {
|
||||||
|
$timestamp_id = Application_Common_Database::prepareAndExecute(
|
||||||
|
$timestamp_sql,
|
||||||
|
array('ts'=> $dp['timestamp']),
|
||||||
|
"column");
|
||||||
|
|
||||||
|
$mount_name_id = Application_Common_Database::prepareAndExecute(
|
||||||
|
$mount_name_check_sql,
|
||||||
|
array('mn' => $dp['mount_name']),
|
||||||
|
"column");
|
||||||
|
|
||||||
|
if (strlen($mount_name_id) == 0) {
|
||||||
|
//there is a race condition here where theoretically the row
|
||||||
|
//with value "mount_name" could appear, but this is *very*
|
||||||
|
//unlikely and won't break anything even if it happens.
|
||||||
|
$mount_name_id = Application_Common_Database::prepareAndExecute(
|
||||||
|
$mount_name_insert_sql,
|
||||||
|
array('mn' => $dp['mount_name']),
|
||||||
|
"column");
|
||||||
|
}
|
||||||
|
|
||||||
|
Application_Common_Database::prepareAndExecute($stats_sql,
|
||||||
|
array('timestamp_id' => $timestamp_id,
|
||||||
|
'listener_count' => $dp["num_listeners"],
|
||||||
|
'mount_name_id' => $mount_name_id,
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -129,6 +129,35 @@ class Application_Model_StreamSetting
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Similar to getStreamData, but removes all sX prefixes to
|
||||||
|
* make data easier to iterate over */
|
||||||
|
public static function getStreamDataNormalized($p_streamId)
|
||||||
|
{
|
||||||
|
$con = Propel::getConnection();
|
||||||
|
$streamId = pg_escape_string($p_streamId);
|
||||||
|
$sql = "SELECT * "
|
||||||
|
."FROM cc_stream_setting "
|
||||||
|
."WHERE keyname LIKE '{$streamId}_%'";
|
||||||
|
|
||||||
|
$stmt = $con->prepare($sql);
|
||||||
|
|
||||||
|
if ($stmt->execute()) {
|
||||||
|
$rows = $stmt->fetchAll();
|
||||||
|
} else {
|
||||||
|
$msg = implode(',', $stmt->errorInfo());
|
||||||
|
throw new Exception("Error: $msg");
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = array();
|
||||||
|
|
||||||
|
foreach ($rows as $row) {
|
||||||
|
list($id, $key) = explode("_", $row["keyname"], 2);
|
||||||
|
$data[$key] = $row["value"];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
public static function getStreamSetting()
|
public static function getStreamSetting()
|
||||||
{
|
{
|
||||||
$con = Propel::getConnection();
|
$con = Propel::getConnection();
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skeleton subclass for representing a row from the 'cc_listener_count' table.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* You should add additional methods to this class to meet the
|
||||||
|
* application requirements. This class will only be generated as
|
||||||
|
* long as it does not already exist in the output directory.
|
||||||
|
*
|
||||||
|
* @package propel.generator.airtime
|
||||||
|
*/
|
||||||
|
class CcListenerCount extends BaseCcListenerCount {
|
||||||
|
|
||||||
|
} // CcListenerCount
|
|
@ -0,0 +1,18 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skeleton subclass for performing query and update operations on the 'cc_listener_count' table.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* You should add additional methods to this class to meet the
|
||||||
|
* application requirements. This class will only be generated as
|
||||||
|
* long as it does not already exist in the output directory.
|
||||||
|
*
|
||||||
|
* @package propel.generator.airtime
|
||||||
|
*/
|
||||||
|
class CcListenerCountPeer extends BaseCcListenerCountPeer {
|
||||||
|
|
||||||
|
} // CcListenerCountPeer
|
|
@ -0,0 +1,18 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skeleton subclass for performing query and update operations on the 'cc_listener_count' table.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* You should add additional methods to this class to meet the
|
||||||
|
* application requirements. This class will only be generated as
|
||||||
|
* long as it does not already exist in the output directory.
|
||||||
|
*
|
||||||
|
* @package propel.generator.airtime
|
||||||
|
*/
|
||||||
|
class CcListenerCountQuery extends BaseCcListenerCountQuery {
|
||||||
|
|
||||||
|
} // CcListenerCountQuery
|
|
@ -0,0 +1,18 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skeleton subclass for representing a row from the 'cc_timestamp' table.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* You should add additional methods to this class to meet the
|
||||||
|
* application requirements. This class will only be generated as
|
||||||
|
* long as it does not already exist in the output directory.
|
||||||
|
*
|
||||||
|
* @package propel.generator.airtime
|
||||||
|
*/
|
||||||
|
class CcTimestamp extends BaseCcTimestamp {
|
||||||
|
|
||||||
|
} // CcTimestamp
|
|
@ -0,0 +1,18 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skeleton subclass for performing query and update operations on the 'cc_timestamp' table.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* You should add additional methods to this class to meet the
|
||||||
|
* application requirements. This class will only be generated as
|
||||||
|
* long as it does not already exist in the output directory.
|
||||||
|
*
|
||||||
|
* @package propel.generator.airtime
|
||||||
|
*/
|
||||||
|
class CcTimestampPeer extends BaseCcTimestampPeer {
|
||||||
|
|
||||||
|
} // CcTimestampPeer
|
|
@ -0,0 +1,18 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Skeleton subclass for performing query and update operations on the 'cc_timestamp' table.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* You should add additional methods to this class to meet the
|
||||||
|
* application requirements. This class will only be generated as
|
||||||
|
* long as it does not already exist in the output directory.
|
||||||
|
*
|
||||||
|
* @package propel.generator.airtime
|
||||||
|
*/
|
||||||
|
class CcTimestampQuery extends BaseCcTimestampQuery {
|
||||||
|
|
||||||
|
} // CcTimestampQuery
|
|
@ -0,0 +1,57 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class defines the structure of the 'cc_listener_count' table.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* This map class is used by Propel to do runtime db structure discovery.
|
||||||
|
* For example, the createSelectSql() method checks the type of a given column used in an
|
||||||
|
* ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive
|
||||||
|
* (i.e. if it's a text column type).
|
||||||
|
*
|
||||||
|
* @package propel.generator.airtime.map
|
||||||
|
*/
|
||||||
|
class CcListenerCountTableMap extends TableMap {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The (dot-path) name of this class
|
||||||
|
*/
|
||||||
|
const CLASS_NAME = 'airtime.map.CcListenerCountTableMap';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize the table attributes, columns and validators
|
||||||
|
* Relations are not initialized by this method since they are lazy loaded
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @throws PropelException
|
||||||
|
*/
|
||||||
|
public function initialize()
|
||||||
|
{
|
||||||
|
// attributes
|
||||||
|
$this->setName('cc_listener_count');
|
||||||
|
$this->setPhpName('CcListenerCount');
|
||||||
|
$this->setClassname('CcListenerCount');
|
||||||
|
$this->setPackage('airtime');
|
||||||
|
$this->setUseIdGenerator(true);
|
||||||
|
$this->setPrimaryKeyMethodInfo('cc_listener_count_id_seq');
|
||||||
|
// columns
|
||||||
|
$this->addPrimaryKey('ID', 'DbId', 'INTEGER', true, null, null);
|
||||||
|
$this->addForeignKey('TIMESTAMP_ID', 'DbTimestampId', 'INTEGER', 'cc_timestamp', 'ID', true, null, null);
|
||||||
|
$this->addForeignKey('MOUNT_NAME_ID', 'DbMountNameId', 'INTEGER', 'cc_mount_name', 'ID', true, null, null);
|
||||||
|
$this->addColumn('LISTENER_COUNT', 'DbListenerCount', 'INTEGER', true, null, null);
|
||||||
|
// validators
|
||||||
|
} // initialize()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build the RelationMap objects for this table relationships
|
||||||
|
*/
|
||||||
|
public function buildRelations()
|
||||||
|
{
|
||||||
|
$this->addRelation('CcTimestamp', 'CcTimestamp', RelationMap::MANY_TO_ONE, array('timestamp_id' => 'id', ), 'CASCADE', null);
|
||||||
|
$this->addRelation('CcTimestamp', 'CcTimestamp', RelationMap::MANY_TO_ONE, array('mount_name_id' => 'id', ), 'CASCADE', null);
|
||||||
|
} // buildRelations()
|
||||||
|
|
||||||
|
} // CcListenerCountTableMap
|
|
@ -0,0 +1,54 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class defines the structure of the 'cc_timestamp' table.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* This map class is used by Propel to do runtime db structure discovery.
|
||||||
|
* For example, the createSelectSql() method checks the type of a given column used in an
|
||||||
|
* ORDER BY clause to know whether it needs to apply SQL to make the ORDER BY case-insensitive
|
||||||
|
* (i.e. if it's a text column type).
|
||||||
|
*
|
||||||
|
* @package propel.generator.airtime.map
|
||||||
|
*/
|
||||||
|
class CcTimestampTableMap extends TableMap {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The (dot-path) name of this class
|
||||||
|
*/
|
||||||
|
const CLASS_NAME = 'airtime.map.CcTimestampTableMap';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize the table attributes, columns and validators
|
||||||
|
* Relations are not initialized by this method since they are lazy loaded
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @throws PropelException
|
||||||
|
*/
|
||||||
|
public function initialize()
|
||||||
|
{
|
||||||
|
// attributes
|
||||||
|
$this->setName('cc_timestamp');
|
||||||
|
$this->setPhpName('CcTimestamp');
|
||||||
|
$this->setClassname('CcTimestamp');
|
||||||
|
$this->setPackage('airtime');
|
||||||
|
$this->setUseIdGenerator(true);
|
||||||
|
$this->setPrimaryKeyMethodInfo('cc_timestamp_id_seq');
|
||||||
|
// columns
|
||||||
|
$this->addPrimaryKey('ID', 'DbId', 'INTEGER', true, null, null);
|
||||||
|
$this->addColumn('TIMESTAMP', 'DbTimestamp', 'TIMESTAMP', true, null, null);
|
||||||
|
// validators
|
||||||
|
} // initialize()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build the RelationMap objects for this table relationships
|
||||||
|
*/
|
||||||
|
public function buildRelations()
|
||||||
|
{
|
||||||
|
$this->addRelation('CcListenerCount', 'CcListenerCount', RelationMap::ONE_TO_MANY, array('id' => 'timestamp_id', ), 'CASCADE', null);
|
||||||
|
} // buildRelations()
|
||||||
|
|
||||||
|
} // CcTimestampTableMap
|
|
@ -0,0 +1,984 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Base class that represents a row from the 'cc_listener_count' table.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @package propel.generator.airtime.om
|
||||||
|
*/
|
||||||
|
abstract class BaseCcListenerCount extends BaseObject implements Persistent
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Peer class name
|
||||||
|
*/
|
||||||
|
const PEER = 'CcListenerCountPeer';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Peer class.
|
||||||
|
* Instance provides a convenient way of calling static methods on a class
|
||||||
|
* that calling code may not be able to identify.
|
||||||
|
* @var CcListenerCountPeer
|
||||||
|
*/
|
||||||
|
protected static $peer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The value for the id field.
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
protected $id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The value for the timestamp_id field.
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
protected $timestamp_id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The value for the mount_name_id field.
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
protected $mount_name_id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The value for the listener_count field.
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
protected $listener_count;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var CcTimestamp
|
||||||
|
*/
|
||||||
|
protected $aCcTimestamp;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var CcTimestamp
|
||||||
|
*/
|
||||||
|
protected $aCcTimestamp;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Flag to prevent endless save loop, if this object is referenced
|
||||||
|
* by another object which falls in this transaction.
|
||||||
|
* @var boolean
|
||||||
|
*/
|
||||||
|
protected $alreadyInSave = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Flag to prevent endless validation loop, if this object is referenced
|
||||||
|
* by another object which falls in this transaction.
|
||||||
|
* @var boolean
|
||||||
|
*/
|
||||||
|
protected $alreadyInValidation = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the [id] column value.
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getDbId()
|
||||||
|
{
|
||||||
|
return $this->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the [timestamp_id] column value.
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getDbTimestampId()
|
||||||
|
{
|
||||||
|
return $this->timestamp_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the [mount_name_id] column value.
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getDbMountNameId()
|
||||||
|
{
|
||||||
|
return $this->mount_name_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the [listener_count] column value.
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getDbListenerCount()
|
||||||
|
{
|
||||||
|
return $this->listener_count;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the value of [id] column.
|
||||||
|
*
|
||||||
|
* @param int $v new value
|
||||||
|
* @return CcListenerCount The current object (for fluent API support)
|
||||||
|
*/
|
||||||
|
public function setDbId($v)
|
||||||
|
{
|
||||||
|
if ($v !== null) {
|
||||||
|
$v = (int) $v;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->id !== $v) {
|
||||||
|
$this->id = $v;
|
||||||
|
$this->modifiedColumns[] = CcListenerCountPeer::ID;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
} // setDbId()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the value of [timestamp_id] column.
|
||||||
|
*
|
||||||
|
* @param int $v new value
|
||||||
|
* @return CcListenerCount The current object (for fluent API support)
|
||||||
|
*/
|
||||||
|
public function setDbTimestampId($v)
|
||||||
|
{
|
||||||
|
if ($v !== null) {
|
||||||
|
$v = (int) $v;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->timestamp_id !== $v) {
|
||||||
|
$this->timestamp_id = $v;
|
||||||
|
$this->modifiedColumns[] = CcListenerCountPeer::TIMESTAMP_ID;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->aCcTimestamp !== null && $this->aCcTimestamp->getDbId() !== $v) {
|
||||||
|
$this->aCcTimestamp = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
} // setDbTimestampId()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the value of [mount_name_id] column.
|
||||||
|
*
|
||||||
|
* @param int $v new value
|
||||||
|
* @return CcListenerCount The current object (for fluent API support)
|
||||||
|
*/
|
||||||
|
public function setDbMountNameId($v)
|
||||||
|
{
|
||||||
|
if ($v !== null) {
|
||||||
|
$v = (int) $v;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->mount_name_id !== $v) {
|
||||||
|
$this->mount_name_id = $v;
|
||||||
|
$this->modifiedColumns[] = CcListenerCountPeer::MOUNT_NAME_ID;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->aCcTimestamp !== null && $this->aCcTimestamp->getDbId() !== $v) {
|
||||||
|
$this->aCcTimestamp = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
} // setDbMountNameId()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the value of [listener_count] column.
|
||||||
|
*
|
||||||
|
* @param int $v new value
|
||||||
|
* @return CcListenerCount The current object (for fluent API support)
|
||||||
|
*/
|
||||||
|
public function setDbListenerCount($v)
|
||||||
|
{
|
||||||
|
if ($v !== null) {
|
||||||
|
$v = (int) $v;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->listener_count !== $v) {
|
||||||
|
$this->listener_count = $v;
|
||||||
|
$this->modifiedColumns[] = CcListenerCountPeer::LISTENER_COUNT;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
} // setDbListenerCount()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates whether the columns in this object are only set to default values.
|
||||||
|
*
|
||||||
|
* This method can be used in conjunction with isModified() to indicate whether an object is both
|
||||||
|
* modified _and_ has some values set which are non-default.
|
||||||
|
*
|
||||||
|
* @return boolean Whether the columns in this object are only been set with default values.
|
||||||
|
*/
|
||||||
|
public function hasOnlyDefaultValues()
|
||||||
|
{
|
||||||
|
// otherwise, everything was equal, so return TRUE
|
||||||
|
return true;
|
||||||
|
} // hasOnlyDefaultValues()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hydrates (populates) the object variables with values from the database resultset.
|
||||||
|
*
|
||||||
|
* An offset (0-based "start column") is specified so that objects can be hydrated
|
||||||
|
* with a subset of the columns in the resultset rows. This is needed, for example,
|
||||||
|
* for results of JOIN queries where the resultset row includes columns from two or
|
||||||
|
* more tables.
|
||||||
|
*
|
||||||
|
* @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
|
||||||
|
* @param int $startcol 0-based offset column which indicates which restultset column to start with.
|
||||||
|
* @param boolean $rehydrate Whether this object is being re-hydrated from the database.
|
||||||
|
* @return int next starting column
|
||||||
|
* @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
|
||||||
|
*/
|
||||||
|
public function hydrate($row, $startcol = 0, $rehydrate = false)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
|
||||||
|
$this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
|
||||||
|
$this->timestamp_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null;
|
||||||
|
$this->mount_name_id = ($row[$startcol + 2] !== null) ? (int) $row[$startcol + 2] : null;
|
||||||
|
$this->listener_count = ($row[$startcol + 3] !== null) ? (int) $row[$startcol + 3] : null;
|
||||||
|
$this->resetModified();
|
||||||
|
|
||||||
|
$this->setNew(false);
|
||||||
|
|
||||||
|
if ($rehydrate) {
|
||||||
|
$this->ensureConsistency();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $startcol + 4; // 4 = CcListenerCountPeer::NUM_COLUMNS - CcListenerCountPeer::NUM_LAZY_LOAD_COLUMNS).
|
||||||
|
|
||||||
|
} catch (Exception $e) {
|
||||||
|
throw new PropelException("Error populating CcListenerCount object", $e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks and repairs the internal consistency of the object.
|
||||||
|
*
|
||||||
|
* This method is executed after an already-instantiated object is re-hydrated
|
||||||
|
* from the database. It exists to check any foreign keys to make sure that
|
||||||
|
* the objects related to the current object are correct based on foreign key.
|
||||||
|
*
|
||||||
|
* You can override this method in the stub class, but you should always invoke
|
||||||
|
* the base method from the overridden method (i.e. parent::ensureConsistency()),
|
||||||
|
* in case your model changes.
|
||||||
|
*
|
||||||
|
* @throws PropelException
|
||||||
|
*/
|
||||||
|
public function ensureConsistency()
|
||||||
|
{
|
||||||
|
|
||||||
|
if ($this->aCcTimestamp !== null && $this->timestamp_id !== $this->aCcTimestamp->getDbId()) {
|
||||||
|
$this->aCcTimestamp = null;
|
||||||
|
}
|
||||||
|
if ($this->aCcTimestamp !== null && $this->mount_name_id !== $this->aCcTimestamp->getDbId()) {
|
||||||
|
$this->aCcTimestamp = null;
|
||||||
|
}
|
||||||
|
} // ensureConsistency
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
|
||||||
|
*
|
||||||
|
* This will only work if the object has been saved and has a valid primary key set.
|
||||||
|
*
|
||||||
|
* @param boolean $deep (optional) Whether to also de-associated any related objects.
|
||||||
|
* @param PropelPDO $con (optional) The PropelPDO connection to use.
|
||||||
|
* @return void
|
||||||
|
* @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
|
||||||
|
*/
|
||||||
|
public function reload($deep = false, PropelPDO $con = null)
|
||||||
|
{
|
||||||
|
if ($this->isDeleted()) {
|
||||||
|
throw new PropelException("Cannot reload a deleted object.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->isNew()) {
|
||||||
|
throw new PropelException("Cannot reload an unsaved object.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($con === null) {
|
||||||
|
$con = Propel::getConnection(CcListenerCountPeer::DATABASE_NAME, Propel::CONNECTION_READ);
|
||||||
|
}
|
||||||
|
|
||||||
|
// We don't need to alter the object instance pool; we're just modifying this instance
|
||||||
|
// already in the pool.
|
||||||
|
|
||||||
|
$stmt = CcListenerCountPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
|
||||||
|
$row = $stmt->fetch(PDO::FETCH_NUM);
|
||||||
|
$stmt->closeCursor();
|
||||||
|
if (!$row) {
|
||||||
|
throw new PropelException('Cannot find matching row in the database to reload object values.');
|
||||||
|
}
|
||||||
|
$this->hydrate($row, 0, true); // rehydrate
|
||||||
|
|
||||||
|
if ($deep) { // also de-associate any related objects?
|
||||||
|
|
||||||
|
$this->aCcTimestamp = null;
|
||||||
|
$this->aCcTimestamp = null;
|
||||||
|
} // if (deep)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes this object from datastore and sets delete attribute.
|
||||||
|
*
|
||||||
|
* @param PropelPDO $con
|
||||||
|
* @return void
|
||||||
|
* @throws PropelException
|
||||||
|
* @see BaseObject::setDeleted()
|
||||||
|
* @see BaseObject::isDeleted()
|
||||||
|
*/
|
||||||
|
public function delete(PropelPDO $con = null)
|
||||||
|
{
|
||||||
|
if ($this->isDeleted()) {
|
||||||
|
throw new PropelException("This object has already been deleted.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($con === null) {
|
||||||
|
$con = Propel::getConnection(CcListenerCountPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
|
||||||
|
}
|
||||||
|
|
||||||
|
$con->beginTransaction();
|
||||||
|
try {
|
||||||
|
$ret = $this->preDelete($con);
|
||||||
|
if ($ret) {
|
||||||
|
CcListenerCountQuery::create()
|
||||||
|
->filterByPrimaryKey($this->getPrimaryKey())
|
||||||
|
->delete($con);
|
||||||
|
$this->postDelete($con);
|
||||||
|
$con->commit();
|
||||||
|
$this->setDeleted(true);
|
||||||
|
} else {
|
||||||
|
$con->commit();
|
||||||
|
}
|
||||||
|
} catch (PropelException $e) {
|
||||||
|
$con->rollBack();
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Persists this object to the database.
|
||||||
|
*
|
||||||
|
* If the object is new, it inserts it; otherwise an update is performed.
|
||||||
|
* All modified related objects will also be persisted in the doSave()
|
||||||
|
* method. This method wraps all precipitate database operations in a
|
||||||
|
* single transaction.
|
||||||
|
*
|
||||||
|
* @param PropelPDO $con
|
||||||
|
* @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
|
||||||
|
* @throws PropelException
|
||||||
|
* @see doSave()
|
||||||
|
*/
|
||||||
|
public function save(PropelPDO $con = null)
|
||||||
|
{
|
||||||
|
if ($this->isDeleted()) {
|
||||||
|
throw new PropelException("You cannot save an object that has been deleted.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($con === null) {
|
||||||
|
$con = Propel::getConnection(CcListenerCountPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
|
||||||
|
}
|
||||||
|
|
||||||
|
$con->beginTransaction();
|
||||||
|
$isInsert = $this->isNew();
|
||||||
|
try {
|
||||||
|
$ret = $this->preSave($con);
|
||||||
|
if ($isInsert) {
|
||||||
|
$ret = $ret && $this->preInsert($con);
|
||||||
|
} else {
|
||||||
|
$ret = $ret && $this->preUpdate($con);
|
||||||
|
}
|
||||||
|
if ($ret) {
|
||||||
|
$affectedRows = $this->doSave($con);
|
||||||
|
if ($isInsert) {
|
||||||
|
$this->postInsert($con);
|
||||||
|
} else {
|
||||||
|
$this->postUpdate($con);
|
||||||
|
}
|
||||||
|
$this->postSave($con);
|
||||||
|
CcListenerCountPeer::addInstanceToPool($this);
|
||||||
|
} else {
|
||||||
|
$affectedRows = 0;
|
||||||
|
}
|
||||||
|
$con->commit();
|
||||||
|
return $affectedRows;
|
||||||
|
} catch (PropelException $e) {
|
||||||
|
$con->rollBack();
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Performs the work of inserting or updating the row in the database.
|
||||||
|
*
|
||||||
|
* If the object is new, it inserts it; otherwise an update is performed.
|
||||||
|
* All related objects are also updated in this method.
|
||||||
|
*
|
||||||
|
* @param PropelPDO $con
|
||||||
|
* @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
|
||||||
|
* @throws PropelException
|
||||||
|
* @see save()
|
||||||
|
*/
|
||||||
|
protected function doSave(PropelPDO $con)
|
||||||
|
{
|
||||||
|
$affectedRows = 0; // initialize var to track total num of affected rows
|
||||||
|
if (!$this->alreadyInSave) {
|
||||||
|
$this->alreadyInSave = true;
|
||||||
|
|
||||||
|
// We call the save method on the following object(s) if they
|
||||||
|
// were passed to this object by their coresponding set
|
||||||
|
// method. This object relates to these object(s) by a
|
||||||
|
// foreign key reference.
|
||||||
|
|
||||||
|
if ($this->aCcTimestamp !== null) {
|
||||||
|
if ($this->aCcTimestamp->isModified() || $this->aCcTimestamp->isNew()) {
|
||||||
|
$affectedRows += $this->aCcTimestamp->save($con);
|
||||||
|
}
|
||||||
|
$this->setCcTimestamp($this->aCcTimestamp);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->aCcTimestamp !== null) {
|
||||||
|
if ($this->aCcTimestamp->isModified() || $this->aCcTimestamp->isNew()) {
|
||||||
|
$affectedRows += $this->aCcTimestamp->save($con);
|
||||||
|
}
|
||||||
|
$this->setCcTimestamp($this->aCcTimestamp);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->isNew() ) {
|
||||||
|
$this->modifiedColumns[] = CcListenerCountPeer::ID;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If this object has been modified, then save it to the database.
|
||||||
|
if ($this->isModified()) {
|
||||||
|
if ($this->isNew()) {
|
||||||
|
$criteria = $this->buildCriteria();
|
||||||
|
if ($criteria->keyContainsValue(CcListenerCountPeer::ID) ) {
|
||||||
|
throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcListenerCountPeer::ID.')');
|
||||||
|
}
|
||||||
|
|
||||||
|
$pk = BasePeer::doInsert($criteria, $con);
|
||||||
|
$affectedRows += 1;
|
||||||
|
$this->setDbId($pk); //[IMV] update autoincrement primary key
|
||||||
|
$this->setNew(false);
|
||||||
|
} else {
|
||||||
|
$affectedRows += CcListenerCountPeer::doUpdate($this, $con);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->resetModified(); // [HL] After being saved an object is no longer 'modified'
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->alreadyInSave = false;
|
||||||
|
|
||||||
|
}
|
||||||
|
return $affectedRows;
|
||||||
|
} // doSave()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Array of ValidationFailed objects.
|
||||||
|
* @var array ValidationFailed[]
|
||||||
|
*/
|
||||||
|
protected $validationFailures = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets any ValidationFailed objects that resulted from last call to validate().
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @return array ValidationFailed[]
|
||||||
|
* @see validate()
|
||||||
|
*/
|
||||||
|
public function getValidationFailures()
|
||||||
|
{
|
||||||
|
return $this->validationFailures;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validates the objects modified field values and all objects related to this table.
|
||||||
|
*
|
||||||
|
* If $columns is either a column name or an array of column names
|
||||||
|
* only those columns are validated.
|
||||||
|
*
|
||||||
|
* @param mixed $columns Column name or an array of column names.
|
||||||
|
* @return boolean Whether all columns pass validation.
|
||||||
|
* @see doValidate()
|
||||||
|
* @see getValidationFailures()
|
||||||
|
*/
|
||||||
|
public function validate($columns = null)
|
||||||
|
{
|
||||||
|
$res = $this->doValidate($columns);
|
||||||
|
if ($res === true) {
|
||||||
|
$this->validationFailures = array();
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
$this->validationFailures = $res;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function performs the validation work for complex object models.
|
||||||
|
*
|
||||||
|
* In addition to checking the current object, all related objects will
|
||||||
|
* also be validated. If all pass then <code>true</code> is returned; otherwise
|
||||||
|
* an aggreagated array of ValidationFailed objects will be returned.
|
||||||
|
*
|
||||||
|
* @param array $columns Array of column names to validate.
|
||||||
|
* @return mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise.
|
||||||
|
*/
|
||||||
|
protected function doValidate($columns = null)
|
||||||
|
{
|
||||||
|
if (!$this->alreadyInValidation) {
|
||||||
|
$this->alreadyInValidation = true;
|
||||||
|
$retval = null;
|
||||||
|
|
||||||
|
$failureMap = array();
|
||||||
|
|
||||||
|
|
||||||
|
// We call the validate method on the following object(s) if they
|
||||||
|
// were passed to this object by their coresponding set
|
||||||
|
// method. This object relates to these object(s) by a
|
||||||
|
// foreign key reference.
|
||||||
|
|
||||||
|
if ($this->aCcTimestamp !== null) {
|
||||||
|
if (!$this->aCcTimestamp->validate($columns)) {
|
||||||
|
$failureMap = array_merge($failureMap, $this->aCcTimestamp->getValidationFailures());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->aCcTimestamp !== null) {
|
||||||
|
if (!$this->aCcTimestamp->validate($columns)) {
|
||||||
|
$failureMap = array_merge($failureMap, $this->aCcTimestamp->getValidationFailures());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (($retval = CcListenerCountPeer::doValidate($this, $columns)) !== true) {
|
||||||
|
$failureMap = array_merge($failureMap, $retval);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$this->alreadyInValidation = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (!empty($failureMap) ? $failureMap : true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves a field from the object by name passed in as a string.
|
||||||
|
*
|
||||||
|
* @param string $name name
|
||||||
|
* @param string $type The type of fieldname the $name is of:
|
||||||
|
* one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
|
||||||
|
* BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
|
||||||
|
* @return mixed Value of field.
|
||||||
|
*/
|
||||||
|
public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
|
||||||
|
{
|
||||||
|
$pos = CcListenerCountPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
|
||||||
|
$field = $this->getByPosition($pos);
|
||||||
|
return $field;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves a field from the object by Position as specified in the xml schema.
|
||||||
|
* Zero-based.
|
||||||
|
*
|
||||||
|
* @param int $pos position in xml schema
|
||||||
|
* @return mixed Value of field at $pos
|
||||||
|
*/
|
||||||
|
public function getByPosition($pos)
|
||||||
|
{
|
||||||
|
switch($pos) {
|
||||||
|
case 0:
|
||||||
|
return $this->getDbId();
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
return $this->getDbTimestampId();
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
return $this->getDbMountNameId();
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
return $this->getDbListenerCount();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
break;
|
||||||
|
} // switch()
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Exports the object as an array.
|
||||||
|
*
|
||||||
|
* You can specify the key type of the array by passing one of the class
|
||||||
|
* type constants.
|
||||||
|
*
|
||||||
|
* @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
|
||||||
|
* BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
|
||||||
|
* Defaults to BasePeer::TYPE_PHPNAME.
|
||||||
|
* @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
|
||||||
|
* @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
|
||||||
|
*
|
||||||
|
* @return array an associative array containing the field names (as keys) and field values
|
||||||
|
*/
|
||||||
|
public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $includeForeignObjects = false)
|
||||||
|
{
|
||||||
|
$keys = CcListenerCountPeer::getFieldNames($keyType);
|
||||||
|
$result = array(
|
||||||
|
$keys[0] => $this->getDbId(),
|
||||||
|
$keys[1] => $this->getDbTimestampId(),
|
||||||
|
$keys[2] => $this->getDbMountNameId(),
|
||||||
|
$keys[3] => $this->getDbListenerCount(),
|
||||||
|
);
|
||||||
|
if ($includeForeignObjects) {
|
||||||
|
if (null !== $this->aCcTimestamp) {
|
||||||
|
$result['CcTimestamp'] = $this->aCcTimestamp->toArray($keyType, $includeLazyLoadColumns, true);
|
||||||
|
}
|
||||||
|
if (null !== $this->aCcTimestamp) {
|
||||||
|
$result['CcTimestamp'] = $this->aCcTimestamp->toArray($keyType, $includeLazyLoadColumns, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets a field from the object by name passed in as a string.
|
||||||
|
*
|
||||||
|
* @param string $name peer name
|
||||||
|
* @param mixed $value field value
|
||||||
|
* @param string $type The type of fieldname the $name is of:
|
||||||
|
* one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
|
||||||
|
* BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
|
||||||
|
{
|
||||||
|
$pos = CcListenerCountPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
|
||||||
|
return $this->setByPosition($pos, $value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets a field from the object by Position as specified in the xml schema.
|
||||||
|
* Zero-based.
|
||||||
|
*
|
||||||
|
* @param int $pos position in xml schema
|
||||||
|
* @param mixed $value field value
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function setByPosition($pos, $value)
|
||||||
|
{
|
||||||
|
switch($pos) {
|
||||||
|
case 0:
|
||||||
|
$this->setDbId($value);
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
$this->setDbTimestampId($value);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
$this->setDbMountNameId($value);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
$this->setDbListenerCount($value);
|
||||||
|
break;
|
||||||
|
} // switch()
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Populates the object using an array.
|
||||||
|
*
|
||||||
|
* This is particularly useful when populating an object from one of the
|
||||||
|
* request arrays (e.g. $_POST). This method goes through the column
|
||||||
|
* names, checking to see whether a matching key exists in populated
|
||||||
|
* array. If so the setByName() method is called for that column.
|
||||||
|
*
|
||||||
|
* You can specify the key type of the array by additionally passing one
|
||||||
|
* of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
|
||||||
|
* BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
|
||||||
|
* The default key type is the column's phpname (e.g. 'AuthorId')
|
||||||
|
*
|
||||||
|
* @param array $arr An array to populate the object from.
|
||||||
|
* @param string $keyType The type of keys the array uses.
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
|
||||||
|
{
|
||||||
|
$keys = CcListenerCountPeer::getFieldNames($keyType);
|
||||||
|
|
||||||
|
if (array_key_exists($keys[0], $arr)) $this->setDbId($arr[$keys[0]]);
|
||||||
|
if (array_key_exists($keys[1], $arr)) $this->setDbTimestampId($arr[$keys[1]]);
|
||||||
|
if (array_key_exists($keys[2], $arr)) $this->setDbMountNameId($arr[$keys[2]]);
|
||||||
|
if (array_key_exists($keys[3], $arr)) $this->setDbListenerCount($arr[$keys[3]]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build a Criteria object containing the values of all modified columns in this object.
|
||||||
|
*
|
||||||
|
* @return Criteria The Criteria object containing all modified values.
|
||||||
|
*/
|
||||||
|
public function buildCriteria()
|
||||||
|
{
|
||||||
|
$criteria = new Criteria(CcListenerCountPeer::DATABASE_NAME);
|
||||||
|
|
||||||
|
if ($this->isColumnModified(CcListenerCountPeer::ID)) $criteria->add(CcListenerCountPeer::ID, $this->id);
|
||||||
|
if ($this->isColumnModified(CcListenerCountPeer::TIMESTAMP_ID)) $criteria->add(CcListenerCountPeer::TIMESTAMP_ID, $this->timestamp_id);
|
||||||
|
if ($this->isColumnModified(CcListenerCountPeer::MOUNT_NAME_ID)) $criteria->add(CcListenerCountPeer::MOUNT_NAME_ID, $this->mount_name_id);
|
||||||
|
if ($this->isColumnModified(CcListenerCountPeer::LISTENER_COUNT)) $criteria->add(CcListenerCountPeer::LISTENER_COUNT, $this->listener_count);
|
||||||
|
|
||||||
|
return $criteria;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Builds a Criteria object containing the primary key for this object.
|
||||||
|
*
|
||||||
|
* Unlike buildCriteria() this method includes the primary key values regardless
|
||||||
|
* of whether or not they have been modified.
|
||||||
|
*
|
||||||
|
* @return Criteria The Criteria object containing value(s) for primary key(s).
|
||||||
|
*/
|
||||||
|
public function buildPkeyCriteria()
|
||||||
|
{
|
||||||
|
$criteria = new Criteria(CcListenerCountPeer::DATABASE_NAME);
|
||||||
|
$criteria->add(CcListenerCountPeer::ID, $this->id);
|
||||||
|
|
||||||
|
return $criteria;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the primary key for this object (row).
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getPrimaryKey()
|
||||||
|
{
|
||||||
|
return $this->getDbId();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generic method to set the primary key (id column).
|
||||||
|
*
|
||||||
|
* @param int $key Primary key.
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function setPrimaryKey($key)
|
||||||
|
{
|
||||||
|
$this->setDbId($key);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if the primary key for this object is null.
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public function isPrimaryKeyNull()
|
||||||
|
{
|
||||||
|
return null === $this->getDbId();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets contents of passed object to values from current object.
|
||||||
|
*
|
||||||
|
* If desired, this method can also make copies of all associated (fkey referrers)
|
||||||
|
* objects.
|
||||||
|
*
|
||||||
|
* @param object $copyObj An object of CcListenerCount (or compatible) type.
|
||||||
|
* @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
|
||||||
|
* @throws PropelException
|
||||||
|
*/
|
||||||
|
public function copyInto($copyObj, $deepCopy = false)
|
||||||
|
{
|
||||||
|
$copyObj->setDbTimestampId($this->timestamp_id);
|
||||||
|
$copyObj->setDbMountNameId($this->mount_name_id);
|
||||||
|
$copyObj->setDbListenerCount($this->listener_count);
|
||||||
|
|
||||||
|
$copyObj->setNew(true);
|
||||||
|
$copyObj->setDbId(NULL); // this is a auto-increment column, so set to default value
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Makes a copy of this object that will be inserted as a new row in table when saved.
|
||||||
|
* It creates a new object filling in the simple attributes, but skipping any primary
|
||||||
|
* keys that are defined for the table.
|
||||||
|
*
|
||||||
|
* If desired, this method can also make copies of all associated (fkey referrers)
|
||||||
|
* objects.
|
||||||
|
*
|
||||||
|
* @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
|
||||||
|
* @return CcListenerCount Clone of current object.
|
||||||
|
* @throws PropelException
|
||||||
|
*/
|
||||||
|
public function copy($deepCopy = false)
|
||||||
|
{
|
||||||
|
// we use get_class(), because this might be a subclass
|
||||||
|
$clazz = get_class($this);
|
||||||
|
$copyObj = new $clazz();
|
||||||
|
$this->copyInto($copyObj, $deepCopy);
|
||||||
|
return $copyObj;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a peer instance associated with this om.
|
||||||
|
*
|
||||||
|
* Since Peer classes are not to have any instance attributes, this method returns the
|
||||||
|
* same instance for all member of this class. The method could therefore
|
||||||
|
* be static, but this would prevent one from overriding the behavior.
|
||||||
|
*
|
||||||
|
* @return CcListenerCountPeer
|
||||||
|
*/
|
||||||
|
public function getPeer()
|
||||||
|
{
|
||||||
|
if (self::$peer === null) {
|
||||||
|
self::$peer = new CcListenerCountPeer();
|
||||||
|
}
|
||||||
|
return self::$peer;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Declares an association between this object and a CcTimestamp object.
|
||||||
|
*
|
||||||
|
* @param CcTimestamp $v
|
||||||
|
* @return CcListenerCount The current object (for fluent API support)
|
||||||
|
* @throws PropelException
|
||||||
|
*/
|
||||||
|
public function setCcTimestamp(CcTimestamp $v = null)
|
||||||
|
{
|
||||||
|
if ($v === null) {
|
||||||
|
$this->setDbTimestampId(NULL);
|
||||||
|
} else {
|
||||||
|
$this->setDbTimestampId($v->getDbId());
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->aCcTimestamp = $v;
|
||||||
|
|
||||||
|
// Add binding for other direction of this n:n relationship.
|
||||||
|
// If this object has already been added to the CcTimestamp object, it will not be re-added.
|
||||||
|
if ($v !== null) {
|
||||||
|
$v->addCcListenerCount($this);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the associated CcTimestamp object
|
||||||
|
*
|
||||||
|
* @param PropelPDO Optional Connection object.
|
||||||
|
* @return CcTimestamp The associated CcTimestamp object.
|
||||||
|
* @throws PropelException
|
||||||
|
*/
|
||||||
|
public function getCcTimestamp(PropelPDO $con = null)
|
||||||
|
{
|
||||||
|
if ($this->aCcTimestamp === null && ($this->timestamp_id !== null)) {
|
||||||
|
$this->aCcTimestamp = CcTimestampQuery::create()->findPk($this->timestamp_id, $con);
|
||||||
|
/* The following can be used additionally to
|
||||||
|
guarantee the related object contains a reference
|
||||||
|
to this object. This level of coupling may, however, be
|
||||||
|
undesirable since it could result in an only partially populated collection
|
||||||
|
in the referenced object.
|
||||||
|
$this->aCcTimestamp->addCcListenerCounts($this);
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
return $this->aCcTimestamp;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Declares an association between this object and a CcTimestamp object.
|
||||||
|
*
|
||||||
|
* @param CcTimestamp $v
|
||||||
|
* @return CcListenerCount The current object (for fluent API support)
|
||||||
|
* @throws PropelException
|
||||||
|
*/
|
||||||
|
public function setCcTimestamp(CcTimestamp $v = null)
|
||||||
|
{
|
||||||
|
if ($v === null) {
|
||||||
|
$this->setDbMountNameId(NULL);
|
||||||
|
} else {
|
||||||
|
$this->setDbMountNameId($v->getDbId());
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->aCcTimestamp = $v;
|
||||||
|
|
||||||
|
// Add binding for other direction of this n:n relationship.
|
||||||
|
// If this object has already been added to the CcTimestamp object, it will not be re-added.
|
||||||
|
if ($v !== null) {
|
||||||
|
$v->addCcListenerCount($this);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the associated CcTimestamp object
|
||||||
|
*
|
||||||
|
* @param PropelPDO Optional Connection object.
|
||||||
|
* @return CcTimestamp The associated CcTimestamp object.
|
||||||
|
* @throws PropelException
|
||||||
|
*/
|
||||||
|
public function getCcTimestamp(PropelPDO $con = null)
|
||||||
|
{
|
||||||
|
if ($this->aCcTimestamp === null && ($this->mount_name_id !== null)) {
|
||||||
|
$this->aCcTimestamp = CcTimestampQuery::create()->findPk($this->mount_name_id, $con);
|
||||||
|
/* The following can be used additionally to
|
||||||
|
guarantee the related object contains a reference
|
||||||
|
to this object. This level of coupling may, however, be
|
||||||
|
undesirable since it could result in an only partially populated collection
|
||||||
|
in the referenced object.
|
||||||
|
$this->aCcTimestamp->addCcListenerCounts($this);
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
return $this->aCcTimestamp;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clears the current object and sets all attributes to their default values
|
||||||
|
*/
|
||||||
|
public function clear()
|
||||||
|
{
|
||||||
|
$this->id = null;
|
||||||
|
$this->timestamp_id = null;
|
||||||
|
$this->mount_name_id = null;
|
||||||
|
$this->listener_count = null;
|
||||||
|
$this->alreadyInSave = false;
|
||||||
|
$this->alreadyInValidation = false;
|
||||||
|
$this->clearAllReferences();
|
||||||
|
$this->resetModified();
|
||||||
|
$this->setNew(true);
|
||||||
|
$this->setDeleted(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resets all collections of referencing foreign keys.
|
||||||
|
*
|
||||||
|
* This method is a user-space workaround for PHP's inability to garbage collect objects
|
||||||
|
* with circular references. This is currently necessary when using Propel in certain
|
||||||
|
* daemon or large-volumne/high-memory operations.
|
||||||
|
*
|
||||||
|
* @param boolean $deep Whether to also clear the references on all associated objects.
|
||||||
|
*/
|
||||||
|
public function clearAllReferences($deep = false)
|
||||||
|
{
|
||||||
|
if ($deep) {
|
||||||
|
} // if ($deep)
|
||||||
|
|
||||||
|
$this->aCcTimestamp = null;
|
||||||
|
$this->aCcTimestamp = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Catches calls to virtual methods
|
||||||
|
*/
|
||||||
|
public function __call($name, $params)
|
||||||
|
{
|
||||||
|
if (preg_match('/get(\w+)/', $name, $matches)) {
|
||||||
|
$virtualColumn = $matches[1];
|
||||||
|
if ($this->hasVirtualColumn($virtualColumn)) {
|
||||||
|
return $this->getVirtualColumn($virtualColumn);
|
||||||
|
}
|
||||||
|
// no lcfirst in php<5.3...
|
||||||
|
$virtualColumn[0] = strtolower($virtualColumn[0]);
|
||||||
|
if ($this->hasVirtualColumn($virtualColumn)) {
|
||||||
|
return $this->getVirtualColumn($virtualColumn);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new PropelException('Call to undefined method: ' . $name);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // BaseCcListenerCount
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,406 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Base class that represents a query for the 'cc_listener_count' table.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @method CcListenerCountQuery orderByDbId($order = Criteria::ASC) Order by the id column
|
||||||
|
* @method CcListenerCountQuery orderByDbTimestampId($order = Criteria::ASC) Order by the timestamp_id column
|
||||||
|
* @method CcListenerCountQuery orderByDbMountNameId($order = Criteria::ASC) Order by the mount_name_id column
|
||||||
|
* @method CcListenerCountQuery orderByDbListenerCount($order = Criteria::ASC) Order by the listener_count column
|
||||||
|
*
|
||||||
|
* @method CcListenerCountQuery groupByDbId() Group by the id column
|
||||||
|
* @method CcListenerCountQuery groupByDbTimestampId() Group by the timestamp_id column
|
||||||
|
* @method CcListenerCountQuery groupByDbMountNameId() Group by the mount_name_id column
|
||||||
|
* @method CcListenerCountQuery groupByDbListenerCount() Group by the listener_count column
|
||||||
|
*
|
||||||
|
* @method CcListenerCountQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
|
||||||
|
* @method CcListenerCountQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
|
||||||
|
* @method CcListenerCountQuery innerJoin($relation) Adds a INNER JOIN clause to the query
|
||||||
|
*
|
||||||
|
* @method CcListenerCountQuery leftJoinCcTimestamp($relationAlias = '') Adds a LEFT JOIN clause to the query using the CcTimestamp relation
|
||||||
|
* @method CcListenerCountQuery rightJoinCcTimestamp($relationAlias = '') Adds a RIGHT JOIN clause to the query using the CcTimestamp relation
|
||||||
|
* @method CcListenerCountQuery innerJoinCcTimestamp($relationAlias = '') Adds a INNER JOIN clause to the query using the CcTimestamp relation
|
||||||
|
*
|
||||||
|
* @method CcListenerCountQuery leftJoinCcTimestamp($relationAlias = '') Adds a LEFT JOIN clause to the query using the CcTimestamp relation
|
||||||
|
* @method CcListenerCountQuery rightJoinCcTimestamp($relationAlias = '') Adds a RIGHT JOIN clause to the query using the CcTimestamp relation
|
||||||
|
* @method CcListenerCountQuery innerJoinCcTimestamp($relationAlias = '') Adds a INNER JOIN clause to the query using the CcTimestamp relation
|
||||||
|
*
|
||||||
|
* @method CcListenerCount findOne(PropelPDO $con = null) Return the first CcListenerCount matching the query
|
||||||
|
* @method CcListenerCount findOneOrCreate(PropelPDO $con = null) Return the first CcListenerCount matching the query, or a new CcListenerCount object populated from the query conditions when no match is found
|
||||||
|
*
|
||||||
|
* @method CcListenerCount findOneByDbId(int $id) Return the first CcListenerCount filtered by the id column
|
||||||
|
* @method CcListenerCount findOneByDbTimestampId(int $timestamp_id) Return the first CcListenerCount filtered by the timestamp_id column
|
||||||
|
* @method CcListenerCount findOneByDbMountNameId(int $mount_name_id) Return the first CcListenerCount filtered by the mount_name_id column
|
||||||
|
* @method CcListenerCount findOneByDbListenerCount(int $listener_count) Return the first CcListenerCount filtered by the listener_count column
|
||||||
|
*
|
||||||
|
* @method array findByDbId(int $id) Return CcListenerCount objects filtered by the id column
|
||||||
|
* @method array findByDbTimestampId(int $timestamp_id) Return CcListenerCount objects filtered by the timestamp_id column
|
||||||
|
* @method array findByDbMountNameId(int $mount_name_id) Return CcListenerCount objects filtered by the mount_name_id column
|
||||||
|
* @method array findByDbListenerCount(int $listener_count) Return CcListenerCount objects filtered by the listener_count column
|
||||||
|
*
|
||||||
|
* @package propel.generator.airtime.om
|
||||||
|
*/
|
||||||
|
abstract class BaseCcListenerCountQuery extends ModelCriteria
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes internal state of BaseCcListenerCountQuery object.
|
||||||
|
*
|
||||||
|
* @param string $dbName The dabase name
|
||||||
|
* @param string $modelName The phpName of a model, e.g. 'Book'
|
||||||
|
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
|
||||||
|
*/
|
||||||
|
public function __construct($dbName = 'airtime', $modelName = 'CcListenerCount', $modelAlias = null)
|
||||||
|
{
|
||||||
|
parent::__construct($dbName, $modelName, $modelAlias);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a new CcListenerCountQuery object.
|
||||||
|
*
|
||||||
|
* @param string $modelAlias The alias of a model in the query
|
||||||
|
* @param Criteria $criteria Optional Criteria to build the query from
|
||||||
|
*
|
||||||
|
* @return CcListenerCountQuery
|
||||||
|
*/
|
||||||
|
public static function create($modelAlias = null, $criteria = null)
|
||||||
|
{
|
||||||
|
if ($criteria instanceof CcListenerCountQuery) {
|
||||||
|
return $criteria;
|
||||||
|
}
|
||||||
|
$query = new CcListenerCountQuery();
|
||||||
|
if (null !== $modelAlias) {
|
||||||
|
$query->setModelAlias($modelAlias);
|
||||||
|
}
|
||||||
|
if ($criteria instanceof Criteria) {
|
||||||
|
$query->mergeWith($criteria);
|
||||||
|
}
|
||||||
|
return $query;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find object by primary key
|
||||||
|
* Use instance pooling to avoid a database query if the object exists
|
||||||
|
* <code>
|
||||||
|
* $obj = $c->findPk(12, $con);
|
||||||
|
* </code>
|
||||||
|
* @param mixed $key Primary key to use for the query
|
||||||
|
* @param PropelPDO $con an optional connection object
|
||||||
|
*
|
||||||
|
* @return CcListenerCount|array|mixed the result, formatted by the current formatter
|
||||||
|
*/
|
||||||
|
public function findPk($key, $con = null)
|
||||||
|
{
|
||||||
|
if ((null !== ($obj = CcListenerCountPeer::getInstanceFromPool((string) $key))) && $this->getFormatter()->isObjectFormatter()) {
|
||||||
|
// the object is alredy in the instance pool
|
||||||
|
return $obj;
|
||||||
|
} else {
|
||||||
|
// the object has not been requested yet, or the formatter is not an object formatter
|
||||||
|
$criteria = $this->isKeepQuery() ? clone $this : $this;
|
||||||
|
$stmt = $criteria
|
||||||
|
->filterByPrimaryKey($key)
|
||||||
|
->getSelectStatement($con);
|
||||||
|
return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find objects by primary key
|
||||||
|
* <code>
|
||||||
|
* $objs = $c->findPks(array(12, 56, 832), $con);
|
||||||
|
* </code>
|
||||||
|
* @param array $keys Primary keys to use for the query
|
||||||
|
* @param PropelPDO $con an optional connection object
|
||||||
|
*
|
||||||
|
* @return PropelObjectCollection|array|mixed the list of results, formatted by the current formatter
|
||||||
|
*/
|
||||||
|
public function findPks($keys, $con = null)
|
||||||
|
{
|
||||||
|
$criteria = $this->isKeepQuery() ? clone $this : $this;
|
||||||
|
return $this
|
||||||
|
->filterByPrimaryKeys($keys)
|
||||||
|
->find($con);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filter the query by primary key
|
||||||
|
*
|
||||||
|
* @param mixed $key Primary key to use for the query
|
||||||
|
*
|
||||||
|
* @return CcListenerCountQuery The current query, for fluid interface
|
||||||
|
*/
|
||||||
|
public function filterByPrimaryKey($key)
|
||||||
|
{
|
||||||
|
return $this->addUsingAlias(CcListenerCountPeer::ID, $key, Criteria::EQUAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filter the query by a list of primary keys
|
||||||
|
*
|
||||||
|
* @param array $keys The list of primary key to use for the query
|
||||||
|
*
|
||||||
|
* @return CcListenerCountQuery The current query, for fluid interface
|
||||||
|
*/
|
||||||
|
public function filterByPrimaryKeys($keys)
|
||||||
|
{
|
||||||
|
return $this->addUsingAlias(CcListenerCountPeer::ID, $keys, Criteria::IN);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filter the query on the id column
|
||||||
|
*
|
||||||
|
* @param int|array $dbId The value to use as filter.
|
||||||
|
* Accepts an associative array('min' => $minValue, 'max' => $maxValue)
|
||||||
|
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||||
|
*
|
||||||
|
* @return CcListenerCountQuery The current query, for fluid interface
|
||||||
|
*/
|
||||||
|
public function filterByDbId($dbId = null, $comparison = null)
|
||||||
|
{
|
||||||
|
if (is_array($dbId) && null === $comparison) {
|
||||||
|
$comparison = Criteria::IN;
|
||||||
|
}
|
||||||
|
return $this->addUsingAlias(CcListenerCountPeer::ID, $dbId, $comparison);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filter the query on the timestamp_id column
|
||||||
|
*
|
||||||
|
* @param int|array $dbTimestampId The value to use as filter.
|
||||||
|
* Accepts an associative array('min' => $minValue, 'max' => $maxValue)
|
||||||
|
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||||
|
*
|
||||||
|
* @return CcListenerCountQuery The current query, for fluid interface
|
||||||
|
*/
|
||||||
|
public function filterByDbTimestampId($dbTimestampId = null, $comparison = null)
|
||||||
|
{
|
||||||
|
if (is_array($dbTimestampId)) {
|
||||||
|
$useMinMax = false;
|
||||||
|
if (isset($dbTimestampId['min'])) {
|
||||||
|
$this->addUsingAlias(CcListenerCountPeer::TIMESTAMP_ID, $dbTimestampId['min'], Criteria::GREATER_EQUAL);
|
||||||
|
$useMinMax = true;
|
||||||
|
}
|
||||||
|
if (isset($dbTimestampId['max'])) {
|
||||||
|
$this->addUsingAlias(CcListenerCountPeer::TIMESTAMP_ID, $dbTimestampId['max'], Criteria::LESS_EQUAL);
|
||||||
|
$useMinMax = true;
|
||||||
|
}
|
||||||
|
if ($useMinMax) {
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
if (null === $comparison) {
|
||||||
|
$comparison = Criteria::IN;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $this->addUsingAlias(CcListenerCountPeer::TIMESTAMP_ID, $dbTimestampId, $comparison);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filter the query on the mount_name_id column
|
||||||
|
*
|
||||||
|
* @param int|array $dbMountNameId The value to use as filter.
|
||||||
|
* Accepts an associative array('min' => $minValue, 'max' => $maxValue)
|
||||||
|
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||||
|
*
|
||||||
|
* @return CcListenerCountQuery The current query, for fluid interface
|
||||||
|
*/
|
||||||
|
public function filterByDbMountNameId($dbMountNameId = null, $comparison = null)
|
||||||
|
{
|
||||||
|
if (is_array($dbMountNameId)) {
|
||||||
|
$useMinMax = false;
|
||||||
|
if (isset($dbMountNameId['min'])) {
|
||||||
|
$this->addUsingAlias(CcListenerCountPeer::MOUNT_NAME_ID, $dbMountNameId['min'], Criteria::GREATER_EQUAL);
|
||||||
|
$useMinMax = true;
|
||||||
|
}
|
||||||
|
if (isset($dbMountNameId['max'])) {
|
||||||
|
$this->addUsingAlias(CcListenerCountPeer::MOUNT_NAME_ID, $dbMountNameId['max'], Criteria::LESS_EQUAL);
|
||||||
|
$useMinMax = true;
|
||||||
|
}
|
||||||
|
if ($useMinMax) {
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
if (null === $comparison) {
|
||||||
|
$comparison = Criteria::IN;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $this->addUsingAlias(CcListenerCountPeer::MOUNT_NAME_ID, $dbMountNameId, $comparison);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filter the query on the listener_count column
|
||||||
|
*
|
||||||
|
* @param int|array $dbListenerCount The value to use as filter.
|
||||||
|
* Accepts an associative array('min' => $minValue, 'max' => $maxValue)
|
||||||
|
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||||
|
*
|
||||||
|
* @return CcListenerCountQuery The current query, for fluid interface
|
||||||
|
*/
|
||||||
|
public function filterByDbListenerCount($dbListenerCount = null, $comparison = null)
|
||||||
|
{
|
||||||
|
if (is_array($dbListenerCount)) {
|
||||||
|
$useMinMax = false;
|
||||||
|
if (isset($dbListenerCount['min'])) {
|
||||||
|
$this->addUsingAlias(CcListenerCountPeer::LISTENER_COUNT, $dbListenerCount['min'], Criteria::GREATER_EQUAL);
|
||||||
|
$useMinMax = true;
|
||||||
|
}
|
||||||
|
if (isset($dbListenerCount['max'])) {
|
||||||
|
$this->addUsingAlias(CcListenerCountPeer::LISTENER_COUNT, $dbListenerCount['max'], Criteria::LESS_EQUAL);
|
||||||
|
$useMinMax = true;
|
||||||
|
}
|
||||||
|
if ($useMinMax) {
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
if (null === $comparison) {
|
||||||
|
$comparison = Criteria::IN;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $this->addUsingAlias(CcListenerCountPeer::LISTENER_COUNT, $dbListenerCount, $comparison);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filter the query by a related CcTimestamp object
|
||||||
|
*
|
||||||
|
* @param CcTimestamp $ccTimestamp the related object to use as filter
|
||||||
|
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||||
|
*
|
||||||
|
* @return CcListenerCountQuery The current query, for fluid interface
|
||||||
|
*/
|
||||||
|
public function filterByCcTimestamp($ccTimestamp, $comparison = null)
|
||||||
|
{
|
||||||
|
return $this
|
||||||
|
->addUsingAlias(CcListenerCountPeer::TIMESTAMP_ID, $ccTimestamp->getDbId(), $comparison);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a JOIN clause to the query using the CcTimestamp relation
|
||||||
|
*
|
||||||
|
* @param string $relationAlias optional alias for the relation
|
||||||
|
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
|
||||||
|
*
|
||||||
|
* @return CcListenerCountQuery The current query, for fluid interface
|
||||||
|
*/
|
||||||
|
public function joinCcTimestamp($relationAlias = '', $joinType = Criteria::INNER_JOIN)
|
||||||
|
{
|
||||||
|
$tableMap = $this->getTableMap();
|
||||||
|
$relationMap = $tableMap->getRelation('CcTimestamp');
|
||||||
|
|
||||||
|
// create a ModelJoin object for this join
|
||||||
|
$join = new ModelJoin();
|
||||||
|
$join->setJoinType($joinType);
|
||||||
|
$join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
|
||||||
|
if ($previousJoin = $this->getPreviousJoin()) {
|
||||||
|
$join->setPreviousJoin($previousJoin);
|
||||||
|
}
|
||||||
|
|
||||||
|
// add the ModelJoin to the current object
|
||||||
|
if($relationAlias) {
|
||||||
|
$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
|
||||||
|
$this->addJoinObject($join, $relationAlias);
|
||||||
|
} else {
|
||||||
|
$this->addJoinObject($join, 'CcTimestamp');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use the CcTimestamp relation CcTimestamp object
|
||||||
|
*
|
||||||
|
* @see useQuery()
|
||||||
|
*
|
||||||
|
* @param string $relationAlias optional alias for the relation,
|
||||||
|
* to be used as main alias in the secondary query
|
||||||
|
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
|
||||||
|
*
|
||||||
|
* @return CcTimestampQuery A secondary query class using the current class as primary query
|
||||||
|
*/
|
||||||
|
public function useCcTimestampQuery($relationAlias = '', $joinType = Criteria::INNER_JOIN)
|
||||||
|
{
|
||||||
|
return $this
|
||||||
|
->joinCcTimestamp($relationAlias, $joinType)
|
||||||
|
->useQuery($relationAlias ? $relationAlias : 'CcTimestamp', 'CcTimestampQuery');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filter the query by a related CcTimestamp object
|
||||||
|
*
|
||||||
|
* @param CcTimestamp $ccTimestamp the related object to use as filter
|
||||||
|
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||||
|
*
|
||||||
|
* @return CcListenerCountQuery The current query, for fluid interface
|
||||||
|
*/
|
||||||
|
public function filterByCcTimestamp($ccTimestamp, $comparison = null)
|
||||||
|
{
|
||||||
|
return $this
|
||||||
|
->addUsingAlias(CcListenerCountPeer::MOUNT_NAME_ID, $ccTimestamp->getDbId(), $comparison);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a JOIN clause to the query using the CcTimestamp relation
|
||||||
|
*
|
||||||
|
* @param string $relationAlias optional alias for the relation
|
||||||
|
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
|
||||||
|
*
|
||||||
|
* @return CcListenerCountQuery The current query, for fluid interface
|
||||||
|
*/
|
||||||
|
public function joinCcTimestamp($relationAlias = '', $joinType = Criteria::INNER_JOIN)
|
||||||
|
{
|
||||||
|
$tableMap = $this->getTableMap();
|
||||||
|
$relationMap = $tableMap->getRelation('CcTimestamp');
|
||||||
|
|
||||||
|
// create a ModelJoin object for this join
|
||||||
|
$join = new ModelJoin();
|
||||||
|
$join->setJoinType($joinType);
|
||||||
|
$join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
|
||||||
|
if ($previousJoin = $this->getPreviousJoin()) {
|
||||||
|
$join->setPreviousJoin($previousJoin);
|
||||||
|
}
|
||||||
|
|
||||||
|
// add the ModelJoin to the current object
|
||||||
|
if($relationAlias) {
|
||||||
|
$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
|
||||||
|
$this->addJoinObject($join, $relationAlias);
|
||||||
|
} else {
|
||||||
|
$this->addJoinObject($join, 'CcTimestamp');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use the CcTimestamp relation CcTimestamp object
|
||||||
|
*
|
||||||
|
* @see useQuery()
|
||||||
|
*
|
||||||
|
* @param string $relationAlias optional alias for the relation,
|
||||||
|
* to be used as main alias in the secondary query
|
||||||
|
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
|
||||||
|
*
|
||||||
|
* @return CcTimestampQuery A secondary query class using the current class as primary query
|
||||||
|
*/
|
||||||
|
public function useCcTimestampQuery($relationAlias = '', $joinType = Criteria::INNER_JOIN)
|
||||||
|
{
|
||||||
|
return $this
|
||||||
|
->joinCcTimestamp($relationAlias, $joinType)
|
||||||
|
->useQuery($relationAlias ? $relationAlias : 'CcTimestamp', 'CcTimestampQuery');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Exclude object from result
|
||||||
|
*
|
||||||
|
* @param CcListenerCount $ccListenerCount Object to remove from the list of results
|
||||||
|
*
|
||||||
|
* @return CcListenerCountQuery The current query, for fluid interface
|
||||||
|
*/
|
||||||
|
public function prune($ccListenerCount = null)
|
||||||
|
{
|
||||||
|
if ($ccListenerCount) {
|
||||||
|
$this->addUsingAlias(CcListenerCountPeer::ID, $ccListenerCount->getDbId(), Criteria::NOT_EQUAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // BaseCcListenerCountQuery
|
|
@ -0,0 +1,920 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Base class that represents a row from the 'cc_timestamp' table.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @package propel.generator.airtime.om
|
||||||
|
*/
|
||||||
|
abstract class BaseCcTimestamp extends BaseObject implements Persistent
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Peer class name
|
||||||
|
*/
|
||||||
|
const PEER = 'CcTimestampPeer';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Peer class.
|
||||||
|
* Instance provides a convenient way of calling static methods on a class
|
||||||
|
* that calling code may not be able to identify.
|
||||||
|
* @var CcTimestampPeer
|
||||||
|
*/
|
||||||
|
protected static $peer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The value for the id field.
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
protected $id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The value for the timestamp field.
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $timestamp;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array CcListenerCount[] Collection to store aggregation of CcListenerCount objects.
|
||||||
|
*/
|
||||||
|
protected $collCcListenerCounts;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Flag to prevent endless save loop, if this object is referenced
|
||||||
|
* by another object which falls in this transaction.
|
||||||
|
* @var boolean
|
||||||
|
*/
|
||||||
|
protected $alreadyInSave = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Flag to prevent endless validation loop, if this object is referenced
|
||||||
|
* by another object which falls in this transaction.
|
||||||
|
* @var boolean
|
||||||
|
*/
|
||||||
|
protected $alreadyInValidation = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the [id] column value.
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getDbId()
|
||||||
|
{
|
||||||
|
return $this->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the [optionally formatted] temporal [timestamp] column value.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @param string $format The date/time format string (either date()-style or strftime()-style).
|
||||||
|
* If format is NULL, then the raw DateTime object will be returned.
|
||||||
|
* @return mixed Formatted date/time value as string or DateTime object (if format is NULL), NULL if column is NULL
|
||||||
|
* @throws PropelException - if unable to parse/validate the date/time value.
|
||||||
|
*/
|
||||||
|
public function getDbTimestamp($format = 'Y-m-d H:i:s')
|
||||||
|
{
|
||||||
|
if ($this->timestamp === null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
try {
|
||||||
|
$dt = new DateTime($this->timestamp);
|
||||||
|
} catch (Exception $x) {
|
||||||
|
throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->timestamp, true), $x);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($format === null) {
|
||||||
|
// Because propel.useDateTimeClass is TRUE, we return a DateTime object.
|
||||||
|
return $dt;
|
||||||
|
} elseif (strpos($format, '%') !== false) {
|
||||||
|
return strftime($format, $dt->format('U'));
|
||||||
|
} else {
|
||||||
|
return $dt->format($format);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the value of [id] column.
|
||||||
|
*
|
||||||
|
* @param int $v new value
|
||||||
|
* @return CcTimestamp The current object (for fluent API support)
|
||||||
|
*/
|
||||||
|
public function setDbId($v)
|
||||||
|
{
|
||||||
|
if ($v !== null) {
|
||||||
|
$v = (int) $v;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->id !== $v) {
|
||||||
|
$this->id = $v;
|
||||||
|
$this->modifiedColumns[] = CcTimestampPeer::ID;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
} // setDbId()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the value of [timestamp] column to a normalized version of the date/time value specified.
|
||||||
|
*
|
||||||
|
* @param mixed $v string, integer (timestamp), or DateTime value. Empty string will
|
||||||
|
* be treated as NULL for temporal objects.
|
||||||
|
* @return CcTimestamp The current object (for fluent API support)
|
||||||
|
*/
|
||||||
|
public function setDbTimestamp($v)
|
||||||
|
{
|
||||||
|
// we treat '' as NULL for temporal objects because DateTime('') == DateTime('now')
|
||||||
|
// -- which is unexpected, to say the least.
|
||||||
|
if ($v === null || $v === '') {
|
||||||
|
$dt = null;
|
||||||
|
} elseif ($v instanceof DateTime) {
|
||||||
|
$dt = $v;
|
||||||
|
} else {
|
||||||
|
// some string/numeric value passed; we normalize that so that we can
|
||||||
|
// validate it.
|
||||||
|
try {
|
||||||
|
if (is_numeric($v)) { // if it's a unix timestamp
|
||||||
|
$dt = new DateTime('@'.$v, new DateTimeZone('UTC'));
|
||||||
|
// We have to explicitly specify and then change the time zone because of a
|
||||||
|
// DateTime bug: http://bugs.php.net/bug.php?id=43003
|
||||||
|
$dt->setTimeZone(new DateTimeZone(date_default_timezone_get()));
|
||||||
|
} else {
|
||||||
|
$dt = new DateTime($v);
|
||||||
|
}
|
||||||
|
} catch (Exception $x) {
|
||||||
|
throw new PropelException('Error parsing date/time value: ' . var_export($v, true), $x);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( $this->timestamp !== null || $dt !== null ) {
|
||||||
|
// (nested ifs are a little easier to read in this case)
|
||||||
|
|
||||||
|
$currNorm = ($this->timestamp !== null && $tmpDt = new DateTime($this->timestamp)) ? $tmpDt->format('Y-m-d\\TH:i:sO') : null;
|
||||||
|
$newNorm = ($dt !== null) ? $dt->format('Y-m-d\\TH:i:sO') : null;
|
||||||
|
|
||||||
|
if ( ($currNorm !== $newNorm) // normalized values don't match
|
||||||
|
)
|
||||||
|
{
|
||||||
|
$this->timestamp = ($dt ? $dt->format('Y-m-d\\TH:i:sO') : null);
|
||||||
|
$this->modifiedColumns[] = CcTimestampPeer::TIMESTAMP;
|
||||||
|
}
|
||||||
|
} // if either are not null
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
} // setDbTimestamp()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates whether the columns in this object are only set to default values.
|
||||||
|
*
|
||||||
|
* This method can be used in conjunction with isModified() to indicate whether an object is both
|
||||||
|
* modified _and_ has some values set which are non-default.
|
||||||
|
*
|
||||||
|
* @return boolean Whether the columns in this object are only been set with default values.
|
||||||
|
*/
|
||||||
|
public function hasOnlyDefaultValues()
|
||||||
|
{
|
||||||
|
// otherwise, everything was equal, so return TRUE
|
||||||
|
return true;
|
||||||
|
} // hasOnlyDefaultValues()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hydrates (populates) the object variables with values from the database resultset.
|
||||||
|
*
|
||||||
|
* An offset (0-based "start column") is specified so that objects can be hydrated
|
||||||
|
* with a subset of the columns in the resultset rows. This is needed, for example,
|
||||||
|
* for results of JOIN queries where the resultset row includes columns from two or
|
||||||
|
* more tables.
|
||||||
|
*
|
||||||
|
* @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
|
||||||
|
* @param int $startcol 0-based offset column which indicates which restultset column to start with.
|
||||||
|
* @param boolean $rehydrate Whether this object is being re-hydrated from the database.
|
||||||
|
* @return int next starting column
|
||||||
|
* @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
|
||||||
|
*/
|
||||||
|
public function hydrate($row, $startcol = 0, $rehydrate = false)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
|
||||||
|
$this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
|
||||||
|
$this->timestamp = ($row[$startcol + 1] !== null) ? (string) $row[$startcol + 1] : null;
|
||||||
|
$this->resetModified();
|
||||||
|
|
||||||
|
$this->setNew(false);
|
||||||
|
|
||||||
|
if ($rehydrate) {
|
||||||
|
$this->ensureConsistency();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $startcol + 2; // 2 = CcTimestampPeer::NUM_COLUMNS - CcTimestampPeer::NUM_LAZY_LOAD_COLUMNS).
|
||||||
|
|
||||||
|
} catch (Exception $e) {
|
||||||
|
throw new PropelException("Error populating CcTimestamp object", $e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks and repairs the internal consistency of the object.
|
||||||
|
*
|
||||||
|
* This method is executed after an already-instantiated object is re-hydrated
|
||||||
|
* from the database. It exists to check any foreign keys to make sure that
|
||||||
|
* the objects related to the current object are correct based on foreign key.
|
||||||
|
*
|
||||||
|
* You can override this method in the stub class, but you should always invoke
|
||||||
|
* the base method from the overridden method (i.e. parent::ensureConsistency()),
|
||||||
|
* in case your model changes.
|
||||||
|
*
|
||||||
|
* @throws PropelException
|
||||||
|
*/
|
||||||
|
public function ensureConsistency()
|
||||||
|
{
|
||||||
|
|
||||||
|
} // ensureConsistency
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
|
||||||
|
*
|
||||||
|
* This will only work if the object has been saved and has a valid primary key set.
|
||||||
|
*
|
||||||
|
* @param boolean $deep (optional) Whether to also de-associated any related objects.
|
||||||
|
* @param PropelPDO $con (optional) The PropelPDO connection to use.
|
||||||
|
* @return void
|
||||||
|
* @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
|
||||||
|
*/
|
||||||
|
public function reload($deep = false, PropelPDO $con = null)
|
||||||
|
{
|
||||||
|
if ($this->isDeleted()) {
|
||||||
|
throw new PropelException("Cannot reload a deleted object.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->isNew()) {
|
||||||
|
throw new PropelException("Cannot reload an unsaved object.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($con === null) {
|
||||||
|
$con = Propel::getConnection(CcTimestampPeer::DATABASE_NAME, Propel::CONNECTION_READ);
|
||||||
|
}
|
||||||
|
|
||||||
|
// We don't need to alter the object instance pool; we're just modifying this instance
|
||||||
|
// already in the pool.
|
||||||
|
|
||||||
|
$stmt = CcTimestampPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
|
||||||
|
$row = $stmt->fetch(PDO::FETCH_NUM);
|
||||||
|
$stmt->closeCursor();
|
||||||
|
if (!$row) {
|
||||||
|
throw new PropelException('Cannot find matching row in the database to reload object values.');
|
||||||
|
}
|
||||||
|
$this->hydrate($row, 0, true); // rehydrate
|
||||||
|
|
||||||
|
if ($deep) { // also de-associate any related objects?
|
||||||
|
|
||||||
|
$this->collCcListenerCounts = null;
|
||||||
|
|
||||||
|
} // if (deep)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes this object from datastore and sets delete attribute.
|
||||||
|
*
|
||||||
|
* @param PropelPDO $con
|
||||||
|
* @return void
|
||||||
|
* @throws PropelException
|
||||||
|
* @see BaseObject::setDeleted()
|
||||||
|
* @see BaseObject::isDeleted()
|
||||||
|
*/
|
||||||
|
public function delete(PropelPDO $con = null)
|
||||||
|
{
|
||||||
|
if ($this->isDeleted()) {
|
||||||
|
throw new PropelException("This object has already been deleted.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($con === null) {
|
||||||
|
$con = Propel::getConnection(CcTimestampPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
|
||||||
|
}
|
||||||
|
|
||||||
|
$con->beginTransaction();
|
||||||
|
try {
|
||||||
|
$ret = $this->preDelete($con);
|
||||||
|
if ($ret) {
|
||||||
|
CcTimestampQuery::create()
|
||||||
|
->filterByPrimaryKey($this->getPrimaryKey())
|
||||||
|
->delete($con);
|
||||||
|
$this->postDelete($con);
|
||||||
|
$con->commit();
|
||||||
|
$this->setDeleted(true);
|
||||||
|
} else {
|
||||||
|
$con->commit();
|
||||||
|
}
|
||||||
|
} catch (PropelException $e) {
|
||||||
|
$con->rollBack();
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Persists this object to the database.
|
||||||
|
*
|
||||||
|
* If the object is new, it inserts it; otherwise an update is performed.
|
||||||
|
* All modified related objects will also be persisted in the doSave()
|
||||||
|
* method. This method wraps all precipitate database operations in a
|
||||||
|
* single transaction.
|
||||||
|
*
|
||||||
|
* @param PropelPDO $con
|
||||||
|
* @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
|
||||||
|
* @throws PropelException
|
||||||
|
* @see doSave()
|
||||||
|
*/
|
||||||
|
public function save(PropelPDO $con = null)
|
||||||
|
{
|
||||||
|
if ($this->isDeleted()) {
|
||||||
|
throw new PropelException("You cannot save an object that has been deleted.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($con === null) {
|
||||||
|
$con = Propel::getConnection(CcTimestampPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
|
||||||
|
}
|
||||||
|
|
||||||
|
$con->beginTransaction();
|
||||||
|
$isInsert = $this->isNew();
|
||||||
|
try {
|
||||||
|
$ret = $this->preSave($con);
|
||||||
|
if ($isInsert) {
|
||||||
|
$ret = $ret && $this->preInsert($con);
|
||||||
|
} else {
|
||||||
|
$ret = $ret && $this->preUpdate($con);
|
||||||
|
}
|
||||||
|
if ($ret) {
|
||||||
|
$affectedRows = $this->doSave($con);
|
||||||
|
if ($isInsert) {
|
||||||
|
$this->postInsert($con);
|
||||||
|
} else {
|
||||||
|
$this->postUpdate($con);
|
||||||
|
}
|
||||||
|
$this->postSave($con);
|
||||||
|
CcTimestampPeer::addInstanceToPool($this);
|
||||||
|
} else {
|
||||||
|
$affectedRows = 0;
|
||||||
|
}
|
||||||
|
$con->commit();
|
||||||
|
return $affectedRows;
|
||||||
|
} catch (PropelException $e) {
|
||||||
|
$con->rollBack();
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Performs the work of inserting or updating the row in the database.
|
||||||
|
*
|
||||||
|
* If the object is new, it inserts it; otherwise an update is performed.
|
||||||
|
* All related objects are also updated in this method.
|
||||||
|
*
|
||||||
|
* @param PropelPDO $con
|
||||||
|
* @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
|
||||||
|
* @throws PropelException
|
||||||
|
* @see save()
|
||||||
|
*/
|
||||||
|
protected function doSave(PropelPDO $con)
|
||||||
|
{
|
||||||
|
$affectedRows = 0; // initialize var to track total num of affected rows
|
||||||
|
if (!$this->alreadyInSave) {
|
||||||
|
$this->alreadyInSave = true;
|
||||||
|
|
||||||
|
if ($this->isNew() ) {
|
||||||
|
$this->modifiedColumns[] = CcTimestampPeer::ID;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If this object has been modified, then save it to the database.
|
||||||
|
if ($this->isModified()) {
|
||||||
|
if ($this->isNew()) {
|
||||||
|
$criteria = $this->buildCriteria();
|
||||||
|
if ($criteria->keyContainsValue(CcTimestampPeer::ID) ) {
|
||||||
|
throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcTimestampPeer::ID.')');
|
||||||
|
}
|
||||||
|
|
||||||
|
$pk = BasePeer::doInsert($criteria, $con);
|
||||||
|
$affectedRows = 1;
|
||||||
|
$this->setDbId($pk); //[IMV] update autoincrement primary key
|
||||||
|
$this->setNew(false);
|
||||||
|
} else {
|
||||||
|
$affectedRows = CcTimestampPeer::doUpdate($this, $con);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->resetModified(); // [HL] After being saved an object is no longer 'modified'
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->collCcListenerCounts !== null) {
|
||||||
|
foreach ($this->collCcListenerCounts as $referrerFK) {
|
||||||
|
if (!$referrerFK->isDeleted()) {
|
||||||
|
$affectedRows += $referrerFK->save($con);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->alreadyInSave = false;
|
||||||
|
|
||||||
|
}
|
||||||
|
return $affectedRows;
|
||||||
|
} // doSave()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Array of ValidationFailed objects.
|
||||||
|
* @var array ValidationFailed[]
|
||||||
|
*/
|
||||||
|
protected $validationFailures = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets any ValidationFailed objects that resulted from last call to validate().
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @return array ValidationFailed[]
|
||||||
|
* @see validate()
|
||||||
|
*/
|
||||||
|
public function getValidationFailures()
|
||||||
|
{
|
||||||
|
return $this->validationFailures;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validates the objects modified field values and all objects related to this table.
|
||||||
|
*
|
||||||
|
* If $columns is either a column name or an array of column names
|
||||||
|
* only those columns are validated.
|
||||||
|
*
|
||||||
|
* @param mixed $columns Column name or an array of column names.
|
||||||
|
* @return boolean Whether all columns pass validation.
|
||||||
|
* @see doValidate()
|
||||||
|
* @see getValidationFailures()
|
||||||
|
*/
|
||||||
|
public function validate($columns = null)
|
||||||
|
{
|
||||||
|
$res = $this->doValidate($columns);
|
||||||
|
if ($res === true) {
|
||||||
|
$this->validationFailures = array();
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
$this->validationFailures = $res;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function performs the validation work for complex object models.
|
||||||
|
*
|
||||||
|
* In addition to checking the current object, all related objects will
|
||||||
|
* also be validated. If all pass then <code>true</code> is returned; otherwise
|
||||||
|
* an aggreagated array of ValidationFailed objects will be returned.
|
||||||
|
*
|
||||||
|
* @param array $columns Array of column names to validate.
|
||||||
|
* @return mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise.
|
||||||
|
*/
|
||||||
|
protected function doValidate($columns = null)
|
||||||
|
{
|
||||||
|
if (!$this->alreadyInValidation) {
|
||||||
|
$this->alreadyInValidation = true;
|
||||||
|
$retval = null;
|
||||||
|
|
||||||
|
$failureMap = array();
|
||||||
|
|
||||||
|
|
||||||
|
if (($retval = CcTimestampPeer::doValidate($this, $columns)) !== true) {
|
||||||
|
$failureMap = array_merge($failureMap, $retval);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if ($this->collCcListenerCounts !== null) {
|
||||||
|
foreach ($this->collCcListenerCounts as $referrerFK) {
|
||||||
|
if (!$referrerFK->validate($columns)) {
|
||||||
|
$failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$this->alreadyInValidation = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (!empty($failureMap) ? $failureMap : true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves a field from the object by name passed in as a string.
|
||||||
|
*
|
||||||
|
* @param string $name name
|
||||||
|
* @param string $type The type of fieldname the $name is of:
|
||||||
|
* one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
|
||||||
|
* BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
|
||||||
|
* @return mixed Value of field.
|
||||||
|
*/
|
||||||
|
public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
|
||||||
|
{
|
||||||
|
$pos = CcTimestampPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
|
||||||
|
$field = $this->getByPosition($pos);
|
||||||
|
return $field;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves a field from the object by Position as specified in the xml schema.
|
||||||
|
* Zero-based.
|
||||||
|
*
|
||||||
|
* @param int $pos position in xml schema
|
||||||
|
* @return mixed Value of field at $pos
|
||||||
|
*/
|
||||||
|
public function getByPosition($pos)
|
||||||
|
{
|
||||||
|
switch($pos) {
|
||||||
|
case 0:
|
||||||
|
return $this->getDbId();
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
return $this->getDbTimestamp();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
break;
|
||||||
|
} // switch()
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Exports the object as an array.
|
||||||
|
*
|
||||||
|
* You can specify the key type of the array by passing one of the class
|
||||||
|
* type constants.
|
||||||
|
*
|
||||||
|
* @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
|
||||||
|
* BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
|
||||||
|
* Defaults to BasePeer::TYPE_PHPNAME.
|
||||||
|
* @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE.
|
||||||
|
*
|
||||||
|
* @return array an associative array containing the field names (as keys) and field values
|
||||||
|
*/
|
||||||
|
public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true)
|
||||||
|
{
|
||||||
|
$keys = CcTimestampPeer::getFieldNames($keyType);
|
||||||
|
$result = array(
|
||||||
|
$keys[0] => $this->getDbId(),
|
||||||
|
$keys[1] => $this->getDbTimestamp(),
|
||||||
|
);
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets a field from the object by name passed in as a string.
|
||||||
|
*
|
||||||
|
* @param string $name peer name
|
||||||
|
* @param mixed $value field value
|
||||||
|
* @param string $type The type of fieldname the $name is of:
|
||||||
|
* one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
|
||||||
|
* BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
|
||||||
|
{
|
||||||
|
$pos = CcTimestampPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
|
||||||
|
return $this->setByPosition($pos, $value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets a field from the object by Position as specified in the xml schema.
|
||||||
|
* Zero-based.
|
||||||
|
*
|
||||||
|
* @param int $pos position in xml schema
|
||||||
|
* @param mixed $value field value
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function setByPosition($pos, $value)
|
||||||
|
{
|
||||||
|
switch($pos) {
|
||||||
|
case 0:
|
||||||
|
$this->setDbId($value);
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
$this->setDbTimestamp($value);
|
||||||
|
break;
|
||||||
|
} // switch()
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Populates the object using an array.
|
||||||
|
*
|
||||||
|
* This is particularly useful when populating an object from one of the
|
||||||
|
* request arrays (e.g. $_POST). This method goes through the column
|
||||||
|
* names, checking to see whether a matching key exists in populated
|
||||||
|
* array. If so the setByName() method is called for that column.
|
||||||
|
*
|
||||||
|
* You can specify the key type of the array by additionally passing one
|
||||||
|
* of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
|
||||||
|
* BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
|
||||||
|
* The default key type is the column's phpname (e.g. 'AuthorId')
|
||||||
|
*
|
||||||
|
* @param array $arr An array to populate the object from.
|
||||||
|
* @param string $keyType The type of keys the array uses.
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
|
||||||
|
{
|
||||||
|
$keys = CcTimestampPeer::getFieldNames($keyType);
|
||||||
|
|
||||||
|
if (array_key_exists($keys[0], $arr)) $this->setDbId($arr[$keys[0]]);
|
||||||
|
if (array_key_exists($keys[1], $arr)) $this->setDbTimestamp($arr[$keys[1]]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build a Criteria object containing the values of all modified columns in this object.
|
||||||
|
*
|
||||||
|
* @return Criteria The Criteria object containing all modified values.
|
||||||
|
*/
|
||||||
|
public function buildCriteria()
|
||||||
|
{
|
||||||
|
$criteria = new Criteria(CcTimestampPeer::DATABASE_NAME);
|
||||||
|
|
||||||
|
if ($this->isColumnModified(CcTimestampPeer::ID)) $criteria->add(CcTimestampPeer::ID, $this->id);
|
||||||
|
if ($this->isColumnModified(CcTimestampPeer::TIMESTAMP)) $criteria->add(CcTimestampPeer::TIMESTAMP, $this->timestamp);
|
||||||
|
|
||||||
|
return $criteria;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Builds a Criteria object containing the primary key for this object.
|
||||||
|
*
|
||||||
|
* Unlike buildCriteria() this method includes the primary key values regardless
|
||||||
|
* of whether or not they have been modified.
|
||||||
|
*
|
||||||
|
* @return Criteria The Criteria object containing value(s) for primary key(s).
|
||||||
|
*/
|
||||||
|
public function buildPkeyCriteria()
|
||||||
|
{
|
||||||
|
$criteria = new Criteria(CcTimestampPeer::DATABASE_NAME);
|
||||||
|
$criteria->add(CcTimestampPeer::ID, $this->id);
|
||||||
|
|
||||||
|
return $criteria;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the primary key for this object (row).
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getPrimaryKey()
|
||||||
|
{
|
||||||
|
return $this->getDbId();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generic method to set the primary key (id column).
|
||||||
|
*
|
||||||
|
* @param int $key Primary key.
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function setPrimaryKey($key)
|
||||||
|
{
|
||||||
|
$this->setDbId($key);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if the primary key for this object is null.
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public function isPrimaryKeyNull()
|
||||||
|
{
|
||||||
|
return null === $this->getDbId();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets contents of passed object to values from current object.
|
||||||
|
*
|
||||||
|
* If desired, this method can also make copies of all associated (fkey referrers)
|
||||||
|
* objects.
|
||||||
|
*
|
||||||
|
* @param object $copyObj An object of CcTimestamp (or compatible) type.
|
||||||
|
* @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
|
||||||
|
* @throws PropelException
|
||||||
|
*/
|
||||||
|
public function copyInto($copyObj, $deepCopy = false)
|
||||||
|
{
|
||||||
|
$copyObj->setDbTimestamp($this->timestamp);
|
||||||
|
|
||||||
|
if ($deepCopy) {
|
||||||
|
// important: temporarily setNew(false) because this affects the behavior of
|
||||||
|
// the getter/setter methods for fkey referrer objects.
|
||||||
|
$copyObj->setNew(false);
|
||||||
|
|
||||||
|
foreach ($this->getCcListenerCounts() as $relObj) {
|
||||||
|
if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
|
||||||
|
$copyObj->addCcListenerCount($relObj->copy($deepCopy));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // if ($deepCopy)
|
||||||
|
|
||||||
|
|
||||||
|
$copyObj->setNew(true);
|
||||||
|
$copyObj->setDbId(NULL); // this is a auto-increment column, so set to default value
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Makes a copy of this object that will be inserted as a new row in table when saved.
|
||||||
|
* It creates a new object filling in the simple attributes, but skipping any primary
|
||||||
|
* keys that are defined for the table.
|
||||||
|
*
|
||||||
|
* If desired, this method can also make copies of all associated (fkey referrers)
|
||||||
|
* objects.
|
||||||
|
*
|
||||||
|
* @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
|
||||||
|
* @return CcTimestamp Clone of current object.
|
||||||
|
* @throws PropelException
|
||||||
|
*/
|
||||||
|
public function copy($deepCopy = false)
|
||||||
|
{
|
||||||
|
// we use get_class(), because this might be a subclass
|
||||||
|
$clazz = get_class($this);
|
||||||
|
$copyObj = new $clazz();
|
||||||
|
$this->copyInto($copyObj, $deepCopy);
|
||||||
|
return $copyObj;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a peer instance associated with this om.
|
||||||
|
*
|
||||||
|
* Since Peer classes are not to have any instance attributes, this method returns the
|
||||||
|
* same instance for all member of this class. The method could therefore
|
||||||
|
* be static, but this would prevent one from overriding the behavior.
|
||||||
|
*
|
||||||
|
* @return CcTimestampPeer
|
||||||
|
*/
|
||||||
|
public function getPeer()
|
||||||
|
{
|
||||||
|
if (self::$peer === null) {
|
||||||
|
self::$peer = new CcTimestampPeer();
|
||||||
|
}
|
||||||
|
return self::$peer;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clears out the collCcListenerCounts collection
|
||||||
|
*
|
||||||
|
* This does not modify the database; however, it will remove any associated objects, causing
|
||||||
|
* them to be refetched by subsequent calls to accessor method.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @see addCcListenerCounts()
|
||||||
|
*/
|
||||||
|
public function clearCcListenerCounts()
|
||||||
|
{
|
||||||
|
$this->collCcListenerCounts = null; // important to set this to NULL since that means it is uninitialized
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the collCcListenerCounts collection.
|
||||||
|
*
|
||||||
|
* By default this just sets the collCcListenerCounts collection to an empty array (like clearcollCcListenerCounts());
|
||||||
|
* however, you may wish to override this method in your stub class to provide setting appropriate
|
||||||
|
* to your application -- for example, setting the initial array to the values stored in database.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function initCcListenerCounts()
|
||||||
|
{
|
||||||
|
$this->collCcListenerCounts = new PropelObjectCollection();
|
||||||
|
$this->collCcListenerCounts->setModel('CcListenerCount');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets an array of CcListenerCount objects which contain a foreign key that references this object.
|
||||||
|
*
|
||||||
|
* If the $criteria is not null, it is used to always fetch the results from the database.
|
||||||
|
* Otherwise the results are fetched from the database the first time, then cached.
|
||||||
|
* Next time the same method is called without $criteria, the cached collection is returned.
|
||||||
|
* If this CcTimestamp is new, it will return
|
||||||
|
* an empty collection or the current collection; the criteria is ignored on a new object.
|
||||||
|
*
|
||||||
|
* @param Criteria $criteria optional Criteria object to narrow the query
|
||||||
|
* @param PropelPDO $con optional connection object
|
||||||
|
* @return PropelCollection|array CcListenerCount[] List of CcListenerCount objects
|
||||||
|
* @throws PropelException
|
||||||
|
*/
|
||||||
|
public function getCcListenerCounts($criteria = null, PropelPDO $con = null)
|
||||||
|
{
|
||||||
|
if(null === $this->collCcListenerCounts || null !== $criteria) {
|
||||||
|
if ($this->isNew() && null === $this->collCcListenerCounts) {
|
||||||
|
// return empty collection
|
||||||
|
$this->initCcListenerCounts();
|
||||||
|
} else {
|
||||||
|
$collCcListenerCounts = CcListenerCountQuery::create(null, $criteria)
|
||||||
|
->filterByCcTimestamp($this)
|
||||||
|
->find($con);
|
||||||
|
if (null !== $criteria) {
|
||||||
|
return $collCcListenerCounts;
|
||||||
|
}
|
||||||
|
$this->collCcListenerCounts = $collCcListenerCounts;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $this->collCcListenerCounts;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the number of related CcListenerCount objects.
|
||||||
|
*
|
||||||
|
* @param Criteria $criteria
|
||||||
|
* @param boolean $distinct
|
||||||
|
* @param PropelPDO $con
|
||||||
|
* @return int Count of related CcListenerCount objects.
|
||||||
|
* @throws PropelException
|
||||||
|
*/
|
||||||
|
public function countCcListenerCounts(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
|
||||||
|
{
|
||||||
|
if(null === $this->collCcListenerCounts || null !== $criteria) {
|
||||||
|
if ($this->isNew() && null === $this->collCcListenerCounts) {
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
|
$query = CcListenerCountQuery::create(null, $criteria);
|
||||||
|
if($distinct) {
|
||||||
|
$query->distinct();
|
||||||
|
}
|
||||||
|
return $query
|
||||||
|
->filterByCcTimestamp($this)
|
||||||
|
->count($con);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return count($this->collCcListenerCounts);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method called to associate a CcListenerCount object to this object
|
||||||
|
* through the CcListenerCount foreign key attribute.
|
||||||
|
*
|
||||||
|
* @param CcListenerCount $l CcListenerCount
|
||||||
|
* @return void
|
||||||
|
* @throws PropelException
|
||||||
|
*/
|
||||||
|
public function addCcListenerCount(CcListenerCount $l)
|
||||||
|
{
|
||||||
|
if ($this->collCcListenerCounts === null) {
|
||||||
|
$this->initCcListenerCounts();
|
||||||
|
}
|
||||||
|
if (!$this->collCcListenerCounts->contains($l)) { // only add it if the **same** object is not already associated
|
||||||
|
$this->collCcListenerCounts[]= $l;
|
||||||
|
$l->setCcTimestamp($this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clears the current object and sets all attributes to their default values
|
||||||
|
*/
|
||||||
|
public function clear()
|
||||||
|
{
|
||||||
|
$this->id = null;
|
||||||
|
$this->timestamp = null;
|
||||||
|
$this->alreadyInSave = false;
|
||||||
|
$this->alreadyInValidation = false;
|
||||||
|
$this->clearAllReferences();
|
||||||
|
$this->resetModified();
|
||||||
|
$this->setNew(true);
|
||||||
|
$this->setDeleted(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resets all collections of referencing foreign keys.
|
||||||
|
*
|
||||||
|
* This method is a user-space workaround for PHP's inability to garbage collect objects
|
||||||
|
* with circular references. This is currently necessary when using Propel in certain
|
||||||
|
* daemon or large-volumne/high-memory operations.
|
||||||
|
*
|
||||||
|
* @param boolean $deep Whether to also clear the references on all associated objects.
|
||||||
|
*/
|
||||||
|
public function clearAllReferences($deep = false)
|
||||||
|
{
|
||||||
|
if ($deep) {
|
||||||
|
if ($this->collCcListenerCounts) {
|
||||||
|
foreach ((array) $this->collCcListenerCounts as $o) {
|
||||||
|
$o->clearAllReferences($deep);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} // if ($deep)
|
||||||
|
|
||||||
|
$this->collCcListenerCounts = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Catches calls to virtual methods
|
||||||
|
*/
|
||||||
|
public function __call($name, $params)
|
||||||
|
{
|
||||||
|
if (preg_match('/get(\w+)/', $name, $matches)) {
|
||||||
|
$virtualColumn = $matches[1];
|
||||||
|
if ($this->hasVirtualColumn($virtualColumn)) {
|
||||||
|
return $this->getVirtualColumn($virtualColumn);
|
||||||
|
}
|
||||||
|
// no lcfirst in php<5.3...
|
||||||
|
$virtualColumn[0] = strtolower($virtualColumn[0]);
|
||||||
|
if ($this->hasVirtualColumn($virtualColumn)) {
|
||||||
|
return $this->getVirtualColumn($virtualColumn);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new PropelException('Call to undefined method: ' . $name);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // BaseCcTimestamp
|
|
@ -0,0 +1,742 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Base static class for performing query and update operations on the 'cc_timestamp' table.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @package propel.generator.airtime.om
|
||||||
|
*/
|
||||||
|
abstract class BaseCcTimestampPeer {
|
||||||
|
|
||||||
|
/** the default database name for this class */
|
||||||
|
const DATABASE_NAME = 'airtime';
|
||||||
|
|
||||||
|
/** the table name for this class */
|
||||||
|
const TABLE_NAME = 'cc_timestamp';
|
||||||
|
|
||||||
|
/** the related Propel class for this table */
|
||||||
|
const OM_CLASS = 'CcTimestamp';
|
||||||
|
|
||||||
|
/** A class that can be returned by this peer. */
|
||||||
|
const CLASS_DEFAULT = 'airtime.CcTimestamp';
|
||||||
|
|
||||||
|
/** the related TableMap class for this table */
|
||||||
|
const TM_CLASS = 'CcTimestampTableMap';
|
||||||
|
|
||||||
|
/** The total number of columns. */
|
||||||
|
const NUM_COLUMNS = 2;
|
||||||
|
|
||||||
|
/** The number of lazy-loaded columns. */
|
||||||
|
const NUM_LAZY_LOAD_COLUMNS = 0;
|
||||||
|
|
||||||
|
/** the column name for the ID field */
|
||||||
|
const ID = 'cc_timestamp.ID';
|
||||||
|
|
||||||
|
/** the column name for the TIMESTAMP field */
|
||||||
|
const TIMESTAMP = 'cc_timestamp.TIMESTAMP';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An identiy map to hold any loaded instances of CcTimestamp objects.
|
||||||
|
* This must be public so that other peer classes can access this when hydrating from JOIN
|
||||||
|
* queries.
|
||||||
|
* @var array CcTimestamp[]
|
||||||
|
*/
|
||||||
|
public static $instances = array();
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* holds an array of fieldnames
|
||||||
|
*
|
||||||
|
* first dimension keys are the type constants
|
||||||
|
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
|
||||||
|
*/
|
||||||
|
private static $fieldNames = array (
|
||||||
|
BasePeer::TYPE_PHPNAME => array ('DbId', 'DbTimestamp', ),
|
||||||
|
BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbTimestamp', ),
|
||||||
|
BasePeer::TYPE_COLNAME => array (self::ID, self::TIMESTAMP, ),
|
||||||
|
BasePeer::TYPE_RAW_COLNAME => array ('ID', 'TIMESTAMP', ),
|
||||||
|
BasePeer::TYPE_FIELDNAME => array ('id', 'timestamp', ),
|
||||||
|
BasePeer::TYPE_NUM => array (0, 1, )
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* holds an array of keys for quick access to the fieldnames array
|
||||||
|
*
|
||||||
|
* first dimension keys are the type constants
|
||||||
|
* e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
|
||||||
|
*/
|
||||||
|
private static $fieldKeys = array (
|
||||||
|
BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbTimestamp' => 1, ),
|
||||||
|
BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbTimestamp' => 1, ),
|
||||||
|
BasePeer::TYPE_COLNAME => array (self::ID => 0, self::TIMESTAMP => 1, ),
|
||||||
|
BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'TIMESTAMP' => 1, ),
|
||||||
|
BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'timestamp' => 1, ),
|
||||||
|
BasePeer::TYPE_NUM => array (0, 1, )
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Translates a fieldname to another type
|
||||||
|
*
|
||||||
|
* @param string $name field name
|
||||||
|
* @param string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
|
||||||
|
* BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
|
||||||
|
* @param string $toType One of the class type constants
|
||||||
|
* @return string translated name of the field.
|
||||||
|
* @throws PropelException - if the specified name could not be found in the fieldname mappings.
|
||||||
|
*/
|
||||||
|
static public function translateFieldName($name, $fromType, $toType)
|
||||||
|
{
|
||||||
|
$toNames = self::getFieldNames($toType);
|
||||||
|
$key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null;
|
||||||
|
if ($key === null) {
|
||||||
|
throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true));
|
||||||
|
}
|
||||||
|
return $toNames[$key];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns an array of field names.
|
||||||
|
*
|
||||||
|
* @param string $type The type of fieldnames to return:
|
||||||
|
* One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
|
||||||
|
* BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
|
||||||
|
* @return array A list of field names
|
||||||
|
*/
|
||||||
|
|
||||||
|
static public function getFieldNames($type = BasePeer::TYPE_PHPNAME)
|
||||||
|
{
|
||||||
|
if (!array_key_exists($type, self::$fieldNames)) {
|
||||||
|
throw new PropelException('Method getFieldNames() expects the parameter $type to be one of the class constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME, BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM. ' . $type . ' was given.');
|
||||||
|
}
|
||||||
|
return self::$fieldNames[$type];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convenience method which changes table.column to alias.column.
|
||||||
|
*
|
||||||
|
* Using this method you can maintain SQL abstraction while using column aliases.
|
||||||
|
* <code>
|
||||||
|
* $c->addAlias("alias1", TablePeer::TABLE_NAME);
|
||||||
|
* $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN);
|
||||||
|
* </code>
|
||||||
|
* @param string $alias The alias for the current table.
|
||||||
|
* @param string $column The column name for current table. (i.e. CcTimestampPeer::COLUMN_NAME).
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public static function alias($alias, $column)
|
||||||
|
{
|
||||||
|
return str_replace(CcTimestampPeer::TABLE_NAME.'.', $alias.'.', $column);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add all the columns needed to create a new object.
|
||||||
|
*
|
||||||
|
* Note: any columns that were marked with lazyLoad="true" in the
|
||||||
|
* XML schema will not be added to the select list and only loaded
|
||||||
|
* on demand.
|
||||||
|
*
|
||||||
|
* @param Criteria $criteria object containing the columns to add.
|
||||||
|
* @param string $alias optional table alias
|
||||||
|
* @throws PropelException Any exceptions caught during processing will be
|
||||||
|
* rethrown wrapped into a PropelException.
|
||||||
|
*/
|
||||||
|
public static function addSelectColumns(Criteria $criteria, $alias = null)
|
||||||
|
{
|
||||||
|
if (null === $alias) {
|
||||||
|
$criteria->addSelectColumn(CcTimestampPeer::ID);
|
||||||
|
$criteria->addSelectColumn(CcTimestampPeer::TIMESTAMP);
|
||||||
|
} else {
|
||||||
|
$criteria->addSelectColumn($alias . '.ID');
|
||||||
|
$criteria->addSelectColumn($alias . '.TIMESTAMP');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the number of rows matching criteria.
|
||||||
|
*
|
||||||
|
* @param Criteria $criteria
|
||||||
|
* @param boolean $distinct Whether to select only distinct columns; deprecated: use Criteria->setDistinct() instead.
|
||||||
|
* @param PropelPDO $con
|
||||||
|
* @return int Number of matching rows.
|
||||||
|
*/
|
||||||
|
public static function doCount(Criteria $criteria, $distinct = false, PropelPDO $con = null)
|
||||||
|
{
|
||||||
|
// we may modify criteria, so copy it first
|
||||||
|
$criteria = clone $criteria;
|
||||||
|
|
||||||
|
// We need to set the primary table name, since in the case that there are no WHERE columns
|
||||||
|
// it will be impossible for the BasePeer::createSelectSql() method to determine which
|
||||||
|
// tables go into the FROM clause.
|
||||||
|
$criteria->setPrimaryTableName(CcTimestampPeer::TABLE_NAME);
|
||||||
|
|
||||||
|
if ($distinct && !in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) {
|
||||||
|
$criteria->setDistinct();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$criteria->hasSelectClause()) {
|
||||||
|
CcTimestampPeer::addSelectColumns($criteria);
|
||||||
|
}
|
||||||
|
|
||||||
|
$criteria->clearOrderByColumns(); // ORDER BY won't ever affect the count
|
||||||
|
$criteria->setDbName(self::DATABASE_NAME); // Set the correct dbName
|
||||||
|
|
||||||
|
if ($con === null) {
|
||||||
|
$con = Propel::getConnection(CcTimestampPeer::DATABASE_NAME, Propel::CONNECTION_READ);
|
||||||
|
}
|
||||||
|
// BasePeer returns a PDOStatement
|
||||||
|
$stmt = BasePeer::doCount($criteria, $con);
|
||||||
|
|
||||||
|
if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
|
||||||
|
$count = (int) $row[0];
|
||||||
|
} else {
|
||||||
|
$count = 0; // no rows returned; we infer that means 0 matches.
|
||||||
|
}
|
||||||
|
$stmt->closeCursor();
|
||||||
|
return $count;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Method to select one object from the DB.
|
||||||
|
*
|
||||||
|
* @param Criteria $criteria object used to create the SELECT statement.
|
||||||
|
* @param PropelPDO $con
|
||||||
|
* @return CcTimestamp
|
||||||
|
* @throws PropelException Any exceptions caught during processing will be
|
||||||
|
* rethrown wrapped into a PropelException.
|
||||||
|
*/
|
||||||
|
public static function doSelectOne(Criteria $criteria, PropelPDO $con = null)
|
||||||
|
{
|
||||||
|
$critcopy = clone $criteria;
|
||||||
|
$critcopy->setLimit(1);
|
||||||
|
$objects = CcTimestampPeer::doSelect($critcopy, $con);
|
||||||
|
if ($objects) {
|
||||||
|
return $objects[0];
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Method to do selects.
|
||||||
|
*
|
||||||
|
* @param Criteria $criteria The Criteria object used to build the SELECT statement.
|
||||||
|
* @param PropelPDO $con
|
||||||
|
* @return array Array of selected Objects
|
||||||
|
* @throws PropelException Any exceptions caught during processing will be
|
||||||
|
* rethrown wrapped into a PropelException.
|
||||||
|
*/
|
||||||
|
public static function doSelect(Criteria $criteria, PropelPDO $con = null)
|
||||||
|
{
|
||||||
|
return CcTimestampPeer::populateObjects(CcTimestampPeer::doSelectStmt($criteria, $con));
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Prepares the Criteria object and uses the parent doSelect() method to execute a PDOStatement.
|
||||||
|
*
|
||||||
|
* Use this method directly if you want to work with an executed statement durirectly (for example
|
||||||
|
* to perform your own object hydration).
|
||||||
|
*
|
||||||
|
* @param Criteria $criteria The Criteria object used to build the SELECT statement.
|
||||||
|
* @param PropelPDO $con The connection to use
|
||||||
|
* @throws PropelException Any exceptions caught during processing will be
|
||||||
|
* rethrown wrapped into a PropelException.
|
||||||
|
* @return PDOStatement The executed PDOStatement object.
|
||||||
|
* @see BasePeer::doSelect()
|
||||||
|
*/
|
||||||
|
public static function doSelectStmt(Criteria $criteria, PropelPDO $con = null)
|
||||||
|
{
|
||||||
|
if ($con === null) {
|
||||||
|
$con = Propel::getConnection(CcTimestampPeer::DATABASE_NAME, Propel::CONNECTION_READ);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$criteria->hasSelectClause()) {
|
||||||
|
$criteria = clone $criteria;
|
||||||
|
CcTimestampPeer::addSelectColumns($criteria);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set the correct dbName
|
||||||
|
$criteria->setDbName(self::DATABASE_NAME);
|
||||||
|
|
||||||
|
// BasePeer returns a PDOStatement
|
||||||
|
return BasePeer::doSelect($criteria, $con);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Adds an object to the instance pool.
|
||||||
|
*
|
||||||
|
* Propel keeps cached copies of objects in an instance pool when they are retrieved
|
||||||
|
* from the database. In some cases -- especially when you override doSelect*()
|
||||||
|
* methods in your stub classes -- you may need to explicitly add objects
|
||||||
|
* to the cache in order to ensure that the same objects are always returned by doSelect*()
|
||||||
|
* and retrieveByPK*() calls.
|
||||||
|
*
|
||||||
|
* @param CcTimestamp $value A CcTimestamp object.
|
||||||
|
* @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
|
||||||
|
*/
|
||||||
|
public static function addInstanceToPool(CcTimestamp $obj, $key = null)
|
||||||
|
{
|
||||||
|
if (Propel::isInstancePoolingEnabled()) {
|
||||||
|
if ($key === null) {
|
||||||
|
$key = (string) $obj->getDbId();
|
||||||
|
} // if key === null
|
||||||
|
self::$instances[$key] = $obj;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes an object from the instance pool.
|
||||||
|
*
|
||||||
|
* Propel keeps cached copies of objects in an instance pool when they are retrieved
|
||||||
|
* from the database. In some cases -- especially when you override doDelete
|
||||||
|
* methods in your stub classes -- you may need to explicitly remove objects
|
||||||
|
* from the cache in order to prevent returning objects that no longer exist.
|
||||||
|
*
|
||||||
|
* @param mixed $value A CcTimestamp object or a primary key value.
|
||||||
|
*/
|
||||||
|
public static function removeInstanceFromPool($value)
|
||||||
|
{
|
||||||
|
if (Propel::isInstancePoolingEnabled() && $value !== null) {
|
||||||
|
if (is_object($value) && $value instanceof CcTimestamp) {
|
||||||
|
$key = (string) $value->getDbId();
|
||||||
|
} elseif (is_scalar($value)) {
|
||||||
|
// assume we've been passed a primary key
|
||||||
|
$key = (string) $value;
|
||||||
|
} else {
|
||||||
|
$e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or CcTimestamp object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value,true)));
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
|
||||||
|
unset(self::$instances[$key]);
|
||||||
|
}
|
||||||
|
} // removeInstanceFromPool()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
|
||||||
|
*
|
||||||
|
* For tables with a single-column primary key, that simple pkey value will be returned. For tables with
|
||||||
|
* a multi-column primary key, a serialize()d version of the primary key will be returned.
|
||||||
|
*
|
||||||
|
* @param string $key The key (@see getPrimaryKeyHash()) for this instance.
|
||||||
|
* @return CcTimestamp Found object or NULL if 1) no instance exists for specified key or 2) instance pooling has been disabled.
|
||||||
|
* @see getPrimaryKeyHash()
|
||||||
|
*/
|
||||||
|
public static function getInstanceFromPool($key)
|
||||||
|
{
|
||||||
|
if (Propel::isInstancePoolingEnabled()) {
|
||||||
|
if (isset(self::$instances[$key])) {
|
||||||
|
return self::$instances[$key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null; // just to be explicit
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clear the instance pool.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public static function clearInstancePool()
|
||||||
|
{
|
||||||
|
self::$instances = array();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method to invalidate the instance pool of all tables related to cc_timestamp
|
||||||
|
* by a foreign key with ON DELETE CASCADE
|
||||||
|
*/
|
||||||
|
public static function clearRelatedInstancePool()
|
||||||
|
{
|
||||||
|
// Invalidate objects in CcListenerCountPeer instance pool,
|
||||||
|
// since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule.
|
||||||
|
CcListenerCountPeer::clearInstancePool();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table.
|
||||||
|
*
|
||||||
|
* For tables with a single-column primary key, that simple pkey value will be returned. For tables with
|
||||||
|
* a multi-column primary key, a serialize()d version of the primary key will be returned.
|
||||||
|
*
|
||||||
|
* @param array $row PropelPDO resultset row.
|
||||||
|
* @param int $startcol The 0-based offset for reading from the resultset row.
|
||||||
|
* @return string A string version of PK or NULL if the components of primary key in result array are all null.
|
||||||
|
*/
|
||||||
|
public static function getPrimaryKeyHashFromRow($row, $startcol = 0)
|
||||||
|
{
|
||||||
|
// If the PK cannot be derived from the row, return NULL.
|
||||||
|
if ($row[$startcol] === null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return (string) $row[$startcol];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the primary key from the DB resultset row
|
||||||
|
* For tables with a single-column primary key, that simple pkey value will be returned. For tables with
|
||||||
|
* a multi-column primary key, an array of the primary key columns will be returned.
|
||||||
|
*
|
||||||
|
* @param array $row PropelPDO resultset row.
|
||||||
|
* @param int $startcol The 0-based offset for reading from the resultset row.
|
||||||
|
* @return mixed The primary key of the row
|
||||||
|
*/
|
||||||
|
public static function getPrimaryKeyFromRow($row, $startcol = 0)
|
||||||
|
{
|
||||||
|
return (int) $row[$startcol];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The returned array will contain objects of the default type or
|
||||||
|
* objects that inherit from the default.
|
||||||
|
*
|
||||||
|
* @throws PropelException Any exceptions caught during processing will be
|
||||||
|
* rethrown wrapped into a PropelException.
|
||||||
|
*/
|
||||||
|
public static function populateObjects(PDOStatement $stmt)
|
||||||
|
{
|
||||||
|
$results = array();
|
||||||
|
|
||||||
|
// set the class once to avoid overhead in the loop
|
||||||
|
$cls = CcTimestampPeer::getOMClass(false);
|
||||||
|
// populate the object(s)
|
||||||
|
while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
|
||||||
|
$key = CcTimestampPeer::getPrimaryKeyHashFromRow($row, 0);
|
||||||
|
if (null !== ($obj = CcTimestampPeer::getInstanceFromPool($key))) {
|
||||||
|
// We no longer rehydrate the object, since this can cause data loss.
|
||||||
|
// See http://www.propelorm.org/ticket/509
|
||||||
|
// $obj->hydrate($row, 0, true); // rehydrate
|
||||||
|
$results[] = $obj;
|
||||||
|
} else {
|
||||||
|
$obj = new $cls();
|
||||||
|
$obj->hydrate($row);
|
||||||
|
$results[] = $obj;
|
||||||
|
CcTimestampPeer::addInstanceToPool($obj, $key);
|
||||||
|
} // if key exists
|
||||||
|
}
|
||||||
|
$stmt->closeCursor();
|
||||||
|
return $results;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Populates an object of the default type or an object that inherit from the default.
|
||||||
|
*
|
||||||
|
* @param array $row PropelPDO resultset row.
|
||||||
|
* @param int $startcol The 0-based offset for reading from the resultset row.
|
||||||
|
* @throws PropelException Any exceptions caught during processing will be
|
||||||
|
* rethrown wrapped into a PropelException.
|
||||||
|
* @return array (CcTimestamp object, last column rank)
|
||||||
|
*/
|
||||||
|
public static function populateObject($row, $startcol = 0)
|
||||||
|
{
|
||||||
|
$key = CcTimestampPeer::getPrimaryKeyHashFromRow($row, $startcol);
|
||||||
|
if (null !== ($obj = CcTimestampPeer::getInstanceFromPool($key))) {
|
||||||
|
// We no longer rehydrate the object, since this can cause data loss.
|
||||||
|
// See http://www.propelorm.org/ticket/509
|
||||||
|
// $obj->hydrate($row, $startcol, true); // rehydrate
|
||||||
|
$col = $startcol + CcTimestampPeer::NUM_COLUMNS;
|
||||||
|
} else {
|
||||||
|
$cls = CcTimestampPeer::OM_CLASS;
|
||||||
|
$obj = new $cls();
|
||||||
|
$col = $obj->hydrate($row, $startcol);
|
||||||
|
CcTimestampPeer::addInstanceToPool($obj, $key);
|
||||||
|
}
|
||||||
|
return array($obj, $col);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Returns the TableMap related to this peer.
|
||||||
|
* This method is not needed for general use but a specific application could have a need.
|
||||||
|
* @return TableMap
|
||||||
|
* @throws PropelException Any exceptions caught during processing will be
|
||||||
|
* rethrown wrapped into a PropelException.
|
||||||
|
*/
|
||||||
|
public static function getTableMap()
|
||||||
|
{
|
||||||
|
return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a TableMap instance to the database for this peer class.
|
||||||
|
*/
|
||||||
|
public static function buildTableMap()
|
||||||
|
{
|
||||||
|
$dbMap = Propel::getDatabaseMap(BaseCcTimestampPeer::DATABASE_NAME);
|
||||||
|
if (!$dbMap->hasTable(BaseCcTimestampPeer::TABLE_NAME))
|
||||||
|
{
|
||||||
|
$dbMap->addTableObject(new CcTimestampTableMap());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The class that the Peer will make instances of.
|
||||||
|
*
|
||||||
|
* If $withPrefix is true, the returned path
|
||||||
|
* uses a dot-path notation which is tranalted into a path
|
||||||
|
* relative to a location on the PHP include_path.
|
||||||
|
* (e.g. path.to.MyClass -> 'path/to/MyClass.php')
|
||||||
|
*
|
||||||
|
* @param boolean $withPrefix Whether or not to return the path with the class name
|
||||||
|
* @return string path.to.ClassName
|
||||||
|
*/
|
||||||
|
public static function getOMClass($withPrefix = true)
|
||||||
|
{
|
||||||
|
return $withPrefix ? CcTimestampPeer::CLASS_DEFAULT : CcTimestampPeer::OM_CLASS;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method perform an INSERT on the database, given a CcTimestamp or Criteria object.
|
||||||
|
*
|
||||||
|
* @param mixed $values Criteria or CcTimestamp object containing data that is used to create the INSERT statement.
|
||||||
|
* @param PropelPDO $con the PropelPDO connection to use
|
||||||
|
* @return mixed The new primary key.
|
||||||
|
* @throws PropelException Any exceptions caught during processing will be
|
||||||
|
* rethrown wrapped into a PropelException.
|
||||||
|
*/
|
||||||
|
public static function doInsert($values, PropelPDO $con = null)
|
||||||
|
{
|
||||||
|
if ($con === null) {
|
||||||
|
$con = Propel::getConnection(CcTimestampPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($values instanceof Criteria) {
|
||||||
|
$criteria = clone $values; // rename for clarity
|
||||||
|
} else {
|
||||||
|
$criteria = $values->buildCriteria(); // build Criteria from CcTimestamp object
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($criteria->containsKey(CcTimestampPeer::ID) && $criteria->keyContainsValue(CcTimestampPeer::ID) ) {
|
||||||
|
throw new PropelException('Cannot insert a value for auto-increment primary key ('.CcTimestampPeer::ID.')');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Set the correct dbName
|
||||||
|
$criteria->setDbName(self::DATABASE_NAME);
|
||||||
|
|
||||||
|
try {
|
||||||
|
// use transaction because $criteria could contain info
|
||||||
|
// for more than one table (I guess, conceivably)
|
||||||
|
$con->beginTransaction();
|
||||||
|
$pk = BasePeer::doInsert($criteria, $con);
|
||||||
|
$con->commit();
|
||||||
|
} catch(PropelException $e) {
|
||||||
|
$con->rollBack();
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $pk;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method perform an UPDATE on the database, given a CcTimestamp or Criteria object.
|
||||||
|
*
|
||||||
|
* @param mixed $values Criteria or CcTimestamp object containing data that is used to create the UPDATE statement.
|
||||||
|
* @param PropelPDO $con The connection to use (specify PropelPDO connection object to exert more control over transactions).
|
||||||
|
* @return int The number of affected rows (if supported by underlying database driver).
|
||||||
|
* @throws PropelException Any exceptions caught during processing will be
|
||||||
|
* rethrown wrapped into a PropelException.
|
||||||
|
*/
|
||||||
|
public static function doUpdate($values, PropelPDO $con = null)
|
||||||
|
{
|
||||||
|
if ($con === null) {
|
||||||
|
$con = Propel::getConnection(CcTimestampPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
|
||||||
|
}
|
||||||
|
|
||||||
|
$selectCriteria = new Criteria(self::DATABASE_NAME);
|
||||||
|
|
||||||
|
if ($values instanceof Criteria) {
|
||||||
|
$criteria = clone $values; // rename for clarity
|
||||||
|
|
||||||
|
$comparison = $criteria->getComparison(CcTimestampPeer::ID);
|
||||||
|
$value = $criteria->remove(CcTimestampPeer::ID);
|
||||||
|
if ($value) {
|
||||||
|
$selectCriteria->add(CcTimestampPeer::ID, $value, $comparison);
|
||||||
|
} else {
|
||||||
|
$selectCriteria->setPrimaryTableName(CcTimestampPeer::TABLE_NAME);
|
||||||
|
}
|
||||||
|
|
||||||
|
} else { // $values is CcTimestamp object
|
||||||
|
$criteria = $values->buildCriteria(); // gets full criteria
|
||||||
|
$selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
|
||||||
|
}
|
||||||
|
|
||||||
|
// set the correct dbName
|
||||||
|
$criteria->setDbName(self::DATABASE_NAME);
|
||||||
|
|
||||||
|
return BasePeer::doUpdate($selectCriteria, $criteria, $con);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method to DELETE all rows from the cc_timestamp table.
|
||||||
|
*
|
||||||
|
* @return int The number of affected rows (if supported by underlying database driver).
|
||||||
|
*/
|
||||||
|
public static function doDeleteAll($con = null)
|
||||||
|
{
|
||||||
|
if ($con === null) {
|
||||||
|
$con = Propel::getConnection(CcTimestampPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
|
||||||
|
}
|
||||||
|
$affectedRows = 0; // initialize var to track total num of affected rows
|
||||||
|
try {
|
||||||
|
// use transaction because $criteria could contain info
|
||||||
|
// for more than one table or we could emulating ON DELETE CASCADE, etc.
|
||||||
|
$con->beginTransaction();
|
||||||
|
$affectedRows += BasePeer::doDeleteAll(CcTimestampPeer::TABLE_NAME, $con, CcTimestampPeer::DATABASE_NAME);
|
||||||
|
// Because this db requires some delete cascade/set null emulation, we have to
|
||||||
|
// clear the cached instance *after* the emulation has happened (since
|
||||||
|
// instances get re-added by the select statement contained therein).
|
||||||
|
CcTimestampPeer::clearInstancePool();
|
||||||
|
CcTimestampPeer::clearRelatedInstancePool();
|
||||||
|
$con->commit();
|
||||||
|
return $affectedRows;
|
||||||
|
} catch (PropelException $e) {
|
||||||
|
$con->rollBack();
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method perform a DELETE on the database, given a CcTimestamp or Criteria object OR a primary key value.
|
||||||
|
*
|
||||||
|
* @param mixed $values Criteria or CcTimestamp object or primary key or array of primary keys
|
||||||
|
* which is used to create the DELETE statement
|
||||||
|
* @param PropelPDO $con the connection to use
|
||||||
|
* @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
|
||||||
|
* if supported by native driver or if emulated using Propel.
|
||||||
|
* @throws PropelException Any exceptions caught during processing will be
|
||||||
|
* rethrown wrapped into a PropelException.
|
||||||
|
*/
|
||||||
|
public static function doDelete($values, PropelPDO $con = null)
|
||||||
|
{
|
||||||
|
if ($con === null) {
|
||||||
|
$con = Propel::getConnection(CcTimestampPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($values instanceof Criteria) {
|
||||||
|
// invalidate the cache for all objects of this type, since we have no
|
||||||
|
// way of knowing (without running a query) what objects should be invalidated
|
||||||
|
// from the cache based on this Criteria.
|
||||||
|
CcTimestampPeer::clearInstancePool();
|
||||||
|
// rename for clarity
|
||||||
|
$criteria = clone $values;
|
||||||
|
} elseif ($values instanceof CcTimestamp) { // it's a model object
|
||||||
|
// invalidate the cache for this single object
|
||||||
|
CcTimestampPeer::removeInstanceFromPool($values);
|
||||||
|
// create criteria based on pk values
|
||||||
|
$criteria = $values->buildPkeyCriteria();
|
||||||
|
} else { // it's a primary key, or an array of pks
|
||||||
|
$criteria = new Criteria(self::DATABASE_NAME);
|
||||||
|
$criteria->add(CcTimestampPeer::ID, (array) $values, Criteria::IN);
|
||||||
|
// invalidate the cache for this object(s)
|
||||||
|
foreach ((array) $values as $singleval) {
|
||||||
|
CcTimestampPeer::removeInstanceFromPool($singleval);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set the correct dbName
|
||||||
|
$criteria->setDbName(self::DATABASE_NAME);
|
||||||
|
|
||||||
|
$affectedRows = 0; // initialize var to track total num of affected rows
|
||||||
|
|
||||||
|
try {
|
||||||
|
// use transaction because $criteria could contain info
|
||||||
|
// for more than one table or we could emulating ON DELETE CASCADE, etc.
|
||||||
|
$con->beginTransaction();
|
||||||
|
|
||||||
|
$affectedRows += BasePeer::doDelete($criteria, $con);
|
||||||
|
CcTimestampPeer::clearRelatedInstancePool();
|
||||||
|
$con->commit();
|
||||||
|
return $affectedRows;
|
||||||
|
} catch (PropelException $e) {
|
||||||
|
$con->rollBack();
|
||||||
|
throw $e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validates all modified columns of given CcTimestamp object.
|
||||||
|
* If parameter $columns is either a single column name or an array of column names
|
||||||
|
* than only those columns are validated.
|
||||||
|
*
|
||||||
|
* NOTICE: This does not apply to primary or foreign keys for now.
|
||||||
|
*
|
||||||
|
* @param CcTimestamp $obj The object to validate.
|
||||||
|
* @param mixed $cols Column name or array of column names.
|
||||||
|
*
|
||||||
|
* @return mixed TRUE if all columns are valid or the error message of the first invalid column.
|
||||||
|
*/
|
||||||
|
public static function doValidate(CcTimestamp $obj, $cols = null)
|
||||||
|
{
|
||||||
|
$columns = array();
|
||||||
|
|
||||||
|
if ($cols) {
|
||||||
|
$dbMap = Propel::getDatabaseMap(CcTimestampPeer::DATABASE_NAME);
|
||||||
|
$tableMap = $dbMap->getTable(CcTimestampPeer::TABLE_NAME);
|
||||||
|
|
||||||
|
if (! is_array($cols)) {
|
||||||
|
$cols = array($cols);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($cols as $colName) {
|
||||||
|
if ($tableMap->containsColumn($colName)) {
|
||||||
|
$get = 'get' . $tableMap->getColumn($colName)->getPhpName();
|
||||||
|
$columns[$colName] = $obj->$get();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return BasePeer::doValidate(CcTimestampPeer::DATABASE_NAME, CcTimestampPeer::TABLE_NAME, $columns);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve a single object by pkey.
|
||||||
|
*
|
||||||
|
* @param int $pk the primary key.
|
||||||
|
* @param PropelPDO $con the connection to use
|
||||||
|
* @return CcTimestamp
|
||||||
|
*/
|
||||||
|
public static function retrieveByPK($pk, PropelPDO $con = null)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (null !== ($obj = CcTimestampPeer::getInstanceFromPool((string) $pk))) {
|
||||||
|
return $obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($con === null) {
|
||||||
|
$con = Propel::getConnection(CcTimestampPeer::DATABASE_NAME, Propel::CONNECTION_READ);
|
||||||
|
}
|
||||||
|
|
||||||
|
$criteria = new Criteria(CcTimestampPeer::DATABASE_NAME);
|
||||||
|
$criteria->add(CcTimestampPeer::ID, $pk);
|
||||||
|
|
||||||
|
$v = CcTimestampPeer::doSelect($criteria, $con);
|
||||||
|
|
||||||
|
return !empty($v) > 0 ? $v[0] : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve multiple objects by pkey.
|
||||||
|
*
|
||||||
|
* @param array $pks List of primary keys
|
||||||
|
* @param PropelPDO $con the connection to use
|
||||||
|
* @throws PropelException Any exceptions caught during processing will be
|
||||||
|
* rethrown wrapped into a PropelException.
|
||||||
|
*/
|
||||||
|
public static function retrieveByPKs($pks, PropelPDO $con = null)
|
||||||
|
{
|
||||||
|
if ($con === null) {
|
||||||
|
$con = Propel::getConnection(CcTimestampPeer::DATABASE_NAME, Propel::CONNECTION_READ);
|
||||||
|
}
|
||||||
|
|
||||||
|
$objs = null;
|
||||||
|
if (empty($pks)) {
|
||||||
|
$objs = array();
|
||||||
|
} else {
|
||||||
|
$criteria = new Criteria(CcTimestampPeer::DATABASE_NAME);
|
||||||
|
$criteria->add(CcTimestampPeer::ID, $pks, Criteria::IN);
|
||||||
|
$objs = CcTimestampPeer::doSelect($criteria, $con);
|
||||||
|
}
|
||||||
|
return $objs;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // BaseCcTimestampPeer
|
||||||
|
|
||||||
|
// This is the static code needed to register the TableMap for this table with the main Propel class.
|
||||||
|
//
|
||||||
|
BaseCcTimestampPeer::buildTableMap();
|
||||||
|
|
|
@ -0,0 +1,268 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Base class that represents a query for the 'cc_timestamp' table.
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @method CcTimestampQuery orderByDbId($order = Criteria::ASC) Order by the id column
|
||||||
|
* @method CcTimestampQuery orderByDbTimestamp($order = Criteria::ASC) Order by the timestamp column
|
||||||
|
*
|
||||||
|
* @method CcTimestampQuery groupByDbId() Group by the id column
|
||||||
|
* @method CcTimestampQuery groupByDbTimestamp() Group by the timestamp column
|
||||||
|
*
|
||||||
|
* @method CcTimestampQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
|
||||||
|
* @method CcTimestampQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
|
||||||
|
* @method CcTimestampQuery innerJoin($relation) Adds a INNER JOIN clause to the query
|
||||||
|
*
|
||||||
|
* @method CcTimestampQuery leftJoinCcListenerCount($relationAlias = '') Adds a LEFT JOIN clause to the query using the CcListenerCount relation
|
||||||
|
* @method CcTimestampQuery rightJoinCcListenerCount($relationAlias = '') Adds a RIGHT JOIN clause to the query using the CcListenerCount relation
|
||||||
|
* @method CcTimestampQuery innerJoinCcListenerCount($relationAlias = '') Adds a INNER JOIN clause to the query using the CcListenerCount relation
|
||||||
|
*
|
||||||
|
* @method CcTimestamp findOne(PropelPDO $con = null) Return the first CcTimestamp matching the query
|
||||||
|
* @method CcTimestamp findOneOrCreate(PropelPDO $con = null) Return the first CcTimestamp matching the query, or a new CcTimestamp object populated from the query conditions when no match is found
|
||||||
|
*
|
||||||
|
* @method CcTimestamp findOneByDbId(int $id) Return the first CcTimestamp filtered by the id column
|
||||||
|
* @method CcTimestamp findOneByDbTimestamp(string $timestamp) Return the first CcTimestamp filtered by the timestamp column
|
||||||
|
*
|
||||||
|
* @method array findByDbId(int $id) Return CcTimestamp objects filtered by the id column
|
||||||
|
* @method array findByDbTimestamp(string $timestamp) Return CcTimestamp objects filtered by the timestamp column
|
||||||
|
*
|
||||||
|
* @package propel.generator.airtime.om
|
||||||
|
*/
|
||||||
|
abstract class BaseCcTimestampQuery extends ModelCriteria
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes internal state of BaseCcTimestampQuery object.
|
||||||
|
*
|
||||||
|
* @param string $dbName The dabase name
|
||||||
|
* @param string $modelName The phpName of a model, e.g. 'Book'
|
||||||
|
* @param string $modelAlias The alias for the model in this query, e.g. 'b'
|
||||||
|
*/
|
||||||
|
public function __construct($dbName = 'airtime', $modelName = 'CcTimestamp', $modelAlias = null)
|
||||||
|
{
|
||||||
|
parent::__construct($dbName, $modelName, $modelAlias);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a new CcTimestampQuery object.
|
||||||
|
*
|
||||||
|
* @param string $modelAlias The alias of a model in the query
|
||||||
|
* @param Criteria $criteria Optional Criteria to build the query from
|
||||||
|
*
|
||||||
|
* @return CcTimestampQuery
|
||||||
|
*/
|
||||||
|
public static function create($modelAlias = null, $criteria = null)
|
||||||
|
{
|
||||||
|
if ($criteria instanceof CcTimestampQuery) {
|
||||||
|
return $criteria;
|
||||||
|
}
|
||||||
|
$query = new CcTimestampQuery();
|
||||||
|
if (null !== $modelAlias) {
|
||||||
|
$query->setModelAlias($modelAlias);
|
||||||
|
}
|
||||||
|
if ($criteria instanceof Criteria) {
|
||||||
|
$query->mergeWith($criteria);
|
||||||
|
}
|
||||||
|
return $query;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find object by primary key
|
||||||
|
* Use instance pooling to avoid a database query if the object exists
|
||||||
|
* <code>
|
||||||
|
* $obj = $c->findPk(12, $con);
|
||||||
|
* </code>
|
||||||
|
* @param mixed $key Primary key to use for the query
|
||||||
|
* @param PropelPDO $con an optional connection object
|
||||||
|
*
|
||||||
|
* @return CcTimestamp|array|mixed the result, formatted by the current formatter
|
||||||
|
*/
|
||||||
|
public function findPk($key, $con = null)
|
||||||
|
{
|
||||||
|
if ((null !== ($obj = CcTimestampPeer::getInstanceFromPool((string) $key))) && $this->getFormatter()->isObjectFormatter()) {
|
||||||
|
// the object is alredy in the instance pool
|
||||||
|
return $obj;
|
||||||
|
} else {
|
||||||
|
// the object has not been requested yet, or the formatter is not an object formatter
|
||||||
|
$criteria = $this->isKeepQuery() ? clone $this : $this;
|
||||||
|
$stmt = $criteria
|
||||||
|
->filterByPrimaryKey($key)
|
||||||
|
->getSelectStatement($con);
|
||||||
|
return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find objects by primary key
|
||||||
|
* <code>
|
||||||
|
* $objs = $c->findPks(array(12, 56, 832), $con);
|
||||||
|
* </code>
|
||||||
|
* @param array $keys Primary keys to use for the query
|
||||||
|
* @param PropelPDO $con an optional connection object
|
||||||
|
*
|
||||||
|
* @return PropelObjectCollection|array|mixed the list of results, formatted by the current formatter
|
||||||
|
*/
|
||||||
|
public function findPks($keys, $con = null)
|
||||||
|
{
|
||||||
|
$criteria = $this->isKeepQuery() ? clone $this : $this;
|
||||||
|
return $this
|
||||||
|
->filterByPrimaryKeys($keys)
|
||||||
|
->find($con);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filter the query by primary key
|
||||||
|
*
|
||||||
|
* @param mixed $key Primary key to use for the query
|
||||||
|
*
|
||||||
|
* @return CcTimestampQuery The current query, for fluid interface
|
||||||
|
*/
|
||||||
|
public function filterByPrimaryKey($key)
|
||||||
|
{
|
||||||
|
return $this->addUsingAlias(CcTimestampPeer::ID, $key, Criteria::EQUAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filter the query by a list of primary keys
|
||||||
|
*
|
||||||
|
* @param array $keys The list of primary key to use for the query
|
||||||
|
*
|
||||||
|
* @return CcTimestampQuery The current query, for fluid interface
|
||||||
|
*/
|
||||||
|
public function filterByPrimaryKeys($keys)
|
||||||
|
{
|
||||||
|
return $this->addUsingAlias(CcTimestampPeer::ID, $keys, Criteria::IN);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filter the query on the id column
|
||||||
|
*
|
||||||
|
* @param int|array $dbId The value to use as filter.
|
||||||
|
* Accepts an associative array('min' => $minValue, 'max' => $maxValue)
|
||||||
|
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||||
|
*
|
||||||
|
* @return CcTimestampQuery The current query, for fluid interface
|
||||||
|
*/
|
||||||
|
public function filterByDbId($dbId = null, $comparison = null)
|
||||||
|
{
|
||||||
|
if (is_array($dbId) && null === $comparison) {
|
||||||
|
$comparison = Criteria::IN;
|
||||||
|
}
|
||||||
|
return $this->addUsingAlias(CcTimestampPeer::ID, $dbId, $comparison);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filter the query on the timestamp column
|
||||||
|
*
|
||||||
|
* @param string|array $dbTimestamp The value to use as filter.
|
||||||
|
* Accepts an associative array('min' => $minValue, 'max' => $maxValue)
|
||||||
|
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||||
|
*
|
||||||
|
* @return CcTimestampQuery The current query, for fluid interface
|
||||||
|
*/
|
||||||
|
public function filterByDbTimestamp($dbTimestamp = null, $comparison = null)
|
||||||
|
{
|
||||||
|
if (is_array($dbTimestamp)) {
|
||||||
|
$useMinMax = false;
|
||||||
|
if (isset($dbTimestamp['min'])) {
|
||||||
|
$this->addUsingAlias(CcTimestampPeer::TIMESTAMP, $dbTimestamp['min'], Criteria::GREATER_EQUAL);
|
||||||
|
$useMinMax = true;
|
||||||
|
}
|
||||||
|
if (isset($dbTimestamp['max'])) {
|
||||||
|
$this->addUsingAlias(CcTimestampPeer::TIMESTAMP, $dbTimestamp['max'], Criteria::LESS_EQUAL);
|
||||||
|
$useMinMax = true;
|
||||||
|
}
|
||||||
|
if ($useMinMax) {
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
if (null === $comparison) {
|
||||||
|
$comparison = Criteria::IN;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $this->addUsingAlias(CcTimestampPeer::TIMESTAMP, $dbTimestamp, $comparison);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filter the query by a related CcListenerCount object
|
||||||
|
*
|
||||||
|
* @param CcListenerCount $ccListenerCount the related object to use as filter
|
||||||
|
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
|
||||||
|
*
|
||||||
|
* @return CcTimestampQuery The current query, for fluid interface
|
||||||
|
*/
|
||||||
|
public function filterByCcListenerCount($ccListenerCount, $comparison = null)
|
||||||
|
{
|
||||||
|
return $this
|
||||||
|
->addUsingAlias(CcTimestampPeer::ID, $ccListenerCount->getDbTimestampId(), $comparison);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a JOIN clause to the query using the CcListenerCount relation
|
||||||
|
*
|
||||||
|
* @param string $relationAlias optional alias for the relation
|
||||||
|
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
|
||||||
|
*
|
||||||
|
* @return CcTimestampQuery The current query, for fluid interface
|
||||||
|
*/
|
||||||
|
public function joinCcListenerCount($relationAlias = '', $joinType = Criteria::INNER_JOIN)
|
||||||
|
{
|
||||||
|
$tableMap = $this->getTableMap();
|
||||||
|
$relationMap = $tableMap->getRelation('CcListenerCount');
|
||||||
|
|
||||||
|
// create a ModelJoin object for this join
|
||||||
|
$join = new ModelJoin();
|
||||||
|
$join->setJoinType($joinType);
|
||||||
|
$join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias);
|
||||||
|
if ($previousJoin = $this->getPreviousJoin()) {
|
||||||
|
$join->setPreviousJoin($previousJoin);
|
||||||
|
}
|
||||||
|
|
||||||
|
// add the ModelJoin to the current object
|
||||||
|
if($relationAlias) {
|
||||||
|
$this->addAlias($relationAlias, $relationMap->getRightTable()->getName());
|
||||||
|
$this->addJoinObject($join, $relationAlias);
|
||||||
|
} else {
|
||||||
|
$this->addJoinObject($join, 'CcListenerCount');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use the CcListenerCount relation CcListenerCount object
|
||||||
|
*
|
||||||
|
* @see useQuery()
|
||||||
|
*
|
||||||
|
* @param string $relationAlias optional alias for the relation,
|
||||||
|
* to be used as main alias in the secondary query
|
||||||
|
* @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
|
||||||
|
*
|
||||||
|
* @return CcListenerCountQuery A secondary query class using the current class as primary query
|
||||||
|
*/
|
||||||
|
public function useCcListenerCountQuery($relationAlias = '', $joinType = Criteria::INNER_JOIN)
|
||||||
|
{
|
||||||
|
return $this
|
||||||
|
->joinCcListenerCount($relationAlias, $joinType)
|
||||||
|
->useQuery($relationAlias ? $relationAlias : 'CcListenerCount', 'CcListenerCountQuery');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Exclude object from result
|
||||||
|
*
|
||||||
|
* @param CcTimestamp $ccTimestamp Object to remove from the list of results
|
||||||
|
*
|
||||||
|
* @return CcTimestampQuery The current query, for fluid interface
|
||||||
|
*/
|
||||||
|
public function prune($ccTimestamp = null)
|
||||||
|
{
|
||||||
|
if ($ccTimestamp) {
|
||||||
|
$this->addUsingAlias(CcTimestampPeer::ID, $ccTimestamp->getDbId(), Criteria::NOT_EQUAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // BaseCcTimestampQuery
|
|
@ -0,0 +1,7 @@
|
||||||
|
<div id="listenerstat_content" class="ui-widget ui-widget-content block-shadow alpha-block padded">
|
||||||
|
Listener Count Over Time<br>
|
||||||
|
<div id="flot_placeholder" style="width:600px;height:300px;margin:0px 50px 0px 50px"></div>
|
||||||
|
<div id="legend" style="width:600px;height:70px;margin:0px 50px 0px 50px"></div>
|
||||||
|
<?php echo $this->date_form; ?>
|
||||||
|
|
||||||
|
</div>
|
|
@ -438,4 +438,24 @@
|
||||||
<reference local="instance_id" foreign="id"/>
|
<reference local="instance_id" foreign="id"/>
|
||||||
</foreign-key>
|
</foreign-key>
|
||||||
</table>
|
</table>
|
||||||
|
<table name="cc_mount_name" phpName="CcTimestamp">
|
||||||
|
<column name="id" phpName="DbId" primaryKey="true" type="INTEGER" autoIncrement="true" required="true" />
|
||||||
|
<column name="mount_name" phpName="DbMountName" type="VARCHAR" required="true" />
|
||||||
|
</table>
|
||||||
|
<table name="cc_timestamp" phpName="CcTimestamp">
|
||||||
|
<column name="id" phpName="DbId" primaryKey="true" type="INTEGER" autoIncrement="true" required="true" />
|
||||||
|
<column name="timestamp" phpName="DbTimestamp" type="TIMESTAMP" required="true" />
|
||||||
|
</table>
|
||||||
|
<table name="cc_listener_count" phpName="CcListenerCount">
|
||||||
|
<column name="id" phpName="DbId" primaryKey="true" type="INTEGER" autoIncrement="true" required="true" />
|
||||||
|
<column name="timestamp_id" phpName="DbTimestampId" type="INTEGER" required="true"/>
|
||||||
|
<column name="mount_name_id" phpName="DbMountNameId" type="INTEGER" required="true"/>
|
||||||
|
<column name="listener_count" phpName="DbListenerCount" type="INTEGER" required="true" />
|
||||||
|
<foreign-key foreignTable="cc_timestamp" name="cc_timestamp_inst_fkey" onDelete="CASCADE">
|
||||||
|
<reference local="timestamp_id" foreign="id"/>
|
||||||
|
</foreign-key>
|
||||||
|
<foreign-key foreignTable="cc_mount_name" name="cc_mount_name_inst_fkey" onDelete="CASCADE">
|
||||||
|
<reference local="mount_name_id" foreign="id"/>
|
||||||
|
</foreign-key>
|
||||||
|
</table>
|
||||||
</database>
|
</database>
|
||||||
|
|
|
@ -667,6 +667,62 @@ CREATE TABLE "cc_webstream_metadata"
|
||||||
COMMENT ON TABLE "cc_webstream_metadata" IS '';
|
COMMENT ON TABLE "cc_webstream_metadata" IS '';
|
||||||
|
|
||||||
|
|
||||||
|
SET search_path TO public;
|
||||||
|
-----------------------------------------------------------------------------
|
||||||
|
-- cc_mount_name
|
||||||
|
-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
DROP TABLE "cc_mount_name" CASCADE;
|
||||||
|
|
||||||
|
|
||||||
|
CREATE TABLE "cc_mount_name"
|
||||||
|
(
|
||||||
|
"id" serial NOT NULL,
|
||||||
|
"mount_name" VARCHAR(255) NOT NULL,
|
||||||
|
PRIMARY KEY ("id")
|
||||||
|
);
|
||||||
|
|
||||||
|
COMMENT ON TABLE "cc_mount_name" IS '';
|
||||||
|
|
||||||
|
|
||||||
|
SET search_path TO public;
|
||||||
|
-----------------------------------------------------------------------------
|
||||||
|
-- cc_timestamp
|
||||||
|
-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
DROP TABLE "cc_timestamp" CASCADE;
|
||||||
|
|
||||||
|
|
||||||
|
CREATE TABLE "cc_timestamp"
|
||||||
|
(
|
||||||
|
"id" serial NOT NULL,
|
||||||
|
"timestamp" TIMESTAMP NOT NULL,
|
||||||
|
PRIMARY KEY ("id")
|
||||||
|
);
|
||||||
|
|
||||||
|
COMMENT ON TABLE "cc_timestamp" IS '';
|
||||||
|
|
||||||
|
|
||||||
|
SET search_path TO public;
|
||||||
|
-----------------------------------------------------------------------------
|
||||||
|
-- cc_listener_count
|
||||||
|
-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
DROP TABLE "cc_listener_count" CASCADE;
|
||||||
|
|
||||||
|
|
||||||
|
CREATE TABLE "cc_listener_count"
|
||||||
|
(
|
||||||
|
"id" serial NOT NULL,
|
||||||
|
"timestamp_id" INTEGER NOT NULL,
|
||||||
|
"mount_name_id" INTEGER NOT NULL,
|
||||||
|
"listener_count" INTEGER NOT NULL,
|
||||||
|
PRIMARY KEY ("id")
|
||||||
|
);
|
||||||
|
|
||||||
|
COMMENT ON TABLE "cc_listener_count" IS '';
|
||||||
|
|
||||||
|
|
||||||
SET search_path TO public;
|
SET search_path TO public;
|
||||||
ALTER TABLE "cc_files" ADD CONSTRAINT "cc_files_owner_fkey" FOREIGN KEY ("owner_id") REFERENCES "cc_subjs" ("id");
|
ALTER TABLE "cc_files" ADD CONSTRAINT "cc_files_owner_fkey" FOREIGN KEY ("owner_id") REFERENCES "cc_subjs" ("id");
|
||||||
|
|
||||||
|
@ -719,3 +775,7 @@ ALTER TABLE "cc_sess" ADD CONSTRAINT "cc_sess_userid_fkey" FOREIGN KEY ("userid"
|
||||||
ALTER TABLE "cc_subjs_token" ADD CONSTRAINT "cc_subjs_token_userid_fkey" FOREIGN KEY ("user_id") REFERENCES "cc_subjs" ("id") ON DELETE CASCADE;
|
ALTER TABLE "cc_subjs_token" ADD CONSTRAINT "cc_subjs_token_userid_fkey" FOREIGN KEY ("user_id") REFERENCES "cc_subjs" ("id") ON DELETE CASCADE;
|
||||||
|
|
||||||
ALTER TABLE "cc_webstream_metadata" ADD CONSTRAINT "cc_schedule_inst_fkey" FOREIGN KEY ("instance_id") REFERENCES "cc_schedule" ("id") ON DELETE CASCADE;
|
ALTER TABLE "cc_webstream_metadata" ADD CONSTRAINT "cc_schedule_inst_fkey" FOREIGN KEY ("instance_id") REFERENCES "cc_schedule" ("id") ON DELETE CASCADE;
|
||||||
|
|
||||||
|
ALTER TABLE "cc_listener_count" ADD CONSTRAINT "cc_timestamp_inst_fkey" FOREIGN KEY ("timestamp_id") REFERENCES "cc_timestamp" ("id") ON DELETE CASCADE;
|
||||||
|
|
||||||
|
ALTER TABLE "cc_listener_count" ADD CONSTRAINT "cc_mount_name_inst_fkey" FOREIGN KEY ("mount_name_id") REFERENCES "cc_mount_name" ("id") ON DELETE CASCADE;
|
||||||
|
|
|
@ -0,0 +1,175 @@
|
||||||
|
$(document).ready(function() {
|
||||||
|
listenerstat_content = $("#listenerstat_content")
|
||||||
|
dateStartId = "#his_date_start",
|
||||||
|
timeStartId = "#his_time_start",
|
||||||
|
dateEndId = "#his_date_end",
|
||||||
|
timeEndId = "#his_time_end";
|
||||||
|
|
||||||
|
getDataAndPlot();
|
||||||
|
|
||||||
|
listenerstat_content.find("#his_submit").click(function(){
|
||||||
|
startTimestamp = AIRTIME.utilities.fnGetTimestamp(dateStartId, timeStartId);
|
||||||
|
endTimestamp = AIRTIME.utilities.fnGetTimestamp(dateEndId, timeEndId);
|
||||||
|
getDataAndPlot(startTimestamp, endTimestamp);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
function getDataAndPlot(startTimestamp, endTimestamp){
|
||||||
|
// get data
|
||||||
|
$.get('/Listenerstat/get-data', {startTimestamp: startTimestamp, endTimestamp: endTimestamp}, function(data){
|
||||||
|
data = JSON.parse(data);
|
||||||
|
out = new Object();
|
||||||
|
$.each(data, function(mpName, v){
|
||||||
|
plotData = new Object();
|
||||||
|
plotData.data = new Array();
|
||||||
|
$.each(v, function(i, ele){
|
||||||
|
plotData.label = mpName;
|
||||||
|
var d = new Date(0);
|
||||||
|
d.setUTCSeconds(ele.timestamp);
|
||||||
|
plotData.data.push([d, ele.listener_count]);
|
||||||
|
})
|
||||||
|
out[mpName] = plotData;
|
||||||
|
});
|
||||||
|
plot(out);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function plot(datasets){
|
||||||
|
var plot;
|
||||||
|
data = null;
|
||||||
|
function plotByChoice(doAll)
|
||||||
|
{
|
||||||
|
// largest date object that you can set
|
||||||
|
firstTimestamp = new Date(8640000000000000);
|
||||||
|
// smallest
|
||||||
|
lastTimestamp = new Date(0);
|
||||||
|
|
||||||
|
data = [];
|
||||||
|
if (doAll != null)
|
||||||
|
{
|
||||||
|
$.each(datasets, function(key, val) {
|
||||||
|
if (firstTimestamp.getTime() > val.data[0][0].getTime()) {
|
||||||
|
firstTimestamp = val.data[0][0];
|
||||||
|
}
|
||||||
|
if (lastTimestamp.getTime() < val.data[val.data.length-1][0].getTime()) {
|
||||||
|
lastTimestamp = val.data[val.data.length-1][0];
|
||||||
|
}
|
||||||
|
data.push(val);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$('#legend .legendCB').each(
|
||||||
|
function(){
|
||||||
|
if (this.checked)
|
||||||
|
{
|
||||||
|
data.push(datasets[this.id]);
|
||||||
|
if (firstTimestamp.getTime() > datasets[this.id].data[0][0].getTime()) {
|
||||||
|
firstTimestamp = datasets[this.id].data[0][0];
|
||||||
|
}
|
||||||
|
if (lastTimestamp.getTime() < datasets[this.id].data[datasets[this.id].data.length-1][0].getTime()) {
|
||||||
|
lastTimestamp = datasets[this.id].data[datasets[this.id].data.length-1][0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
data.push({label: this.id, data: []})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
numOfTicks = 10;
|
||||||
|
tickSize = (lastTimestamp.getTime() - firstTimestamp.getTime())/1000/numOfTicks;
|
||||||
|
|
||||||
|
plot = $.plot($("#flot_placeholder"), data, {
|
||||||
|
yaxis: { min: 0, tickDecimals: 0 },
|
||||||
|
xaxis: { mode: "time", timeformat:"%y/%m/%0d %H:%M", tickSize: [tickSize, "second"] },
|
||||||
|
grid: {
|
||||||
|
hoverable: true,
|
||||||
|
backgroundColor: { colors: ["#888888", "#999999"] }
|
||||||
|
},
|
||||||
|
series: {
|
||||||
|
lines: {
|
||||||
|
show: true,
|
||||||
|
fill: 0.3
|
||||||
|
},
|
||||||
|
points: { show: true }
|
||||||
|
},
|
||||||
|
legend: {
|
||||||
|
container: $('#legend'),
|
||||||
|
noColumns: 5,
|
||||||
|
labelFormatter: function (label, series) {
|
||||||
|
var cb = '<input style="float:left;" class="legendCB" type="checkbox" ';
|
||||||
|
if (series.data.length > 0){
|
||||||
|
cb += 'checked="true" ';
|
||||||
|
}
|
||||||
|
cb += 'id="'+label+'" /> ';
|
||||||
|
cb += label;
|
||||||
|
return cb;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
function showTooltip(x, y, contents) {
|
||||||
|
$('<div id="tooltip">' + contents + '</div>').css( {
|
||||||
|
position: 'absolute',
|
||||||
|
display: 'none',
|
||||||
|
top: y + 5,
|
||||||
|
left: x + 5,
|
||||||
|
border: '1px solid #fdd',
|
||||||
|
padding: '2px',
|
||||||
|
'background-color': '#fee',
|
||||||
|
opacity: 0.80
|
||||||
|
}).appendTo("body").fadeIn(200);
|
||||||
|
}
|
||||||
|
|
||||||
|
var previousPoint = null;
|
||||||
|
$("#flot_placeholder").bind("plothover", function (event, pos, item) {
|
||||||
|
if (item) {
|
||||||
|
if (previousPoint != item.dataIndex) {
|
||||||
|
previousPoint = item.dataIndex;
|
||||||
|
|
||||||
|
$("#tooltip").remove();
|
||||||
|
var y = item.datapoint[1].toFixed(2);
|
||||||
|
|
||||||
|
showTooltip(item.pageX, item.pageY,
|
||||||
|
"Listener Count on '"+item.series.label + "': " + Math.floor(y));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$("#tooltip").remove();
|
||||||
|
previousPoint = null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#placeholder").bind("plotclick", function (event, pos, item) {
|
||||||
|
if (item) {
|
||||||
|
$("#clickdata").text("You clicked point " + item.dataIndex + " in " + item.series.label + ".");
|
||||||
|
plot.highlight(item.series, item.datapoint);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#legend').find("input").click(function(){setTimeout(plotByChoice,100);});
|
||||||
|
}
|
||||||
|
|
||||||
|
plotByChoice(true);
|
||||||
|
oBaseDatePickerSettings = {
|
||||||
|
dateFormat: 'yy-mm-dd',
|
||||||
|
onSelect: function(sDate, oDatePicker) {
|
||||||
|
$(this).datepicker( "setDate", sDate );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
oBaseTimePickerSettings = {
|
||||||
|
showPeriodLabels: false,
|
||||||
|
showCloseButton: true,
|
||||||
|
showLeadingZero: false,
|
||||||
|
defaultTime: '0:00'
|
||||||
|
};
|
||||||
|
|
||||||
|
listenerstat_content.find(dateStartId).datepicker(oBaseDatePickerSettings);
|
||||||
|
listenerstat_content.find(timeStartId).timepicker(oBaseTimePickerSettings);
|
||||||
|
listenerstat_content.find(dateEndId).datepicker(oBaseDatePickerSettings);
|
||||||
|
listenerstat_content.find(timeEndId).timepicker(oBaseTimePickerSettings);
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,76 @@
|
||||||
|
Frequently asked questions
|
||||||
|
--------------------------
|
||||||
|
|
||||||
|
Q: How much data can Flot cope with?
|
||||||
|
|
||||||
|
A: Flot will happily draw everything you send to it so the answer
|
||||||
|
depends on the browser. The excanvas emulation used for IE (built with
|
||||||
|
VML) makes IE by far the slowest browser so be sure to test with that
|
||||||
|
if IE users are in your target group.
|
||||||
|
|
||||||
|
1000 points is not a problem, but as soon as you start having more
|
||||||
|
points than the pixel width, you should probably start thinking about
|
||||||
|
downsampling/aggregation as this is near the resolution limit of the
|
||||||
|
chart anyway. If you downsample server-side, you also save bandwidth.
|
||||||
|
|
||||||
|
|
||||||
|
Q: Flot isn't working when I'm using JSON data as source!
|
||||||
|
|
||||||
|
A: Actually, Flot loves JSON data, you just got the format wrong.
|
||||||
|
Double check that you're not inputting strings instead of numbers,
|
||||||
|
like [["0", "-2.13"], ["5", "4.3"]]. This is most common mistake, and
|
||||||
|
the error might not show up immediately because Javascript can do some
|
||||||
|
conversion automatically.
|
||||||
|
|
||||||
|
|
||||||
|
Q: Can I export the graph?
|
||||||
|
|
||||||
|
A: This is a limitation of the canvas technology. There's a hook in
|
||||||
|
the canvas object for getting an image out, but you won't get the tick
|
||||||
|
labels. And it's not likely to be supported by IE. At this point, your
|
||||||
|
best bet is probably taking a screenshot, e.g. with PrtScn.
|
||||||
|
|
||||||
|
|
||||||
|
Q: The bars are all tiny in time mode?
|
||||||
|
|
||||||
|
A: It's not really possible to determine the bar width automatically.
|
||||||
|
So you have to set the width with the barWidth option which is NOT in
|
||||||
|
pixels, but in the units of the x axis (or the y axis for horizontal
|
||||||
|
bars). For time mode that's milliseconds so the default value of 1
|
||||||
|
makes the bars 1 millisecond wide.
|
||||||
|
|
||||||
|
|
||||||
|
Q: Can I use Flot with libraries like Mootools or Prototype?
|
||||||
|
|
||||||
|
A: Yes, Flot supports it out of the box and it's easy! Just use jQuery
|
||||||
|
instead of $, e.g. call jQuery.plot instead of $.plot and use
|
||||||
|
jQuery(something) instead of $(something). As a convenience, you can
|
||||||
|
put in a DOM element for the graph placeholder where the examples and
|
||||||
|
the API documentation are using jQuery objects.
|
||||||
|
|
||||||
|
Depending on how you include jQuery, you may have to add one line of
|
||||||
|
code to prevent jQuery from overwriting functions from the other
|
||||||
|
libraries, see the documentation in jQuery ("Using jQuery with other
|
||||||
|
libraries") for details.
|
||||||
|
|
||||||
|
|
||||||
|
Q: Flot doesn't work with [insert name of Javascript UI framework]!
|
||||||
|
|
||||||
|
A: The only non-standard thing used by Flot is the canvas tag;
|
||||||
|
otherwise it is simply a series of absolute positioned divs within the
|
||||||
|
placeholder tag you put in. If this is not working, it's probably
|
||||||
|
because the framework you're using is doing something weird with the
|
||||||
|
DOM, or you're using it the wrong way.
|
||||||
|
|
||||||
|
A common problem is that there's display:none on a container until the
|
||||||
|
user does something. Many tab widgets work this way, and there's
|
||||||
|
nothing wrong with it - you just can't call Flot inside a display:none
|
||||||
|
container as explained in the README so you need to hold off the Flot
|
||||||
|
call until the container is actually displayed (or use
|
||||||
|
visibility:hidden instead of display:none or move the container
|
||||||
|
off-screen).
|
||||||
|
|
||||||
|
If you find there's a specific thing we can do to Flot to help, feel
|
||||||
|
free to submit a bug report. Otherwise, you're welcome to ask for help
|
||||||
|
on the forum/mailing list, but please don't submit a bug report to
|
||||||
|
Flot.
|
|
@ -0,0 +1,22 @@
|
||||||
|
Copyright (c) 2007-2009 IOLA and Ole Laursen
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person
|
||||||
|
obtaining a copy of this software and associated documentation
|
||||||
|
files (the "Software"), to deal in the Software without
|
||||||
|
restriction, including without limitation the rights to use,
|
||||||
|
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the
|
||||||
|
Software is furnished to do so, subject to the following
|
||||||
|
conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be
|
||||||
|
included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||||
|
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||||
|
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
OTHER DEALINGS IN THE SOFTWARE.
|
|
@ -0,0 +1,9 @@
|
||||||
|
# Makefile for generating minified files
|
||||||
|
|
||||||
|
.PHONY: all
|
||||||
|
|
||||||
|
# we cheat and process all .js files instead of an exhaustive list
|
||||||
|
all: $(patsubst %.js,%.min.js,$(filter-out %.min.js,$(wildcard *.js)))
|
||||||
|
|
||||||
|
%.min.js: %.js
|
||||||
|
yui-compressor $< -o $@
|
|
@ -0,0 +1,508 @@
|
||||||
|
Flot 0.7
|
||||||
|
--------
|
||||||
|
|
||||||
|
API changes:
|
||||||
|
|
||||||
|
Multiple axes support. Code using dual axes should be changed from
|
||||||
|
using x2axis/y2axis in the options to using an array (although
|
||||||
|
backwards-compatibility hooks are in place). For instance,
|
||||||
|
|
||||||
|
{
|
||||||
|
xaxis: { ... }, x2axis: { ... },
|
||||||
|
yaxis: { ... }, y2axis: { ... }
|
||||||
|
}
|
||||||
|
|
||||||
|
becomes
|
||||||
|
|
||||||
|
{
|
||||||
|
xaxes: [ { ... }, { ... } ],
|
||||||
|
yaxes: [ { ... }, { ... } ]
|
||||||
|
}
|
||||||
|
|
||||||
|
Note that if you're just using one axis, continue to use the
|
||||||
|
xaxis/yaxis directly (it now sets the default settings for the
|
||||||
|
arrays). Plugins touching the axes must be ported to take the extra
|
||||||
|
axes into account, check the source to see some examples.
|
||||||
|
|
||||||
|
A related change is that the visibility of axes is now auto-detected.
|
||||||
|
So if you were relying on an axis to show up even without any data in
|
||||||
|
the chart, you now need to set the axis "show" option explicitly.
|
||||||
|
|
||||||
|
"tickColor" on the grid options is now deprecated in favour of a
|
||||||
|
corresponding option on the axes, so { grid: { tickColor: "#000" }}
|
||||||
|
becomes { xaxis: { tickColor: "#000"}, yaxis: { tickColor: "#000"} },
|
||||||
|
but if you just configure a base color Flot will now autogenerate a
|
||||||
|
tick color by adding transparency. Backwards-compatibility hooks are
|
||||||
|
in place.
|
||||||
|
|
||||||
|
Final note: now that IE 9 is coming out with canvas support, you may
|
||||||
|
want to adapt the excanvas include to skip loading it in IE 9 (the
|
||||||
|
examples have been adapted thanks to Ryley Breiddal). An alternative
|
||||||
|
to excanvas using Flash has also surfaced, if your graphs are slow in
|
||||||
|
IE, you may want to give it a spin:
|
||||||
|
|
||||||
|
http://code.google.com/p/flashcanvas/
|
||||||
|
|
||||||
|
|
||||||
|
Changes:
|
||||||
|
|
||||||
|
- Support for specifying a bottom for each point for line charts when
|
||||||
|
filling them, this means that an arbitrary bottom can be used
|
||||||
|
instead of just the x axis (based on patches patiently provided by
|
||||||
|
Roman V. Prikhodchenko).
|
||||||
|
- New fillbetween plugin that can compute a bottom for a series from
|
||||||
|
another series, useful for filling areas between lines (see new
|
||||||
|
example percentiles.html for a use case).
|
||||||
|
- More predictable handling of gaps for the stacking plugin, now all
|
||||||
|
undefined ranges are skipped.
|
||||||
|
- Stacking plugin can stack horizontal bar charts.
|
||||||
|
- Navigate plugin now redraws the plot while panning instead of only
|
||||||
|
after the fact (can be disabled by setting the pan.frameRate option
|
||||||
|
to null), raised by lastthemy (issue 235).
|
||||||
|
- Date formatter now accepts %0m and %0d to get a zero-padded month or
|
||||||
|
day (issue raised by Maximillian Dornseif).
|
||||||
|
- Revamped internals to support an unlimited number of axes, not just
|
||||||
|
dual (sponsored by Flight Data Services,
|
||||||
|
www.flightdataservices.com).
|
||||||
|
- New setting on axes, "tickLength", to control the size of ticks or
|
||||||
|
turn them off without turning off the labels.
|
||||||
|
- Axis labels are now put in container divs with classes, for instance
|
||||||
|
labels in the x axes can be reached via ".xAxis .tickLabel".
|
||||||
|
- Support for setting the color of an axis (sponsored by Flight Data
|
||||||
|
Services, www.flightdataservices.com).
|
||||||
|
- Tick color is now auto-generated as the base color with some
|
||||||
|
transparency (unless you override it).
|
||||||
|
- Support for aligning ticks in the axes with "alignTicksWithAxis" to
|
||||||
|
ensure that they appear next to each other rather than in between,
|
||||||
|
at the expense of possibly awkward tick steps (sponsored by Flight
|
||||||
|
Data Services, www.flightdataservices.com).
|
||||||
|
- Support for customizing the point type through a callback when
|
||||||
|
plotting points and new symbol plugin with some predefined point
|
||||||
|
types (sponsored by Utility Data Corporation).
|
||||||
|
- Resize plugin for automatically redrawing when the placeholder
|
||||||
|
changes size, e.g. on window resizes (sponsored by Novus Partners).
|
||||||
|
A resize() method has been added to plot object facilitate this.
|
||||||
|
- Support Infinity/-Infinity for plotting asymptotes by hacking it
|
||||||
|
into +/-Number.MAX_VALUE (reported by rabaea.mircea).
|
||||||
|
- Support for restricting navigate plugin to not pan/zoom an axis (based
|
||||||
|
on patch by kkaefer).
|
||||||
|
- Support for providing the drag cursor for the navigate plugin as an
|
||||||
|
option (based on patch by Kelly T. Moore).
|
||||||
|
- Options for controlling whether an axis is shown or not (suggestion
|
||||||
|
by Timo Tuominen) and whether to reserve space for it even if it
|
||||||
|
isn't shown.
|
||||||
|
- New attribute $.plot.version with the Flot version as a string.
|
||||||
|
- The version comment is now included in the minified jquery.flot.min.js.
|
||||||
|
- New options.grid.minBorderMargin for adjusting the minimum margin
|
||||||
|
provided around the border (based on patch by corani, issue 188).
|
||||||
|
- Refactor replot behaviour so Flot tries to reuse the existing
|
||||||
|
canvas, adding shutdown() methods to the plot (based on patch by
|
||||||
|
Ryley Breiddal, issue 269). This prevents a memory leak in Chrome
|
||||||
|
and hopefully makes replotting faster for those who are using $.plot
|
||||||
|
instead of .setData()/.draw(). Also update jQuery to 1.5.1 to
|
||||||
|
prevent IE leaks fixed in jQuery.
|
||||||
|
- New real-time line chart example.
|
||||||
|
|
||||||
|
- New hooks: drawSeries, shutdown
|
||||||
|
|
||||||
|
Bug fixes:
|
||||||
|
|
||||||
|
- Fixed problem with findNearbyItem and bars on top of each other
|
||||||
|
(reported by ragingchikn, issue 242).
|
||||||
|
- Fixed problem with ticks and the border (based on patch from
|
||||||
|
ultimatehustler69, issue 236).
|
||||||
|
- Fixed problem with plugins adding options to the series objects.
|
||||||
|
- Fixed a problem introduced in 0.6 with specifying a gradient with {
|
||||||
|
brightness: x, opacity: y }.
|
||||||
|
- Don't use $.browser.msie, check for getContext on the created canvas
|
||||||
|
element instead and try to use excanvas if it's not found (fixes IE
|
||||||
|
9 compatibility).
|
||||||
|
- highlight(s, index) was looking up the point in the original s.data
|
||||||
|
instead of in the computed datapoints array, which breaks with
|
||||||
|
plugins that modify the datapoints (such as the stacking plugin).
|
||||||
|
Issue 316 reported by curlypaul924.
|
||||||
|
- More robust handling of axis from data passed in from getData()
|
||||||
|
(problem reported by Morgan).
|
||||||
|
- Fixed problem with turning off bar outline (issue 253, fix by Jordi
|
||||||
|
Castells).
|
||||||
|
- Check the selection passed into setSelection in the selection
|
||||||
|
plugin, to guard against errors when synchronizing plots (fix by Lau
|
||||||
|
Bech Lauritzen).
|
||||||
|
- Fix bug in crosshair code with mouseout resetting the crosshair even
|
||||||
|
if it is locked (fix by Lau Bech Lauritzen and Banko Adam).
|
||||||
|
- Fix bug with points plotting using line width from lines rather than
|
||||||
|
points.
|
||||||
|
- Fix bug with passing non-array 0 data (for plugins that don't expect
|
||||||
|
arrays, patch by vpapp1).
|
||||||
|
- Fix errors in JSON in examples so they work with jQuery 1.4.2
|
||||||
|
(fix reported by honestbleeps, issue 357).
|
||||||
|
- Fix bug with tooltip in interacting.html, this makes the tooltip
|
||||||
|
much smoother (fix by bdkahn). Fix related bug inside highlighting
|
||||||
|
handler in Flot.
|
||||||
|
- Use closure trick to make inline colorhelpers plugin respect
|
||||||
|
jQuery.noConflict(true), renaming the global jQuery object (reported
|
||||||
|
by Nick Stielau).
|
||||||
|
- Listen for mouseleave events and fire a plothover event with empty
|
||||||
|
item when it occurs to drop highlights when the mouse leaves the
|
||||||
|
plot (reported by by outspirit).
|
||||||
|
- Fix bug with using aboveData with a background (reported by
|
||||||
|
amitayd).
|
||||||
|
- Fix possible excanvas leak (report and suggested fix by tom9729).
|
||||||
|
- Fix bug with backwards compatibility for shadowSize = 0 (report and
|
||||||
|
suggested fix by aspinak).
|
||||||
|
- Adapt examples to skip loading excanvas (fix by Ryley Breiddal).
|
||||||
|
- Fix bug that prevent a simple f(x) = -x transform from working
|
||||||
|
correctly (fix by Mike, issue 263).
|
||||||
|
- Fix bug in restoring cursor in navigate plugin (reported by Matteo
|
||||||
|
Gattanini, issue 395).
|
||||||
|
- Fix bug in picking items when transform/inverseTransform is in use
|
||||||
|
(reported by Ofri Raviv, and patches and analysis by Jan and Tom
|
||||||
|
Paton, issue 334 and 467).
|
||||||
|
- Fix problem with unaligned ticks and hover/click events caused by
|
||||||
|
padding on the placeholder by hardcoding the placeholder padding to
|
||||||
|
0 (reported by adityadineshsaxena, Matt Sommer, Daniel Atos and some
|
||||||
|
other people, issue 301).
|
||||||
|
- Update colorhelpers plugin to avoid dying when trying to parse an
|
||||||
|
invalid string (reported by cadavor, issue 483).
|
||||||
|
|
||||||
|
|
||||||
|
Flot 0.6
|
||||||
|
--------
|
||||||
|
|
||||||
|
API changes:
|
||||||
|
|
||||||
|
1. Selection support has been moved to a plugin. Thus if you're
|
||||||
|
passing selection: { mode: something }, you MUST include the file
|
||||||
|
jquery.flot.selection.js after jquery.flot.js. This reduces the size
|
||||||
|
of base Flot and makes it easier to customize the selection as well as
|
||||||
|
improving code clarity. The change is based on a patch from andershol.
|
||||||
|
|
||||||
|
2. In the global options specified in the $.plot command,
|
||||||
|
"lines", "points", "bars" and "shadowSize" have been moved to a
|
||||||
|
sub-object called "series", i.e.
|
||||||
|
|
||||||
|
$.plot(placeholder, data, { lines: { show: true }})
|
||||||
|
|
||||||
|
should be changed to
|
||||||
|
|
||||||
|
$.plot(placeholder, data, { series: { lines: { show: true }}})
|
||||||
|
|
||||||
|
All future series-specific options will go into this sub-object to
|
||||||
|
simplify plugin writing. Backward-compatibility code is in place, so
|
||||||
|
old code should not break.
|
||||||
|
|
||||||
|
3. "plothover" no longer provides the original data point, but instead
|
||||||
|
a normalized one, since there may be no corresponding original point.
|
||||||
|
|
||||||
|
4. Due to a bug in previous versions of jQuery, you now need at least
|
||||||
|
jQuery 1.2.6. But if you can, try jQuery 1.3.2 as it got some
|
||||||
|
improvements in event handling speed.
|
||||||
|
|
||||||
|
|
||||||
|
Changes:
|
||||||
|
|
||||||
|
- Added support for disabling interactivity for specific data series
|
||||||
|
(request from Ronald Schouten and Steve Upton).
|
||||||
|
|
||||||
|
- Flot now calls $() on the placeholder and optional legend container
|
||||||
|
passed in so you can specify DOM elements or CSS expressions to make
|
||||||
|
it easier to use Flot with libraries like Prototype or Mootools or
|
||||||
|
through raw JSON from Ajax responses.
|
||||||
|
|
||||||
|
- A new "plotselecting" event is now emitted while the user is making
|
||||||
|
a selection.
|
||||||
|
|
||||||
|
- The "plothover" event is now emitted immediately instead of at most
|
||||||
|
10 times per second, you'll have to put in a setTimeout yourself if
|
||||||
|
you're doing something really expensive on this event.
|
||||||
|
|
||||||
|
- The built-in date formatter can now be accessed as
|
||||||
|
$.plot.formatDate(...) (suggestion by Matt Manela) and even
|
||||||
|
replaced.
|
||||||
|
|
||||||
|
- Added "borderColor" option to the grid (patch from Amaury Chamayou
|
||||||
|
and patch from Mike R. Williamson).
|
||||||
|
|
||||||
|
- Added support for gradient backgrounds for the grid, take a look at
|
||||||
|
the "setting options" example (based on patch from Amaury Chamayou,
|
||||||
|
issue 90).
|
||||||
|
|
||||||
|
- Gradient bars (suggestion by stefpet).
|
||||||
|
|
||||||
|
- Added a "plotunselected" event which is triggered when the selection
|
||||||
|
is removed, see "selection" example (suggestion by Meda Ugo);
|
||||||
|
|
||||||
|
- The option legend.margin can now specify horizontal and vertical
|
||||||
|
margins independently (suggestion by someone who's annoyed).
|
||||||
|
|
||||||
|
- Data passed into Flot is now copied to a new canonical format to
|
||||||
|
enable further processing before it hits the drawing routines. As a
|
||||||
|
side-effect, this should make Flot more robust in the face of bad
|
||||||
|
data (and fixes issue 112).
|
||||||
|
|
||||||
|
- Step-wise charting: line charts have a new option "steps" that when
|
||||||
|
set to true connects the points with horizontal/vertical steps
|
||||||
|
instead of diagonal lines.
|
||||||
|
|
||||||
|
- The legend labelFormatter now passes the series in addition to just
|
||||||
|
the label (suggestion by Vincent Lemeltier).
|
||||||
|
|
||||||
|
- Horizontal bars (based on patch by Jason LeBrun).
|
||||||
|
|
||||||
|
- Support for partial bars by specifying a third coordinate, i.e. they
|
||||||
|
don't have to start from the axis. This can be used to make stacked
|
||||||
|
bars.
|
||||||
|
|
||||||
|
- New option to disable the (grid.show).
|
||||||
|
|
||||||
|
- Added pointOffset method for converting a point in data space to an
|
||||||
|
offset within the placeholder.
|
||||||
|
|
||||||
|
- Plugin system: register an init method in the $.flot.plugins array
|
||||||
|
to get started, see PLUGINS.txt for details on how to write plugins
|
||||||
|
(it's easy). There are also some extra methods to enable access to
|
||||||
|
internal state.
|
||||||
|
|
||||||
|
- Hooks: you can register functions that are called while Flot is
|
||||||
|
crunching the data and doing the plot. This can be used to modify
|
||||||
|
Flot without changing the source, useful for writing plugins. Some
|
||||||
|
hooks are defined, more are likely to come.
|
||||||
|
|
||||||
|
- Threshold plugin: you can set a threshold and a color, and the data
|
||||||
|
points below that threshold will then get the color. Useful for
|
||||||
|
marking data below 0, for instance.
|
||||||
|
|
||||||
|
- Stack plugin: you can specify a stack key for each series to have
|
||||||
|
them summed. This is useful for drawing additive/cumulative graphs
|
||||||
|
with bars and (currently unfilled) lines.
|
||||||
|
|
||||||
|
- Crosshairs plugin: trace the mouse position on the axes, enable with
|
||||||
|
crosshair: { mode: "x"} (see the new tracking example for a use).
|
||||||
|
|
||||||
|
- Image plugin: plot prerendered images.
|
||||||
|
|
||||||
|
- Navigation plugin for panning and zooming a plot.
|
||||||
|
|
||||||
|
- More configurable grid.
|
||||||
|
|
||||||
|
- Axis transformation support, useful for non-linear plots, e.g. log
|
||||||
|
axes and compressed time axes (like omitting weekends).
|
||||||
|
|
||||||
|
- Support for twelve-hour date formatting (patch by Forrest Aldridge).
|
||||||
|
|
||||||
|
- The color parsing code in Flot has been cleaned up and split out so
|
||||||
|
it's now available as a separate jQuery plugin. It's included inline
|
||||||
|
in the Flot source to make dependency managing easier. This also
|
||||||
|
makes it really easy to use the color helpers in Flot plugins.
|
||||||
|
|
||||||
|
Bug fixes:
|
||||||
|
|
||||||
|
- Fixed two corner-case bugs when drawing filled curves (report and
|
||||||
|
analysis by Joshua Varner).
|
||||||
|
- Fix auto-adjustment code when setting min to 0 for an axis where the
|
||||||
|
dataset is completely flat on that axis (report by chovy).
|
||||||
|
- Fixed a bug with passing in data from getData to setData when the
|
||||||
|
secondary axes are used (issue 65, reported by nperelman).
|
||||||
|
- Fixed so that it is possible to turn lines off when no other chart
|
||||||
|
type is shown (based on problem reported by Glenn Vanderburg), and
|
||||||
|
fixed so that setting lineWidth to 0 also hides the shadow (based on
|
||||||
|
problem reported by Sergio Nunes).
|
||||||
|
- Updated mousemove position expression to the latest from jQuery (bug
|
||||||
|
reported by meyuchas).
|
||||||
|
- Use CSS borders instead of background in legend (fix printing issue 25
|
||||||
|
and 45).
|
||||||
|
- Explicitly convert axis min/max to numbers.
|
||||||
|
- Fixed a bug with drawing marking lines with different colors
|
||||||
|
(reported by Khurram).
|
||||||
|
- Fixed a bug with returning y2 values in the selection event (fix
|
||||||
|
by exists, issue 75).
|
||||||
|
- Only set position relative on placeholder if it hasn't already a
|
||||||
|
position different from static (reported by kyberneticist, issue 95).
|
||||||
|
- Don't round markings to prevent sub-pixel problems (reported by Dan
|
||||||
|
Lipsitt).
|
||||||
|
- Make the grid border act similarly to a regular CSS border, i.e.
|
||||||
|
prevent it from overlapping the plot itself. This also fixes a
|
||||||
|
problem with anti-aliasing when the width is 1 pixel (reported by
|
||||||
|
Anthony Ettinger).
|
||||||
|
- Imported version 3 of excanvas and fixed two issues with the newer
|
||||||
|
version. Hopefully, this will make Flot work with IE8 (nudge by
|
||||||
|
Fabien Menager, further analysis by Booink, issue 133).
|
||||||
|
- Changed the shadow code for lines to hopefully look a bit better
|
||||||
|
with vertical lines.
|
||||||
|
- Round tick positions to avoid possible problems with fractions
|
||||||
|
(suggestion by Fred, issue 130).
|
||||||
|
- Made the heuristic for determining how many ticks to aim for a bit
|
||||||
|
smarter.
|
||||||
|
- Fix for uneven axis margins (report and patch by Paul Kienzle) and
|
||||||
|
snapping to ticks (concurrent report and patch by lifthrasiir).
|
||||||
|
- Fixed bug with slicing in findNearbyItems (patch by zollman).
|
||||||
|
- Make heuristic for x axis label widths more dynamic (patch by
|
||||||
|
rickinhethuis).
|
||||||
|
- Make sure points on top take precedence when finding nearby points
|
||||||
|
when hovering (reported by didroe, issue 224).
|
||||||
|
|
||||||
|
Flot 0.5
|
||||||
|
--------
|
||||||
|
|
||||||
|
Backwards API change summary: Timestamps are now in UTC. Also
|
||||||
|
"selected" event -> becomes "plotselected" with new data, the
|
||||||
|
parameters for setSelection are now different (but backwards
|
||||||
|
compatibility hooks are in place), coloredAreas becomes markings with
|
||||||
|
a new interface (but backwards compatibility hooks are in place).
|
||||||
|
|
||||||
|
|
||||||
|
Interactivity: added a new "plothover" event and this and the
|
||||||
|
"plotclick" event now returns the closest data item (based on patch by
|
||||||
|
/david, patch by Mark Byers for bar support). See the revamped
|
||||||
|
"interacting with the data" example for some hints on what you can do.
|
||||||
|
|
||||||
|
Highlighting: you can now highlight points and datapoints are
|
||||||
|
autohighlighted when you hover over them (if hovering is turned on).
|
||||||
|
|
||||||
|
Support for dual axis has been added (based on patch by someone who's
|
||||||
|
annoyed and /david). For each data series you can specify which axes
|
||||||
|
it belongs to, and there are two more axes, x2axis and y2axis, to
|
||||||
|
customize. This affects the "selected" event which has been renamed to
|
||||||
|
"plotselected" and spews out { xaxis: { from: -10, to: 20 } ... },
|
||||||
|
setSelection in which the parameters are on a new form (backwards
|
||||||
|
compatible hooks are in place so old code shouldn't break) and
|
||||||
|
markings (formerly coloredAreas).
|
||||||
|
|
||||||
|
Timestamps in time mode are now displayed according to
|
||||||
|
UTC instead of the time zone of the visitor. This affects the way the
|
||||||
|
timestamps should be input; you'll probably have to offset the
|
||||||
|
timestamps according to your local time zone. It also affects any
|
||||||
|
custom date handling code (which basically now should use the
|
||||||
|
equivalent UTC date mehods, e.g. .setUTCMonth() instead of
|
||||||
|
.setMonth().
|
||||||
|
|
||||||
|
Added support for specifying the size of tick labels (axis.labelWidth,
|
||||||
|
axis.labelHeight). Useful for specifying a max label size to keep
|
||||||
|
multiple plots aligned.
|
||||||
|
|
||||||
|
Markings, previously coloredAreas, are now specified as ranges on the
|
||||||
|
axes, like { xaxis: { from: 0, to: 10 }}. Furthermore with markings
|
||||||
|
you can now draw horizontal/vertical lines by setting from and to to
|
||||||
|
the same coordinate (idea from line support patch by by Ryan Funduk).
|
||||||
|
|
||||||
|
The "fill" option can now be a number that specifies the opacity of
|
||||||
|
the fill.
|
||||||
|
|
||||||
|
You can now specify a coordinate as null (like [2, null]) and Flot
|
||||||
|
will take the other coordinate into account when scaling the axes
|
||||||
|
(based on patch by joebno).
|
||||||
|
|
||||||
|
New option for bars "align". Set it to "center" to center the bars on
|
||||||
|
the value they represent.
|
||||||
|
|
||||||
|
setSelection now takes a second parameter which you can use to prevent
|
||||||
|
the method from firing the "plotselected" handler.
|
||||||
|
|
||||||
|
Using the "container" option in legend now overwrites the container
|
||||||
|
element instead of just appending to it (fixes infinite legend bug,
|
||||||
|
reported by several people, fix by Brad Dewey).
|
||||||
|
|
||||||
|
Fixed a bug in calculating spacing around the plot (reported by
|
||||||
|
timothytoe). Fixed a bug in finding max values for all-negative data
|
||||||
|
sets. Prevent the possibility of eternal looping in tick calculations.
|
||||||
|
Fixed a bug when borderWidth is set to 0 (reported by
|
||||||
|
Rob/sanchothefat). Fixed a bug with drawing bars extending below 0
|
||||||
|
(reported by James Hewitt, patch by Ryan Funduk). Fixed a
|
||||||
|
bug with line widths of bars (reported by MikeM). Fixed a bug with
|
||||||
|
'nw' and 'sw' legend positions. Improved the handling of axis
|
||||||
|
auto-scaling with bars. Fixed a bug with multi-line x-axis tick
|
||||||
|
labels (reported by Luca Ciano). IE-fix help by Savage Zhang.
|
||||||
|
|
||||||
|
|
||||||
|
Flot 0.4
|
||||||
|
--------
|
||||||
|
|
||||||
|
API changes: deprecated axis.noTicks in favor of just specifying the
|
||||||
|
number as axis.ticks. So "xaxis: { noTicks: 10 }" becomes
|
||||||
|
"xaxis: { ticks: 10 }"
|
||||||
|
|
||||||
|
Time series support. Specify axis.mode: "time", put in Javascript
|
||||||
|
timestamps as data, and Flot will automatically spit out sensible
|
||||||
|
ticks. Take a look at the two new examples. The format can be
|
||||||
|
customized with axis.timeformat and axis.monthNames, or if that fails
|
||||||
|
with axis.tickFormatter.
|
||||||
|
|
||||||
|
Support for colored background areas via grid.coloredAreas. Specify an
|
||||||
|
array of { x1, y1, x2, y2 } objects or a function that returns these
|
||||||
|
given { xmin, xmax, ymin, ymax }.
|
||||||
|
|
||||||
|
More members on the plot object (report by Chris Davies and others).
|
||||||
|
"getData" for inspecting the assigned settings on data series (e.g.
|
||||||
|
color) and "setData", "setupGrid" and "draw" for updating the contents
|
||||||
|
without a total replot.
|
||||||
|
|
||||||
|
The default number of ticks to aim for is now dependent on the size of
|
||||||
|
the plot in pixels. Support for customizing tick interval sizes
|
||||||
|
directly with axis.minTickSize and axis.tickSize.
|
||||||
|
|
||||||
|
Cleaned up the automatic axis scaling algorithm and fixed how it
|
||||||
|
interacts with ticks. Also fixed a couple of tick-related corner case
|
||||||
|
bugs (one reported by mainstreetmark, another reported by timothytoe).
|
||||||
|
|
||||||
|
The option axis.tickFormatter now takes a function with two
|
||||||
|
parameters, the second parameter is an optional object with
|
||||||
|
information about the axis. It has min, max, tickDecimals, tickSize.
|
||||||
|
|
||||||
|
Added support for segmented lines (based on patch from Michael
|
||||||
|
MacDonald) and for ignoring null and bad values (suggestion from Nick
|
||||||
|
Konidaris and joshwaihi).
|
||||||
|
|
||||||
|
Added support for changing the border width (joebno and safoo).
|
||||||
|
Label colors can be changed via CSS by selecting the tickLabel class.
|
||||||
|
|
||||||
|
Fixed a bug in handling single-item bar series (reported by Emil
|
||||||
|
Filipov). Fixed erratic behaviour when interacting with the plot
|
||||||
|
with IE 7 (reported by Lau Bech Lauritzen). Prevent IE/Safari text
|
||||||
|
selection when selecting stuff on the canvas.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Flot 0.3
|
||||||
|
--------
|
||||||
|
|
||||||
|
This is mostly a quick-fix release because jquery.js wasn't included
|
||||||
|
in the previous zip/tarball.
|
||||||
|
|
||||||
|
Support clicking on the plot. Turn it on with grid: { clickable: true },
|
||||||
|
then you get a "plotclick" event on the graph placeholder with the
|
||||||
|
position in units of the plot.
|
||||||
|
|
||||||
|
Fixed a bug in dealing with data where min = max, thanks to Michael
|
||||||
|
Messinides.
|
||||||
|
|
||||||
|
Include jquery.js in the zip/tarball.
|
||||||
|
|
||||||
|
|
||||||
|
Flot 0.2
|
||||||
|
--------
|
||||||
|
|
||||||
|
Added support for putting a background behind the default legend. The
|
||||||
|
default is the partly transparent background color. Added
|
||||||
|
backgroundColor and backgroundOpacity to the legend options to control
|
||||||
|
this.
|
||||||
|
|
||||||
|
The ticks options can now be a callback function that takes one
|
||||||
|
parameter, an object with the attributes min and max. The function
|
||||||
|
should return a ticks array.
|
||||||
|
|
||||||
|
Added labelFormatter option in legend, useful for turning the legend
|
||||||
|
labels into links.
|
||||||
|
|
||||||
|
Fixed a couple of bugs.
|
||||||
|
|
||||||
|
The API should now be fully documented.
|
||||||
|
|
||||||
|
Patch from Guy Fraser to make parts of the code smaller.
|
||||||
|
|
||||||
|
API changes: Moved labelMargin option to grid from x/yaxis.
|
||||||
|
|
||||||
|
|
||||||
|
Flot 0.1
|
||||||
|
--------
|
||||||
|
|
||||||
|
First public release.
|
|
@ -0,0 +1,137 @@
|
||||||
|
Writing plugins
|
||||||
|
---------------
|
||||||
|
|
||||||
|
All you need to do to make a new plugin is creating an init function
|
||||||
|
and a set of options (if needed), stuffing it into an object and
|
||||||
|
putting it in the $.plot.plugins array. For example:
|
||||||
|
|
||||||
|
function myCoolPluginInit(plot) {
|
||||||
|
plot.coolstring = "Hello!";
|
||||||
|
};
|
||||||
|
|
||||||
|
$.plot.plugins.push({ init: myCoolPluginInit, options: { ... } });
|
||||||
|
|
||||||
|
// if $.plot is called, it will return a plot object with the
|
||||||
|
// attribute "coolstring"
|
||||||
|
|
||||||
|
Now, given that the plugin might run in many different places, it's
|
||||||
|
a good idea to avoid leaking names. The usual trick here is wrap the
|
||||||
|
above lines in an anonymous function which is called immediately, like
|
||||||
|
this: (function () { inner code ... })(). To make it even more robust
|
||||||
|
in case $ is not bound to jQuery but some other Javascript library, we
|
||||||
|
can write it as
|
||||||
|
|
||||||
|
(function ($) {
|
||||||
|
// plugin definition
|
||||||
|
// ...
|
||||||
|
})(jQuery);
|
||||||
|
|
||||||
|
There's a complete example below, but you should also check out the
|
||||||
|
plugins bundled with Flot.
|
||||||
|
|
||||||
|
|
||||||
|
Complete example
|
||||||
|
----------------
|
||||||
|
|
||||||
|
Here is a simple debug plugin which alerts each of the series in the
|
||||||
|
plot. It has a single option that control whether it is enabled and
|
||||||
|
how much info to output:
|
||||||
|
|
||||||
|
(function ($) {
|
||||||
|
function init(plot) {
|
||||||
|
var debugLevel = 1;
|
||||||
|
|
||||||
|
function checkDebugEnabled(plot, options) {
|
||||||
|
if (options.debug) {
|
||||||
|
debugLevel = options.debug;
|
||||||
|
|
||||||
|
plot.hooks.processDatapoints.push(alertSeries);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function alertSeries(plot, series, datapoints) {
|
||||||
|
var msg = "series " + series.label;
|
||||||
|
if (debugLevel > 1)
|
||||||
|
msg += " with " + series.data.length + " points";
|
||||||
|
alert(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
plot.hooks.processOptions.push(checkDebugEnabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
var options = { debug: 0 };
|
||||||
|
|
||||||
|
$.plot.plugins.push({
|
||||||
|
init: init,
|
||||||
|
options: options,
|
||||||
|
name: "simpledebug",
|
||||||
|
version: "0.1"
|
||||||
|
});
|
||||||
|
})(jQuery);
|
||||||
|
|
||||||
|
We also define "name" and "version". It's not used by Flot, but might
|
||||||
|
be helpful for other plugins in resolving dependencies.
|
||||||
|
|
||||||
|
Put the above in a file named "jquery.flot.debug.js", include it in an
|
||||||
|
HTML page and then it can be used with:
|
||||||
|
|
||||||
|
$.plot($("#placeholder"), [...], { debug: 2 });
|
||||||
|
|
||||||
|
This simple plugin illustrates a couple of points:
|
||||||
|
|
||||||
|
- It uses the anonymous function trick to avoid name pollution.
|
||||||
|
- It can be enabled/disabled through an option.
|
||||||
|
- Variables in the init function can be used to store plot-specific
|
||||||
|
state between the hooks.
|
||||||
|
|
||||||
|
The two last points are important because there may be multiple plots
|
||||||
|
on the same page, and you'd want to make sure they are not mixed up.
|
||||||
|
|
||||||
|
|
||||||
|
Shutting down a plugin
|
||||||
|
----------------------
|
||||||
|
|
||||||
|
Each plot object has a shutdown hook which is run when plot.shutdown()
|
||||||
|
is called. This usually mostly happens in case another plot is made on
|
||||||
|
top of an existing one.
|
||||||
|
|
||||||
|
The purpose of the hook is to give you a chance to unbind any event
|
||||||
|
handlers you've registered and remove any extra DOM things you've
|
||||||
|
inserted.
|
||||||
|
|
||||||
|
The problem with event handlers is that you can have registered a
|
||||||
|
handler which is run in some point in the future, e.g. with
|
||||||
|
setTimeout(). Meanwhile, the plot may have been shutdown and removed,
|
||||||
|
but because your event handler is still referencing it, it can't be
|
||||||
|
garbage collected yet, and worse, if your handler eventually runs, it
|
||||||
|
may overwrite stuff on a completely different plot.
|
||||||
|
|
||||||
|
|
||||||
|
Some hints on the options
|
||||||
|
-------------------------
|
||||||
|
|
||||||
|
Plugins should always support appropriate options to enable/disable
|
||||||
|
them because the plugin user may have several plots on the same page
|
||||||
|
where only one should use the plugin. In most cases it's probably a
|
||||||
|
good idea if the plugin is turned off rather than on per default, just
|
||||||
|
like most of the powerful features in Flot.
|
||||||
|
|
||||||
|
If the plugin needs options that are specific to each series, like the
|
||||||
|
points or lines options in core Flot, you can put them in "series" in
|
||||||
|
the options object, e.g.
|
||||||
|
|
||||||
|
var options = {
|
||||||
|
series: {
|
||||||
|
downsample: {
|
||||||
|
algorithm: null,
|
||||||
|
maxpoints: 1000
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Then they will be copied by Flot into each series, providing default
|
||||||
|
values in case none are specified.
|
||||||
|
|
||||||
|
Think hard and long about naming the options. These names are going to
|
||||||
|
be public API, and code is going to depend on them if the plugin is
|
||||||
|
successful.
|
|
@ -0,0 +1,90 @@
|
||||||
|
About
|
||||||
|
-----
|
||||||
|
|
||||||
|
Flot is a Javascript plotting library for jQuery. Read more at the
|
||||||
|
website:
|
||||||
|
|
||||||
|
http://code.google.com/p/flot/
|
||||||
|
|
||||||
|
Take a look at the examples linked from above, they should give a good
|
||||||
|
impression of what Flot can do and the source code of the examples is
|
||||||
|
probably the fastest way to learn how to use Flot.
|
||||||
|
|
||||||
|
|
||||||
|
Installation
|
||||||
|
------------
|
||||||
|
|
||||||
|
Just include the Javascript file after you've included jQuery.
|
||||||
|
|
||||||
|
Generally, all browsers that support the HTML5 canvas tag are
|
||||||
|
supported.
|
||||||
|
|
||||||
|
For support for Internet Explorer < 9, you can use Excanvas, a canvas
|
||||||
|
emulator; this is used in the examples bundled with Flot. You just
|
||||||
|
include the excanvas script like this:
|
||||||
|
|
||||||
|
<!--[if lte IE 8]><script language="javascript" type="text/javascript" src="excanvas.min.js"></script><![endif]-->
|
||||||
|
|
||||||
|
If it's not working on your development IE 6.0, check that it has
|
||||||
|
support for VML which Excanvas is relying on. It appears that some
|
||||||
|
stripped down versions used for test environments on virtual machines
|
||||||
|
lack the VML support.
|
||||||
|
|
||||||
|
You can also try using Flashcanvas (see
|
||||||
|
http://code.google.com/p/flashcanvas/), which uses Flash to do the
|
||||||
|
emulation. Although Flash can be a bit slower to load than VML, if
|
||||||
|
you've got a lot of points, the Flash version can be much faster
|
||||||
|
overall. Flot contains some wrapper code for activating Excanvas which
|
||||||
|
Flashcanvas is compatible with.
|
||||||
|
|
||||||
|
You need at least jQuery 1.2.6, but try at least 1.3.2 for interactive
|
||||||
|
charts because of performance improvements in event handling.
|
||||||
|
|
||||||
|
|
||||||
|
Basic usage
|
||||||
|
-----------
|
||||||
|
|
||||||
|
Create a placeholder div to put the graph in:
|
||||||
|
|
||||||
|
<div id="placeholder"></div>
|
||||||
|
|
||||||
|
You need to set the width and height of this div, otherwise the plot
|
||||||
|
library doesn't know how to scale the graph. You can do it inline like
|
||||||
|
this:
|
||||||
|
|
||||||
|
<div id="placeholder" style="width:600px;height:300px"></div>
|
||||||
|
|
||||||
|
You can also do it with an external stylesheet. Make sure that the
|
||||||
|
placeholder isn't within something with a display:none CSS property -
|
||||||
|
in that case, Flot has trouble measuring label dimensions which
|
||||||
|
results in garbled looks and might have trouble measuring the
|
||||||
|
placeholder dimensions which is fatal (it'll throw an exception).
|
||||||
|
|
||||||
|
Then when the div is ready in the DOM, which is usually on document
|
||||||
|
ready, run the plot function:
|
||||||
|
|
||||||
|
$.plot($("#placeholder"), data, options);
|
||||||
|
|
||||||
|
Here, data is an array of data series and options is an object with
|
||||||
|
settings if you want to customize the plot. Take a look at the
|
||||||
|
examples for some ideas of what to put in or look at the reference
|
||||||
|
in the file "API.txt". Here's a quick example that'll draw a line from
|
||||||
|
(0, 0) to (1, 1):
|
||||||
|
|
||||||
|
$.plot($("#placeholder"), [ [[0, 0], [1, 1]] ], { yaxis: { max: 1 } });
|
||||||
|
|
||||||
|
The plot function immediately draws the chart and then returns a plot
|
||||||
|
object with a couple of methods.
|
||||||
|
|
||||||
|
|
||||||
|
What's with the name?
|
||||||
|
---------------------
|
||||||
|
|
||||||
|
First: it's pronounced with a short o, like "plot". Not like "flawed".
|
||||||
|
|
||||||
|
So "Flot" rhymes with "plot".
|
||||||
|
|
||||||
|
And if you look up "flot" in a Danish-to-English dictionary, some up
|
||||||
|
the words that come up are "good-looking", "attractive", "stylish",
|
||||||
|
"smart", "impressive", "extravagant". One of the main goals with Flot
|
||||||
|
is pretty looks.
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,179 @@
|
||||||
|
/* Plugin for jQuery for working with colors.
|
||||||
|
*
|
||||||
|
* Version 1.1.
|
||||||
|
*
|
||||||
|
* Inspiration from jQuery color animation plugin by John Resig.
|
||||||
|
*
|
||||||
|
* Released under the MIT license by Ole Laursen, October 2009.
|
||||||
|
*
|
||||||
|
* Examples:
|
||||||
|
*
|
||||||
|
* $.color.parse("#fff").scale('rgb', 0.25).add('a', -0.5).toString()
|
||||||
|
* var c = $.color.extract($("#mydiv"), 'background-color');
|
||||||
|
* console.log(c.r, c.g, c.b, c.a);
|
||||||
|
* $.color.make(100, 50, 25, 0.4).toString() // returns "rgba(100,50,25,0.4)"
|
||||||
|
*
|
||||||
|
* Note that .scale() and .add() return the same modified object
|
||||||
|
* instead of making a new one.
|
||||||
|
*
|
||||||
|
* V. 1.1: Fix error handling so e.g. parsing an empty string does
|
||||||
|
* produce a color rather than just crashing.
|
||||||
|
*/
|
||||||
|
|
||||||
|
(function($) {
|
||||||
|
$.color = {};
|
||||||
|
|
||||||
|
// construct color object with some convenient chainable helpers
|
||||||
|
$.color.make = function (r, g, b, a) {
|
||||||
|
var o = {};
|
||||||
|
o.r = r || 0;
|
||||||
|
o.g = g || 0;
|
||||||
|
o.b = b || 0;
|
||||||
|
o.a = a != null ? a : 1;
|
||||||
|
|
||||||
|
o.add = function (c, d) {
|
||||||
|
for (var i = 0; i < c.length; ++i)
|
||||||
|
o[c.charAt(i)] += d;
|
||||||
|
return o.normalize();
|
||||||
|
};
|
||||||
|
|
||||||
|
o.scale = function (c, f) {
|
||||||
|
for (var i = 0; i < c.length; ++i)
|
||||||
|
o[c.charAt(i)] *= f;
|
||||||
|
return o.normalize();
|
||||||
|
};
|
||||||
|
|
||||||
|
o.toString = function () {
|
||||||
|
if (o.a >= 1.0) {
|
||||||
|
return "rgb("+[o.r, o.g, o.b].join(",")+")";
|
||||||
|
} else {
|
||||||
|
return "rgba("+[o.r, o.g, o.b, o.a].join(",")+")";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
o.normalize = function () {
|
||||||
|
function clamp(min, value, max) {
|
||||||
|
return value < min ? min: (value > max ? max: value);
|
||||||
|
}
|
||||||
|
|
||||||
|
o.r = clamp(0, parseInt(o.r), 255);
|
||||||
|
o.g = clamp(0, parseInt(o.g), 255);
|
||||||
|
o.b = clamp(0, parseInt(o.b), 255);
|
||||||
|
o.a = clamp(0, o.a, 1);
|
||||||
|
return o;
|
||||||
|
};
|
||||||
|
|
||||||
|
o.clone = function () {
|
||||||
|
return $.color.make(o.r, o.b, o.g, o.a);
|
||||||
|
};
|
||||||
|
|
||||||
|
return o.normalize();
|
||||||
|
}
|
||||||
|
|
||||||
|
// extract CSS color property from element, going up in the DOM
|
||||||
|
// if it's "transparent"
|
||||||
|
$.color.extract = function (elem, css) {
|
||||||
|
var c;
|
||||||
|
do {
|
||||||
|
c = elem.css(css).toLowerCase();
|
||||||
|
// keep going until we find an element that has color, or
|
||||||
|
// we hit the body
|
||||||
|
if (c != '' && c != 'transparent')
|
||||||
|
break;
|
||||||
|
elem = elem.parent();
|
||||||
|
} while (!$.nodeName(elem.get(0), "body"));
|
||||||
|
|
||||||
|
// catch Safari's way of signalling transparent
|
||||||
|
if (c == "rgba(0, 0, 0, 0)")
|
||||||
|
c = "transparent";
|
||||||
|
|
||||||
|
return $.color.parse(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
// parse CSS color string (like "rgb(10, 32, 43)" or "#fff"),
|
||||||
|
// returns color object, if parsing failed, you get black (0, 0,
|
||||||
|
// 0) out
|
||||||
|
$.color.parse = function (str) {
|
||||||
|
var res, m = $.color.make;
|
||||||
|
|
||||||
|
// Look for rgb(num,num,num)
|
||||||
|
if (res = /rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(str))
|
||||||
|
return m(parseInt(res[1], 10), parseInt(res[2], 10), parseInt(res[3], 10));
|
||||||
|
|
||||||
|
// Look for rgba(num,num,num,num)
|
||||||
|
if (res = /rgba\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]+(?:\.[0-9]+)?)\s*\)/.exec(str))
|
||||||
|
return m(parseInt(res[1], 10), parseInt(res[2], 10), parseInt(res[3], 10), parseFloat(res[4]));
|
||||||
|
|
||||||
|
// Look for rgb(num%,num%,num%)
|
||||||
|
if (res = /rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(str))
|
||||||
|
return m(parseFloat(res[1])*2.55, parseFloat(res[2])*2.55, parseFloat(res[3])*2.55);
|
||||||
|
|
||||||
|
// Look for rgba(num%,num%,num%,num)
|
||||||
|
if (res = /rgba\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\s*\)/.exec(str))
|
||||||
|
return m(parseFloat(res[1])*2.55, parseFloat(res[2])*2.55, parseFloat(res[3])*2.55, parseFloat(res[4]));
|
||||||
|
|
||||||
|
// Look for #a0b1c2
|
||||||
|
if (res = /#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(str))
|
||||||
|
return m(parseInt(res[1], 16), parseInt(res[2], 16), parseInt(res[3], 16));
|
||||||
|
|
||||||
|
// Look for #fff
|
||||||
|
if (res = /#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(str))
|
||||||
|
return m(parseInt(res[1]+res[1], 16), parseInt(res[2]+res[2], 16), parseInt(res[3]+res[3], 16));
|
||||||
|
|
||||||
|
// Otherwise, we're most likely dealing with a named color
|
||||||
|
var name = $.trim(str).toLowerCase();
|
||||||
|
if (name == "transparent")
|
||||||
|
return m(255, 255, 255, 0);
|
||||||
|
else {
|
||||||
|
// default to black
|
||||||
|
res = lookupColors[name] || [0, 0, 0];
|
||||||
|
return m(res[0], res[1], res[2]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var lookupColors = {
|
||||||
|
aqua:[0,255,255],
|
||||||
|
azure:[240,255,255],
|
||||||
|
beige:[245,245,220],
|
||||||
|
black:[0,0,0],
|
||||||
|
blue:[0,0,255],
|
||||||
|
brown:[165,42,42],
|
||||||
|
cyan:[0,255,255],
|
||||||
|
darkblue:[0,0,139],
|
||||||
|
darkcyan:[0,139,139],
|
||||||
|
darkgrey:[169,169,169],
|
||||||
|
darkgreen:[0,100,0],
|
||||||
|
darkkhaki:[189,183,107],
|
||||||
|
darkmagenta:[139,0,139],
|
||||||
|
darkolivegreen:[85,107,47],
|
||||||
|
darkorange:[255,140,0],
|
||||||
|
darkorchid:[153,50,204],
|
||||||
|
darkred:[139,0,0],
|
||||||
|
darksalmon:[233,150,122],
|
||||||
|
darkviolet:[148,0,211],
|
||||||
|
fuchsia:[255,0,255],
|
||||||
|
gold:[255,215,0],
|
||||||
|
green:[0,128,0],
|
||||||
|
indigo:[75,0,130],
|
||||||
|
khaki:[240,230,140],
|
||||||
|
lightblue:[173,216,230],
|
||||||
|
lightcyan:[224,255,255],
|
||||||
|
lightgreen:[144,238,144],
|
||||||
|
lightgrey:[211,211,211],
|
||||||
|
lightpink:[255,182,193],
|
||||||
|
lightyellow:[255,255,224],
|
||||||
|
lime:[0,255,0],
|
||||||
|
magenta:[255,0,255],
|
||||||
|
maroon:[128,0,0],
|
||||||
|
navy:[0,0,128],
|
||||||
|
olive:[128,128,0],
|
||||||
|
orange:[255,165,0],
|
||||||
|
pink:[255,192,203],
|
||||||
|
purple:[128,0,128],
|
||||||
|
violet:[128,0,128],
|
||||||
|
red:[255,0,0],
|
||||||
|
silver:[192,192,192],
|
||||||
|
white:[255,255,255],
|
||||||
|
yellow:[255,255,0]
|
||||||
|
};
|
||||||
|
})(jQuery);
|
|
@ -0,0 +1,167 @@
|
||||||
|
/*
|
||||||
|
Flot plugin for showing crosshairs, thin lines, when the mouse hovers
|
||||||
|
over the plot.
|
||||||
|
|
||||||
|
crosshair: {
|
||||||
|
mode: null or "x" or "y" or "xy"
|
||||||
|
color: color
|
||||||
|
lineWidth: number
|
||||||
|
}
|
||||||
|
|
||||||
|
Set the mode to one of "x", "y" or "xy". The "x" mode enables a
|
||||||
|
vertical crosshair that lets you trace the values on the x axis, "y"
|
||||||
|
enables a horizontal crosshair and "xy" enables them both. "color" is
|
||||||
|
the color of the crosshair (default is "rgba(170, 0, 0, 0.80)"),
|
||||||
|
"lineWidth" is the width of the drawn lines (default is 1).
|
||||||
|
|
||||||
|
The plugin also adds four public methods:
|
||||||
|
|
||||||
|
- setCrosshair(pos)
|
||||||
|
|
||||||
|
Set the position of the crosshair. Note that this is cleared if
|
||||||
|
the user moves the mouse. "pos" is in coordinates of the plot and
|
||||||
|
should be on the form { x: xpos, y: ypos } (you can use x2/x3/...
|
||||||
|
if you're using multiple axes), which is coincidentally the same
|
||||||
|
format as what you get from a "plothover" event. If "pos" is null,
|
||||||
|
the crosshair is cleared.
|
||||||
|
|
||||||
|
- clearCrosshair()
|
||||||
|
|
||||||
|
Clear the crosshair.
|
||||||
|
|
||||||
|
- lockCrosshair(pos)
|
||||||
|
|
||||||
|
Cause the crosshair to lock to the current location, no longer
|
||||||
|
updating if the user moves the mouse. Optionally supply a position
|
||||||
|
(passed on to setCrosshair()) to move it to.
|
||||||
|
|
||||||
|
Example usage:
|
||||||
|
var myFlot = $.plot( $("#graph"), ..., { crosshair: { mode: "x" } } };
|
||||||
|
$("#graph").bind("plothover", function (evt, position, item) {
|
||||||
|
if (item) {
|
||||||
|
// Lock the crosshair to the data point being hovered
|
||||||
|
myFlot.lockCrosshair({ x: item.datapoint[0], y: item.datapoint[1] });
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// Return normal crosshair operation
|
||||||
|
myFlot.unlockCrosshair();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
- unlockCrosshair()
|
||||||
|
|
||||||
|
Free the crosshair to move again after locking it.
|
||||||
|
*/
|
||||||
|
|
||||||
|
(function ($) {
|
||||||
|
var options = {
|
||||||
|
crosshair: {
|
||||||
|
mode: null, // one of null, "x", "y" or "xy",
|
||||||
|
color: "rgba(170, 0, 0, 0.80)",
|
||||||
|
lineWidth: 1
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
function init(plot) {
|
||||||
|
// position of crosshair in pixels
|
||||||
|
var crosshair = { x: -1, y: -1, locked: false };
|
||||||
|
|
||||||
|
plot.setCrosshair = function setCrosshair(pos) {
|
||||||
|
if (!pos)
|
||||||
|
crosshair.x = -1;
|
||||||
|
else {
|
||||||
|
var o = plot.p2c(pos);
|
||||||
|
crosshair.x = Math.max(0, Math.min(o.left, plot.width()));
|
||||||
|
crosshair.y = Math.max(0, Math.min(o.top, plot.height()));
|
||||||
|
}
|
||||||
|
|
||||||
|
plot.triggerRedrawOverlay();
|
||||||
|
};
|
||||||
|
|
||||||
|
plot.clearCrosshair = plot.setCrosshair; // passes null for pos
|
||||||
|
|
||||||
|
plot.lockCrosshair = function lockCrosshair(pos) {
|
||||||
|
if (pos)
|
||||||
|
plot.setCrosshair(pos);
|
||||||
|
crosshair.locked = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
plot.unlockCrosshair = function unlockCrosshair() {
|
||||||
|
crosshair.locked = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function onMouseOut(e) {
|
||||||
|
if (crosshair.locked)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (crosshair.x != -1) {
|
||||||
|
crosshair.x = -1;
|
||||||
|
plot.triggerRedrawOverlay();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function onMouseMove(e) {
|
||||||
|
if (crosshair.locked)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (plot.getSelection && plot.getSelection()) {
|
||||||
|
crosshair.x = -1; // hide the crosshair while selecting
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var offset = plot.offset();
|
||||||
|
crosshair.x = Math.max(0, Math.min(e.pageX - offset.left, plot.width()));
|
||||||
|
crosshair.y = Math.max(0, Math.min(e.pageY - offset.top, plot.height()));
|
||||||
|
plot.triggerRedrawOverlay();
|
||||||
|
}
|
||||||
|
|
||||||
|
plot.hooks.bindEvents.push(function (plot, eventHolder) {
|
||||||
|
if (!plot.getOptions().crosshair.mode)
|
||||||
|
return;
|
||||||
|
|
||||||
|
eventHolder.mouseout(onMouseOut);
|
||||||
|
eventHolder.mousemove(onMouseMove);
|
||||||
|
});
|
||||||
|
|
||||||
|
plot.hooks.drawOverlay.push(function (plot, ctx) {
|
||||||
|
var c = plot.getOptions().crosshair;
|
||||||
|
if (!c.mode)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var plotOffset = plot.getPlotOffset();
|
||||||
|
|
||||||
|
ctx.save();
|
||||||
|
ctx.translate(plotOffset.left, plotOffset.top);
|
||||||
|
|
||||||
|
if (crosshair.x != -1) {
|
||||||
|
ctx.strokeStyle = c.color;
|
||||||
|
ctx.lineWidth = c.lineWidth;
|
||||||
|
ctx.lineJoin = "round";
|
||||||
|
|
||||||
|
ctx.beginPath();
|
||||||
|
if (c.mode.indexOf("x") != -1) {
|
||||||
|
ctx.moveTo(crosshair.x, 0);
|
||||||
|
ctx.lineTo(crosshair.x, plot.height());
|
||||||
|
}
|
||||||
|
if (c.mode.indexOf("y") != -1) {
|
||||||
|
ctx.moveTo(0, crosshair.y);
|
||||||
|
ctx.lineTo(plot.width(), crosshair.y);
|
||||||
|
}
|
||||||
|
ctx.stroke();
|
||||||
|
}
|
||||||
|
ctx.restore();
|
||||||
|
});
|
||||||
|
|
||||||
|
plot.hooks.shutdown.push(function (plot, eventHolder) {
|
||||||
|
eventHolder.unbind("mouseout", onMouseOut);
|
||||||
|
eventHolder.unbind("mousemove", onMouseMove);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
$.plot.plugins.push({
|
||||||
|
init: init,
|
||||||
|
options: options,
|
||||||
|
name: 'crosshair',
|
||||||
|
version: '1.0'
|
||||||
|
});
|
||||||
|
})(jQuery);
|
|
@ -0,0 +1,183 @@
|
||||||
|
/*
|
||||||
|
Flot plugin for computing bottoms for filled line and bar charts.
|
||||||
|
|
||||||
|
The case: you've got two series that you want to fill the area
|
||||||
|
between. In Flot terms, you need to use one as the fill bottom of the
|
||||||
|
other. You can specify the bottom of each data point as the third
|
||||||
|
coordinate manually, or you can use this plugin to compute it for you.
|
||||||
|
|
||||||
|
In order to name the other series, you need to give it an id, like this
|
||||||
|
|
||||||
|
var dataset = [
|
||||||
|
{ data: [ ... ], id: "foo" } , // use default bottom
|
||||||
|
{ data: [ ... ], fillBetween: "foo" }, // use first dataset as bottom
|
||||||
|
];
|
||||||
|
|
||||||
|
$.plot($("#placeholder"), dataset, { line: { show: true, fill: true }});
|
||||||
|
|
||||||
|
As a convenience, if the id given is a number that doesn't appear as
|
||||||
|
an id in the series, it is interpreted as the index in the array
|
||||||
|
instead (so fillBetween: 0 can also mean the first series).
|
||||||
|
|
||||||
|
Internally, the plugin modifies the datapoints in each series. For
|
||||||
|
line series, extra data points might be inserted through
|
||||||
|
interpolation. Note that at points where the bottom line is not
|
||||||
|
defined (due to a null point or start/end of line), the current line
|
||||||
|
will show a gap too. The algorithm comes from the jquery.flot.stack.js
|
||||||
|
plugin, possibly some code could be shared.
|
||||||
|
*/
|
||||||
|
|
||||||
|
(function ($) {
|
||||||
|
var options = {
|
||||||
|
series: { fillBetween: null } // or number
|
||||||
|
};
|
||||||
|
|
||||||
|
function init(plot) {
|
||||||
|
function findBottomSeries(s, allseries) {
|
||||||
|
var i;
|
||||||
|
for (i = 0; i < allseries.length; ++i) {
|
||||||
|
if (allseries[i].id == s.fillBetween)
|
||||||
|
return allseries[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof s.fillBetween == "number") {
|
||||||
|
i = s.fillBetween;
|
||||||
|
|
||||||
|
if (i < 0 || i >= allseries.length)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return allseries[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function computeFillBottoms(plot, s, datapoints) {
|
||||||
|
if (s.fillBetween == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var other = findBottomSeries(s, plot.getData());
|
||||||
|
if (!other)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var ps = datapoints.pointsize,
|
||||||
|
points = datapoints.points,
|
||||||
|
otherps = other.datapoints.pointsize,
|
||||||
|
otherpoints = other.datapoints.points,
|
||||||
|
newpoints = [],
|
||||||
|
px, py, intery, qx, qy, bottom,
|
||||||
|
withlines = s.lines.show,
|
||||||
|
withbottom = ps > 2 && datapoints.format[2].y,
|
||||||
|
withsteps = withlines && s.lines.steps,
|
||||||
|
fromgap = true,
|
||||||
|
i = 0, j = 0, l;
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
if (i >= points.length)
|
||||||
|
break;
|
||||||
|
|
||||||
|
l = newpoints.length;
|
||||||
|
|
||||||
|
if (points[i] == null) {
|
||||||
|
// copy gaps
|
||||||
|
for (m = 0; m < ps; ++m)
|
||||||
|
newpoints.push(points[i + m]);
|
||||||
|
i += ps;
|
||||||
|
}
|
||||||
|
else if (j >= otherpoints.length) {
|
||||||
|
// for lines, we can't use the rest of the points
|
||||||
|
if (!withlines) {
|
||||||
|
for (m = 0; m < ps; ++m)
|
||||||
|
newpoints.push(points[i + m]);
|
||||||
|
}
|
||||||
|
i += ps;
|
||||||
|
}
|
||||||
|
else if (otherpoints[j] == null) {
|
||||||
|
// oops, got a gap
|
||||||
|
for (m = 0; m < ps; ++m)
|
||||||
|
newpoints.push(null);
|
||||||
|
fromgap = true;
|
||||||
|
j += otherps;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// cases where we actually got two points
|
||||||
|
px = points[i];
|
||||||
|
py = points[i + 1];
|
||||||
|
qx = otherpoints[j];
|
||||||
|
qy = otherpoints[j + 1];
|
||||||
|
bottom = 0;
|
||||||
|
|
||||||
|
if (px == qx) {
|
||||||
|
for (m = 0; m < ps; ++m)
|
||||||
|
newpoints.push(points[i + m]);
|
||||||
|
|
||||||
|
//newpoints[l + 1] += qy;
|
||||||
|
bottom = qy;
|
||||||
|
|
||||||
|
i += ps;
|
||||||
|
j += otherps;
|
||||||
|
}
|
||||||
|
else if (px > qx) {
|
||||||
|
// we got past point below, might need to
|
||||||
|
// insert interpolated extra point
|
||||||
|
if (withlines && i > 0 && points[i - ps] != null) {
|
||||||
|
intery = py + (points[i - ps + 1] - py) * (qx - px) / (points[i - ps] - px);
|
||||||
|
newpoints.push(qx);
|
||||||
|
newpoints.push(intery)
|
||||||
|
for (m = 2; m < ps; ++m)
|
||||||
|
newpoints.push(points[i + m]);
|
||||||
|
bottom = qy;
|
||||||
|
}
|
||||||
|
|
||||||
|
j += otherps;
|
||||||
|
}
|
||||||
|
else { // px < qx
|
||||||
|
if (fromgap && withlines) {
|
||||||
|
// if we come from a gap, we just skip this point
|
||||||
|
i += ps;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (m = 0; m < ps; ++m)
|
||||||
|
newpoints.push(points[i + m]);
|
||||||
|
|
||||||
|
// we might be able to interpolate a point below,
|
||||||
|
// this can give us a better y
|
||||||
|
if (withlines && j > 0 && otherpoints[j - otherps] != null)
|
||||||
|
bottom = qy + (otherpoints[j - otherps + 1] - qy) * (px - qx) / (otherpoints[j - otherps] - qx);
|
||||||
|
|
||||||
|
//newpoints[l + 1] += bottom;
|
||||||
|
|
||||||
|
i += ps;
|
||||||
|
}
|
||||||
|
|
||||||
|
fromgap = false;
|
||||||
|
|
||||||
|
if (l != newpoints.length && withbottom)
|
||||||
|
newpoints[l + 2] = bottom;
|
||||||
|
}
|
||||||
|
|
||||||
|
// maintain the line steps invariant
|
||||||
|
if (withsteps && l != newpoints.length && l > 0
|
||||||
|
&& newpoints[l] != null
|
||||||
|
&& newpoints[l] != newpoints[l - ps]
|
||||||
|
&& newpoints[l + 1] != newpoints[l - ps + 1]) {
|
||||||
|
for (m = 0; m < ps; ++m)
|
||||||
|
newpoints[l + ps + m] = newpoints[l + m];
|
||||||
|
newpoints[l + 1] = newpoints[l - ps + 1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
datapoints.points = newpoints;
|
||||||
|
}
|
||||||
|
|
||||||
|
plot.hooks.processDatapoints.push(computeFillBottoms);
|
||||||
|
}
|
||||||
|
|
||||||
|
$.plot.plugins.push({
|
||||||
|
init: init,
|
||||||
|
options: options,
|
||||||
|
name: 'fillbetween',
|
||||||
|
version: '1.0'
|
||||||
|
});
|
||||||
|
})(jQuery);
|
|
@ -0,0 +1,238 @@
|
||||||
|
/*
|
||||||
|
Flot plugin for plotting images, e.g. useful for putting ticks on a
|
||||||
|
prerendered complex visualization.
|
||||||
|
|
||||||
|
The data syntax is [[image, x1, y1, x2, y2], ...] where (x1, y1) and
|
||||||
|
(x2, y2) are where you intend the two opposite corners of the image to
|
||||||
|
end up in the plot. Image must be a fully loaded Javascript image (you
|
||||||
|
can make one with new Image()). If the image is not complete, it's
|
||||||
|
skipped when plotting.
|
||||||
|
|
||||||
|
There are two helpers included for retrieving images. The easiest work
|
||||||
|
the way that you put in URLs instead of images in the data (like
|
||||||
|
["myimage.png", 0, 0, 10, 10]), then call $.plot.image.loadData(data,
|
||||||
|
options, callback) where data and options are the same as you pass in
|
||||||
|
to $.plot. This loads the images, replaces the URLs in the data with
|
||||||
|
the corresponding images and calls "callback" when all images are
|
||||||
|
loaded (or failed loading). In the callback, you can then call $.plot
|
||||||
|
with the data set. See the included example.
|
||||||
|
|
||||||
|
A more low-level helper, $.plot.image.load(urls, callback) is also
|
||||||
|
included. Given a list of URLs, it calls callback with an object
|
||||||
|
mapping from URL to Image object when all images are loaded or have
|
||||||
|
failed loading.
|
||||||
|
|
||||||
|
Options for the plugin are
|
||||||
|
|
||||||
|
series: {
|
||||||
|
images: {
|
||||||
|
show: boolean
|
||||||
|
anchor: "corner" or "center"
|
||||||
|
alpha: [0,1]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
which can be specified for a specific series
|
||||||
|
|
||||||
|
$.plot($("#placeholder"), [{ data: [ ... ], images: { ... } ])
|
||||||
|
|
||||||
|
Note that because the data format is different from usual data points,
|
||||||
|
you can't use images with anything else in a specific data series.
|
||||||
|
|
||||||
|
Setting "anchor" to "center" causes the pixels in the image to be
|
||||||
|
anchored at the corner pixel centers inside of at the pixel corners,
|
||||||
|
effectively letting half a pixel stick out to each side in the plot.
|
||||||
|
|
||||||
|
|
||||||
|
A possible future direction could be support for tiling for large
|
||||||
|
images (like Google Maps).
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
(function ($) {
|
||||||
|
var options = {
|
||||||
|
series: {
|
||||||
|
images: {
|
||||||
|
show: false,
|
||||||
|
alpha: 1,
|
||||||
|
anchor: "corner" // or "center"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
$.plot.image = {};
|
||||||
|
|
||||||
|
$.plot.image.loadDataImages = function (series, options, callback) {
|
||||||
|
var urls = [], points = [];
|
||||||
|
|
||||||
|
var defaultShow = options.series.images.show;
|
||||||
|
|
||||||
|
$.each(series, function (i, s) {
|
||||||
|
if (!(defaultShow || s.images.show))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (s.data)
|
||||||
|
s = s.data;
|
||||||
|
|
||||||
|
$.each(s, function (i, p) {
|
||||||
|
if (typeof p[0] == "string") {
|
||||||
|
urls.push(p[0]);
|
||||||
|
points.push(p);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
$.plot.image.load(urls, function (loadedImages) {
|
||||||
|
$.each(points, function (i, p) {
|
||||||
|
var url = p[0];
|
||||||
|
if (loadedImages[url])
|
||||||
|
p[0] = loadedImages[url];
|
||||||
|
});
|
||||||
|
|
||||||
|
callback();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
$.plot.image.load = function (urls, callback) {
|
||||||
|
var missing = urls.length, loaded = {};
|
||||||
|
if (missing == 0)
|
||||||
|
callback({});
|
||||||
|
|
||||||
|
$.each(urls, function (i, url) {
|
||||||
|
var handler = function () {
|
||||||
|
--missing;
|
||||||
|
|
||||||
|
loaded[url] = this;
|
||||||
|
|
||||||
|
if (missing == 0)
|
||||||
|
callback(loaded);
|
||||||
|
};
|
||||||
|
|
||||||
|
$('<img />').load(handler).error(handler).attr('src', url);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function drawSeries(plot, ctx, series) {
|
||||||
|
var plotOffset = plot.getPlotOffset();
|
||||||
|
|
||||||
|
if (!series.images || !series.images.show)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var points = series.datapoints.points,
|
||||||
|
ps = series.datapoints.pointsize;
|
||||||
|
|
||||||
|
for (var i = 0; i < points.length; i += ps) {
|
||||||
|
var img = points[i],
|
||||||
|
x1 = points[i + 1], y1 = points[i + 2],
|
||||||
|
x2 = points[i + 3], y2 = points[i + 4],
|
||||||
|
xaxis = series.xaxis, yaxis = series.yaxis,
|
||||||
|
tmp;
|
||||||
|
|
||||||
|
// actually we should check img.complete, but it
|
||||||
|
// appears to be a somewhat unreliable indicator in
|
||||||
|
// IE6 (false even after load event)
|
||||||
|
if (!img || img.width <= 0 || img.height <= 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (x1 > x2) {
|
||||||
|
tmp = x2;
|
||||||
|
x2 = x1;
|
||||||
|
x1 = tmp;
|
||||||
|
}
|
||||||
|
if (y1 > y2) {
|
||||||
|
tmp = y2;
|
||||||
|
y2 = y1;
|
||||||
|
y1 = tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
// if the anchor is at the center of the pixel, expand the
|
||||||
|
// image by 1/2 pixel in each direction
|
||||||
|
if (series.images.anchor == "center") {
|
||||||
|
tmp = 0.5 * (x2-x1) / (img.width - 1);
|
||||||
|
x1 -= tmp;
|
||||||
|
x2 += tmp;
|
||||||
|
tmp = 0.5 * (y2-y1) / (img.height - 1);
|
||||||
|
y1 -= tmp;
|
||||||
|
y2 += tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
// clip
|
||||||
|
if (x1 == x2 || y1 == y2 ||
|
||||||
|
x1 >= xaxis.max || x2 <= xaxis.min ||
|
||||||
|
y1 >= yaxis.max || y2 <= yaxis.min)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
var sx1 = 0, sy1 = 0, sx2 = img.width, sy2 = img.height;
|
||||||
|
if (x1 < xaxis.min) {
|
||||||
|
sx1 += (sx2 - sx1) * (xaxis.min - x1) / (x2 - x1);
|
||||||
|
x1 = xaxis.min;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (x2 > xaxis.max) {
|
||||||
|
sx2 += (sx2 - sx1) * (xaxis.max - x2) / (x2 - x1);
|
||||||
|
x2 = xaxis.max;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (y1 < yaxis.min) {
|
||||||
|
sy2 += (sy1 - sy2) * (yaxis.min - y1) / (y2 - y1);
|
||||||
|
y1 = yaxis.min;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (y2 > yaxis.max) {
|
||||||
|
sy1 += (sy1 - sy2) * (yaxis.max - y2) / (y2 - y1);
|
||||||
|
y2 = yaxis.max;
|
||||||
|
}
|
||||||
|
|
||||||
|
x1 = xaxis.p2c(x1);
|
||||||
|
x2 = xaxis.p2c(x2);
|
||||||
|
y1 = yaxis.p2c(y1);
|
||||||
|
y2 = yaxis.p2c(y2);
|
||||||
|
|
||||||
|
// the transformation may have swapped us
|
||||||
|
if (x1 > x2) {
|
||||||
|
tmp = x2;
|
||||||
|
x2 = x1;
|
||||||
|
x1 = tmp;
|
||||||
|
}
|
||||||
|
if (y1 > y2) {
|
||||||
|
tmp = y2;
|
||||||
|
y2 = y1;
|
||||||
|
y1 = tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
tmp = ctx.globalAlpha;
|
||||||
|
ctx.globalAlpha *= series.images.alpha;
|
||||||
|
ctx.drawImage(img,
|
||||||
|
sx1, sy1, sx2 - sx1, sy2 - sy1,
|
||||||
|
x1 + plotOffset.left, y1 + plotOffset.top,
|
||||||
|
x2 - x1, y2 - y1);
|
||||||
|
ctx.globalAlpha = tmp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function processRawData(plot, series, data, datapoints) {
|
||||||
|
if (!series.images.show)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// format is Image, x1, y1, x2, y2 (opposite corners)
|
||||||
|
datapoints.format = [
|
||||||
|
{ required: true },
|
||||||
|
{ x: true, number: true, required: true },
|
||||||
|
{ y: true, number: true, required: true },
|
||||||
|
{ x: true, number: true, required: true },
|
||||||
|
{ y: true, number: true, required: true }
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
function init(plot) {
|
||||||
|
plot.hooks.processRawData.push(processRawData);
|
||||||
|
plot.hooks.drawSeries.push(drawSeries);
|
||||||
|
}
|
||||||
|
|
||||||
|
$.plot.plugins.push({
|
||||||
|
init: init,
|
||||||
|
options: options,
|
||||||
|
name: 'image',
|
||||||
|
version: '1.1'
|
||||||
|
});
|
||||||
|
})(jQuery);
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,336 @@
|
||||||
|
/*
|
||||||
|
Flot plugin for adding panning and zooming capabilities to a plot.
|
||||||
|
|
||||||
|
The default behaviour is double click and scrollwheel up/down to zoom
|
||||||
|
in, drag to pan. The plugin defines plot.zoom({ center }),
|
||||||
|
plot.zoomOut() and plot.pan(offset) so you easily can add custom
|
||||||
|
controls. It also fires a "plotpan" and "plotzoom" event when
|
||||||
|
something happens, useful for synchronizing plots.
|
||||||
|
|
||||||
|
Options:
|
||||||
|
|
||||||
|
zoom: {
|
||||||
|
interactive: false
|
||||||
|
trigger: "dblclick" // or "click" for single click
|
||||||
|
amount: 1.5 // 2 = 200% (zoom in), 0.5 = 50% (zoom out)
|
||||||
|
}
|
||||||
|
|
||||||
|
pan: {
|
||||||
|
interactive: false
|
||||||
|
cursor: "move" // CSS mouse cursor value used when dragging, e.g. "pointer"
|
||||||
|
frameRate: 20
|
||||||
|
}
|
||||||
|
|
||||||
|
xaxis, yaxis, x2axis, y2axis: {
|
||||||
|
zoomRange: null // or [number, number] (min range, max range) or false
|
||||||
|
panRange: null // or [number, number] (min, max) or false
|
||||||
|
}
|
||||||
|
|
||||||
|
"interactive" enables the built-in drag/click behaviour. If you enable
|
||||||
|
interactive for pan, then you'll have a basic plot that supports
|
||||||
|
moving around; the same for zoom.
|
||||||
|
|
||||||
|
"amount" specifies the default amount to zoom in (so 1.5 = 150%)
|
||||||
|
relative to the current viewport.
|
||||||
|
|
||||||
|
"cursor" is a standard CSS mouse cursor string used for visual
|
||||||
|
feedback to the user when dragging.
|
||||||
|
|
||||||
|
"frameRate" specifies the maximum number of times per second the plot
|
||||||
|
will update itself while the user is panning around on it (set to null
|
||||||
|
to disable intermediate pans, the plot will then not update until the
|
||||||
|
mouse button is released).
|
||||||
|
|
||||||
|
"zoomRange" is the interval in which zooming can happen, e.g. with
|
||||||
|
zoomRange: [1, 100] the zoom will never scale the axis so that the
|
||||||
|
difference between min and max is smaller than 1 or larger than 100.
|
||||||
|
You can set either end to null to ignore, e.g. [1, null]. If you set
|
||||||
|
zoomRange to false, zooming on that axis will be disabled.
|
||||||
|
|
||||||
|
"panRange" confines the panning to stay within a range, e.g. with
|
||||||
|
panRange: [-10, 20] panning stops at -10 in one end and at 20 in the
|
||||||
|
other. Either can be null, e.g. [-10, null]. If you set
|
||||||
|
panRange to false, panning on that axis will be disabled.
|
||||||
|
|
||||||
|
Example API usage:
|
||||||
|
|
||||||
|
plot = $.plot(...);
|
||||||
|
|
||||||
|
// zoom default amount in on the pixel (10, 20)
|
||||||
|
plot.zoom({ center: { left: 10, top: 20 } });
|
||||||
|
|
||||||
|
// zoom out again
|
||||||
|
plot.zoomOut({ center: { left: 10, top: 20 } });
|
||||||
|
|
||||||
|
// zoom 200% in on the pixel (10, 20)
|
||||||
|
plot.zoom({ amount: 2, center: { left: 10, top: 20 } });
|
||||||
|
|
||||||
|
// pan 100 pixels to the left and 20 down
|
||||||
|
plot.pan({ left: -100, top: 20 })
|
||||||
|
|
||||||
|
Here, "center" specifies where the center of the zooming should
|
||||||
|
happen. Note that this is defined in pixel space, not the space of the
|
||||||
|
data points (you can use the p2c helpers on the axes in Flot to help
|
||||||
|
you convert between these).
|
||||||
|
|
||||||
|
"amount" is the amount to zoom the viewport relative to the current
|
||||||
|
range, so 1 is 100% (i.e. no change), 1.5 is 150% (zoom in), 0.7 is
|
||||||
|
70% (zoom out). You can set the default in the options.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
// First two dependencies, jquery.event.drag.js and
|
||||||
|
// jquery.mousewheel.js, we put them inline here to save people the
|
||||||
|
// effort of downloading them.
|
||||||
|
|
||||||
|
/*
|
||||||
|
jquery.event.drag.js ~ v1.5 ~ Copyright (c) 2008, Three Dub Media (http://threedubmedia.com)
|
||||||
|
Licensed under the MIT License ~ http://threedubmedia.googlecode.com/files/MIT-LICENSE.txt
|
||||||
|
*/
|
||||||
|
(function(E){E.fn.drag=function(L,K,J){if(K){this.bind("dragstart",L)}if(J){this.bind("dragend",J)}return !L?this.trigger("drag"):this.bind("drag",K?K:L)};var A=E.event,B=A.special,F=B.drag={not:":input",distance:0,which:1,dragging:false,setup:function(J){J=E.extend({distance:F.distance,which:F.which,not:F.not},J||{});J.distance=I(J.distance);A.add(this,"mousedown",H,J);if(this.attachEvent){this.attachEvent("ondragstart",D)}},teardown:function(){A.remove(this,"mousedown",H);if(this===F.dragging){F.dragging=F.proxy=false}G(this,true);if(this.detachEvent){this.detachEvent("ondragstart",D)}}};B.dragstart=B.dragend={setup:function(){},teardown:function(){}};function H(L){var K=this,J,M=L.data||{};if(M.elem){K=L.dragTarget=M.elem;L.dragProxy=F.proxy||K;L.cursorOffsetX=M.pageX-M.left;L.cursorOffsetY=M.pageY-M.top;L.offsetX=L.pageX-L.cursorOffsetX;L.offsetY=L.pageY-L.cursorOffsetY}else{if(F.dragging||(M.which>0&&L.which!=M.which)||E(L.target).is(M.not)){return }}switch(L.type){case"mousedown":E.extend(M,E(K).offset(),{elem:K,target:L.target,pageX:L.pageX,pageY:L.pageY});A.add(document,"mousemove mouseup",H,M);G(K,false);F.dragging=null;return false;case !F.dragging&&"mousemove":if(I(L.pageX-M.pageX)+I(L.pageY-M.pageY)<M.distance){break}L.target=M.target;J=C(L,"dragstart",K);if(J!==false){F.dragging=K;F.proxy=L.dragProxy=E(J||K)[0]}case"mousemove":if(F.dragging){J=C(L,"drag",K);if(B.drop){B.drop.allowed=(J!==false);B.drop.handler(L)}if(J!==false){break}L.type="mouseup"}case"mouseup":A.remove(document,"mousemove mouseup",H);if(F.dragging){if(B.drop){B.drop.handler(L)}C(L,"dragend",K)}G(K,true);F.dragging=F.proxy=M.elem=false;break}return true}function C(M,K,L){M.type=K;var J=E.event.handle.call(L,M);return J===false?false:J||M.result}function I(J){return Math.pow(J,2)}function D(){return(F.dragging===false)}function G(K,J){if(!K){return }K.unselectable=J?"off":"on";K.onselectstart=function(){return J};if(K.style){K.style.MozUserSelect=J?"":"none"}}})(jQuery);
|
||||||
|
|
||||||
|
|
||||||
|
/* jquery.mousewheel.min.js
|
||||||
|
* Copyright (c) 2009 Brandon Aaron (http://brandonaaron.net)
|
||||||
|
* Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
|
||||||
|
* and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
|
||||||
|
* Thanks to: http://adomas.org/javascript-mouse-wheel/ for some pointers.
|
||||||
|
* Thanks to: Mathias Bank(http://www.mathias-bank.de) for a scope bug fix.
|
||||||
|
*
|
||||||
|
* Version: 3.0.2
|
||||||
|
*
|
||||||
|
* Requires: 1.2.2+
|
||||||
|
*/
|
||||||
|
(function(c){var a=["DOMMouseScroll","mousewheel"];c.event.special.mousewheel={setup:function(){if(this.addEventListener){for(var d=a.length;d;){this.addEventListener(a[--d],b,false)}}else{this.onmousewheel=b}},teardown:function(){if(this.removeEventListener){for(var d=a.length;d;){this.removeEventListener(a[--d],b,false)}}else{this.onmousewheel=null}}};c.fn.extend({mousewheel:function(d){return d?this.bind("mousewheel",d):this.trigger("mousewheel")},unmousewheel:function(d){return this.unbind("mousewheel",d)}});function b(f){var d=[].slice.call(arguments,1),g=0,e=true;f=c.event.fix(f||window.event);f.type="mousewheel";if(f.wheelDelta){g=f.wheelDelta/120}if(f.detail){g=-f.detail/3}d.unshift(f,g);return c.event.handle.apply(this,d)}})(jQuery);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
(function ($) {
|
||||||
|
var options = {
|
||||||
|
xaxis: {
|
||||||
|
zoomRange: null, // or [number, number] (min range, max range)
|
||||||
|
panRange: null // or [number, number] (min, max)
|
||||||
|
},
|
||||||
|
zoom: {
|
||||||
|
interactive: false,
|
||||||
|
trigger: "dblclick", // or "click" for single click
|
||||||
|
amount: 1.5 // how much to zoom relative to current position, 2 = 200% (zoom in), 0.5 = 50% (zoom out)
|
||||||
|
},
|
||||||
|
pan: {
|
||||||
|
interactive: false,
|
||||||
|
cursor: "move",
|
||||||
|
frameRate: 20
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
function init(plot) {
|
||||||
|
function onZoomClick(e, zoomOut) {
|
||||||
|
var c = plot.offset();
|
||||||
|
c.left = e.pageX - c.left;
|
||||||
|
c.top = e.pageY - c.top;
|
||||||
|
if (zoomOut)
|
||||||
|
plot.zoomOut({ center: c });
|
||||||
|
else
|
||||||
|
plot.zoom({ center: c });
|
||||||
|
}
|
||||||
|
|
||||||
|
function onMouseWheel(e, delta) {
|
||||||
|
onZoomClick(e, delta < 0);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var prevCursor = 'default', prevPageX = 0, prevPageY = 0,
|
||||||
|
panTimeout = null;
|
||||||
|
|
||||||
|
function onDragStart(e) {
|
||||||
|
if (e.which != 1) // only accept left-click
|
||||||
|
return false;
|
||||||
|
var c = plot.getPlaceholder().css('cursor');
|
||||||
|
if (c)
|
||||||
|
prevCursor = c;
|
||||||
|
plot.getPlaceholder().css('cursor', plot.getOptions().pan.cursor);
|
||||||
|
prevPageX = e.pageX;
|
||||||
|
prevPageY = e.pageY;
|
||||||
|
}
|
||||||
|
|
||||||
|
function onDrag(e) {
|
||||||
|
var frameRate = plot.getOptions().pan.frameRate;
|
||||||
|
if (panTimeout || !frameRate)
|
||||||
|
return;
|
||||||
|
|
||||||
|
panTimeout = setTimeout(function () {
|
||||||
|
plot.pan({ left: prevPageX - e.pageX,
|
||||||
|
top: prevPageY - e.pageY });
|
||||||
|
prevPageX = e.pageX;
|
||||||
|
prevPageY = e.pageY;
|
||||||
|
|
||||||
|
panTimeout = null;
|
||||||
|
}, 1 / frameRate * 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
function onDragEnd(e) {
|
||||||
|
if (panTimeout) {
|
||||||
|
clearTimeout(panTimeout);
|
||||||
|
panTimeout = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
plot.getPlaceholder().css('cursor', prevCursor);
|
||||||
|
plot.pan({ left: prevPageX - e.pageX,
|
||||||
|
top: prevPageY - e.pageY });
|
||||||
|
}
|
||||||
|
|
||||||
|
function bindEvents(plot, eventHolder) {
|
||||||
|
var o = plot.getOptions();
|
||||||
|
if (o.zoom.interactive) {
|
||||||
|
eventHolder[o.zoom.trigger](onZoomClick);
|
||||||
|
eventHolder.mousewheel(onMouseWheel);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (o.pan.interactive) {
|
||||||
|
eventHolder.bind("dragstart", { distance: 10 }, onDragStart);
|
||||||
|
eventHolder.bind("drag", onDrag);
|
||||||
|
eventHolder.bind("dragend", onDragEnd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
plot.zoomOut = function (args) {
|
||||||
|
if (!args)
|
||||||
|
args = {};
|
||||||
|
|
||||||
|
if (!args.amount)
|
||||||
|
args.amount = plot.getOptions().zoom.amount
|
||||||
|
|
||||||
|
args.amount = 1 / args.amount;
|
||||||
|
plot.zoom(args);
|
||||||
|
}
|
||||||
|
|
||||||
|
plot.zoom = function (args) {
|
||||||
|
if (!args)
|
||||||
|
args = {};
|
||||||
|
|
||||||
|
var c = args.center,
|
||||||
|
amount = args.amount || plot.getOptions().zoom.amount,
|
||||||
|
w = plot.width(), h = plot.height();
|
||||||
|
|
||||||
|
if (!c)
|
||||||
|
c = { left: w / 2, top: h / 2 };
|
||||||
|
|
||||||
|
var xf = c.left / w,
|
||||||
|
yf = c.top / h,
|
||||||
|
minmax = {
|
||||||
|
x: {
|
||||||
|
min: c.left - xf * w / amount,
|
||||||
|
max: c.left + (1 - xf) * w / amount
|
||||||
|
},
|
||||||
|
y: {
|
||||||
|
min: c.top - yf * h / amount,
|
||||||
|
max: c.top + (1 - yf) * h / amount
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
$.each(plot.getAxes(), function(_, axis) {
|
||||||
|
var opts = axis.options,
|
||||||
|
min = minmax[axis.direction].min,
|
||||||
|
max = minmax[axis.direction].max,
|
||||||
|
zr = opts.zoomRange;
|
||||||
|
|
||||||
|
if (zr === false) // no zooming on this axis
|
||||||
|
return;
|
||||||
|
|
||||||
|
min = axis.c2p(min);
|
||||||
|
max = axis.c2p(max);
|
||||||
|
if (min > max) {
|
||||||
|
// make sure min < max
|
||||||
|
var tmp = min;
|
||||||
|
min = max;
|
||||||
|
max = tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
var range = max - min;
|
||||||
|
if (zr &&
|
||||||
|
((zr[0] != null && range < zr[0]) ||
|
||||||
|
(zr[1] != null && range > zr[1])))
|
||||||
|
return;
|
||||||
|
|
||||||
|
opts.min = min;
|
||||||
|
opts.max = max;
|
||||||
|
});
|
||||||
|
|
||||||
|
plot.setupGrid();
|
||||||
|
plot.draw();
|
||||||
|
|
||||||
|
if (!args.preventEvent)
|
||||||
|
plot.getPlaceholder().trigger("plotzoom", [ plot ]);
|
||||||
|
}
|
||||||
|
|
||||||
|
plot.pan = function (args) {
|
||||||
|
var delta = {
|
||||||
|
x: +args.left,
|
||||||
|
y: +args.top
|
||||||
|
};
|
||||||
|
|
||||||
|
if (isNaN(delta.x))
|
||||||
|
delta.x = 0;
|
||||||
|
if (isNaN(delta.y))
|
||||||
|
delta.y = 0;
|
||||||
|
|
||||||
|
$.each(plot.getAxes(), function (_, axis) {
|
||||||
|
var opts = axis.options,
|
||||||
|
min, max, d = delta[axis.direction];
|
||||||
|
|
||||||
|
min = axis.c2p(axis.p2c(axis.min) + d),
|
||||||
|
max = axis.c2p(axis.p2c(axis.max) + d);
|
||||||
|
|
||||||
|
var pr = opts.panRange;
|
||||||
|
if (pr === false) // no panning on this axis
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (pr) {
|
||||||
|
// check whether we hit the wall
|
||||||
|
if (pr[0] != null && pr[0] > min) {
|
||||||
|
d = pr[0] - min;
|
||||||
|
min += d;
|
||||||
|
max += d;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pr[1] != null && pr[1] < max) {
|
||||||
|
d = pr[1] - max;
|
||||||
|
min += d;
|
||||||
|
max += d;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
opts.min = min;
|
||||||
|
opts.max = max;
|
||||||
|
});
|
||||||
|
|
||||||
|
plot.setupGrid();
|
||||||
|
plot.draw();
|
||||||
|
|
||||||
|
if (!args.preventEvent)
|
||||||
|
plot.getPlaceholder().trigger("plotpan", [ plot ]);
|
||||||
|
}
|
||||||
|
|
||||||
|
function shutdown(plot, eventHolder) {
|
||||||
|
eventHolder.unbind(plot.getOptions().zoom.trigger, onZoomClick);
|
||||||
|
eventHolder.unbind("mousewheel", onMouseWheel);
|
||||||
|
eventHolder.unbind("dragstart", onDragStart);
|
||||||
|
eventHolder.unbind("drag", onDrag);
|
||||||
|
eventHolder.unbind("dragend", onDragEnd);
|
||||||
|
if (panTimeout)
|
||||||
|
clearTimeout(panTimeout);
|
||||||
|
}
|
||||||
|
|
||||||
|
plot.hooks.bindEvents.push(bindEvents);
|
||||||
|
plot.hooks.shutdown.push(shutdown);
|
||||||
|
}
|
||||||
|
|
||||||
|
$.plot.plugins.push({
|
||||||
|
init: init,
|
||||||
|
options: options,
|
||||||
|
name: 'navigate',
|
||||||
|
version: '1.3'
|
||||||
|
});
|
||||||
|
})(jQuery);
|
|
@ -0,0 +1,750 @@
|
||||||
|
/*
|
||||||
|
Flot plugin for rendering pie charts. The plugin assumes the data is
|
||||||
|
coming is as a single data value for each series, and each of those
|
||||||
|
values is a positive value or zero (negative numbers don't make
|
||||||
|
any sense and will cause strange effects). The data values do
|
||||||
|
NOT need to be passed in as percentage values because it
|
||||||
|
internally calculates the total and percentages.
|
||||||
|
|
||||||
|
* Created by Brian Medendorp, June 2009
|
||||||
|
* Updated November 2009 with contributions from: btburnett3, Anthony Aragues and Xavi Ivars
|
||||||
|
|
||||||
|
* Changes:
|
||||||
|
2009-10-22: lineJoin set to round
|
||||||
|
2009-10-23: IE full circle fix, donut
|
||||||
|
2009-11-11: Added basic hover from btburnett3 - does not work in IE, and center is off in Chrome and Opera
|
||||||
|
2009-11-17: Added IE hover capability submitted by Anthony Aragues
|
||||||
|
2009-11-18: Added bug fix submitted by Xavi Ivars (issues with arrays when other JS libraries are included as well)
|
||||||
|
|
||||||
|
|
||||||
|
Available options are:
|
||||||
|
series: {
|
||||||
|
pie: {
|
||||||
|
show: true/false
|
||||||
|
radius: 0-1 for percentage of fullsize, or a specified pixel length, or 'auto'
|
||||||
|
innerRadius: 0-1 for percentage of fullsize or a specified pixel length, for creating a donut effect
|
||||||
|
startAngle: 0-2 factor of PI used for starting angle (in radians) i.e 3/2 starts at the top, 0 and 2 have the same result
|
||||||
|
tilt: 0-1 for percentage to tilt the pie, where 1 is no tilt, and 0 is completely flat (nothing will show)
|
||||||
|
offset: {
|
||||||
|
top: integer value to move the pie up or down
|
||||||
|
left: integer value to move the pie left or right, or 'auto'
|
||||||
|
},
|
||||||
|
stroke: {
|
||||||
|
color: any hexidecimal color value (other formats may or may not work, so best to stick with something like '#FFF')
|
||||||
|
width: integer pixel width of the stroke
|
||||||
|
},
|
||||||
|
label: {
|
||||||
|
show: true/false, or 'auto'
|
||||||
|
formatter: a user-defined function that modifies the text/style of the label text
|
||||||
|
radius: 0-1 for percentage of fullsize, or a specified pixel length
|
||||||
|
background: {
|
||||||
|
color: any hexidecimal color value (other formats may or may not work, so best to stick with something like '#000')
|
||||||
|
opacity: 0-1
|
||||||
|
},
|
||||||
|
threshold: 0-1 for the percentage value at which to hide labels (if they're too small)
|
||||||
|
},
|
||||||
|
combine: {
|
||||||
|
threshold: 0-1 for the percentage value at which to combine slices (if they're too small)
|
||||||
|
color: any hexidecimal color value (other formats may or may not work, so best to stick with something like '#CCC'), if null, the plugin will automatically use the color of the first slice to be combined
|
||||||
|
label: any text value of what the combined slice should be labeled
|
||||||
|
}
|
||||||
|
highlight: {
|
||||||
|
opacity: 0-1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
More detail and specific examples can be found in the included HTML file.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
(function ($)
|
||||||
|
{
|
||||||
|
function init(plot) // this is the "body" of the plugin
|
||||||
|
{
|
||||||
|
var canvas = null;
|
||||||
|
var target = null;
|
||||||
|
var maxRadius = null;
|
||||||
|
var centerLeft = null;
|
||||||
|
var centerTop = null;
|
||||||
|
var total = 0;
|
||||||
|
var redraw = true;
|
||||||
|
var redrawAttempts = 10;
|
||||||
|
var shrink = 0.95;
|
||||||
|
var legendWidth = 0;
|
||||||
|
var processed = false;
|
||||||
|
var raw = false;
|
||||||
|
|
||||||
|
// interactive variables
|
||||||
|
var highlights = [];
|
||||||
|
|
||||||
|
// add hook to determine if pie plugin in enabled, and then perform necessary operations
|
||||||
|
plot.hooks.processOptions.push(checkPieEnabled);
|
||||||
|
plot.hooks.bindEvents.push(bindEvents);
|
||||||
|
|
||||||
|
// check to see if the pie plugin is enabled
|
||||||
|
function checkPieEnabled(plot, options)
|
||||||
|
{
|
||||||
|
if (options.series.pie.show)
|
||||||
|
{
|
||||||
|
//disable grid
|
||||||
|
options.grid.show = false;
|
||||||
|
|
||||||
|
// set labels.show
|
||||||
|
if (options.series.pie.label.show=='auto')
|
||||||
|
if (options.legend.show)
|
||||||
|
options.series.pie.label.show = false;
|
||||||
|
else
|
||||||
|
options.series.pie.label.show = true;
|
||||||
|
|
||||||
|
// set radius
|
||||||
|
if (options.series.pie.radius=='auto')
|
||||||
|
if (options.series.pie.label.show)
|
||||||
|
options.series.pie.radius = 3/4;
|
||||||
|
else
|
||||||
|
options.series.pie.radius = 1;
|
||||||
|
|
||||||
|
// ensure sane tilt
|
||||||
|
if (options.series.pie.tilt>1)
|
||||||
|
options.series.pie.tilt=1;
|
||||||
|
if (options.series.pie.tilt<0)
|
||||||
|
options.series.pie.tilt=0;
|
||||||
|
|
||||||
|
// add processData hook to do transformations on the data
|
||||||
|
plot.hooks.processDatapoints.push(processDatapoints);
|
||||||
|
plot.hooks.drawOverlay.push(drawOverlay);
|
||||||
|
|
||||||
|
// add draw hook
|
||||||
|
plot.hooks.draw.push(draw);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// bind hoverable events
|
||||||
|
function bindEvents(plot, eventHolder)
|
||||||
|
{
|
||||||
|
var options = plot.getOptions();
|
||||||
|
|
||||||
|
if (options.series.pie.show && options.grid.hoverable)
|
||||||
|
eventHolder.unbind('mousemove').mousemove(onMouseMove);
|
||||||
|
|
||||||
|
if (options.series.pie.show && options.grid.clickable)
|
||||||
|
eventHolder.unbind('click').click(onClick);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// debugging function that prints out an object
|
||||||
|
function alertObject(obj)
|
||||||
|
{
|
||||||
|
var msg = '';
|
||||||
|
function traverse(obj, depth)
|
||||||
|
{
|
||||||
|
if (!depth)
|
||||||
|
depth = 0;
|
||||||
|
for (var i = 0; i < obj.length; ++i)
|
||||||
|
{
|
||||||
|
for (var j=0; j<depth; j++)
|
||||||
|
msg += '\t';
|
||||||
|
|
||||||
|
if( typeof obj[i] == "object")
|
||||||
|
{ // its an object
|
||||||
|
msg += ''+i+':\n';
|
||||||
|
traverse(obj[i], depth+1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{ // its a value
|
||||||
|
msg += ''+i+': '+obj[i]+'\n';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
traverse(obj);
|
||||||
|
alert(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
function calcTotal(data)
|
||||||
|
{
|
||||||
|
for (var i = 0; i < data.length; ++i)
|
||||||
|
{
|
||||||
|
var item = parseFloat(data[i].data[0][1]);
|
||||||
|
if (item)
|
||||||
|
total += item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function processDatapoints(plot, series, data, datapoints)
|
||||||
|
{
|
||||||
|
if (!processed)
|
||||||
|
{
|
||||||
|
processed = true;
|
||||||
|
|
||||||
|
canvas = plot.getCanvas();
|
||||||
|
target = $(canvas).parent();
|
||||||
|
options = plot.getOptions();
|
||||||
|
|
||||||
|
plot.setData(combine(plot.getData()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function setupPie()
|
||||||
|
{
|
||||||
|
legendWidth = target.children().filter('.legend').children().width();
|
||||||
|
|
||||||
|
// calculate maximum radius and center point
|
||||||
|
maxRadius = Math.min(canvas.width,(canvas.height/options.series.pie.tilt))/2;
|
||||||
|
centerTop = (canvas.height/2)+options.series.pie.offset.top;
|
||||||
|
centerLeft = (canvas.width/2);
|
||||||
|
|
||||||
|
if (options.series.pie.offset.left=='auto')
|
||||||
|
if (options.legend.position.match('w'))
|
||||||
|
centerLeft += legendWidth/2;
|
||||||
|
else
|
||||||
|
centerLeft -= legendWidth/2;
|
||||||
|
else
|
||||||
|
centerLeft += options.series.pie.offset.left;
|
||||||
|
|
||||||
|
if (centerLeft<maxRadius)
|
||||||
|
centerLeft = maxRadius;
|
||||||
|
else if (centerLeft>canvas.width-maxRadius)
|
||||||
|
centerLeft = canvas.width-maxRadius;
|
||||||
|
}
|
||||||
|
|
||||||
|
function fixData(data)
|
||||||
|
{
|
||||||
|
for (var i = 0; i < data.length; ++i)
|
||||||
|
{
|
||||||
|
if (typeof(data[i].data)=='number')
|
||||||
|
data[i].data = [[1,data[i].data]];
|
||||||
|
else if (typeof(data[i].data)=='undefined' || typeof(data[i].data[0])=='undefined')
|
||||||
|
{
|
||||||
|
if (typeof(data[i].data)!='undefined' && typeof(data[i].data.label)!='undefined')
|
||||||
|
data[i].label = data[i].data.label; // fix weirdness coming from flot
|
||||||
|
data[i].data = [[1,0]];
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
function combine(data)
|
||||||
|
{
|
||||||
|
data = fixData(data);
|
||||||
|
calcTotal(data);
|
||||||
|
var combined = 0;
|
||||||
|
var numCombined = 0;
|
||||||
|
var color = options.series.pie.combine.color;
|
||||||
|
|
||||||
|
var newdata = [];
|
||||||
|
for (var i = 0; i < data.length; ++i)
|
||||||
|
{
|
||||||
|
// make sure its a number
|
||||||
|
data[i].data[0][1] = parseFloat(data[i].data[0][1]);
|
||||||
|
if (!data[i].data[0][1])
|
||||||
|
data[i].data[0][1] = 0;
|
||||||
|
|
||||||
|
if (data[i].data[0][1]/total<=options.series.pie.combine.threshold)
|
||||||
|
{
|
||||||
|
combined += data[i].data[0][1];
|
||||||
|
numCombined++;
|
||||||
|
if (!color)
|
||||||
|
color = data[i].color;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
newdata.push({
|
||||||
|
data: [[1,data[i].data[0][1]]],
|
||||||
|
color: data[i].color,
|
||||||
|
label: data[i].label,
|
||||||
|
angle: (data[i].data[0][1]*(Math.PI*2))/total,
|
||||||
|
percent: (data[i].data[0][1]/total*100)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (numCombined>0)
|
||||||
|
newdata.push({
|
||||||
|
data: [[1,combined]],
|
||||||
|
color: color,
|
||||||
|
label: options.series.pie.combine.label,
|
||||||
|
angle: (combined*(Math.PI*2))/total,
|
||||||
|
percent: (combined/total*100)
|
||||||
|
});
|
||||||
|
return newdata;
|
||||||
|
}
|
||||||
|
|
||||||
|
function draw(plot, newCtx)
|
||||||
|
{
|
||||||
|
if (!target) return; // if no series were passed
|
||||||
|
ctx = newCtx;
|
||||||
|
|
||||||
|
setupPie();
|
||||||
|
var slices = plot.getData();
|
||||||
|
|
||||||
|
var attempts = 0;
|
||||||
|
while (redraw && attempts<redrawAttempts)
|
||||||
|
{
|
||||||
|
redraw = false;
|
||||||
|
if (attempts>0)
|
||||||
|
maxRadius *= shrink;
|
||||||
|
attempts += 1;
|
||||||
|
clear();
|
||||||
|
if (options.series.pie.tilt<=0.8)
|
||||||
|
drawShadow();
|
||||||
|
drawPie();
|
||||||
|
}
|
||||||
|
if (attempts >= redrawAttempts) {
|
||||||
|
clear();
|
||||||
|
target.prepend('<div class="error">Could not draw pie with labels contained inside canvas</div>');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( plot.setSeries && plot.insertLegend )
|
||||||
|
{
|
||||||
|
plot.setSeries(slices);
|
||||||
|
plot.insertLegend();
|
||||||
|
}
|
||||||
|
|
||||||
|
// we're actually done at this point, just defining internal functions at this point
|
||||||
|
|
||||||
|
function clear()
|
||||||
|
{
|
||||||
|
ctx.clearRect(0,0,canvas.width,canvas.height);
|
||||||
|
target.children().filter('.pieLabel, .pieLabelBackground').remove();
|
||||||
|
}
|
||||||
|
|
||||||
|
function drawShadow()
|
||||||
|
{
|
||||||
|
var shadowLeft = 5;
|
||||||
|
var shadowTop = 15;
|
||||||
|
var edge = 10;
|
||||||
|
var alpha = 0.02;
|
||||||
|
|
||||||
|
// set radius
|
||||||
|
if (options.series.pie.radius>1)
|
||||||
|
var radius = options.series.pie.radius;
|
||||||
|
else
|
||||||
|
var radius = maxRadius * options.series.pie.radius;
|
||||||
|
|
||||||
|
if (radius>=(canvas.width/2)-shadowLeft || radius*options.series.pie.tilt>=(canvas.height/2)-shadowTop || radius<=edge)
|
||||||
|
return; // shadow would be outside canvas, so don't draw it
|
||||||
|
|
||||||
|
ctx.save();
|
||||||
|
ctx.translate(shadowLeft,shadowTop);
|
||||||
|
ctx.globalAlpha = alpha;
|
||||||
|
ctx.fillStyle = '#000';
|
||||||
|
|
||||||
|
// center and rotate to starting position
|
||||||
|
ctx.translate(centerLeft,centerTop);
|
||||||
|
ctx.scale(1, options.series.pie.tilt);
|
||||||
|
|
||||||
|
//radius -= edge;
|
||||||
|
for (var i=1; i<=edge; i++)
|
||||||
|
{
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.arc(0,0,radius,0,Math.PI*2,false);
|
||||||
|
ctx.fill();
|
||||||
|
radius -= i;
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx.restore();
|
||||||
|
}
|
||||||
|
|
||||||
|
function drawPie()
|
||||||
|
{
|
||||||
|
startAngle = Math.PI*options.series.pie.startAngle;
|
||||||
|
|
||||||
|
// set radius
|
||||||
|
if (options.series.pie.radius>1)
|
||||||
|
var radius = options.series.pie.radius;
|
||||||
|
else
|
||||||
|
var radius = maxRadius * options.series.pie.radius;
|
||||||
|
|
||||||
|
// center and rotate to starting position
|
||||||
|
ctx.save();
|
||||||
|
ctx.translate(centerLeft,centerTop);
|
||||||
|
ctx.scale(1, options.series.pie.tilt);
|
||||||
|
//ctx.rotate(startAngle); // start at top; -- This doesn't work properly in Opera
|
||||||
|
|
||||||
|
// draw slices
|
||||||
|
ctx.save();
|
||||||
|
var currentAngle = startAngle;
|
||||||
|
for (var i = 0; i < slices.length; ++i)
|
||||||
|
{
|
||||||
|
slices[i].startAngle = currentAngle;
|
||||||
|
drawSlice(slices[i].angle, slices[i].color, true);
|
||||||
|
}
|
||||||
|
ctx.restore();
|
||||||
|
|
||||||
|
// draw slice outlines
|
||||||
|
ctx.save();
|
||||||
|
ctx.lineWidth = options.series.pie.stroke.width;
|
||||||
|
currentAngle = startAngle;
|
||||||
|
for (var i = 0; i < slices.length; ++i)
|
||||||
|
drawSlice(slices[i].angle, options.series.pie.stroke.color, false);
|
||||||
|
ctx.restore();
|
||||||
|
|
||||||
|
// draw donut hole
|
||||||
|
drawDonutHole(ctx);
|
||||||
|
|
||||||
|
// draw labels
|
||||||
|
if (options.series.pie.label.show)
|
||||||
|
drawLabels();
|
||||||
|
|
||||||
|
// restore to original state
|
||||||
|
ctx.restore();
|
||||||
|
|
||||||
|
function drawSlice(angle, color, fill)
|
||||||
|
{
|
||||||
|
if (angle<=0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (fill)
|
||||||
|
ctx.fillStyle = color;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ctx.strokeStyle = color;
|
||||||
|
ctx.lineJoin = 'round';
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx.beginPath();
|
||||||
|
if (Math.abs(angle - Math.PI*2) > 0.000000001)
|
||||||
|
ctx.moveTo(0,0); // Center of the pie
|
||||||
|
else if ($.browser.msie)
|
||||||
|
angle -= 0.0001;
|
||||||
|
//ctx.arc(0,0,radius,0,angle,false); // This doesn't work properly in Opera
|
||||||
|
ctx.arc(0,0,radius,currentAngle,currentAngle+angle,false);
|
||||||
|
ctx.closePath();
|
||||||
|
//ctx.rotate(angle); // This doesn't work properly in Opera
|
||||||
|
currentAngle += angle;
|
||||||
|
|
||||||
|
if (fill)
|
||||||
|
ctx.fill();
|
||||||
|
else
|
||||||
|
ctx.stroke();
|
||||||
|
}
|
||||||
|
|
||||||
|
function drawLabels()
|
||||||
|
{
|
||||||
|
var currentAngle = startAngle;
|
||||||
|
|
||||||
|
// set radius
|
||||||
|
if (options.series.pie.label.radius>1)
|
||||||
|
var radius = options.series.pie.label.radius;
|
||||||
|
else
|
||||||
|
var radius = maxRadius * options.series.pie.label.radius;
|
||||||
|
|
||||||
|
for (var i = 0; i < slices.length; ++i)
|
||||||
|
{
|
||||||
|
if (slices[i].percent >= options.series.pie.label.threshold*100)
|
||||||
|
drawLabel(slices[i], currentAngle, i);
|
||||||
|
currentAngle += slices[i].angle;
|
||||||
|
}
|
||||||
|
|
||||||
|
function drawLabel(slice, startAngle, index)
|
||||||
|
{
|
||||||
|
if (slice.data[0][1]==0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// format label text
|
||||||
|
var lf = options.legend.labelFormatter, text, plf = options.series.pie.label.formatter;
|
||||||
|
if (lf)
|
||||||
|
text = lf(slice.label, slice);
|
||||||
|
else
|
||||||
|
text = slice.label;
|
||||||
|
if (plf)
|
||||||
|
text = plf(text, slice);
|
||||||
|
|
||||||
|
var halfAngle = ((startAngle+slice.angle) + startAngle)/2;
|
||||||
|
var x = centerLeft + Math.round(Math.cos(halfAngle) * radius);
|
||||||
|
var y = centerTop + Math.round(Math.sin(halfAngle) * radius) * options.series.pie.tilt;
|
||||||
|
|
||||||
|
var html = '<span class="pieLabel" id="pieLabel'+index+'" style="position:absolute;top:' + y + 'px;left:' + x + 'px;">' + text + "</span>";
|
||||||
|
target.append(html);
|
||||||
|
var label = target.children('#pieLabel'+index);
|
||||||
|
var labelTop = (y - label.height()/2);
|
||||||
|
var labelLeft = (x - label.width()/2);
|
||||||
|
label.css('top', labelTop);
|
||||||
|
label.css('left', labelLeft);
|
||||||
|
|
||||||
|
// check to make sure that the label is not outside the canvas
|
||||||
|
if (0-labelTop>0 || 0-labelLeft>0 || canvas.height-(labelTop+label.height())<0 || canvas.width-(labelLeft+label.width())<0)
|
||||||
|
redraw = true;
|
||||||
|
|
||||||
|
if (options.series.pie.label.background.opacity != 0) {
|
||||||
|
// put in the transparent background separately to avoid blended labels and label boxes
|
||||||
|
var c = options.series.pie.label.background.color;
|
||||||
|
if (c == null) {
|
||||||
|
c = slice.color;
|
||||||
|
}
|
||||||
|
var pos = 'top:'+labelTop+'px;left:'+labelLeft+'px;';
|
||||||
|
$('<div class="pieLabelBackground" style="position:absolute;width:' + label.width() + 'px;height:' + label.height() + 'px;' + pos +'background-color:' + c + ';"> </div>').insertBefore(label).css('opacity', options.series.pie.label.background.opacity);
|
||||||
|
}
|
||||||
|
} // end individual label function
|
||||||
|
} // end drawLabels function
|
||||||
|
} // end drawPie function
|
||||||
|
} // end draw function
|
||||||
|
|
||||||
|
// Placed here because it needs to be accessed from multiple locations
|
||||||
|
function drawDonutHole(layer)
|
||||||
|
{
|
||||||
|
// draw donut hole
|
||||||
|
if(options.series.pie.innerRadius > 0)
|
||||||
|
{
|
||||||
|
// subtract the center
|
||||||
|
layer.save();
|
||||||
|
innerRadius = options.series.pie.innerRadius > 1 ? options.series.pie.innerRadius : maxRadius * options.series.pie.innerRadius;
|
||||||
|
layer.globalCompositeOperation = 'destination-out'; // this does not work with excanvas, but it will fall back to using the stroke color
|
||||||
|
layer.beginPath();
|
||||||
|
layer.fillStyle = options.series.pie.stroke.color;
|
||||||
|
layer.arc(0,0,innerRadius,0,Math.PI*2,false);
|
||||||
|
layer.fill();
|
||||||
|
layer.closePath();
|
||||||
|
layer.restore();
|
||||||
|
|
||||||
|
// add inner stroke
|
||||||
|
layer.save();
|
||||||
|
layer.beginPath();
|
||||||
|
layer.strokeStyle = options.series.pie.stroke.color;
|
||||||
|
layer.arc(0,0,innerRadius,0,Math.PI*2,false);
|
||||||
|
layer.stroke();
|
||||||
|
layer.closePath();
|
||||||
|
layer.restore();
|
||||||
|
// TODO: add extra shadow inside hole (with a mask) if the pie is tilted.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//-- Additional Interactive related functions --
|
||||||
|
|
||||||
|
function isPointInPoly(poly, pt)
|
||||||
|
{
|
||||||
|
for(var c = false, i = -1, l = poly.length, j = l - 1; ++i < l; j = i)
|
||||||
|
((poly[i][1] <= pt[1] && pt[1] < poly[j][1]) || (poly[j][1] <= pt[1] && pt[1]< poly[i][1]))
|
||||||
|
&& (pt[0] < (poly[j][0] - poly[i][0]) * (pt[1] - poly[i][1]) / (poly[j][1] - poly[i][1]) + poly[i][0])
|
||||||
|
&& (c = !c);
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
function findNearbySlice(mouseX, mouseY)
|
||||||
|
{
|
||||||
|
var slices = plot.getData(),
|
||||||
|
options = plot.getOptions(),
|
||||||
|
radius = options.series.pie.radius > 1 ? options.series.pie.radius : maxRadius * options.series.pie.radius;
|
||||||
|
|
||||||
|
for (var i = 0; i < slices.length; ++i)
|
||||||
|
{
|
||||||
|
var s = slices[i];
|
||||||
|
|
||||||
|
if(s.pie.show)
|
||||||
|
{
|
||||||
|
ctx.save();
|
||||||
|
ctx.beginPath();
|
||||||
|
ctx.moveTo(0,0); // Center of the pie
|
||||||
|
//ctx.scale(1, options.series.pie.tilt); // this actually seems to break everything when here.
|
||||||
|
ctx.arc(0,0,radius,s.startAngle,s.startAngle+s.angle,false);
|
||||||
|
ctx.closePath();
|
||||||
|
x = mouseX-centerLeft;
|
||||||
|
y = mouseY-centerTop;
|
||||||
|
if(ctx.isPointInPath)
|
||||||
|
{
|
||||||
|
if (ctx.isPointInPath(mouseX-centerLeft, mouseY-centerTop))
|
||||||
|
{
|
||||||
|
//alert('found slice!');
|
||||||
|
ctx.restore();
|
||||||
|
return {datapoint: [s.percent, s.data], dataIndex: 0, series: s, seriesIndex: i};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// excanvas for IE doesn;t support isPointInPath, this is a workaround.
|
||||||
|
p1X = (radius * Math.cos(s.startAngle));
|
||||||
|
p1Y = (radius * Math.sin(s.startAngle));
|
||||||
|
p2X = (radius * Math.cos(s.startAngle+(s.angle/4)));
|
||||||
|
p2Y = (radius * Math.sin(s.startAngle+(s.angle/4)));
|
||||||
|
p3X = (radius * Math.cos(s.startAngle+(s.angle/2)));
|
||||||
|
p3Y = (radius * Math.sin(s.startAngle+(s.angle/2)));
|
||||||
|
p4X = (radius * Math.cos(s.startAngle+(s.angle/1.5)));
|
||||||
|
p4Y = (radius * Math.sin(s.startAngle+(s.angle/1.5)));
|
||||||
|
p5X = (radius * Math.cos(s.startAngle+s.angle));
|
||||||
|
p5Y = (radius * Math.sin(s.startAngle+s.angle));
|
||||||
|
arrPoly = [[0,0],[p1X,p1Y],[p2X,p2Y],[p3X,p3Y],[p4X,p4Y],[p5X,p5Y]];
|
||||||
|
arrPoint = [x,y];
|
||||||
|
// TODO: perhaps do some mathmatical trickery here with the Y-coordinate to compensate for pie tilt?
|
||||||
|
if(isPointInPoly(arrPoly, arrPoint))
|
||||||
|
{
|
||||||
|
ctx.restore();
|
||||||
|
return {datapoint: [s.percent, s.data], dataIndex: 0, series: s, seriesIndex: i};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ctx.restore();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function onMouseMove(e)
|
||||||
|
{
|
||||||
|
triggerClickHoverEvent('plothover', e);
|
||||||
|
}
|
||||||
|
|
||||||
|
function onClick(e)
|
||||||
|
{
|
||||||
|
triggerClickHoverEvent('plotclick', e);
|
||||||
|
}
|
||||||
|
|
||||||
|
// trigger click or hover event (they send the same parameters so we share their code)
|
||||||
|
function triggerClickHoverEvent(eventname, e)
|
||||||
|
{
|
||||||
|
var offset = plot.offset(),
|
||||||
|
canvasX = parseInt(e.pageX - offset.left),
|
||||||
|
canvasY = parseInt(e.pageY - offset.top),
|
||||||
|
item = findNearbySlice(canvasX, canvasY);
|
||||||
|
|
||||||
|
if (options.grid.autoHighlight)
|
||||||
|
{
|
||||||
|
// clear auto-highlights
|
||||||
|
for (var i = 0; i < highlights.length; ++i)
|
||||||
|
{
|
||||||
|
var h = highlights[i];
|
||||||
|
if (h.auto == eventname && !(item && h.series == item.series))
|
||||||
|
unhighlight(h.series);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// highlight the slice
|
||||||
|
if (item)
|
||||||
|
highlight(item.series, eventname);
|
||||||
|
|
||||||
|
// trigger any hover bind events
|
||||||
|
var pos = { pageX: e.pageX, pageY: e.pageY };
|
||||||
|
target.trigger(eventname, [ pos, item ]);
|
||||||
|
}
|
||||||
|
|
||||||
|
function highlight(s, auto)
|
||||||
|
{
|
||||||
|
if (typeof s == "number")
|
||||||
|
s = series[s];
|
||||||
|
|
||||||
|
var i = indexOfHighlight(s);
|
||||||
|
if (i == -1)
|
||||||
|
{
|
||||||
|
highlights.push({ series: s, auto: auto });
|
||||||
|
plot.triggerRedrawOverlay();
|
||||||
|
}
|
||||||
|
else if (!auto)
|
||||||
|
highlights[i].auto = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function unhighlight(s)
|
||||||
|
{
|
||||||
|
if (s == null)
|
||||||
|
{
|
||||||
|
highlights = [];
|
||||||
|
plot.triggerRedrawOverlay();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof s == "number")
|
||||||
|
s = series[s];
|
||||||
|
|
||||||
|
var i = indexOfHighlight(s);
|
||||||
|
if (i != -1)
|
||||||
|
{
|
||||||
|
highlights.splice(i, 1);
|
||||||
|
plot.triggerRedrawOverlay();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function indexOfHighlight(s)
|
||||||
|
{
|
||||||
|
for (var i = 0; i < highlights.length; ++i)
|
||||||
|
{
|
||||||
|
var h = highlights[i];
|
||||||
|
if (h.series == s)
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
function drawOverlay(plot, octx)
|
||||||
|
{
|
||||||
|
//alert(options.series.pie.radius);
|
||||||
|
var options = plot.getOptions();
|
||||||
|
//alert(options.series.pie.radius);
|
||||||
|
|
||||||
|
var radius = options.series.pie.radius > 1 ? options.series.pie.radius : maxRadius * options.series.pie.radius;
|
||||||
|
|
||||||
|
octx.save();
|
||||||
|
octx.translate(centerLeft, centerTop);
|
||||||
|
octx.scale(1, options.series.pie.tilt);
|
||||||
|
|
||||||
|
for (i = 0; i < highlights.length; ++i)
|
||||||
|
drawHighlight(highlights[i].series);
|
||||||
|
|
||||||
|
drawDonutHole(octx);
|
||||||
|
|
||||||
|
octx.restore();
|
||||||
|
|
||||||
|
function drawHighlight(series)
|
||||||
|
{
|
||||||
|
if (series.angle < 0) return;
|
||||||
|
|
||||||
|
//octx.fillStyle = parseColor(options.series.pie.highlight.color).scale(null, null, null, options.series.pie.highlight.opacity).toString();
|
||||||
|
octx.fillStyle = "rgba(255, 255, 255, "+options.series.pie.highlight.opacity+")"; // this is temporary until we have access to parseColor
|
||||||
|
|
||||||
|
octx.beginPath();
|
||||||
|
if (Math.abs(series.angle - Math.PI*2) > 0.000000001)
|
||||||
|
octx.moveTo(0,0); // Center of the pie
|
||||||
|
octx.arc(0,0,radius,series.startAngle,series.startAngle+series.angle,false);
|
||||||
|
octx.closePath();
|
||||||
|
octx.fill();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
} // end init (plugin body)
|
||||||
|
|
||||||
|
// define pie specific options and their default values
|
||||||
|
var options = {
|
||||||
|
series: {
|
||||||
|
pie: {
|
||||||
|
show: false,
|
||||||
|
radius: 'auto', // actual radius of the visible pie (based on full calculated radius if <=1, or hard pixel value)
|
||||||
|
innerRadius:0, /* for donut */
|
||||||
|
startAngle: 3/2,
|
||||||
|
tilt: 1,
|
||||||
|
offset: {
|
||||||
|
top: 0,
|
||||||
|
left: 'auto'
|
||||||
|
},
|
||||||
|
stroke: {
|
||||||
|
color: '#FFF',
|
||||||
|
width: 1
|
||||||
|
},
|
||||||
|
label: {
|
||||||
|
show: 'auto',
|
||||||
|
formatter: function(label, slice){
|
||||||
|
return '<div style="font-size:x-small;text-align:center;padding:2px;color:'+slice.color+';">'+label+'<br/>'+Math.round(slice.percent)+'%</div>';
|
||||||
|
}, // formatter function
|
||||||
|
radius: 1, // radius at which to place the labels (based on full calculated radius if <=1, or hard pixel value)
|
||||||
|
background: {
|
||||||
|
color: null,
|
||||||
|
opacity: 0
|
||||||
|
},
|
||||||
|
threshold: 0 // percentage at which to hide the label (i.e. the slice is too narrow)
|
||||||
|
},
|
||||||
|
combine: {
|
||||||
|
threshold: -1, // percentage at which to combine little slices into one larger slice
|
||||||
|
color: null, // color to give the new slice (auto-generated if null)
|
||||||
|
label: 'Other' // label to give the new slice
|
||||||
|
},
|
||||||
|
highlight: {
|
||||||
|
//color: '#FFF', // will add this functionality once parseColor is available
|
||||||
|
opacity: 0.5
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
$.plot.plugins.push({
|
||||||
|
init: init,
|
||||||
|
options: options,
|
||||||
|
name: "pie",
|
||||||
|
version: "1.0"
|
||||||
|
});
|
||||||
|
})(jQuery);
|
|
@ -0,0 +1,60 @@
|
||||||
|
/*
|
||||||
|
Flot plugin for automatically redrawing plots when the placeholder
|
||||||
|
size changes, e.g. on window resizes.
|
||||||
|
|
||||||
|
It works by listening for changes on the placeholder div (through the
|
||||||
|
jQuery resize event plugin) - if the size changes, it will redraw the
|
||||||
|
plot.
|
||||||
|
|
||||||
|
There are no options. If you need to disable the plugin for some
|
||||||
|
plots, you can just fix the size of their placeholders.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/* Inline dependency:
|
||||||
|
* jQuery resize event - v1.1 - 3/14/2010
|
||||||
|
* http://benalman.com/projects/jquery-resize-plugin/
|
||||||
|
*
|
||||||
|
* Copyright (c) 2010 "Cowboy" Ben Alman
|
||||||
|
* Dual licensed under the MIT and GPL licenses.
|
||||||
|
* http://benalman.com/about/license/
|
||||||
|
*/
|
||||||
|
(function($,h,c){var a=$([]),e=$.resize=$.extend($.resize,{}),i,k="setTimeout",j="resize",d=j+"-special-event",b="delay",f="throttleWindow";e[b]=250;e[f]=true;$.event.special[j]={setup:function(){if(!e[f]&&this[k]){return false}var l=$(this);a=a.add(l);$.data(this,d,{w:l.width(),h:l.height()});if(a.length===1){g()}},teardown:function(){if(!e[f]&&this[k]){return false}var l=$(this);a=a.not(l);l.removeData(d);if(!a.length){clearTimeout(i)}},add:function(l){if(!e[f]&&this[k]){return false}var n;function m(s,o,p){var q=$(this),r=$.data(this,d);r.w=o!==c?o:q.width();r.h=p!==c?p:q.height();n.apply(this,arguments)}if($.isFunction(l)){n=l;return m}else{n=l.handler;l.handler=m}}};function g(){i=h[k](function(){a.each(function(){var n=$(this),m=n.width(),l=n.height(),o=$.data(this,d);if(m!==o.w||l!==o.h){n.trigger(j,[o.w=m,o.h=l])}});g()},e[b])}})(jQuery,this);
|
||||||
|
|
||||||
|
|
||||||
|
(function ($) {
|
||||||
|
var options = { }; // no options
|
||||||
|
|
||||||
|
function init(plot) {
|
||||||
|
function onResize() {
|
||||||
|
var placeholder = plot.getPlaceholder();
|
||||||
|
|
||||||
|
// somebody might have hidden us and we can't plot
|
||||||
|
// when we don't have the dimensions
|
||||||
|
if (placeholder.width() == 0 || placeholder.height() == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
plot.resize();
|
||||||
|
plot.setupGrid();
|
||||||
|
plot.draw();
|
||||||
|
}
|
||||||
|
|
||||||
|
function bindEvents(plot, eventHolder) {
|
||||||
|
plot.getPlaceholder().resize(onResize);
|
||||||
|
}
|
||||||
|
|
||||||
|
function shutdown(plot, eventHolder) {
|
||||||
|
plot.getPlaceholder().unbind("resize", onResize);
|
||||||
|
}
|
||||||
|
|
||||||
|
plot.hooks.bindEvents.push(bindEvents);
|
||||||
|
plot.hooks.shutdown.push(shutdown);
|
||||||
|
}
|
||||||
|
|
||||||
|
$.plot.plugins.push({
|
||||||
|
init: init,
|
||||||
|
options: options,
|
||||||
|
name: 'resize',
|
||||||
|
version: '1.0'
|
||||||
|
});
|
||||||
|
})(jQuery);
|
|
@ -0,0 +1,344 @@
|
||||||
|
/*
|
||||||
|
Flot plugin for selecting regions.
|
||||||
|
|
||||||
|
The plugin defines the following options:
|
||||||
|
|
||||||
|
selection: {
|
||||||
|
mode: null or "x" or "y" or "xy",
|
||||||
|
color: color
|
||||||
|
}
|
||||||
|
|
||||||
|
Selection support is enabled by setting the mode to one of "x", "y" or
|
||||||
|
"xy". In "x" mode, the user will only be able to specify the x range,
|
||||||
|
similarly for "y" mode. For "xy", the selection becomes a rectangle
|
||||||
|
where both ranges can be specified. "color" is color of the selection
|
||||||
|
(if you need to change the color later on, you can get to it with
|
||||||
|
plot.getOptions().selection.color).
|
||||||
|
|
||||||
|
When selection support is enabled, a "plotselected" event will be
|
||||||
|
emitted on the DOM element you passed into the plot function. The
|
||||||
|
event handler gets a parameter with the ranges selected on the axes,
|
||||||
|
like this:
|
||||||
|
|
||||||
|
placeholder.bind("plotselected", function(event, ranges) {
|
||||||
|
alert("You selected " + ranges.xaxis.from + " to " + ranges.xaxis.to)
|
||||||
|
// similar for yaxis - with multiple axes, the extra ones are in
|
||||||
|
// x2axis, x3axis, ...
|
||||||
|
});
|
||||||
|
|
||||||
|
The "plotselected" event is only fired when the user has finished
|
||||||
|
making the selection. A "plotselecting" event is fired during the
|
||||||
|
process with the same parameters as the "plotselected" event, in case
|
||||||
|
you want to know what's happening while it's happening,
|
||||||
|
|
||||||
|
A "plotunselected" event with no arguments is emitted when the user
|
||||||
|
clicks the mouse to remove the selection.
|
||||||
|
|
||||||
|
The plugin allso adds the following methods to the plot object:
|
||||||
|
|
||||||
|
- setSelection(ranges, preventEvent)
|
||||||
|
|
||||||
|
Set the selection rectangle. The passed in ranges is on the same
|
||||||
|
form as returned in the "plotselected" event. If the selection mode
|
||||||
|
is "x", you should put in either an xaxis range, if the mode is "y"
|
||||||
|
you need to put in an yaxis range and both xaxis and yaxis if the
|
||||||
|
selection mode is "xy", like this:
|
||||||
|
|
||||||
|
setSelection({ xaxis: { from: 0, to: 10 }, yaxis: { from: 40, to: 60 } });
|
||||||
|
|
||||||
|
setSelection will trigger the "plotselected" event when called. If
|
||||||
|
you don't want that to happen, e.g. if you're inside a
|
||||||
|
"plotselected" handler, pass true as the second parameter. If you
|
||||||
|
are using multiple axes, you can specify the ranges on any of those,
|
||||||
|
e.g. as x2axis/x3axis/... instead of xaxis, the plugin picks the
|
||||||
|
first one it sees.
|
||||||
|
|
||||||
|
- clearSelection(preventEvent)
|
||||||
|
|
||||||
|
Clear the selection rectangle. Pass in true to avoid getting a
|
||||||
|
"plotunselected" event.
|
||||||
|
|
||||||
|
- getSelection()
|
||||||
|
|
||||||
|
Returns the current selection in the same format as the
|
||||||
|
"plotselected" event. If there's currently no selection, the
|
||||||
|
function returns null.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
(function ($) {
|
||||||
|
function init(plot) {
|
||||||
|
var selection = {
|
||||||
|
first: { x: -1, y: -1}, second: { x: -1, y: -1},
|
||||||
|
show: false,
|
||||||
|
active: false
|
||||||
|
};
|
||||||
|
|
||||||
|
// FIXME: The drag handling implemented here should be
|
||||||
|
// abstracted out, there's some similar code from a library in
|
||||||
|
// the navigation plugin, this should be massaged a bit to fit
|
||||||
|
// the Flot cases here better and reused. Doing this would
|
||||||
|
// make this plugin much slimmer.
|
||||||
|
var savedhandlers = {};
|
||||||
|
|
||||||
|
var mouseUpHandler = null;
|
||||||
|
|
||||||
|
function onMouseMove(e) {
|
||||||
|
if (selection.active) {
|
||||||
|
updateSelection(e);
|
||||||
|
|
||||||
|
plot.getPlaceholder().trigger("plotselecting", [ getSelection() ]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function onMouseDown(e) {
|
||||||
|
if (e.which != 1) // only accept left-click
|
||||||
|
return;
|
||||||
|
|
||||||
|
// cancel out any text selections
|
||||||
|
document.body.focus();
|
||||||
|
|
||||||
|
// prevent text selection and drag in old-school browsers
|
||||||
|
if (document.onselectstart !== undefined && savedhandlers.onselectstart == null) {
|
||||||
|
savedhandlers.onselectstart = document.onselectstart;
|
||||||
|
document.onselectstart = function () { return false; };
|
||||||
|
}
|
||||||
|
if (document.ondrag !== undefined && savedhandlers.ondrag == null) {
|
||||||
|
savedhandlers.ondrag = document.ondrag;
|
||||||
|
document.ondrag = function () { return false; };
|
||||||
|
}
|
||||||
|
|
||||||
|
setSelectionPos(selection.first, e);
|
||||||
|
|
||||||
|
selection.active = true;
|
||||||
|
|
||||||
|
// this is a bit silly, but we have to use a closure to be
|
||||||
|
// able to whack the same handler again
|
||||||
|
mouseUpHandler = function (e) { onMouseUp(e); };
|
||||||
|
|
||||||
|
$(document).one("mouseup", mouseUpHandler);
|
||||||
|
}
|
||||||
|
|
||||||
|
function onMouseUp(e) {
|
||||||
|
mouseUpHandler = null;
|
||||||
|
|
||||||
|
// revert drag stuff for old-school browsers
|
||||||
|
if (document.onselectstart !== undefined)
|
||||||
|
document.onselectstart = savedhandlers.onselectstart;
|
||||||
|
if (document.ondrag !== undefined)
|
||||||
|
document.ondrag = savedhandlers.ondrag;
|
||||||
|
|
||||||
|
// no more dragging
|
||||||
|
selection.active = false;
|
||||||
|
updateSelection(e);
|
||||||
|
|
||||||
|
if (selectionIsSane())
|
||||||
|
triggerSelectedEvent();
|
||||||
|
else {
|
||||||
|
// this counts as a clear
|
||||||
|
plot.getPlaceholder().trigger("plotunselected", [ ]);
|
||||||
|
plot.getPlaceholder().trigger("plotselecting", [ null ]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getSelection() {
|
||||||
|
if (!selectionIsSane())
|
||||||
|
return null;
|
||||||
|
|
||||||
|
var r = {}, c1 = selection.first, c2 = selection.second;
|
||||||
|
$.each(plot.getAxes(), function (name, axis) {
|
||||||
|
if (axis.used) {
|
||||||
|
var p1 = axis.c2p(c1[axis.direction]), p2 = axis.c2p(c2[axis.direction]);
|
||||||
|
r[name] = { from: Math.min(p1, p2), to: Math.max(p1, p2) };
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
function triggerSelectedEvent() {
|
||||||
|
var r = getSelection();
|
||||||
|
|
||||||
|
plot.getPlaceholder().trigger("plotselected", [ r ]);
|
||||||
|
|
||||||
|
// backwards-compat stuff, to be removed in future
|
||||||
|
if (r.xaxis && r.yaxis)
|
||||||
|
plot.getPlaceholder().trigger("selected", [ { x1: r.xaxis.from, y1: r.yaxis.from, x2: r.xaxis.to, y2: r.yaxis.to } ]);
|
||||||
|
}
|
||||||
|
|
||||||
|
function clamp(min, value, max) {
|
||||||
|
return value < min ? min: (value > max ? max: value);
|
||||||
|
}
|
||||||
|
|
||||||
|
function setSelectionPos(pos, e) {
|
||||||
|
var o = plot.getOptions();
|
||||||
|
var offset = plot.getPlaceholder().offset();
|
||||||
|
var plotOffset = plot.getPlotOffset();
|
||||||
|
pos.x = clamp(0, e.pageX - offset.left - plotOffset.left, plot.width());
|
||||||
|
pos.y = clamp(0, e.pageY - offset.top - plotOffset.top, plot.height());
|
||||||
|
|
||||||
|
if (o.selection.mode == "y")
|
||||||
|
pos.x = pos == selection.first ? 0 : plot.width();
|
||||||
|
|
||||||
|
if (o.selection.mode == "x")
|
||||||
|
pos.y = pos == selection.first ? 0 : plot.height();
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateSelection(pos) {
|
||||||
|
if (pos.pageX == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
setSelectionPos(selection.second, pos);
|
||||||
|
if (selectionIsSane()) {
|
||||||
|
selection.show = true;
|
||||||
|
plot.triggerRedrawOverlay();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
clearSelection(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
function clearSelection(preventEvent) {
|
||||||
|
if (selection.show) {
|
||||||
|
selection.show = false;
|
||||||
|
plot.triggerRedrawOverlay();
|
||||||
|
if (!preventEvent)
|
||||||
|
plot.getPlaceholder().trigger("plotunselected", [ ]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// function taken from markings support in Flot
|
||||||
|
function extractRange(ranges, coord) {
|
||||||
|
var axis, from, to, key, axes = plot.getAxes();
|
||||||
|
|
||||||
|
for (var k in axes) {
|
||||||
|
axis = axes[k];
|
||||||
|
if (axis.direction == coord) {
|
||||||
|
key = coord + axis.n + "axis";
|
||||||
|
if (!ranges[key] && axis.n == 1)
|
||||||
|
key = coord + "axis"; // support x1axis as xaxis
|
||||||
|
if (ranges[key]) {
|
||||||
|
from = ranges[key].from;
|
||||||
|
to = ranges[key].to;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// backwards-compat stuff - to be removed in future
|
||||||
|
if (!ranges[key]) {
|
||||||
|
axis = coord == "x" ? plot.getXAxes()[0] : plot.getYAxes()[0];
|
||||||
|
from = ranges[coord + "1"];
|
||||||
|
to = ranges[coord + "2"];
|
||||||
|
}
|
||||||
|
|
||||||
|
// auto-reverse as an added bonus
|
||||||
|
if (from != null && to != null && from > to) {
|
||||||
|
var tmp = from;
|
||||||
|
from = to;
|
||||||
|
to = tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
return { from: from, to: to, axis: axis };
|
||||||
|
}
|
||||||
|
|
||||||
|
function setSelection(ranges, preventEvent) {
|
||||||
|
var axis, range, o = plot.getOptions();
|
||||||
|
|
||||||
|
if (o.selection.mode == "y") {
|
||||||
|
selection.first.x = 0;
|
||||||
|
selection.second.x = plot.width();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
range = extractRange(ranges, "x");
|
||||||
|
|
||||||
|
selection.first.x = range.axis.p2c(range.from);
|
||||||
|
selection.second.x = range.axis.p2c(range.to);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (o.selection.mode == "x") {
|
||||||
|
selection.first.y = 0;
|
||||||
|
selection.second.y = plot.height();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
range = extractRange(ranges, "y");
|
||||||
|
|
||||||
|
selection.first.y = range.axis.p2c(range.from);
|
||||||
|
selection.second.y = range.axis.p2c(range.to);
|
||||||
|
}
|
||||||
|
|
||||||
|
selection.show = true;
|
||||||
|
plot.triggerRedrawOverlay();
|
||||||
|
if (!preventEvent && selectionIsSane())
|
||||||
|
triggerSelectedEvent();
|
||||||
|
}
|
||||||
|
|
||||||
|
function selectionIsSane() {
|
||||||
|
var minSize = 5;
|
||||||
|
return Math.abs(selection.second.x - selection.first.x) >= minSize &&
|
||||||
|
Math.abs(selection.second.y - selection.first.y) >= minSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
plot.clearSelection = clearSelection;
|
||||||
|
plot.setSelection = setSelection;
|
||||||
|
plot.getSelection = getSelection;
|
||||||
|
|
||||||
|
plot.hooks.bindEvents.push(function(plot, eventHolder) {
|
||||||
|
var o = plot.getOptions();
|
||||||
|
if (o.selection.mode != null) {
|
||||||
|
eventHolder.mousemove(onMouseMove);
|
||||||
|
eventHolder.mousedown(onMouseDown);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
plot.hooks.drawOverlay.push(function (plot, ctx) {
|
||||||
|
// draw selection
|
||||||
|
if (selection.show && selectionIsSane()) {
|
||||||
|
var plotOffset = plot.getPlotOffset();
|
||||||
|
var o = plot.getOptions();
|
||||||
|
|
||||||
|
ctx.save();
|
||||||
|
ctx.translate(plotOffset.left, plotOffset.top);
|
||||||
|
|
||||||
|
var c = $.color.parse(o.selection.color);
|
||||||
|
|
||||||
|
ctx.strokeStyle = c.scale('a', 0.8).toString();
|
||||||
|
ctx.lineWidth = 1;
|
||||||
|
ctx.lineJoin = "round";
|
||||||
|
ctx.fillStyle = c.scale('a', 0.4).toString();
|
||||||
|
|
||||||
|
var x = Math.min(selection.first.x, selection.second.x),
|
||||||
|
y = Math.min(selection.first.y, selection.second.y),
|
||||||
|
w = Math.abs(selection.second.x - selection.first.x),
|
||||||
|
h = Math.abs(selection.second.y - selection.first.y);
|
||||||
|
|
||||||
|
ctx.fillRect(x, y, w, h);
|
||||||
|
ctx.strokeRect(x, y, w, h);
|
||||||
|
|
||||||
|
ctx.restore();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
plot.hooks.shutdown.push(function (plot, eventHolder) {
|
||||||
|
eventHolder.unbind("mousemove", onMouseMove);
|
||||||
|
eventHolder.unbind("mousedown", onMouseDown);
|
||||||
|
|
||||||
|
if (mouseUpHandler)
|
||||||
|
$(document).unbind("mouseup", mouseUpHandler);
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$.plot.plugins.push({
|
||||||
|
init: init,
|
||||||
|
options: {
|
||||||
|
selection: {
|
||||||
|
mode: null, // one of null, "x", "y" or "xy"
|
||||||
|
color: "#e8cfac"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
name: 'selection',
|
||||||
|
version: '1.1'
|
||||||
|
});
|
||||||
|
})(jQuery);
|
|
@ -0,0 +1,184 @@
|
||||||
|
/*
|
||||||
|
Flot plugin for stacking data sets, i.e. putting them on top of each
|
||||||
|
other, for accumulative graphs.
|
||||||
|
|
||||||
|
The plugin assumes the data is sorted on x (or y if stacking
|
||||||
|
horizontally). For line charts, it is assumed that if a line has an
|
||||||
|
undefined gap (from a null point), then the line above it should have
|
||||||
|
the same gap - insert zeros instead of "null" if you want another
|
||||||
|
behaviour. This also holds for the start and end of the chart. Note
|
||||||
|
that stacking a mix of positive and negative values in most instances
|
||||||
|
doesn't make sense (so it looks weird).
|
||||||
|
|
||||||
|
Two or more series are stacked when their "stack" attribute is set to
|
||||||
|
the same key (which can be any number or string or just "true"). To
|
||||||
|
specify the default stack, you can set
|
||||||
|
|
||||||
|
series: {
|
||||||
|
stack: null or true or key (number/string)
|
||||||
|
}
|
||||||
|
|
||||||
|
or specify it for a specific series
|
||||||
|
|
||||||
|
$.plot($("#placeholder"), [{ data: [ ... ], stack: true }])
|
||||||
|
|
||||||
|
The stacking order is determined by the order of the data series in
|
||||||
|
the array (later series end up on top of the previous).
|
||||||
|
|
||||||
|
Internally, the plugin modifies the datapoints in each series, adding
|
||||||
|
an offset to the y value. For line series, extra data points are
|
||||||
|
inserted through interpolation. If there's a second y value, it's also
|
||||||
|
adjusted (e.g for bar charts or filled areas).
|
||||||
|
*/
|
||||||
|
|
||||||
|
(function ($) {
|
||||||
|
var options = {
|
||||||
|
series: { stack: null } // or number/string
|
||||||
|
};
|
||||||
|
|
||||||
|
function init(plot) {
|
||||||
|
function findMatchingSeries(s, allseries) {
|
||||||
|
var res = null
|
||||||
|
for (var i = 0; i < allseries.length; ++i) {
|
||||||
|
if (s == allseries[i])
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (allseries[i].stack == s.stack)
|
||||||
|
res = allseries[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
function stackData(plot, s, datapoints) {
|
||||||
|
if (s.stack == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var other = findMatchingSeries(s, plot.getData());
|
||||||
|
if (!other)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var ps = datapoints.pointsize,
|
||||||
|
points = datapoints.points,
|
||||||
|
otherps = other.datapoints.pointsize,
|
||||||
|
otherpoints = other.datapoints.points,
|
||||||
|
newpoints = [],
|
||||||
|
px, py, intery, qx, qy, bottom,
|
||||||
|
withlines = s.lines.show,
|
||||||
|
horizontal = s.bars.horizontal,
|
||||||
|
withbottom = ps > 2 && (horizontal ? datapoints.format[2].x : datapoints.format[2].y),
|
||||||
|
withsteps = withlines && s.lines.steps,
|
||||||
|
fromgap = true,
|
||||||
|
keyOffset = horizontal ? 1 : 0,
|
||||||
|
accumulateOffset = horizontal ? 0 : 1,
|
||||||
|
i = 0, j = 0, l;
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
if (i >= points.length)
|
||||||
|
break;
|
||||||
|
|
||||||
|
l = newpoints.length;
|
||||||
|
|
||||||
|
if (points[i] == null) {
|
||||||
|
// copy gaps
|
||||||
|
for (m = 0; m < ps; ++m)
|
||||||
|
newpoints.push(points[i + m]);
|
||||||
|
i += ps;
|
||||||
|
}
|
||||||
|
else if (j >= otherpoints.length) {
|
||||||
|
// for lines, we can't use the rest of the points
|
||||||
|
if (!withlines) {
|
||||||
|
for (m = 0; m < ps; ++m)
|
||||||
|
newpoints.push(points[i + m]);
|
||||||
|
}
|
||||||
|
i += ps;
|
||||||
|
}
|
||||||
|
else if (otherpoints[j] == null) {
|
||||||
|
// oops, got a gap
|
||||||
|
for (m = 0; m < ps; ++m)
|
||||||
|
newpoints.push(null);
|
||||||
|
fromgap = true;
|
||||||
|
j += otherps;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// cases where we actually got two points
|
||||||
|
px = points[i + keyOffset];
|
||||||
|
py = points[i + accumulateOffset];
|
||||||
|
qx = otherpoints[j + keyOffset];
|
||||||
|
qy = otherpoints[j + accumulateOffset];
|
||||||
|
bottom = 0;
|
||||||
|
|
||||||
|
if (px == qx) {
|
||||||
|
for (m = 0; m < ps; ++m)
|
||||||
|
newpoints.push(points[i + m]);
|
||||||
|
|
||||||
|
newpoints[l + accumulateOffset] += qy;
|
||||||
|
bottom = qy;
|
||||||
|
|
||||||
|
i += ps;
|
||||||
|
j += otherps;
|
||||||
|
}
|
||||||
|
else if (px > qx) {
|
||||||
|
// we got past point below, might need to
|
||||||
|
// insert interpolated extra point
|
||||||
|
if (withlines && i > 0 && points[i - ps] != null) {
|
||||||
|
intery = py + (points[i - ps + accumulateOffset] - py) * (qx - px) / (points[i - ps + keyOffset] - px);
|
||||||
|
newpoints.push(qx);
|
||||||
|
newpoints.push(intery + qy);
|
||||||
|
for (m = 2; m < ps; ++m)
|
||||||
|
newpoints.push(points[i + m]);
|
||||||
|
bottom = qy;
|
||||||
|
}
|
||||||
|
|
||||||
|
j += otherps;
|
||||||
|
}
|
||||||
|
else { // px < qx
|
||||||
|
if (fromgap && withlines) {
|
||||||
|
// if we come from a gap, we just skip this point
|
||||||
|
i += ps;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (m = 0; m < ps; ++m)
|
||||||
|
newpoints.push(points[i + m]);
|
||||||
|
|
||||||
|
// we might be able to interpolate a point below,
|
||||||
|
// this can give us a better y
|
||||||
|
if (withlines && j > 0 && otherpoints[j - otherps] != null)
|
||||||
|
bottom = qy + (otherpoints[j - otherps + accumulateOffset] - qy) * (px - qx) / (otherpoints[j - otherps + keyOffset] - qx);
|
||||||
|
|
||||||
|
newpoints[l + accumulateOffset] += bottom;
|
||||||
|
|
||||||
|
i += ps;
|
||||||
|
}
|
||||||
|
|
||||||
|
fromgap = false;
|
||||||
|
|
||||||
|
if (l != newpoints.length && withbottom)
|
||||||
|
newpoints[l + 2] += bottom;
|
||||||
|
}
|
||||||
|
|
||||||
|
// maintain the line steps invariant
|
||||||
|
if (withsteps && l != newpoints.length && l > 0
|
||||||
|
&& newpoints[l] != null
|
||||||
|
&& newpoints[l] != newpoints[l - ps]
|
||||||
|
&& newpoints[l + 1] != newpoints[l - ps + 1]) {
|
||||||
|
for (m = 0; m < ps; ++m)
|
||||||
|
newpoints[l + ps + m] = newpoints[l + m];
|
||||||
|
newpoints[l + 1] = newpoints[l - ps + 1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
datapoints.points = newpoints;
|
||||||
|
}
|
||||||
|
|
||||||
|
plot.hooks.processDatapoints.push(stackData);
|
||||||
|
}
|
||||||
|
|
||||||
|
$.plot.plugins.push({
|
||||||
|
init: init,
|
||||||
|
options: options,
|
||||||
|
name: 'stack',
|
||||||
|
version: '1.2'
|
||||||
|
});
|
||||||
|
})(jQuery);
|
|
@ -0,0 +1,70 @@
|
||||||
|
/*
|
||||||
|
Flot plugin that adds some extra symbols for plotting points.
|
||||||
|
|
||||||
|
The symbols are accessed as strings through the standard symbol
|
||||||
|
choice:
|
||||||
|
|
||||||
|
series: {
|
||||||
|
points: {
|
||||||
|
symbol: "square" // or "diamond", "triangle", "cross"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
(function ($) {
|
||||||
|
function processRawData(plot, series, datapoints) {
|
||||||
|
// we normalize the area of each symbol so it is approximately the
|
||||||
|
// same as a circle of the given radius
|
||||||
|
|
||||||
|
var handlers = {
|
||||||
|
square: function (ctx, x, y, radius, shadow) {
|
||||||
|
// pi * r^2 = (2s)^2 => s = r * sqrt(pi)/2
|
||||||
|
var size = radius * Math.sqrt(Math.PI) / 2;
|
||||||
|
ctx.rect(x - size, y - size, size + size, size + size);
|
||||||
|
},
|
||||||
|
diamond: function (ctx, x, y, radius, shadow) {
|
||||||
|
// pi * r^2 = 2s^2 => s = r * sqrt(pi/2)
|
||||||
|
var size = radius * Math.sqrt(Math.PI / 2);
|
||||||
|
ctx.moveTo(x - size, y);
|
||||||
|
ctx.lineTo(x, y - size);
|
||||||
|
ctx.lineTo(x + size, y);
|
||||||
|
ctx.lineTo(x, y + size);
|
||||||
|
ctx.lineTo(x - size, y);
|
||||||
|
},
|
||||||
|
triangle: function (ctx, x, y, radius, shadow) {
|
||||||
|
// pi * r^2 = 1/2 * s^2 * sin (pi / 3) => s = r * sqrt(2 * pi / sin(pi / 3))
|
||||||
|
var size = radius * Math.sqrt(2 * Math.PI / Math.sin(Math.PI / 3));
|
||||||
|
var height = size * Math.sin(Math.PI / 3);
|
||||||
|
ctx.moveTo(x - size/2, y + height/2);
|
||||||
|
ctx.lineTo(x + size/2, y + height/2);
|
||||||
|
if (!shadow) {
|
||||||
|
ctx.lineTo(x, y - height/2);
|
||||||
|
ctx.lineTo(x - size/2, y + height/2);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
cross: function (ctx, x, y, radius, shadow) {
|
||||||
|
// pi * r^2 = (2s)^2 => s = r * sqrt(pi)/2
|
||||||
|
var size = radius * Math.sqrt(Math.PI) / 2;
|
||||||
|
ctx.moveTo(x - size, y - size);
|
||||||
|
ctx.lineTo(x + size, y + size);
|
||||||
|
ctx.moveTo(x - size, y + size);
|
||||||
|
ctx.lineTo(x + size, y - size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var s = series.points.symbol;
|
||||||
|
if (handlers[s])
|
||||||
|
series.points.symbol = handlers[s];
|
||||||
|
}
|
||||||
|
|
||||||
|
function init(plot) {
|
||||||
|
plot.hooks.processDatapoints.push(processRawData);
|
||||||
|
}
|
||||||
|
|
||||||
|
$.plot.plugins.push({
|
||||||
|
init: init,
|
||||||
|
name: 'symbols',
|
||||||
|
version: '1.0'
|
||||||
|
});
|
||||||
|
})(jQuery);
|
|
@ -0,0 +1,103 @@
|
||||||
|
/*
|
||||||
|
Flot plugin for thresholding data. Controlled through the option
|
||||||
|
"threshold" in either the global series options
|
||||||
|
|
||||||
|
series: {
|
||||||
|
threshold: {
|
||||||
|
below: number
|
||||||
|
color: colorspec
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
or in a specific series
|
||||||
|
|
||||||
|
$.plot($("#placeholder"), [{ data: [ ... ], threshold: { ... }}])
|
||||||
|
|
||||||
|
The data points below "below" are drawn with the specified color. This
|
||||||
|
makes it easy to mark points below 0, e.g. for budget data.
|
||||||
|
|
||||||
|
Internally, the plugin works by splitting the data into two series,
|
||||||
|
above and below the threshold. The extra series below the threshold
|
||||||
|
will have its label cleared and the special "originSeries" attribute
|
||||||
|
set to the original series. You may need to check for this in hover
|
||||||
|
events.
|
||||||
|
*/
|
||||||
|
|
||||||
|
(function ($) {
|
||||||
|
var options = {
|
||||||
|
series: { threshold: null } // or { below: number, color: color spec}
|
||||||
|
};
|
||||||
|
|
||||||
|
function init(plot) {
|
||||||
|
function thresholdData(plot, s, datapoints) {
|
||||||
|
if (!s.threshold)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var ps = datapoints.pointsize, i, x, y, p, prevp,
|
||||||
|
thresholded = $.extend({}, s); // note: shallow copy
|
||||||
|
|
||||||
|
thresholded.datapoints = { points: [], pointsize: ps };
|
||||||
|
thresholded.label = null;
|
||||||
|
thresholded.color = s.threshold.color;
|
||||||
|
thresholded.threshold = null;
|
||||||
|
thresholded.originSeries = s;
|
||||||
|
thresholded.data = [];
|
||||||
|
|
||||||
|
var below = s.threshold.below,
|
||||||
|
origpoints = datapoints.points,
|
||||||
|
addCrossingPoints = s.lines.show;
|
||||||
|
|
||||||
|
threspoints = [];
|
||||||
|
newpoints = [];
|
||||||
|
|
||||||
|
for (i = 0; i < origpoints.length; i += ps) {
|
||||||
|
x = origpoints[i]
|
||||||
|
y = origpoints[i + 1];
|
||||||
|
|
||||||
|
prevp = p;
|
||||||
|
if (y < below)
|
||||||
|
p = threspoints;
|
||||||
|
else
|
||||||
|
p = newpoints;
|
||||||
|
|
||||||
|
if (addCrossingPoints && prevp != p && x != null
|
||||||
|
&& i > 0 && origpoints[i - ps] != null) {
|
||||||
|
var interx = (x - origpoints[i - ps]) / (y - origpoints[i - ps + 1]) * (below - y) + x;
|
||||||
|
prevp.push(interx);
|
||||||
|
prevp.push(below);
|
||||||
|
for (m = 2; m < ps; ++m)
|
||||||
|
prevp.push(origpoints[i + m]);
|
||||||
|
|
||||||
|
p.push(null); // start new segment
|
||||||
|
p.push(null);
|
||||||
|
for (m = 2; m < ps; ++m)
|
||||||
|
p.push(origpoints[i + m]);
|
||||||
|
p.push(interx);
|
||||||
|
p.push(below);
|
||||||
|
for (m = 2; m < ps; ++m)
|
||||||
|
p.push(origpoints[i + m]);
|
||||||
|
}
|
||||||
|
|
||||||
|
p.push(x);
|
||||||
|
p.push(y);
|
||||||
|
}
|
||||||
|
|
||||||
|
datapoints.points = newpoints;
|
||||||
|
thresholded.datapoints.points = threspoints;
|
||||||
|
|
||||||
|
if (thresholded.datapoints.points.length > 0)
|
||||||
|
plot.getData().push(thresholded);
|
||||||
|
|
||||||
|
// FIXME: there are probably some edge cases left in bars
|
||||||
|
}
|
||||||
|
|
||||||
|
plot.hooks.processDatapoints.push(thresholdData);
|
||||||
|
}
|
||||||
|
|
||||||
|
$.plot.plugins.push({
|
||||||
|
init: init,
|
||||||
|
options: options,
|
||||||
|
name: 'threshold',
|
||||||
|
version: '1.0'
|
||||||
|
});
|
||||||
|
})(jQuery);
|
File diff suppressed because it is too large
Load Diff
|
@ -121,3 +121,6 @@ notify_webstream_data = 'notify-webstream-data/api_key/%%api_key%%/media_id/%%me
|
||||||
|
|
||||||
notify_liquidsoap_started = 'rabbitmq-do-push/api_key/%%api_key%%/format/json'
|
notify_liquidsoap_started = 'rabbitmq-do-push/api_key/%%api_key%%/format/json'
|
||||||
|
|
||||||
|
get_stream_parameters = 'get-stream-parameters/api_key/%%api_key%%/format/json'
|
||||||
|
|
||||||
|
push_stream_stats = 'push-stream-stats/api_key/%%api_key%%/format/json'
|
||||||
|
|
|
@ -388,5 +388,14 @@ class AirtimeApiClient(object):
|
||||||
Update the server with the latest metadata we've received from the
|
Update the server with the latest metadata we've received from the
|
||||||
external webstream
|
external webstream
|
||||||
"""
|
"""
|
||||||
self.logger.info( self.notify_webstream_data.req(
|
self.logger.info( self.services.notify_webstream_data.req(
|
||||||
_post_data={'data':data}, media_id=str(media_id)).retry(5))
|
_post_data={'data':data}, media_id=str(media_id)).retry(5))
|
||||||
|
|
||||||
|
def get_stream_parameters(self):
|
||||||
|
response = self.services.get_stream_parameters()
|
||||||
|
self.logger.debug(response)
|
||||||
|
return response
|
||||||
|
|
||||||
|
def push_stream_stats(self, data):
|
||||||
|
# TODO : users of this method should do their own error handling
|
||||||
|
response = self.services.push_stream_stats(_post_data={'data': json.dumps(data)})
|
||||||
|
|
|
@ -11,40 +11,40 @@ from configobj import ConfigObj
|
||||||
if os.geteuid() != 0:
|
if os.geteuid() != 0:
|
||||||
print "Please run this as root."
|
print "Please run this as root."
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
def get_current_script_dir():
|
def get_current_script_dir():
|
||||||
current_script_dir = os.path.realpath(__file__)
|
current_script_dir = os.path.realpath(__file__)
|
||||||
index = current_script_dir.rindex('/')
|
index = current_script_dir.rindex('/')
|
||||||
return current_script_dir[0:index]
|
return current_script_dir[0:index]
|
||||||
|
|
||||||
def copy_dir(src_dir, dest_dir):
|
def copy_dir(src_dir, dest_dir):
|
||||||
if (os.path.exists(dest_dir)) and (dest_dir != "/"):
|
if (os.path.exists(dest_dir)) and (dest_dir != "/"):
|
||||||
shutil.rmtree(dest_dir)
|
shutil.rmtree(dest_dir)
|
||||||
if not (os.path.exists(dest_dir)):
|
if not (os.path.exists(dest_dir)):
|
||||||
#print "Copying directory "+os.path.realpath(src_dir)+" to "+os.path.realpath(dest_dir)
|
#print "Copying directory "+os.path.realpath(src_dir)+" to "+os.path.realpath(dest_dir)
|
||||||
shutil.copytree(src_dir, dest_dir)
|
shutil.copytree(src_dir, dest_dir)
|
||||||
|
|
||||||
def create_dir(path):
|
def create_dir(path):
|
||||||
try:
|
try:
|
||||||
os.makedirs(path)
|
os.makedirs(path)
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def get_rand_string(length=10):
|
def get_rand_string(length=10):
|
||||||
return ''.join(random.choice(string.ascii_uppercase + string.digits) for x in range(length))
|
return ''.join(random.choice(string.ascii_uppercase + string.digits) for x in range(length))
|
||||||
|
|
||||||
def get_rand_string(length=10):
|
def get_rand_string(length=10):
|
||||||
return ''.join(random.choice(string.ascii_uppercase + string.digits) for x in range(length))
|
return ''.join(random.choice(string.ascii_uppercase + string.digits) for x in range(length))
|
||||||
|
|
||||||
PATH_INI_FILE = '/etc/airtime/pypo.cfg'
|
PATH_INI_FILE = '/etc/airtime/pypo.cfg'
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Absolute path this script is in
|
# Absolute path this script is in
|
||||||
current_script_dir = get_current_script_dir()
|
current_script_dir = get_current_script_dir()
|
||||||
|
|
||||||
if not os.path.exists(PATH_INI_FILE):
|
if not os.path.exists(PATH_INI_FILE):
|
||||||
shutil.copy('%s/../pypo.cfg'%current_script_dir, PATH_INI_FILE)
|
shutil.copy('%s/../pypo.cfg'%current_script_dir, PATH_INI_FILE)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
os.remove("/etc/airtime/liquidsoap.cfg")
|
os.remove("/etc/airtime/liquidsoap.cfg")
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
|
@ -59,7 +59,7 @@ try:
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
print 'Error loading config file: ', e
|
print 'Error loading config file: ', e
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
#copy monit files
|
#copy monit files
|
||||||
shutil.copy('%s/../../monit/monit-airtime-generic.cfg'%current_script_dir, '/etc/monit/conf.d/')
|
shutil.copy('%s/../../monit/monit-airtime-generic.cfg'%current_script_dir, '/etc/monit/conf.d/')
|
||||||
subprocess.call('sed -i "s/\$admin_pass/%s/g" /etc/monit/conf.d/monit-airtime-generic.cfg' % get_rand_string(), shell=True)
|
subprocess.call('sed -i "s/\$admin_pass/%s/g" /etc/monit/conf.d/monit-airtime-generic.cfg' % get_rand_string(), shell=True)
|
||||||
|
@ -80,13 +80,13 @@ try:
|
||||||
create_dir(config['cache_dir'])
|
create_dir(config['cache_dir'])
|
||||||
create_dir(config['file_dir'])
|
create_dir(config['file_dir'])
|
||||||
create_dir(config['tmp_dir'])
|
create_dir(config['tmp_dir'])
|
||||||
|
|
||||||
create_dir(config["base_recorded_files"])
|
create_dir(config["base_recorded_files"])
|
||||||
|
|
||||||
#copy files to bin dir
|
#copy files to bin dir
|
||||||
copy_dir("%s/.."%current_script_dir, config["bin_dir"]+"/bin/")
|
copy_dir("%s/.."%current_script_dir, config["bin_dir"]+"/bin/")
|
||||||
|
|
||||||
# delete /usr/lib/airtime/pypo/bin/liquidsoap_scripts/liquidsoap.cfg
|
# delete /usr/lib/airtime/pypo/bin/liquidsoap_scripts/liquidsoap.cfg
|
||||||
# as we don't use it anymore.(CC-2552)
|
# as we don't use it anymore.(CC-2552)
|
||||||
os.remove(config["bin_dir"]+"/bin/liquidsoap_scripts/liquidsoap.cfg")
|
os.remove(config["bin_dir"]+"/bin/liquidsoap_scripts/liquidsoap.cfg")
|
||||||
|
|
||||||
|
@ -102,7 +102,7 @@ try:
|
||||||
|
|
||||||
#copy log rotate script
|
#copy log rotate script
|
||||||
shutil.copy(config["bin_dir"]+"/bin/liquidsoap_scripts/airtime-liquidsoap.logrotate", "/etc/logrotate.d/airtime-liquidsoap")
|
shutil.copy(config["bin_dir"]+"/bin/liquidsoap_scripts/airtime-liquidsoap.logrotate", "/etc/logrotate.d/airtime-liquidsoap")
|
||||||
|
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
print e
|
print e
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,127 @@
|
||||||
|
from threading import Thread
|
||||||
|
import urllib2
|
||||||
|
import xml.dom.minidom
|
||||||
|
import base64
|
||||||
|
from datetime import datetime
|
||||||
|
import traceback
|
||||||
|
import logging
|
||||||
|
import time
|
||||||
|
|
||||||
|
from api_clients import api_client
|
||||||
|
|
||||||
|
class ListenerStat(Thread):
|
||||||
|
def __init__(self, logger=None):
|
||||||
|
Thread.__init__(self)
|
||||||
|
self.api_client = api_client.AirtimeApiClient()
|
||||||
|
if logger is None:
|
||||||
|
self.logger = logging.getLogger()
|
||||||
|
else:
|
||||||
|
self.logger = logger
|
||||||
|
|
||||||
|
def get_node_text(self, nodelist):
|
||||||
|
rc = []
|
||||||
|
for node in nodelist:
|
||||||
|
if node.nodeType == node.TEXT_NODE:
|
||||||
|
rc.append(node.data)
|
||||||
|
return ''.join(rc)
|
||||||
|
|
||||||
|
def get_stream_parameters(self):
|
||||||
|
#[{"user":"", "password":"", "url":"", "port":""},{},{}]
|
||||||
|
return self.api_client.get_stream_parameters()
|
||||||
|
|
||||||
|
|
||||||
|
def get_icecast_xml(self, ip):
|
||||||
|
encoded = base64.b64encode("%(admin_user)s:%(admin_password)s" % ip)
|
||||||
|
|
||||||
|
header = {"Authorization":"Basic %s" % encoded}
|
||||||
|
self.logger.debug(ip)
|
||||||
|
url = 'http://%(host)s:%(port)s/admin/stats.xml' % ip
|
||||||
|
self.logger.debug(url)
|
||||||
|
req = urllib2.Request(
|
||||||
|
#assuming that the icecast stats path is /admin/stats.xml
|
||||||
|
#need to fix this
|
||||||
|
url=url,
|
||||||
|
headers=header)
|
||||||
|
|
||||||
|
f = urllib2.urlopen(req)
|
||||||
|
document = f.read()
|
||||||
|
return document
|
||||||
|
|
||||||
|
|
||||||
|
def get_icecast_stats(self, ip):
|
||||||
|
document = self.get_icecast_xml(ip)
|
||||||
|
dom = xml.dom.minidom.parseString(document)
|
||||||
|
sources = dom.getElementsByTagName("source")
|
||||||
|
|
||||||
|
mount_stats = {}
|
||||||
|
for s in sources:
|
||||||
|
#drop the leading '/' character
|
||||||
|
mount_name = s.getAttribute("mount")[1:]
|
||||||
|
if mount_name == ip["mount"]:
|
||||||
|
timestamp = datetime.utcnow().strftime("%Y-%m-%d %H:%M:%S")
|
||||||
|
listeners = s.getElementsByTagName("listeners")
|
||||||
|
num_listeners = 0
|
||||||
|
if len(listeners):
|
||||||
|
num_listeners = self.get_node_text(listeners[0].childNodes)
|
||||||
|
|
||||||
|
mount_stats = {"timestamp":timestamp, \
|
||||||
|
"num_listeners": num_listeners, \
|
||||||
|
"mount_name": mount_name}
|
||||||
|
return mount_stats
|
||||||
|
|
||||||
|
def get_stream_stats(self, stream_parameters):
|
||||||
|
stats = []
|
||||||
|
|
||||||
|
#iterate over stream_parameters which is a list of dicts. Each dict
|
||||||
|
#represents one Airtime stream (currently this limit is 3).
|
||||||
|
#Note that there can be optimizations done, since if all three
|
||||||
|
#streams are the same server, we will still initiate 3 separate
|
||||||
|
#connections
|
||||||
|
for k, v in stream_parameters.items():
|
||||||
|
v["admin_user"] = "admin"
|
||||||
|
v["admin_password"] = "hackme"
|
||||||
|
if v["enable"] == 'true':
|
||||||
|
stats.append(self.get_icecast_stats(v))
|
||||||
|
#stats.append(get_shoutcast_stats(ip))
|
||||||
|
|
||||||
|
return stats
|
||||||
|
|
||||||
|
def push_stream_stats(self, stats):
|
||||||
|
self.api_client.push_stream_stats(stats)
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
#Wake up every 120 seconds and gather icecast statistics. Note that we
|
||||||
|
#are currently querying the server every 2 minutes for list of
|
||||||
|
#mountpoints as well. We could remove this query if we hooked into
|
||||||
|
#rabbitmq events, and listened for these changes instead.
|
||||||
|
while True:
|
||||||
|
try:
|
||||||
|
stream_parameters = self.get_stream_parameters()
|
||||||
|
|
||||||
|
stats = self.get_stream_stats(stream_parameters["stream_params"])
|
||||||
|
self.logger.debug(stats)
|
||||||
|
|
||||||
|
self.push_stream_stats(stats)
|
||||||
|
except Exception, e:
|
||||||
|
top = traceback.format_exc()
|
||||||
|
self.logger.error('Exception: %s', top)
|
||||||
|
|
||||||
|
time.sleep(120)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
# create logger
|
||||||
|
logger = logging.getLogger('std_out')
|
||||||
|
logger.setLevel(logging.DEBUG)
|
||||||
|
# create console handler and set level to debug
|
||||||
|
#ch = logging.StreamHandler()
|
||||||
|
#ch.setLevel(logging.DEBUG)
|
||||||
|
# create formatter
|
||||||
|
formatter = logging.Formatter('%(asctime)s - %(name)s - %(lineno)s - %(levelname)s - %(message)s')
|
||||||
|
# add formatter to ch
|
||||||
|
#ch.setFormatter(formatter)
|
||||||
|
# add ch to logger
|
||||||
|
#logger.addHandler(ch)
|
||||||
|
|
||||||
|
ls = ListenerStat(logger)
|
||||||
|
ls.run()
|
|
@ -21,6 +21,7 @@ from pypopush import PypoPush
|
||||||
from pypofetch import PypoFetch
|
from pypofetch import PypoFetch
|
||||||
from pypofile import PypoFile
|
from pypofile import PypoFile
|
||||||
from recorder import Recorder
|
from recorder import Recorder
|
||||||
|
from listenerstat import ListenerStat
|
||||||
from pypomessagehandler import PypoMessageHandler
|
from pypomessagehandler import PypoMessageHandler
|
||||||
|
|
||||||
from configobj import ConfigObj
|
from configobj import ConfigObj
|
||||||
|
@ -209,6 +210,10 @@ if __name__ == '__main__':
|
||||||
recorder.daemon = True
|
recorder.daemon = True
|
||||||
recorder.start()
|
recorder.start()
|
||||||
|
|
||||||
|
stat = ListenerStat()
|
||||||
|
stat.daemon = True
|
||||||
|
stat.start()
|
||||||
|
|
||||||
# all join() are commented out because we want to exit entire pypo
|
# all join() are commented out because we want to exit entire pypo
|
||||||
# if pypofetch is exiting
|
# if pypofetch is exiting
|
||||||
#pmh.join()
|
#pmh.join()
|
||||||
|
|
Loading…
Reference in New Issue