/** * List pages and get an array of pages paths * @param boolean ($listHidden) List hidden files & folders * @param string ($pagesPath) Pages path * @throws IOException If the pages directory does not exists * @return array Array of pages paths */ public function listPages($listHidden = false, $pagesPath = null) { $pages = array(); $that =& $this; try { if ($pagesPath === null) { $pagesPath = PAGES; } $fs = new Files($pagesPath); $fs->getFilesList('', false, function ($file, $dir = '') use(&$pages, &$that, $listHidden) { // If files have the right extension and file not secret // (does not begin with '_') $ext = '.' . Config::fileExtension(); $len = -strlen($ext); if (($listHidden || $file[0] !== '_') && substr($file, $len) === $ext) { if ($dir !== '') { $dir = trim($dir, '/\\') . '/'; } // If directory is not secret (or root) if ($listHidden || $dir === '' || $dir[0] !== '_') { $pagePath = $dir . basename($file, $ext); $pages[] = $pagePath; } } }); return $pages; } catch (IOException $e) { exceptionHandler($e); } }