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


PHP tao_helpers_File::createTempDir方法代码示例

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


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

示例1: download

 /**
  * (non-PHPdoc)
  * @see \oat\tao\model\media\MediaBrowser::download()
  */
 public function download($link)
 {
     $url = str_replace('\\/', '/', $link);
     $fileName = \tao_helpers_File::createTempDir() . basename($link);
     common_Logger::d('Downloading ' . $url);
     helpers_TimeOutHelper::setTimeOutLimit(helpers_TimeOutHelper::NO_TIMEOUT);
     $fp = fopen($fileName, 'w+');
     $curlHandler = curl_init();
     curl_setopt($curlHandler, CURLOPT_URL, $url);
     curl_setopt($curlHandler, CURLOPT_FILE, $fp);
     curl_setopt($curlHandler, CURLOPT_TIMEOUT, 50);
     curl_setopt($curlHandler, CURLOPT_FOLLOWLOCATION, true);
     //if there is an http auth on the local domain, it's mandatory to auth with curl
     if (USE_HTTP_AUTH) {
         $addAuth = false;
         $domains = array('localhost', '127.0.0.1', ROOT_URL);
         foreach ($domains as $domain) {
             if (preg_match("/" . preg_quote($domain, '/') . "/", $url)) {
                 $addAuth = true;
             }
         }
         if ($addAuth) {
             curl_setopt($curlHandler, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
             curl_setopt($curlHandler, CURLOPT_USERPWD, USE_HTTP_USER . ":" . USE_HTTP_PASS);
         }
     }
     curl_exec($curlHandler);
     $httpCode = curl_getinfo($curlHandler, CURLINFO_HTTP_CODE);
     $success = $httpCode == 200;
     curl_close($curlHandler);
     fclose($fp);
     helpers_TimeOutHelper::reset();
     return $fileName;
 }
开发者ID:nagyist,项目名称:tao-core,代码行数:38,代码来源:HttpSource.php

示例2: generate

 /**
  * Generate a new Booklet from a specific test
  * in a specific class and return a report
  * 
  * @param core_kernel_classes_Resource $test
  * @param core_kernel_classes_Class $class
  * @return common_report_Report
  */
 public static function generate(core_kernel_classes_Resource $test, core_kernel_classes_Class $class)
 {
     $report = new common_report_Report(common_report_Report::TYPE_SUCCESS);
     $model = \taoTests_models_classes_TestsService::singleton()->getTestModel($test);
     if ($model->getUri() != INSTANCE_TEST_MODEL_QTI) {
         $report->setType(common_report_Report::TYPE_ERROR);
         $report->setMessage(__('%s is not a QTI test', $test->getLabel()));
         return $report;
     }
     // generate file content
     $tmpFolder = \tao_helpers_File::createTempDir();
     $tmpFile = $tmpFolder . 'test.txt';
     $content = '';
     foreach (self::getItems($test) as $item) {
         $content .= self::renderItem($item);
     }
     file_put_contents($tmpFile, $content);
     // generate tao instance
     $instance = BookletClassService::singleton()->createBookletInstance($class, __('%s Booklet', $test->getLabel()), $tmpFile);
     \tao_helpers_File::delTree($tmpFolder);
     // return report with instance
     $report->setMessage(__('%s created', $instance->getLabel()));
     $report->setData($instance);
     return $report;
 }
开发者ID:nagyist,项目名称:extension-tao-booklet,代码行数:33,代码来源:BookletRenderer.php

示例3: getRubrics

 /**
  * Gets the rubrics according to the current session state
  * The content is directly rendered into the page
  * @param RunnerServiceContext $context
  * @return mixed
  */
 public function getRubrics(RunnerServiceContext $context)
 {
     // TODO: make a better implementation for rubrics loading.
     /* @var AssessmentTestSession $session */
     $session = $context->getTestSession();
     $compilationDirs = $context->getCompilationDirectory();
     // -- variables used in the included rubric block templates.
     // base path (base URI to be used for resource inclusion).
     $basePathVarName = TAOQTITEST_BASE_PATH_NAME;
     ${$basePathVarName} = $compilationDirs['public']->getPublicAccessUrl();
     // state name (the variable to access to get the state of the assessmentTestSession).
     $stateName = TAOQTITEST_RENDERING_STATE_NAME;
     ${$stateName} = $session;
     // views name (the variable to be accessed for the visibility of rubric blocks).
     $viewsName = TAOQTITEST_VIEWS_NAME;
     ${$viewsName} = array(View::CANDIDATE);
     ob_start();
     foreach ($session->getRoute()->current()->getRubricBlockRefs() as $rubric) {
         $data = $compilationDirs['private']->read($rubric->getHref());
         $tmpFile = \tao_helpers_File::createTempDir() . basename($rubric->getHref());
         file_put_contents($tmpFile, $data);
         include $tmpFile;
         unlink($tmpFile);
     }
     $rubrics = ob_get_contents();
     ob_end_clean();
     return $rubrics;
 }
开发者ID:oat-sa,项目名称:extension-tao-testqti,代码行数:34,代码来源:QtiRunnerRubric.php

示例4: testDeepCloneTriplesFile

 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);
 }
开发者ID:kendaop,项目名称:extension-tao-revision,代码行数:25,代码来源:CloneHelperTest.php

示例5: importDelivery

 public static function importDelivery(core_kernel_classes_Class $deliveryClass, $archiveFile)
 {
     $folder = tao_helpers_File::createTempDir();
     $zip = new ZipArchive();
     if ($zip->open($archiveFile) === true) {
         if ($zip->extractTo($folder)) {
             $returnValue = $folder;
         }
         $zip->close();
     }
     $manifestPath = $folder . self::MANIFEST_FILE;
     if (!file_exists($manifestPath)) {
         return common_report_Report::createFailure(__('Manifest not found in assembly'));
     }
     $manifest = json_decode(file_get_contents($manifestPath), true);
     $label = $manifest['label'];
     $serviceCall = tao_models_classes_service_ServiceCall::fromString(base64_decode($manifest['runtime']));
     $dirs = $manifest['dir'];
     $resultServer = taoResultServer_models_classes_ResultServerAuthoringService::singleton()->getDefaultResultServer();
     try {
         foreach ($dirs as $id => $relPath) {
             tao_models_classes_service_FileStorage::singleton()->import($id, $folder . $relPath);
         }
         $delivery = $deliveryClass->createInstanceWithProperties(array(RDFS_LABEL => $label, PROPERTY_COMPILEDDELIVERY_DIRECTORY => array_keys($dirs), PROPERTY_COMPILEDDELIVERY_TIME => time(), PROPERTY_COMPILEDDELIVERY_RUNTIME => $serviceCall->toOntology(), TAO_DELIVERY_RESULTSERVER_PROP => $resultServer));
         $report = common_report_Report::createSuccess(__('Delivery "%s" successfully imported', $label), $delivery);
     } catch (Exception $e) {
         if (isset($delivery) && $delivery instanceof core_kernel_classes_Resource) {
             $delivery->delete();
         }
         $report = common_report_Report::createFailure(__('Unkown error during impoort'));
     }
     return $report;
 }
开发者ID:swapnilaptara,项目名称:tao-aptara-assess,代码行数:33,代码来源:class.Assembler.php

示例6: importDelivery

 public function importDelivery(core_kernel_classes_Class $deliveryClass, $archiveFile)
 {
     $folder = tao_helpers_File::createTempDir();
     $zip = new ZipArchive();
     if ($zip->open($archiveFile) !== true) {
         return common_report_Report::createFailure(__('Unable to export Archive'));
     }
     $zip->extractTo($folder);
     $zip->close();
     $manifestPath = $folder . self::MANIFEST_FILE;
     if (!file_exists($manifestPath)) {
         return common_report_Report::createFailure(__('Manifest not found in assembly'));
     }
     $manifest = json_decode(file_get_contents($manifestPath), true);
     try {
         $this->importDeliveryFiles($deliveryClass, $manifest, $folder);
         $delivery = $this->importDeliveryResource($deliveryClass, $manifest);
         $report = common_report_Report::createSuccess(__('Delivery "%s" successfully imported', $delivery->getUri()), $delivery);
     } catch (Exception $e) {
         common_Logger::w($e->getMessage());
         if (isset($delivery) && $delivery instanceof core_kernel_classes_Resource) {
             $delivery->delete();
         }
         $report = common_report_Report::createFailure(__('Unkown error during impoort'));
     }
     return $report;
 }
开发者ID:nagyist,项目名称:extension-tao-delivery,代码行数:27,代码来源:class.Assembler.php

示例7: testCompile

 public function testCompile()
 {
     //test with items
     $config = array('previous' => true);
     $items = array($this->item->getUri());
     $this->testModel->save($this->test, array('itemUris' => $items, 'config' => $config));
     $waitingReport = new \common_report_Report(\common_report_Report::TYPE_SUCCESS);
     $serviceCall = $this->getMockBuilder('tao_models_classes_service_ServiceCall')->disableOriginalConstructor()->setMethods(array('serializeToString'))->getMock();
     $serviceCall->expects($this->once())->method('serializeToString')->willReturn('greatString');
     $waitingReport->setData($serviceCall);
     $testCompiler = $this->getMockBuilder('oat\\taoTestLinear\\model\\TestCompiler')->setConstructorArgs(array($this->test, $this->storage))->setMethods(array('subCompile', 'spawnPrivateDirectory'))->getMock();
     $testCompiler->expects($this->once())->method('subCompile')->willReturn($waitingReport);
     //will spawn a new directory and store the content file
     $directoryMock = $this->getMockBuilder('tao_models_classes_service_StorageDirectory')->disableOriginalConstructor()->setMethods(array('getPath'))->getMock();
     $tmpDir = \tao_helpers_File::createTempDir();
     $this->assertFileExists($tmpDir);
     $directoryMock->expects($this->once())->method('getPath')->willReturn($tmpDir);
     $testCompiler->expects($this->once())->method('spawnPrivateDirectory')->willReturn($directoryMock);
     $report = $testCompiler->compile();
     $this->assertEquals(__('Test Compilation'), $report->getMessage(), __('Compilation should work'));
     $this->assertFileExists($tmpDir . 'data.json', __('Compilation file not created'));
     $compile = '{"items":{"http:\\/\\/myFancyDomain.com\\/myGreatResourceUriForItem":"greatString"},"previous":true}';
     $this->assertEquals($compile, file_get_contents($tmpDir . 'data.json', __('File content error')));
     \tao_helpers_File::delTree($tmpDir);
     $this->assertFileNotExists($tmpDir);
 }
开发者ID:oat-sa,项目名称:extension-tao-testlinear,代码行数:26,代码来源:TestCompilerTest.php

示例8: testStoreData

 public function testStoreData()
 {
     $store = new DataStorage($this->sentData);
     $this->sampleFilePath = \tao_helpers_File::createTempDir() . 'stored.csv';
     $ref = new \ReflectionProperty('oat\\taoClientDiagnostic\\model\\DataStorage', 'filePath');
     $ref->setAccessible(true);
     $ref->setValue($store, $this->sampleFilePath);
     $store->setIsCompatible(true)->storeData();
     $this->assertFileExists($this->sampleFilePath);
     $row = 0;
     if (($handle = fopen($this->sampleFilePath, "r")) !== FALSE) {
         while (($data = fgetcsv($handle, 1000, ";")) !== FALSE) {
             $num = count($data);
             $row++;
             $this->assertEquals(24, $num);
             if ($row === 2) {
                 $this->assertEquals($this->sentData['key'], $data[0]);
                 $this->assertEquals($this->sentData['login'], $data[1]);
                 $this->assertEquals($this->sentData['ip'], $data[2]);
                 $this->assertEquals($this->sentData['browser'], $data[3]);
                 $this->assertEquals($this->sentData['browserVersion'], $data[4]);
                 $this->assertEquals($this->sentData['os'], $data[5]);
                 $this->assertEquals($this->sentData['osVersion'], $data[6]);
                 $this->assertEquals(1, $data[23]);
             }
         }
         fclose($handle);
         $this->assertEquals(2, $row);
     }
     $store->setIsCompatible(false)->storeData();
     $row = 0;
     if (($handle = fopen($this->sampleFilePath, "r")) !== FALSE) {
         while (($data = fgetcsv($handle, 1000, ";")) !== FALSE) {
             $num = count($data);
             $row++;
             $this->assertEquals(24, $num);
             if ($row === 2) {
                 $this->assertEquals($this->sentData['key'], $data[0]);
                 $this->assertEquals($this->sentData['login'], $data[1]);
                 $this->assertEquals($this->sentData['ip'], $data[2]);
                 $this->assertEquals($this->sentData['browser'], $data[3]);
                 $this->assertEquals($this->sentData['browserVersion'], $data[4]);
                 $this->assertEquals($this->sentData['os'], $data[5]);
                 $this->assertEquals($this->sentData['osVersion'], $data[6]);
                 $this->assertEquals(0, $data[23]);
             }
         }
         fclose($handle);
         $this->assertEquals(2, $row);
     }
     return $store;
 }
开发者ID:nagyist,项目名称:extension-tao-clientdiag,代码行数:52,代码来源:DataStoringTest.php

示例9: testDeepDeleteTriples

 public function testDeepDeleteTriples()
 {
     //create resources
     $repository = \tao_models_classes_FileSourceService::singleton()->addLocalSource("Label Test", \tao_helpers_File::createTempDir());
     $file = $repository->createFile("test.xml", "sample");
     //delete resource
     DeleteHelper::deepDeleteTriples($file->getRdfTriples());
     DeleteHelper::deepDeleteTriples($repository->getRdfTriples());
     //see if all is deleted
     //try to get the resource
     $resourceTest = new \core_kernel_classes_Resource($repository->getUri());
     $fileTest = new \core_kernel_classes_Resource($file->getUri());
     $this->assertCount(0, $resourceTest->getRdfTriples());
     $this->assertCount(0, $fileTest->getRdfTriples());
 }
开发者ID:kendaop,项目名称:extension-tao-revision,代码行数:15,代码来源:DeleteHelperTest.php

示例10: testTracing

 public function testTracing()
 {
     $events = array('{"name":"div","type":"click","time":"1288780765981","id":"qunit-fixture"}', '{"name":"BUSINESS","type":"TEST","time":"1288780765982","id":"12"}', '{"name":"h2","type":"click","time":"1288780766000","id":"qunit-banner"}', '{"name":"h1","type":"click","time":"1288780765999","id":"qunit-header"}');
     $folder = tao_helpers_File::createTempDir();
     $processId = '123456789';
     $eventFilter = $this->eventsService->getEventList($this->eventFile, 'server');
     $this->assertTrue($this->eventsService->traceEvent($events, $processId, $folder, $eventFilter));
     $this->assertTrue($this->eventsService->traceEvent($events, $processId, $folder));
     $this->assertTrue(file_exists($folder . '/' . $processId . '_0.xml'));
     foreach (glob($folder . '/' . $processId . '*') as $trace_file) {
         if (preg_match('/(xml|lock)$/', $trace_file)) {
             unlink($trace_file);
         }
     }
     tao_helpers_File::delTree($folder);
 }
开发者ID:nagyist,项目名称:tao-core,代码行数:16,代码来源:EventsServiceTest.php

示例11: __construct

 public function __construct()
 {
     $this->tmpDir = \tao_helpers_File::createTempDir();
     $this->dir = str_replace(DIRECTORY_SEPARATOR, '/', dirname(__DIR__));
     $this->taoDir = dirname($this->dir) . '/tao';
     $this->assetDir = $this->dir . '/fontConversion/assets';
     $this->doNotEdit = file_get_contents($this->assetDir . '/do-not-edit.tpl');
     $this->currentSelection = $this->assetDir . '/selection.json';
     $writables = array($this->taoDir . '/views/css/font/tao/', $this->taoDir . '/views/scss/inc/fonts/', $this->taoDir . '/views/js/lib/ckeditor/skins/tao/scss/inc/', $this->taoDir . '/helpers/', $this->assetDir);
     foreach ($writables as $writable) {
         if (!is_writable($writable)) {
             throw new \Exception(implode("\n<br>", $writables) . ' must be writable');
         }
     }
     $this->setData('icon-listing', $this->loadIconListing());
 }
开发者ID:nagyist,项目名称:extension-tao-devtools,代码行数:16,代码来源:FontConversion.php

示例12: extract

 /**
  * Extract zip package into temp directory
  *
  * @param string $source Zip path
  * @return string Tmp directory to find extracted zip
  * @throws PortableElementExtractException
  */
 public function extract($source)
 {
     $tmpDirectory = null;
     $this->assertSourceAsFile($source);
     $folder = \tao_helpers_File::createTempDir();
     $zip = new ZipArchive();
     if ($zip->open($source) === true) {
         if ($zip->extractTo($folder)) {
             $tmpDirectory = $folder;
         }
         $zip->close();
     }
     if (!is_dir($tmpDirectory)) {
         throw new PortableElementExtractException('Unable to extract portable element.');
     }
     return $tmpDirectory;
 }
开发者ID:oat-sa,项目名称:extension-tao-itemqti,代码行数:24,代码来源:PortableElementPackageParser.php

示例13: testStoreFileValid

 public function testStoreFileValid()
 {
     $tmpDir = \tao_helpers_File::createTempDir();
     $storageDir = $tmpDir . 'media/';
     mkdir($storageDir);
     //force baseDir
     $ref = new \ReflectionProperty('oat\\taoMediaManager\\model\\fileManagement\\SimpleFileManagement', 'baseDir');
     $ref->setAccessible(true);
     $ref->setValue($this->fileManagement, $storageDir);
     $ref->setAccessible(false);
     $fileTmp = dirname(__DIR__) . '/sample/Brazil.png';
     $this->assertFileNotExists($storageDir . 'Brazil.png', 'The file is already stored');
     $link = $this->fileManagement->storeFile($fileTmp, 'brazil.png');
     // test the return link
     $this->assertInternalType('string', $link, 'The method return should be a string');
     $this->assertEquals('brazil.png', $link, 'The link is wrong');
     $this->assertFileExists($storageDir . 'brazil.png', 'The file has not been stored');
     return array($storageDir, $link);
 }
开发者ID:nagyist,项目名称:extension-tao-mediamanager,代码行数:19,代码来源:SimpleFileManagementTest.php

示例14: testSend

 public function testSend()
 {
     $testfolder = tao_helpers_File::createTempDir();
     $expectedFilePath = $testfolder . 'testidentifier' . DIRECTORY_SEPARATOR . 'message.html';
     $this->assertFileNotExists($expectedFilePath);
     $userMock = $this->prophesize('oat\\oatbox\\user\\User');
     $userMock->getIdentifier()->willReturn('testidentifier');
     $userMock->getIdentifier()->should(new CallTimesPrediction(1));
     $messageMock = $this->prophesize('oat\\tao\\model\\messaging\\Message');
     $messageMock->getTo()->willReturn($userMock->reveal());
     $messageMock->getTo()->should(new CallTimesPrediction(1));
     $messageMock->getBody()->willReturn('testBody');
     $messageMock->getBody()->should(new CallTimesPrediction(1));
     $transporter = new FileSink(array(FileSink::CONFIG_FILEPATH => $testfolder));
     $result = $transporter->send($messageMock->reveal());
     $this->assertTrue($result);
     $this->assertFileExists($expectedFilePath);
     $messageContent = file_get_contents($expectedFilePath);
     $this->assertEquals('testBody', $messageContent);
     $userMock->checkProphecyMethodsPredictions();
     $messageMock->checkProphecyMethodsPredictions();
     tao_helpers_File::delTree($testfolder);
     $this->assertFalse(is_dir($testfolder));
 }
开发者ID:nagyist,项目名称:tao-core,代码行数:24,代码来源:FileSink.php

示例15: testEdit

 /**
  * @dataProvider sharedStimulusImportProvider
  */
 public function testEdit($filename, $expectedReport, $called)
 {
     if (file_exists($filename)) {
         $tmpDir = \tao_helpers_File::createTempDir();
         copy($filename, $tmpDir . basename($filename));
         $filename = $tmpDir . basename($filename);
     }
     $clazz = new \core_kernel_classes_Class('http://www.tao.lu/Ontologies/TAOMedia.rdf#Media');
     $instance = $clazz->createInstance('my Label');
     $file['uploaded_file'] = $filename;
     $file['name'] = basename($filename);
     $form = new FileImportForm($instance->getUri());
     $form = $form->getForm();
     $form->setValues(array('source' => $file, 'lang' => 'EN_en'));
     if ($called) {
         $this->service->expects($this->once())->method('editMediaInstance')->willReturn(true);
     }
     $report = $this->packageImporter->edit($instance, $form);
     /** @var \common_report_Report $expectedReport*/
     $expectedReport->setMessage(preg_replace('/%s/', 'edited', $expectedReport->getMessage()));
     $this->assertEquals($expectedReport->getMessage(), $report->getMessage(), __('Report message is wrong'));
     $this->assertEquals($expectedReport->getType(), $report->getType(), __('Report should be success'));
     $instance->delete(true);
 }
开发者ID:nagyist,项目名称:extension-tao-mediamanager,代码行数:27,代码来源:SharedStimulusPackageImporterTest.php


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