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


PHP tao_helpers_File::scandir方法代码示例

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


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

示例1: saveDoc

 /**
  * Save the content of test from a QTI Document
  * @param core_kernel_classes_Resource $test
  * @param qtism\data\storage\xml\XmlDocument $doc
  * @return boolean true if saved
  * @throws taoQtiTest_models_classes_QtiTestServiceException
  */
 private function saveDoc(core_kernel_classes_Resource $test, XmlDocument $doc)
 {
     $saved = false;
     if (!is_null($test) && !is_null($doc)) {
         $file = $this->getTestFile($test);
         if (!is_null($file)) {
             $testPath = $file->getAbsolutePath();
             try {
                 // Search for the test.xml file in the test content directory.
                 $files = tao_helpers_File::scandir($testPath, array('recursive' => true, 'absolute' => true, 'only' => tao_helpers_File::$FILE));
                 $dirContent = array();
                 foreach ($files as $f) {
                     $pathinfo = pathinfo($f);
                     if ($pathinfo['filename'] . '.' . $pathinfo['extension'] === TAOQTITEST_FILENAME) {
                         $dirContent[] = $f;
                     }
                 }
                 if (count($dirContent) === 0) {
                     throw new Exception('No QTI-XML test file found.');
                 } else {
                     if (count($dirContent) > 1) {
                         throw new Exception('Multiple QTI-XML test file found.');
                     }
                 }
                 $finalPath = current($dirContent);
                 $doc->save($finalPath);
                 $saved = true;
             } catch (Exception $e) {
                 throw new taoQtiTest_models_classes_QtiTestServiceException("An error occured while writing QTI-XML test '{$testPath}': " . $e->getMessage(), taoQtiTest_models_classes_QtiTestServiceException::ITEM_WRITE_ERROR);
             }
         }
     }
     return $saved;
 }
开发者ID:nagyist,项目名称:extension-tao-testqti,代码行数:41,代码来源:class.QtiTestService.php

示例2: exportTest

 /**
  * Export the Test definition itself and its related media.
  * 
  * @param array $itemIdentifiers An array of identifiers that were assigned to exported items into the IMS Manifest.
  */
 protected function exportTest(array $itemIdentifiers)
 {
     // Serialize the test definition somewhere and add
     // it to the archive.
     $tmpPath = tempnam('/tmp', 'tao');
     $this->getTestDocument()->save($tmpPath);
     $testPath = $this->getTestService()->getTestContent($this->getItem())->getAbsolutePath();
     // Add the test definition in the archive.
     $testBasePath = 'tests/' . tao_helpers_Uri::getUniqueId($this->getItem()->getUri()) . '/';
     $extraPath = trim(str_replace(array($testPath, TAOQTITEST_FILENAME), '', $this->getTestService()->getDocPath($this->getItem())), DIRECTORY_SEPARATOR);
     $testHref = $testBasePath . (empty($extraPath) === false ? $extraPath . '/' : '') . 'test.xml';
     common_Logger::t('TEST DEFINITION AT: ' . $testHref);
     $this->addFile($tmpPath, $testHref);
     $this->referenceTest($testHref, $itemIdentifiers);
     $files = tao_helpers_File::scandir($testPath, array('recursive' => true, 'absolute' => true));
     foreach ($files as $f) {
         // Only add dependency files...
         if (is_dir($f) === false && strpos($f, TAOQTITEST_FILENAME) === false) {
             // Add the file to the archive.
             $fileHref = $testBasePath . ltrim(str_replace($testPath, '', $f), '/');
             common_Logger::t('AUXILIARY FILE AT: ' . $fileHref);
             $this->getZip()->addFile($f, $fileHref);
             $this->referenceAuxiliaryFile($fileHref);
         }
     }
 }
开发者ID:nagyist,项目名称:extension-tao-testqti,代码行数:31,代码来源:class.QtiTestExporter.php

示例3: copyPublicResources

 /**
  * Copy the test resources (e.g. images) that will be availabe at delivery time
  * in the public compilation directory.
  * 
  */
 protected function copyPublicResources()
 {
     $compiledDocDir = $this->getPrivateDirectory()->getPath();
     $publicCompiledDocDir = $this->getPublicDirectory()->getPath();
     foreach (tao_helpers_File::scandir($compiledDocDir, array('recursive' => true, 'only' => tao_helpers_File::$FILE, 'absolute' => true)) as $file) {
         $mime = tao_helpers_File::getMimeType($file, true);
         $pathinfo = pathinfo($file);
         // Exclude CSS files because already copied when dealing with rubric blocks.
         if (in_array($mime, self::getPublicMimeTypes()) === true && $pathinfo['extension'] !== 'php') {
             $file = str_replace($compiledDocDir, '', $file);
             common_Logger::t("Copying public resource '{$file}'...");
             taoQtiTest_helpers_Utils::storeQtiResource($publicCompiledDocDir, $file, $compiledDocDir);
         }
     }
 }
开发者ID:nagyist,项目名称:extension-tao-testqti,代码行数:20,代码来源:class.QtiTestCompiler.php


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