public function executeNormalView() { $this->setup(); $this->poll = $this->slot->getPoll(); $type = $this->poll->getType(); if (!($this->show_poll = aPollToolkit::checkIfShowPoll($this->getRequest(), $this->poll))) { return 'Success'; } // validating apoll_settings_available_polls entry $this->poll_validation = aPollToolkit::checkPollConfiguration($type); if ($this->poll_validation->isValid()) { $form_name = aPollToolkit::getPollFormName($type); $this->poll_form = new $form_name(array('poll_id' => $this->poll->getId(), 'slot_name' => $this->name, 'permid' => $this->permid, 'pageid' => $this->pageid, 'remote_address' => $this->getRequest()->getRemoteAddress(), 'culture' => $this->getUser()->getCulture(), 'poll_type' => $type)); // Getting view template partial to display the form. // The template can be defined in two ways: // - In apoll_settings_view_default_template, to set an overall template for all polls // - In In apoll_settings_available_polls_XXX_view_template, where XXX // is the name of this poll, to override the default display template $this->form_view_template = aPollToolkit::getPollViewTemplate($type); // Getting the action treating the form sumbission. // The action can be defined in two ways: // - In apoll_settings_view_submit_action, to set an overall action for all polls // - In In apoll_settings_available_polls_XXX_submit_action, where XXX // is the name of this poll, to override the default action $this->submit_action = aPollToolkit::getPollSubmitAction($type); } }
public function executeShow(sfWebRequest $request) { $this->a_poll_answer = $this->getRoute()->getObject(); // Once shown, we consider that an answer is no more new $this->a_poll_answer->setIsNew(false); $this->a_poll_answer->save(); $this->form_answer = $this->configuration->getForm($this->a_poll_answer); $poll = $this->a_poll_answer->getPoll(); $form_name = aPollToolkit::getPollFormName($poll->getType()); $values = $this->a_poll_answer->getFieldsAsArray(); $this->form_poll = new $form_name($values); }
protected function prepareExport() { if (!class_exists('PHPExcel')) { throw new sfException('Cannot find PHPExcel. Did you install it? PHP excel is required to export poll answers to excel.'); } // Poll's form $this->poll = $this->getRoute()->getObject(); $form_name = aPollToolkit::getPollFormName($this->poll->getType()); // Answer form $answer_form = new aPollAnswerForm(); // generating report content $this->report = $this->fillExcel(new PHPExcel(), $this->poll, new $form_name(), $answer_form); // setting decoration and headers $this->setLayout(false); $response = $this->getResponse(); $response->clearHttpHeaders(); return $response; }
<p><?php echo a_('Here are the settings defined in app.yml. They are a mix of what has been defined for the poll itself, and settings inherited from global parameters.'); ?> </p> <?php $name = $poll['type']; ?> <dl> <dt><?php echo a_('Form'); ?> </dt> <dd><?php echo aPollToolkit::getPollFormName($name); ?> </dd> <dt><?php echo a_('Form render template (view_template)'); ?> </dt> <dd><?php echo aPollToolkit::getPollViewTemplate($name); ?> </dd> <dt><?php echo a_('Submit action'); ?>
static function sendNotificationEmail($name, sfMailer $mailer, aPollPoll $poll, aPollAnswer $answer) { if (!self::getSendNotification($name)) { return false; } sfContext::getInstance()->getConfiguration()->loadHelpers('Partial'); $from = self::isUserOrEmail(self::getNotificationEmailFrom($name), true); $to = self::isUserOrEmail(self::getNotificationEmailTo($name), true); if (is_null($to)) { throw new sfException('No destination email defined. Cannot send a notification.'); } $form_name = aPollToolkit::getPollFormName($poll->getType()); $arguments = array('poll' => $poll, 'poll_form' => new $form_name($answer->getFieldsAsArray()), 'answer' => $answer); $message = $mailer->compose($from, $to); //$message->setContentType("text/html"); $message->setSubject(get_partial(self::getNotificationEmailTitlePartial($name), $arguments)); $body = get_partial(self::getNotificationEmailBodyPartial($name), $arguments); $message->addPart(self::createPlainTextBody($body), 'text/plain'); $message->addPart(self::createHtmlBody($poll->getType(), $body), 'text/html'); $mailer->send($message); return true; }