From e174ad8131864747763728f7da56dfcb21574a88 Mon Sep 17 00:00:00 2001 From: padams Date: Thu, 17 Mar 2011 20:52:07 +0000 Subject: [PATCH] adding various stubs for segmentation. --- modules/base/classes/resultSetManager.php | 207 +++++++++++++++++--- modules/base/js/owa.report.js | 2 +- modules/base/js/owa.resultSetExplorer.js | 30 ++- modules/base/js/owa.tracker-combined-min.js | 6 +- modules/base/js/owa.tracker.js | 2 +- modules/base/templates/report_document.tpl | 2 +- owa_base.php | 8 +- owa_coreAPI.php | 45 +++-- owa_db.php | 15 +- owa_metric.php | 34 ++-- owa_module.php | 12 +- owa_view.php | 4 +- 12 files changed, 288 insertions(+), 79 deletions(-) diff --git a/modules/base/classes/resultSetManager.php b/modules/base/classes/resultSetManager.php index 70d2c837c..8f2e6fe33 100644 --- a/modules/base/classes/resultSetManager.php +++ b/modules/base/classes/resultSetManager.php @@ -97,8 +97,10 @@ class owa_resultSetManager extends owa_base { var $query_params = array(); var $baseEntity; var $metricObjectsByEntityMap = array(); + var $metricObjectsCache = array(); var $errors = array(); var $formatters = array(); + var $segment; function __construct($db = '') { @@ -184,34 +186,137 @@ function applyConstraints() { foreach ($this->getConstraints() as $k => $constraint) { - $dim = $this->lookupDimension($constraint['name'], $this->baseEntity); + // refactor to support metrics in constraints - //$dimEntity = owa_coreAPI::entityFactory($dim['entity']); + if ( $this->isDimension( $constraint['name'] ) ) { + $dim = $this->lookupDimension($constraint['name'], $this->baseEntity); + + //$dimEntity = owa_coreAPI::entityFactory($dim['entity']); + + + $col = $dim['column']; + $constraint['name'] = $col; + $nconstraints[$col] = $constraint; + + } + + if ( $this->isMetric( $constraint['name'] ) ) { + + // get metric object + //$m = $this->metricObjectsByEntityMap[$this->baseEntity->getName()][$metric_name]; + // if not calculated + if ( ! $m->isCalculated() ) { + $col = $m->getSelectWithNoAlias(); + $constraint['name'] = $col; + $nconstraints[$col] = $constraint; + } + } - $col = $dim['column']; - $constraint['name'] = $col; - $nconstraints[$col] = $constraint; - $this->db->multiWhere($nconstraints); //print_r($nconstraints); } + $this->db->multiWhere($nconstraints); + + } + + function setSegment($segment) { + + if ( ! strpos( $segment, 'dynamic' ) ) { + // look up segment from db + $segment = 'something from db'; + } + + $parsed = $this->constraintsStringToArray( $segment ); + $metrics = array(); + $dimensions = array(); + + foreach ( $parsed as $item ) { + + if ( $this->isMetric( $item['name'] ) ) { + $metrics[$item['name']] = $item; + + // add to all metrics or dimensions array - needed to determin base entity + if ( ! in_array($item['name'], $this->allMetrics) ) { + $this->allMetrics[] = $item['name']; + } + + if ( ! in_array($item['name'], $this->allDimensions) ) { + $this->allDimensions[] = $item['name']; + } + + } elseif ($this->isDimension( $item['name'] ) ) { + $dimensions[$item['name']] = $item; + } + } + + $this->segment = array('metrics' => $metrics, 'dimensions' => $dimensions); + } + + function getMetricNamesFromSegment() { + + if ( isset($this->segment['metrics'] ) ) { + + return array_keys($this->segment['metrics']); + } else { + + return array(); + } + } + + function getDimensionNamesFromSegment() { + + if ( isset( $this->segment['dimensions'] ) ) { + + return array_keys( $this->segment['dimensions'] ); + } else { + return array(); + } } + function generateSegmentTable( $base_entity ) { + + $rsm = new owa_resultSetManager; + + $rsm->setBaseEntity($base_entity); + //set metrics + $rsm->metrics = $this->getMetricNamesFromSegment(); + //set dimensions + $rsm->setDimensions( $this->getDimensionNamesFromSegment() ); + + if ( $rsm->dimensions ) { + $rsm->applyJoins(); + $rsm->applyDimensions(); + } + + //get all columns. need to optimize to just the columns needed + $rsm->db->select( '*' ); + $rsm->db->from( $base_entity->getTableName(), $base_entity->getTableAlias() ); + return $rsm->db->generateSelectQuerySql(); + } function chooseBaseEntity() { $metric_imps = array(); // load metric implementations - foreach ($this->metrics as $metric_name) { + $all_metrics = $this->metrics; + + // add in metrics from segment if present + if ( isset($this->segment['metrics'] ) ) { - $metric_imps = array_merge($this->getMetricEntities($metric_name), $metric_imps); + $all_metrics = array_unique( array_merge( $this->metrics, $this->getMetricNamesFromSegment() ) ); + } + + $all_metrics = array_unique( array_merge( $this->metrics, $this->getMetricNamesFromConstraints() ) ); + + foreach ($all_metrics as $metric_name) { + $metric_imps = array_merge($this->getMetricEntities($metric_name), $metric_imps); } - //print_r($metric_imps); + owa_coreAPI::debug('pre-reduce set of entities to choose from: '.print_r($metric_imps, true)); $entities = array(); @@ -251,7 +356,12 @@ function chooseBaseEntity() { $error = false; //cycle through each dimension frm dim list and those found in constraints. - $dims = array_unique(array_merge($this->dimensions, $this->getDimensionsFromConstraints())); + $dims = array_unique( array_merge( $this->dimensions, $this->getDimensionsFromConstraints() ) ); + + if ( isset( $this->segment['dimensions'] ) ) { + + $dims = array_unique( array_merge( $this->dimensions, $this->getDimensionNamesFromSegment() ) ); + } owa_coreAPI::debug(sprintf('Dimensions: %s',print_r($this->dimensions, true))); @@ -302,6 +412,11 @@ function getDimensionsFromConstraints() { return $dims; } + + function getMetricNamesFromConstraints() { + + return array(); + } function isDimensionRelated($dimension_name, $entity_name) { @@ -328,6 +443,7 @@ function isDimensionRelated($dimension_name, $entity_name) { } function getMetricEntities($metric_name) { + owa_coreAPI::debug("getting metric entities for $metric_name"); //get the class implementations $s = owa_coreAPI::serviceSingleton(); @@ -340,17 +456,17 @@ function getMetricEntities($metric_name) { $m = owa_coreAPI::metricFactory($map['class'], $map['params']); // check to see if this is a calculated metric - if ($m->isCalculated()) { - - foreach ($m->getChildMetrics() as $cmetric_name) { - $this->addCalculatedMetric($m); - $entities = array_merge($this->getMetricEntities($cmetric_name), $entities); - } - - } else { - $this->metricObjectsByEntityMap[$m->getEntityName()][$metric_name] = $m; - $entities[$metric_name][] = $m->getEntityName(); + if ($m->isCalculated()) { + + foreach ($m->getChildMetrics() as $cmetric_name) { + $this->addCalculatedMetric($m); + $entities = array_merge($this->getMetricEntities($cmetric_name), $entities); } + + } else { + $this->metricObjectsByEntityMap[$m->getEntityName()][$metric_name] = $m; + $entities[$metric_name][] = $m->getEntityName(); + } } @@ -391,6 +507,19 @@ function getDimensionForeignKey($dimension, $entity) { return $fk; } } + + function isDimension( $name ) { + + $dims = owa_coreAPI::getAllDimensions(); + //print_r($dims); + return in_array( $name, array_keys( $dims ) ); + } + + function isMetric( $name ) { + + $metrics = owa_coreAPI::getAllMetrics(); + return in_array( $name, array_keys( $metrics ) ); + } function lookupDimension($name, $entity) { @@ -1035,7 +1164,13 @@ function getResults() { $this->applyConstraints(); $this->applySelects(); - $this->db->selectFrom($bm->getTableName(), $bm->getTableAlias()); + // set from table + if ( $this->segment ) { + $this->db->selectFrom( $this->generateSegmentTable( $bm ), $bm->getTableAlias() ); + } else { + $this->db->selectFrom($bm->getTableName(), $bm->getTableAlias()); + } + // generate aggregate results $results = $this->db->getOneRow(); // merge into result set @@ -1045,13 +1180,19 @@ function getResults() { // setup dimensional query if (!empty($this->dimensions)) { + $this->applyJoins(); // apply dimensional SQL $this->applyDimensions(); $this->applySelects(); - - $this->db->selectFrom($bm->getTableName(), $bm->getTableAlias()); + + // set from table + if ( $this->segment ) { + $this->db->selectFrom( $this->generateSegmentTable( $bm ), $bm->getTableAlias() ); + } else { + $this->db->selectFrom($bm->getTableName(), $bm->getTableAlias()); + } // pass limit to db object if one exists if (!empty($this->limit)) { @@ -1212,13 +1353,27 @@ function evalFormula($formula) { return $value; } + /** + * Return the approraite metric implementation for the baseEntity + * Must be called after the base entity has been determined + * + * @param string $name the name of the metric + * + */ function getMetric($name) { - if (in_array($name, $this->metrics)) { - return $this->metricObjectsByEntityMap[$this->baseEntity->getName()][$name]; - } + // check to see if the entity object map is loaded + if ( ! in_array( $name, $this->metrics ) ) { + // if not load it forthat metric + $this->getMetricEntities($name); + } + + return $this->metricObjectsByEntityMap[$this->baseEntity->getName()][$name]; + } + + function setQueryStringParam($name, $string) { $this->query_params[$name] = $string; diff --git a/modules/base/js/owa.report.js b/modules/base/js/owa.report.js index c8c8e4105..38ef910a8 100644 --- a/modules/base/js/owa.report.js +++ b/modules/base/js/owa.report.js @@ -18,7 +18,7 @@ OWA.report.prototype = { // ... // bind event handlers - that = this; + var that = this; jQuery('#owa_reportSiteFilterSelect').change( function() { that.reload(); } ); jQuery("#owa_reportPeriodFilterSubmit").click( function() { that.reload(); } ); }, diff --git a/modules/base/js/owa.resultSetExplorer.js b/modules/base/js/owa.resultSetExplorer.js index 12b7d4ccf..07d1ffdab 100644 --- a/modules/base/js/owa.resultSetExplorer.js +++ b/modules/base/js/owa.resultSetExplorer.js @@ -188,7 +188,7 @@ OWA.resultSetExplorer.prototype = { }, refreshGrid : function() { - + var that = this; // custom formattter functions. @@ -201,15 +201,25 @@ OWA.resultSetExplorer.prototype = { //var name = 'actionName'; //alert(that.columnLinks[name].template); OWA.debug(options.rowId-1+' '+name); - //var new_url = that.columnLinks[name].template.replace('%s', escape(sub_value)); - var new_url = that.resultSet.resultsRows[options.rowId-1][name].link; - var link = '' + cellvalue + ''; - return link; + //var new_url = that.columnLinks[name].template.replace('%s', escape(sub_value)); + //alert(JSON.stringify(that.resultSet.resultsRows[options.rowId-1])); + //alert(options.rowId-1); + //alert(name); + //alert(JSON.stringify(cellvalue)); + //alert(JSON.stringify(options.colModel.link_template)); + //alert(JSON.stringify(rowdata)); + if ( rowdata[name].link.length > 0 ) { + var new_url = rowdata[name].link; + //var new_url = that.resultSet.resultsRows[options.rowId-1][name].link; + var link = '' + cellvalue + ''; + return link; + } }, useServerFormatter : function(cellvalue, options, rowdata) { var name = options.colModel.realColName; - return that.resultSet.resultsRows[options.rowId-1][name].formatted_value; + return rowdata[name].formatted_value; + //return that.resultSet.resultsRows[options.rowId-1][name].formatted_value; } }); @@ -404,6 +414,7 @@ OWA.resultSetExplorer.prototype = { var _resizable = true; var _fixed = false; var _datefmt = ''; + var _link_template = ''; if (column.result_type === 'dimension') { _align = 'left'; @@ -432,6 +443,10 @@ OWA.resultSetExplorer.prototype = { if (this.options.grid.columnFormatters.hasOwnProperty(column.name)) { _format = this.options.grid.columnFormatters[column.name]; } + + if ( this.columnLinks.hasOwnProperty( column.name ) ) { + _link_template = this.columnLinks[column.name].template; + } var columnDef = { name: column.name +'.value', @@ -445,7 +460,8 @@ OWA.resultSetExplorer.prototype = { resizable: _resizable, fixed: _fixed, realColName: column.name, - datefmt: _datefmt + datefmt: _datefmt, + link_template: _link_template }; return columnDef; diff --git a/modules/base/js/owa.tracker-combined-min.js b/modules/base/js/owa.tracker-combined-min.js index 57491d81e..a32701df5 100644 --- a/modules/base/js/owa.tracker-combined-min.js +++ b/modules/base/js/owa.tracker-combined-min.js @@ -1,4 +1,4 @@ -// OWA Tracker Min file created 1299269531 +// OWA Tracker Min file created 1300394369 //// Start of json2 //// @@ -115,7 +115,7 @@ OWA.debug('cmd queue object name %s',obj_name);OWA.debug('cmd queue object metho window[obj_name][method].apply(window[obj_name],args);},loadCmds:function(cmds){this.asyncCmds=cmds;},process:function(){for(var i=0;i0){this.page.merge(owa_params);}}} -OWA.tracker.prototype={id:'',siteId:'',init:0,stateInit:false,globalEventProperties:{},sharableStateStores:['v','s','c'],startTime:null,endTime:null,campaignState:[],isNewCampaign:false,isNewSessionFlag:false,isTrafficAttributed:false,cookie_names:['owa_s','owa_v','owa_c'],linkedStateSet:false,hashCookiesToDomain:true,organicSearchEngines:[{d:'google',q:'q'},{d:'yahoo',q:'p'},{d:'yahoo',q:'q'},{d:'msn',q:'q'},{d:'bing',q:'q'},{d:'images.google',q:'q'},{d:'aol',q:'query'},{d:'aol',q:'encquery'},{d:'aol',q:'q'},{d:'lycos',q:'query'},{d:'ask',q:'q'},{d:'altavista',q:'q'},{d:'netscape',q:'query'},{d:'cnn',q:'query'},{d:'about',q:'terms'},{d:'mamma',q:'q'},{d:'daum',q:'q'},{d:'eniro',q:'search_word'},{d:'naver',q:'query'},{d:'pchome',q:'q'},{d:'alltheweb',q:'q'},{d:'voila',q:'rdata'},{d:'virgilio',q:'qs'},{d:'live',q:'q'},{d:'baidu',q:'wd'},{d:'alice',q:'qs'},{d:'yandex',q:'text'},{d:'najdi',q:'q'},{d:'mama',q:'query'},{d:'seznam',q:'q'},{d:'search',q:'q'},{d:'wp',q:'szukaj'},{d:'onet',q:'qt'},{d:'szukacz',q:'q'},{d:'yam',q:'k'},{d:'kvasir',q:'q'},{d:'sesam',q:'q'},{d:'ozu',q:'q'},{d:'terra',q:'query'},{d:'mynet',q:'q'},{d:'ekolay',q:'q'},{d:'rambler',q:'query'},{d:'rambler',q:'words'}],urlParams:{},streamBindings:['bindMovementEvents','bindScrollEvents','bindKeypressEvents','bindClickEvents'],page:'',click:'',domstream:'',movement:'',keystroke:'',hover:'',last_event:'',last_movement:'',event_queue:[],player:'',overlay:'',setDebug:function(bool){OWA.setSetting('debug',bool);},checkForLinkedState:function(){if(this.linkedStateSet!=true){var ls=this.getUrlParam('owa_state');if(!ls){ls=this.getAnchorParam('owa_state');} +OWA.tracker.prototype={id:'',siteId:'',init:0,stateInit:false,globalEventProperties:{},sharableStateStores:['v','s','c','b'],startTime:null,endTime:null,campaignState:[],isNewCampaign:false,isNewSessionFlag:false,isTrafficAttributed:false,cookie_names:['owa_s','owa_v','owa_c'],linkedStateSet:false,hashCookiesToDomain:true,organicSearchEngines:[{d:'google',q:'q'},{d:'yahoo',q:'p'},{d:'yahoo',q:'q'},{d:'msn',q:'q'},{d:'bing',q:'q'},{d:'images.google',q:'q'},{d:'aol',q:'query'},{d:'aol',q:'encquery'},{d:'aol',q:'q'},{d:'lycos',q:'query'},{d:'ask',q:'q'},{d:'altavista',q:'q'},{d:'netscape',q:'query'},{d:'cnn',q:'query'},{d:'about',q:'terms'},{d:'mamma',q:'q'},{d:'daum',q:'q'},{d:'eniro',q:'search_word'},{d:'naver',q:'query'},{d:'pchome',q:'q'},{d:'alltheweb',q:'q'},{d:'voila',q:'rdata'},{d:'virgilio',q:'qs'},{d:'live',q:'q'},{d:'baidu',q:'wd'},{d:'alice',q:'qs'},{d:'yandex',q:'text'},{d:'najdi',q:'q'},{d:'mama',q:'query'},{d:'seznam',q:'q'},{d:'search',q:'q'},{d:'wp',q:'szukaj'},{d:'onet',q:'qt'},{d:'szukacz',q:'q'},{d:'yam',q:'k'},{d:'kvasir',q:'q'},{d:'sesam',q:'q'},{d:'ozu',q:'q'},{d:'terra',q:'query'},{d:'mynet',q:'q'},{d:'ekolay',q:'q'},{d:'rambler',q:'query'},{d:'rambler',q:'words'}],urlParams:{},streamBindings:['bindMovementEvents','bindScrollEvents','bindKeypressEvents','bindClickEvents'],page:'',click:'',domstream:'',movement:'',keystroke:'',hover:'',last_event:'',last_movement:'',event_queue:[],player:'',overlay:'',setDebug:function(bool){OWA.setSetting('debug',bool);},checkForLinkedState:function(){if(this.linkedStateSet!=true){var ls=this.getUrlParam('owa_state');if(!ls){ls=this.getAnchorParam('owa_state');} if(ls){OWA.debug('Shared OWA state detected...');ls=OWA.util.base64_decode(OWA.util.urldecode(ls));OWA.debug('linked state: %s',ls);var state=ls.split('.');OWA.debug('linked state: %s',JSON.stringify(state));if(state){for(var i=0;state.length>i;i++){var pair=state[i].split('=');OWA.debug('pair: %s',pair);var value=OWA.util.urldecode(pair[1]);OWA.debug('pair: %s',value);decodedvalue=OWA.util.decodeCookieValue(value);var format=OWA.util.getCookieValueFormat(value);decodedvalue.cdh=OWA.util.getCookieDomainHash(this.getCookieDomain());OWA.replaceState(pair[0],decodedvalue,true,format);}}} this.linkedStateSet=true;}},shareStateByLink:function(url){OWA.debug('href of link: '+url);if(url){var state=this.createSharedStateValue();var anchor=this.getUrlAnchorValue();if(!anchor){OWA.debug('shared state: %s',state);document.location.href=url+'#owa_state.'+state;}else{}}},createSharedStateValue:function(){var state='';for(var i=0;this.sharableStateStores.length>i;i++){var value=OWA.getState(this.sharableStateStores[i]);value=OWA.util.encodeJsonForCookie(value,OWA.getStateStoreFormat(this.sharableStateStores[i]));if(value){state+=OWA.util.sprintf('%s=%s',this.sharableStateStores[i],OWA.util.urlEncode(value));if(this.sharableStateStores.length!=(i+1)){state+='.';}}} if(state){OWA.debug('linked state to send: %s',state);state=OWA.util.base64_encode(state);state=OWA.util.urlEncode(state);return state;}},shareShareByPost:function(form){var state=this.createSharedStateValue();form.action+='#owa_state.'+state;form.submit();},getCookieDomain:function(){return this.getOption('cookie_domain')||OWA.getSetting('cookie_domain')||document.domain;},setCookieDomain:function(domain){var not_passed=false;if(!domain){domain=document.domain;not_passed=true;} @@ -190,7 +190,7 @@ OWA.setState('s','last_req',event.get('timestamp'),true);this.setGlobalEventProp if(prior_session_id){this.globalEventProperties.prior_session_id=prior_session_id;} this.resetSessionState();session_id=OWA.util.generateRandomGuid(this.getSiteId());this.globalEventProperties.session_id=session_id;this.globalEventProperties.is_new_session=true;this.isNewSessionFlag=true;OWA.setState('s','sid',session_id,true);}else{session_id=OWA.getState('s','sid');if(!session_id){state_store_name=OWA.util.sprintf('%s_%s','ss',this.getSiteId());session_id=OWA.getState(state_store_name,'s');OWA.setState('s','sid',session_id,true);} this.globalEventProperties.session_id=session_id;} -if(!this.getGlobalEventProperty('session_id')){session_id=OWA.util.generateRandomGuid(this.getSiteId());this.globalEventProperties.session_id=session_id;this.globalEventProperties.is_new_session=true;this.isNewSessionFlag=true;OWA.setState('s','sid',session_id,true);}},resetSessionState:function(){var last_req=OWA.setState('s','last_req');OWA.clearState('s');OWA.setState('s','last_req',last_req);},isNewSession:function(timestamp,last_req){var is_new_session=false;if(!timestamp){timestamp=OWA.util.getCurrentUnixTimestamp();} +if(!this.getGlobalEventProperty('session_id')){session_id=OWA.util.generateRandomGuid(this.getSiteId());this.globalEventProperties.session_id=session_id;this.globalEventProperties.is_new_session=true;this.isNewSessionFlag=true;OWA.setState('s','sid',session_id,true);}},resetSessionState:function(){var last_req=OWA.getState('s','last_req');OWA.clearState('s');OWA.setState('s','last_req',last_req);},isNewSession:function(timestamp,last_req){var is_new_session=false;if(!timestamp){timestamp=OWA.util.getCurrentUnixTimestamp();} if(!last_req){last_req=0;} var time_since_lastreq=timestamp-last_req;var len=this.options.sessionLength;if(time_since_lastreq65){OWA.debug('Custom variable name + value is too large. Must be less than 64 characters.');return;} switch(scope){case'session':OWA.util.setState('b',cv_param_name,cv_param_value);OWA.debug('just set custom var on session.');break;case'visitor':OWA.util.setState('v',cv_param_name,cv_param_value);OWA.util.clearState('b',cv_param_name);break;} diff --git a/modules/base/js/owa.tracker.js b/modules/base/js/owa.tracker.js index f159f564f..b3baddd9f 100644 --- a/modules/base/js/owa.tracker.js +++ b/modules/base/js/owa.tracker.js @@ -1877,7 +1877,7 @@ OWA.tracker.prototype = { resetSessionState : function() { - var last_req = OWA.setState( 's', 'last_req'); + var last_req = OWA.getState( 's', 'last_req'); OWA.clearState('s'); OWA.setState('s', 'last_req', last_req); }, diff --git a/modules/base/templates/report_document.tpl b/modules/base/templates/report_document.tpl index 94a428151..576f6c391 100644 --- a/modules/base/templates/report_document.tpl +++ b/modules/base/templates/report_document.tpl @@ -63,7 +63,7 @@ 'dimensions' => 'priorPagePath,priorPageTitle', 'sort' => 'visits-', 'resultsPerPage' => 15, - 'constraints' => 'pageUrl=='.urlencode($dimension_properties->get('url')), + 'constraints' => urlencode('pageUrl=='.$dimension_properties->get('url')), 'format' => 'json'), true);?>'; var prshre = new OWA.resultSetExplorer('priorpages'); diff --git a/owa_base.php b/owa_base.php index 44a57256a..4f6af74b2 100644 --- a/owa_base.php +++ b/owa_base.php @@ -71,13 +71,7 @@ class owa_base { * Base Constructor * * @return owa_base - */ - function owa_base() { - - return owa_base::__construct(); - - } - + */ function __construct() { owa_coreAPI::profile($this, __FUNCTION__, __LINE__); $this->e = &owa_coreAPI::errorSingleton(); diff --git a/owa_coreAPI.php b/owa_coreAPI.php index 5948d7cc1..9a6492357 100644 --- a/owa_coreAPI.php +++ b/owa_coreAPI.php @@ -104,15 +104,14 @@ public static function &configSingleton($params = array()) { static $config; - if(!isset($config)): + if( ! isset( $config ) ) { - if (!class_exists('owa_settings')): - require_once(OWA_BASE_CLASS_DIR.'settings.php'); - endif; - - $config = owa_coreAPI::supportClassFactory('base', 'settings'); + if ( ! class_exists( 'owa_settings' ) ) { + require_once( OWA_BASE_CLASS_DIR.'settings.php' ); + } - endif; + $config = owa_coreAPI::supportClassFactory( 'base', 'settings' ); + } return $config; } @@ -121,13 +120,13 @@ public static function &errorSingleton() { static $e; - if(!$e) { + if( ! $e ) { - if (!class_exists('owa_error')): - require_once(OWA_BASE_CLASS_DIR.'error.php'); - endif; + if ( ! class_exists( 'owa_error' ) ) { + require_once( OWA_BASE_CLASS_DIR.'error.php' ); + } - $e = owa_coreAPI::supportClassFactory('base', 'error'); + $e = owa_coreAPI::supportClassFactory( 'base', 'error' ); } @@ -1332,6 +1331,28 @@ public static function generateInstanceSpecificHash() { return md5( $salt ); } + + public static function getAllDimensions() { + + $s = owa_coreAPI::serviceSingleton(); + + $dims = $s->dimensions; + + foreach ( $s->denormalizedDimensions as $k => $entity_dims ) { + foreach ($entity_dims as $entity => $dedim) { + $dims[$k] = $dedim; + } + } + + return $dims; + } + + public static function getAllMetrics() { + + $s = owa_coreAPI::serviceSingleton(); + return $s->metrics; + } + } ?> \ No newline at end of file diff --git a/owa_db.php b/owa_db.php index 98fdb9750..705171d09 100644 --- a/owa_db.php +++ b/owa_db.php @@ -411,8 +411,8 @@ function _insertQuery() { } - function _selectQuery() { - + function generateSelectQuerySql() { + $cols = ''; $i = 0; $params = $this->_fetchSqlParams('select_values'); @@ -440,14 +440,21 @@ function _selectQuery() { } - $this->_setSql(sprintf("SELECT %s FROM %s %s %s %s %s", + $sql = sprintf("SELECT %s FROM %s %s %s %s %s", $cols, $this->_makeFromClause(), $this->_makeWhereClause(), $this->_makeGroupByClause(), $this->_makeOrderByClause(), $this->_makeLimitClause() - )); + ); + $this->_setSql($sql); + return $sql; + } + + function _selectQuery() { + + $this->generateSelectQuerySql(); return $this->_query(); } diff --git a/owa_metric.php b/owa_metric.php index be84be85a..9cb576c8d 100644 --- a/owa_metric.php +++ b/owa_metric.php @@ -104,9 +104,9 @@ function __construct($params = array()) { $this->params = $params; } - $this->db = owa_coreAPI::dbSingleton(); + //$this->db = owa_coreAPI::dbSingleton(); - $this->pagination = new owa_pagination; + //$this->pagination = new owa_pagination; return parent::__construct(); } @@ -116,6 +116,8 @@ function __construct($params = array()) { * @depricated * @remove */ + /* + function applyOptions($params) { // apply constraints @@ -325,9 +327,8 @@ function setEndDate($date) { endif; } - /** - * @depricated - */ + + //@depricated function generate($method = 'calculate') { $this->makeTimePeriod(); @@ -365,9 +366,8 @@ function generate($method = 'calculate') { } - /** - * @depricated - */ + + //@depricated function generateResults() { // set period specific constraints @@ -400,9 +400,7 @@ function generateResults() { return $rs; } - /** - * @depricated - */ + //@depricated function calculatePaginationCount() { if (method_exists($this, 'paginationCount')): @@ -416,6 +414,7 @@ function calculatePaginationCount() { endif; } +*/ /** * Set the labels of the measures * @@ -466,7 +465,8 @@ function getLabels() { return $this->labels; } - + /* + function getPagination() { $count = $this->calculatePaginationCount(); @@ -475,6 +475,7 @@ function getPagination() { } + */ function zeroFill(&$array) { // PHP 5 only function used here @@ -498,7 +499,8 @@ function addzero(&$v, $k) { return; } - + /* + function getPeriod() { return $this->params['period']; @@ -517,6 +519,7 @@ function getLimit() { } + */ function setEntity($name) { $this->entity = owa_coreAPI::entityFactory($name); @@ -547,6 +550,11 @@ function getSelect() { return $this->select; } + function getSelectWithNoAlias() { + + return $this->select[0]; + } + function setName($name) { $this->name = $name; diff --git a/owa_module.php b/owa_module.php index 80b7dceb6..77131eec4 100644 --- a/owa_module.php +++ b/owa_module.php @@ -668,9 +668,17 @@ function addEventProcessor($event_type, $processor) { return; } - function registerMetric($metric_name, $class_name, $params = array()) { + function registerMetric($metric_name, $class_name, $params = array(), $label = '', $description = '') { - $map = array('class' => $class_name, 'params' => $params); + if ( ! $label ) { + $label = $metric_name; + } + + if ( ! $description ) { + $description = 'No description available.'; + } + + $map = array('class' => $class_name, 'params' => $params, 'label' => $label, 'description' => $description); $this->metrics[$metric_name][] = $map; } diff --git a/owa_view.php b/owa_view.php index c30cd4aa1..48527a157 100644 --- a/owa_view.php +++ b/owa_view.php @@ -381,7 +381,7 @@ function setCss($path) { $url = owa_coreAPI::getSetting('base', 'modules_url').$path; $this->css[] = $url; - return; + return true; } function setJs($name, $path, $version ='', $deps = array(), $ie_only = false) { @@ -402,7 +402,7 @@ function setJs($name, $path, $version ='', $deps = array(), $ie_only = false) { $this->js[$uid]['version'] = $version; $this->js[$uid]['ie_only'] = $ie_only; - return; + return true; } function concatinateJs() {