diff --git a/_config.php b/_config.php index 170f6a7..0fa79b2 100644 --- a/_config.php +++ b/_config.php @@ -7,11 +7,11 @@ */ if(!defined('DOCSVIEWER_PATH')) { - define('DOCSVIEWER_PATH', dirname(__FILE__)); + define('DOCSVIEWER_PATH', dirname(__FILE__)); } if(!defined('DOCSVIEWER_DIR')) { - $dir = explode(DIRECTORY_SEPARATOR, DOCSVIEWER_PATH); + $dir = explode(DIRECTORY_SEPARATOR, DOCSVIEWER_PATH); - define('DOCSVIEWER_DIR', array_pop($dir)); + define('DOCSVIEWER_DIR', array_pop($dir)); } diff --git a/code/DocumentationManifest.php b/code/DocumentationManifest.php index 8011f48..541fadb 100644 --- a/code/DocumentationManifest.php +++ b/code/DocumentationManifest.php @@ -10,10 +10,10 @@ * array( * 'en/someniceurl/' => array( * 'filepath' => '/path/to/docs/en/SomeniceFile.md', - * 'title' => 'Some nice URL', - * 'summary' => 'Summary Text', - * 'basename' => 'SomeniceFile.md', - * 'type' => 'DocumentationPage' + * 'title' => 'Some nice URL', + * 'summary' => 'Summary Text', + * 'basename' => 'SomeniceFile.md', + * 'type' => 'DocumentationPage' * ) * ) * @@ -21,10 +21,10 @@ * URL format is in the following structures: * * {lang}/{path} - * {lang}/{module}/{path} + * {lang}/{module}/{path} * {lang}/{module}/{version}/{/path} * - * @package framework + * @package framework * @subpackage manifest */ class DocumentationManifest @@ -81,7 +81,7 @@ class DocumentationManifest * or loaded from cache until needed. * * @param bool $includeTests Include tests in the manifest. - * @param bool $forceRegen Force the manifest to be regenerated. + * @param bool $forceRegen Force the manifest to be regenerated. */ public function __construct($forceRegen = false) { @@ -89,10 +89,12 @@ class DocumentationManifest $this->forceRegen = $forceRegen; $this->registeredEntities = new ArrayList(); - $this->cache = SS_Cache::factory('DocumentationManifest', 'Core', array( + $this->cache = SS_Cache::factory( + 'DocumentationManifest', 'Core', array( 'automatic_serialization' => true, 'lifetime' => null - )); + ) + ); $this->setupEntities(); } @@ -153,7 +155,9 @@ class DocumentationManifest foreach ($langs as $k => $lang) { if (isset($possible[$lang])) { - /** @var DocumentationEntity $entity */ + /** + * @var DocumentationEntity $entity +*/ $entity = Injector::inst()->create( 'DocumentationEntity', $key ); @@ -316,7 +320,7 @@ class DocumentationManifest /** * Get any redirect for the given url * - * @param type $url + * @param type $url * @return string */ public function getRedirect($url) @@ -337,10 +341,12 @@ class DocumentationManifest public function regenerate($cache = true) { $finder = new DocumentationManifestFileFinder(); - $finder->setOptions(array( + $finder->setOptions( + array( 'dir_callback' => array($this, 'handleFolder'), 'file_callback' => array($this, 'handleFile') - )); + ) + ); $this->redirects = array(); foreach ($this->getEntities() as $entity) { @@ -364,21 +370,23 @@ class DocumentationManifest $this->pages = array(); foreach ($grouped as $entity) { - uasort($entity, function ($a, $b) { - // ensure parent directories are first - $a['filepath'] = str_replace('index.md', '', $a['filepath']); - $b['filepath'] = str_replace('index.md', '', $b['filepath']); + uasort( + $entity, function ($a, $b) { + // ensure parent directories are first + $a['filepath'] = str_replace('index.md', '', $a['filepath']); + $b['filepath'] = str_replace('index.md', '', $b['filepath']); - if (strpos($b['filepath'], $a['filepath']) === 0) { - return -1; + if (strpos($b['filepath'], $a['filepath']) === 0) { + return -1; + } + + if ($a['filepath'] == $b['filepath']) { + return 0; + } + + return ($a['filepath'] < $b['filepath']) ? -1 : 1; } - - if ($a['filepath'] == $b['filepath']) { - return 0; - } - - return ($a['filepath'] < $b['filepath']) ? -1 : 1; - }); + ); $this->pages = array_merge($this->pages, $entity); } @@ -399,23 +407,25 @@ class DocumentationManifest /** * Remove the link_base from the start of a link * - * @param string $link + * @param string $link * @return string */ protected function stripLinkBase($link) { - return ltrim(str_replace( - Config::inst()->get('DocumentationViewer', 'link_base'), - '', - $link - ), '/'); + return ltrim( + str_replace( + Config::inst()->get('DocumentationViewer', 'link_base'), + '', + $link + ), '/' + ); } /** * * @param DocumentationPage $page - * @param string $basename - * @param string $path + * @param string $basename + * @param string $path */ protected function addPage($page, $basename, $path) { @@ -474,7 +484,7 @@ class DocumentationManifest * * @param string $basename * @param string $path - * @param int $depth + * @param int $depth */ public function handleFile($basename, $path, $depth) { @@ -512,10 +522,14 @@ class DocumentationManifest $parts = explode('/', trim($record->getRelativeLink(), '/')); // Add the base link. - $output->push(new ArrayData(array( - 'Link' => $base->Link(), - 'Title' => $base->Title - ))); + $output->push( + new ArrayData( + array( + 'Link' => $base->Link(), + 'Title' => $base->Title + ) + ) + ); $progress = $base->Link(); @@ -523,10 +537,14 @@ class DocumentationManifest if ($part) { $progress = Controller::join_links($progress, $part, '/'); - $output->push(new ArrayData(array( - 'Link' => $progress, - 'Title' => DocumentationHelper::clean_page_name($part) - ))); + $output->push( + new ArrayData( + array( + 'Link' => $progress, + 'Title' => DocumentationHelper::clean_page_name($part) + ) + ) + ); } } @@ -551,20 +569,24 @@ class DocumentationManifest foreach ($this->getPages() as $url => $page) { if ($grabNext && strpos($page['filepath'], $entityBase) !== false) { - return new ArrayData(array( + return new ArrayData( + array( 'Link' => Controller::join_links(Config::inst()->get('DocumentationViewer', 'link_base'), $url), 'Title' => $page['title'] - )); + ) + ); } if ($filepath == $page['filepath']) { $grabNext = true; } elseif (!$fallback && strpos($page['filepath'], $filepath) !== false) { - $fallback = new ArrayData(array( + $fallback = new ArrayData( + array( 'Link' => Controller::join_links(Config::inst()->get('DocumentationViewer', 'link_base'), $url), 'Title' => $page['title'], 'Fallback' => true - )); + ) + ); } } @@ -593,10 +615,12 @@ class DocumentationManifest foreach ($this->getPages() as $url => $page) { if ($filepath == $page['filepath']) { if ($previousUrl) { - return new ArrayData(array( + return new ArrayData( + array( 'Link' => Controller::join_links(Config::inst()->get('DocumentationViewer', 'link_base'), $previousUrl), 'Title' => $previousPage['title'] - )); + ) + ); } } @@ -675,13 +699,17 @@ class DocumentationManifest $children = $this->getChildrenFor($pagePath, $recordPath); } - $output->push(new ArrayData(array( - 'Link' => Controller::join_links($base, $url, '/'), - 'Title' => $page['title'], - 'LinkingMode' => $mode, - 'Summary' => $page['summary'], - 'Children' => $children - ))); + $output->push( + new ArrayData( + array( + 'Link' => Controller::join_links($base, $url, '/'), + 'Title' => $page['title'], + 'LinkingMode' => $mode, + 'Summary' => $page['summary'], + 'Children' => $children + ) + ) + ); } } @@ -740,20 +768,26 @@ class DocumentationManifest $output = new ArrayList(); - /** @var DocumentationEntity $check */ + /** + * @var DocumentationEntity $check +*/ foreach ($this->getEntities() as $check) { if ($check->getKey() == $entity->getKey()) { if ($check->getLanguage() == $entity->getLanguage()) { $same = ($check->getVersion() == $entity->getVersion()); - $output->push(new ArrayData(array( - 'Title' => $check->getVersionTitle(), - 'Version' => $check->getVersion(), - 'Archived' => $check->getIsArchived(), - 'Link' => $check->Link(), - 'LinkingMode' => ($same) ? 'current' : 'link', - 'IsStable' => $check->getIsStable() - ))); + $output->push( + new ArrayData( + array( + 'Title' => $check->getVersionTitle(), + 'Version' => $check->getVersion(), + 'Archived' => $check->getIsArchived(), + 'Link' => $check->Link(), + 'LinkingMode' => ($same) ? 'current' : 'link', + 'IsStable' => $check->getIsStable() + ) + ) + ); } } } @@ -783,6 +817,7 @@ class DocumentationManifest /** * Gets whether there is a default entity or not + * * @return boolean */ public function getHasDefaultEntity() diff --git a/code/DocumentationParser.php b/code/DocumentationParser.php index da0e444..4326747 100755 --- a/code/DocumentationParser.php +++ b/code/DocumentationParser.php @@ -30,9 +30,9 @@ class DocumentationParser * Pathparts: folder/subfolder/page * * @param DocumentationPage $page - * @param String $baselink Link relative to webroot, up until the "root" - * of the module. Necessary to rewrite relative - * links + * @param String $baselink Link relative to webroot, up until the "root" of the module. Necessary to rewrite relative links + * of the module. Necessary to rewrite relative + * links * * @return String */ @@ -238,16 +238,22 @@ class DocumentationParser } // Rewrite URL (relative or absolute) - $baselink = DocumentationHelper::relativePath(DocumentationHelper::normalizePath( - dirname($page->getPath()) - )); + $baselink = DocumentationHelper::relativePath( + DocumentationHelper::normalizePath( + dirname($page->getPath()) + ) + ); // if the image starts with a slash, it's absolute if (substr($url, 0, 1) == '/') { - $relativeUrl = DocumentationHelper::normalizePath(str_replace(BASE_PATH, '', Controller::join_links( - $page->getEntity()->getPath(), - $url - ))); + $relativeUrl = DocumentationHelper::normalizePath( + str_replace( + BASE_PATH, '', Controller::join_links( + $page->getEntity()->getPath(), + $url + ) + ) + ); } else { $relativeUrl = rtrim($baselink, '/') . '/' . ltrim($url, '/'); } @@ -264,7 +270,7 @@ class DocumentationParser ); // Replace any double slashes (apart from protocol) -// $absoluteUrl = preg_replace('/([^:])\/{2,}/', '$1/', $absoluteUrl); + // $absoluteUrl = preg_replace('/([^:])\/{2,}/', '$1/', $absoluteUrl); // Replace in original content $md = str_replace( @@ -299,8 +305,8 @@ class DocumentationParser * The markdown parser gets confused by the extra pair of parentheses in links of the form [DataObject](api:DataObject::populateDefaults()) so * all links are re-written as html markup instead of markdown [Title](url). This also prevents other markdown parsing problems. * - * @param String $markdown - * @param DocumentationPage $doc_page + * @param String $markdown + * @param DocumentationPage $doc_page * @return String */ public static function rewrite_api_links($markdown, $doc_page) @@ -324,19 +330,19 @@ class DocumentationParser preg_match_all($regex, $markdown, $links); if($links) { foreach($links[0] as $i => $match) { - if($type === 'no_title'){ + if($type === 'no_title') { $title = $links[1][$i]; $link = $links[1][$i]; // change backticked links to avoid being parsed in the same way as non-backticked links - $markdown = str_replace('`'.$match.'`','XYZ'.$link.'XYZ',$markdown); + $markdown = str_replace('`'.$match.'`', 'XYZ'.$link.'XYZ', $markdown); } else { $title = $links[1][$i]; $link = $links[2][$i]; // change backticked links to avoid being parsed in the same way as non-backticked links - $markdown = str_replace('`'.$match.'`','XX'.$title.'YY'.$link.'ZZ',$markdown); + $markdown = str_replace('`'.$match.'`', 'XX'.$title.'YY'.$link.'ZZ', $markdown); } $html = sprintf($html_format, $link, $version, $module, $title); - $markdown = str_replace($match,$html,$markdown); + $markdown = str_replace($match, $html, $markdown); } } } @@ -346,7 +352,7 @@ class DocumentationParser if($links) { foreach($links[0] as $i => $match) { $link = $links[1][$i]; - $markdown = str_replace($match,'`[api:'.$link.']`',$markdown); + $markdown = str_replace($match, '`[api:'.$link.']`', $markdown); } } @@ -356,7 +362,7 @@ class DocumentationParser foreach($links[0] as $i => $match) { $title = $links[1][$i]; $link = $links[2][$i]; - $markdown = str_replace($match,'`['.$title.'](api:'.$link.')`',$markdown); + $markdown = str_replace($match, '`['.$title.'](api:'.$link.')`', $markdown); } } @@ -418,7 +424,7 @@ class DocumentationParser /** * Resolves all relative links within markdown. * - * @param String $md Markdown content + * @param String $md Markdown content * @param DocumentationPage $page * * @return String Markdown @@ -524,11 +530,13 @@ class DocumentationParser public static function retrieve_meta_data(DocumentationPage &$page) { if ($md = $page->getMarkdown()) { - $matches = preg_match_all('/ + $matches = preg_match_all( + '/ (?[A-Za-z0-9_-]+): \s* (?.*) - /x', $md, $meta); + /x', $md, $meta + ); if ($matches) { foreach ($meta['key'] as $index => $key) { diff --git a/code/DocumentationPermalinks.php b/code/DocumentationPermalinks.php index 18e785d..ca04c2f 100755 --- a/code/DocumentationPermalinks.php +++ b/code/DocumentationPermalinks.php @@ -21,7 +21,7 @@ class DocumentationPermalinks * * * DocumentationPermalinks::add(array( - * 'debugging' => 'current/en/sapphire/topics/debugging' + * 'debugging' => 'current/en/sapphire/topics/debugging' * )); * * diff --git a/code/DocumentationSearch.php b/code/DocumentationSearch.php index f8eb2ce..8ce67b1 100755 --- a/code/DocumentationSearch.php +++ b/code/DocumentationSearch.php @@ -127,7 +127,7 @@ class DocumentationSearch * Folder name for indexes (in the temp folder). * * @config - * @var string + * @var string */ private static $index_location; @@ -240,7 +240,8 @@ class DocumentationSearch $content = $hit->content; - $obj = new ArrayData(array( + $obj = new ArrayData( + array( 'Title' => DBField::create_field('Varchar', $doc->getFieldValue('Title')), 'BreadcrumbTitle' => DBField::create_field('HTMLText', $doc->getFieldValue('BreadcrumbTitle')), 'Link' => DBField::create_field('Varchar', $doc->getFieldValue('Link')), @@ -251,7 +252,8 @@ class DocumentationSearch 'Score' => $hit->score, 'Number' => $k + 1, 'ID' => md5($doc->getFieldValue('Link')) - )); + ) + ); $results->push($obj); } @@ -267,13 +269,15 @@ class DocumentationSearch // Pagination links if ($currentPage > 1) { - $data['PrevUrl'] = DBField::create_field('Text', + $data['PrevUrl'] = DBField::create_field( + 'Text', $this->buildQueryUrl(array('start' => ($currentPage - 2) * $pageLength)) ); } if ($currentPage < $totalPages) { - $data['NextUrl'] = DBField::create_field('Text', + $data['NextUrl'] = DBField::create_field( + 'Text', $this->buildQueryUrl(array('start' => $currentPage * $pageLength)) ); } @@ -284,9 +288,11 @@ class DocumentationSearch $obj = new DataObject(); $obj->IsEllipsis = false; $obj->PageNumber = $i; - $obj->Link = $this->buildQueryUrl(array( + $obj->Link = $this->buildQueryUrl( + array( 'start' => ($i - 1) * $pageLength - )); + ) + ); $obj->Current = false; if ($i == $currentPage) { diff --git a/code/controllers/DocumentationOpenSearchController.php b/code/controllers/DocumentationOpenSearchController.php index 30a74e8..b7b6477 100644 --- a/code/controllers/DocumentationOpenSearchController.php +++ b/code/controllers/DocumentationOpenSearchController.php @@ -41,8 +41,10 @@ class DocumentationOpenSearchController extends Controller return $this->customise( new ArrayData($data) - )->renderWith(array( + )->renderWith( + array( 'OpenSearchDescription' - )); + ) + ); } } diff --git a/code/controllers/DocumentationViewer.php b/code/controllers/DocumentationViewer.php index 3a8143c..56c539c 100755 --- a/code/controllers/DocumentationViewer.php +++ b/code/controllers/DocumentationViewer.php @@ -105,14 +105,16 @@ class DocumentationViewer extends Controller implements PermissionProvider Requirements::javascript('https://cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js'); Requirements::javascript(DOCSVIEWER_DIR .'/javascript/DocumentationViewer.js'); - Requirements::combine_files('docs.css', array( + Requirements::combine_files( + 'docs.css', array( DOCSVIEWER_DIR .'/css/normalize.css', DOCSVIEWER_DIR .'/css/utilities.css', DOCSVIEWER_DIR .'/css/typography.css', DOCSVIEWER_DIR .'/css/forms.css', DOCSVIEWER_DIR .'/css/layout.css', DOCSVIEWER_DIR .'/css/small.css' - )); + ) + ); } } @@ -122,7 +124,8 @@ class DocumentationViewer extends Controller implements PermissionProvider * @return array */ - public function providePermissions() { + public function providePermissions() + { return array( 'CMS_VIEW_DEVDOCS' => array( 'name' => 'View Site Documentation', @@ -270,10 +273,12 @@ class DocumentationViewer extends Controller implements PermissionProvider $this->init(); $type = get_class($this->record); - $body = $this->renderWith(array( + $body = $this->renderWith( + array( "DocumentationViewer_{$type}", "DocumentationViewer" - )); + ) + ); return new SS_HTTPResponse($body, 200); } elseif ($redirect = $this->getManifest()->getRedirect($url)) { @@ -281,10 +286,12 @@ class DocumentationViewer extends Controller implements PermissionProvider $to = Controller::join_links(Director::baseURL(), $base, $redirect); return $response->redirect($to, 301); } elseif (!$url || $url == $lang) { - $body = $this->renderWith(array( + $body = $this->renderWith( + array( "DocumentationViewer_DocumentationFolder", "DocumentationViewer" - )); + ) + ); return new SS_HTTPResponse($body, 200); } @@ -294,7 +301,7 @@ class DocumentationViewer extends Controller implements PermissionProvider } /** - * @param int $status + * @param int $status * @param string $message * * @return SS_HTTPResponse @@ -304,9 +311,13 @@ class DocumentationViewer extends Controller implements PermissionProvider $this->init(); $class = get_class($this); - $body = $this->customise(new ArrayData(array( - 'Message' => $message - )))->renderWith(array("{$class}_error", $class)); + $body = $this->customise( + new ArrayData( + array( + 'Message' => $message + ) + ) + )->renderWith(array("{$class}_error", $class)); return new SS_HTTPResponse($body, $status); } @@ -386,13 +397,17 @@ class DocumentationViewer extends Controller implements PermissionProvider $link = $entity->Link(); - $output->push(new ArrayData(array( - 'Title' => $entity->getTitle(), - 'Link' => $link, - 'LinkingMode' => $mode, - 'DefaultEntity' => $entity->getIsDefaultEntity(), - 'Children' => $children - ))); + $output->push( + new ArrayData( + array( + 'Title' => $entity->getTitle(), + 'Link' => $link, + 'LinkingMode' => $mode, + 'DefaultEntity' => $entity->getIsDefaultEntity(), + 'Children' => $children + ) + ) + ); } return $output; @@ -449,9 +464,13 @@ class DocumentationViewer extends Controller implements PermissionProvider } } - return $this->customise(new ArrayData(array( - 'Children' => $children - )))->renderWith('Includes/DocumentationPages'); + return $this->customise( + new ArrayData( + array( + 'Children' => $children + ) + ) + )->renderWith('Includes/DocumentationPages'); } /** @@ -565,11 +584,15 @@ class DocumentationViewer extends Controller implements PermissionProvider $first = strtoupper(trim(substr($page['title'], 0, 1))); if ($first) { - $output->push(new ArrayData(array( - 'Link' => Controller::join_links($baseLink, $url), - 'Title' => $page['title'], - 'FirstLetter' => $first - ))); + $output->push( + new ArrayData( + array( + 'Link' => Controller::join_links($baseLink, $url), + 'Title' => $page['title'], + 'FirstLetter' => $first + ) + ) + ); } } @@ -596,18 +619,18 @@ class DocumentationViewer extends Controller implements PermissionProvider * to jump into editing the documentation. * * Some variables are replaced: - * - %version% - * - %entity% - * - %path% - * - %lang% + * - %version% + * - %entity% + * - %path% + * - %lang% * * For example to provide an edit link to the framework module in github: * * * DocumentationViewer::set_edit_link( - * 'framework', - * 'https://github.com/silverstripe/%entity%/edit/%version%/docs/%lang%/%path%', - * $opts + * 'framework', + * 'https://github.com/silverstripe/%entity%/edit/%version%/docs/%lang%/%path%', + * $opts * )); * * @@ -662,7 +685,6 @@ class DocumentationViewer extends Controller implements PermissionProvider $version, ltrim($page->getRelativePath(), '/') ), - $url['url'] ); } @@ -683,7 +705,8 @@ class DocumentationViewer extends Controller implements PermissionProvider { return ($this->record) ? $this->getManifest()->getNextPage( - $this->record->getPath(), $this->getEntity()->getPath()) + $this->record->getPath(), $this->getEntity()->getPath() + ) : null; } @@ -697,7 +720,8 @@ class DocumentationViewer extends Controller implements PermissionProvider { return ($this->record) ? $this->getManifest()->getPreviousPage( - $this->record->getPath(), $this->getEntity()->getPath()) + $this->record->getPath(), $this->getEntity()->getPath() + ) : null; } @@ -728,8 +752,9 @@ class DocumentationViewer extends Controller implements PermissionProvider /** * Gets whether there is a default entity or not + * * @return boolean - * @see DocumentationManifest::getHasDefaultEntity() + * @see DocumentationManifest::getHasDefaultEntity() */ public function getHasDefaultEntity() { diff --git a/code/extensions/DocumentationStaticPublisherExtension.php b/code/extensions/DocumentationStaticPublisherExtension.php index 5e0b3d3..83159c9 100644 --- a/code/extensions/DocumentationStaticPublisherExtension.php +++ b/code/extensions/DocumentationStaticPublisherExtension.php @@ -10,7 +10,7 @@ * * StaticExporter: * extensions: - * - DocumentationStaticPublisherExtension + * - DocumentationStaticPublisherExtension * * * If you don't plan on using static publisher for anything else and you have diff --git a/code/extensions/DocumentationViewerVersionWarning.php b/code/extensions/DocumentationViewerVersionWarning.php index 90c09bf..7ef6ac8 100644 --- a/code/extensions/DocumentationViewerVersionWarning.php +++ b/code/extensions/DocumentationViewerVersionWarning.php @@ -33,15 +33,23 @@ class DocumentationViewerVersionWarning extends Extension $compare = $entity->compare($stable); if ($entity->getVersion() == "master" || $compare > 0) { - return $this->owner->customise(new ArrayData(array( - 'FutureRelease' => true, - 'StableVersion' => DBField::create_field('HTMLText', $stable->getVersion()) - ))); + return $this->owner->customise( + new ArrayData( + array( + 'FutureRelease' => true, + 'StableVersion' => DBField::create_field('HTMLText', $stable->getVersion()) + ) + ) + ); } else { - return $this->owner->customise(new ArrayData(array( - 'OutdatedRelease' => true, - 'StableVersion' => DBField::create_field('HTMLText', $stable->getVersion()) - ))); + return $this->owner->customise( + new ArrayData( + array( + 'OutdatedRelease' => true, + 'StableVersion' => DBField::create_field('HTMLText', $stable->getVersion()) + ) + ) + ); } return false; diff --git a/code/models/DocumentationEntity.php b/code/models/DocumentationEntity.php index 9ce838f..177c172 100755 --- a/code/models/DocumentationEntity.php +++ b/code/models/DocumentationEntity.php @@ -11,8 +11,7 @@ * entity can have a language attached to it. So for an instance with en, de and * fr documentation you may have three {@link DocumentationEntities} registered. * - * - * @package docsviewer + * @package docsviewer * @subpackage models */ @@ -130,7 +129,7 @@ class DocumentationEntity extends ViewableData * * Includes the version information * - * @param boolean $short If true, will attempt to return a short version of the url + * @param boolean $short If true, will attempt to return a short version of the url * This might omit the version number if this is the default version. * @return string */ @@ -256,17 +255,19 @@ class DocumentationEntity extends ViewableData * * @return string */ - public function getVersionTitle() { + public function getVersionTitle() + { return $this->versionTitle; } /** * Sets the title for this version * - * @param string $title + * @param string $title * @return $this */ - public function setVersionTitle($title) { + public function setVersionTitle($title) + { $this->versionTitle = $title; return $this; } @@ -274,10 +275,11 @@ class DocumentationEntity extends ViewableData /** * Set if this is archived * - * @param bool $archived + * @param bool $archived * @return $this */ - public function setIsArchived($archived) { + public function setIsArchived($archived) + { $this->archived = $archived; return $this; } @@ -285,7 +287,8 @@ class DocumentationEntity extends ViewableData /** * @return bool */ - public function getIsArchived() { + public function getIsArchived() + { return $this->archived; } @@ -354,7 +357,7 @@ class DocumentationEntity extends ViewableData * version. Will return -1 for if the version is older, 0 if versions are * the same and 1 if the version is greater than. * - * @param DocumentationEntity $other + * @param DocumentationEntity $other * @return int */ public function compare(DocumentationEntity $other) diff --git a/code/models/DocumentationFolder.php b/code/models/DocumentationFolder.php index c769af6..61ff5b6 100644 --- a/code/models/DocumentationFolder.php +++ b/code/models/DocumentationFolder.php @@ -5,7 +5,7 @@ * * Maps to a folder on the file system. * - * @package docsviewer + * @package docsviewer * @subpackage model */ class DocumentationFolder extends DocumentationPage diff --git a/code/models/DocumentationPage.php b/code/models/DocumentationPage.php index 6290e97..a73d2f2 100755 --- a/code/models/DocumentationPage.php +++ b/code/models/DocumentationPage.php @@ -7,7 +7,7 @@ * not always be the file name. If the file contains meta data with a nicer URL * sthen it will use that. * - * @package docsviewer + * @package docsviewer * @subpackage model */ class DocumentationPage extends ViewableData @@ -38,8 +38,8 @@ class DocumentationPage extends ViewableData /** * @param DocumentationEntity $entity - * @param string $filename - * @param string $path + * @param string $filename + * @param string $path */ public function __construct(DocumentationEntity $entity, $filename, $path) { @@ -71,15 +71,19 @@ class DocumentationPage extends ViewableData // add the module to the breadcrumb trail. $pathParts[] = $this->entity->getTitle(); - $titleParts = array_map(array( + $titleParts = array_map( + array( 'DocumentationHelper', 'clean_page_name' - ), $pathParts); + ), $pathParts + ); - $titleParts = array_filter($titleParts, function ($val) { - if ($val) { - return $val; + $titleParts = array_filter( + $titleParts, function ($val) { + if ($val) { + return $val; + } } - }); + ); if ($this->getTitle()) { array_unshift($titleParts, $this->getTitle()); @@ -208,9 +212,13 @@ class DocumentationPage extends ViewableData { $path = $this->getRelativePath(); $url = explode('/', $path); - $url = implode('/', array_map(function ($a) { - return DocumentationHelper::clean_page_url($a); - }, $url)); + $url = implode( + '/', array_map( + function ($a) { + return DocumentationHelper::clean_page_url($a); + }, $url + ) + ); $url = trim($url, '/') . '/'; @@ -240,16 +248,18 @@ class DocumentationPage extends ViewableData * Returns the URL that will be required for the user to hit to view the * given document base name. * - * @param boolean $short If true, will attempt to return a short version of the url + * @param boolean $short If true, will attempt to return a short version of the url * This might omit the version number if this is the default version. * @return string */ public function Link($short = false) { - return ltrim(Controller::join_links( - $this->entity->Link($short), - $this->getRelativeLink() - ), '/'); + return ltrim( + Controller::join_links( + $this->entity->Link($short), + $this->getRelativeLink() + ), '/' + ); } /** @@ -257,7 +267,7 @@ class DocumentationPage extends ViewableData * block on request * * @param DocumentationPage $md - * @param bool $remove + * @param bool $remove */ public function populateMetaDataFromText(&$md, $removeMetaData = false) { diff --git a/code/tasks/CheckDocsSourcesTask.php b/code/tasks/CheckDocsSourcesTask.php index aad09d4..71a1dde 100644 --- a/code/tasks/CheckDocsSourcesTask.php +++ b/code/tasks/CheckDocsSourcesTask.php @@ -3,19 +3,22 @@ /** * Check status of sources dirs */ -class CheckDocsSourcesTask extends BuildTask { +class CheckDocsSourcesTask extends BuildTask +{ protected $errors = 0; protected $description = "Check validity of all docs source files registered"; - public function start() { + public function start() + { if(!Director::is_cli()) { echo "