Esempio n. 1
0
 /**
  * Display the whole thang
  *
  * @param array $data
  */
 public function display($data = array())
 {
     $template = new \SimpleSubscribe\Template('adminApi.latte');
     $templateGuts = $this->hasMessages() ? $this->getMessages() : \SimpleSubscribe\FrontEnd::unsubscriptionForm();
     $templateAction = $this->hasMessages() ? 'Confirm Subscription' : 'Unsubscribe';
     $templateBackUrl = $this->settings->getBackLinkUrl();
     $defaults = array('action' => $templateAction, 'stylesheetUrl' => SUBSCRIBE_ASSETS . 'styleApi.css', 'guts' => $templateGuts, 'backLink' => '<a href="' . $templateBackUrl . '">Back to homepage &raquo;</a>');
     $template->prepareTemplate($defaults, $data);
     echo $template->getTemplate();
 }
Esempio n. 2
0
 /**
  * Prepare template
  *
  * @param string $templateFile
  * @param array $data
  * @return Nette\Templating\FileTemplate
  */
 public function getEmailTemplate($data = array())
 {
     // prepare social links and colours
     $settingsSocial = isset($this->settingsAll['social']) ? $this->settingsAll['social'] : array();
     $settingsColours = isset($this->settingsAll['emailDesign']) ? $this->settingsAll['emailDesign'] : array();
     $defaultColours = array('colourBodyBg' => '#ececec', 'colourBg' => '#f5f5f5', 'colourTitle' => '#000000', 'colourLinks' => '#000000');
     // which template file are we using?
     $templateFile = $this->htmlEmail ? 'email.latte' : 'emailPlain.latte';
     // defaults
     $defaults = array('subject' => '', 'homeUrl' => '', 'image' => $this->senderName, 'message' => '', 'social' => $settingsSocial, 'colours' => array_merge($defaultColours, $settingsColours), 'unSubscribe' => Html::el('a')->href(SUBSCRIBE_API_URL)->setText('Unsubscribe here.'));
     // prepare template
     $template = new \SimpleSubscribe\Template($templateFile);
     $template->prepareTemplate($defaults, $data);
     // convert to string if needed
     if ($this->htmlEmail != TRUE) {
         $templatePlain = new \SimpleSubscribe\Html2Text($template->getTemplate());
         return $templatePlain->get_text();
     }
     return $template->getTemplate();
 }
Esempio n. 3
0
 /**
  * Unsubscription form
  *
  * @param bool $widget
  * @param array $args
  * @return Nette\Templating\FileTemplate
  */
 public static function unsubscriptionForm($widget = FALSE, $args = array())
 {
     $widgetMessage = '';
     $widgetTitle = isset($args['title']) && !empty($args['title']) ? $args['title'] : 'Unsubscribe';
     $widgetId = isset($args['widget_id']) ? $args['widget_id'] : NULL;
     $form = \SimpleSubscribe\Forms::unsubscriptionForm($widget, $widgetId);
     if ($form->isSubmitted() && $form->isValid()) {
         try {
             $subscribers = \SimpleSubscribe\RepositorySubscribers::getInstance();
             $formValues = $form->getValues();
             $subscribers->deleteOrDeactivateByEmail($formValues->email);
             $widgetMessage = '<strong>You have successfully unsubscribed. We\'re sorry to see you leave!</strong>';
             $form = '';
         } catch (RepositarySubscribersException $e) {
             $form->addError($e->getMessage());
         }
     }
     if ($widget) {
         // defaults
         $defaults = array('beforeWidget' => $args['before_widget'], 'beforeTitle' => $args['before_title'], 'afterTitle' => $args['after_title'], 'widgetTitle' => $widgetTitle, 'message' => $widgetMessage, 'guts' => $form, 'afterWidget' => $args['after_widget']);
         // template
         $template = new \SimpleSubscribe\Template('widget.latte');
         $template->prepareTemplate($defaults);
     } else {
         // defaults
         $defaults = array('title' => 'Unsubscribe', 'message' => $widgetMessage, 'guts' => $form);
         // template
         $template = new \SimpleSubscribe\Template('shortcode.latte');
         $template->prepareTemplate($defaults);
     }
     return $template->getTemplate();
 }
Esempio n. 4
0
 /**
  * Renders admin log, errors, q messages
  */
 public function renderAdminLog()
 {
     $table = new \SimpleSubscribe\TableLogs($this->log);
     $table->prepare_items();
     // template
     $template = new \SimpleSubscribe\Template('adminLog.latte');
     $template->prepareTemplate(array('table' => $table));
     echo $template->getTemplate();
 }