本文整理汇总了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;
}
示例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;
}
示例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 == "..") {
//.........这里部分代码省略.........
示例4: isFlash
public function isFlash()
{
$file = $this->bannerFile->file_path;
return HFile::getExtension($file) == 'swf';
}
示例5: getExtension
public function getExtension()
{
return HFile::getExtension($this->file_path);
}