Example #1
0
 /**
  * Get all sub directory
  * @param string $path The base path want to find
  * @return array Array of path of sub directory founded
  */
 public static function getAllSubDirectory($path)
 {
     $rdi = new RDIterator($path, RDIterator::SKIP_DOTS);
     $subDirs = [];
     foreach ($rdi as $item) {
         if ($item->isDir()) {
             $subDirs[] = $rdi->getPathname();
         }
     }
     return $subDirs;
 }
mysql_connection_select(DATABASE);
// set parameter defaults
$formImportDir = @$_REQUEST['formImportDir'];
// outName returns the hml direct.
$resourceUriRoot = @$_REQUEST['resourceUriRoot'];
// URI prefix for the resources upload with forms.
//if no style given then try default, if default doesn't exist we our put raw xml
$importData = array();
$info = new SplFileInfo($formImportDir);
$i = 0;
$xmlForms = array("form" => array(), "resource" => array());
if ($info->isDir()) {
    $iterator = new RecursiveDirectoryIterator($formImportDir);
    while ($iterator->valid()) {
        if ($iterator->isFile()) {
            $ext = pathinfo($iterator->getPathname(), PATHINFO_EXTENSION);
            if ($ext == "xml") {
                //				echo $prefix,$j,"&nbsp;import ",$dirIterator->getPathname(), "<br>\n";
                $xmlForms["form"][$iterator->getFilename()] = $iterator->getPathname();
            } else {
                $filepath = preg_replace("/" . preg_replace("/\\//", "\\\\/", HEURIST_UPLOAD_DIR) . "/", "/", $iterator->getPathname());
                //				echo $prefix,$j,"&nbsp;resource ".$dirIterator->getFilename()." has path ".$filepath, "<br>\n";
                $xmlForms["resource"][$iterator->getFilename()] = $filepath;
            }
        } else {
            if ($iterator->isDir() && $iterator->hasChildren(false)) {
                //			echo $i,pathinfo($iterator->getPathname(),PATHINFO_FILENAME), "<br>\n";
                processChildDir($iterator->getChildren(), $i . "-");
            }
        }
        $iterator->next();