本文整理汇总了PHP中Frontend\Core\Engine\Navigation::getPageInfo方法的典型用法代码示例。如果您正苦于以下问题:PHP Navigation::getPageInfo方法的具体用法?PHP Navigation::getPageInfo怎么用?PHP Navigation::getPageInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Frontend\Core\Engine\Navigation
的用法示例。
在下文中一共展示了Navigation::getPageInfo方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loadData
/**
* Load the data
*/
private function loadData()
{
// get the current page id
$pageId = $this->getContainer()->get('page')->getId();
$navigation = FrontendNavigation::getNavigation();
$pageInfo = FrontendNavigation::getPageInfo($pageId);
$this->navigation = array();
if (isset($navigation['page'][$pageInfo['parent_id']])) {
$pages = $navigation['page'][$pageInfo['parent_id']];
// store
$pagesPrev = $pages;
$pagesNext = $pages;
// check for current id
foreach ($pagesNext as $key => $value) {
if ((int) $key != (int) $pageId) {
// go to next pointer in array
next($pagesNext);
next($pagesPrev);
} else {
break;
}
}
// get previous page
$this->navigation['previous'] = prev($pagesPrev);
// get next page
$this->navigation['next'] = next($pagesNext);
// get parent page
$this->navigation['parent'] = FrontendNavigation::getPageInfo($pageInfo['parent_id']);
}
}
示例2: __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']);
}
}
示例3: 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']));
}
}
示例4: getTags
/**
* Get tags for current "page"
*/
private function getTags()
{
// get page id
$pageId = $this->getContainer()->get('page')->getId();
// array of excluded records
$this->exclude[] = array('module' => 'Pages', 'other_id' => $pageId);
// get tags for page
$tags = (array) FrontendTagsModel::getForItem('pages', $pageId);
foreach ($tags as $tag) {
$this->tags = array_merge((array) $this->tags, (array) $tag['name']);
}
// get page record
$record = (array) FrontendNavigation::getPageInfo($pageId);
// loop blocks
foreach ((array) $record['extra_blocks'] as $block) {
// set module class
$class = 'Frontend\\Modules\\' . $block['module'] . '\\Engine\\Model';
if (is_callable(array($class, 'getIdForTags'))) {
// get record for module
$record = FrontendTagsModel::callFromInterface($block['module'], $class, 'getIdForTags', $this->URL);
// check if record exists
if (!$record) {
continue;
}
// add to excluded records
$this->exclude[] = array('module' => $block['module'], 'other_id' => $record['id']);
// get record's tags
$tags = (array) FrontendTagsModel::getForItem($block['module'], $record['id']);
foreach ($tags as $tag) {
$this->tags = array_merge((array) $this->tags, (array) $tag['name']);
}
}
}
}
示例5: processPage
/**
* Processes the page
*/
protected function processPage()
{
// set pageTitle
$this->header->setPageTitle($this->record['meta_title'], (bool) ($this->record['meta_title_overwrite'] == 'Y'));
// set meta-data
$this->header->addMetaDescription($this->record['meta_description'], (bool) ($this->record['meta_description_overwrite'] == 'Y'));
$this->header->addMetaKeywords($this->record['meta_keywords'], $this->record['meta_keywords_overwrite'] == 'Y');
$this->header->setMetaCustom($this->record['meta_custom']);
// advanced SEO-attributes
if (isset($this->record['meta_data']['seo_index'])) {
$this->header->addMetaData(array('name' => 'robots', 'content' => $this->record['meta_data']['seo_index']));
}
if (isset($this->record['meta_data']['seo_follow'])) {
$this->header->addMetaData(array('name' => 'robots', 'content' => $this->record['meta_data']['seo_follow']));
}
// create navigation instance
new Navigation($this->getKernel());
// assign content
$pageInfo = Navigation::getPageInfo($this->record['id']);
$this->record['has_children'] = $pageInfo['has_children'];
$this->tpl->assign('page', $this->record);
// set template path
$this->templatePath = FRONTEND_PATH . '/' . $this->record['template_path'];
// loop blocks
foreach ($this->record['positions'] as $position => &$blocks) {
// position not known in template = skip it
if (!in_array($position, $this->record['template_data']['names'])) {
continue;
}
// loop blocks in position
foreach ($blocks as $index => &$block) {
// an extra
if ($block['extra_id'] !== null) {
// block
if ($block['extra_type'] == 'block') {
// create new instance
$extra = new FrontendBlockExtra($this->getKernel(), $block['extra_module'], $block['extra_action'], $block['extra_data']);
if (extension_loaded('newrelic')) {
newrelic_name_transaction($block['extra_module'] . '::' . $block['extra_action']);
}
} else {
// widget
$extra = new FrontendBlockWidget($this->getKernel(), $block['extra_module'], $block['extra_action'], $block['extra_data']);
}
// add to list of extras
$block = array('extra' => $extra);
// add to list of extras to parse
$this->extras[] = $extra;
} else {
// the block only contains HTML
$block = array('blockIsEditor' => true, 'blockContent' => $block['html']);
// Maintain backwards compatibility
$block['blockIsHTML'] = $block['blockIsEditor'];
}
}
}
}
示例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;
}