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


PHP tao_helpers_File::concat方法代码示例

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


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

示例1: export

 /**
  * (non-PHPdoc)
  * @see tao_models_classes_export_ExportHandler::export()
  */
 public function export($formValues, $destination)
 {
     $file = null;
     if (isset($formValues['filename']) === true) {
         $instances = is_string($formValues['instances']) ? array($formValues['instances']) : $formValues['instances'];
         if (count($instances) > 0) {
             $fileName = $formValues['filename'] . '_' . time() . '.zip';
             $path = tao_helpers_File::concat(array($destination, $fileName));
             if (tao_helpers_File::securityCheck($path, true) === false) {
                 throw new common_Exception('Unauthorized file name for QTI Test ZIP archive.');
             }
             // Create a new ZIP archive to store data related to the QTI Test.
             $zip = new ZipArchive();
             if ($zip->open($path, ZipArchive::CREATE) !== true) {
                 throw new common_Exception("Unable to create ZIP archive for QTI Test at location '" . $path . "'.");
             }
             // Create an empty IMS Manifest as a basis.
             $manifest = taoQtiTest_helpers_Utils::emptyImsManifest();
             foreach ($instances as $instance) {
                 $testResource = new core_kernel_classes_Resource($instance);
                 $testExporter = new taoQtiTest_models_classes_export_QtiTestExporter($testResource, $zip, $manifest);
                 common_Logger::d('Export ' . $instance);
                 $testExporter->export();
             }
             $file = $path;
             $zip->close();
         } else {
             common_Logger::w("No instance in form to export");
         }
     } else {
         common_Logger::w("Missing filename for QTI Test export using Export Handler '" . __CLASS__ . "'.");
     }
     return $file;
 }
开发者ID:nagyist,项目名称:extension-tao-testqti,代码行数:38,代码来源:class.TestExport.php

示例2: export

 /**
  * (non-PHPdoc)
  * @see tao_models_classes_export_ExportHandler::export()
  */
 public function export($formValues, $destination)
 {
     $file = null;
     if (isset($formValues['filename']) && isset($formValues['resource'])) {
         $class = new core_kernel_classes_Class($formValues['resource']);
         common_Logger::i('Exporting ' . $class->getUri());
         $adapter = new tao_helpers_data_GenerisAdapterRdf();
         $rdf = $adapter->export($class);
         if (!empty($rdf)) {
             $name = $formValues['filename'] . '_' . time() . '.rdf';
             $path = tao_helpers_File::concat(array($destination, $name));
             if (file_put_contents($path, $rdf)) {
                 $file = $path;
             }
         }
     }
     return $file;
 }
开发者ID:nagyist,项目名称:tao-core,代码行数:22,代码来源:class.RdfExporter.php

示例3: export

 /**
  * (non-PHPdoc)
  * @see tao_models_classes_export_ExportHandler::export()
  */
 public function export($formValues, $destination)
 {
     $report = common_report_Report::createSuccess();
     if (isset($formValues['filename']) === true) {
         $instances = is_string($formValues['instances']) ? array($formValues['instances']) : $formValues['instances'];
         if (count($instances) > 0) {
             $fileName = $formValues['filename'] . '_' . time() . '.zip';
             $path = tao_helpers_File::concat(array($destination, $fileName));
             if (tao_helpers_File::securityCheck($path, true) === false) {
                 throw new common_Exception('Unauthorized file name for QTI Test ZIP archive.');
             }
             // Create a new ZIP archive to store data related to the QTI Test.
             $zip = new ZipArchive();
             if ($zip->open($path, ZipArchive::CREATE) !== true) {
                 throw new common_Exception("Unable to create ZIP archive for QTI Test at location '" . $path . "'.");
             }
             // Create an empty IMS Manifest as a basis.
             $manifest = $this->createManifest();
             foreach ($instances as $instance) {
                 $testResource = new core_kernel_classes_Resource($instance);
                 $testExporter = $this->createExporter($testResource, $zip, $manifest);
                 common_Logger::d('Export ' . $instance);
                 $subReport = $testExporter->export();
                 if ($report->getType() !== common_report_Report::TYPE_ERROR && ($subReport->containsError() || $subReport->getType() === common_report_Report::TYPE_ERROR)) {
                     $report->setType(common_report_Report::TYPE_ERROR);
                     $report->setMessage(__('Not all test could be export', $testResource->getLabel()));
                 }
                 $report->add($subReport);
             }
             $report->setData($path);
             $zip->close();
         } else {
             common_Logger::w("No instance in form to export");
         }
     } else {
         common_Logger::w("Missing filename for QTI Test export using Export Handler '" . __CLASS__ . "'.");
     }
     return $report;
 }
开发者ID:oat-sa,项目名称:extension-tao-testqti,代码行数:43,代码来源:class.TestExport.php

示例4: exportCompiledDelivery

 /**
  * export a compiled delivery into an archive
  * 
  * @param core_kernel_classes_Resource $compiledDelivery
  * @throws Exception
  * @return string
  */
 public static function exportCompiledDelivery(core_kernel_classes_Resource $compiledDelivery)
 {
     $fileName = tao_helpers_Display::textCleaner($compiledDelivery->getLabel()) . '.zip';
     $path = tao_helpers_File::concat(array(tao_helpers_Export::getExportPath(), $fileName));
     if (!tao_helpers_File::securityCheck($path, true)) {
         throw new Exception('Unauthorized file name');
     }
     $zipArchive = new ZipArchive();
     if ($zipArchive->open($path, ZipArchive::CREATE) !== true) {
         throw new Exception('Unable to create archive at ' . $path);
     }
     $taoDeliveryVersion = common_ext_ExtensionsManager::singleton()->getInstalledVersion('taoDelivery');
     $data = array('dir' => array(), 'label' => $compiledDelivery->getLabel(), 'version' => $taoDeliveryVersion);
     $directories = $compiledDelivery->getPropertyValues(new core_kernel_classes_Property(PROPERTY_COMPILEDDELIVERY_DIRECTORY));
     foreach ($directories as $id) {
         $directory = tao_models_classes_service_FileStorage::singleton()->getDirectoryById($id);
         tao_helpers_File::addFilesToZip($zipArchive, $directory->getPath(), $directory->getRelativePath());
         $data['dir'][$id] = $directory->getRelativePath();
     }
     $runtime = $compiledDelivery->getUniquePropertyValue(new core_kernel_classes_Property(PROPERTY_COMPILEDDELIVERY_RUNTIME));
     $serviceCall = tao_models_classes_service_ServiceCall::fromResource($runtime);
     $data['runtime'] = base64_encode($serviceCall->serializeToString());
     $rdfExporter = new tao_models_classes_export_RdfExporter();
     $rdfdata = $rdfExporter->getRdfString(array($compiledDelivery));
     if (!$zipArchive->addFromString('delivery.rdf', $rdfdata)) {
         throw common_Exception('Unable to add metadata to exported delivery assembly');
     }
     $data['meta'] = 'delivery.rdf';
     $content = json_encode($data);
     //'<?php return '.common_Utils::toPHPVariableString($data).";";
     if (!$zipArchive->addFromString(self::MANIFEST_FILE, $content)) {
         $zipArchive->close();
         unlink($path);
         throw common_Exception('Unable to add manifest to exported delivery assembly');
     }
     $zipArchive->close();
     return $path;
 }
开发者ID:swapnilaptara,项目名称:tao-aptara-assess,代码行数:45,代码来源:class.Assembler.php

示例5: uploadFile

 /**
  * Get, check and move the file uploaded (described in the posetedFile parameter)
  * 
  * @param array $postedFile
  * @param string $folder
  * @return array $data
  */
 protected function uploadFile($postedFile, $folder)
 {
     $returnValue = array();
     if (isset($postedFile['tmp_name']) && isset($postedFile['name'])) {
         $tempFile = $postedFile['tmp_name'];
         $targetPath = tao_helpers_File::concat(array($this->rootFolder, $folder));
         if (tao_helpers_File::securityCheck($targetPath)) {
             if (!file_exists($targetPath)) {
                 mkdir($targetPath);
             }
             $targetFile = tao_helpers_File::concat(array($targetPath, uniqid() . '_' . $postedFile['name']));
             if (move_uploaded_file($tempFile, $targetFile)) {
                 $returnValue['uploaded'] = true;
                 $data = $postedFile;
                 $data['type'] = tao_helpers_File::getMimeType($targetFile);
                 $data['uploaded_file'] = $targetFile;
                 $returnValue['name'] = $postedFile['name'];
                 $returnValue['uploaded_file'] = $targetFile;
                 $returnValue['data'] = serialize($data);
             }
         }
     }
     return $returnValue;
 }
开发者ID:nagyist,项目名称:tao-core,代码行数:31,代码来源:class.File.php

示例6: out

if (!is_dir($exportDir)) {
    out("{$exportDir} is not a directory");
    exit;
}
$api = core_kernel_impl_ApiModelOO::singleton();
$nsManager = common_ext_NamespaceManager::singleton();
$namespaces = $nsManager->getAllNamespaces();
//$namespaces = array(LOCAL_NAMESPACE);
foreach ($namespaces as $namespace) {
    out("Exporting {$namespace}");
    $rdfData = core_kernel_api_ModelExporter::exportModelByUri($namespace);
    if (empty($rdfData)) {
        out("Nothing exported!");
        continue;
    }
    if ($nameMode == 'long') {
        $filename = str_replace('/', '_', str_replace('#', '', $namespace));
    } else {
        $filename = str_replace('#', '', strtolower(basename($namespace)));
    }
    if (!preg_match("/\\.rdf\$/", $filename)) {
        $filename .= '.rdf';
    }
    $path = tao_helpers_File::concat(array($exportDir, $filename));
    if (file_put_contents($path, $rdfData) != false) {
        out("Namespace exported at {$path}");
    } else {
        out("Error during the file creation : {$path}");
    }
    out();
}
开发者ID:nagyist,项目名称:tao-core,代码行数:31,代码来源:exportRDFModels.php

示例7: cloneItemContent

 protected function cloneItemContent($source, $destination, $property)
 {
     $fileNameProp = new core_kernel_classes_Property(PROPERTY_FILE_FILENAME);
     foreach ($source->getPropertyValuesCollection($property)->getIterator() as $propertyValue) {
         $file = new core_kernel_versioning_File($propertyValue->getUri());
         $repo = $file->getRepository();
         $relPath = basename($file->getAbsolutePath());
         if (!empty($relPath)) {
             $newPath = tao_helpers_File::concat(array($this->getItemFolder($destination), $relPath));
             common_Logger::i('copy ' . dirname($file->getAbsolutePath()) . ' to ' . dirname($newPath));
             tao_helpers_File::copy(dirname($file->getAbsolutePath()), dirname($newPath), true);
             if (file_exists($newPath)) {
                 $subpath = substr($newPath, strlen($repo->getPath()));
                 $newFile = $repo->createFile((string) $file->getOnePropertyValue($fileNameProp), dirname($subpath) . '/');
                 $destination->setPropertyValue($property, $newFile->getUri());
                 $newFile->add(true, true);
                 $newFile->commit('Clone of ' . $source->getUri(), true);
             }
         }
     }
 }
开发者ID:nagyist,项目名称:tao-extension-tao-item,代码行数:21,代码来源:class.ItemsService.php

示例8: getMediaResource

 /**
  * Load an item external media
  * It prevents to get it direclty in the data folder that access is denied
  * @requiresRight uri READ
  * @deprecated
  */
 public function getMediaResource()
 {
     if ($this->hasRequestParameter('path')) {
         $item = null;
         if ($this->hasRequestParameter('uri') && $this->hasRequestParameter('classUri')) {
             $item = $this->getCurrentInstance();
         } else {
             if ($this->hasSessionAttribute('uri') && $this->hasSessionAttribute('classUri')) {
                 $classUri = tao_helpers_Uri::decode($this->getSessionAttribute('classUri'));
                 if ($this->getClassService()->isItemClass(new core_kernel_classes_Class($classUri))) {
                     $item = new core_kernel_classes_Resource(tao_helpers_Uri::decode($this->getSessionAttribute('uri')));
                 }
             }
         }
         if (!is_null($item)) {
             $path = urldecode($this->getRequestParameter('path'));
             if (!tao_helpers_File::securityCheck($path)) {
                 throw new Exception('Unauthorized path ' . $path);
             }
             if (preg_match('/(.)+\\/filemanager\\/views\\/data\\//i', $path)) {
                 // check if the file is linked to the file manager
                 $resource = preg_replace('/(.)+\\/filemanager\\/views\\/data\\//i', ROOT_PATH . '/filemanager/views/data/', $path);
             } else {
                 // look in the item's dedicated folder. it should be a resource
                 // that is local to the item, not it the file manager
                 // $folder is the item's dedicated folder path, $path the path to the resource, relative to $folder
                 $folder = $this->getClassService()->getItemFolder($item);
                 $resource = tao_helpers_File::concat(array($folder, $path));
             }
             if (file_exists($resource)) {
                 $mimeType = tao_helpers_File::getMimeType($resource);
                 //allow only images, video, flash (and css?)
                 if (preg_match("/^(image|video|audio|application\\/x-shockwave-flash)/", $mimeType)) {
                     header("Content-Type: {$mimeType}; charset utf-8");
                     print trim(file_get_contents($resource));
                 }
             }
         }
     }
 }
开发者ID:nagyist,项目名称:tao-extension-tao-item,代码行数:46,代码来源:class.Items.php


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