当前位置: 首页>>代码示例>>PHP>>正文


PHP tao_helpers_File::remove方法代码示例

本文整理汇总了PHP中tao_helpers_File::remove方法的典型用法代码示例。如果您正苦于以下问题:PHP tao_helpers_File::remove方法的具体用法?PHP tao_helpers_File::remove怎么用?PHP tao_helpers_File::remove使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tao_helpers_File的用法示例。


在下文中一共展示了tao_helpers_File::remove方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: import

 /**
  * (non-PHPdoc)
  * @see tao_models_classes_import_ImportHandler::import()
  */
 public function import($class, $form)
 {
     $fileInfo = $form->getValue('source');
     //import for CSV
     if (isset($fileInfo)) {
         set_time_limit(200);
         //the zip extraction is a long process that can exced the 30s timeout
         //get the services instances we will need
         $itemService = taoItems_models_classes_ItemsService::singleton();
         $uploadedFile = $fileInfo['uploaded_file'];
         $uploadedFileBaseName = basename($uploadedFile);
         // uploaded file name contains an extra prefix that we have to remove.
         $uploadedFileBaseName = preg_replace('/^([0-9a-z])+_/', '', $uploadedFileBaseName, 1);
         $uploadedFileBaseName = preg_replace('/.zip|.ZIP$/', '', $uploadedFileBaseName);
         $validate = count($form->getValue('disable_validation')) == 0 ? true : false;
         try {
             $report = taoDelivery_models_classes_import_Assembler::importDelivery($class, $uploadedFile);
         } catch (common_Exception $e) {
             $report = common_report_Report::createFailure(__('An error occured during the import'));
             if ($e instanceof common_exception_UserReadableException) {
                 $report->add($e);
             }
         }
         tao_helpers_File::remove($uploadedFile);
     } else {
         throw new common_exception_Error('No file provided as parameter \'source\' for OWI import');
     }
     return $report;
 }
开发者ID:swapnilaptara,项目名称:tao-aptara-assess,代码行数:33,代码来源:class.AssemblyImportHandler.php

示例2: import

 /**
  * Import file entry point by using $this->service
  * Check POST method & get valid uploaded file
  */
 public function import()
 {
     try {
         // Check if it's post method
         if ($this->getRequestMethod() != Request::HTTP_POST) {
             throw new \common_exception_NotImplemented('Only post method is accepted to import Qti package.');
         }
         // Get valid package parameter
         $package = $this->getUploadedPackage();
         // Call service to import package
         \helpers_TimeOutHelper::setTimeOutLimit(\helpers_TimeOutHelper::LONG);
         $report = ImportService::singleton()->importQTIPACKFile($package, $this->getDestinationClass());
         \helpers_TimeOutHelper::reset();
         \tao_helpers_File::remove($package);
         if ($report->getType() !== \common_report_Report::TYPE_SUCCESS) {
             $this->returnFailure(new \common_Exception(__("An unexpected error occured during the import of the IMS QTI Item Package.")));
         } else {
             $itemIds = [];
             /** @var \common_report_Report $subReport */
             foreach ($report as $subReport) {
                 $itemIds[] = $subReport->getData()->getUri();
             }
             $this->returnSuccess(array('items' => $itemIds));
         }
     } catch (ExtractException $e) {
         $this->returnFailure(new \common_Exception(__('The ZIP archive containing the IMS QTI Item cannot be extracted.')));
     } catch (ParsingException $e) {
         $this->returnFailure(new \common_Exception(__('The ZIP archive does not contain an imsmanifest.xml file or is an invalid ZIP archive.')));
     } catch (\Exception $e) {
         $this->returnFailure($e);
     }
 }
开发者ID:oat-sa,项目名称:extension-tao-itemqti,代码行数:36,代码来源:RestQtiItem.php

示例3: import

 /**
  * (non-PHPdoc)
  * @see tao_models_classes_import_ImportHandler::import()
  */
 public function import($class, $form)
 {
     $fileInfo = $form->getValue('source');
     //import for CSV
     if (isset($fileInfo)) {
         \helpers_TimeOutHelper::setTimeOutLimit(\helpers_TimeOutHelper::MEDIUM);
         //get the services instances we will need
         $itemService = \taoItems_models_classes_ItemsService::singleton();
         $uploadedFile = $fileInfo['uploaded_file'];
         $uploadedFileBaseName = basename($uploadedFile);
         // uploaded file name contains an extra prefix that we have to remove.
         $uploadedFileBaseName = preg_replace('/^([0-9a-z])+_/', '', $uploadedFileBaseName, 1);
         $uploadedFileBaseName = preg_replace('/.zip|.ZIP$/', '', $uploadedFileBaseName);
         $validate = count($form->getValue('disable_validation')) == 0 ? true : false;
         try {
             $importer = new Assembler();
             $report = $importer->importDelivery($class, $uploadedFile);
         } catch (\common_Exception $e) {
             $report = common_report_Report::createFailure(__('An error occured during the import'));
             if ($e instanceof \common_exception_UserReadableException) {
                 $report->add($e);
             }
         }
         \tao_helpers_File::remove($uploadedFile);
         \helpers_TimeOutHelper::reset();
     } else {
         throw new \common_exception_Error('No file provided as parameter \'source\' for Delivery Assembly import');
     }
     return $report;
 }
开发者ID:oat-sa,项目名称:extension-tao-delivery-rdf,代码行数:34,代码来源:AssemblyImportHandler.php

示例4: cancelUpload

 public function cancelUpload()
 {
     $removed = 0;
     if ($this->hasRequestParameter('filename')) {
         $filename = trim($this->getRequestParameter('filename'));
         if (!empty($filename)) {
             $pattern = "/^[0-9a-f]*_" . preg_quote($filename, "/") . "\$/";
             $targetPath = tao_helpers_File::concat(array($this->rootFolder, $_REQUEST['folder']));
             foreach (scandir($targetPath) as $file) {
                 if (preg_match($pattern, $file)) {
                     if (tao_helpers_File::remove($targetPath . '/' . $file)) {
                         $removed++;
                     }
                 }
             }
         }
     }
     echo json_encode(array('removed' => $removed));
 }
开发者ID:nagyist,项目名称:tao-core,代码行数:19,代码来源:class.File.php

示例5: import

 /**
  * (non-PHPdoc)
  * @see tao_models_classes_import_ImportHandler::import()
  */
 public function import($class, $form)
 {
     try {
         $fileInfo = $form->getValue('source');
         if (isset($fileInfo['uploaded_file'])) {
             $uploadedFile = $fileInfo['uploaded_file'];
             // The zip extraction is a long process that can exceed the 30s timeout
             helpers_TimeOutHelper::setTimeOutLimit(helpers_TimeOutHelper::LONG);
             $report = taoQtiTest_models_classes_QtiTestService::singleton()->importMultipleTests($class, $uploadedFile);
             helpers_TimeOutHelper::reset();
             tao_helpers_File::remove($uploadedFile);
         } else {
             throw new common_exception_Error('No source file for import');
         }
         return $report;
     } catch (Exception $e) {
         return common_report_Report::createFailure($e->getMessage());
     }
 }
开发者ID:oat-sa,项目名称:extension-tao-testqti,代码行数:23,代码来源:class.TestImport.php

示例6: bindUploadFileDescription

 /**
  * Binds an UploadFileDescription with the target instance.
  *
  * @access protected
  * @author Jerome Bogaerts <jerome@taotesting.com>
  * @param  Property property The property to bind the data.
  * @param  UploadFileDescription desc the upload file description.
  * @return void
  */
 protected function bindUploadFileDescription(core_kernel_classes_Property $property, tao_helpers_form_data_UploadFileDescription $desc)
 {
     $instance = $this->getTargetInstance();
     // Delete old files.
     foreach ($instance->getPropertyValues($property) as $oF) {
         $oldFile = new core_kernel_versioning_File($oF);
         $oldFile->delete(true);
     }
     $name = $desc->getName();
     $size = $desc->getSize();
     if (!empty($name) && !empty($size)) {
         // Move the file at the right place.
         $source = $desc->getTmpPath();
         $repository = tao_models_classes_TaoService::singleton()->getUploadFileSource();
         $file = $repository->spawnFile($source, $desc->getName());
         tao_helpers_File::remove($source);
         $instance->setPropertyValue($property, $file->getUri());
         // Update the UploadFileDescription with the stored file.
         $desc->setFile($file);
     }
 }
开发者ID:nagyist,项目名称:tao-core,代码行数:30,代码来源:class.GenerisFormDataBinder.php

示例7: actionDelete

 /**
  * Implementation of the 'delete' action.
  *
  * @access public
  * @author Joel Bout, <joel.bout@tudor.lu>
  * @return void
  */
 public function actionDelete()
 {
     $this->outVerbose("Deleting language '" . $this->options['language'] . "' for extension '" . $this->options['extension'] . "' ...");
     $dir = $this->buildLanguagePath($this->options['extension'], $this->options['language']);
     if (!tao_helpers_File::remove($dir, true)) {
         $this->err("Could not delete language '" . $this->options['language'] . "' for extension '" . $this->options['extension'] . "'.", true);
     }
     $this->outVerbose("Language '" . $this->options['language'] . "' for extension '" . $this->options['extension'] . "' successfully deleted.");
 }
开发者ID:nagyist,项目名称:tao-core,代码行数:16,代码来源:class.TaoTranslate.php

示例8: tearDown

 public function tearDown()
 {
     parent::tearDown();
     tao_helpers_File::remove($this->envPath, true);
     $this->assertFalse(is_dir($this->envPath));
 }
开发者ID:swapnilaptara,项目名称:tao-aptara-assess,代码行数:6,代码来源:FileHelperTest.php

示例9: testImportRules

 public function testImportRules()
 {
     $path = $this->getSamplePath('/csv/users1-header-rules-validator.csv');
     $file = tao_helpers_File::createTempDir() . '/temp-import-rules-validator.csv';
     tao_helpers_File::copy($path, $file);
     $this->assertFileExists($file);
     $importer = new CsvBasicImporter();
     $class = $this->prophesize('\\core_kernel_classes_Class');
     $resource = $this->prophesize('\\core_kernel_classes_Resource');
     $class->createInstanceWithProperties(["label" => ["Correct row"], "firstName" => ["Jérôme"], "lastName" => ["Bogaerts"], "login" => ["jbogaerts"], "mail" => ["jerome.bogaerts@tudor.lu"], "password" => ["jbogaerts!!!111Ok"], "UserUIlg" => ["http://www.tao.lu/Ontologies/TAO.rdf#LangEN"]])->shouldBeCalledTimes(1)->willReturn($resource->reveal());
     $importer->setValidators(['label' => [tao_helpers_form_FormFactory::getValidator('Length', ["max" => 20])], 'firstName' => [tao_helpers_form_FormFactory::getValidator('NotEmpty'), tao_helpers_form_FormFactory::getValidator('Length', ["min" => 2, "max" => 25])], 'lastName' => [tao_helpers_form_FormFactory::getValidator('NotEmpty'), tao_helpers_form_FormFactory::getValidator('Length', ["min" => 2, "max" => 12])], 'login' => [tao_helpers_form_FormFactory::getValidator('NotEmpty'), tao_helpers_form_FormFactory::getValidator('AlphaNum'), tao_helpers_form_FormFactory::getValidator('Unique'), tao_helpers_form_FormFactory::getValidator('Length', ["min" => 2, "max" => 12])], 'mail' => [tao_helpers_form_FormFactory::getValidator('NotEmpty'), tao_helpers_form_FormFactory::getValidator('Email'), tao_helpers_form_FormFactory::getValidator('Length', ["min" => 6, "max" => 100])], 'password' => [tao_helpers_form_FormFactory::getValidator('NotEmpty')], 'UserUIlg' => [tao_helpers_form_FormFactory::getValidator('Url')]]);
     $report = $importer->import($class->reveal(), ['file' => $file, 'map' => ['label' => "0", 'firstName' => "1", 'lastName' => "2", 'login' => "3", 'mail' => "4", 'password' => "5", 'UserUIlg' => "6"]]);
     $this->assertInstanceOf('common_report_Report', $report);
     $this->assertEquals(common_report_Report::TYPE_WARNING, $report->getType());
     $this->assertCount(6, $report->getErrors());
     //cause import has errors
     $this->assertFileExists($file);
     tao_helpers_File::remove($file);
     $this->assertFileNotExists($file);
 }
开发者ID:oat-sa,项目名称:tao-core,代码行数:20,代码来源:CsvImportTest.php

示例10: bindUploadFileDescription

 /**
  * Binds an UploadFileDescription with the target instance.
  *
  * @access protected
  * @author Jerome Bogaerts <jerome@taotesting.com>
  * @param  core_kernel_classes_Property $property The property to bind the data.
  * @param  tao_helpers_form_data_UploadFileDescription $desc the upload file description.
  * @return void
  */
 protected function bindUploadFileDescription(core_kernel_classes_Property $property, tao_helpers_form_data_UploadFileDescription $desc)
 {
     $instance = $this->getTargetInstance();
     // If form has delete action, remove file
     if ($desc->getAction() == tao_helpers_form_data_UploadFileDescription::FORM_ACTION_DELETE) {
         $this->removeFile($property);
     } elseif ($desc->getAction() == tao_helpers_form_data_UploadFileDescription::FORM_ACTION_ADD) {
         $name = $desc->getName();
         $size = $desc->getSize();
         if (!empty($name) && !empty($size)) {
             // Remove old
             $this->removeFile($property);
             // Move the file at the right place.
             $source = $desc->getTmpPath();
             $serial = tao_models_classes_TaoService::singleton()->storeUploadedFile($source, $name);
             tao_helpers_File::remove($source);
             // Create association between item & file, database side
             $instance->editPropertyValues($property, $serial);
             // Update the UploadFileDescription with the stored file.
             $desc->setFile($serial);
         }
     }
 }
开发者ID:oat-sa,项目名称:tao-core,代码行数:32,代码来源:class.GenerisFormDataBinder.php


注:本文中的tao_helpers_File::remove方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。