/**
  * 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);
     }
 }
Esempio n. 3
0
 /**
  * Constructor.
  * @param $argv array task arguments
  */
 function UsageStatsLoader($args)
 {
     parent::FileLoader($args);
     $this->_geoLocationTool = new GeoLocationTool();
     $plugin = PluginRegistry::getPlugin('generic', 'usagestatsplugin');
     // Load the metric type constant.
     PluginRegistry::loadCategory('reports');
     $this->_plugin = $plugin;
     $this->_plugin->import('UsageStatsTemporaryRecordDAO');
     $statsDao = new UsageStatsTemporaryRecordDAO();
     DAORegistry::registerDAO('UsageStatsTemporaryRecordDAO', $statsDao);
     $this->_counterRobotsListFile = $this->_getCounterRobotListFile();
     $journalDao = DAORegistry::getDAO('JournalDAO');
     /* @var $journalDao JournalDAO */
     $journalFactory = $journalDao->getAll();
     /* @var $journalFactory DAOResultFactory */
     $journalsByPath = array();
     while ($journal = $journalFactory->next()) {
         /* @var $journal Journal */
         $journalsByPath[$journal->getPath()] = $journal;
     }
     $this->_journalsByPath = $journalsByPath;
     $this->checkFolderStructure(true);
 }
 /**
  * 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);
                 }
             }
         }
     }
 }