public function __construct($smConf = array(), $filter = true) { parent::__construct(); if (count($smConf) == 0) { $smConf = Piwik_Config::getInstance()->smarty; } foreach ($smConf as $key => $value) { $this->{$key} = $value; } $this->template_dir = $smConf['template_dir']; array_walk($this->template_dir, array("Piwik_Smarty", "addPiwikPath"), PIWIK_INCLUDE_PATH); $this->plugins_dir = $smConf['plugins_dir']; array_walk($this->plugins_dir, array("Piwik_Smarty", "addPiwikPath"), PIWIK_INCLUDE_PATH); $this->compile_dir = $smConf['compile_dir']; Piwik_Smarty::addPiwikPath($this->compile_dir, null, PIWIK_USER_PATH); $this->cache_dir = $smConf['cache_dir']; Piwik_Smarty::addPiwikPath($this->cache_dir, null, PIWIK_USER_PATH); $error_reporting = $smConf['error_reporting']; if ($error_reporting != (string) (int) $error_reporting) { $error_reporting = self::bitwise_eval($error_reporting); } $this->error_reporting = $error_reporting; if ($filter) { $this->load_filter('output', 'cachebuster'); $use_ajax_cdn = Piwik_Config::getInstance()->General['use_ajax_cdn']; if ($use_ajax_cdn) { $this->load_filter('output', 'ajaxcdn'); } $this->load_filter('output', 'trimwhitespace'); } }
public function renderReport($processedReport) { $isGoalPluginEnabled = Piwik_Common::isGoalPluginEnabled(); $prettyDate = $processedReport['prettyDate']; $reportData = $processedReport['reportData']; $evolutionMetrics = array(); $multiSitesAPIMetrics = Piwik_MultiSites_API::getApiMetrics($enhanced = true); foreach ($multiSitesAPIMetrics as $metricSettings) { $evolutionMetrics[] = $metricSettings[Piwik_MultiSites_API::METRIC_EVOLUTION_COL_NAME_KEY]; } // no decimal for all metrics to shorten SMS content (keeps the monetary sign for revenue metrics) $reportData->filter('ColumnCallbackReplace', array(array_merge(array_keys($multiSitesAPIMetrics), $evolutionMetrics), create_function('$value', ' return preg_replace_callback ( FLOAT_REGEXP, create_function ( \'$matches\', \'return round($matches[0]);\' ), $value ); '))); // evolution metrics formatting : // - remove monetary, percentage and white spaces to shorten SMS content // (this is also needed to be able to test $value != 0 and see if there is an evolution at all in SMSReport.tpl) // - adds a plus sign $reportData->filter('ColumnCallbackReplace', array($evolutionMetrics, create_function('$value', ' $matched = preg_match(FLOAT_REGEXP, $value, $matches); return $matched ? sprintf("%+d",$matches[0]) : $value; '))); $dataRows = $reportData->getRows(); $reportMetadata = $processedReport['reportMetadata']; $reportRowsMetadata = $reportMetadata->getRows(); $siteHasECommerce = array(); foreach ($reportRowsMetadata as $rowMetadata) { $idSite = $rowMetadata->getColumn('idsite'); $siteHasECommerce[$idSite] = Piwik_Site::isEcommerceEnabledFor($idSite); } $smarty = new Piwik_Smarty(); $smarty->assign("isGoalPluginEnabled", $isGoalPluginEnabled); $smarty->assign("reportRows", $dataRows); $smarty->assign("reportRowsMetadata", $reportRowsMetadata); $smarty->assign("prettyDate", $prettyDate); $smarty->assign("siteHasECommerce", $siteHasECommerce); $smarty->assign("displaySiteName", $processedReport['metadata']['action'] == 'getAll'); $this->rendering .= $smarty->fetch(PIWIK_USER_PATH . '/plugins/MobileMessaging/templates/SMSReport.tpl'); }
protected function initSettings($smConf) { if (count($smConf) == 0) { $smConf = Piwik_Config::getInstance()->smarty; } foreach ($smConf as $key => $value) { $this->{$key} = $value; } $this->template_dir = $smConf['template_dir']; array_walk($this->template_dir, array("Piwik_Smarty", "addPiwikPath"), PIWIK_INCLUDE_PATH); $this->plugins_dir = $smConf['plugins_dir']; array_walk($this->plugins_dir, array("Piwik_Smarty", "addPiwikPath"), PIWIK_INCLUDE_PATH); $this->compile_dir = $smConf['compile_dir']; Piwik_Smarty::addPiwikPath($this->compile_dir, null, PIWIK_USER_PATH); $this->cache_dir = $smConf['cache_dir']; Piwik_Smarty::addPiwikPath($this->cache_dir, null, PIWIK_USER_PATH); $error_reporting = $smConf['error_reporting']; if ($error_reporting != (string) (int) $error_reporting) { $error_reporting = self::bitwise_eval($error_reporting); } $this->error_reporting = $error_reporting; Piwik_PostEvent('Smarty.initSettings', $this); }
private function epilogue() { $smarty = new Piwik_Smarty(); $this->rendering .= $smarty->fetch(self::prefixTemplatePath("html_report_footer.tpl")); }