getURL() public static method

Get URL for a given pageId
public static getURL ( integer $pageId, string $language = null ) : string
$pageId integer The pageID wherefore you want the URL.
$language string The language wherein the URL should be retrieved, if not provided we will load the language that was provided in the URL.
return string
 /**
  * Execute the action
  */
 public function execute()
 {
     parent::execute();
     //--Get the id
     $id = $this->URL->getParameter(1);
     //--check if the id is not empty
     if (empty($id)) {
         $this->redirect(FrontendNavigation::getURL(404));
     }
     //--Explode the id
     $ids = explode("-", $id);
     //--check if the id contains 2 elements
     if (count($ids) != 2) {
         $this->redirect(FrontendNavigation::getURL(404));
     }
     //--Get the ids and decrypt
     $send_id = (int) FrontendMailengineModel::decryptId($ids[0]);
     $user_id = (int) FrontendMailengineModel::decryptId($ids[1]);
     //--check if the ids are integers
     if ($send_id <= 0) {
         $this->redirect(FrontendNavigation::getURL(404));
     }
     if ($user_id > 0) {
         $data = array();
         $data["send_id"] = $send_id;
         $data["user_id"] = $user_id;
         //--Add open-mail to the database
         FrontendMailengineModel::insertMailOpen($data);
     }
     //--Create an empty image
     $this->createImage();
     //--Stop the script
     die;
 }
Beispiel #2
0
 /**
  * Execute the extra.
  */
 public function execute()
 {
     // get activation key
     $key = $this->URL->getParameter(0);
     // load template
     $this->loadTemplate();
     // do we have an activation key?
     if (isset($key)) {
         // get profile id
         $profileId = FrontendProfilesModel::getIdBySetting('activation_key', $key);
         // have id?
         if ($profileId != null) {
             // update status
             FrontendProfilesModel::update($profileId, array('status' => 'active'));
             // delete activation key
             FrontendProfilesModel::deleteSetting($profileId, 'activation_key');
             // login profile
             FrontendProfilesAuthentication::login($profileId);
             // trigger event
             FrontendModel::triggerEvent('Profiles', 'after_activate', array('id' => $profileId));
             // show success message
             $this->tpl->assign('activationSuccess', true);
         } else {
             // failure
             $this->redirect(FrontendNavigation::getURL(404));
         }
     } else {
         $this->redirect(FrontendNavigation::getURL(404));
     }
 }
Beispiel #3
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));
     }
     // fetch record
     $this->record = FrontendTagsModel::get($this->URL->getParameter(1));
     // validate record
     if (empty($this->record)) {
         $this->redirect(FrontendNavigation::getURL(404));
     }
     // fetch modules
     $this->modules = FrontendTagsModel::getModulesForTag($this->record['id']);
     // loop modules
     foreach ($this->modules as $module) {
         // get the ids of the items linked to the tag
         $otherIds = (array) $this->get('database')->getColumn('SELECT other_id
              FROM modules_tags
              WHERE module = ? AND tag_id = ?', array($module, $this->record['id']));
         // set module class
         $class = 'Frontend\\Modules\\' . $module . '\\Engine\\Model';
         // get the items that are linked to the tags
         $items = (array) FrontendTagsModel::callFromInterface($module, $class, 'getForTags', $otherIds);
         // add into results array
         if (!empty($items)) {
             $this->results[] = array('name' => $module, 'label' => FL::lbl(\SpoonFilter::ucfirst($module)), 'items' => $items);
         }
     }
 }
Beispiel #4
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';
     }
 }
Beispiel #5
0
 /**
  * Execute the extra.
  */
 public function execute()
 {
     // get reset key
     $key = $this->URL->getParameter(0);
     // do we have an reset key?
     if (isset($key)) {
         // load parent
         parent::execute();
         // load template
         $this->loadTemplate();
         // get profile id
         $profileId = FrontendProfilesModel::getIdBySetting('forgot_password_key', $key);
         // have id?
         if ($profileId !== 0) {
             // load
             $this->loadForm();
             // validate
             $this->validateForm();
         } elseif ($this->URL->getParameter('sent') != 'true') {
             $this->redirect(FrontendNavigation::getURL(404));
         }
         // parse
         $this->parse();
     } else {
         $this->redirect(FrontendNavigation::getURL(404));
     }
 }
Beispiel #6
0
 /**
  * Load the data, don't forget to validate the incoming data
  */
 private function getData()
 {
     // get categories
     $categories = FrontendBlogModel::getAllCategories();
     $possibleCategories = array();
     foreach ($categories as $category) {
         $possibleCategories[$category['url']] = $category['id'];
     }
     // requested category
     $requestedCategory = \SpoonFilter::getValue($this->URL->getParameter(1, 'string'), array_keys($possibleCategories), 'false');
     // requested page
     $requestedPage = $this->URL->getParameter('page', 'int', 1);
     // validate category
     if ($requestedCategory == 'false') {
         $this->redirect(FrontendNavigation::getURL(404));
     }
     // set category
     $this->category = $categories[$possibleCategories[$requestedCategory]];
     // set URL and limit
     $this->pagination['url'] = FrontendNavigation::getURLForBlock('Blog', 'Category') . '/' . $requestedCategory;
     $this->pagination['limit'] = $this->get('fork.settings')->get('Blog', 'overview_num_items', 10);
     // populate count fields in pagination
     $this->pagination['num_items'] = FrontendBlogModel::getAllForCategoryCount($requestedCategory);
     $this->pagination['num_pages'] = (int) ceil($this->pagination['num_items'] / $this->pagination['limit']);
     // redirect if the request page doesn't exists
     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 articles
     $this->items = FrontendBlogModel::getAllForCategory($requestedCategory, $this->pagination['limit'], $this->pagination['offset']);
 }
Beispiel #7
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']);
 }
 protected function redirectLink($link_id)
 {
     //--Get the link
     $link = FrontendMailengineModel::getLink($link_id);
     //--Check if the link is empty -> redirect 404
     if (empty($link)) {
         $this->redirect(FrontendNavigation::getURL(404));
     }
     //--Redirect
     $this->redirect($link["url"]);
 }
Beispiel #9
0
 /**
  * Execute the extra
  */
 public function execute()
 {
     $this->id = $this->URL->getParameter(1);
     // validate incoming parameters
     if ($this->id === null) {
         $this->redirect(FrontendNavigation::getURL(404));
     }
     parent::execute();
     $this->loadTemplate();
     $this->getData();
     $this->parse();
 }
Beispiel #10
0
 /**
  * Load the data
  */
 protected function loadData()
 {
     //--Check the params
     if ($this->URL->getParameter(0) === null) {
         $this->redirect(FrontendNavigation::getURL(404), 404);
     }
     //--Get record
     $this->record = FrontendAddressesModel::get($this->URL->getParameter(1));
     if (empty($this->record)) {
         $this->redirect(FrontendNavigation::getURL(404), 307);
     }
 }
 /**
  * Execute the action
  */
 public function execute()
 {
     parent::execute();
     //--Get the id
     $this->id = \SpoonFilter::getGetValue('id', null, 0, 'int');
     //--Check if mailing exist
     if (!FrontendMailengineModel::extistSend($this->id)) {
         $this->redirect(FrontendNavigation::getURL(404));
     }
     $this->loadTemplate();
     $this->loadData();
     $this->parse();
 }
Beispiel #12
0
 /**
  * Execute the extra
  */
 public function execute()
 {
     // profile not logged in
     if (!FrontendProfilesAuthentication::isLoggedIn()) {
         parent::execute();
         $this->loadTemplate();
         $this->loadForm();
         $this->validateForm();
         $this->parse();
     } else {
         // profile logged in
         $this->redirect(FrontendNavigation::getURL(404));
     }
 }
Beispiel #13
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']);
 }
Beispiel #14
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 record
     $this->record = FrontendBlogModel::get($this->URL->getParameter(1));
     // anything found?
     if (empty($this->record)) {
         $this->redirect(FrontendNavigation::getURL(404));
     }
     // get articles
     $this->items = FrontendBlogModel::getComments($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');
 }
 /**
  * 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
     $this->record = FrontendSlideshowModel::getGalleryByURL($this->URL->getParameter(1));
     if (empty($this->record)) {
         $this->redirect(FrontendNavigation::getURL(404));
     }
     // get image data
     $this->slides = FrontendSlideshowModel::getImages($this->record['gallery_id']);
     // get gallery data
     $this->gallery = FrontendSlideshowModel::getGallery($this->record['gallery_id']);
 }
Beispiel #17
0
 /**
  * @param KernelInterface $kernel
  */
 public function __construct(KernelInterface $kernel)
 {
     parent::__construct($kernel);
     // store in reference
     $this->getContainer()->set('breadcrumb', $this);
     // get more information for the homepage
     $homeInfo = Navigation::getPageInfo(1);
     // add homepage as first item (with correct element)
     $this->addElement($homeInfo['navigation_title'], Navigation::getURL(1));
     // get other pages
     $pages = $this->URL->getPages();
     // init vars
     $items = array();
     $errorURL = Navigation::getUrl(404);
     // loop pages
     while (!empty($pages)) {
         // init vars
         $URL = implode('/', $pages);
         $menuId = Navigation::getPageId($URL);
         $pageInfo = Navigation::getPageInfo($menuId);
         // do we know something about the page
         if ($pageInfo !== false && isset($pageInfo['navigation_title'])) {
             // only add pages that aren't direct actions
             if ($pageInfo['tree_type'] != 'direct_action') {
                 // get URL
                 $pageURL = Navigation::getUrl($menuId);
                 // if this is the error-page, so we won't show an URL.
                 if ($pageURL == $errorURL) {
                     $pageURL = null;
                 }
                 // add to the items
                 $items[] = array('title' => $pageInfo['navigation_title'], 'url' => $pageURL);
             }
         }
         // remove element
         array_pop($pages);
     }
     // reverse so everything is in place
     krsort($items);
     // loop and add elements
     foreach ($items as $row) {
         $this->addElement($row['title'], $row['url']);
     }
 }
Beispiel #18
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 #19
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 #20
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));
     }
     // load revision
     if ($this->URL->getParameter('revision', 'int') != 0) {
         // get data
         $this->record = FrontendBlogModel::getRevision($this->URL->getParameter(1), $this->URL->getParameter('revision', 'int'));
         // add no-index, so the draft won't get accidentally indexed
         $this->header->addMetaData(array('name' => 'robots', 'content' => 'noindex, nofollow'), true);
     } else {
         // get by URL
         $this->record = FrontendBlogModel::get($this->URL->getParameter(1));
     }
     // anything found?
     if (empty($this->record)) {
         $this->redirect(FrontendNavigation::getURL(404));
     }
     // get comments
     $this->comments = FrontendBlogModel::getComments($this->record['id']);
     // get tags
     $this->record['tags'] = FrontendTagsModel::getForItem('Blog', $this->record['id']);
     // get settings
     $this->settings = $this->get('fork.settings')->getForModule('Blog');
     // overwrite URLs
     $this->record['category_full_url'] = FrontendNavigation::getURLForBlock('Blog', 'Category') . '/' . $this->record['category_url'];
     $this->record['full_url'] = FrontendNavigation::getURLForBlock('Blog', 'Detail') . '/' . $this->record['url'];
     $this->record['allow_comments'] = $this->record['allow_comments'] == 'Y';
     $this->record['comments_count'] = count($this->comments);
     // reset allow comments
     if (!$this->settings['allow_comments']) {
         $this->record['allow_comments'] = false;
     }
 }
Beispiel #21
0
 /**
  * Load the data
  */
 private function getRealData()
 {
     // no search term = no search
     if (!$this->term) {
         return;
     }
     // set url
     $this->pagination['url'] = FrontendNavigation::getURLForBlock('Search') . '?form=search&q=' . $this->term;
     // populate calculated fields in pagination
     $this->pagination['limit'] = $this->limit;
     $this->pagination['offset'] = $this->offset;
     $this->pagination['requested_page'] = $this->requestedPage;
     // get items
     $this->items = FrontendSearchModel::search($this->term, $this->pagination['limit'], $this->pagination['offset']);
     // populate count fields in pagination
     // this is done after actual search because some items might be
     // activated/deactivated (getTotal only does rough checking)
     $this->pagination['num_items'] = FrontendSearchModel::getTotal($this->term);
     $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 ($this->requestedPage > $this->pagination['num_pages'] || $this->requestedPage < 1) {
         $this->redirect(FrontendNavigation::getURL(404));
     }
     // debug mode = no cache
     if (!$this->getContainer()->getParameter('kernel.debug')) {
         // set cache content
         $filesystem = new Filesystem();
         $filesystem->dumpFile($this->cacheFile, "<?php\n" . '$pagination = ' . var_export($this->pagination, true) . ";\n" . '$items = ' . var_export($this->items, true) . ";\n?>");
     }
 }
Beispiel #22
0
 /**
  * Process the query string
  */
 private function processQueryString()
 {
     // store the query string local, so we don't alter it.
     $queryString = trim($this->request->getPathInfo(), '/');
     // split into chunks
     $chunks = (array) explode('/', $queryString);
     $hasMultiLanguages = $this->getContainer()->getParameter('site.multilanguage');
     // single language
     if (!$hasMultiLanguages) {
         // set language id
         $language = $this->get('fork.settings')->get('Core', 'default_language', SITE_DEFAULT_LANGUAGE);
     } else {
         // multiple languages
         // default value
         $mustRedirect = false;
         // get possible languages
         $possibleLanguages = (array) Language::getActiveLanguages();
         $redirectLanguages = (array) Language::getRedirectLanguages();
         // the language is present in the URL
         if (isset($chunks[0]) && in_array($chunks[0], $possibleLanguages)) {
             // define language
             $language = (string) $chunks[0];
             // try to set a cookie with the language
             try {
                 // set cookie
                 CommonCookie::set('frontend_language', $language);
             } catch (\SpoonCookieException $e) {
                 // settings cookies isn't allowed, because this isn't a real problem we ignore the exception
             }
             // set sessions
             \SpoonSession::set('frontend_language', $language);
             // remove the language part
             array_shift($chunks);
         } elseif (CommonCookie::exists('frontend_language') && in_array(CommonCookie::get('frontend_language'), $redirectLanguages)) {
             // set languageId
             $language = (string) CommonCookie::get('frontend_language');
             // redirect is needed
             $mustRedirect = true;
         } else {
             // default browser language
             // set languageId & abbreviation
             $language = Language::getBrowserLanguage();
             // try to set a cookie with the language
             try {
                 // set cookie
                 CommonCookie::set('frontend_language', $language);
             } catch (\SpoonCookieException $e) {
                 // settings cookies isn't allowed, because this isn't a real problem we ignore the exception
             }
             // redirect is needed
             $mustRedirect = true;
         }
         // redirect is required
         if ($mustRedirect) {
             // build URL
             // trim the first / from the query string to prevent double slashes
             $url = rtrim('/' . $language . '/' . trim($this->getQueryString(), '/'), '/');
             // when we are just adding the language to the domain, it's a temporary redirect because
             // Safari keeps the 301 in cache, so the cookie to switch language doesn't work any more
             $redirectCode = $url == '/' . $language ? 302 : 301;
             // set header & redirect
             throw new RedirectException('Redirect', new RedirectResponse($url, $redirectCode));
         }
     }
     // define the language
     defined('FRONTEND_LANGUAGE') || define('FRONTEND_LANGUAGE', $language);
     defined('LANGUAGE') || define('LANGUAGE', $language);
     // sets the locale file
     Language::setLocale($language);
     // list of pageIds & their full URL
     $keys = Navigation::getKeys();
     // rebuild our URL, but without the language parameter. (it's tripped earlier)
     $url = implode('/', $chunks);
     $startURL = $url;
     // loop until we find the URL in the list of pages
     while (!in_array($url, $keys)) {
         // remove the last chunk
         array_pop($chunks);
         // redefine the URL
         $url = implode('/', $chunks);
     }
     // remove language from query string
     if ($hasMultiLanguages) {
         $queryString = trim(mb_substr($queryString, mb_strlen($language)), '/');
     }
     // if it's the homepage AND parameters were given (not allowed!)
     if ($url == '' && $queryString != '') {
         // get 404 URL
         $url = Navigation::getURL(404);
         // remove language
         if ($hasMultiLanguages) {
             $url = str_replace('/' . $language, '', $url);
         }
     }
     // set pages
     $url = trim($url, '/');
     // currently not in the homepage
     if ($url != '') {
         // explode in pages
         $pages = explode('/', $url);
         // reset pages
         $this->setPages($pages);
         // reset parameters
         $this->setParameters(array());
     }
     // set parameters
     $parameters = trim(mb_substr($startURL, mb_strlen($url)), '/');
     // has at least one parameter
     if ($parameters != '') {
         // parameters will be separated by /
         $parameters = explode('/', $parameters);
         // set parameters
         $this->setParameters($parameters);
     }
     // pageId, parentId & depth
     $pageId = Navigation::getPageId(implode('/', $this->getPages()));
     $pageInfo = Navigation::getPageInfo($pageId);
     // invalid page, or parameters but no extra
     if ($pageInfo === false || !empty($parameters) && !$pageInfo['has_extra']) {
         // get 404 URL
         $url = Navigation::getURL(404);
         // remove language
         if ($hasMultiLanguages) {
             $url = str_replace('/' . $language, '', $url);
         }
         // remove the first slash
         $url = trim($url, '/');
         // currently not in the homepage
         if ($url != '') {
             // explode in pages
             $pages = explode('/', $url);
             // reset pages
             $this->setPages($pages);
             // reset parameters
             $this->setParameters(array());
         }
     }
     // is this an internal redirect?
     if (isset($pageInfo['redirect_page_id']) && $pageInfo['redirect_page_id'] != '') {
         // get url for item
         $newPageURL = Navigation::getURL((int) $pageInfo['redirect_page_id']);
         $errorURL = Navigation::getURL(404);
         // not an error?
         if ($newPageURL != $errorURL) {
             // redirect
             throw new RedirectException('Redirect', new RedirectResponse($newPageURL, $pageInfo['redirect_code']));
         }
     }
     // is this an external redirect?
     if (isset($pageInfo['redirect_url']) && $pageInfo['redirect_url'] != '') {
         // redirect
         throw new RedirectException('Redirect', new RedirectResponse($pageInfo['redirect_url'], $pageInfo['redirect_code']));
     }
 }
Beispiel #23
0
 /**
  * Load the data, don't forget to validate the incoming data
  */
 private function getData()
 {
     // get parameters
     $this->year = $this->URL->getParameter(1);
     $this->month = $this->URL->getParameter(2);
     // redirect /2010/6 to /2010/06 to avoid duplicate content
     if ($this->month !== null && mb_strlen($this->month) != 2) {
         $queryString = isset($_SERVER['QUERY_STRING']) ? '?' . $_SERVER['QUERY_STRING'] : '';
         $this->redirect(FrontendNavigation::getURLForBlock('Blog', 'Archive') . '/' . $this->year . '/' . str_pad($this->month, 2, '0', STR_PAD_LEFT) . $queryString, 301);
     }
     if (mb_strlen($this->year) != 4) {
         $this->redirect(FrontendNavigation::getURL(404));
     }
     // redefine
     $this->year = (int) $this->year;
     if ($this->month !== null) {
         $this->month = (int) $this->month;
     }
     // validate parameters
     if ($this->year == 0 || $this->month === 0) {
         $this->redirect(FrontendNavigation::getURL(404));
     }
     // requested page
     $requestedPage = $this->URL->getParameter('page', 'int', 1);
     // rebuild url
     $url = $this->year;
     // build timestamp
     if ($this->month !== null) {
         $this->startDate = gmmktime(00, 00, 00, $this->month, 01, $this->year);
         $this->endDate = gmmktime(23, 59, 59, $this->month, gmdate('t', $this->startDate), $this->year);
         $url .= '/' . str_pad($this->month, 2, '0', STR_PAD_LEFT);
     } else {
         // year
         $this->startDate = gmmktime(00, 00, 00, 01, 01, $this->year);
         $this->endDate = gmmktime(23, 59, 59, 12, 31, $this->year);
     }
     // set URL and limit
     $this->pagination['url'] = FrontendNavigation::getURLForBlock('Blog', 'Archive') . '/' . $url;
     $this->pagination['limit'] = $this->get('fork.settings')->get('Blog', 'overview_num_items', 10);
     // populate count fields in pagination
     $this->pagination['num_items'] = FrontendBlogModel::getAllForDateRangeCount($this->startDate, $this->endDate);
     $this->pagination['num_pages'] = (int) ceil($this->pagination['num_items'] / $this->pagination['limit']);
     // redirect if the request page doesn't exists
     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 articles
     $this->items = FrontendBlogModel::getAllForDateRange($this->startDate, $this->endDate, $this->pagination['limit'], $this->pagination['offset']);
 }
Beispiel #24
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'];
 }
Beispiel #25
0
 /**
  * Get the data
  */
 private function getData()
 {
     // validate incoming parameters
     if ($this->URL->getParameter(1) === null) {
         $this->redirect(FrontendNavigation::getURL(404));
     }
     // get record
     $this->record = FrontendAgendaModel::get($this->URL->getParameter(1));
     // check if record is not empty
     if (empty($this->record)) {
         $this->redirect(FrontendNavigation::getURL(404));
     }
     // if parameters given - select parameters, else set original date
     $this->beginDate = date('Y-m-d H:i', $this->URL->getParameter('begindate'));
     $this->endDate = date('Y-m-d H:i', $this->URL->getParameter('enddate'));
     // settings
     $this->settings = $this->get('fork.settings')->getForModule('Agenda');
     // media
     //        $this->images = FrontendAgendaModel::getImages($this->record['id'], $this->settings);
     //        $this->files = FrontendAgendaModel::getFiles($this->record['id']);
     //        $this->videos = FrontendAgendaModel::getVideos($this->record['id']);
     $this->record['image'] = FrontendMediaHelper::getFromModule('Agenda', $this->record['id'], 0, 1, 'Agenda');
     $this->record['images'] = FrontendMediaHelper::getFromModule('Agenda', $this->record['id'], 0, 0, 'Agenda');
     $this->record['allow_subscriptions'] = $this->record['allow_subscriptions'] == 'Y';
     // location
     $this->settings['center']['lat'] = $this->record['lat'];
     $this->settings['center']['lng'] = $this->record['lng'];
     $this->settings['maps_url'] = FrontendAgendaModel::buildUrl($this->settings, array($this->record));
 }
Beispiel #26
0
 /**
  * Get page content
  */
 protected function getPageContent()
 {
     // load revision
     if ($this->URL->getParameter('page_revision', 'int') != 0) {
         // get data
         $this->record = Model::getPageRevision($this->URL->getParameter('page_revision', 'int'));
         // add no-index to meta-custom, so the draft won't get accidentally indexed
         $this->header->addMetaData(array('name' => 'robots', 'content' => 'noindex, nofollow'), true);
     } else {
         // get page record
         $this->record = (array) Model::getPage($this->pageId);
     }
     // empty record (pageId doesn't exists, hope this line is never used)
     if (empty($this->record) && $this->pageId != 404) {
         \SpoonHTTP::redirect(Navigation::getURL(404), 404);
     }
     // init var
     $redirect = true;
     // loop blocks, if all are empty we should redirect to the first child
     foreach ($this->record['positions'] as $blocks) {
         // loop blocks in position
         foreach ($blocks as $block) {
             // HTML provided?
             if ($block['html'] != '') {
                 $redirect = false;
             }
             // an decent extra provided?
             if ($block['extra_type'] == 'block') {
                 $redirect = false;
             }
             // a widget provided
             if ($block['extra_type'] == 'widget') {
                 $redirect = false;
             }
         }
     }
     // should we redirect?
     if ($redirect) {
         // get first child
         $firstChildId = Navigation::getFirstChildId($this->record['id']);
         // validate the child
         if ($firstChildId !== false) {
             // build URL
             $URL = Navigation::getURL($firstChildId);
             // redirect
             \SpoonHTTP::redirect($URL, 301);
         }
     }
 }
Beispiel #27
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::getCategory($url);
     if (empty($this->record)) {
         $this->redirect(FrontendNavigation::getURL(404));
     }
     // get subcategories
     $this->subcategories = FrontendCatalogModel::getAllCategories($this->record['id'], $this->record['url']);
     // get subcategories tree of parent
     $this->subcategoriesTree = FrontendCatalogModel::getCategoriesTree($this->record['id']);
     //--Get all the categories
     $this->categoriesTree = FrontendCatalogModel::getCategoriesTree(0, $this->record['id']);
     // get products
     $this->products = FrontendCatalogModel::getAllByCategory($this->record['id']);
     foreach ($this->products as &$product) {
         $product['image'] = FrontendMediaHelper::getFromModule('Catalog', $product['id'], 0, 1, 'product');
     }
     // 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'];
 }
Beispiel #28
0
 /**
  * Get page content
  *
  * @param $pageId
  *
  * @return array
  * @throws RedirectException
  */
 protected function getPageContent($pageId)
 {
     // load revision
     if ($this->URL->getParameter('page_revision', 'int') != 0) {
         // get data
         $record = Model::getPageRevision($this->URL->getParameter('page_revision', 'int'));
         // add no-index to meta-custom, so the draft won't get accidentally indexed
         $this->header->addMetaData(array('name' => 'robots', 'content' => 'noindex, nofollow'), true);
     } else {
         // get page record
         $record = (array) Model::getPage($pageId);
     }
     if (empty($record)) {
         return array();
     }
     // init var
     $redirect = true;
     // loop blocks, if all are empty we should redirect to the first child
     foreach ($record['positions'] as $blocks) {
         // loop blocks in position
         foreach ($blocks as $block) {
             // HTML provided?
             if ($block['html'] != '') {
                 $redirect = false;
             }
             // an decent extra provided?
             if ($block['extra_type'] == 'block') {
                 $redirect = false;
             }
             // a widget provided
             if ($block['extra_type'] == 'widget') {
                 $redirect = false;
             }
         }
     }
     // should we redirect?
     if ($redirect) {
         // get first child
         $firstChildId = Navigation::getFirstChildId($record['id']);
         // validate the child
         if ($firstChildId !== false) {
             // build URL
             $url = Navigation::getURL($firstChildId);
             // redirect
             throw new RedirectException('Redirect', new RedirectResponse($url, 301));
         }
     }
     return $record;
 }
Beispiel #29
0
 /**
  * Get all category items (at least a chunk)
  *
  * @param int $categoryId
  * @param int[optional] $limit The number of items to get.
  * @param int[optional] $offset The offset.
  * @return array
  */
 public static function getAllByCategory($categoryId, $limit = 10, $offset = 0)
 {
     $items = (array) FrontendModel::get('database')->getRecords('SELECT i.*, m.url
          FROM blocks AS i
          INNER JOIN meta AS m ON i.meta_id = m.id
          WHERE i.category_id = ? AND i.language = ?
          ORDER BY i.sequence ASC, i.id DESC LIMIT ?, ?', array($categoryId, FRONTEND_LANGUAGE, (int) $offset, (int) $limit));
     // no results?
     if (empty($items)) {
         return array();
     }
     // get detail action url
     $detailUrl = Navigation::getURLForBlock('Blocks', 'Detail');
     // prepare items for search
     foreach ($items as &$item) {
         if ($item['page_id'] > 0) {
             $item['link'] = Navigation::getURL($item['page_id']);
         }
         $item['full_url'] = $detailUrl . '/' . $item['url'];
     }
     // return
     return $items;
 }
Beispiel #30
0
 /**
  * Parse the search results for this module
  *
  * Note: a module's search function should always:
  *        - accept an array of entry id's
  *        - return only the entries that are allowed to be displayed, with their array's index being the entry's id
  *
  * @param array $ids The ids of the found results.
  * @return array
  */
 public static function search(array $ids)
 {
     // get db
     $db = FrontendModel::getContainer()->get('database');
     // define ids to ignore
     $ignore = array(404);
     // get items
     $items = (array) $db->getRecords('SELECT p.id, p.title, m.url, p.revision_id AS text
          FROM pages AS p
          INNER JOIN meta AS m ON p.meta_id = m.id
          INNER JOIN themes_templates AS t ON p.template_id = t.id
          WHERE p.id IN (' . implode(', ', $ids) . ') AND p.id NOT IN (' . implode(', ', $ignore) . ') AND p.status = ? AND p.hidden = ? AND p.language = ?', array('active', 'N', FRONTEND_LANGUAGE), 'id');
     // prepare items for search
     foreach ($items as &$item) {
         $item['text'] = implode(' ', (array) $db->getColumn('SELECT pb.html
                  FROM pages_blocks AS pb
                  WHERE pb.revision_id = ?', array($item['text'])));
         $item['full_url'] = FrontendNavigation::getURL($item['id']);
     }
     return $items;
 }