本文整理汇总了PHP中aTools::validatePageAccess方法的典型用法代码示例。如果您正苦于以下问题:PHP aTools::validatePageAccess方法的具体用法?PHP aTools::validatePageAccess怎么用?PHP aTools::validatePageAccess使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类aTools
的用法示例。
在下文中一共展示了aTools::validatePageAccess方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: preExecute
public static function preExecute($actions)
{
$request = $actions->getRequest();
// Figure out where we are all over again, because there seems to be no clean way
// to get the same controller-free URL that the routing engine gets. TODO:
// ask Fabien how we can do that.
$uri = $actions->getRequest()->getUri();
$uriPrefix = $actions->getRequest()->getUriPrefix();
$uri = substr($uri, strlen($uriPrefix));
if (preg_match("/^\\/[^\\/]+\\.php(.*)\$/", $uri, $matches)) {
$uri = $matches[1];
}
// This will quickly fetch a result that was already cached when we
// ran through the routing table (unless we hit the routing table cache,
// in which case we're looking it up for the first time, also OK)
$page = aPageTable::getMatchingEnginePage($uri, $remainder);
if (!$page) {
throw new sfException('Attempt to access engine action without a page');
}
$page = aPageTable::retrieveByIdWithSlots($page->id);
// We want to do these things the same way executeShow would
aTools::validatePageAccess($actions, $page);
aTools::setPageEnvironment($actions, $page);
// Convenient access to the current page for the subclass
$actions->page = $page;
}
示例2: executeShow
public function executeShow(sfWebRequest $request)
{
$slug = $this->getRequestParameter('slug');
if (substr($slug, 0, 1) !== '/') {
$slug = "/{$slug}";
}
$page = aPageTable::retrieveBySlugWithSlots($slug);
aTools::validatePageAccess($this, $page);
aTools::setPageEnvironment($this, $page);
$this->page = $page;
$this->setTemplate($page->template);
return 'Template';
}
示例3: preExecute
/**
* Poor man's multiple inheritance. This allows us to subclass an existing
* actions class in order to create an engine version of it. See aEngineActions
* for the call to add to your own preExecute method
* @param mixed $actions
*/
public static function preExecute($actions)
{
$request = $actions->getRequest();
// Figure out where we are all over again, because there seems to be no clean way
// to get the same controller-free URL that the routing engine gets. TODO:
// ask Fabien how we can do that.
$uri = urldecode($actions->getRequest()->getUri());
$rr = preg_quote(sfContext::getInstance()->getRequest()->getRelativeUrlRoot(), '/');
if (preg_match("/^(?:https?:\\/\\/[^\\/]+)?{$rr}(?:\\/[^\\/]+\\.php)?(.*)\$/", $uri, $matches)) {
$uri = $matches[1];
} else {
throw new sfException("Unable to parse engine URL {$uri}");
}
// This will quickly fetch a result that was already cached when we
// ran through the routing table (unless we hit the routing table cache,
// in which case we're looking it up for the first time, also OK)
$page = aPageTable::getMatchingEnginePageInfo($uri, $remainder);
if (!$page) {
throw new sfException('Attempt to access engine action without a page');
}
$page = aPageTable::retrieveByIdWithSlots($page['id']);
// We want to do these things the same way executeShow would
aTools::validatePageAccess($actions, $page);
aTools::setPageEnvironment($actions, $page);
// Convenient access to the current page for the subclass
$actions->page = $page;
// If your engine supports allowing the user to choose from several page types
// to distinguish different ways of using your engine, then you'll need to
// return the template name from your show and index actions (and perhaps
// others as appropriate). You can pull that information straight from
// $this->page->template, or you can take advantage of $this->pageTemplate which
// is ready to return as the result of an action (default has been changed
// to Success, other values have their first letter capitalized)
$templates = aTools::getTemplates();
// originalTemplate is what's in the template field of the page, except that
// nulls and empty strings from pre-1.5 Apostrophe have been converted to 'default'
// for consistency
$actions->originalTemplate = $page->template;
if (!strlen($actions->originalTemplate)) {
// Compatibility with 1.4 templates and reasonable Symfony expectations
$actions->originalTemplate = 'default';
}
// pageTemplate is suitable to return from an action. 'default' becomes 'Success'
// (the Symfony standard for a "normal" template's suffix) and other values have
// their first letter capitalized
if ($actions->originalTemplate === 'default') {
$actions->pageTemplate = 'Success';
} else {
$actions->pageTemplate = ucfirst($actions->originalTemplate);
}
}
示例4: executeShow
public function executeShow(sfWebRequest $request)
{
$slug = $this->getRequestParameter('slug');
if (substr($slug, 0, 1) !== '/') {
$slug = "/{$slug}";
}
$page = aPageTable::retrieveBySlugWithSlots($slug);
if (!$page) {
$redirect = Doctrine::getTable('aRedirect')->findOneBySlug($slug);
if ($redirect) {
$page = aPageTable::retrieveByIdWithSlots($redirect->page_id);
return $this->redirect($page->getUrl(), 301);
}
}
aTools::validatePageAccess($this, $page);
aTools::setPageEnvironment($this, $page);
$this->page = $page;
$this->setTemplate($page->template);
return 'Template';
}
示例5: executeShow
/**
* DOCUMENT ME
* @param sfWebRequest $request
* @return mixed
*/
public function executeShow(sfWebRequest $request)
{
$slug = $this->getRequestParameter('slug');
// remove trailing slashes from $slug
$pattern = '/\\/$/';
if (preg_match($pattern, $slug) && $slug != '/') {
sfContext::getInstance()->getConfiguration()->loadHelpers(array('Url'));
$new_slug = preg_replace($pattern, '', $slug);
$slug = addcslashes($slug, '/');
$new_uri = preg_replace('/' . $slug . '/', $new_slug, $request->getUri());
$this->redirect($new_uri);
}
if (substr($slug, 0, 1) !== '/') {
$slug = "/{$slug}";
}
$page = aPageTable::retrieveBySlugWithSlots($slug);
if (!$page) {
$redirect = Doctrine::getTable('aRedirect')->findOneBySlug($slug);
if ($redirect) {
$page = aPageTable::retrieveByIdWithSlots($redirect->page_id);
return $this->redirect($page->getUrl(), 301);
}
}
aTools::validatePageAccess($this, $page);
aTools::setPageEnvironment($this, $page);
$this->page = $page;
$this->setTemplate($page->template);
$tagstring = implode(',', $page->getTags());
if (strlen($tagstring)) {
$this->getResponse()->addMeta('keywords', htmlspecialchars($tagstring));
}
if (strlen($page->getMetaDescription())) {
$this->getResponse()->addMeta('description', $page->getMetaDescription());
}
return 'Template';
}