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


PHP HFile::getExtension方法代码示例

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


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

示例1: getImageFiles

/**
 * Возвращает массив файлов изображений из папки
 */
function getImageFiles($dir = '.', $exclude)
{
    $files = array();
    $a = scandir($dir);
    foreach ($a as $k => $v) {
        if ($v == '.' || $v == '..') {
            continue;
        }
        if (is_dir(HFile::addSlashPath($dir) . $v)) {
            $files = array_merge($files, getImageFiles(HFile::addSlashPath($dir) . $v, $exclude));
        } else {
            if (isImage(HFile::getExtension($v))) {
                $files[] = str_replace($exclude, '', HFile::addSlashPath($dir) . $v);
            }
        }
    }
    return $files;
}
开发者ID:Cranky4,项目名称:npfs,代码行数:21,代码来源:clearPreview.php

示例2: getCopyFileName

 protected function getCopyFileName($filePath)
 {
     $path = HFile::getDir($filePath);
     $files = file_exists($path) ? HFile::findFiles($path) : array();
     $files = array_flip($files);
     $ext = HFile::getExtension($this->fileName);
     $file = HFile::getFileNameByPath($this->fileName, true);
     $i = 0;
     $copyFileName = '';
     do {
         $copyFileName = $file . '(' . ++$i . ').' . $ext;
     } while (array_key_exists($copyFileName, $files));
     return $copyFileName;
 }
开发者ID:kot-ezhva,项目名称:ygin,代码行数:14,代码来源:FileUploadAction.php

示例3: getWidgetOverrideData

 public function getWidgetOverrideData($path)
 {
     $result = array();
     $path = HFile::addSlashPath($path);
     $widgets = $this->getWidgets($path);
     if (!($dir = @opendir($path))) {
         return array();
     }
     $assets = array();
     $views = array();
     while (($file = readdir($dir)) !== false) {
         if ($file == "." || $file == "..") {
             continue;
         }
         if (is_dir($path . $file)) {
             if ($file == 'assets') {
                 $assets = $this->getFiles($path . $file);
             } elseif ($file == 'views') {
                 $views = $this->getFiles($path . $file);
             }
         }
     }
     //Если виджет один в папке то собираем его ресурсы по упрощенной схеме
     if (count($widgets) == 1) {
         $result[] = $widgets[0];
         $item = new OverrideDataItem();
         $item->name = 'assets';
         $item->path = $path . 'assets';
         $item->items = $assets;
         $widgets[0]->addItem($item);
         $item = new OverrideDataItem();
         $item->name = 'views';
         $item->path = $path . 'views';
         $item->items = $views;
         $widgets[0]->addItem($item);
     } else {
         //иначе пытаемся определить принадлежность ресурсов
         foreach ($widgets as $wKey => $widgetItem) {
             $wContent = file_get_contents($widgetItem->path);
             foreach ($views as $vKey => $viewItem) {
                 $viewName = basename($viewItem->path);
                 $viewName = mb_substr($viewName, 0, mb_strlen($viewName) - 4);
                 //проверяем принадлежность представления виджету
                 if (preg_match('~render\\((\'|")/?' . $viewName . '(\'|")~su', $wContent)) {
                     $widgetViewsItem = null;
                     if (!($widgetViewsItem = $widgetItem->getByName('views'))) {
                         $widgetViewsItem = new OverrideDataItem();
                         $widgetViewsItem->name = 'views';
                         $widgetViewsItem->path = $path . 'views';
                         $widgetItem->addItem($widgetViewsItem);
                     }
                     $widgetViewsItem->addItem($viewItem);
                 }
             }
         }
         foreach ($assets as $aKey => $assetsItem) {
             $assetsName = basename($assetsItem->path);
             $pattern = '';
             if (HFile::getExtension($assetsName, true) == 'css') {
                 $pattern = '~registerCssFile\\(("|\')' . $assetsName . '("|\')~su';
             } elseif (HFile::getExtension($assetsName, true) == 'js') {
                 $pattern = '~registerJsFile\\(("|\')' . $assetsName . '("|\')~su';
             } else {
                 $pattern = '~' . basename($assetsName) . '~su';
             }
             foreach ($widgets as $wKey => $widgetItem) {
                 $wContent = file_get_contents($widgetItem->path);
                 //Возможно ресурс публикуется из виджета
                 $addAssets = (bool) preg_match($pattern, $wContent);
                 if ($widgetItem->getByName('views') != null && !$addAssets) {
                     //проверяем принадлежность ресурса представлению
                     foreach ($widgetItem->getByName('views') as $vKey => $viewItem) {
                         $vContent = file_get_contents($viewItem->path);
                         if (preg_match($pattern, $vContent)) {
                             $addAssets = true;
                             break;
                         }
                     }
                 }
                 if ($addAssets) {
                     $widgetAssetsItem = null;
                     if (!($widgetAssetsItem = $widgetItem->getByName('assets'))) {
                         $widgetAssetsItem = new OverrideDataItem();
                         $widgetAssetsItem->name = 'assets';
                         $widgetAssetsItem->path = $path . 'assets';
                         $widgetItem->addItem($widgetAssetsItem);
                     }
                     $widgetAssetsItem->addItem(clone $assetsItem);
                     //clone так, как ассет может принадлежать разным виджетам
                 }
             }
         }
         //end foreach
         $result = $widgets;
     }
     //end else
     //Собираем виджеты по вложенным папкам
     rewinddir($dir);
     while (($file = readdir($dir)) !== false) {
         if ($file == "." || $file == "..") {
//.........这里部分代码省略.........
开发者ID:Cranky4,项目名称:npfs,代码行数:101,代码来源:DefaultController.php

示例4: isFlash

 public function isFlash()
 {
     $file = $this->bannerFile->file_path;
     return HFile::getExtension($file) == 'swf';
 }
开发者ID:Cranky4,项目名称:npfs,代码行数:5,代码来源:Banner.php

示例5: getExtension

 public function getExtension()
 {
     return HFile::getExtension($this->file_path);
 }
开发者ID:kot-ezhva,项目名称:ygin,代码行数:4,代码来源:File.php


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