getURLForBlock() public static method

Get the URL for a give module & action combination
public static getURLForBlock ( string $module, string $action = null, string $language = null, array $data = null ) : string
$module string The module wherefore the URL should be build.
$action string The specific action wherefore the URL should be build.
$language string The language wherein the URL should be retrieved, if not provided we will load the language that was provided in the URL.
$data array An array with keys and values that partially or fully match the data of the block. If it matches multiple versions of that block it will just return the first match.
return string
Beispiel #1
0
    public static function getAlbumsForOverview()
    {
        $return = (array) FrontendModel::getContainer()->get('database')->getRecords('	SELECT i.*, m.url, m.data AS meta_data
		 														FROM gallery_albums AS i
																	INNER JOIN meta AS m ON m.id = i.meta_id
																WHERE i.language = ? AND show_in_overview = ?
																ORDER BY sequence ASC', array(FRONTEND_LANGUAGE, 'Y'));
        if (!empty($return)) {
            //--Get link for the categories
            $albumLink = FrontendNavigation::getURLForBlock('Gallery', 'Detail');
            foreach ($return as &$row) {
                //--Create url
                $row['full_url'] = $albumLink . '/' . $row['url'];
                //-- Unserialize
                if (isset($row['meta_data'])) {
                    $row['meta_data'] = @unserialize($row['meta_data']);
                }
                $image = self::getImagesForAlbum($row['id'], 1);
                if (!empty($image)) {
                    foreach ($image as $rowImage) {
                        $row['image'] = $rowImage;
                    }
                }
            }
        }
        return $return;
    }
Beispiel #2
0
 /**
  * Parse the data into the template
  */
 private function parse()
 {
     // get vars
     $title = \SpoonFilter::ucfirst(FL::msg('BlogAllComments'));
     $link = SITE_URL . FrontendNavigation::getURLForBlock('Blog');
     $detailLink = SITE_URL . FrontendNavigation::getURLForBlock('Blog', 'Detail');
     $description = null;
     // create new rss instance
     $rss = new FrontendRSS($title, $link, $description);
     // loop articles
     foreach ($this->items as $item) {
         // init vars
         $title = $item['author'] . ' ' . FL::lbl('On') . ' ' . $item['post_title'];
         $link = $detailLink . '/' . $item['post_url'] . '/#comment-' . $item['id'];
         $description = $item['text'];
         // create new instance
         $rssItem = new FrontendRSSItem($title, $link, $description);
         // set item properties
         $rssItem->setPublicationDate($item['created_on']);
         $rssItem->setAuthor($item['author']);
         // add item
         $rss->addItem($rssItem);
     }
     $rss->parse();
 }
Beispiel #3
0
 /**
  * Execute the action
  */
 public function execute()
 {
     // call parent, this will probably add some general CSS/JS or other required files
     parent::execute();
     // get parameters
     $charset = $this->getContainer()->getParameter('kernel.charset');
     $searchTerm = \SpoonFilter::getPostValue('term', null, '');
     $term = $charset == 'utf-8' ? \SpoonFilter::htmlspecialchars($searchTerm) : \SpoonFilter::htmlentities($searchTerm);
     $limit = (int) $this->get('fork.settings')->get('Search', 'autocomplete_num_items', 10);
     // validate
     if ($term == '') {
         $this->output(self::BAD_REQUEST, null, 'term-parameter is missing.');
     } else {
         // get matches
         $matches = FrontendSearchModel::getStartsWith($term, FRONTEND_LANGUAGE, $limit);
         // get search url
         $url = FrontendNavigation::getURLForBlock('Search');
         // loop items and set search url
         foreach ($matches as &$match) {
             $match['url'] = $url . '?form=search&q=' . $match['term'];
         }
         // output
         $this->output(self::OK, $matches);
     }
 }
 /**
  * Validate the form
  */
 protected function validateForm()
 {
     if ($this->frm->isSubmitted()) {
         $fields = $this->frm->getFields();
         if ($fields['email']->isEmail(FL::err('EmailIsInvalid'))) {
         }
         if (FrontendMailengineModel::isSubscribed($fields['email']->getValue())) {
             $fields['email']->addError(FL::err('AlreadySubscribed'));
         }
         if ($this->frm->isCorrect()) {
             //--Subscribe
             $id = FrontendMailengineModel::subscribe($fields['email']->getValue());
             //--Get the default group
             $defaultGroup = FrontendModel::getModuleSetting($this->module, 'default_group');
             if ($defaultGroup > 0) {
                 $data = array();
                 $data['user_id'] = $id;
                 $data['group_id'] = $defaultGroup;
                 //--Add user to group
                 FrontendMailengineModel::insertUserToGroup($data);
             }
             // redirect
             $this->redirect(FrontendNavigation::getURLForBlock('Mailengine', 'MailengineSubscribe') . '?sent=true#subscribe');
         }
     }
     $this->frm->parse($this->tpl);
 }
Beispiel #5
0
 /**
  * Load the data, don't forget to validate the incoming data
  */
 private function getData()
 {
     // requested page
     $requestedPage = $this->URL->getParameter('page', 'int', 1);
     // set URL and limit
     $this->pagination['url'] = FrontendNavigation::getURLForBlock('catalog');
     $this->pagination['limit'] = FrontendModel::getModuleSetting('catalog', 'overview_num_items', 10);
     // populate count fields in pagination
     $this->pagination['num_items'] = FrontendCatalogModel::getAllCount();
     $this->pagination['num_pages'] = (int) ceil($this->pagination['num_items'] / $this->pagination['limit']);
     // num pages is always equal to at least 1
     if ($this->pagination['num_pages'] == 0) {
         $this->pagination['num_pages'] = 1;
     }
     // redirect if the request page doesn't exist
     if ($requestedPage > $this->pagination['num_pages'] || $requestedPage < 1) {
         $this->redirect(FrontendNavigation::getURL(404));
     }
     // populate calculated fields in pagination
     $this->pagination['requested_page'] = $requestedPage;
     $this->pagination['offset'] = $this->pagination['requested_page'] * $this->pagination['limit'] - $this->pagination['limit'];
     // get all categories
     $this->categories = FrontendCatalogModel::getAllCategories();
     // get tree of all categories
     $this->categoriesTree = FrontendCatalogModel::getCategoriesTree();
     // get all products
     $this->products = FrontendCatalogModel::getAll($this->pagination['limit'], $this->pagination['offset']);
 }
Beispiel #6
0
 /**
  * Load the data, don't forget to validate the incoming data
  */
 private function getData()
 {
     // requested page
     $requestedPage = $this->URL->getParameter('page', 'int', 1);
     $this->firstName = Cookie::get('fname');
     $this->catalogUrl = FrontendNavigation::getURLForBlock('Catalog');
 }
 /**
  * Parse
  */
 private function parse()
 {
     // get categories
     $categories = FrontendCatalogModel::getAllCategories();
     $count = 0;
     // any categories?
     if (!empty($categories)) {
         // build link
         $link = FrontendNavigation::getURLForBlock('Catalog', 'Category');
         // loop and reset url
         foreach ($categories as $key => &$row) {
             if ($row['parent_id'] > 0 || $count >= 4) {
                 unset($categories[$key]);
                 continue;
             }
             //--Create url
             $row['url'] = $link . '/' . $row['url'];
             //--Get image
             $row['image'] = FrontendMediaHelper::getFromModule('Catalog', $row['id'], 0, 1, 'category');
             //--add count
             $count++;
         }
     }
     // assign comments
     $this->tpl->assign('categories', $categories);
 }
Beispiel #8
0
 /**
  * Execute the extra
  *
  * @return void
  */
 public function execute()
 {
     parent::execute();
     // Define email from the subscribe widget
     $email = $this->getEmail();
     // Create the form
     $form = $this->createForm($this->get('mailmotor.form.subscription'), new Subscription($email, FRONTEND_LANGUAGE));
     $form->handleRequest($this->get('request'));
     if (!$form->isValid()) {
         $this->tpl->assign('form', $form->createView());
         if ($form->isSubmitted()) {
             $this->tpl->assign('mailmotorSubscribeHasFormError', true);
         }
         $this->loadTemplate();
         $this->parse();
         return;
     }
     $redirectLink = FrontendNavigation::getURLForBlock('Mailmotor', 'Subscribe') . '?subscribed=true';
     /** @var Subscription $subscription */
     $subscription = $form->getData();
     try {
         // The command bus will handle the unsubscription
         $this->get('command_bus')->handle($subscription);
     } catch (NotImplementedException $e) {
         // fallback for when no mail-engine is chosen in the Backend
         $this->get('event_dispatcher')->dispatch(NotImplementedSubscribedEvent::EVENT_NAME, new NotImplementedSubscribedEvent($subscription));
         $redirectLink .= '&double-opt-in=false';
     }
     $redirectLink .= '#mailmotorSubscribeForm';
     return $this->redirect($redirectLink);
 }
Beispiel #9
0
 /**
  * Load the data, don't forget to validate the incoming data
  */
 private function getData()
 {
     // validate incoming parameters
     if ($this->URL->getParameter(1) === null) {
         $this->redirect(FrontendNavigation::getURL(404));
     }
     // get by URL
     $this->record = FrontendFaqModel::get($this->URL->getParameter(1));
     // anything found?
     if (empty($this->record)) {
         $this->redirect(FrontendNavigation::getURL(404));
     }
     // overwrite URLs
     $this->record['category_full_url'] = FrontendNavigation::getURLForBlock('Faq', 'Category') . '/' . $this->record['category_url'];
     $this->record['full_url'] = FrontendNavigation::getURLForBlock('Faq', 'Detail') . '/' . $this->record['url'];
     // get tags
     $this->record['tags'] = FrontendTagsModel::getForItem('Faq', $this->record['id']);
     // get settings
     $this->settings = $this->get('fork.settings')->getForModule('Faq');
     // reset allow comments
     if (!$this->settings['allow_feedback']) {
         $this->record['allow_feedback'] = false;
     }
     // ge status
     $this->status = $this->URL->getParameter(2);
     if ($this->status == FL::getAction('Success')) {
         $this->status = 'success';
     }
     if ($this->status == FL::getAction('Spam')) {
         $this->status = 'spam';
     }
 }
 /**
  * Get the data
  *
  * @return void
  */
 private function getData()
 {
     // get all galleries
     $this->items = FrontendSlideshowModel::getGalleries();
     // full url assets
     $this->full_url = FrontendNavigation::getURLForBlock('Slideshow', 'Detail');
     $this->full_url_category = FrontendNavigation::getURLForBlock('Slideshow', 'Category');
 }
Beispiel #11
0
 /**
  * Load the form
  */
 private function loadForm()
 {
     $this->frm = new FrontendForm('subscribe', null, null, 'subscribeForm');
     $this->frm->setAction(FrontendNavigation::getURLForBlock('Mailmotor', 'Subscribe'));
     $this->frm->addText('email')->setAttributes(array('required' => null, 'type' => 'email'));
     $this->frm->parse($this->tpl);
     $this->tpl->assign('formToken', $this->frm->getToken());
 }
 /**
  * Load the data
  */
 protected function loadData()
 {
     //--Get the send mailing
     $this->record = FrontendMailengineModel::getSend($this->id);
     //--Create iframe
     $iframe = FrontendNavigation::getURLForBlock('Mailengine', 'MailenginePreview') . "?id=" . $this->id;
     $this->tpl->assign('iframe', $iframe);
 }
Beispiel #13
0
 /**
  * Execute the extra
  */
 public function execute()
 {
     parent::execute();
     $this->loadTemplate();
     // Check if we're logged in, else redirect to the login form.
     if (!FrontendProfilesAuthentication::isLoggedIn()) {
         $queryString = $this->URL->getQueryString();
         throw new RedirectException('Redirect', new RedirectResponse(Navigation::getURLForBlock('Profiles', 'Login') . '?queryString=' . $queryString));
     }
 }
Beispiel #14
0
 /**
  * Parse the data into the template
  */
 private function parse()
 {
     // get vars
     $title = isset($this->settings['rss_title_' . LANGUAGE]) ? $this->settings['rss_title_' . LANGUAGE] : $this->get('fork.settings')->get('Blog', 'rss_title_' . LANGUAGE, SITE_DEFAULT_TITLE);
     $link = SITE_URL . FrontendNavigation::getURLForBlock('Blog');
     $description = isset($this->settings['rss_description_' . LANGUAGE]) ? $this->settings['rss_description_' . LANGUAGE] : null;
     // create new rss instance
     $rss = new FrontendRSS($title, $link, $description);
     // loop articles
     foreach ($this->items as $item) {
         // init vars
         $title = $item['title'];
         $link = $item['full_url'];
         $description = $item['introduction'] != '' ? $item['introduction'] : $item['text'];
         // meta is wanted
         if ($this->get('fork.settings')->get('Blog', 'rss_meta_' . LANGUAGE, true)) {
             // append meta
             $description .= '<div class="meta">' . "\n";
             $description .= '    <p><a href="' . $link . '" title="' . $title . '">' . $title . '</a> ' . sprintf(FL::msg('WrittenBy'), FrontendUser::getBackendUser($item['user_id'])->getSetting('nickname'));
             $description .= ' ' . FL::lbl('In') . ' <a href="' . $item['category_full_url'] . '" title="' . $item['category_title'] . '">' . $item['category_title'] . '</a>.</p>' . "\n";
             // any tags
             if (isset($item['tags'])) {
                 // append tags-paragraph
                 $description .= '    <p>' . \SpoonFilter::ucfirst(FL::lbl('Tags')) . ': ';
                 $first = true;
                 // loop tags
                 foreach ($item['tags'] as $tag) {
                     // prepend separator
                     if (!$first) {
                         $description .= ', ';
                     }
                     // add
                     $description .= '<a href="' . $tag['full_url'] . '" rel="tag" title="' . $tag['name'] . '">' . $tag['name'] . '</a>';
                     // reset
                     $first = false;
                 }
                 // end
                 $description .= '.</p>' . "\n";
             }
             // end HTML
             $description .= '</div>' . "\n";
         }
         // create new instance
         $rssItem = new FrontendRSSItem($title, $link, $description);
         // set item properties
         $rssItem->setPublicationDate($item['publish_on']);
         $rssItem->addCategory($item['category_title']);
         $rssItem->setAuthor(FrontendUser::getBackendUser($item['user_id'])->getSetting('nickname'));
         // add item
         $rss->addItem($rssItem);
     }
     // output
     $rss->parse();
 }
Beispiel #15
0
 /**
  * Parse the data into the template
  */
 private function parse()
 {
     // get RSS-link
     $rssLink = FrontendNavigation::getURLForBlock('Blog', 'Rss');
     // add RSS-feed
     $this->header->addLink(array('rel' => 'alternate', 'type' => 'application/rss+xml', 'title' => $this->get('fork.settings')->get('Blog', 'rss_title_' . FRONTEND_LANGUAGE), 'href' => $rssLink), true);
     // assign articles
     $this->tpl->assign('items', $this->items);
     // parse the pagination
     $this->parsePagination();
 }
Beispiel #16
0
 /**
  * Parse
  */
 private function parse()
 {
     // get RSS-link
     $rssTitle = $this->get('fork.settings')->get('Blog', 'rss_title_' . FRONTEND_LANGUAGE);
     $rssLink = FrontendNavigation::getURLForBlock('Blog', 'Rss');
     // add RSS-feed into the metaCustom
     $this->header->addRssLink($rssTitle, $rssLink);
     // assign comments
     $this->tpl->assign('widgetBlogRecentArticlesList', FrontendBlogModel::getAll($this->get('fork.settings')->get('Blog', 'recent_articles_list_num_items', 5)));
     $this->tpl->assign('widgetBlogRecentArticlesFullRssLink', $rssLink);
 }
Beispiel #17
0
 /**
  * Load the form
  */
 private function loadForm()
 {
     // don't show the form if someone is logged in
     if (FrontendProfilesAuthentication::isLoggedIn()) {
         return;
     }
     $this->frm = new FrontendForm('login', FrontendNavigation::getURLForBlock('Profiles', 'Login'));
     $this->frm->addText('email')->setAttributes(array('required' => null, 'type' => 'email'));
     $this->frm->addPassword('password')->setAttributes(array('required' => null));
     $this->frm->addCheckbox('remember', true);
     // parse the form
     $this->frm->parse($this->tpl);
 }
Beispiel #18
0
 /**
  * Load the data, don't forget to validate the incoming data
  */
 private function getData()
 {
     // validate incoming parameters
     if ($this->URL->getParameter(1) === null) {
         $this->redirect(FrontendNavigation::getURL(404));
     }
     // get by URL
     $this->record = FrontendFaqModel::getCategory($this->URL->getParameter(1));
     // anything found?
     if (empty($this->record)) {
         $this->redirect(FrontendNavigation::getURL(404));
     }
     $this->record['full_url'] = FrontendNavigation::getURLForBlock('Faq', 'Category') . '/' . $this->record['url'];
     $this->questions = FrontendFaqModel::getAllForCategory($this->record['id']);
 }
 /**
  * Get the data
  *
  * @return void
  */
 private function getData()
 {
     // check for errors
     if ($this->URL->getParameter(1) === null) {
         $this->redirect(FrontendNavigation::getURL(404));
     }
     // get the gallery meta based on the url
     $this->record = FrontendSlideshowModel::getGalleriesByURL($this->URL->getParameter(1));
     // redirect if nothing is found
     if (empty($this->record)) {
         $this->redirect(FrontendNavigation::getURL(404));
     }
     // full url asset
     $this->full_url = FrontendNavigation::getURLForBlock('Slideshow', 'detail');
     $this->full_url_category = FrontendNavigation::getURLForBlock('Slideshow', 'category');
 }
Beispiel #20
0
 /**
  * Execute the extra.
  */
 public function execute()
 {
     // only logged in profiles can seer their dashboard
     if (FrontendProfilesAuthentication::isLoggedIn()) {
         // call the parent
         parent::execute();
         /*
          * You could use this as some kind of dashboard where you can show an activity
          * stream, some statistics, ...
          */
         $this->loadTemplate();
     } else {
         // profile not logged in
         $this->redirect(FrontendNavigation::getURLForBlock('Profiles', 'Login') . '?queryString=' . FrontendNavigation::getURLForBlock('Profiles'), 307);
     }
 }
Beispiel #21
0
 /**
  * Parse
  */
 private function parse()
 {
     // get categories
     $categories = FrontendAgendaModel::getAllCategories();
     // any categories?
     if (!empty($categories)) {
         // build link
         $link = FrontendNavigation::getURLForBlock('Agenda', 'Category');
         // loop and reset url
         foreach ($categories as &$row) {
             $row['url'] = $link . '/' . $row['url'];
         }
     }
     // assign comments
     $this->tpl->assign('widgetAgendaCategories', $categories);
 }
 /**
  * Validate the form
  */
 protected function validateForm()
 {
     if ($this->frm->isSubmitted()) {
         $fields = $this->frm->getFields();
         if ($fields['email']->isEmail(FL::err('EmailIsInvalid'))) {
         }
         if (!FrontendMailengineModel::isSubscribed($fields['email']->getValue())) {
             $fields['email']->addError(FL::err('NotSubscribed'));
         }
         if ($this->frm->isCorrect()) {
             //--Subscribe
             FrontendMailengineModel::unsubscribe($fields['email']->getValue());
             // redirect
             $this->redirect(FrontendNavigation::getURLForBlock('Mailengine', 'MailengineUnsubscribe') . '?sent=true#unsubscribe');
         }
     }
     $this->frm->parse($this->tpl);
 }
Beispiel #23
0
 /**
  * Parse
  */
 private function parse()
 {
     // get categories
     $tags = FrontendTagsModel::getAll();
     // we just need the 10 first items
     $tags = array_slice($tags, 0, 10);
     // build link
     $link = FrontendNavigation::getURLForBlock('Tags', 'Detail');
     // any tags?
     if (!empty($tags)) {
         // loop and reset url
         foreach ($tags as &$row) {
             $row['url'] = $link . '/' . $row['url'];
         }
     }
     // assign comments
     $this->tpl->assign('widgetTagsTagCloud', $tags);
 }
Beispiel #24
0
 /**
  * Parse
  */
 private function parse()
 {
     // get categories
     $categories = FrontendCatalogModel::getAllCategories();
     // get tree of all categories
     $tree = FrontendCatalogModel::getCategoriesTree();
     // any categories?
     if (!empty($categories)) {
         // build link
         $link = FrontendNavigation::getURLForBlock('Catalog', 'Category');
         // loop and reset url
         foreach ($categories as &$row) {
             $row['url'] = $link . '/' . $row['url'];
         }
     }
     // assign comments
     $this->tpl->assign('widgetCatalogCategoriesFlat', $categories);
     $this->tpl->assign('widgetCatalogCategoriesTree', $tree);
 }
Beispiel #25
0
 /**
  * Load the data, don't forget to validate the incoming data
  */
 private function getData()
 {
     $parameter_count = count($this->URL->getParameters(false));
     if ($parameter_count <= 0) {
         $this->redirect(FrontendNavigation::getURL(404));
     }
     // get category
     $this->category = FrontendAgendaModel::getCategory($this->URL->getParameter($parameter_count - 1));
     if (empty($this->category)) {
         $this->redirect(FrontendNavigation::getURL(404));
     }
     // requested page
     $requestedPage = $this->URL->getParameter('page', 'int', 1);
     // set URL and limit
     $this->pagination['url'] = FrontendNavigation::getURLForBlock('Agenda', 'Category') . '/' . $this->category['url'];
     $this->pagination['limit'] = FrontendModel::getModuleSetting('Agenda', 'overview_num_items', 10);
     // populate count fields in pagination
     $this->pagination['num_items'] = FrontendAgendaModel::getCategoryCount($this->category['id']);
     $this->pagination['num_pages'] = (int) ceil($this->pagination['num_items'] / $this->pagination['limit']);
     // num pages is always equal to at least 1
     if ($this->pagination['num_pages'] == 0) {
         $this->pagination['num_pages'] = 1;
     }
     // redirect if the request page doesn't exist
     if ($requestedPage > $this->pagination['num_pages'] || $requestedPage < 1) {
         $this->redirect(FrontendNavigation::getURL(404));
     }
     // populate calculated fields in pagination
     $this->pagination['requested_page'] = $requestedPage;
     $this->pagination['offset'] = $this->pagination['requested_page'] * $this->pagination['limit'] - $this->pagination['limit'];
     // timestamps
     // @todo SET CORRECT TIMES
     $startTimestamp = strtotime('last Monday 00:59', time());
     // first day of the week
     $endTimestamp = strtotime("next Monday 0:59", time());
     // last day of the week
     // get items
     $this->items = FrontendAgendaModel::getAllByCategory($this->category['id'], $this->pagination['limit'], $this->pagination['offset'], $startTimestamp, $endTimestamp);
     // sort dates
     usort($this->items, "self::cmpValues");
 }
Beispiel #26
0
 /**
  * Parse the footer into the template
  */
 public function parse()
 {
     $footerLinks = (array) Navigation::getFooterLinks();
     $this->tpl->assign('footerLinks', $footerLinks);
     $siteHTMLFooter = (string) $this->get('fork.settings')->get('Core', 'site_html_footer', null);
     $facebookAdminIds = $this->get('fork.settings')->get('Core', 'facebook_admin_ids', null);
     $facebookAppId = $this->get('fork.settings')->get('Core', 'facebook_app_id', null);
     // facebook admins given?
     if ($facebookAdminIds !== null || $facebookAppId !== null) {
         // add Facebook container
         $siteHTMLFooter .= $this->getFacebookHtml($facebookAppId);
     }
     // add Google sitelinks search box code if wanted.
     if ($this->get('fork.settings')->get('Search', 'use_sitelinks_search_box', true)) {
         $searchUrl = FrontendNavigation::getURLForBlock('Search');
         $url404 = FrontendNavigation::getURL(404);
         if ($searchUrl !== $url404) {
             $siteHTMLFooter .= $this->getSiteLinksCode($searchUrl);
         }
     }
     // assign site wide html
     $this->tpl->assign('siteHTMLFooter', $siteHTMLFooter);
 }
Beispiel #27
0
 /**
  * Validate the form
  */
 private function validateForm()
 {
     // is the form submitted
     if ($this->frm->isSubmitted()) {
         // validate required fields
         $email = $this->frm->getField('email');
         // validate required fields
         if ($email->isEmail(FL::err('EmailIsInvalid'))) {
             if (FrontendMailmotorModel::isSubscribed($email->getValue())) {
                 $email->addError(FL::err('AlreadySubscribed'));
             }
         }
         // no errors
         if ($this->frm->isCorrect()) {
             try {
                 // subscribe the user to our default group
                 if (!FrontendMailmotorCMHelper::subscribe($email->getValue())) {
                     throw new FrontendException('Could not subscribe');
                 }
                 // trigger event
                 FrontendModel::triggerEvent('Mailmotor', 'after_subscribe', array('email' => $email->getValue()));
                 // redirect
                 $this->redirect(FrontendNavigation::getURLForBlock('Mailmotor', 'Subscribe') . '?sent=true#subscribeForm');
             } catch (\Exception $e) {
                 // when debugging we need to see the exceptions
                 if ($this->getContainer()->getParameter('kernel.debug')) {
                     throw $e;
                 }
                 // show error
                 $this->tpl->assign('subscribeHasError', true);
             }
         } else {
             $this->tpl->assign('subscribeHasFormError', true);
         }
     }
 }
Beispiel #28
0
 /**
  * Validate the form
  */
 private function validateForm()
 {
     // is the form submitted
     if ($this->frm->isSubmitted()) {
         // get fields
         $txtOldPassword = $this->frm->getField('old_password');
         $txtNewPassword = $this->frm->getField('new_password');
         // old password filled in?
         if ($txtOldPassword->isFilled(FL::getError('PasswordIsRequired'))) {
             // old password correct?
             if (FrontendProfilesAuthentication::getLoginStatus($this->profile->getEmail(), $txtOldPassword->getValue()) !== FrontendProfilesAuthentication::LOGIN_ACTIVE) {
                 // set error
                 $txtOldPassword->addError(FL::getError('InvalidPassword'));
             }
             // new password filled in?
             $txtNewPassword->isFilled(FL::getError('PasswordIsRequired'));
             // passwords match?
             if ($this->frm->getField('new_password')->getValue() !== $this->frm->getField('verify_new_password')->getValue()) {
                 $this->frm->getField('verify_new_password')->addError(FL::err('PasswordsDontMatch'));
             }
         }
         // no errors
         if ($this->frm->isCorrect()) {
             // update password
             FrontendProfilesAuthentication::updatePassword($this->profile->getId(), $txtNewPassword->getValue());
             // trigger event
             FrontendModel::triggerEvent('Profiles', 'after_change_password', array('id' => $this->profile->getId()));
             // redirect
             $this->redirect(SITE_URL . FrontendNavigation::getURLForBlock('Profiles', 'ChangePassword') . '?sent=true');
         } else {
             $this->tpl->assign('updatePasswordHasFormError', true);
         }
     }
 }
Beispiel #29
0
 /**
  * Get a preview URL to the specific mailing
  *
  * @param int        $id          The id of the mailing.
  * @param string $contentType The content-type to set.
  * @param bool   $forCM       Will this URL be used in Campaign Monitor?
  * @return string
  */
 public static function getMailingPreviewURL($id, $contentType = 'html', $forCM = false)
 {
     // check input
     $contentType = \SpoonFilter::getValue($contentType, array('html', 'plain'), 'html');
     $forCM = \SpoonFilter::getValue($forCM, array(false, true), false, 'int');
     // return the URL
     return SITE_URL . FrontendNavigation::getURLForBlock('Mailmotor', 'Detail') . '/' . $id . '?type=' . $contentType . ($forCM == 1 ? '&cm=' . $forCM : '');
 }
Beispiel #30
0
 /**
  * Load the data, don't forget to validate the incoming data
  */
 private function getData()
 {
     $this->parameters = $this->URL->getParameters();
     $url = end($this->parameters);
     if ($url === null) {
         $this->redirect(FrontendNavigation::getURL(404));
     }
     // get by URL
     $this->record = FrontendCatalogModel::getBrandFromUrl($url);
     if (empty($this->record)) {
         $this->redirect(FrontendNavigation::getURL(404));
     }
     // get products
     $this->products = FrontendCatalogModel::getAllByBrand($this->record['id']);
     // requested page
     $requestedPage = $this->URL->getParameter('page', 'int', 1);
     // set URL and limit
     $this->pagination['url'] = FrontendNavigation::getURLForBlock('catalog', 'category') . '/' . $this->record['url'];
     $this->pagination['limit'] = FrontendModel::getModuleSetting('catalog', 'overview_num_items', 10);
     // populate count fields in pagination
     $this->pagination['num_items'] = FrontendCatalogModel::getCategoryCount($this->record['id']);
     $this->pagination['num_pages'] = (int) ceil($this->pagination['num_items'] / $this->pagination['limit']);
     // num pages is always equal to at least 1
     if ($this->pagination['num_pages'] == 0) {
         $this->pagination['num_pages'] = 1;
     }
     // redirect if the request page doesn't exist
     if ($requestedPage > $this->pagination['num_pages'] || $requestedPage < 1) {
         $this->redirect(FrontendNavigation::getURL(404));
     }
     // populate calculated fields in pagination
     $this->pagination['requested_page'] = $requestedPage;
     $this->pagination['offset'] = $this->pagination['requested_page'] * $this->pagination['limit'] - $this->pagination['limit'];
 }