本文整理汇总了PHP中Frontend\Core\Engine\Navigation::getPageId方法的典型用法代码示例。如果您正苦于以下问题:PHP Navigation::getPageId方法的具体用法?PHP Navigation::getPageId怎么用?PHP Navigation::getPageId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Frontend\Core\Engine\Navigation
的用法示例。
在下文中一共展示了Navigation::getPageId方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* @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']);
}
}
示例2: processQueryString
//.........这里部分代码省略.........
// 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']));
}
}
示例3: load
/**
* Loads the actual components on the page
*/
public function load()
{
// set tracking cookie
Model::getVisitorId();
// get pageId for requested URL
$this->pageId = Navigation::getPageId(implode('/', $this->URL->getPages()));
// 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());
// create header instance
$this->header = new Header($this->getKernel());
// new footer instance
$this->footer = new Footer($this->getKernel());
// get page content
$this->getPageContent();
// 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));
}
示例4: load
/**
* 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));
}
示例5: getIdForTags
/**
* Get the id of an item by the full URL of the current page.
* Selects the proper part of the full URL to get the item's id from the database.
*
* @param FrontendURL $URL The current URL.
* @return int
*/
public static function getIdForTags(FrontendURL $URL)
{
return FrontendNavigation::getPageId($URL->getQueryString());
}
示例6: getSubNavigation
/**
* Get the subnavigation html
* syntax: {{ getsubnavigation($type, $parentId, $startdepth, $enddepth, $excludeIds-splitted-by-dash, $template) }}
*
* NOTE: When supplying more than 1 ID to exclude, the single quotes around the dash-separated list are mandatory.
*
* @param string $type The type of navigation, possible values are: page, footer.
* @param int $pageId The parent wherefore the navigation should be build.
* @param int $startDepth The depth to start from.
* @param int $endDepth The maximum depth that has to be build.
* @param string $excludeIds Which pageIds should be excluded (split them by -).
* @param string $template The template that will be used.
*
* @return string
*/
public static function getSubNavigation($type = 'page', $pageId = 0, $startDepth = 1, $endDepth = null, $excludeIds = null, $template = '/Core/Layout/Templates/Navigation.html.twig')
{
// build excludeIds
if ($excludeIds !== null) {
$excludeIds = (array) explode('-', $excludeIds);
}
// get info about the given page
$pageInfo = Navigation::getPageInfo($pageId);
// validate page info
if ($pageInfo === false) {
return '';
}
// split URL into chunks
$chunks = (array) explode('/', $pageInfo['full_url']);
// remove language chunk
$hasMultiLanguages = FrontendModel::getContainer()->getParameter('site.multilanguage');
$chunks = $hasMultiLanguages ? (array) array_slice($chunks, 2) : (array) array_slice($chunks, 1);
if (count($chunks) == 0) {
$chunks[0] = '';
}
// init var
$parentURL = '';
// build url
for ($i = 0; $i < $startDepth - 1; ++$i) {
$parentURL .= $chunks[$i] . '/';
}
// get parent ID
$parentID = Navigation::getPageId($parentURL);
try {
// get HTML
$return = (string) Navigation::getNavigationHTML($type, $parentID, $endDepth, $excludeIds, (string) $template);
} catch (Exception $e) {
return '';
}
// return the var
if ($return != '') {
return $return;
}
// fallback
return;
}