public function getTitle($separator = '|', $options = array())
{
if (!is_array($options)) {
$categoryTitleOn = $options;
unset($options);
$options['categoryTitleOn'] = $categoryTitleOn;
}
$options = array_merge(array('categoryTitleOn' => null, 'tag' => true, 'allowableTags' => ''), $options);
$title = array();
if ($this->isHome()) {
$homeTitle = $this->_View->get('homeTitle');
if ($homeTitle) {
if (!$options['tag']) {
$title[] = strip_tags($homeTitle, $options['allowableTags']);
} else {
$title[] = $homeTitle;
}
}
} else {
$crumbs = $this->getCrumbs($options['categoryTitleOn']);
if ($crumbs) {
$crumbs = array_reverse($crumbs);
foreach ($crumbs as $key => $crumb) {
if ($this->BcArray->first($crumbs, $key) && isset($crumbs[$key + 1])) {
if ($crumbs[$key + 1]['name'] == $crumb['name']) {
continue;
}
}
if (!$options['tag']) {
$title[] = strip_tags($crumb['name'], $options['allowableTags']);
} else {
$title[] = $crumb['name'];
}
}
}
}
// サイトタイトルを追加
$siteName = '';
if (!empty($this->request->params['Site']['title'])) {
$siteName = $this->request->params['Site']['title'];
} elseif (!empty($this->siteConfig['name'])) {
$siteName = $this->siteConfig['name'];
}
if ($siteName) {
if (!$options['tag']) {
$title[] = strip_tags($siteName, $options['allowableTags']);
} else {
$title[] = $siteName;
}
}
return implode($separator, $title);
}