| 1 | <?php |
||
| 11 | class action_plugin_popularity extends Dokuwiki_Action_Plugin { |
||
| 12 | |||
| 13 | /** |
||
| 14 | * @var helper_plugin_popularity |
||
| 15 | */ |
||
| 16 | var $helper; |
||
| 17 | |||
| 18 | function __construct(){ |
||
| 21 | |||
| 22 | /** |
||
| 23 | * Register its handlers with the dokuwiki's event controller |
||
| 24 | */ |
||
| 25 | function register(Doku_Event_Handler $controller) { |
||
| 28 | |||
| 29 | function _autosubmit(Doku_Event &$event, $param){ |
||
| 30 | //Do we have to send the data now |
||
| 31 | if ( !$this->helper->isAutosubmitEnabled() || $this->_isTooEarlyToSubmit() ){ |
||
| 32 | return; |
||
| 33 | } |
||
| 34 | |||
| 35 | //Actually send it |
||
| 36 | $status = $this->helper->sendData( $this->helper->gatherAsString() ); |
||
| 37 | |||
| 38 | if ( $status !== '' ){ |
||
| 39 | //If an error occured, log it |
||
| 40 | io_saveFile( $this->helper->autosubmitErrorFile, $status ); |
||
| 41 | } else { |
||
| 42 | //If the data has been sent successfully, previous log of errors are useless |
||
| 43 | @unlink($this->helper->autosubmitErrorFile); |
||
|
1 ignored issue
–
show
|
|||
| 44 | //Update the last time we sent data |
||
| 45 | touch ( $this->helper->autosubmitFile ); |
||
| 46 | } |
||
| 47 | |||
| 48 | $event->stopPropagation(); |
||
| 49 | $event->preventDefault(); |
||
| 50 | } |
||
| 51 | |||
| 52 | /** |
||
| 53 | * Check if it's time to send autosubmit data |
||
| 54 | * (we should have check if autosubmit is enabled first) |
||
| 55 | */ |
||
| 56 | function _isTooEarlyToSubmit(){ |
||
| 60 | } |
||
| 61 |
Adding explicit visibility (
private,protected, orpublic) is generally recommend to communicate to other developers how, and from where this method is intended to be used.