Changeset 502

Show
Ignore:
Timestamp:
08/24/08 02:05:36 (3 months ago)
Author:
padams
Message:

addng open flash cahrt wdget rework

Location:
trunk
Files:
3 added
11 modified

Legend:

Unmodified
Added
Removed
  • trunk/modules/base/dashboardTrendWidget.php

    r501 r502  
    4242                $m->setPeriod($this->params['period']); 
    4343                $m->setOrder(OWA_SQL_ASCENDING);  
    44                 $results = $m->generate(); 
     44                 
    4545                 
    4646                if (array_key_exists('format', $this->params)): 
     
    5151                         
    5252                $data['title'] = 'Dashboard Trend'; 
    53                 $data['view'] = 'base.widget'; 
    54                 $data['y']['label'] = 'Page Views'; 
    55                 $data['y2']['label'] = 'Visits'; 
    56                 $data['x']['label'] = 'Day'; 
     53                $data['params'] = $this->params; 
     54                $data['widget'] = 'base.dashboardTrendWidget'; 
    5755                 
    5856                switch ($format) { 
     
    6058                        case 'graph': 
    6159                                 
     60                                $data['view'] = 'base.openFlashChart'; 
     61                                $data['height'] = $this->params['height']; 
     62                                $data['width'] = $this->params['width']; 
     63                                break; 
     64                                 
     65                        case 'graph-data': 
     66                                $results = $m->generate(); 
    6267                                $series = owa_lib::deconstruct_assoc($results); 
     68                                $data['y']['label'] = 'Page Views'; 
     69                                $data['y2']['label'] = 'Visits'; 
     70                                $data['x']['label'] = 'Day'; 
    6371                                $data['y']['series'] = $series['page_views']; 
    6472                                $data['y2']['series'] = $series['sessions']; 
     
    6876                                 
    6977                        case 'table': 
    70                                 $data['column_labels'] = array(); 
    71                                 $data['data'] = ''; 
     78                                $m->setLimit(5); 
     79                                $results = $m->generate(); 
     80                                $data['labels'] = $m->getLabels(); 
     81                                $data['rows'] = $results; 
    7282                                $data['view'] = 'base.genericTable'; 
    7383                                break; 
     
    7585                         
    7686                } 
     87                 
     88                if ($this->params['initial-view'] == true): 
     89                        $data['subview'] = $data['view']; 
     90                        $data['view'] = 'base.widget'; 
     91                endif; 
     92                 
    7793                 
    7894                return $data; 
  • trunk/modules/base/metrics/dashCoreByDay.php

    r501 r502  
    3333        function owa_dashCoreByDay($params = null) { 
    3434                 
    35                 $this->params = $params; 
     35                return owa_dashCoreByDay::__construct($params); 
     36         
     37        } 
     38         
     39        function __construct($params = null) { 
     40         
     41                parent::__construct($params); 
    3642                 
    37                 $this->owa_metric(); 
     43                $this->setLabels(array('Month', 'Day', 'Year', 'Unique Visitors', 'Sessions', 'Page Views')); 
    3844                 
    3945                return; 
     
    6268                $db->orderBy('day'); 
    6369                 
     70                if (array_key_exists('limit', $this->params)): 
     71                        $db->limit($this->params['limit']); 
     72                endif; 
     73                 
    6474                $ret = $db->getAllRows(); 
    6575                 
    6676                return $ret; 
    67                  
    68                  
    69 /* 
    70                  
    71                 $this->params['select'] = "session.month,  
    72                         session.day,  
    73                         session.year,  
    74                         count(distinct session.visitor_id) as unique_visitors,  
    75                         count(session.id) as sessions,  
    76                         sum(session.num_pageviews) as page_views "; 
    77                  
    78                  
    79                 $this->params['groupby'] = array('day', 'month'); 
    80  
    81                 $this->params['orderby'] = array('year', 'month', 'day'); 
    82                  
    83                 $this->setTimePeriod($this->params['period']); 
    84  
    85                 $s = owa_coreAPI::entityFactory('base.session'); 
    86                  
    87                 return $s->query($this->params); 
    88  
    89 */               
     77                                 
    9078        } 
    9179         
  • trunk/modules/base/metrics/dashCoreByMonth.php

    r501 r502  
    3333        function owa_dashCoreByMonth($params = null) { 
    3434                 
    35                 $this->params = $params; 
     35                return owa_dashCoreByMonth::__construct($params); 
    3636                 
    37                 $this->owa_metric(); 
     37        } 
     38         
     39        function __construct($params = null) { 
     40         
     41                parent::__construct($params); 
    3842                 
     43                $this->setLabels(array('Month', 'Day', 'Year', 'Unique Visitors', 'Sessions', 'Page Views')); 
     44 
    3945                return; 
    4046                 
     
    6167                return $db->getAllRows(); 
    6268                 
    63                 /* 
    64                  
    65                 $this->params['select'] = "session.month,  
    66                         session.day,  
    67                         session.year,  
    68                         count(distinct session.visitor_id) as unique_visitors,  
    69                         count(session.id) as sessions,  
    70                         sum(session.num_pageviews) as page_views "; 
    71                  
    72                 $this->params['use_summary'] = true; 
    73                  
    74                 $this->params['groupby'] = array('month', 'year'); 
    75  
    76                 $this->params['orderby'] = array('year', 'month'); 
    77                  
    78                 $this->setTimePeriod($this->params['period']); 
    79  
    80                 $s = owa_coreAPI::entityFactory('base.session'); 
    81                  
    82                 return $s->query($this->params); 
    83  
    84 */               
    8569        } 
    8670         
  • trunk/modules/base/templates/report_dashboard.tpl

    r501 r502  
    1313</style> 
    1414 
     15<script type="text/javascript" src="<?=$this->config['public_url'];?>js/includes/jquery/jquery.js"></script> 
     16 
    1517<? include('report_header.tpl');?> 
    1618 
     
    1921                <TD valign="top" id="trend_graph"> 
    2022                 
    21                         <img src="<?=$this->graphLink(array('view' => 'base.graphDashboardTrend', 'period' => 'last_thirty_days', 'site_id' => $params['site_id'])); ?>"> 
     23                        <!-- <img src="<?=$this->graphLink(array('view' => 'base.graphDashboardTrend', 'period' => 'last_thirty_days', 'site_id' => $params['site_id'])); ?>"> --> 
    2224                         
    2325                        <?=$this->getWidget('base.dashboardTrendWidget', 'graph', array('height' => 300, 'width' => 900));?> 
     26                        <? //$this->getWidget('base.dashboardTrendWidget', 'table', array('height' => 300, 'width' => 900));?> 
    2427                </TD>    
    2528        </TR> 
  • trunk/modules/base/templates/widget.tpl

    r501 r502  
    1 <div style="border: 2px solid red;"> 
     1<style> 
    22 
    3 <div id="flash-graph" style="visiblity:;"> 
     3.widget-container {border:1px solid #cccccc; width:100%;} 
     4.widget-header {color: white;background-color:orange; padding:10px;text-align:left; font-weight:bold; font-size:18px;} 
     5.widget-title {font-size:20px;text-align:right;} 
     6.widget-title a {color: white;} 
     7.widget-title-controls {font-size:14px;text-align:right;} 
     8.widget-controls {text-align:right;padding:10px} 
     9.widget-content {padding:10px;} 
    410 
    5 <?=$this->ofc($params['width'], $params['height'], $this->makeAbsoluteLink(array('do' => $widget, 'period' => 'last_thirty_days', 'site_id' => $params['site_id'], 'format' => $format), false , $this->config['action_url'])); ?> 
     11</style> 
    612 
    7 </div> 
    8  
    9 <div id="data-table"></div> 
    10 <div id="data-export"></div> 
    11  
    12 </div> 
    1313 
    1414<script> 
     15var state = new Object; 
     16state['<?=$widget;?>'] = new Object; 
     17state['<?=$widget;?>'].url = "http://wp25-php5-test.openwebanalytics.com/index.php?owa_specialAction&owa_do=base.dashboardTrendWidget&owa_period=last_thirty_days&owa_format="; 
    1518 
    1619</script> 
     20 
     21<script>  
     22        //var widgeturl = "http://wp25-php5-test.openwebanalytics.com/index.php?owa_specialAction&owa_do=base.dashboardTrendWidget&owa_period=last_thirty_days&owa_format="; 
     23        var widgeturl = state['<?=$widget;?>'].url; 
     24         
     25  // When the document loads do everything inside here ...  
     26     jQuery(document).ready(function(){  
     27     //$('#content').load('boo.php'); //by default initally load text from boo.php  
     28                jQuery('.widget-control').click(function() { //start function when any link is clicked 
     29                        var parentname = jQuery("div").parent(".widget-container").attr("id"); 
     30                        var widgetname2 = parentname.split("_"); 
     31                        var widgetname = widgetname2[0]; 
     32                        var widgetcontentid = "#"+widgetname+"_widget-content"; 
     33                        var format = jQuery(this).attr("name"); 
     34                        //alert(widgetcontentid); 
     35                        jQuery(widgetcontentid).slideUp("slow");  
     36                         //var content_show = $(this).attr("title"); //retrieve title of link so we can compare with php file  
     37                        jQuery.ajax({  
     38                                method: "get",url: widgeturl+format,  
     39                                beforeSend: function(){ jQuery(".widget-status").show("fast");}, //show loading just when link is clicked  
     40                                complete: function(){ jQuery(".widget-status").hide("fast");}, //stop showing loading when the process is complete  
     41                                success: function(html){ //so, if data is retrieved, store it in html  
     42                                        jQuery(widgetcontentid).show("slow"); //animation  
     43                                        jQuery(widgetcontentid).html(html); //show the html inside .content div  
     44                                }  
     45                        }); //close $.ajax(  
     46         }); //close click(  
     47     }); //close $(  
     48</script>  
     49 
     50 
     51<div id="<?=$widget;?>_widget-container" class="widget-container"> 
     52 
     53        <div id="<?=$widget;?>_widget-header"class="widget-header"> 
     54                <span class="widget-title"><?=$title;?></span> 
     55 
     56                <div id="<?=$widget;?>_widget-title-controls" style="float:right;"> 
     57                        <span class="widget-title-controls"><a href="">Close</a></span> 
     58                </div> 
     59                 
     60        </div> 
     61 
     62        <div id="<?=$widget;?>_widget-status" class="widget-status">LOADING</div>  
     63 
     64        <div id="<?=$widget;?>_widget-content" class="widget-content"><?=$subview;?></div> 
     65         
     66        <div id="<?=$widget;?>_widget-controls" class="widget-controls"> 
     67                <a class="widget-control" href="#base-dashboardTrendWidget_widget-header" name="graph">Graph</a> |  
     68                <a class="widget-control" href="#base-dashboardTrendWidget_widget-header" name="table">Table</a> |  
     69                <a class="widget-control" href="#base-dashboardTrendWidget_widget-header" name="sparkline">Sparkline</a> 
     70        </div> 
     71 
     72         
     73</div> 
  • trunk/modules/base/widget.php

    r501 r502  
    8383                // load template 
    8484                 
    85                 if ($data['is_external'] == true): 
     85                if ($data['params']['is_external'] == true): 
    8686                        $this->t->set_template('wrapper_widget.tpl'); 
    8787                else: 
     
    9090                 
    9191                if (!array_key_exists('width', $data)): 
    92                         $data['width'] = 300; 
     92                        $data['params']['width'] = 300; 
    9393                endif; 
    9494                 
    9595                if (!array_key_exists('width', $data)): 
    96                         $data['height'] = 250; 
     96                        $data['params']['height'] = 250; 
    9797                endif; 
    9898                 
    9999                $this->body->set_template('widget.tpl'); 
    100                 $this->body->set('format', $data['format']); 
    101                 $this->body->set('widget', $data['widget']);                     
    102                 $this->body->set('params', $data['params']);     
     100                $this->body->set('format', $data['params']['format']); 
     101                $this->body->set('widget', str_replace('.', '-', $data['widget']));                      
     102                $this->body->set('params', $data['params']['params']);   
     103                $this->body->set('title', $data['title']);       
    103104                return; 
    104105        } 
  • trunk/owa_base.php

    r498 r502  
    7575        function owa_base() { 
    7676                 
     77                return owa_base::__construct(); 
     78 
     79        } 
     80         
     81        function __construct() { 
     82         
    7783                $this->e = &owa_coreAPI::errorSingleton(); 
    7884                $this->c = &owa_coreAPI::configSingleton(); 
     
    8086                 
    8187                return; 
    82  
     88         
    8389        } 
    8490         
  • trunk/owa_coreAPI.php

    r501 r502  
    300300                list($module, $file) = split("\.", $modulefile); 
    301301                $class = $class_ns.$file.$class_suffix; 
    302          
     302                //print $class; 
    303303                // Require class file if class does not already exist 
    304304                if(!class_exists($class)):       
     
    369369                list($module, $class) = split("\.", $subview); 
    370370                 
    371                 owa_lib::moduleRequireOnce($module, $class); 
     371                //owa_lib::moduleRequireOnce($module, $class); 
    372372         
    373373                $subview =  owa_lib::moduleFactory($module, $class.'View', $params); 
  • trunk/owa_metric.php

    r501 r502  
    5252         */ 
    5353        var $params = array(); 
    54          
    55         var $db; 
     54                 
     55        /** 
     56         * The lables for calculated measures 
     57         * 
     58         * @var array 
     59         */ 
     60        var $labels = array(); 
    5661 
    5762        /** 
     
    6368        function owa_metric($params = '') { 
    6469 
    65                 return $this->__construct($params); 
     70                return owa_metric::__construct($params); 
    6671        } 
    6772         
     
    412417         
    413418        } 
     419         
     420         
     421        /** 
     422         * Set the labels of the measures 
     423         * 
     424         */ 
     425        function setLabels($array) { 
     426         
     427                $this->labels = $array; 
     428                return; 
     429        } 
     430         
     431        /** 
     432         * Retrieve the labels of the measures 
     433         * 
     434         */ 
     435        function getLabels() { 
     436         
     437                return $this->labels; 
     438         
     439        } 
     440         
     441         
    414442} 
    415443 
  • trunk/owa_template.php

    r501 r502  
    579579        } 
    580580         
    581         function getWidget($widget, $format, $params = '') { 
     581        function getWidget($widget, $format, $params = array()) { 
    582582                 
    583583                if (empty($params)): 
     
    587587                $params['widget'] = $widget; 
    588588                $params['format'] = $format; 
    589                  
    590                 $api = owa_coreAPI::singleton(); 
    591                  
    592                 return $api->performAction('base.widget', $params); 
     589                $params['initial-view'] = true; 
     590                 
     591                return owa_coreAPI::performAction($widget, $params); 
    593592        } 
    594593         
  • trunk/owa_view.php

    r501 r502  
    1717// 
    1818 
    19 require_once('owa_template.php'); 
    20 require_once('owa_base.php'); 
    21 require_once('owa_requestContainer.php'); 
    22 require_once(OWA_BASE_CLASSES_DIR.'owa_coreAPI.php'); 
     19require_once(OWA_BASE_CLASSES_DIR.'owa_template.php'); 
     20//require_once(OWA_BASE_CLASSES_DIR.'owa_base.php'); 
     21require_once(OWA_BASE_CLASSES_DIR.'owa_requestContainer.php'); // ?? 
     22//require_once(OWA_BASE_CLASSES_DIR.'owa_coreAPI.php'); 
    2323 
    2424/** 
     
    301301                else:  
    302302                        //$this->e->debug('RenderView: '.print_r($data, true)); 
    303                         $api = &owa_coreAPI::singleton(); 
    304                          
    305                         $subview = $api->displaySubView($auth_data); 
     303                        //$api = &owa_coreAPI::singleton(); 
     304                         
     305                        $subview = owa_coreAPI::displaySubView($auth_data); 
    306306                         
    307307                        return $subview; 
     
    412412} 
    413413 
    414 class owa_pieFlashChartView extends owa_base { 
     414class owa_pieFlashChartView extends owa_view { 
    415415 
    416416        function owa_pieFlashChartView() { 
     
    421421        function __construct() { 
    422422                 
    423                 return $this->owa_base(); 
     423                return parent::__construct(); 
    424424                 
    425425        } 
     
    458458} 
    459459 
    460  
    461  
    462  
     460class owa_genericTableView extends owa_view { 
     461 
     462        function __construct() { 
     463                 
     464                return parent::__construct(); 
     465                 
     466        } 
     467         
     468        function owa_genericTableView() { 
     469         
     470                return owa_genericTableView::__construct();  
     471        } 
     472         
     473        function construct($data) { 
     474         
     475                $this->t->set_template('wrapper_blank.tpl');             
     476                $this->body->set_template('generic_table.tpl'); 
     477                 
     478                if (!empty($data['labels'])): 
     479                        $this->body->set('labels', $data['labels']); 
     480                else: 
     481                        $this->body->set('labels', ''); 
     482                endif; 
     483                         
     484                if (!empty($data['rows'])): 
     485                        $this->body->set('rows', $data['rows']); 
     486                        $this->body->set('row_count', count($data['rows'])); 
     487                else: 
     488                        $this->body->set('rows', ''); 
     489                        $this->body->set('row_count', 0); 
     490                endif; 
     491                 
     492        } 
     493 
     494} 
     495 
     496class owa_openFlashChartView extends owa_view { 
     497 
     498        function owa_openFlashChartView() { 
     499                 
     500                owa_openFlashChartView::__construct(); 
     501                 
     502                return; 
     503        } 
     504         
     505        function __construct() { 
     506                 
     507                return parent::__construct(); 
     508                 
     509        } 
     510         
     511        function construct($data) { 
     512                 
     513                // load template 
     514                $this->t->set_template('wrapper_blank.tpl'); 
     515                $this->body->set_template('ofc.tpl'); 
     516                // set 
     517                $this->body->set('widget', $data['widget']); 
     518                $this->body->set('height', $data['height']); 
     519                $this->body->set('width', $data['width']); 
     520                 
     521                return; 
     522         
     523        } 
     524 
     525} 
    463526 
    464527?>