Piwik\Plugins\ScheduledReports\API::getReportFormats PHP Method

getReportFormats() public static method

public static getReportFormats ( $reportType )
    public static function getReportFormats($reportType)
    {
        $reportFormats = array();
        /**
         * Triggered when gathering all available scheduled report formats.
         *
         * Plugins that provide their own scheduled report format should use
         * this event to make their format available.
         *
         * @param array &$reportFormats An array mapping string IDs for each available
         *                              scheduled report format with icon paths for those
         *                              formats. Add your new format's ID to this array.
         * @param string $reportType A string ID describing how the report is sent, eg,
         *                           `'sms'` or `'email'`.
         */
        Piwik::postEvent(self::GET_REPORT_FORMATS_EVENT, array(&$reportFormats, $reportType));
        return $reportFormats;
    }

Usage Example

Esempio n. 1
0
 public function index()
 {
     $view = new View('@ScheduledReports/index');
     $this->setGeneralVariablesView($view);
     $view->countWebsites = count(APISitesManager::getInstance()->getSitesIdWithAtLeastViewAccess());
     // get report types
     $reportTypes = API::getReportTypes();
     $view->reportTypes = $reportTypes;
     $view->defaultReportType = self::DEFAULT_REPORT_TYPE;
     $view->defaultReportFormat = ScheduledReports::DEFAULT_REPORT_FORMAT;
     $view->displayFormats = ScheduledReports::getDisplayFormats();
     $reportsByCategoryByType = array();
     $reportFormatsByReportType = array();
     $allowMultipleReportsByReportType = array();
     foreach ($reportTypes as $reportType => $reportTypeIcon) {
         // get report formats
         $reportFormatsByReportType[$reportType] = API::getReportFormats($reportType);
         $allowMultipleReportsByReportType[$reportType] = API::allowMultipleReports($reportType);
         // get report metadata
         $reportsByCategory = array();
         $availableReportMetadata = API::getReportMetadata($this->idSite, $reportType);
         foreach ($availableReportMetadata as $reportMetadata) {
             $reportsByCategory[$reportMetadata['category']][] = $reportMetadata;
         }
         $reportsByCategoryByType[$reportType] = $reportsByCategory;
     }
     $view->reportsByCategoryByReportType = $reportsByCategoryByType;
     $view->reportFormatsByReportType = $reportFormatsByReportType;
     $view->allowMultipleReportsByReportType = $allowMultipleReportsByReportType;
     $reports = array();
     $reportsById = array();
     if (!Piwik::isUserIsAnonymous()) {
         $reports = API::getInstance()->getReports($this->idSite, $period = false, $idReport = false, $ifSuperUserReturnOnlySuperUserReports = true);
         foreach ($reports as &$report) {
             $report['recipients'] = API::getReportRecipients($report);
             $reportsById[$report['idreport']] = $report;
         }
     }
     $view->reports = $reports;
     $view->reportsJSON = Common::json_encode($reportsById);
     $view->downloadOutputType = API::OUTPUT_INLINE;
     $view->periods = ScheduledReports::getPeriodToFrequency();
     $view->defaultPeriod = ScheduledReports::DEFAULT_PERIOD;
     $view->defaultHour = ScheduledReports::DEFAULT_HOUR;
     $view->language = LanguagesManager::getLanguageCodeForCurrentUser();
     $view->segmentEditorActivated = false;
     if (API::isSegmentEditorActivated()) {
         $savedSegmentsById = array();
         foreach (APISegmentEditor::getInstance()->getAll($this->idSite) as $savedSegment) {
             $savedSegmentsById[$savedSegment['idsegment']] = $savedSegment['name'];
         }
         $view->savedSegmentsById = $savedSegmentsById;
         $view->segmentEditorActivated = true;
     }
     return $view->render();
 }