getReportMetadata() 공개 정적인 메소드

public static getReportMetadata ( $idSite, $reportType )
예제 #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();
 }
예제 #2
0
파일: Fixture.php 프로젝트: igorclark/piwik
 /**
  * Create three MAIL and two MOBILE scheduled reports
  *
  * Reports sent by mail can contain PNG graphs when the user specifies it.
  * Depending on the system under test, generated images differ slightly.
  * Because of this discrepancy, PNG graphs are only tested if the system under test
  * has the characteristics described in 'canImagesBeIncludedInScheduledReports'.
  * See tests/README.md for more detail.
  *
  * @see canImagesBeIncludedInScheduledReports
  * @param int $idSite id of website created
  */
 public static function setUpScheduledReports($idSite)
 {
     // fake access is needed so API methods can call Piwik::getCurrentUserLogin(), e.g: 'ScheduledReports.addReport'
     $pseudoMockAccess = new FakeAccess();
     FakeAccess::$superUser = true;
     Access::setSingletonInstance($pseudoMockAccess);
     // retrieve available reports
     $availableReportMetadata = APIScheduledReports::getReportMetadata($idSite, ScheduledReports::EMAIL_TYPE);
     $availableReportIds = array();
     foreach ($availableReportMetadata as $reportMetadata) {
         $availableReportIds[] = $reportMetadata['uniqueId'];
     }
     //@review should we also test evolution graphs?
     // set-up mail report
     APIScheduledReports::getInstance()->addReport($idSite, 'Mail Test report', 'day', 0, ScheduledReports::EMAIL_TYPE, ReportRenderer::HTML_FORMAT, $availableReportIds, array(ScheduledReports::DISPLAY_FORMAT_PARAMETER => ScheduledReports::DISPLAY_FORMAT_TABLES_ONLY));
     // set-up sms report for one website
     APIScheduledReports::getInstance()->addReport($idSite, 'SMS Test report, one website', 'day', 0, MobileMessaging::MOBILE_TYPE, MobileMessaging::SMS_FORMAT, array("MultiSites_getOne"), array("phoneNumbers" => array()));
     // set-up sms report for all websites
     APIScheduledReports::getInstance()->addReport($idSite, 'SMS Test report, all websites', 'day', 0, MobileMessaging::MOBILE_TYPE, MobileMessaging::SMS_FORMAT, array("MultiSites_getAll"), array("phoneNumbers" => array()));
     if (self::canImagesBeIncludedInScheduledReports()) {
         // set-up mail report with images
         APIScheduledReports::getInstance()->addReport($idSite, 'Mail Test report', 'day', 0, ScheduledReports::EMAIL_TYPE, ReportRenderer::HTML_FORMAT, $availableReportIds, array(ScheduledReports::DISPLAY_FORMAT_PARAMETER => ScheduledReports::DISPLAY_FORMAT_TABLES_AND_GRAPHS));
         // set-up mail report with one row evolution based png graph
         APIScheduledReports::getInstance()->addReport($idSite, 'Mail Test report', 'day', 0, ScheduledReports::EMAIL_TYPE, ReportRenderer::HTML_FORMAT, array('Actions_getPageTitles'), array(ScheduledReports::DISPLAY_FORMAT_PARAMETER => ScheduledReports::DISPLAY_FORMAT_GRAPHS_ONLY, ScheduledReports::EVOLUTION_GRAPH_PARAMETER => 'true'));
     }
 }