コード例 #1
0
 function testGetPagesFromFolderRecursive()
 {
     $entity = DocumentationService::register('testdocsrecursive', BASE_PATH . '/sapphiredocs/tests/docs-recursive/');
     $pages = DocumentationService::get_pages_from_folder($entity, null, true);
     // check to see all the pages are found, we don't care about order
     $this->assertEquals($pages->Count(), 9);
     $pages = $pages->column('Title');
     foreach (array('Index', 'SubFolder TestFile', 'SubSubFolder TestFile', 'TestFile') as $expected) {
         $this->assertContains($expected, $pages);
     }
 }
コード例 #2
0
 /**
  * Generate an array of every single documentation page installed on the system. 
  *
  * @return DataObjectSet
  */
 public static function get_all_documentation_pages()
 {
     DocumentationService::load_automatic_registration();
     $modules = DocumentationService::get_registered_entities();
     $output = new DataObjectSet();
     if ($modules) {
         foreach ($modules as $module) {
             foreach ($module->getVersions() as $version) {
                 try {
                     $pages = DocumentationService::get_pages_from_folder($module, false, true, $version);
                     if ($pages) {
                         foreach ($pages as $page) {
                             $output->push($page);
                         }
                     }
                 } catch (Exception $e) {
                     user_error($e, E_USER_WARNING);
                 }
             }
         }
     }
     return $output;
 }
コード例 #3
0
 /**
  * Return the content for the page. If its an actual documentation page then
  * display the content from the page, otherwise display the contents from
  * the index.md file if its a folder
  *
  * @return HTMLText
  */
 function getContent()
 {
     $page = $this->getPage();
     if ($page) {
         return DBField::create("HTMLText", $page->getHTML($this->getVersion(), $this->getLang()));
     }
     // If no page found then we may want to get the listing of the folder.
     // In case no folder exists, show a "not found" page.
     $entity = $this->getEntity();
     $url = $this->Remaining;
     if ($url && $entity) {
         $pages = DocumentationService::get_pages_from_folder($entity, implode('/', $url), false, $this->getVersion(), $this->getLang());
         return $this->customise(array('Content' => false, 'Title' => DocumentationService::clean_page_name(array_pop($url)), 'Pages' => $pages))->renderWith('DocFolderListing');
     } else {
         return $this->customise(array('Content' => false, 'Title' => _t('DocumentationViewer.MODULES', 'Modules'), 'Pages' => $this->getEntities()))->renderWith('DocFolderListing');
     }
     return false;
 }