/**
  * Return the children from a given entity sorted by Title using natural ordering. 
  * It is used for building the tree of the page.
  *
  * @param DocumentationEntity path
  * @param string - an optional path within a entity
  * @param bool enable several recursive calls (more than 1 level)
  * @param string - version to use
  * @param string - lang to use
  *
  * @throws Exception
  * @return DataObjectSet
  */
 public static function get_pages_from_folder($entity, $relativePath = false, $recursive = true, $version = 'trunk', $lang = 'en')
 {
     $output = new DataObjectSet();
     $pages = array();
     if (!$entity instanceof DocumentationEntity) {
         user_error("get_pages_from_folder must be passed a entity", E_USER_ERROR);
     }
     $path = $entity->getPath($version, $lang);
     if (self::is_registered_entity($entity)) {
         self::get_pages_from_folder_recursive($path, $relativePath, $recursive, $pages);
     } else {
         return user_error("{$entity} is not registered", E_USER_WARNING);
     }
     if (count($pages) > 0) {
         natsort($pages);
         foreach ($pages as $key => $pagePath) {
             // get file name from the path
             $file = ($pos = strrpos($pagePath, '/')) ? substr($pagePath, $pos + 1) : $pagePath;
             $page = new DocumentationPage();
             $page->setTitle(self::clean_page_name($file));
             $relative = str_replace($path, '', $pagePath);
             // if no extension, put a slash on it
             if (strpos($relative, '.') === false) {
                 $relative .= '/';
             }
             $page->setEntity($entity);
             $page->setRelativePath($relative);
             $page->setVersion($version);
             $page->setLang($lang);
             $output->push($page);
         }
     }
     return $output;
 }