示例#1
0
 /**
  * Generate the module
  */
 protected function compile()
 {
     global $objPage;
     $arrJumpTo = array();
     $arrNewsletter = array();
     $strRequest = ampersand(\Environment::get('request'), true);
     $objNewsletter = \NewsletterModel::findSentByPids($this->nl_channels);
     if ($objNewsletter !== null) {
         while ($objNewsletter->next()) {
             if (($objTarget = $objNewsletter->getRelated('pid')) === null) {
                 continue;
             }
             $jumpTo = intval($objTarget->jumpTo);
             // A jumpTo page is not mandatory for newsletter channels (see #6521) but required for the list module
             if ($jumpTo < 1) {
                 throw new \Exception("Newsletter channels without redirect page cannot be used in a newsletter list");
             }
             $strUrl = $strRequest;
             if (!isset($arrJumpTo[$objTarget->jumpTo])) {
                 $objJumpTo = $objTarget->getRelated('jumpTo')->loadDetails();
                 if ($objJumpTo !== null) {
                     $arrJumpTo[$objTarget->jumpTo] = $this->generateFrontendUrl($objJumpTo->row(), \Config::get('useAutoItem') && !\Config::get('disableAlias') ? '/%s' : '/items/%s');
                 } else {
                     $arrJumpTo[$objTarget->jumpTo] = $strUrl;
                 }
             }
             $strUrl = $arrJumpTo[$objTarget->jumpTo];
             $strAlias = $objNewsletter->alias != '' && !\Config::get('disableAlias') ? $objNewsletter->alias : $objNewsletter->id;
             $arrNewsletter[] = array('subject' => $objNewsletter->subject, 'title' => strip_insert_tags($objNewsletter->subject), 'href' => sprintf($strUrl, $strAlias), 'date' => \Date::parse($objPage->dateFormat, $objNewsletter->date), 'datim' => \Date::parse($objPage->datimFormat, $objNewsletter->date), 'time' => \Date::parse($objPage->timeFormat, $objNewsletter->date), 'channel' => $objNewsletter->channel);
         }
     }
     $this->Template->newsletters = $arrNewsletter;
 }
示例#2
0
 /**
  * Generate the module
  */
 protected function compile()
 {
     global $objPage;
     $arrJumpTo = array();
     $arrNewsletter = array();
     $objNewsletter = \NewsletterModel::findSentByPids($this->nl_channels);
     if ($objNewsletter !== null) {
         while ($objNewsletter->next()) {
             if (($objTarget = $objNewsletter->getRelated('pid')) === null || !$objTarget->jumpTo) {
                 continue;
             }
             if (!isset($arrJumpTo[$objTarget->jumpTo])) {
                 $objJumpTo = \PageModel::findPublishedById($objTarget->jumpTo);
                 if ($objJumpTo !== null) {
                     $arrJumpTo[$objTarget->jumpTo] = $this->generateFrontendUrl($objJumpTo->row(), $GLOBALS['TL_CONFIG']['useAutoItem'] ? '/%s' : '/items/%s');
                 } else {
                     $arrJumpTo[$objTarget->jumpTo] = null;
                 }
             }
             $strUrl = $arrJumpTo[$objTarget->jumpTo];
             if ($strUrl === null) {
                 continue;
             }
             $strAlias = $objNewsletter->alias != '' && !$GLOBALS['TL_CONFIG']['disableAlias'] ? $objNewsletter->alias : $objNewsletter->id;
             $arrNewsletter[] = array('subject' => $objNewsletter->subject, 'title' => strip_insert_tags($objNewsletter->subject), 'href' => sprintf($strUrl, $strAlias), 'date' => $this->parseDate($objPage->dateFormat, $objNewsletter->date), 'datim' => $this->parseDate($objPage->datimFormat, $objNewsletter->date), 'time' => $this->parseDate($objPage->timeFormat, $objNewsletter->date), 'channel' => $objNewsletter->channel);
         }
     }
     $this->Template->newsletters = $arrNewsletter;
 }
示例#3
0
 public static function show()
 {
     if (isset($_GET['ajax_action_section']) and $_GET['ajax_action_section'] == 'save_description') {
         dibi::query("\n  \t\t\tUPDATE [newsletter_emails] \n  \t\t\tSET description = %s", $_POST['description'], "WHERE id_newsletter_emails = %i", $_POST['id_newsletter_emails']);
         exit;
     }
     MT::addTemplate(APP_DIR . '/require_modules/newsletter/default.phtml', 'newsletter');
     $ds = NewsletterModel::getDatasource();
     if (isset($_GET['id_newsletter_delete'])) {
         NewsletterModel::delete($_GET['id_newsletter_delete']);
         header('location: admin.php?section=newsletter');
         exit;
     }
     if (isset($_GET['export'])) {
         $dse = clone $ds;
         MT::addVar('newsletter', 'export', $dse->where('active = 1 AND id_newsletter_emails IN %l', $_GET['id'])->fetchAll());
     }
     if (@$_GET['order_by'] == 'email') {
         $ds->orderBy('email');
     } else {
         $ds->orderBy('adddate');
     }
     //$vp = new MyPaginator($ds, 10);
     MT::addVar('newsletter', 'emails', $ds->fetchAll());
     //  	MT::addVar('newsletter', 'vp', $vp);
 }
 /**
  * Generate the module
  */
 protected function compile()
 {
     global $objPage;
     $this->Template->content = '';
     $this->Template->referer = 'javascript:history.go(-1)';
     $this->Template->back = $GLOBALS['TL_LANG']['MSC']['goBack'];
     if (TL_MODE == 'FE' && BE_USER_LOGGED_IN) {
         $objNewsletter = \NewsletterModel::findByIdOrAlias(\Input::get('items'));
     } else {
         $objNewsletter = \NewsletterModel::findSentByParentAndIdOrAlias(\Input::get('items'), $this->nl_channels);
     }
     if ($objNewsletter === null) {
         // Do not index or cache the page
         $objPage->noSearch = 1;
         $objPage->cache = 0;
         // Send a 404 header
         header('HTTP/1.1 404 Not Found');
         $this->Template->content = '<p class="error">' . sprintf($GLOBALS['TL_LANG']['MSC']['invalidPage'], \Input::get('items')) . '</p>';
         return;
     }
     // Overwrite the page title (see #2853 and #4955)
     if ($objNewsletter->subject != '') {
         $objPage->pageTitle = strip_tags(strip_insert_tags($objNewsletter->subject));
     }
     // Add enclosure
     if ($objNewsletter->addFile) {
         $this->addEnclosuresToTemplate($this->Template, $objNewsletter->row(), 'files');
     }
     if (!$objNewsletter->sendText) {
         $nl2br = $objPage->outputFormat == 'xhtml' ? 'nl2br_xhtml' : 'nl2br_html5';
         $strContent = '';
         $objContentElements = \ContentModel::findPublishedByPidAndTable($objNewsletter->id, 'tl_newsletter');
         if ($objContentElements !== null) {
             if (!defined('NEWSLETTER_CONTENT_PREVIEW')) {
                 define('NEWSLETTER_CONTENT_PREVIEW', true);
             }
             foreach ($objContentElements as $objContentElement) {
                 $strContent .= $this->getContentElement($objContentElement->id);
             }
         }
         // Parse simple tokens and insert tags
         $strContent = $this->replaceInsertTags($strContent);
         $strContent = \String::parseSimpleTokens($strContent, array());
         // Encode e-mail addresses
         $strContent = \String::encodeEmail($strContent);
         $this->Template->content = $strContent;
     } else {
         $strContent = str_ireplace(' align="center"', '', $objNewsletter->content);
     }
     // Convert relative URLs
     $strContent = $this->convertRelativeUrls($strContent);
     // Parse simple tokens and insert tags
     $strContent = $this->replaceInsertTags($strContent);
     $strContent = \String::parseSimpleTokens($strContent, array());
     // Encode e-mail addresses
     $strContent = \String::encodeEmail($strContent);
     $this->Template->content = $strContent;
     $this->Template->subject = $objNewsletter->subject;
 }
示例#5
0
 public function sendToEmailRegisterToNewsletter(NForm $form)
 {
     $values = $form->getValues();
     if (NewsletterModel::add($values)) {
         $this->flashMessage('Váš Email bol úspešne pridaný.');
     } else {
         $form->addError('Váš email sa už v databáze nachádza.');
     }
     $this->invalidateControl('newsletter');
 }
 /**
  * Generate the content element
  */
 protected function compile()
 {
     $objNewsletter = \NewsletterModel::findByIdOrAlias($this->pid);
     $objNewsletterChannel = \NewsletterChannelModel::findByIds(array($objNewsletter->pid), array('limit' => 1));
     $objParent = $this->getPageDetails($objNewsletterChannel->jumpTo);
     $href = ampersand($this->generateFrontendUrl($objParent->row(), sprintf(\Config::get('useAutoItem') && !\Config::get('disableAlias') ? '/%s' : '/items/%s', $objNewsletter->alias)));
     //$href = ampersand($this->generateFrontendUrl($objParent->row(), ((\Config::get('useAutoItem') && !\Config::get('disableAlias')) ?  '/%s' : '/items/%s'), $objParent->language));
     $this->Template->setData($objNewsletter->row());
     $this->Template->view_online = $href;
     return;
 }
示例#7
0
 public function unsubscribe($code)
 {
     \NewsletterModel::where('hash', $code)->update(array('enabled' => 0));
     return (new \PageController())->createPageFrom(function () {
         Template::setPageTitle('Newsletter');
         Template::clearBreadCrumbs();
         Template::addBreadCrumb('/', 'Home');
         Template::addBreadCrumb('#', 'Newsletter');
         return View::make(Newsletter::$view_unsub);
     });
 }
示例#8
0
 /**
  * decide which page to show.
  * This method is called automatically
  */
 public function index($args = false)
 {
     $request = PRequest::get()->request;
     $model = new NewsletterModel();
     // look at the request.
     if (!isset($request[1])) {
         $Data = $model->PreviousLetters();
         $page = new NewsletterPage($Data);
     } else {
         $Data = $model->Load($request[1]);
         if (isset($request[2])) {
             $Data->Lang = $request[2];
         } else {
             $Data->Lang = 'en';
         }
         if (empty($Data)) {
             $page = new EmptyLetterPage($request[1]);
         } else {
             $page = new OneNewsLetterPage($Data);
         }
     }
     // return the $page object, so the "$page->render()" function can be called somewhere else.
     return $page;
 }
 protected function compile()
 {
     parent::compile();
     $objNewsletter = \NewsletterModel::findSentByParentAndIdOrAlias(\Input::get('items'), $this->nl_channels);
     error_log("check");
     error_log($this->id);
     $html = '';
     $objContentElements = \ContentModel::findPublishedByPidAndTable($objNewsletter->id, 'tl_newsletter');
     error_log($objContentElements);
     if ($objContentElements !== null) {
         while ($objContentElements->next()) {
             $html .= $this->getContentElement($objContentElements->id);
         }
     }
     // Replace insert tags
     $html = $this->replaceInsertTags($html);
     $this->Template->htmlContent = $html;
 }
示例#10
0
 /**
  * Generate the module
  */
 protected function compile()
 {
     global $objPage;
     $this->Template->content = '';
     $this->Template->referer = 'javascript:history.go(-1)';
     $this->Template->back = $GLOBALS['TL_LANG']['MSC']['goBack'];
     $objNewsletter = \NewsletterModel::findSentByParentAndIdOrAlias(\Input::get('items'), $this->nl_channels);
     if ($objNewsletter === null) {
         // Do not index or cache the page
         $objPage->noSearch = 1;
         $objPage->cache = 0;
         // Send a 404 header
         header('HTTP/1.1 404 Not Found');
         $this->Template->content = '<p class="error">' . sprintf($GLOBALS['TL_LANG']['MSC']['invalidPage'], \Input::get('items')) . '</p>';
         return;
     }
     // Overwrite the page title (see #2853 and #4955)
     if ($objNewsletter->subject != '') {
         $objPage->pageTitle = strip_tags(strip_insert_tags($objNewsletter->subject));
     }
     // Add enclosure
     if ($objNewsletter->addFile) {
         $this->addEnclosuresToTemplate($this->Template, $objNewsletter->row(), 'files');
     }
     // Support plain text newsletters (thanks to Hagen Klemp)
     if ($objNewsletter->sendText) {
         $nl2br = $objPage->outputFormat == 'xhtml' ? 'nl2br_xhtml' : 'nl2br_html5';
         $strContent = $nl2br($objNewsletter->text);
     } else {
         $strContent = str_ireplace(' align="center"', '', $objNewsletter->content);
     }
     // Parse simple tokens and insert tags
     $strContent = $this->replaceInsertTags($strContent);
     $strContent = \String::parseSimpleTokens($strContent, array());
     // Encode e-mail addresses
     $strContent = \String::encodeEmail($strContent);
     $this->Template->content = $strContent;
     $this->Template->subject = $objNewsletter->subject;
 }
 /**
  * Generate the module
  */
 protected function compile()
 {
     /** @var \PageModel $objPage */
     global $objPage;
     $this->Template->content = '';
     $this->Template->referer = 'javascript:history.go(-1)';
     $this->Template->back = $GLOBALS['TL_LANG']['MSC']['goBack'];
     $objNewsletter = \NewsletterModel::findSentByParentAndIdOrAlias(\Input::get('items'), $this->nl_channels);
     if (null === $objNewsletter) {
         /** @var \PageError404 $objHandler */
         $objHandler = new $GLOBALS['TL_PTY']['error_404']();
         $objHandler->generate($objPage->id);
     }
     // Overwrite the page title (see #2853 and #4955)
     if ($objNewsletter->subject != '') {
         $objPage->pageTitle = strip_tags(strip_insert_tags($objNewsletter->subject));
     }
     // Add enclosure
     if ($objNewsletter->addFile) {
         $this->addEnclosuresToTemplate($this->Template, $objNewsletter->row(), 'files');
     }
     // Support plain text newsletters (thanks to Hagen Klemp)
     if ($objNewsletter->sendText) {
         $nl2br = $objPage->outputFormat == 'xhtml' ? 'nl2br_xhtml' : 'nl2br_html5';
         $strContent = $nl2br($objNewsletter->text);
     } else {
         $strContent = str_ireplace(' align="center"', '', $objNewsletter->content);
     }
     // Parse simple tokens and insert tags
     $strContent = $this->replaceInsertTags($strContent);
     $strContent = \StringUtil::parseSimpleTokens($strContent, array());
     // Encode e-mail addresses
     $strContent = \StringUtil::encodeEmail($strContent);
     $this->Template->content = $strContent;
     $this->Template->subject = $objNewsletter->subject;
 }
示例#12
0
 /**
  * Add newsletters to the indexer
  *
  * @param array   $arrPages
  * @param integer $intRoot
  * @param boolean $blnIsSitemap
  *
  * @return array
  */
 public function getSearchablePages($arrPages, $intRoot = 0, $blnIsSitemap = false)
 {
     $arrRoot = array();
     if ($intRoot > 0) {
         $arrRoot = $this->Database->getChildRecords($intRoot, 'tl_page');
     }
     $arrProcessed = array();
     $time = \Date::floorToMinute();
     // Get all channels
     $objNewsletter = \NewsletterChannelModel::findAll();
     // Walk through each channel
     if ($objNewsletter !== null) {
         while ($objNewsletter->next()) {
             if (!$objNewsletter->jumpTo) {
                 continue;
             }
             // Skip channels outside the root nodes
             if (!empty($arrRoot) && !in_array($objNewsletter->jumpTo, $arrRoot)) {
                 continue;
             }
             // Get the URL of the jumpTo page
             if (!isset($arrProcessed[$objNewsletter->jumpTo])) {
                 $objParent = \PageModel::findWithDetails($objNewsletter->jumpTo);
                 // The target page does not exist
                 if ($objParent === null) {
                     continue;
                 }
                 // The target page has not been published (see #5520)
                 if (!$objParent->published || $objParent->start != '' && $objParent->start > $time || $objParent->stop != '' && $objParent->stop <= $time + 60) {
                     continue;
                 }
                 // The target page is exempt from the sitemap (see #6418)
                 if ($blnIsSitemap && $objParent->sitemap == 'map_never') {
                     continue;
                 }
                 // Set the domain (see #6421)
                 $domain = ($objParent->rootUseSSL ? 'https://' : 'http://') . ($objParent->domain ?: \Environment::get('host')) . TL_PATH . '/';
                 // Generate the URL
                 $arrProcessed[$objNewsletter->jumpTo] = $domain . $this->generateFrontendUrl($objParent->row(), \Config::get('useAutoItem') && !\Config::get('disableAlias') ? '/%s' : '/items/%s', $objParent->language);
             }
             $strUrl = $arrProcessed[$objNewsletter->jumpTo];
             // Get the items
             $objItem = \NewsletterModel::findSentByPid($objNewsletter->id);
             if ($objItem !== null) {
                 while ($objItem->next()) {
                     $arrPages[] = sprintf($strUrl, $objItem->alias != '' && !\Config::get('disableAlias') ? $objItem->alias : $objItem->id);
                 }
             }
         }
     }
     return $arrPages;
 }
示例#13
0
 /**
  * Generate the module
  */
 protected function compile()
 {
     global $objPage;
     $this->Template->content = '';
     $this->Template->referer = 'javascript:history.go(-1)';
     $this->Template->back = $GLOBALS['TL_LANG']['MSC']['goBack'];
     $objNewsletter = \NewsletterModel::findSentByParentAndIdOrAlias(\Input::get('items'), $this->nl_channels);
     if ($objNewsletter === null) {
         // Do not index or cache the page
         $objPage->noSearch = 1;
         $objPage->cache = 0;
         // Send a 404 header
         header('HTTP/1.1 404 Not Found');
         $this->Template->content = '<p class="error">' . sprintf($GLOBALS['TL_LANG']['MSC']['invalidPage'], \Input::get('items')) . '</p>';
         return;
     }
     $arrEnclosures = array();
     // Add enclosure
     if ($objNewsletter->addFile) {
         $arrEnclosure = deserialize($objNewsletter->files, true);
         $allowedDownload = trimsplit(',', strtolower($GLOBALS['TL_CONFIG']['allowedDownload']));
         if (is_array($arrEnclosure)) {
             // Send file to the browser
             if (\Input::get('file', true) != '' && in_array(\Input::get('file', true), $arrEnclosure)) {
                 $this->sendFileToBrowser(\Input::get('file', true));
             }
             // Add download links
             for ($i = 0; $i < count($arrEnclosure); $i++) {
                 if (is_file(TL_ROOT . '/' . $arrEnclosure[$i])) {
                     $objFile = new \File($arrEnclosure[$i]);
                     if (in_array($objFile->extension, $allowedDownload)) {
                         $src = 'system/themes/' . $this->getTheme() . '/images/' . $objFile->icon;
                         if (($imgSize = @getimagesize(TL_ROOT . '/' . $src)) !== false) {
                             $arrEnclosures[$i]['size'] = ' ' . $imgSize[3];
                         }
                         $arrEnclosures[$i]['icon'] = TL_FILES_URL . $src;
                         $arrEnclosures[$i]['link'] = basename($arrEnclosure[$i]);
                         $arrEnclosures[$i]['filesize'] = $this->getReadableSize($objFile->filesize);
                         $arrEnclosures[$i]['title'] = ucfirst(str_replace('_', ' ', $objFile->filename));
                         $arrEnclosures[$i]['href'] = \Environment::get('request') . ($GLOBALS['TL_CONFIG']['disableAlias'] || strpos(\Environment::get('request'), '?') !== false ? '&amp;' : '?') . 'file=' . $this->urlEncode($arrEnclosure[$i]);
                         $arrEnclosures[$i]['enclosure'] = $arrEnclosure[$i];
                     }
                 }
             }
         }
     }
     // Support plain text newsletters (thanks to Hagen Klemp)
     if ($objNewsletter->sendText) {
         $nl2br = $objPage->outputFormat == 'xhtml' ? 'nl2br_xhtml' : 'nl2br_html5';
         $strContent = $nl2br($objNewsletter->text);
     } else {
         $strContent = str_ireplace(' align="center"', '', $objNewsletter->content);
     }
     // Parse simple tokens and insert tags
     $strContent = $this->replaceInsertTags($strContent);
     $strContent = \String::parseSimpleTokens($strContent, array());
     // Encode e-mail addresses
     $strContent = \String::encodeEmail($strContent);
     $this->Template->content = $strContent;
     $this->Template->subject = $objNewsletter->subject;
     $this->Template->enclosure = $arrEnclosures;
 }
示例#14
0
 /**
  * Add newsletters to the indexer
  * @param array
  * @param integer
  * @param boolean
  * @return array
  */
 public function getSearchablePages($arrPages, $intRoot = 0, $blnIsSitemap = false)
 {
     $arrRoot = array();
     if ($intRoot > 0) {
         $arrRoot = $this->getChildRecords($intRoot, 'tl_page');
     }
     $arrProcessed = array();
     // Get all channels
     $objNewsletter = \NewsletterChannelModel::findAll();
     // Walk through each channel
     if ($objNewsletter !== null) {
         while ($objNewsletter->next()) {
             // Skip channels without target page
             if (!$objNewsletter->jumpTo) {
                 continue;
             }
             // Skip channels outside the root nodes
             if (!empty($arrRoot) && !in_array($objNewsletter->jumpTo, $arrRoot)) {
                 continue;
             }
             // Get the URL of the jumpTo page
             if (!isset($arrProcessed[$objNewsletter->jumpTo])) {
                 $domain = \Environment::get('base');
                 $objParent = $this->getPageDetails($objNewsletter->jumpTo);
                 if ($objParent->domain != '') {
                     $domain = (\Environment::get('ssl') ? 'https://' : 'http://') . $objParent->domain . TL_PATH . '/';
                 }
                 $arrProcessed[$objNewsletter->jumpTo] = $domain . $this->generateFrontendUrl($objParent->row(), $GLOBALS['TL_CONFIG']['useAutoItem'] ? '/%s' : '/items/%s', $objParent->language);
             }
             $strUrl = $arrProcessed[$objNewsletter->jumpTo];
             // Get the items
             $objItem = \NewsletterModel::findSentByPid($objNewsletter->id);
             if ($objItem !== null) {
                 while ($objItem->next()) {
                     $arrPages[] = sprintf($strUrl, $objItem->alias != '' && !$GLOBALS['TL_CONFIG']['disableAlias'] ? $objItem->alias : $objItem->id);
                 }
             }
         }
     }
     return $arrPages;
 }
示例#15
0
 function createComponent($name)
 {
     switch ($name) {
         /*
          * newsletterTabella
          */
         case 'newsletterTabella':
             $grid = new Tabella(NewsletterModel::getFluent()->toDataSource(), array('sorting' => 'desc', 'order' => 'adddate', 'id_table' => 'id', 'limit' => 100, 'onSuccess' => function ($values) {
                 NewsletterModel::edit($values, $values['id_newsletter_emails']);
             }, 'onDelete' => function ($id_newsletter_emails) {
                 NewsletterModel::delete($id_newsletter_emails);
             }));
             $el = NHtml::el("div");
             $session = NEnvironment::getSession('checked_emails');
             $grid->addColumn($el, "", array("editable" => false, 'filter' => false, "width" => 20, "renderer" => function ($row) use($session) {
                 $el = NHtml::el("td");
                 $checked = isset($session->emails[$row['id_newsletter_emails']]) ? 'checked="checked"' : '';
                 $el->add('<input class="checked_emails" type="checkbox" name="se[]" value="' . $row['id_newsletter_emails'] . '" ' . $checked . '/>');
                 return $el;
             }));
             $grid->addColumn("Id", "id_newsletter_emails", array("width" => 30, 'editable' => false));
             $grid->addColumn("Email", "email", array("width" => 50, 'editable' => false));
             //				$grid->addColumn( "Popis", "description", array( 'editable'=>true ) );
             $grid->addColumn("Dátum registrácie ", "adddate", array("width" => 100));
             /*$grid->addColumn( "Aktívny", "active",
             						array(
             							"width" => 50,
             							'type'=>  Tabella::SELECT,
             							"editable" => true,
             							"filter" => array( 1=>'áno', 0=>'nie'),
             							'renderer' => function($row){
             								$active = ($row['active'] == 1)?'áno':'nie';
             								$el = NHtml::el( "td" )->setHtml($active);
             								return $el;
             							}
             						)
             				);
             
             
             				$grid->addColumn("", "",
             					array(
             						"width" => 30,
             						'filter'=>NULL,
             						"options" => '',
             
             						"renderer" => function( $row ) {
             							$el = NHtml::el( "td" );
             
             							$el->add(
             							NHtml::el( 'a' )->href(
             								NEnvironment::getApplication()->getPresenter()->link( 'deleteEmail!' , array('id'=>$row->id_newsletter_emails))
             							)->addClass( 'deleteIcon' )
             							);
             
             							$span = NHtml::el('span');
             
             
             							$el->add($span);
             
             							return $el;
             						}
             						)
             					);
             */
             $this->addComponent($grid, $name);
             break;
             /*
              * newslette text
              */
         /*
          * newslette text
          */
         case 'newsletterTextForm':
             $last_newsletter = dibi::fetch("SELECT * FROM [newsletter_sended_msg] ORDER BY [date] DESC LIMIT 1");
             $f = new MyForm($this, $name);
             $f->addText('subject', 'Predmet')->addRule(NForm::FILLED, 'Predmet musí byť vyplnený.');
             $f->addTextArea('text', '');
             $f->addText('my_email', 'Testovací email');
             $f->addSubmit('btn_send_emails', 'Odoslať všetkým')->onClick[] = array($this, 'actionSendEmails');
             $f->addSubmit('btn_send_to_me', 'Odoslať testovací email')->onClick[] = array($this, 'actionSendTestingEmail');
             if (!$last_newsletter) {
                 $email_template = new NFileTemplate();
                 $email_template->registerFilter(new NLatteFilter());
                 $email_template->setFile(WWW_DIR . '/newsletter/templates/1/1.phtml');
                 $email_template->text = '';
                 $values['text'] = (string) $email_template;
             } else {
                 $values = $last_newsletter;
             }
             $f->setDefaults($values);
             return $f;
             break;
         case 'addForm':
             $f = new MyForm();
             $f->addText('emails', 'Email');
             $f->addSubmit('btn', 'Pridať');
             $f->onSuccess[] = array($this, 'handleAddEmail');
             return $f;
             break;
         default:
             return parent::createComponent($name);
             break;
     }
 }
示例#16
0
 public function sendarticle()
 {
     $post_id = Input::get('id');
     $post = \PostLang::where('post_id', $post_id)->first();
     if ($post) {
         $data['post'] = $post;
         $data['post_url'] = url("/../" . \WebAPL\Language::ext() . "/topost/" . $post_id);
         Template::viewModule($this->module_name, function () use($data, $post) {
             $newsletterUsers = \NewsletterModel::where('enabled', 1)->get();
             foreach ($newsletterUsers as $user) {
                 if (filter_var($user->email, FILTER_VALIDATE_EMAIL)) {
                     $data['user'] = $user;
                     $data['unsubscribe_link'] = url("/../newsletter/unsubscribe/{$user->hash}");
                     Mail::send('views.emails.post', $data, function ($message) use($post, $user) {
                         $message->from("noreply@{$_SERVER['SERVER_NAME']}", 'WebLPA');
                         $message->subject($post->title . " :: NEWSLETTER");
                         $message->to($user->email);
                     });
                 }
             }
         });
     }
 }