public function __construct() { parent::__construct(); }
/** * Returns HTML for a SponsorshipDashboard chart of the data that queryString gets from the database. * * The query is expected to return "number" and "creation_date" fields in each row. * * @param queryString - string - query to run whose 'number' and 'creation_date' fields will be charted. * @param frequency - enum - defined value of SponsorshipDashboardDateProvider::SD_FREQUENCY_<something>. * @param uniqueMemCacheKey - string - key under which the processed results of the query will be cached. * @param metricName - string - the name of the line of data which will be generated by the query (charts could have many lines in some cases). * @param chartName - string - the name of the whole chart. */ public static function getChartHtmlByQuery($queryString, $frequency, $uniqueMemCacheKey, $metricName, $chartName) { wfProfileIn(__METHOD__); //lets create data source $oSource = new SponsorshipDashboardSourceDatabase($uniqueMemCacheKey); // this name will be displayed in on a chart $oSource->serieName = $metricName; // configure the soruce ( source config depends on source type ) $dbr = wfGetDB(DB_SLAVE, array(), F::app()->wg->externalSharedDB); $oSource->setDatabase($dbr); $oSource->setQuery($queryString); $oSource->setFrequency($frequency); // so we have the source, lets configure the report object $oReport = new SponsorshipDashboardReport(); $oReport->name = $chartName; // this shows how many steps will be displayed on chart ( counting backwards from now ) $oReport->setLastDateUnits(30); // lest choose the time resolution $oReport->frequency = $frequency; // then pass ready source to report ( you can pass many sources ) $oReport->tmpSource = $oSource; $oReport->acceptSource(); $oReport->setId(0); $oReport->lockSources(); // now is the time for making output. There are chart, raw and table outputs. $oOutput = new SponsorshipDashboardOutputChart(); $oOutput->showActionsButton = false; $oOutput->emptyChartMsg = wfMsg('apigate-chart-empty'); $oOutput->set($oReport); // to get HTML just call $html = $oOutput->getHTML(false); // false stops it from setting the HTML <title> tag wfProfileOut(__METHOD__); return $html; }
protected function HTMLReport() { global $wgOut; $wgOut->addStyle(AssetsManager::getInstance()->getSassCommonURL('extensions/wikia/SponsorshipDashboard/css/SponsorshipDashboard.scss')); $this->displayHeader(); $chart = SponsorshipDashboardOutputChart::newFromReport($this->currentReport, $this->currentGroup); $table = SponsorshipDashboardOutputTable::newFromReport($this->currentReport); $wgOut->addHTML($chart->getHTML()); $wgOut->addHTML($table->getHTML()); return false; }
public function returnChartData() { $this->loadSources(); $oOutput = SponsorshipDashboardOutputChart::newFromReport($this); return $oOutput->getChartData(); }