addCustomTag(''); $document -> addCustomTag(''); $document -> addCustomTag(''); $document -> addCustomTag(''); $model = &$this->getModel('statistics'); $category = JRequest::getVar('category', 'publications'); $chart = JRequest::getVar('chart', 'programme'); $type = JRequest::getVar('type', 'bar'); if ($category == 'evaluation' && $chart == 'access') { //$fullStats = $model->getEvaluationStatistics(); $fullStats = $this->getStats(); $data = array(); foreach ($fullStats->embargoDocs->lines as $line) { $data[] = array($line->name->value => $line->values[0]->value); } $data[] = array('Open Access' => $fullStats->openAccessDocs); $this->assignRef('data', $data); parent::display('pie'); return; } else { $stats = $this->getStats(); } $categories = array(); $series = array(); $xhartTitle = 'TITLE'; $yAxisTtile = 'yAxis'; $stacking = null; // null, 'normal', 'percent' switch ($chart) { case 'programme': $stats = $stats->pubStats->programmeStats; $chartTitle = 'Publications/Projects per programme'; break; case 'subdivision': $chartTitle = 'Publications/Projects per scientific area'; $stats = $stats->pubStats->subdivisionStats; break; case 'country': $chartTitle = 'Publications/Projects per country'; $stats = $stats->pubStats->countryStats; break; case 'organization': $chartTitle = 'Publications/Projects per institution'; $stats = $stats->pubStats->organizationStats; break; } $chartSubTitle = ''; $seriesIndex = array(0, 1, 4); $lines = $stats->lines; $categoryMap = array(); foreach (array_slice($lines, 0, 15, true) as $line) { $catLabel = (strlen($line->name->label) > 4)?substr($line->name->label, 0, 4).'...':$line->name->label; $categoryMap[$catLabel] = $line->name->value; $categories[] = $catLabel; foreach ($seriesIndex as $index) { $series[$line->values[$index]->label][] = str_replace('\'', '\\\'', $line->values[$index]->value); } } $this->assignRef('chartTitle', $chartTitle); $this->assignRef('chartSubTitle', $chartSubTitle); $this->assignRef('type', $type); $this->assignRef('stacking', $stacking); $this->assignRef('categories', $categories); $this->assignRef('categoryMap', $categoryMap); $this->assignRef('series', $series); parent::display($tpl); } private function getStats() { $model = &$this->getModel('statistics'); $cache = & JFactory::getCache('com_openaire', 'callback'); $conf =& JFactory::getConfig(); $cacheactive = $conf->getValue('config.caching'); $cache->setCaching(1); //enable caching $stats = $cache->call(array($model, 'getEvaluationStatistics')); $cache->setCaching($cacheactive); return $stats; } } ?>