public function display()
{
// CUSTOMIZE DELETE 2016/10/05 ryuring
$path = func_get_args();
// CUSTOMIZE ADD 2014/07/02 ryuring
// >>>
if ($this->request->params['Content']['alias_id']) {
$urlTmp = $this->Content->field('url', ['Content.id' => $this->request->params['Content']['alias_id']]);
} else {
$urlTmp = $this->request->params['Content']['url'];
}
if ($this->request->params['Site']['alias']) {
$site = BcSite::findByUrl($urlTmp);
if ($site && $site->alias == $this->request->params['Site']['alias']) {
$urlTmp = preg_replace('/^\\/' . preg_quote($site->alias, '/') . '\\//', '/' . $this->request->params['Site']['name'] . '/', $urlTmp);
}
}
$urlTmp = preg_replace('/^\\//', '', $urlTmp);
$path = explode('/', $urlTmp);
$count = count($path);
if (!$count) {
$this->redirect('/');
}
$page = $subpage = $titleForLayout = null;
if (!empty($path[0])) {
$page = $path[0];
}
if (!empty($path[1])) {
$subpage = $path[1];
}
if (!empty($path[$count - 1])) {
$titleForLayout = Inflector::humanize($path[$count - 1]);
}
// <<<
$this->set(array('page' => $page, 'subpage' => $subpage, 'title_for_layout' => $titleForLayout));
// CUSTOMIZE ADD 2014/07/02 ryuring
// >>>
$previewCreated = false;
if ($this->request->data) {
if ($this->BcContents->preview == 'default') {
$uuid = $this->_createPreviewTemplate($this->request->data);
$this->set('previewTemplate', TMP . 'pages_preview_' . $uuid . $this->ext);
$previewCreated = true;
}
}
$page = $this->Page->find('first', ['conditions' => ['Page.id' => $this->request->params['Content']['entity_id']], 'recursive' => -1]);
$template = $page['Page']['page_template'];
$pagePath = implode('/', $path);
if (!$template) {
$ContentFolder = ClassRegistry::init('ContentFolder');
$template = $ContentFolder->getParentTemplate($this->request->params['Content']['id'], 'page');
}
$this->set('pagePath', $pagePath);
// <<<
try {
// CUSTOMIZE MODIFY 2014/07/02 ryuring
// >>>
//$this->render(implode('/', $path));
// ---
$this->render('templates/' . $template);
if ($previewCreated) {
@unlink(TMP . 'pages_preview_' . $uuid . $this->ext);
}
// <<<
} catch (MissingViewException $e) {
if (Configure::read('debug')) {
throw $e;
}
throw new NotFoundException();
}
}