/**
  * Call after folder addition in filelist
  * Add the correct folder in the database
  * @param Folder $folder
  * @return void
  */
 public function postFolderAdd($folder)
 {
     if ($folder->getParentFolder() && $folder->getParentFolder()->getName() != '') {
         $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery("uid", "tx_ameosfilemanager_domain_model_folder", "tx_ameosfilemanager_domain_model_folder.identifier like '" . $folder->getParentFolder()->getIdentifier() . "'");
         if (($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) !== FALSE) {
             if (Tools::getFolderPathFromUid($row['uid']) . '/' == $folder->getParentFolder()->getIdentifier()) {
                 $insertArray = array("tstamp" => time(), "crdate" => time(), "cruser_id" => 1, "title" => $folder->getName(), "uid_parent" => $row['uid'], "identifier" => $folder->getIdentifier());
                 $folderRepository = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager')->get('Ameos\\AmeosFilemanager\\Domain\\Repository\\FolderRepository');
                 $folderRepository->requestInsert($insertArray);
             }
         } else {
             $this->postFolderAdd($folder->getParentFolder());
             $this->postFolderAdd($folder);
         }
     } else {
         $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery("uid", "tx_ameosfilemanager_domain_model_folder", "tx_ameosfilemanager_domain_model_folder.identifier like '" . $folder->getIdentifier() . "'");
         if (($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) === FALSE) {
             $insertArray = array("tstamp" => time(), "crdate" => time(), "cruser_id" => 1, "title" => $folder->getName(), "uid_parent" => 0, "identifier" => $folder->getIdentifier());
             $folderRepository = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager')->get('Ameos\\AmeosFilemanager\\Domain\\Repository\\FolderRepository');
             $folderRepository->requestInsert($insertArray);
         }
     }
 }
Ejemplo n.º 2
0
 public function importFromFolder(Folder $folder)
 {
     try {
         $config = array('url_key' => $folder->getName());
         $metadata = array('experiment_id' => -1, 'task_id' => -1);
         $config = $this->getConfig($folder);
         $this->logImportStart($config);
         $metadata = $this->processMetadata($config);
         $sentences = $this->parseResources($folder, $config);
         $this->processSentences($config, $metadata, $sentences);
         $this->logImportSuccess($config);
         $this->showImported($metadata);
         $folder->lock('imported');
     } catch (\IteratorsLengthsMismatchException $exception) {
         $this->handleNotMatchingNumberOfSentences($config['url_key']);
         $this->handleImportError($folder, $metadata);
     } catch (\ImporterException $exception) {
         $this->logImportAbortion($config, $exception);
         $this->handleImportError($folder, $metadata);
     } catch (Exception $exception) {
         $this->logger->log($exception->getMessage());
         $this->handleImportError($folder, $metadata);
     }
 }
Ejemplo n.º 3
0
 /**
  * @brief Updates the folder
  * @param folder the folder to be updated
  */
 public function update(Folder $folder)
 {
     $query = \OCP\DB::prepare('UPDATE ' . self::tableName . ' SET name = ?, opened = ?' . ' WHERE id = ?');
     $params = array($folder->getName(), $folder->getOpened(), $folder->getId());
     $query->execute($params);
     return true;
 }
 protected function getDefaults(Folder $experimentFolder)
 {
     return array('name' => $experimentFolder->getName(), 'url_key' => $experimentFolder->getName(), 'description' => '', 'source' => 'source.txt', 'reference' => 'reference.txt');
 }
Ejemplo n.º 5
0
 protected function getDefaults(Folder $folder)
 {
     return array('name' => $folder->getName(), 'url_key' => $folder->getName(), 'experiment' => $this->experimentsModel->getExperimentByName($folder->getParent()->getName()), 'description' => '', 'translation' => 'translation.txt', 'precompute_ngrams' => true);
 }
Ejemplo n.º 6
0
 public function testGetName()
 {
     assertThat($this->folder->getName(), is($this->folderName));
 }