function testGetLink() { $entity = new DocumentationEntity('testmodule', null, BASE_PATH . '/sapphiredocs/tests/docs/'); $page = new DocumentationPage(); $page->setRelativePath('test.md'); $page->setEntity($entity); // single layer $this->assertStringEndsWith('testmodule/en/test', $page->Link(), 'The page link should have no extension and have a language'); $folder = new DocumentationPage(); $folder->setRelativePath('sort'); $folder->setEntity($entity); // folder, should have a trailing slash $this->assertStringEndsWith('testmodule/en/sort/', $folder->Link()); // second $nested = new DocumentationPage(); $nested->setRelativePath('subfolder/subpage.md'); $nested->setEntity($entity); $this->assertStringEndsWith('testmodule/en/subfolder/subpage', $nested->Link()); // test with version. $entity = DocumentationService::register("versionlinks", BASE_PATH . "/sapphiredocs/tests/docs-v2.4/", '1'); $entity->addVersion('2', BASE_PATH . "/sapphiredocs/tests/docs-v3.0/"); $entity->setStableVersion('2'); $page = new DocumentationPage(); $page->setRelativePath('test.md'); $page->setEntity($entity); $page->setVersion('1'); $this->assertStringEndsWith('versionlinks/en/1/test', $page->Link()); }
public function testGetLink() { $page = new DocumentationPage($this->entity, 'test.md', DOCSVIEWER_PATH . '/tests/docs/en/test.md'); // single layer $this->assertEquals('dev/docs/en/doctest/2.4/test/', $page->Link(), 'The page link should have no extension and have a language'); $page = new DocumentationFolder($this->entity, 'sort', DOCSVIEWER_PATH . '/tests/docs/en/sort/'); $this->assertEquals('dev/docs/en/doctest/2.4/sort/', $page->Link()); $page = new DocumentationFolder($this->entity, '1-basic.md', DOCSVIEWER_PATH . '/tests/docs/en/sort/1-basic.md'); $this->assertEquals('dev/docs/en/doctest/2.4/sort/basic/', $page->Link()); }
/** * Short code parser */ public function includeChildren($args) { if (isset($args['Folder'])) { $children = $this->getManifest()->getChildrenFor(Controller::join_links(dirname($this->record->getPath()), $args['Folder'])); } else { $children = $this->getManifest()->getChildrenFor(dirname($this->record->getPath())); } if (isset($args['Exclude'])) { $exclude = explode(',', $args['Exclude']); foreach ($children as $k => $child) { foreach ($exclude as $e) { if ($child->Link == Controller::join_links($this->record->Link(), strtolower($e), '/')) { unset($children[$k]); } } } } return $this->customise(new ArrayData(array('Children' => $children)))->renderWith('Includes/DocumentationPages'); }
/** * * @param DocumentationPage $page * @param string $basename * @param string $path */ protected function addPage($page, $basename, $path) { $link = $this->stripLinkBase($page->Link()); $this->pages[$link] = array('title' => $page->getTitle(), 'basename' => $basename, 'filepath' => $path, 'type' => get_class($page), 'entitypath' => $this->entity->getPath(), 'summary' => $page->getSummary()); }