상속: extends PKPStatisticsHelper
 /**
  * @see ReportPlugin::display()
  */
 function display($args, $request)
 {
     $router = $request->getRouter();
     $context = $router->getContext($request);
     $metricType = $this->getMetricTypes();
     import('classes.statistics.StatisticsHelper');
     $statsHelper = new StatisticsHelper();
     $columns = array_keys($statsHelper->getColumnNames());
     $reportArgs = array('metricType' => $metricType, 'columns' => $columns, 'filters' => serialize(array(STATISTICS_DIMENSION_CONTEXT_ID => $context->getId())), 'orderBy' => serialize(array(STATISTICS_DIMENSION_MONTH => STATISTICS_ORDER_ASC)));
     Request::redirect(null, null, 'tools', 'generateReport', $reportArgs);
 }
예제 #2
0
 /**
  * Constructor.
  * @param $argv array task arguments
  */
 function PKPUsageStatsLoader($args)
 {
     $plugin = PluginRegistry::getPlugin('generic', 'usagestatsplugin');
     /* @var $plugin UsageStatsPlugin */
     $this->_plugin = $plugin;
     if ($plugin->getSetting(CONTEXT_ID_NONE, 'compressArchives')) {
         $this->setCompressArchives(true);
     }
     $arg = current($args);
     switch ($arg) {
         case 'autoStage':
             if ($plugin->getSetting(0, 'createLogFiles')) {
                 $this->_autoStage = true;
             }
             break;
         case 'externalLogFiles':
             $this->_externalLogFiles = true;
             break;
     }
     // Define the base filesystem path.
     $args[0] = $plugin->getFilesPath();
     parent::FileLoader($args);
     if ($plugin->getEnabled()) {
         // Load the metric type constant.
         PluginRegistry::loadCategory('reports');
         import('classes.statistics.StatisticsHelper');
         $statsHelper = new StatisticsHelper();
         $geoLocationTool = $statsHelper->getGeoLocationTool();
         $this->_geoLocationTool = $geoLocationTool;
         $plugin->import('UsageStatsTemporaryRecordDAO');
         $statsDao = new UsageStatsTemporaryRecordDAO();
         DAORegistry::registerDAO('UsageStatsTemporaryRecordDAO', $statsDao);
         $this->_counterRobotsListFile = $this->_getCounterRobotListFile();
         $contextDao = Application::getContextDAO();
         /* @var $contextDao ContextDAO */
         $contextFactory = $contextDao->getAll();
         /* @var $contextFactory DAOResultFactory */
         $contextsByPath = array();
         while ($context = $contextFactory->next()) {
             /* @var $context Context */
             $contextsByPath[$context->getPath()] = $context;
         }
         $this->_contextsByPath = $contextsByPath;
         $this->checkFolderStructure(true);
     }
 }
 /**
  * Constructor.
  * @param $argv array task arguments
  */
 function UsageStatsLoader($args)
 {
     $plugin =& PluginRegistry::getPlugin('generic', 'usagestatsplugin');
     /* @var $plugin UsageStatsPlugin */
     $this->_plugin =& $plugin;
     $arg = current($args);
     switch ($arg) {
         case 'autoStage':
             if ($plugin->getSetting(0, 'createLogFiles')) {
                 $this->_autoStage = true;
             }
             break;
         case 'externalLogFiles':
             $this->_externalLogFiles = true;
             break;
     }
     // Define the base filesystem path.
     $args[0] = $plugin->getFilesPath();
     parent::FileLoader($args);
     if ($plugin->getEnabled()) {
         // Load the metric type constant.
         PluginRegistry::loadCategory('reports');
         $geoLocationTool =& StatisticsHelper::getGeoLocationTool();
         $this->_geoLocationTool =& $geoLocationTool;
         $plugin->import('UsageStatsTemporaryRecordDAO');
         $statsDao = new UsageStatsTemporaryRecordDAO();
         DAORegistry::registerDAO('UsageStatsTemporaryRecordDAO', $statsDao);
         $this->_counterRobotsListFile = $this->_getCounterRobotListFile();
         $journalDao =& DAORegistry::getDAO('JournalDAO');
         /* @var $journalDao JournalDAO */
         $journalFactory =& $journalDao->getJournals();
         /* @var $journalFactory DAOResultFactory */
         $journalsByPath = array();
         while ($journal =& $journalFactory->next()) {
             /* @var $journal Journal */
             $journalsByPath[$journal->getPath()] =& $journal;
         }
         $this->_journalsByPath = $journalsByPath;
         $this->checkFolderStructure(true);
     }
 }
 /**
  * Get report generator form object.
  * @return ReportGeneratorForm
  */
 function &_getReportGeneratorForm($request)
 {
     $router = $request->getRouter();
     $context = $router->getContext($request);
     $metricType = $request->getUserVar('metricType');
     if (!$metricType) {
         $metricType = $context->getDefaultMetricType();
     }
     $statsHelper = new StatisticsHelper();
     $reportPlugin = $statsHelper->getReportPluginByMetricType($metricType);
     if (!is_scalar($metricType) || !$reportPlugin) {
         fatalError('Invalid metric type.');
     }
     $columns = $reportPlugin->getColumns($metricType);
     $columns = array_flip(array_intersect(array_flip($statsHelper->getColumnNames()), $columns));
     $optionalColumns = $reportPlugin->getOptionalColumns($metricType);
     $optionalColumns = array_flip(array_intersect(array_flip($statsHelper->getColumnNames()), $optionalColumns));
     $objects = $reportPlugin->getObjectTypes($metricType);
     $objects = array_flip(array_intersect(array_flip($statsHelper->getObjectTypeString()), $objects));
     $defaultReportTemplates = $reportPlugin->getDefaultReportTemplates($metricType);
     // If the report plugin doesn't works with the file type column,
     // don't load file types.
     if (isset($columns[STATISTICS_DIMENSION_FILE_TYPE])) {
         $fileTypes = $statsHelper->getFileTypeString();
     } else {
         $fileTypes = null;
     }
     // Metric type will be presented in header, remove if any.
     if (isset($columns[STATISTICS_DIMENSION_METRIC_TYPE])) {
         unset($columns[STATISTICS_DIMENSION_METRIC_TYPE]);
     }
     $reportTemplate = $request->getUserVar('reportTemplate');
     import('controllers.statistics.form.ReportGeneratorForm');
     $reportGeneratorForm = new ReportGeneratorForm($columns, $optionalColumns, $objects, $fileTypes, $metricType, $defaultReportTemplates, $reportTemplate);
     return $reportGeneratorForm;
 }
예제 #5
0
 /**
  * Generate statistics reports from passed
  * request arguments.
  * @param $args array
  * @param $request PKPRequest
  */
 function generateReport($args, $request)
 {
     $this->setupTemplate($request);
     AppLocale::requireComponents(LOCALE_COMPONENT_PKP_SUBMISSION);
     $router = $request->getRouter();
     $context = $router->getContext($request);
     import('classes.statistics.StatisticsHelper');
     $statsHelper = new StatisticsHelper();
     $metricType = $request->getUserVar('metricType');
     if (is_null($metricType)) {
         $metricType = $context->getDefaultMetricType();
     }
     // Generates only one metric type report at a time.
     if (is_array($metricType)) {
         $metricType = current($metricType);
     }
     if (!is_scalar($metricType)) {
         $metricType = null;
     }
     $reportPlugin = $statsHelper->getReportPluginByMetricType($metricType);
     if (!$reportPlugin || is_null($metricType)) {
         $request->redirect(null, null, 'tools', 'statistics');
     }
     $columns = $request->getUserVar('columns');
     $filters = unserialize($request->getUserVar('filters'));
     if (!$filters) {
         $filters = $request->getUserVar('filters');
     }
     $orderBy = $request->getUserVar('orderBy');
     if ($orderBy) {
         $orderBy = unserialize($orderBy);
         if (!$orderBy) {
             $orderBy = $request->getUserVar('orderBy');
         }
     } else {
         $orderBy = array();
     }
     $metrics = $reportPlugin->getMetrics($metricType, $columns, $filters, $orderBy);
     $allColumnNames = $statsHelper->getColumnNames();
     $columnOrder = array_keys($allColumnNames);
     $columnNames = array();
     foreach ($columnOrder as $column) {
         if (in_array($column, $columns)) {
             $columnNames[$column] = $allColumnNames[$column];
         }
         if ($column == STATISTICS_DIMENSION_ASSOC_TYPE && in_array(STATISTICS_DIMENSION_ASSOC_ID, $columns)) {
             $columnNames['common.title'] = __('common.title');
         }
     }
     // Make sure the metric column will always be present.
     if (!in_array(STATISTICS_METRIC, $columnNames)) {
         $columnNames[STATISTICS_METRIC] = $allColumnNames[STATISTICS_METRIC];
     }
     header('content-type: text/comma-separated-values');
     header('content-disposition: attachment; filename=statistics-' . date('Ymd') . '.csv');
     $fp = fopen('php://output', 'wt');
     fputcsv($fp, array($reportPlugin->getDisplayName()));
     fputcsv($fp, array($reportPlugin->getDescription()));
     fputcsv($fp, array(__('common.metric') . ': ' . $metricType));
     fputcsv($fp, array(__('manager.statistics.reports.reportUrl') . ': ' . $request->getCompleteUrl()));
     fputcsv($fp, array(''));
     // Just for better displaying.
     $columnNames = array_merge(array(''), $columnNames);
     fputcsv($fp, $columnNames);
     foreach ($metrics as $record) {
         $row = array();
         foreach ($columnNames as $key => $name) {
             if (empty($name)) {
                 // Column just for better displaying.
                 $row[] = '';
                 continue;
             }
             // Give a chance for subclasses to set the row values.
             if ($returner = $this->getReportRowValue($key, $record)) {
                 $row[] = $returner;
                 continue;
             }
             switch ($key) {
                 case 'common.title':
                     $assocId = $record[STATISTICS_DIMENSION_ASSOC_ID];
                     $assocType = $record[STATISTICS_DIMENSION_ASSOC_TYPE];
                     $row[] = $this->getObjectTitle($assocId, $assocType);
                     break;
                 case STATISTICS_DIMENSION_ASSOC_TYPE:
                     $assocType = $record[STATISTICS_DIMENSION_ASSOC_TYPE];
                     $row[] = $statsHelper->getObjectTypeString($assocType);
                     break;
                 case STATISTICS_DIMENSION_CONTEXT_ID:
                     $assocId = $record[STATISTICS_DIMENSION_CONTEXT_ID];
                     $assocType = Application::getContextAssocType();
                     $row[] = $this->getObjectTitle($assocId, $assocType);
                     break;
                 case STATISTICS_DIMENSION_SUBMISSION_ID:
                     if (isset($record[STATISTICS_DIMENSION_SUBMISSION_ID])) {
                         $assocId = $record[STATISTICS_DIMENSION_SUBMISSION_ID];
                         $assocType = ASSOC_TYPE_SUBMISSION;
                         $row[] = $this->getObjectTitle($assocId, $assocType);
                     } else {
                         $row[] = '';
                     }
                     break;
                 case STATISTICS_DIMENSION_REGION:
                     if (isset($record[STATISTICS_DIMENSION_REGION]) && isset($record[STATISTICS_DIMENSION_COUNTRY])) {
                         $geoLocationTool = $statsHelper->getGeoLocationTool();
                         if ($geoLocationTool) {
                             $regions = $geoLocationTool->getRegions($record[STATISTICS_DIMENSION_COUNTRY]);
                             $regionId = $record[STATISTICS_DIMENSION_REGION];
                             if (strlen($regionId) == 1) {
                                 $regionId = '0' . $regionId;
                             }
                             if (isset($regions[$regionId])) {
                                 $row[] = $regions[$regionId];
                                 break;
                             }
                         }
                     }
                     $row[] = '';
                     break;
                 case STATISTICS_DIMENSION_PKP_SECTION_ID:
                     $sectionId = null;
                     if (isset($record[STATISTICS_DIMENSION_PKP_SECTION_ID])) {
                         $sectionId = $record[STATISTICS_DIMENSION_PKP_SECTION_ID];
                     }
                     if ($sectionId) {
                         $row[] = $this->getObjectTitle($sectionId, ASSOC_TYPE_SECTION);
                     } else {
                         $row[] = '';
                     }
                     break;
                 case STATISTICS_DIMENSION_FILE_TYPE:
                     if ($record[$key]) {
                         $row[] = $statsHelper->getFileTypeString($record[$key]);
                     } else {
                         $row[] = '';
                     }
                     break;
                 default:
                     $row[] = $record[$key];
                     break;
             }
         }
         fputcsv($fp, $row);
     }
     fclose($fp);
 }
 /**
  * Main entry point for PKP statistics reports.
  *
  * @see <http://pkp.sfu.ca/wiki/index.php/OJSdeStatisticsConcept#Input_and_Output_Formats_.28Aggregation.2C_Filters.2C_Metrics_Data.29>
  * for a full specification of the input and output format of this method.
  *
  * @param $metricType null|string|array metrics selection
  *   NB: If you want to use the default metric on journal level then you must
  *   set $metricType = null and add an explicit filter on a single journal ID.
  *   Otherwise the default site-level metric will be used.
  * @param $columns string|array column (aggregation level) selection
  * @param $filters array report-level filter selection
  * @param $orderBy array order criteria
  * @param $range null|DBResultRange paging specification
  *
  * @return null|array The selected data as a simple tabular result set or
  *   null if the given parameter combination is not supported.
  */
 function getMetrics($metricType = null, $columns = array(), $filter = array(), $orderBy = array(), $range = null)
 {
     import('classes.statistics.StatisticsHelper');
     $statsHelper = new StatisticsHelper();
     // Check the parameter format.
     if (!(is_array($filter) && is_array($orderBy))) {
         return null;
     }
     // Check whether which context we are.
     $context = $statsHelper->getContext($filter);
     // Identify and canonicalize filtered metric types.
     $defaultSiteMetricType = $this->getDefaultMetricType();
     $siteMetricTypes = $this->getMetricTypes();
     $metricType = $statsHelper->canonicalizeMetricTypes($metricType, $context, $defaultSiteMetricType, $siteMetricTypes);
     if (!is_array($metricType)) {
         return null;
     }
     $metricTypeCount = count($metricType);
     // Canonicalize columns.
     if (is_scalar($columns)) {
         $columns = array($columns);
     }
     // The metric type dimension is not additive. This imposes two important
     // restrictions on valid report descriptions:
     // 1) We need at least one metric Type to be specified.
     if ($metricTypeCount === 0) {
         return null;
     }
     // 2) If we have multiple metrics then we have to force inclusion of
     // the metric type column to avoid aggregation over several metric types.
     if ($metricTypeCount > 1) {
         if (!in_array(STATISTICS_DIMENSION_METRIC_TYPE, $columns)) {
             array_push($columns, STATISTICS_DIMENSION_METRIC_TYPE);
         }
     }
     // Retrieve report plugins.
     if (is_a($context, 'Context')) {
         $contextId = $context->getId();
     } else {
         $contextId = CONTEXT_SITE;
     }
     $reportPlugins = PluginRegistry::loadCategory('reports', true, $contextId);
     if (!is_array($reportPlugins)) {
         return null;
     }
     // Run through all report plugins and try to retrieve the requested metrics.
     $report = array();
     foreach ($reportPlugins as $reportPlugin) {
         // Check whether one (or more) of the selected metrics can be
         // provided by this plugin.
         $availableMetrics = $reportPlugin->getMetricTypes();
         $availableMetrics = array_intersect($availableMetrics, $metricType);
         if (count($availableMetrics) == 0) {
             continue;
         }
         // Retrieve a (partial) report.
         $partialReport = $reportPlugin->getMetrics($availableMetrics, $columns, $filter, $orderBy, $range);
         // Merge the partial report with the main report.
         $report = array_merge($report, $partialReport);
         // Remove the found metric types from the metric type array.
         $metricType = array_diff($metricType, $availableMetrics);
     }
     // Check whether we found all requested metric types.
     if (count($metricType) > 0) {
         return null;
     }
     // Return the report.
     return $report;
 }
예제 #7
0
 /**
  * @see Form::execute()
  */
 function execute($request)
 {
     parent::execute();
     $router = $request->getRouter();
     /* @var $router PageRouter */
     $context = $router->getContext($request);
     $statsHelper = new StatisticsHelper();
     $columns = $this->getData('columns');
     $filter = array();
     if ($this->getData('objectTypes')) {
         $filter[STATISTICS_DIMENSION_ASSOC_TYPE] = $this->getData('objectTypes');
     }
     if ($this->getData('objectIds') && count($filter[STATISTICS_DIMENSION_ASSOC_TYPE] == 1)) {
         $objectIds = explode(',', $this->getData('objectIds'));
         $filter[STATISTICS_DIMENSION_ASSOC_ID] = $objectIds;
     }
     if ($this->getData('fileTypes')) {
         $filter[STATISTICS_DIMENSION_FILE_TYPE] = $this->getData('fileTypes');
     }
     $filter[STATISTICS_DIMENSION_CONTEXT_ID] = $context->getId();
     if ($this->getData('issues')) {
         $filter[STATISTICS_DIMENSION_ISSUE_ID] = $this->getData('issues');
     }
     if ($this->getData('articles')) {
         $filter[STATISTICS_DIMENSION_SUBMISSION_ID] = $this->getData('articles');
     }
     // Get the time filter data, if any.
     $startTime = $request->getUserDateVar('dateStart', 1, 1, 1, 23, 59, 59);
     $endTime = $request->getUserDateVar('dateEnd', 1, 1, 1, 23, 59, 59);
     if ($startTime && $endTime) {
         $startYear = date('Y', $startTime);
         $endYear = date('Y', $endTime);
         $startMonth = date('m', $startTime);
         $endMonth = date('m', $endTime);
         $startDay = date('d', $startTime);
         $endDay = date('d', $endTime);
     }
     $timeFilterOption = $this->getData('timeFilterOption');
     switch ($timeFilterOption) {
         case TIME_FILTER_OPTION_YESTERDAY:
             $filter[STATISTICS_DIMENSION_DAY] = STATISTICS_YESTERDAY;
             break;
         case TIME_FILTER_OPTION_CURRENT_MONTH:
             $filter[STATISTICS_DIMENSION_MONTH] = STATISTICS_CURRENT_MONTH;
             break;
         case TIME_FILTER_OPTION_RANGE_DAY:
         case TIME_FILTER_OPTION_RANGE_MONTH:
             if ($timeFilterOption == TIME_FILTER_OPTION_RANGE_DAY) {
                 $startDate = $startYear . $startMonth . $startDay;
                 $endDate = $endYear . $endMonth . $endDay;
             } else {
                 $startDate = $startYear . $startMonth;
                 $endDate = $endYear . $endMonth;
             }
             if ($startTime == $endTime) {
                 // The start and end date are the same, there is no range defined
                 // only one specific date. Use the start time.
                 $filter[STATISTICS_DIMENSION_MONTH] = $startDate;
             } else {
                 $filter[STATISTICS_DIMENSION_DAY]['from'] = $startDate;
                 $filter[STATISTICS_DIMENSION_DAY]['to'] = $endDate;
             }
             break;
         default:
             break;
     }
     if ($this->getData('countries')) {
         $filter[STATISTICS_DIMENSION_COUNTRY] = $this->getData('countries');
     }
     if ($this->getData('regions')) {
         $filter[STATISTICS_DIMENSION_REGION] = $this->getData('regions');
     }
     if ($this->getData('cityNames')) {
         $cityNames = explode(',', $this->getData('cityNames'));
         $filter[STATISTICS_DIMENSION_CITY] = $cityNames;
     }
     $orderBy = array();
     if ($this->getData('orderByColumn') && $this->getData('orderByDirection')) {
         $orderByColumn = $this->getData('orderByColumn');
         $orderByDirection = $this->getData('orderByDirection');
         $columnIndex = 0;
         foreach ($orderByColumn as $column) {
             if ($column != '0' && !isset($orderBy[$column])) {
                 $orderByDir = $orderByDirection[$columnIndex];
                 if ($orderByDir == STATISTICS_ORDER_ASC || $orderByDir == STATISTICS_ORDER_DESC) {
                     $orderBy[$column] = $orderByDir;
                 }
             }
             $columnIndex++;
         }
     }
     return $statsHelper->getReportUrl($request, $this->_metricType, $columns, $filter, $orderBy);
 }
 /**
  * Constructor.
  * @param $argv array task arguments
  */
 function PKPUsageStatsLoader($args)
 {
     $plugin = PluginRegistry::getPlugin('generic', 'usagestatsplugin');
     /* @var $plugin UsageStatsPlugin */
     $this->_plugin = $plugin;
     $arg = current($args);
     switch ($arg) {
         case 'autoStage':
             if ($plugin->getSetting(0, 'createLogFiles')) {
                 $this->_autoStage = true;
             }
             break;
         case 'externalLogFiles':
             $this->_externalLogFiles = true;
             break;
     }
     // Define the base filesystem path.
     $args[0] = $plugin->getFilesPath();
     parent::FileLoader($args);
     if ($plugin->getEnabled()) {
         // Load the metric type constant.
         PluginRegistry::loadCategory('reports');
         import('classes.statistics.StatisticsHelper');
         $statsHelper = new StatisticsHelper();
         $geoLocationTool = $statsHelper->getGeoLocationTool();
         $this->_geoLocationTool = $geoLocationTool;
         $plugin->import('UsageStatsTemporaryRecordDAO');
         $statsDao = new UsageStatsTemporaryRecordDAO();
         DAORegistry::registerDAO('UsageStatsTemporaryRecordDAO', $statsDao);
         $this->_counterRobotsListFile = $this->_getCounterRobotListFile();
         $contextDao = Application::getContextDAO();
         /* @var $contextDao ContextDAO */
         $contextFactory = $contextDao->getAll();
         /* @var $contextFactory DAOResultFactory */
         $contextsByPath = array();
         while ($context = $contextFactory->next()) {
             /* @var $context Context */
             $contextsByPath[$context->getPath()] = $context;
         }
         $this->_contextsByPath = $contextsByPath;
         $this->checkFolderStructure(true);
         if ($this->_autoStage) {
             // Copy all log files to stage directory, except the current day one.
             $fileMgr = new FileManager();
             $logFiles = array();
             $logsDirFiles = glob($plugin->getUsageEventLogsPath() . DIRECTORY_SEPARATOR . '*');
             // It's possible that the processing directory have files that
             // were being processed but the php process was stopped before
             // finishing the processing. Just copy them to the stage directory too.
             $processingDirFiles = glob($this->getProcessingPath() . DIRECTORY_SEPARATOR . '*');
             if (is_array($logsDirFiles)) {
                 $logFiles = array_merge($logFiles, $logsDirFiles);
             }
             if (is_array($processingDirFiles)) {
                 $logFiles = array_merge($logFiles, $processingDirFiles);
             }
             foreach ($logFiles as $filePath) {
                 // Make sure it's a file.
                 if ($fileMgr->fileExists($filePath)) {
                     // Avoid current day file.
                     $filename = pathinfo($filePath, PATHINFO_BASENAME);
                     $currentDayFilename = $plugin->getUsageEventCurrentDayLogName();
                     if ($filename == $currentDayFilename) {
                         continue;
                     }
                     $this->moveFile(pathinfo($filePath, PATHINFO_DIRNAME), $this->getStagePath(), $filename);
                 }
             }
         }
     }
 }
 /**
  * Get optional columns list.
  * @return array
  */
 function getOptionalColumnsList()
 {
     import('classes.statistics.StatisticsHelper');
     $statsHelper = new StatisticsHelper();
     $plugin = $this->plugin;
     $reportPlugin = $plugin->getReportPlugin();
     $metricType = $reportPlugin->getMetricTypes();
     $optionalColumns = $reportPlugin->getOptionalColumns($metricType);
     $columnsList = array();
     foreach ($optionalColumns as $column) {
         $columnsList[$column] = $statsHelper->getColumnNames($column);
     }
     return $columnsList;
 }
 /**
  * Get optional columns list.
  * @return array
  */
 function getOptionalColumnsList()
 {
     import('classes.statistics.StatisticsHelper');
     $statsHelper = new StatisticsHelper();
     return array(STATISTICS_DIMENSION_CITY => $statsHelper->getColumnNames(STATISTICS_DIMENSION_CITY), STATISTICS_DIMENSION_REGION => $statsHelper->getColumnNames(STATISTICS_DIMENSION_REGION));
 }
예제 #11
0
파일: view.html.php 프로젝트: Rikisha/proj
 /**
  * Get statistics data and set it to JS.
  * 
  * @return void
  * @since  1.0
  */
 protected function setStatisticsData()
 {
     $ids = JRequest::getString('newsletters', '');
     $this->ids = $ids;
     $days = JRequest::getString('days', 30);
     $this->days = $days;
     $ids = !empty($ids) ? explode(',', $ids) : null;
     $data = StatisticsHelper::totalSent($ids);
     JavascriptHelper::addObject('statTotalSent', $data);
     $data = StatisticsHelper::openedActionsCount($ids);
     JavascriptHelper::addObject('statOpenedCount', $data);
     $data = StatisticsHelper::openedNewslettersCount($ids);
     $res = array('newsletters' => empty($data['newsletters']) ? 0 : $data['newsletters'], 'subscribers' => empty($data['subscribers']) ? 0 : $data['subscribers']);
     JavascriptHelper::addObject('statActiveCount', $res);
     $data = StatisticsHelper::totalClicks($ids);
     JavascriptHelper::addObject('statTotalClicks', $data);
     $previousDay = date('Y-m-d 00:00:00', strtotime("-1 day", time()));
     $thisDay = date('Y-m-d 00:00:00');
     $daysIdentifier = $days == 1 ? "-1 day" : "-" . $days . " Days";
     $fiewDaysBefore = date('Y-m-d 00:00:00', strtotime($daysIdentifier, time()));
     $previousHour = date('Y-m-d H:00:00', strtotime("-1 hour", time()));
     $thisHour = date('Y-m-d H:00:00');
     $oneDayBefore = date('Y-m-d H:00:00', strtotime("-1 day", time()));
     JavascriptHelper::addObject('clicksPerDay', StatisticsHelper::activityPerDay($fiewDaysBefore, $thisDay, $ids, NewsletterTableHistory::ACTION_CLICKED));
     JavascriptHelper::addObject('viewsPerDay', StatisticsHelper::activityPerDay($fiewDaysBefore, $thisDay, $ids, NewsletterTableHistory::ACTION_OPENED));
     JavascriptHelper::addObject('clicksPerHour', StatisticsHelper::activityPerHour($oneDayBefore, $thisHour, $ids, NewsletterTableHistory::ACTION_CLICKED));
     JavascriptHelper::addObject('viewsPerHour', StatisticsHelper::activityPerHour($oneDayBefore, $thisHour, $ids, NewsletterTableHistory::ACTION_OPENED));
 }
예제 #12
0
파일: view.html.php 프로젝트: Rikisha/proj
 function setStatisticsData()
 {
     $theHour = 3600;
     $theDay = $theHour * 24;
     $days = 30;
     $previousDay = date('Y-m-d 00:00:00', strtotime("-1 day", time()));
     $fiewDaysBefore = date('Y-m-d 00:00:00', strtotime("-30 Days", time()));
     JavascriptHelper::addObject('opensPerDay', StatisticsHelper::openedNewslettersPerDay($fiewDaysBefore, $previousDay, null));
     JavascriptHelper::addObject('subsPerDay', StatisticsHelper::activeSubscribersPerDay($fiewDaysBefore, $previousDay, null));
 }
예제 #13
0
파일: view.html.php 프로젝트: Rikisha/proj
 /**
  * Gets the statistics data and set it to JS.
  *
  * @return void
  * @since  1.0
  */
 protected function setStatisticsData()
 {
     $data = StatisticsHelper::totalSent();
     JavascriptHelper::addObject('statTotalSent', $data);
     $data = StatisticsHelper::openedActionsCount();
     JavascriptHelper::addObject('statOpenedCount', $data);
     $data = StatisticsHelper::openedNewslettersCount();
     $res = array('newsletters' => empty($data['newsletters']) ? 0 : $data['newsletters'], 'subscribers' => empty($data['subscribers']) ? 0 : $data['subscribers']);
     JavascriptHelper::addObject('statActiveSubscribersCount', $res);
     $now = date('Y-m-d H:i:s');
     $sevenDaysBefore = date('Y-m-d', strtotime('-7 Days', time())) . " 00:00:00";
     $thirtyDaysBefore = date('Y-m-d', strtotime('-30 Days', time())) . " 00:00:00";
     $ninetyDaysBefore = date('Y-m-d', strtotime('-90 Days', time())) . " 00:00:00";
     $this->totalSubs = array(StatisticsHelper::totalSubscribersCount($sevenDaysBefore, $now), StatisticsHelper::totalSubscribersCount($thirtyDaysBefore, $now), StatisticsHelper::totalSubscribersCount($ninetyDaysBefore, $now));
     $this->newSubs = array(StatisticsHelper::newSubscribersCount($sevenDaysBefore, $now), StatisticsHelper::newSubscribersCount($thirtyDaysBefore, $now), StatisticsHelper::newSubscribersCount($ninetyDaysBefore, $now));
     $this->lostSubs = array(StatisticsHelper::lostSubscribersCount($sevenDaysBefore, $now), StatisticsHelper::lostSubscribersCount($thirtyDaysBefore, $now), StatisticsHelper::lostSubscribersCount($ninetyDaysBefore, $now));
     $this->activeSubs = array(StatisticsHelper::activeSubscribersCount($sevenDaysBefore, $now), StatisticsHelper::activeSubscribersCount($thirtyDaysBefore, $now), StatisticsHelper::activeSubscribersCount($ninetyDaysBefore, $now));
 }
예제 #14
0
파일: view.html.php 프로젝트: Rikisha/proj
 /**
  * Calculate the statistics data and add it to the JS
  *
  * @return void
  * @since  1.0
  */
 protected function setStatisticsData()
 {
     $data = StatisticsHelper::totalSent();
     $res = array('no' => empty($data['no']) ? 0 : $data['no'], 'soft' => empty($data['soft']) ? 0 : $data['soft'], 'hard' => empty($data['hard']) ? 0 : $data['hard'], 'total' => empty($data['total']) ? 0 : $data['total']);
     JavascriptHelper::addObject('statTotalSent', $res);
     $data = StatisticsHelper::openedActionsCount();
     $res = array('other' => empty($data['other']) ? 0 : $data['other'], 'opened' => empty($data['opened']) ? 0 : $data['opened'], 'total' => empty($data['total']) ? 0 : $data['total']);
     JavascriptHelper::addObject('statOpenedCount', $res);
     $data = StatisticsHelper::openedNewslettersCount();
     $res = array('newsletters' => empty($data['newsletters']) ? 0 : $data['newsletters'], 'subscribers' => empty($data['subscribers']) ? 0 : $data['subscribers']);
     JavascriptHelper::addObject('statActiveSubscribersCount', $res);
     $theHour = 3600;
     $theDay = $theHour * 24;
     $days = 30;
     $previousDay = date('Y-m-d 00:00:00', time() - $theDay);
     $fiewDaysBefore = date('Y-m-d 00:00:00', time() - $theDay * $days);
     JavascriptHelper::addObject('newSubsPerDay', StatisticsHelper::newSubscribersPerDay($fiewDaysBefore, $previousDay));
 }