Esempio n. 1
0
 /**
  * Short description of method render
  *
  * @access public
  * @author Joel Bout, <*****@*****.**>
  * @return string
  */
 public function render()
 {
     if (!empty($this->value)) {
         if (common_Utils::isUri($this->value)) {
             $file = new core_kernel_file_File($this->value);
             if ($file->fileExists()) {
                 $fileInfo = $file->getFileInfo();
                 $fileInfo->getFilename();
             } else {
                 $file->delete();
             }
         }
     }
     $returnValue = $this->renderLabel();
     $returnValue .= "<input type='hidden' name='MAX_FILE_SIZE' value='" . tao_helpers_form_elements_File::MAX_FILE_SIZE . "' />";
     $returnValue .= "<input type='file' name='{$this->name}' id='{$this->name}' ";
     $returnValue .= $this->renderAttributes();
     $returnValue .= " value='{$this->value}'  />";
     return (string) $returnValue;
 }
 /**
  * Delete the content of a QTI test
  * @param core_kernel_classes_Resource $test
  * @throws common_exception_Error
  */
 public function deleteContent(core_kernel_classes_Resource $test)
 {
     $content = $test->getOnePropertyValue(new core_kernel_classes_Property(TEST_TESTCONTENT_PROP));
     if (!is_null($content)) {
         $file = new core_kernel_file_File($content);
         try {
             $path = $file->getAbsolutePath();
             if (is_dir($path)) {
                 if (!tao_helpers_File::delTree($path)) {
                     throw new common_exception_Error("Unable to remove test content directory located at '" . $file->getAbsolutePath() . "'.");
                 }
             }
         } catch (common_Exception $e) {
             // Empty file...
         }
         $file->delete();
         $test->removePropertyValue(new core_kernel_classes_Property(TEST_TESTCONTENT_PROP), $file);
     }
 }
Esempio n. 3
0
 /**
  * This implementation use \core_kernel_file_File URI as serial
  *
  * @see FileReferenceSerializer::cleanUp
  */
 public function cleanUp($serial)
 {
     $resourceFile = $this->getResource($serial);
     $file = new \core_kernel_file_File($resourceFile);
     return $file->delete();
 }
 public function testDeepCloneTriplesFile()
 {
     /** @var \core_kernel_versioning_Repository $repository */
     $repository = \tao_models_classes_FileSourceService::singleton()->addLocalSource("repository test", \tao_helpers_File::createTempDir());
     //see if clone item content works
     /** @var \core_kernel_versioning_File $file */
     $file = $repository->spawnFile(__DIR__ . '/sample/test.xml', "test", function ($originalName) {
         return md5($originalName);
     });
     //see if clone file works
     $rdfsTriple = new \core_kernel_classes_Triple();
     $rdfsTriple->predicate = "http://www.w3.org/1999/02/22-rdf-syntax-ns#value";
     $rdfsTriple->object = $file->getUri();
     $return = CloneHelper::deepCloneTriples(array($rdfsTriple));
     $this->assertCount(1, $return);
     $this->assertEquals($rdfsTriple->predicate, $return[0]->predicate);
     $this->assertNotEquals($rdfsTriple->object, $return[0]->object);
     $fileCopy = new \core_kernel_file_File($return[0]->object);
     $this->assertFileExists($fileCopy->getAbsolutePath());
     $this->assertEquals($file->getLabel(), $fileCopy->getLabel());
     $this->assertNotEquals($file->getAbsolutePath(), $fileCopy->getAbsolutePath());
     $file->delete(true);
     $fileCopy->delete(true);
     $repository->delete(true);
 }
 /**
  * (non-PHPdoc)
  * @see \oat\taoMediaManager\model\fileManagement\FileManagement::deleteFile()
  */
 public function deleteFile($link)
 {
     unlink($this->getLocalPath($link));
     $file = new \core_kernel_file_File($link);
     return $file->delete();
 }
 /**
  * (non-PHPdoc)
  * @see \oat\taoMediaManager\model\fileManagement\FileManagement::deleteFile()
  */
 public function deleteFile($link)
 {
     $file = new \core_kernel_file_File($link);
     unlink($file->getAbsolutePath());
     return $file->delete();
 }
Esempio n. 7
0
 /**
  * Delete the file from the file system.
  * If the versioned file is in conflict solve the problem
  * and delete it.
  *
  * @access public
  * @author Lionel Lecaque, <*****@*****.**>
  * @param  boolean deleteReference
  * @return boolean
  */
 public function delete($deleteReference = false)
 {
     $returnValue = (bool) false;
     if ($this->fileExists()) {
         $filePath = $this->getAbsolutePath();
         //check if the file is up to date
         /**
          * @todo this code won't work in shell implentation
          */
         //If the file has yet been deleted remotly => udpate it
         if ($this->getStatus() == VERSIONING_FILE_STATUS_REMOTELY_DELETED) {
             $returnValue = $this->update();
             /**
              * @todo check the file is now well deleted locally
              */
         } else {
             //check if the resource is versioned before the delete
             $isVersioned = $this->isVersioned();
             //if in conflict solve before the problem by using our version of the file
             if ($this->isInConflict()) {
                 $this->resolve(VERSIONING_FILE_VERSION_MINE);
             }
             //delete the svn resource
             $returnValue = core_kernel_versioning_FileProxy::singleton()->delete($this, $filePath, true);
             //commit the svn delete
             if ($returnValue && $isVersioned) {
                 //delete the svn resource
                 $returnValue = $this->commit(__('delete the file') . ' ' . $filePath, is_dir($filePath));
             }
         }
     } else {
         $returnValue = true;
     }
     //delete the tao resource
     $returnValue &= parent::delete($deleteReference);
     return (bool) $returnValue;
 }