/** * 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; }
/** * Check if it's time to send autosubmit data * (we should have check if autosubmit is enabled first) */ function _isTooEarlyToSubmit() { $lastSubmit = $this->helper->lastSentTime(); return $lastSubmit + 24 * 60 * 60 * 30 > time(); }