public function canonicalUrl($url)
{
if (strlen($url)) {
if ($url[0] == '/') {
// If the URL begins with a "/", the following is the
// canonical URL
return substr($url, 1);
} else {
// Else, the canonical name is under the current dir
if ($this->getDirName()) {
return $this->canonicalize($this->getDirName() . '/' . $url);
} else {
return $this->canonicalize($url);
}
}
}
return null;
}
public function resolve(Environment $environment, $data) { $metas = $environment->getMetas(); $file = $environment->canonicalUrl($data); if ($metas) { $entry = $metas->get($file); $entry['url'] = $environment->relativeUrl('/' . $entry['url']); } else { $entry = array('title' => '(unresolved)', 'url' => '#'); } return $entry; }