本文整理汇总了PHP中PageManager::resolvePageByPath方法的典型用法代码示例。如果您正苦于以下问题:PHP PageManager::resolvePageByPath方法的具体用法?PHP PageManager::resolvePageByPath怎么用?PHP PageManager::resolvePageByPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PageManager
的用法示例。
在下文中一共展示了PageManager::resolvePageByPath方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: resolvePage
/**
* This function attempts to resolve the given page in to it's Symphony page. If no
* page is given, it is assumed the 'index' is being requested. Before a page row is
* returned, it is checked to see that if it has the 'admin' type, that the requesting
* user is authenticated as a Symphony author. If they are not, the Symphony 403
* page is returned (whether that be set as a user defined page using the page type
* of 403, or just returning the Default Symphony 403 error page). Any URL parameters
* set on the page are added to the `$env` variable before the function returns an
* associative array of page details such as Title, Content Type etc.
*
* @uses FrontendPrePageResolve
* @see __isSchemaValid()
* @param string $page
* The URL of the current page that is being Rendered as returned by `getCurrentPage()`.
* If no URL is provided, Symphony assumes the Page with the type 'index' is being
* requested.
* @return array
* An associative array of page details
*/
public function resolvePage($page = null)
{
if ($page) {
$this->_page = $page;
}
$row = null;
/**
* Before page resolve. Allows manipulation of page without redirection
* @delegate FrontendPrePageResolve
* @param string $context
* '/frontend/'
* @param mixed $row
* @param FrontendPage $page
* An instance of this FrontendPage
*/
Symphony::ExtensionManager()->notifyMembers('FrontendPrePageResolve', '/frontend/', array('row' => &$row, 'page' => &$this->_page));
// Default to the index page if no page has been specified
if ((!$this->_page || $this->_page == '//') && is_null($row)) {
$row = PageManager::fetchPageByType('index');
} else {
if (is_null($row)) {
$page_extra_bits = array();
$pathArr = preg_split('/\\//', trim($this->_page, '/'), -1, PREG_SPLIT_NO_EMPTY);
$handle = array_pop($pathArr);
do {
$path = implode('/', $pathArr);
if ($row = PageManager::resolvePageByPath($handle, $path)) {
$pathArr[] = $handle;
break 1;
} else {
$page_extra_bits[] = $handle;
}
} while ($handle = array_pop($pathArr));
if (empty($pathArr)) {
return false;
}
if (!$this->__isSchemaValid($row['params'], $page_extra_bits)) {
return false;
}
}
}
// Process the extra URL params
$url_params = preg_split('/\\//', $row['params'], -1, PREG_SPLIT_NO_EMPTY);
foreach ($url_params as $var) {
$this->_env['url'][$var] = NULL;
}
if (isset($page_extra_bits)) {
if (!empty($page_extra_bits)) {
$page_extra_bits = array_reverse($page_extra_bits);
}
for ($i = 0, $ii = count($page_extra_bits); $i < $ii; $i++) {
$this->_env['url'][$url_params[$i]] = str_replace(' ', '+', $page_extra_bits[$i]);
}
}
if (!is_array($row) || empty($row)) {
return false;
}
$row['type'] = PageManager::fetchPageTypes($row['id']);
// Make sure the user has permission to access this page
if (!$this->is_logged_in && in_array('admin', $row['type'])) {
$row = PageManager::fetchPageByType('403');
if (empty($row)) {
GenericExceptionHandler::$enabled = true;
throw new SymphonyErrorPage(__('Please login to view this page.') . ' <a href="' . SYMPHONY_URL . '/login/">' . __('Take me to the login page') . '</a>.', __('Forbidden'), 'generic', array('header' => 'HTTP/1.0 403 Forbidden'));
}
$row['type'] = PageManager::fetchPageTypes($row['id']);
}
$row['filelocation'] = PageManager::resolvePageFileLocation($row['path'], $row['handle']);
return $row;
}
示例2: resolvePage
/**
* This function attempts to resolve the given page in to it's Symphony page. If no
* page is given, it is assumed the 'index' is being requested. Before a page row is
* returned, it is checked to see that if it has the 'admin' type, that the requesting
* user is authenticated as a Symphony author. If they are not, the Symphony 403
* page is returned (whether that be set as a user defined page using the page type
* of 403, or just returning the Default Symphony 403 error page). Any URL parameters
* set on the page are added to the `$env` variable before the function returns an
* associative array of page details such as Title, Content Type etc.
*
* @uses FrontendPrePageResolve
* @see __isSchemaValid()
* @param string $page
* The URL of the current page that is being Rendered as returned by `getCurrentPage()`.
* If no URL is provided, Symphony assumes the Page with the type 'index' is being
* requested.
* @return array
* An associative array of page details
*/
public function resolvePage($page = null)
{
if ($page) {
$this->_page = $page;
}
$row = null;
/**
* Before page resolve. Allows manipulation of page without redirection
* @delegate FrontendPrePageResolve
* @param string $context
* '/frontend/'
* @param mixed $row
* @param FrontendPage $page
* An instance of this FrontendPage
*/
Symphony::ExtensionManager()->notifyMembers('FrontendPrePageResolve', '/frontend/', array('row' => &$row, 'page' => &$this->_page));
// Default to the index page if no page has been specified
if ((!$this->_page || $this->_page == '//') && is_null($row)) {
$row = PageManager::fetchPageByType('index');
} else {
if (is_null($row)) {
$page_extra_bits = array();
$pathArr = preg_split('/\\//', trim($this->_page, '/'), -1, PREG_SPLIT_NO_EMPTY);
$handle = array_pop($pathArr);
do {
$path = implode('/', $pathArr);
if ($row = PageManager::resolvePageByPath($handle, $path)) {
$pathArr[] = $handle;
break 1;
} else {
$page_extra_bits[] = $handle;
}
} while ($handle = array_pop($pathArr));
// If the `$pathArr` is empty, that means a page hasn't resolved for
// the given `$page`, however in some cases the index page may allow
// parameters, so we'll check.
if (empty($pathArr)) {
// If the index page does not handle parameters, then return false
// (which will give up the 404), otherwise treat the `$page` as
// parameters of the index. RE: #1351
$index = PageManager::fetchPageByType('index');
if (!$this->__isSchemaValid($index['params'], $page_extra_bits)) {
return false;
} else {
$row = $index;
}
} else {
if (!$this->__isSchemaValid($row['params'], $page_extra_bits)) {
return false;
}
}
}
}
// Process the extra URL params
$url_params = preg_split('/\\//', $row['params'], -1, PREG_SPLIT_NO_EMPTY);
foreach ($url_params as $var) {
$this->_env['url'][$var] = NULL;
}
if (isset($page_extra_bits)) {
if (!empty($page_extra_bits)) {
$page_extra_bits = array_reverse($page_extra_bits);
}
for ($i = 0, $ii = count($page_extra_bits); $i < $ii; $i++) {
$this->_env['url'][$url_params[$i]] = str_replace(' ', '+', $page_extra_bits[$i]);
}
}
if (!is_array($row) || empty($row)) {
return false;
}
$row['type'] = PageManager::fetchPageTypes($row['id']);
// Make sure the user has permission to access this page
if (!$this->is_logged_in && in_array('admin', $row['type'])) {
$row = PageManager::fetchPageByType('403');
if (empty($row)) {
Frontend::instance()->throwCustomError(__('Please login to view this page.') . ' <a href="' . SYMPHONY_URL . '/login/">' . __('Take me to the login page') . '</a>.', __('Forbidden'), Page::HTTP_STATUS_FORBIDDEN);
}
$row['type'] = PageManager::fetchPageTypes($row['id']);
}
$row['filelocation'] = PageManager::resolvePageFileLocation($row['path'], $row['handle']);
return $row;
}