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


PHP tao_helpers_File::getSafeFileName方法代码示例

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


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

示例1: send

 public function send(Message $message)
 {
     $receiver = $message->getTo();
     $path = $this->getOption(self::CONFIG_FILEPATH) . \tao_helpers_File::getSafeFileName($receiver->getIdentifier()) . DIRECTORY_SEPARATOR;
     if (!file_exists($path)) {
         mkdir($path);
     }
     $messageFile = $path . \tao_helpers_File::getSafeFileName('message.html', $path);
     \common_Logger::d($messageFile);
     $written = file_put_contents($messageFile, $message->getBody());
     return $written !== false;
 }
开发者ID:swapnilaptara,项目名称:tao-aptara-assess,代码行数:12,代码来源:FileSink.php

示例2: getFilePath

 /**
  * Get file path to save message
  * @param User $receiver
  * @param boolean $refresh whether the file path must be regenerated.
  */
 public function getFilePath(User $receiver)
 {
     $basePath = $this->getOption(self::CONFIG_FILEPATH);
     if (is_null($basePath) || !file_exists($basePath)) {
         throw new \common_exception_InconsistentData('Missing path ' . self::CONFIG_FILEPATH . ' for ' . __CLASS__);
     }
     $path = $basePath . \tao_helpers_File::getSafeFileName($receiver->getIdentifier()) . DIRECTORY_SEPARATOR;
     if (!file_exists($path)) {
         mkdir($path);
     }
     return $path . \tao_helpers_File::getSafeFileName('message.html', $path);
 }
开发者ID:nagyist,项目名称:tao-core,代码行数:17,代码来源:FileSink.php

示例3: migrateFrom09To091

 private static function migrateFrom09To091()
 {
     // Get all items...
     $itemService = \taoItems_models_classes_ItemsService::singleton();
     $itemClass = $itemService->getRootClass();
     foreach ($itemClass->getInstances(true) as $item) {
         if ($itemService->hasItemModel($item, array(TAO_ITEM_MODEL_QTI))) {
             $path = $itemService->getDefaultItemFolder($item);
             $qtiXml = $itemService->getItemContent($item);
             if (empty($qtiXml) === false) {
                 $qtiDom = new \DOMDocument('1.0', 'UTF-8');
                 $qtiDom->loadXML($qtiXml);
                 // Get all stylesheet hrefs.
                 $hrefs = Utils::getStylesheetHrefs($qtiDom);
                 // Make sure the hrefs are refering existing files.
                 for ($i = 0; $i < count($hrefs); $i++) {
                     $href = $hrefs[$i];
                     if (is_readable($path . $href) === false) {
                         \common_Logger::i("The stylesheet->href '{$path}.{$href}' does not reference an existing file. Trying to repair...");
                         // Let's try with another name...
                         $pathinfo = pathinfo($href);
                         $altFileName = \tao_helpers_File::getSafeFileName($pathinfo['basename']);
                         $dirSep = $pathinfo['dirname'] !== '.' ? $pathInfo['dirname'] . DIRECTORY_SEPARATOR : '';
                         $altPath = $path . $dirSep . $altFileName;
                         if (is_readable($altPath)) {
                             // Bingo! We rebind.
                             $hrefs[$i] = $dirSep . $altFileName;
                             \common_Logger::i("Repaired with new href '{$dirSep}.{$altFileName}}'.");
                         } else {
                             // It's definitely broken...
                             unset($hrefs[$i]);
                             \common_Logger::i("Could not be repaired! QTI stylesheet component removed from item.");
                         }
                     }
                 }
                 // Reput them in the item with cleanup enabled
                 // to solve the XMLSchema validation issue.
                 if (count($hrefs) > 0) {
                     $href = array_shift($hrefs);
                     Utils::appendStylesheet($qtiDom, $href, true);
                 }
                 // Append the rest of the stylesheets.
                 foreach ($hrefs as $href) {
                     Utils::appendStylesheet($qtiDom, $href);
                 }
                 $itemService->setItemContent($item, $qtiDom->saveXML());
             }
         }
     }
 }
开发者ID:oat-sa,项目名称:extension-tao-cssdevkit,代码行数:50,代码来源:Updater.php

示例4: __invoke

 /**
  * (non-PHPdoc)
  * @see \oat\oatbox\action\Action::__invoke()
  */
 public function __invoke($params)
 {
     \common_ext_ExtensionsManager::singleton()->getExtensionById('taoDeliveryRdf');
     if (count($params) != 2) {
         return new \common_report_Report(\common_report_Report::TYPE_ERROR, __('Usage: %s DELIVERY_CLASS_URI OUTPUT_DIRECTORY', __CLASS__));
     }
     $deliveryClassUri = array_shift($params);
     $deliveryClass = new \core_kernel_classes_Class($deliveryClassUri);
     $dir = array_shift($params);
     if (!file_exists($dir) && !mkdir($dir)) {
         return new \common_report_Report(\common_report_Report::TYPE_ERROR, __('Directory %s doesn\'t exist', $dir));
     }
     $dir = rtrim($dir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
     $report = new \common_report_Report(\common_report_Report::TYPE_SUCCESS, __('Exporting %s', $deliveryClass->getLabel()));
     foreach ($deliveryClass->getInstances(true) as $delivery) {
         $destFile = $dir . \tao_helpers_File::getSafeFileName($delivery->getLabel()) . '.zip';
         $tmpFile = Assembler::exportCompiledDelivery($delivery);
         \tao_helpers_File::move($tmpFile, $destFile);
         $report->add(new \common_report_Report(\common_report_Report::TYPE_SUCCESS, __('Exported %1$s to %2$s', $delivery->getLabel(), $destFile)));
     }
     return $report;
 }
开发者ID:oat-sa,项目名称:extension-tao-delivery-rdf,代码行数:26,代码来源:ExportAssemblyClass.php

示例5: retrieveAssets

 /**
  * 
  * @param core_kernel_classes_Resource $item
  * @param string $lang
  * @param string $destination
  * @return \oat\taoQtiItem\model\qti\Item
  */
 protected function retrieveAssets(core_kernel_classes_Resource $item, $lang, $destination)
 {
     $xml = taoItems_models_classes_ItemsService::singleton()->getItemContent($item);
     $qtiParser = new Parser($xml);
     $qtiItem = $qtiParser->load();
     $assetParser = new AssetParser($qtiItem);
     $assetParser->setGetSharedLibraries(false);
     $assetParser->setGetXinclude(false);
     $resolver = new ItemMediaResolver($item, $lang);
     foreach ($assetParser->extract() as $type => $assets) {
         foreach ($assets as $assetUrl) {
             foreach (self::$BLACKLIST as $blacklist) {
                 if (preg_match($blacklist, $assetUrl) === 1) {
                     continue 2;
                 }
             }
             $mediaAsset = $resolver->resolve($assetUrl);
             $mediaSource = $mediaAsset->getMediaSource();
             $srcPath = $mediaSource->download($mediaAsset->getMediaIdentifier());
             $filename = \tao_helpers_File::getSafeFileName(ltrim($mediaAsset->getMediaIdentifier(), '/'), $destination);
             $replacement = $mediaAsset->getMediaIdentifier();
             if (get_class($mediaSource) !== 'oat\\tao\\model\\media\\sourceStrategy\\HttpSource') {
                 $fileInfo = $mediaSource->getFileInfo($mediaAsset->getMediaIdentifier());
                 $filename = $fileInfo['filePath'];
                 if ($mediaAsset->getMediaIdentifier() !== $fileInfo['uri']) {
                     $replacement = $filename;
                 }
             }
             $destPath = ltrim($filename, '/');
             tao_helpers_File::copy($srcPath, $destination . $destPath, false);
             $xml = str_replace($assetUrl, $replacement, $xml);
         }
     }
     $qtiParser = new Parser($xml);
     $assetRetrievedQtiItem = $qtiParser->load();
     //loadxinclude
     $xincludeLoader = new XIncludeLoader($assetRetrievedQtiItem, $resolver);
     $xincludeLoader->load(true);
     return $assetRetrievedQtiItem;
 }
开发者ID:nagyist,项目名称:extension-tao-itemqti,代码行数:47,代码来源:QtiItemCompiler.php


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