From 8596046db551f4eda739892c98b35d4461ef0019 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Fri, 10 Dec 2010 09:46:38 +0100 Subject: added missing files for popularity plugin --- lib/plugins/popularity/action.php | 57 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 lib/plugins/popularity/action.php (limited to 'lib/plugins/popularity/action.php') diff --git a/lib/plugins/popularity/action.php b/lib/plugins/popularity/action.php new file mode 100644 index 000000000..ce10808b9 --- /dev/null +++ b/lib/plugins/popularity/action.php @@ -0,0 +1,57 @@ +helper = $this->loadHelper('popularity', false); + } + + /** + * Register its handlers with the dokuwiki's event controller + */ + function register(&$controller) { + $controller->register_hook('INDEXER_TASKS_RUN', 'AFTER', $this, '_autosubmit', array()); + } + + function _autosubmit(&$event, $param){ + //Do we have to send the data now + if ( !$this->helper->isAutosubmitEnabled() || $this->_isTooEarlyToSubmit() ){ + return; + } + + //Actually send it + $status = $this->helper->sendData( $this->helper->gatherAsString() ); + + + if ( $status !== '' ){ + //If an error occured, log it + io_saveFile( $this->helper->autosubmitErrorFile, $status ); + } else { + //If the data has been sent successfully, previous log of errors are useless + @unlink($this->helper->autosubmitErrorFile); + //Update the last time we sent data + touch ( $this->helper->autosubmitFile ); + } + + $event->stopPropagation(); + $event->preventDefault(); + } + + /** + * Check if it's time to send autosubmit data + * (we should have check the autosubmit is enabled first) + */ + function _isTooEarlyToSubmit(){ + $lastSubmit = @filemtime($this->helper->autosubmitFile); + return $lastSubmit + 24*60*60*30 > time(); + } +} -- cgit v1.2.3