Correct title generation for index files in entity root

Previously would output the language code as the title 'En'. This double checks whether the file is at the root of the entity and if so, it'll use the entity name.
This commit is contained in:
Will Rossiter 2014-09-27 10:15:52 +12:00
parent 804c67dcaf
commit 508238a7b2
2 changed files with 20 additions and 11 deletions

View File

@ -14,10 +14,7 @@ class DocumentationFolder extends DocumentationPage {
* @return string
*/
public function getTitle() {
$path = explode(DIRECTORY_SEPARATOR, trim($this->getPath(), DIRECTORY_SEPARATOR));
$folderName = array_pop($path);
return DocumentationHelper::clean_page_name($folderName);
return $this->getTitleFromFolder();
}
}

View File

@ -103,17 +103,29 @@ class DocumentationPage extends ViewableData {
$page = DocumentationHelper::clean_page_name($this->filename);
if($page == "Index") {
// look at the folder name
$parts = explode("/", $this->getPath());
array_pop($parts); // name
$page = DocumentationHelper::clean_page_name(
array_pop($parts)
);
return $this->getTitleFromFolder();
}
return $page;
}
public function getTitleFromFolder() {
$folder = $this->getPath();
$entity = $this->getEntity()->getPath();
$folder = str_replace('index.md', '', $folder);
// if it's the root of the entity then we want to use the entity name
// otherwise we'll get 'En' for the entity folder
if($folder == $entity) {
return $this->getEntity()->getTitle();
} else {
$path = explode(DIRECTORY_SEPARATOR, trim($folder, DIRECTORY_SEPARATOR));
$folderName = array_pop($path);
}
return DocumentationHelper::clean_page_name($folderName);
}
/**
* @return string