示例#1
0
 function _autosubmit(Doku_Event &$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();
 }
示例#2
0
 /**
  * Build the form which presents the data to be sent
  * @param string $submissionMode How is the data supposed to be sent? (may be: 'browser' or 'server')
  * @param string $data   The popularity data, if it has already been computed. NULL otherwise.
  * @return string The form, as an html string
  */
 function buildForm($submissionMode, $data = null)
 {
     $url = $submissionMode === 'browser' ? $this->helper->submitUrl : script();
     if (is_null($data)) {
         $data = $this->helper->gatherAsString();
     }
     $form = '<form method="post" action="' . $url . '" accept-charset="utf-8">' . '<fieldset style="width: 60%;">' . '<textarea class="edit" rows="10" cols="80" readonly="readonly" name="data">' . $data . '</textarea><br />';
     //If we submit via the server, we give the opportunity to suscribe to the autosubmission option
     if ($submissionMode !== 'browser') {
         $form .= '<label for="autosubmit">' . '<input type="checkbox" name="autosubmit" id="autosubmit" ' . ($this->helper->isAutosubmitEnabled() ? 'checked' : '') . '/> ' . $this->getLang('autosubmit') . '<br />' . '</label>' . '<input type="hidden" name="do" value="admin" />' . '<input type="hidden" name="page" value="popularity" />';
     }
     $form .= '<button type="submit">' . $this->getLang('submit') . '</button>' . '</fieldset>' . '</form>';
     return $form;
 }