/** * Parse */ private function parse() { $this->tpl->assign('isLoggedIn', FrontendProfilesAuthentication::isLoggedIn()); if (FrontendProfilesAuthentication::isLoggedIn()) { $profile = FrontendProfilesAuthentication::getProfile(); $this->tpl->assign('profile', $profile->toArray()); } }
/** * Parse */ private function parse() { // assign if logged in $this->tpl->assign('isLoggedIn', FrontendProfilesAuthentication::isLoggedIn()); // is logged in if (FrontendProfilesAuthentication::isLoggedIn()) { // get the profile $profile = FrontendProfilesAuthentication::getProfile(); // assign logged in profile $this->tpl->assign('profile', $profile->toArray()); } }
/** * Get profile data. */ private function getData() { // get profile $this->profile = FrontendProfilesAuthentication::getProfile(); }
/** * Parse the general profiles info into the template. */ public static function parse() { // get the template $tpl = FrontendModel::getContainer()->get('template'); // logged in if (FrontendProfilesAuthentication::isLoggedIn()) { // get profile $profile = FrontendProfilesAuthentication::getProfile(); // display name set? if ($profile->getDisplayName() != '') { $tpl->assign('profileDisplayName', $profile->getDisplayName()); } else { // no display name -> use email $tpl->assign('profileDisplayName', $profile->getEmail()); } // show logged in $tpl->assign('isLoggedIn', true); } // ignore these urls in the query string $ignoreUrls = array(FrontendNavigation::getURLForBlock('Profiles', 'Login'), FrontendNavigation::getURLForBlock('Profiles', 'Register'), FrontendNavigation::getURLForBlock('Profiles', 'ForgotPassword')); // query string $queryString = isset($_GET['queryString']) ? SITE_URL . '/' . urldecode($_GET['queryString']) : SELF; // check all ignore urls foreach ($ignoreUrls as $url) { // query string contains a boeboe url if (stripos($queryString, $url) !== false) { $queryString = ''; break; } } // no need to add this if its empty $queryString = $queryString != '' ? '?queryString=' . urlencode($queryString) : ''; // useful urls $tpl->assign('loginUrl', FrontendNavigation::getURLForBlock('Profiles', 'Login') . $queryString); $tpl->assign('registerUrl', FrontendNavigation::getURLForBlock('Profiles', 'Register')); $tpl->assign('forgotPasswordUrl', FrontendNavigation::getURLForBlock('Profiles', 'ForgotPassword')); }
/** * Loads the actual components on the page */ public function load() { // set tracking cookie Model::getVisitorId(); // create header instance $this->header = new Header($this->getKernel()); // get page content from pageId of the requested URL $this->record = $this->getPageContent(Navigation::getPageId(implode('/', $this->URL->getPages()))); if (empty($this->record)) { $this->record = Model::getPage(404); } // authentication if (BackendModel::isModuleInstalled('Profiles') && isset($this->record['data']['auth_required'])) { $data = $this->record['data']; // is auth required and is profile logged in if ($data['auth_required']) { if (!FrontendAuthenticationModel::isLoggedIn()) { // redirect to login page $queryString = $this->URL->getQueryString(); throw new RedirectException('Redirect', new RedirectResponse(Navigation::getURLForBlock('Profiles', 'Login') . '?queryString=' . $queryString)); } // specific groups for auth? if (!empty($data['auth_groups'])) { $inGroup = false; foreach ($data['auth_groups'] as $group) { if (FrontendAuthenticationModel::getProfile()->isInGroup($group)) { $inGroup = true; } } if (!$inGroup) { $this->record = Model::getPage(404); } } } } // we need to set the correct id $this->pageId = (int) $this->record['id']; // set headers if this is a 404 page if ($this->pageId == 404) { $this->statusCode = 404; if (extension_loaded('newrelic')) { newrelic_name_transaction('404'); } } // create breadcrumb instance $this->breadcrumb = new Breadcrumb($this->getKernel()); // new footer instance $this->footer = new Footer($this->getKernel()); // process page $this->processPage(); // execute all extras linked to the page $this->processExtras(); // store statistics $this->storeStatistics(); // trigger event Model::triggerEvent('Core', 'after_page_processed', array('id' => $this->getId(), 'record' => $this->getRecord(), 'statusCode' => $this->getStatusCode(), 'sessionId' => \SpoonSession::getSessionId(), 'visitorId' => Model::getVisitorId(), 'SESSION' => $_SESSION, 'COOKIE' => $_COOKIE, 'GET' => $_GET, 'POST' => $_POST, 'SERVER' => $_SERVER)); }
/** * Get navigation HTML * * @param string $type The type of navigation the HTML should be build for. * @param int $parentId The parentID to start of. * @param int $depth The maximum depth to parse. * @param array $excludeIds PageIDs to be excluded. * @param string $template The template that will be used. * @param int $depthCounter A counter that will hold the current depth. * * @return string * @throws Exception */ public static function getNavigationHTML($type = 'page', $parentId = 0, $depth = null, $excludeIds = array(), $template = '/Core/Layout/Templates/Navigation.html.twig', $depthCounter = 1) { // get navigation $navigation = self::getNavigation(); // merge the exclude ids with the previously set exclude ids $excludeIds = array_merge((array) $excludeIds, self::$excludedPageIds); // meta-navigation is requested but meta isn't enabled if ($type == 'meta' && (!Model::get('fork.settings')->get('Pages', 'meta_navigation', true) || !isset($navigation['meta']))) { return ''; } // validate if (!isset($navigation[$type])) { throw new Exception('This type (' . $type . ') isn\'t a valid navigation type. Possible values are: page, footer, meta.'); } if (!isset($navigation[$type][$parentId])) { throw new Exception('The parent (' . $parentId . ') doesn\'t exists.'); } // special construction to merge home with its immediate children $mergedHome = false; while (true) { // loop elements foreach ($navigation[$type][$parentId] as $id => $page) { // home is a special item, it should live on the same depth if ($page['page_id'] == 1 && !$mergedHome) { // extra checks otherwise exceptions will wbe triggered. if (!isset($navigation[$type][$parentId]) || !is_array($navigation[$type][$parentId])) { $navigation[$type][$parentId] = array(); } if (!isset($navigation[$type][$page['page_id']]) || !is_array($navigation[$type][$page['page_id']])) { $navigation[$type][$page['page_id']] = array(); } // add children $navigation[$type][$parentId] = array_merge($navigation[$type][$parentId], $navigation[$type][$page['page_id']]); // mark as merged $mergedHome = true; // restart loop continue 2; } // not hidden and not an action if ($page['hidden'] || $page['tree_type'] == 'direct_action') { unset($navigation[$type][$parentId][$id]); continue; } // authentication if (isset($page['data'])) { // unserialize data $page['data'] = unserialize($page['data']); // if auth_required isset and is true if (isset($page['data']['auth_required']) && $page['data']['auth_required']) { // is profile logged? unset if (!FrontendAuthentication::isLoggedIn()) { unset($navigation[$type][$parentId][$id]); continue; } // check if group auth is set if (!empty($page['data']['auth_groups'])) { $inGroup = false; // loop group and set value true if one is found foreach ($page['data']['auth_groups'] as $group) { if (FrontendAuthentication::getProfile()->isInGroup($group)) { $inGroup = true; } } // unset page if not in any of the groups if (!$inGroup) { unset($navigation[$type][$parentId][$id]); } } } } // some ids should be excluded if (in_array($page['page_id'], (array) $excludeIds)) { unset($navigation[$type][$parentId][$id]); continue; } // if the item is in the selected page it should get an selected class if (in_array($page['page_id'], self::$selectedPageIds)) { $navigation[$type][$parentId][$id]['selected'] = true; } else { $navigation[$type][$parentId][$id]['selected'] = false; } // add nofollow attribute if needed if ($page['no_follow']) { $navigation[$type][$parentId][$id]['nofollow'] = true; } else { $navigation[$type][$parentId][$id]['nofollow'] = false; } // meta and footer subpages have the "page" type if ($type == 'meta' || $type == 'footer') { $subType = 'page'; } else { $subType = $type; } // fetch children if needed if (isset($navigation[$subType][$page['page_id']]) && $page['page_id'] != 1 && ($depth == null || $depthCounter + 1 <= $depth)) { $navigation[$type][$parentId][$id]['children'] = self::getNavigationHTML($subType, $page['page_id'], $depth, $excludeIds, $template, $depthCounter + 1); } else { $navigation[$type][$parentId][$id]['children'] = false; } // add parent id $navigation[$type][$parentId][$id]['parent_id'] = $parentId; // add depth $navigation[$type][$parentId][$id]['depth'] = $depthCounter; // set link $navigation[$type][$parentId][$id]['link'] = static::getURL($page['page_id']); // is this an internal redirect? if (isset($page['redirect_page_id']) && $page['redirect_page_id'] != '') { $navigation[$type][$parentId][$id]['link'] = static::getURL((int) $page['redirect_page_id']); } // is this an external redirect? if (isset($page['redirect_url']) && $page['redirect_url'] != '') { $navigation[$type][$parentId][$id]['link'] = $page['redirect_url']; } } // break the loop (it is only used for the special construction with home) break; } // return parsed content return Model::get('templating')->render($template, array('navigation' => $navigation[$type][$parentId])); }