Changeset 509

Show
Ignore:
Timestamp:
10/30/08 00:56:44 (2 months ago)
Author:
padams
Message:

adding refactored admin UI, widget, view and db calss changes

Location:
trunk
Files:
48 added
35 modified

Legend:

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

    r508 r509  
    3636        var $offset = 0; 
    3737         
     38        var $total_count; 
     39         
    3840        function __construct() { 
    3941                 
     
    6264                 
    6365                $this->offset = $this->limit * $this->page; 
    64                 return; 
     66                return $this->offset; 
    6567        } 
    6668         
    6769        function getMaxPageNum() { 
    6870         
    69                 if ($this->more_pages == true): 
    70                         $mpn = $this->page + 1; 
    71                 else: 
    72                         $mpn = $this->page; 
    73                 endif; 
     71                $c = $this->total_count / $this->limit; 
    7472                 
    75                 return $mpn; 
     73                $c = ceil($c); 
     74                 
     75                return $c; 
    7676        } 
    7777         
     
    8484                $pagination['max_page_num'] = $this->getMaxPageNum(); 
    8585                $pagination['more_pages'] = $this->more_pages; 
     86                $pagination['total_count'] = $this->total_count; 
    8687                 
    8788                return $pagination; 
  • trunk/modules/base/classes/widget.php

    r508 r509  
    3737         
    3838        var $default_format = 'graph'; 
     39        var $dom_id; 
    3940         
    4041        function __construct($params) { 
     
    5051        function pre() { 
    5152         
     53                // create dom safe id from do action param 
     54                $this->dom_id = str_replace('.', '-', $this->params['do']); 
     55                $this->data['dom_id'] = $this->dom_id; 
     56                         
    5257                if (!array_key_exists('format', $this->params)): 
    5358                         
     
    7580                $this->data['widget'] = $this->params['do']; 
    7681                $this->data['do'] = $this->params['do']; 
     82                 
     83                // set default dimensions 
     84                 
     85                if (array_key_exists('width', $this->params)): 
     86                        $this->setWidth($this->params['width']); 
     87                endif; 
     88                 
     89                if (array_key_exists('height', $this->params)): 
     90                        $this->setHeight($this->params['height']); 
     91                endif; 
    7792 
    7893        } 
    7994         
    80         function enableFormat($name, $label) { 
    81          
     95        function enableFormat($name, $label = '') { 
     96                 
     97                if (empty($label)): 
     98                        $label = ucwords($name); 
     99                endif; 
     100                 
    82101                $this->data['widget_views'][$name] = $label; 
    83102                return; 
     
    87106        function setHeight($height) { 
    88107         
    89                 if (!array_key_exists('height', $this->params)): 
    90108                        $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; 
    99109                 
    100110                return; 
     
    103113        function setWidth($width) { 
    104114         
    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; 
     115                $this->data['width'] = $width; 
    116116                 
    117117                return; 
     118        } 
     119         
     120        function setDefaultFormat($format) { 
     121         
     122                $this->default_format = $format; 
     123                 
     124                return; 
     125                 
    118126        } 
    119127 
     
    151159                endif; 
    152160                 
    153                 if (!array_key_exists('width', $data)): 
    154                         $data['params']['width'] = 300; 
    155                 else: 
    156                         $data['params']['width'] = $data['outer_width']; 
     161                if (array_key_exists('width', $data)): 
     162                        $data['params']['width'] = $data['width']; 
    157163                endif; 
    158164                 
    159                 if (!array_key_exists('height', $data)): 
    160                         $data['params']['height'] = 250; 
    161                 else: 
    162                         $data['params']['height'] = $data['outer_height']; 
     165                if (array_key_exists('height', $data)): 
     166                        $data['params']['height'] = $data['height']; 
    163167                endif; 
    164168                 
     
    171175                $this->body->set('title', $data['title']); 
    172176                $this->body->set('widget_views', $data['widget_views']); 
     177                $this->body->set('widget_views_count', count($data['widget_views'])); 
    173178                $this->body->set('do', $data['widget']); 
    174179                 
  • trunk/modules/base/dashboardTrendWidget.php

    r508 r509  
    4343                 
    4444                // Set Title of the Widget 
    45                 $this->data['title'] = 'Dashboard Trend'; 
    46                  
    47                 // set default dimensions 
    48                 $this->setHeight(300); 
    49                 $this->setWidth(800); 
     45                $this->data['title'] = 'Dashboard Trend';                
    5046                 
    5147                // enable formats 
    52                 $this->enableFormat('graph', 'Graph'); 
    53                 $this->enableFormat('table', 'Table'); 
    54                 $this->enableFormat('sparkline', 'Sparkline'); 
     48                $this->enableFormat('graph'); 
     49                $this->enableFormat('table'); 
     50                $this->enableFormat('sparkline'); 
    5551                 
    5652                //setup Metrics 
     
    110106                         
    111107                                $this->data['type'] = 'line'; 
    112                                 $this->data['view'] = 'base.sparkline';                  
     108                                $this->data['view'] = 'base.sparkline';                          
    113109                                break; 
     110                                 
    114111                        case 'sparkline-image': 
    115112                                 
  • trunk/modules/base/metrics/dashCounts.php

    r501 r509  
    3333        function owa_dashCounts($params = null) { 
    3434                 
    35                 $this->params = $params; 
     35                return owa_dashCounts::__construct($params); 
    3636                 
    37                 $this->owa_metric(); 
     37        } 
     38         
     39        function __construct($params = null) { 
    3840                 
    39                 return; 
    40                  
     41                return parent::__construct($params); 
    4142        } 
    4243         
    4344        function calculate() { 
    4445                 
    45                 $db = owa_coreAPI::dbSingleton(); 
    46  
    47                 $db->selectFrom('owa_session'); 
    48                 $db->selectColumn("count(distinct session.visitor_id) as unique_visitors,  
     46                $this->db->selectFrom('owa_session', 'session'); 
     47                $this->db->selectColumn("count(distinct session.visitor_id) as unique_visitors,  
    4948                                                        sum(session.is_new_visitor) as new_visitor, sum(session.is_repeat_visitor) as repeat_visitor, 
    5049                                                        count(session.id) as sessions,  
    5150                                                        sum(session.num_pageviews) as page_views"); 
    5251                 
    53                 // pass constraints into where clause 
    54                 $db->multiWhere($this->getConstraints()); 
    55  
    56                 return $db->getOneRow(); 
     52                $ret = $this->db->getOneRow(); 
    5753                 
    58                 /* 
    59  
    60                 $this->params['select'] = "count(distinct session.visitor_id) as unique_visitors,  
    61                         sum(session.is_new_visitor) as new_visitor, sum(session.is_repeat_visitor) as repeat_visitor, 
    62                         count(session.id) as sessions,  
    63                         sum(session.num_pageviews) as page_views "; 
     54                return $ret; 
    6455                 
    65                 $this->params['use_summary'] = true; 
    66                  
    67                 $this->setTimePeriod($this->params['period']); 
    68                  
    69                 $s = owa_coreAPI::entityFactory('base.session'); 
    70                  
    71                 return $s->query($this->params); 
    72                  
    73 */ 
    7456        } 
    7557         
  • trunk/modules/base/metrics/latestVisits.php

    r501 r509  
    4444        function calculate() { 
    4545                         
    46                 $db = owa_coreAPI::dbSingleton(); 
    47                  
    4846                $s = owa_coreAPI::entityFactory('base.session'); 
    4947                $h = owa_coreAPI::entityFactory('base.host'); 
     
    5351                $r = owa_coreAPI::entityFactory('base.referer'); 
    5452                 
    55                 $db->selectFrom($s->getTableName()); 
     53                $this->db->selectFrom($s->getTableName()); 
    5654                 
    57                 $db->selectColumn($s->getColumnsSql('session_')); 
    58                 $db->selectColumn($h->getColumnsSql('host_')); 
    59                 $db->selectColumn($ua->getColumnsSql('ua_')); 
    60                 $db->selectColumn($d->getColumnsSql('document_')); 
    61                 $db->selectColumn($v->getColumnsSql('visitor_')); 
    62                 $db->selectColumn($r->getColumnsSql('referer_')); 
     55                $this->db->selectColumn($s->getColumnsSql('session_')); 
     56                $this->db->selectColumn($h->getColumnsSql('host_')); 
     57                $this->db->selectColumn($ua->getColumnsSql('ua_')); 
     58                $this->db->selectColumn($d->getColumnsSql('document_')); 
     59                $this->db->selectColumn($v->getColumnsSql('visitor_')); 
     60                $this->db->selectColumn($r->getColumnsSql('referer_')); 
    6361                 
    64                 $db->join(OWA_SQL_JOIN_LEFT_OUTER, $h->getTableName(), '', 'host_id'); 
    65                 $db->join(OWA_SQL_JOIN_LEFT_OUTER, $ua->getTableName(), '', 'ua_id'); 
    66                 $db->join(OWA_SQL_JOIN_LEFT_OUTER, $d->getTableName(), '', 'first_page_id'); 
    67                 $db->join(OWA_SQL_JOIN_LEFT_OUTER, $v->getTableName(), '', 'visitor_id'); 
    68                 $db->join(OWA_SQL_JOIN_LEFT_OUTER, $r->getTableName(), '', 'referer_id'); 
     62                $this->db->join(OWA_SQL_JOIN_LEFT_OUTER, $h->getTableName(), '', 'host_id'); 
     63                $this->db->join(OWA_SQL_JOIN_LEFT_OUTER, $ua->getTableName(), '', 'ua_id'); 
     64                $this->db->join(OWA_SQL_JOIN_LEFT_OUTER, $d->getTableName(), '', 'first_page_id'); 
     65                $this->db->join(OWA_SQL_JOIN_LEFT_OUTER, $v->getTableName(), '', 'visitor_id'); 
     66                $this->db->join(OWA_SQL_JOIN_LEFT_OUTER, $r->getTableName(), '', 'referer_id'); 
    6967                 
    7068                // pass constraints into where clause 
    71                 $db->multiWhere($this->getConstraints()); 
    72                 $db->orderBy('session_timestamp'); 
    73                 $db->order($this->params['order']); 
    74                 $db->limit($this->params['limit']); 
    75                 $db->offset($this->params['offset']); 
    7669                 
    77                 $ret = $db->getAllRows(); 
     70                $this->db->orderBy('session_timestamp'); 
     71                $this->db->order($this->params['order']); 
     72                 
     73                $ret = $this->db->getAllRows(); 
    7874                 
    7975                return $ret; 
     76        } 
     77         
     78        function paginationCount() { 
     79         
     80                $this->db->selectFrom('owa_session'); 
     81                $this->db->selectColumn('count(id) as count'); 
     82                 
     83                $ret = $this->db->getOneRow(); 
     84                 
     85                return $ret['count']; 
     86                 
     87                 
    8088        } 
    8189         
  • trunk/modules/base/metrics/pageViewsByDay.php

    r501 r509  
    3333        function owa_pageViewsByDay($params = null) { 
    3434                 
    35                 $this->params = $params; 
     35                return owa_pageViewsByDay::__construct($params); 
    3636                 
    37                 $this->owa_metric(); 
    38                  
    39                 return; 
    40                  
     37        } 
     38         
     39        function __construct($params = null) { 
     40         
     41                return parent::__construct($params); 
    4142        } 
    4243         
    4344        function calculate() { 
    4445                 
    45                 $db = owa_coreAPI::dbSingleton(); 
    46  
    47                 $db->selectFrom('owa_session', 'session'); 
    48                 $db->selectColumn("sum(session.num_pageviews) as page_views, 
     46                $this->db->selectFrom('owa_session', 'session'); 
     47                $this->db->selectColumn("sum(session.num_pageviews) as page_views, 
    4948                                                                        session.month,  
    5049                                                                        session.day,  
    5150                                                                        session.year"); 
    5251                 
    53                 // pass constraints into where clause 
    54                 $db->multiWhere($this->getConstraints()); 
    55  
    5652                if (array_key_exists('groupby', $this->params)): 
    57                         $db->groupBy($this->params['groupby']); 
     53                        $this->db->groupBy($this->params['groupby']); 
    5854                else: 
    59                         $db->groupBy('session.day'); 
     55                        $this->db->groupBy('session.day'); 
    6056                endif; 
    6157                 
    62                 $db->orderBy('session.year'); 
    63                 $db->orderBy('session.month'); 
    64                 $db->orderBy('session.day'); 
     58                $this->db->orderBy('session.year'); 
     59                $this->db->orderBy('session.month'); 
     60                $this->db->orderBy('session.day'); 
    6561                 
     62                return $this->db->getAllRows(); 
    6663                 
    67                 return $db->getAllRows(); 
    68                  
    69                 /* 
    70  
    71                  
    72                 $s = owa_coreAPI::entityFactory('base.session'); 
    73                  
    74                 $this->setTimePeriod($this->params['period']); 
    75                  
    76                 $this->params['select'] = "sum(session.num_pageviews) as page_views, 
    77                                                                         session.month,  
    78                                                                         session.day,  
    79                                                                         session.year"; 
    80                                                                  
    81                  
    82                 $this->params['orderby'] = array('session.year', 'session.month', 'session.day'); 
    83          
    84                 return $s->query($this->params); 
    85                  
    86 */ 
    8764        } 
    8865         
  • trunk/modules/base/metrics/topPages.php

    r501 r509  
    3838         
    3939        function __construct($params) { 
    40          
     40                                 
     41                $this->setLabels(array('Page Views', 'Page Name', 'Page Type', 'URL', 'Document ID')); 
     42                $this->page_results = true; 
     43 
    4144                return parent::__construct($params); 
    4245        } 
     
    4548        function calculate() { 
    4649                         
    47                 $db = owa_coreAPI::dbSingleton(); 
     50                //$db = owa_coreAPI::dbSingleton(); 
    4851                                 
    4952                $r = owa_coreAPI::entityFactory('base.request'); 
     
    5154                 
    5255                //$r->addRelatedObject('document_id', owa_coreAPI::entityFactory('base.document')); 
    53                 $db->selectFrom($r->getTableName(), 'request'); 
    54                 $db->selectColumn("count(request.document_id) as count, 
     56                $this->db->selectFrom($r->getTableName(), 'request'); 
     57                $this->db->selectColumn("count(request.document_id) as count, 
    5558                                                document.page_title, 
    5659                                                document.page_type, 
     
    6164                //$this->setTimePeriod($this->params['period']); 
    6265                 
    63                 $db->where('document.page_type', 'feed', '!='); 
     66                $this->db->where('document.page_type', 'feed', '!='); 
    6467 
    65                 // pass constraints into where clause 
    66                 $db->multiWhere($this->getConstraints()); 
    67  
    68                 $db->join(OWA_SQL_JOIN_LEFT_OUTER,$d->getTableName(), 'document', 'document_id', 'document.id'); 
    69                 $db->groupBy('document.id'); 
    70                 $db->orderBy('count'); 
    71                 $db->order('DESC'); 
     68                 
     69                $this->db->join(OWA_SQL_JOIN_LEFT_OUTER,$d->getTableName(), 'document', 'document_id', 'document.id'); 
     70                $this->db->groupBy('document.id'); 
     71                $this->db->orderBy('count'); 
     72                 
     73                //$db->order('DESC'); 
    7274                 
    73