/** * Get the title at the top of the form * * @param int $step The current step * @return string */ protected function getFormTitle($step) { if ($this->trackEngine) { return sprintf($this->_('Merge import into "%s" track. Step %d of %d.'), $this->trackEngine->getTrackName(), $step, $this->getStepCount()); } return sprintf($this->_('New track import. Step %d of %d.'), $step, $this->getStepCount()); }
/** * Add the elements from the model to the bridge for the current step * * @param \MUtil_Model_Bridge_FormBridgeInterface $bridge * @param \MUtil_Model_ModelAbstract $model */ protected function addStepGenerateExportFile(\MUtil_Model_Bridge_FormBridgeInterface $bridge, \MUtil_Model_ModelAbstract $model) { // Things go really wrong (at the session level) if we run this code // while the finish button was pressed if ($this->isFinishedClicked()) { return; } $this->displayHeader($bridge, $this->_('Creating the export file'), 'h3'); $this->nextDisabled = true; $batch = $this->getExportBatch(); $form = $bridge->getForm(); $batch->setFormId($form->getId()); $batch->autoStart = true; // \MUtil_Registry_Source::$verbose = true; if ($batch->run($this->request)) { exit; } $element = $form->createElement('html', $batch->getId()); if ($batch->isFinished()) { $this->nextDisabled = $batch->getCounter('export_errors'); $batch->autoStart = false; // Keep the filename after $batch->getMessages(true) cleared the previous $downloadName = \MUtil_File::cleanupName($this->trackEngine->getTrackName()) . '.track.txt'; $localFilename = $batch->getSessionVariable('filename'); $this->addMessage($batch->getMessages(true)); $batch->setSessionVariable('downloadname', $downloadName); $batch->setSessionVariable('filename', $localFilename); // Log Export $data = $this->formData; // Remove unuseful data unset($data['button_spacer'], $data['current_step'], $data[$this->csrfId]); // Add useful data $data['localfile'] = '...' . substr($localFilename, -30); $data['downloadname'] = $downloadName; ksort($data); $this->accesslog->logChange($this->request, null, array_filter($data)); if ($this->nextDisabled) { $element->pInfo($this->_('Export errors occurred.')); } else { $p = $element->pInfo($this->_('Export file generated.'), ' '); $p->sprintf($this->plural('Click here if the download does not start automatically in %d second:', 'Click here if the download does not start automatically in %d seconds:', $this->downloadWaitSeconds), $this->downloadWaitSeconds); $p->append(' '); $href = new \MUtil_Html_HrefArrayAttribute(array('file' => 'go', $this->stepFieldName => 'download')); $p->a($href, $downloadName, array('type' => 'application/download')); $metaContent = sprintf('%d;url=%s', $this->downloadWaitSeconds, $href->render($this->view)); $this->view->headMeta($metaContent, 'refresh', 'http-equiv'); } } else { $element->setValue($batch->getPanel($this->view, $batch->getProgressPercentage() . '%')); } $form->activateJQuery(); $form->addElement($element); }
/** * The place to check if the data set in the snippet is valid * to generate the snippet. * * When invalid data should result in an error, you can throw it * here but you can also perform the check in the * checkRegistryRequestsAnswers() function from the * {@see \MUtil_Registry_TargetInterface}. * * @return boolean */ public function hasHtmlOutput() { if (!$this->trackId) { if (isset($this->trackData['gtr_id_track'])) { $this->trackId = $this->trackData['gtr_id_track']; } elseif ($this->trackEngine instanceof \Gems_Tracker_Engine_TrackEngineInterface) { $this->trackId = $this->trackEngine->getTrackId(); } } if (!$this->trackName) { if (isset($this->trackData['gtr_track_name'])) { $this->trackName = $this->trackData['gtr_track_name']; } elseif ($this->trackEngine instanceof \Gems_Tracker_Engine_TrackEngineInterface) { $this->trackName = $this->trackEngine->getTrackName(); } } return (bool) $this->trackName && parent::hasHtmlOutput(); }
/** * Called after the check that all required registry values * have been set correctly has run. * * @return void */ public function afterRegistry() { parent::afterRegistry(); $this->contentTitle = sprintf($this->_('Rounds in %s track'), $this->trackEngine->getTrackName()); }
/** * Performs actual download * * @param \MUtil_Model_Bridge_FormBridgeInterface $bridge * @param \MUtil_Model_ModelAbstract $model */ protected function downloadExportFile() { $this->view->layout()->disableLayout(); \Zend_Controller_Action_HelperBroker::getExistingHelper('viewRenderer')->setNoRender(true); $filename = $this->getExportBatch(false)->getSessionVariable('filename'); $downloadName = \MUtil_File::cleanupName($this->trackEngine->getTrackName()) . '.track.txt'; header("Content-Type: application/download"); header("Content-Disposition: attachment; filename=\"{$downloadName}\""); header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Pragma: cache"); // HTTP/1.0 readfile($filename); exit; }