Author: coar
Date: Fri Mar 12 05:47:13 2010
New Revision: 922149

URL: http://svn.apache.org/viewvc?rev=922149&view=rev
Log:
Itty bitty steps..

Added:
    labs/pulse/web-reports/pulse-classes.php
      - copied, changed from r920982, 
labs/pulse/web-reports/liststats-classes.php
Removed:
    labs/pulse/web-reports/liststats-classes.php

Copied: labs/pulse/web-reports/pulse-classes.php (from r920982, 
labs/pulse/web-reports/liststats-classes.php)
URL: 
http://svn.apache.org/viewvc/labs/pulse/web-reports/pulse-classes.php?p2=labs/pulse/web-reports/pulse-classes.php&p1=labs/pulse/web-reports/liststats-classes.php&r1=920982&r2=922149&rev=922149&view=diff
==============================================================================
--- labs/pulse/web-reports/liststats-classes.php (original)
+++ labs/pulse/web-reports/pulse-classes.php Fri Mar 12 05:47:13 2010
@@ -27,7 +27,7 @@ class lsdb__baseclass {
     /*
      * Self-explanatory, I hope.
      */
-    function isNew($newval=null) {
+    public function isNew($newval=null) {
         $oldval = ($this->_new ? true : false);
         if (isset($newval)) {
             $this->_new = ($newval ? true : false);
@@ -35,7 +35,7 @@ class lsdb__baseclass {
         return $oldval;
     }
 
-    function isDirty($newval=null) {
+    public function isDirty($newval=null) {
         $oldval = ($this->_dirty ? true : false);
         if (isset($newval)) {
             $this->_dirty = ($newval ? true : false);
@@ -67,6 +67,23 @@ class lsdb__baseclass {
     }
 
     /*
+     * Catchall for fetching properties.
+     */
+    public function __get($pname) {
+        $pname = $this->nkey($pname);
+        if (isset($this->_record[$pname])) {
+            return $this->_record[$pname];
+        }
+        else if (isset($this->_custom[$pname])) {
+            return $this->_custom[$pname];
+        }
+        else if (isset($this->$pname)) {
+            return $this->$pname;
+        }
+        return null;
+    }
+
+    /*
      * Set a cell value for the object.
      */
     function set($fname, $val=null) {
@@ -94,6 +111,23 @@ class lsdb__baseclass {
     }
 
     /*
+     * Catchall for fetching properties.
+     */
+    public function __set($pname, $pval) {
+        $pname = $this->nkey($pname);
+        if (isset($this->_record[$pname])) {
+            $this->_record[$pname] = $pval;
+        }
+        else if (isset($this->_custom[$pname])) {
+            $this->_custom[$pname] = $pval;
+        }
+        else {
+            $this->$pname = $pval;
+        }
+        return $pval;
+    }
+
+    /*
      * Clear a cell.
      */
     function reset($key=null) {
@@ -224,7 +258,7 @@ class lsDB extends lsdb__baseclass {
     /*
      * Class constructor.
      */
-    function lsDB($host='localhost', $username=null, $pw=null) {
+    public function __construct($host='localhost', $username=null, $pw=null) {
         $this->open($host, $username, $pw);
         $this->_dbo =& $this;
         $sql = 'SHOW TABLES';
@@ -247,7 +281,7 @@ class lsDB extends lsdb__baseclass {
      * Method (doesn't really need to be a method, but o well) to
      * add a condition segment to a MySQL WHERE clause.
      */
-    function where($field, $value, $comp='=', $verbatim=false) {
+    protected function where($field, $value, $comp='=', $verbatim=false) {
         $clause = '';
         if (isset($value)) {
             if ($verbatim) {
@@ -260,13 +294,13 @@ class lsDB extends lsdb__baseclass {
         return $clause;
     }
 
-    function id($field, $table, $addl=null) {
+    protected function id($field, $table, $addl=null) {
         $this->_id_fieldname = $field;
         $this->_db_tablename = $table;
         $this->_id_display = $addl;
     }
 
-    function is_valid_field($table, $field) {
+    public function is_valid_field($table, $field) {
         if (array_key_exists($table, $this->_dbo->_db)
             && array_key_exists($field, $this->_dbo->_db[$table])) {
             return true;
@@ -281,24 +315,24 @@ class lsDB extends lsdb__baseclass {
      * need to copy them from MySQL into our object before
      * returning them.
      */
-    function errno() {
+    public function errno() {
         $this->_errno = mysql_errno($this->_dbc);
         return $this->_errno;
     }
 
-    function errstr() {
+    public function errstr() {
         $this->_errstr = mysql_error($this->_dbc);
         return $this->_errstr;
     }
 
-    function sql() {
+    public function sql() {
         return $this->_sql;
     }
 
     /*
      * Load the latest values from the database.
      */
-    function refresh($key=null) {
+    public function refresh($key=null) {
         if (! isset($key)) {
             $key = $this->_key;
         }
@@ -323,7 +357,7 @@ class lsDB extends lsdb__baseclass {
      * -2 means there's no single record to delete (either doesn't
      * exist or ambiguous).  Anything else is a MySQL error number.
      */
-    function delete() {
+    public function delete() {
         $this->clear_error();
         if ((! isset($this->_db_tablename))
             || (! isset($this->_id_fieldname))
@@ -392,7 +426,7 @@ class lsDB extends lsdb__baseclass {
      * Copy the database bits to the current object (not used in the
      * acDB class itself, but inherited).
      */
-    function importdb($dbo) {
+    protected function importdb($dbo) {
         while (is_object($dbo) && (! is_a($dbo, 'lsDB'))) {
             $dbo =& $dbo->_dbo;
         }
@@ -406,7 +440,7 @@ class lsDB extends lsdb__baseclass {
     /*
      * Close the connexion.  Hardly necessary, but just for completeness..
      */
-    function close() {
+    public function close() {
         if ($this->_dbc != 0) {
             mysql_close($this->_dbc);
             $this->_dbc = 0;
@@ -418,7 +452,7 @@ class lsDB extends lsdb__baseclass {
     /*
      * Access the database server and open the database.
      */
-    function open($host='localhost', $username=null, $pw=null) {
+    public function open($host='localhost', $username=null, $pw=null) {
         if ($this->_dbc != 0) {
             return mysql_ping($this->_dbc);
         }
@@ -445,14 +479,14 @@ class lsDB extends lsdb__baseclass {
     /*
      * Function to issue a query inside the object.
      */
-    function query($sql) {
+    public function query($sql) {
         $this->_sql = $sql;
         $this->_query = mysql_query($sql, $this->_dbc);
         $this->setknownerrstate();
         return $this->_query;
     }
 
-    function release($q=null) {
+    public function release($q=null) {
         $query = $q;
         $status = true;
         if (! isset($q)) {
@@ -466,12 +500,12 @@ class lsDB extends lsdb__baseclass {
         }
         return $status;
     }
-        
+
     /*
      * Set our error cells to a known state: either no error, stuckage,
      * or something from the last db action.
      */
-    function setknownerrstate() {
+    public function setknownerrstate() {
         if ((! isset($this->_dbc)) || (! $this->_dbc)) {
             $this->_errno = -666;
             $this->_errstr = 'no database connexion active';
@@ -491,7 +525,7 @@ class lsDB extends lsdb__baseclass {
     /*
      * Commit function..
      */
-    function commit($altkey=null) {
+    public function commit($altkey=null) {
         if (! $this->isDirty()) {
             return null;
         }
@@ -597,7 +631,7 @@ class lsDB extends lsdb__baseclass {
      * Method for generating info for the commit message subject line.
      * Other classes get to supercede it.
      */
-    function commit_subject() {
+    public function commit_subject() {
         return null;
     }
 
@@ -607,11 +641,11 @@ class lsDB extends lsdb__baseclass {
      * commit proceeds, otherwise it's aborted and the return value is
      * treated as the reason.
      */
-    function precommit() {
+    public function precommit() {
         return null;
     }
 
-    function latest() {
+    public function latest() {
         $sql = 'SELECT xid FROM loadinfo ORDER BY asof DESC LIMIT 1 ';
         $q = $this->query($sql);
         if ($q) {
@@ -622,31 +656,33 @@ class lsDB extends lsdb__baseclass {
         return null;
     }
 
-    function summary($list, $from, $until=null) {
+    public function summary($list, $from, $until=null) {
         return new lsMListSummary($this->_dbo, null, $list, $from, $until);
     }
-    function mlist($id=null) {
+
+    public function mlist($id=null) {
         return new lsMList($this->_dbo, $id);
     }
-    function infotext($id=null) {
+
+    public function infotext($id=null) {
         return new lsInfoText($this->_dbo, $id);
     }
-    
 
-    function select($criteria=null, $order=null) {
+    public function select($criteria=null, $order=null) {
         $o_selection = new lsSelection($this->_dbo, $criteria, $order);
         return $o_selection;
     }
-    function mlists($criteria=null, $order=null, $xids_only=false) {
+
+    public function mlists($criteria=null, $order=null, $xids_only=false) {
         $o_selection = $this->select($criteria, $order);
         return ($xids_only ? $o_selection->xids() : $o_selection->mlists());
     }
 
-    function domain($id=null) {
+    public function domain($id=null) {
         return new lsDomain($this->_dbo, $id);
     }
 
-    function domains($criteria=null, $order=null) {
+    public function domains($criteria=null, $order=null) {
         $sql = 'SELECT DISTINCT domain FROM list ';
         if (isset($criteria) && is_array($criteria)) {
             $first = true;
@@ -693,7 +729,7 @@ class lsDB extends lsdb__baseclass {
 
 class lsLoadInfo extends lsDB {
 
-    function lsLoadInfo($dbo, $id=null) {
+    public function __construct($dbo, $id=null) {
         $this->id('xid', 'loadinfo');
         $this->importdb($dbo);
         if (! isset($id)) {
@@ -714,7 +750,7 @@ class lsLoadInfo extends lsDB {
         }
     }
 
-    function mlists($criteria=null, $order=null, $xids_only=false) {
+    public function mlists($criteria=null, $order=null, $xids_only=false) {
         $sql = 'SELECT xid FROM list WHERE '
             . $this->where('asof', $this->get('asof'));
         if (isset($criteria) && is_array($criteria)) {
@@ -764,7 +800,7 @@ class lsSelection extends lsDB {
     var $_xids;
     var $_mlists;
 
-    function lsSelection($dbo, $criteria=null, $order=null) {
+    public function __construct($dbo, $criteria=null, $order=null) {
         $this->importdb($dbo);
         $sql = 'SELECT xid FROM list ';
         if (isset($criteria)) {
@@ -818,15 +854,15 @@ class lsSelection extends lsDB {
         }
     }
 
-    function mlists() {
+    public function mlists() {
         return $this->_mlists;
     }
 
-    function xids() {
+    public function xids() {
         return $this->_xids;
     }
 
-    function domains($countonly=false) {
+    public function domains($countonly=false) {
         $dlist = array();
         foreach ($this->_mlists as $o_mlist) {
             $dlist[$o_mlist->get('domain')] = true;
@@ -838,11 +874,11 @@ class lsSelection extends lsDB {
         return array_keys($dlist);
     }
 
-    function domain_count() {
+    public function domain_count() {
         return $this->domains(true);
     }
 
-    function total_posts() {
+    public function total_posts() {
         $posts = 0;
         foreach ($this->_mlists as $o_mlist) {
             $n = $o_mlist->get('posts');
@@ -853,7 +889,7 @@ class lsSelection extends lsDB {
         return $posts;
     }
 
-    function mean_posts() {
+    public function mean_posts() {
         $days = $this->post_days();
         if ($days) {
             return $this->total_posts() / $days;
@@ -861,7 +897,7 @@ class lsSelection extends lsDB {
         return 0;
     }
 
-    function post_days() {
+    public function post_days() {
         $days = 0;
         foreach ($this->_mlists as $o_mlist) {
             if ($o_mlist->get('posts') >= 0) {
@@ -871,7 +907,7 @@ class lsSelection extends lsDB {
         return $days;
     }
 
-    function total_subscribers() {
+    public function total_subscribers() {
         $subs = 0;
         foreach ($this->_mlists as $o_mlist) {
             $n = $o_mlist->get('count');
@@ -882,7 +918,7 @@ class lsSelection extends lsDB {
         return $subs;
     }
 
-    function total_digest_subscribers() {
+    public function total_digest_subscribers() {
         $subs = 0;
         foreach ($this->_mlists as $o_mlist) {
             $n = $o_mlist->get('dcount');
@@ -897,8 +933,8 @@ class lsSelection extends lsDB {
 
 class lsMListSummary extends lsMList {
 
-    function lsMListSummary($dbo, $id=null,
-                            $list=null, $from=null, $until=null) {
+    public function __construct($dbo, $id=null,
+                                $list=null, $from=null, $until=null) {
         $this->id('xid', 'list_summary');
         $this->importdb($dbo);
         if (! isset($id)) {
@@ -914,7 +950,7 @@ class lsMListSummary extends lsMList {
         }
     }
 
-    function summarise($list, $begin, $end=null) {
+    public function summarise($list, $begin, $end=null) {
         $from = new rlib_Date($begin);
         $until = new rlib_Date($end);
         $from = $from->as_dbdate();
@@ -948,17 +984,19 @@ class lsMListSummary extends lsMList {
         $this->set('mean_posts', $o_selection->mean_posts());
     }
 
-    function subscriber_count() {
+    public function subscriber_count() {
         return $this->get('count');
     }
-    function digester_count() {
+
+    public function digester_count() {
         return $this->get('dcount');
     }
-    function digest_subscriber_count() {
+
+    public function digest_subscriber_count() {
         return $this->digester_count();
     }
 
-    function info($entify=false) {
+    public function info($entify=false) {
         if (($iid = $this->get('info')) == 0) {
             return null;
         }
@@ -974,7 +1012,7 @@ class lsMListSummary extends lsMList {
 
 class lsInfoText extends lsDB {
 
-    function lsInfoText($dbo, $id=null) {
+    public function __construct($dbo, $id=null) {
         $this->id('xid', 'info_text');
         $this->importdb($dbo);
         if (! isset($id)) {
@@ -995,9 +1033,20 @@ class lsInfoText extends lsDB {
     }
 }
 
+class lsDomain extends lsDB {
+
+    private $_lists = array();
+    public $name;
+
+    public function __construct($dbo, $id=null) {
+        $this->importdb($dbo);
+        $this->name = $id;
+    }
+}
+
 class lsMList extends lsDB {
 
-    function lsMList($dbo, $id=null, $asof=null) {
+    public function __construct($dbo, $id=null, $asof=null) {
         $this->id('xid', 'list');
         $this->importdb($dbo);
         if (! isset($id)) {
@@ -1020,17 +1069,19 @@ class lsMList extends lsDB {
         }
     }
 
-    function subscriber_count() {
+    public function subscriber_count() {
         return $this->get('count');
     }
-    function digester_count() {
+
+    public function digester_count() {
         return $this->get('dcount');
     }
-    function digest_subscriber_count() {
+
+    public function digest_subscriber_count() {
         return $this->digester_count();
     }
 
-    function info($entify=false) {
+    public function info($entify=false) {
         if (($iid = $this->get('info')) == 0) {
             return null;
         }
@@ -1041,7 +1092,7 @@ class lsMList extends lsDB {
         }
         return $info;
     }
-    
+
 }
 
 /*



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to