public function ExportFromDirectory()
 {
     // NarroLogger::LogDebug(sprintf('Starting to export in directory "%s"', $this->strTranslationPath));
     /**
      * get the file list with complete paths
      */
     $arrFiles = $this->ListDir($this->strTemplatePath);
     $intTotalFilesToProcess = count($arrFiles);
     if ($intTotalFilesToProcess == 1 && pathinfo($arrFiles[0], PATHINFO_EXTENSION) == 'xpi') {
         return $this->ExportToXpi($arrFiles[0]);
     }
     if ($intTotalFilesToProcess > __MAXIMUM_FILE_COUNT_TO_EXPORT__) {
         NarroLogger::LogError(sprintf('Too many files to process: %d. The maximum number of files to export is set in the configuration file at %d', $intTotalFilesToProcess, __MAXIMUM_FILE_COUNT_TO_EXPORT__));
         return false;
     }
     // NarroLogger::LogDebug(sprintf('Starting to process %d files', $intTotalFilesToProcess));
     $arrDirectories = array();
     NarroProgress::SetProgress(0, $this->objProject->ProjectId, 'export', $intTotalFilesToProcess);
     if (is_array($arrFiles)) {
         foreach ($arrFiles as $intFileNo => $strFileToExport) {
             $arrFileParts = explode('/', str_replace($this->strTemplatePath, '', $strFileToExport));
             $strFileName = $arrFileParts[count($arrFileParts) - 1];
             unset($arrFileParts[count($arrFileParts) - 1]);
             unset($arrFileParts[0]);
             $strPath = '';
             $intParentId = null;
             $arrDirectories = array();
             foreach ($arrFileParts as $intPos => $strDir) {
                 $strPath = $strPath . '/' . $strDir;
                 if (!isset($arrDirectories[$strPath])) {
                     if (!is_null($intParentId)) {
                         $objFile = NarroFile::QuerySingle(QQ::AndCondition(QQ::Equal(QQN::NarroFile()->ProjectId, $this->objProject->ProjectId), QQ::Equal(QQN::NarroFile()->FileName, $strDir), QQ::Equal(QQN::NarroFile()->TypeId, NarroFileType::Folder), QQ::Equal(QQN::NarroFile()->ParentId, $intParentId)));
                     } else {
                         $objFile = NarroFile::QuerySingle(QQ::AndCondition(QQ::Equal(QQN::NarroFile()->ProjectId, $this->objProject->ProjectId), QQ::Equal(QQN::NarroFile()->FileName, $strDir), QQ::Equal(QQN::NarroFile()->TypeId, NarroFileType::Folder), QQ::IsNull(QQN::NarroFile()->ParentId)));
                     }
                     if (!$objFile instanceof NarroFile) {
                         NarroLogger::LogWarn(sprintf('Could not find folder "%s" with parent id "%d" in the database.', $strDir, $intParentId));
                         continue;
                     }
                     $arrDirectories[$strPath] = $objFile->FileId;
                 }
                 $intParentId = $arrDirectories[$strPath];
             }
             $strTranslatedFileToExport = str_replace($this->strTemplatePath, $this->strTranslationPath, $strFileToExport);
             if (!file_exists(dirname($strTranslatedFileToExport))) {
                 if (!mkdir(dirname($strTranslatedFileToExport), 0777, true)) {
                     NarroLogger::LogWarn(sprintf('Failed to create the parent directories for the file %s', $strFileToExport));
                     return false;
                 }
                 NarroUtils::RecursiveChmod(dirname($strTranslatedFileToExport));
             }
             $objFile = NarroFile::QuerySingle(QQ::AndCondition(QQ::Equal(QQN::NarroFile()->ProjectId, $this->objProject->ProjectId), QQ::Equal(QQN::NarroFile()->FileName, $strFileName), QQ::Equal(QQN::NarroFile()->ParentId, $intParentId), QQ::Equal(QQN::NarroFile()->Active, 1)));
             if (!$objFile instanceof NarroFile) {
                 continue;
             }
             // NarroLogger::LogDebug(sprintf('Exporting file "%s" using template "%s"', $objFile->FileName, $strTranslatedFileToExport));
             $intTime = time();
             $this->ExportFile($objFile, $strFileToExport, $strTranslatedFileToExport);
             $intElapsedTime = time() - $intTime;
             // NarroLogger::LogDebug(sprintf('Processed file "%s" in %d seconds, %d files left', str_replace($this->strTemplatePath, '', $strFileToExport), $intElapsedTime, (count($arrFiles) - $intFileNo - 1)));
             NarroImportStatistics::$arrStatistics['Exported files']++;
             NarroProgress::SetProgress((int) ceil($intFileNo * 100 / $intTotalFilesToProcess), $this->objProject->ProjectId, 'export');
         }
     }
     return true;
 }