本文整理汇总了PHP中RootURLController::should_be_on_root方法的典型用法代码示例。如果您正苦于以下问题:PHP RootURLController::should_be_on_root方法的具体用法?PHP RootURLController::should_be_on_root怎么用?PHP RootURLController::should_be_on_root使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RootURLController
的用法示例。
在下文中一共展示了RootURLController::should_be_on_root方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
public function init()
{
parent::init();
// If we've accessed the homepage as /home/, then we should redirect to /.
if ($this->dataRecord && $this->dataRecord instanceof SiteTree && RootURLController::should_be_on_root($this->dataRecord) && (!isset($this->urlParams['Action']) || !$this->urlParams['Action']) && !$_POST && !$_FILES && !$this->redirectedTo()) {
$getVars = $_GET;
unset($getVars['url']);
if ($getVars) {
$url = "?" . http_build_query($getVars);
} else {
$url = "";
}
$this->redirect($url, 301);
return;
}
if ($this->dataRecord) {
$this->dataRecord->extend('contentcontrollerInit', $this);
} else {
singleton('SiteTree')->extend('contentcontrollerInit', $this);
}
if ($this->redirectedTo()) {
return;
}
// Check page permissions
if ($this->dataRecord && $this->URLSegment != 'Security' && !$this->dataRecord->canView()) {
return Security::permissionFailure($this);
}
// Use theme from the site config
if (($config = SiteConfig::current_site_config()) && $config->Theme) {
Config::inst()->update('SSViewer', 'theme', $config->Theme);
}
}
示例2: init
public function init()
{
parent::init();
// If we've accessed the homepage as /home/, then we should redirect to /.
if ($this->dataRecord && $this->dataRecord instanceof SiteTree && RootURLController::should_be_on_root($this->dataRecord) && (!isset($this->urlParams['Action']) || !$this->urlParams['Action']) && !$_POST && !$_FILES && !$this->redirectedTo()) {
$getVars = $_GET;
unset($getVars['url']);
if ($getVars) {
$url = "?" . http_build_query($getVars);
} else {
$url = "";
}
$this->redirect($url, 301);
return;
}
if ($this->dataRecord) {
$this->dataRecord->extend('contentcontrollerInit', $this);
} else {
singleton('SiteTree')->extend('contentcontrollerInit', $this);
}
if ($this->redirectedTo()) {
return;
}
// Check page permissions
if ($this->dataRecord && $this->URLSegment != 'Security' && !$this->dataRecord->canView()) {
return Security::permissionFailure($this);
}
// Draft/Archive security check - only CMS users should be able to look at stage/archived content
if ($this->URLSegment != 'Security' && !Session::get('unsecuredDraftSite') && (Versioned::current_archived_date() || Versioned::current_stage() && Versioned::current_stage() != 'Live')) {
if (!$this->dataRecord->canViewStage(Versioned::current_archived_date() ? 'Stage' : Versioned::current_stage())) {
$link = $this->Link();
$message = _t("ContentController.DRAFT_SITE_ACCESS_RESTRICTION", 'You must log in with your CMS password in order to view the draft or archived content. ' . '<a href="%s">Click here to go back to the published site.</a>');
Session::clear('currentStage');
Session::clear('archiveDate');
$permissionMessage = sprintf(_t("ContentController.DRAFT_SITE_ACCESS_RESTRICTION", 'You must log in with your CMS password in order to view the draft or archived content. ' . '<a href="%s">Click here to go back to the published site.</a>'), Controller::join_links($this->Link(), "?stage=Live"));
return Security::permissionFailure($this, $permissionMessage);
}
}
// Use theme from the site config
if (($config = SiteConfig::current_site_config()) && $config->Theme) {
Config::inst()->update('SSViewer', 'theme', $config->Theme);
}
}
示例3: init
public function init()
{
parent::init();
//Log page views
Statistics::collect();
// If we've accessed the homepage as /home/, then we should redirect to /.
if ($this->dataRecord && $this->dataRecord instanceof SiteTree && RootURLController::should_be_on_root($this->dataRecord) && !$this->urlParams['Action'] && !$_POST && !$_FILES && !Director::redirected_to()) {
$getVars = $_GET;
unset($getVars['url']);
if ($getVars) {
$url = "?" . http_build_query($getVars);
} else {
$url = "";
}
Director::redirect($url);
return;
}
if ($this->dataRecord) {
$this->dataRecord->extend('contentcontrollerInit', $this);
} else {
singleton('SiteTree')->extend('contentcontrollerInit', $this);
}
if (Director::redirected_to()) {
return;
}
Director::set_site_mode('site');
// Check page permissions
if ($this->dataRecord && $this->URLSegment != 'Security' && !$this->dataRecord->can('View')) {
Security::permissionFailure($this);
}
// Draft/Archive security check - only CMS users should be able to look at stage/archived content
if ($this->URLSegment != 'Security' && (Versioned::current_archived_date() || Versioned::current_stage() && Versioned::current_stage() != 'Live')) {
if (!Permission::check('CMS_ACCESS_CMSMain')) {
$link = $this->Link();
$message = _t("ContentController.DRAFT_SITE_ACCESS_RESTRICTION", "You must log in with your CMS password in order to view the draft or archived content. <a href=\"%s\">Click here to go back to the published site.</a>");
Security::permissionFailure($this, sprintf($message, "{$link}?stage=Live"));
return;
}
}
}