Changeset 508

Show
Ignore:
Timestamp:
10/22/08 02:12:03 (3 months ago)
Author:
padams
Message:

- adding new sparkline class
- adding new sparkline widget format
- adding new pagination class and associateed metric class methods
- adding javascript pagination controls to wdget object

Location:
trunk
Files:
121 added
20 modified

Legend:

Unmodified
Added
Removed
  • trunk/modules/base/classes/widget.php

    r504 r508  
    5151         
    5252                if (!array_key_exists('format', $this->params)): 
    53                         $this->params['format'] = $this->default_format; 
     53                         
     54                                $this->params['format'] = $this->default_format; 
     55                 
     56                else: 
     57                        if (empty($this->params['format'])): 
     58                                $this->params['format'] = $this->default_format; 
     59                        endif; 
    5460                endif; 
    5561                 
     
    6672                        unset($this->data['params']['initial_view']); 
    6773                endif; 
    68                  
     74                $this->data['wrapper'] = $this->params['wrapper']; 
    6975                $this->data['widget'] = $this->params['do']; 
    70          
     76                $this->data['do'] = $this->params['do']; 
     77 
    7178        } 
    7279         
     
    7683                return; 
    7784         
     85        } 
     86         
     87        function setHeight($height) { 
     88         
     89                if (!array_key_exists('height', $this->params)): 
     90                        $this->data['height'] = $height; 
     91                else: 
     92                        $this->data['height'] = $this->params['height']; 
     93                endif; 
     94                 
     95                if ($this->params['wrapper'] === true): 
     96                        $this->data['outer_height'] = $this->data['height']; 
     97                        $this->data['height'] = $this->data['height'] - 130; 
     98                endif; 
     99                 
     100                return; 
     101        } 
     102         
     103        function setWidth($width) { 
     104         
     105                if (!array_key_exists('width', $this->params)): 
     106                        $this->data['width'] = $width; 
     107                else: 
     108                        $this->data['width'] = $this->params['width']; 
     109                endif; 
     110                 
     111                if ($this->params['wrapper'] == true): 
     112                        $this->data['outer_width'] = $this->data['width'];       
     113                        $this->data['width'] = $this->data['width'] - 50; 
     114                         
     115                endif; 
     116                 
     117                return; 
    78118        } 
    79119 
     
    113153                if (!array_key_exists('width', $data)): 
    114154                        $data['params']['width'] = 300; 
     155                else: 
     156                        $data['params']['width'] = $data['outer_width']; 
    115157                endif; 
    116158                 
    117                 if (!array_key_exists('width', $data)): 
     159                if (!array_key_exists('height', $data)): 
    118160                        $data['params']['height'] = 250; 
     161                else: 
     162                        $data['params']['height'] = $data['outer_height']; 
    119163                endif; 
     164                 
     165                $this->_setLinkState(); 
    120166                 
    121167                $this->body->set_template('widget.tpl'); 
     
    125171                $this->body->set('title', $data['title']); 
    126172                $this->body->set('widget_views', $data['widget_views']); 
    127                 $this->body->set('do', $data['widget']);         
     173                $this->body->set('do', $data['widget']); 
     174                 
     175                 
    128176                 
    129177                return; 
  • trunk/modules/base/dashboardTrendWidget.php

    r504 r508  
    2020require_once(OWA_BASE_CLASSES_DIR.'owa_lib.php'); 
    2121require_once(OWA_BASE_CLASS_DIR.'widget.php'); 
    22 require_once(OWA_BASE_CLASSES_DIR.'owa_view.php'); 
    2322 
     23/** 
     24 * DashBoard Trend Widget Controller 
     25 * 
     26 * 
     27 */ 
    2428class owa_dashboardTrendWidgetController extends owa_widgetController { 
    25  
     29         
    2630        function __construct($params) { 
     31                 
     32                $this->default_format = 'graph'; 
    2733                 
    2834                return parent::__construct($params); 
     
    3844                // Set Title of the Widget 
    3945                $this->data['title'] = 'Dashboard Trend'; 
     46                 
     47                // set default dimensions 
     48                $this->setHeight(300); 
     49                $this->setWidth(800); 
    4050                 
    4151                // enable formats 
     
    5666                                 
    5767                                $this->data['view'] = 'base.openFlashChart'; 
    58                                 $this->data['height'] = $this->params['height']; 
    59                                 $this->data['width'] = $this->params['width']; 
    6068                                break; 
    6169                                 
     
    7583                        case 'table': 
    7684                         
    77                                 $m->setLimit(5); 
     85                                // apply limit override 
     86                                if (array_key_exists('limit', $this->params)): 
     87                                        $m->setLimit($this->params['limit']); 
     88                                else: 
     89                                        $m->setLimit(5);         
     90                                endif; 
     91                                                                                         
     92                                // set page number of results 
     93                                if (array_key_exists('page', $this->params)): 
     94                                        $m->setPage($this->params['page']); 
     95                                endif; 
     96                                 
    7897                                $results = $m->generate(); 
     98                                 
    7999                                $this->data['labels'] = $m->getLabels(); 
    80100                                $this->data['rows'] = $results; 
    81101                                $this->data['view'] = 'base.genericTable'; 
     102                                 
     103                                // generate pagination array 
     104                                $this->data['pagination'] = $m->getPagination(); 
     105                         
     106                                //print_r($this->data['pagination']); 
    82107                                break; 
    83                                          
     108                                 
     109                        case 'sparkline': 
     110                         
     111                                $this->data['type'] = 'line'; 
     112                                $this->data['view'] = 'base.sparkline';                  
     113                                break; 
     114                        case 'sparkline-image': 
     115                                 
     116                                $this->data['view'] = 'base.sparklineLineGraph'; 
     117                                break;           
    84118                } 
    85119                 
  • trunk/modules/base/metrics/dashCoreByDay.php

    r502 r508  
    3030 
    3131class owa_dashCoreByDay extends owa_metric { 
     32 
     33        var $limit = 10; 
    3234         
    3335        function owa_dashCoreByDay($params = null) { 
     
    4244                 
    4345                $this->setLabels(array('Month', 'Day', 'Year', 'Unique Visitors', 'Sessions', 'Page Views')); 
     46                $this->page_results = true; 
    4447                 
    4548                return; 
     
    4952        function calculate() { 
    5053                 
    51                 $db = owa_coreAPI::dbSingleton(); 
     54                $this->db->selectFrom('owa_session', 'session'); 
    5255                 
    53                 $db->selectFrom('owa_session', 'session'); 
     56                $this->db->selectColumn("session.month,  
     57                                                                session.day,  
     58                                                                session.year,  
     59                                                                count(distinct session.visitor_id) as unique_visitors,  
     60                                                                count(session.id) as sessions,  
     61                                                                sum(session.num_pageviews) as page_views"); 
     62                                                                         
     63                $this->db->groupBy('day'); 
     64                $this->db->groupBy('month'); 
     65                $this->db->orderBy('year'); 
     66                $this->db->orderBy('month'); 
     67                $this->db->orderBy('day'); 
    5468                 
    55                 $db->selectColumn("session.month,  
    56                                                         session.day,  
    57                                                         session.year,  
    58                                                         count(distinct session.visitor_id) as unique_visitors,  
    59                                                         count(session.id) as sessions,  
    60                                                         sum(session.num_pageviews) as page_views"); 
    61                                                                          
    62                 // pass constraints set by caller into where clause 
    63                 $db->multiWhere($this->getConstraints()); 
    64                 $db->groupBy('day'); 
    65                 $db->groupBy('month'); 
    66                 $db->orderBy('year'); 
    67                 $db->orderBy('month'); 
    68                 $db->orderBy('day'); 
    69                  
    70                 if (array_key_exists('limit', $this->params)): 
    71                         $db->limit($this->params['limit']); 
    72                 endif; 
    73                  
    74                 $ret = $db->getAllRows(); 
     69                $ret = $this->db->getAllRows(); 
    7570                 
    7671                return $ret; 
  • trunk/modules/base/metrics/dashCountsTraffic.php

    r501 r508  
    4444                 
    4545                $db = owa_coreAPI::dbSingleton(); 
     46                 
    4647                $db->selectColumn("count(distinct session.visitor_id) as unique_visitors,  
    4748                        sum(session.is_new_visitor) as new_visitor, sum(session.is_repeat_visitor) as repeat_visitor, 
     
    5960 
    6061                return $ret; 
    61  
    62          
    63                 /* 
    64  
    65                 $this->params['select'] = "count(distinct session.visitor_id) as unique_visitors,  
    66                         sum(session.is_new_visitor) as new_visitor, sum(session.is_repeat_visitor) as repeat_visitor, 
    67                         count(session.id) as sessions,  
    68                         sum(session.num_pageviews) as page_views "; 
    69                  
    70                 $this->params['use_summary'] = true; 
    71                  
    72                 $this->setTimePeriod($this->params['period']); 
    73                  
    74                 $s = owa_coreAPI::entityFactory('base.session'); 
    75                  
    76                 $ref = owa_coreAPI::entityFactory('base.referer'); 
    77                  
    78                 $this->params['related_objs'] = array('referer_id' => $ref); 
    79                  
    80                 return $s->query($this->params); 
    81 */ 
    8262                 
    8363        } 
  • trunk/modules/base/processEvent.php

    r424 r508  
    5858                 
    5959                // Pre process - default and standard properties 
    60                 $this->pre(); 
     60                $this->preProcess(); 
    6161                 
    6262                $this->event->state = $this->params['caller']['event']; 
     
    7676         * Must be called before all other event property setting functions 
    7777         */ 
    78         function pre() { 
     78        function preProcess() { 
    7979                 
    8080                // set site id if not already set . Needed for GUID generation of event 
     
    141141        } 
    142142         
    143         function post() { 
     143        function postProcess() { 
    144144                 
    145145                //Clean Query Strings 
  • trunk/modules/base/processRequest.php

    r463 r508  
    5959                 
    6060                // Pre process - set default and standard event property names 
    61                 $this->pre(); 
     61                $this->preProcess(); 
    6262                 
    6363                // Set event properties 
     
    110110                 
    111111                // Post Process - cleanup after all properties are set 
    112                 $this->post(); 
     112                $this->postProcess(); 
    113113                 
    114114                return $this->event->log(); 
  • trunk/modules/base/report.php

    r503 r508  
    9393                $this->body->set('params', $this->report_params); 
    9494                 
    95                 // create state params for all links 
     95                /* 
     96// create state params for all links 
    9697                $link_params = array( 
    9798                                                                'period'        => $this->data['params']['period'], // could be set by setPeriod 
     
    107108                $this->body->caller_params['link_state'] =  $link_params; 
    108109                $this->subview->body->caller_params['link_state'] =  $link_params; 
     110*/ 
     111                $this->_setLinkState(); 
    109112                 
    110113                // set site filter list 
  • trunk/modules/base/reportDashboard.php

    r504 r508  
    11<?php 
    2