本文整理汇总了PHP中FileManager::HasExtension方法的典型用法代码示例。如果您正苦于以下问题:PHP FileManager::HasExtension方法的具体用法?PHP FileManager::HasExtension怎么用?PHP FileManager::HasExtension使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileManager
的用法示例。
在下文中一共展示了FileManager::HasExtension方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: FieldTypes
public static function FieldTypes()
{
$files = scandir(TYPEF_SOURCE_DIR . '/classes/Plugin/Mailform/FieldTag');
$fieldTypes = array();
foreach ($files as $file) {
if (is_file(TYPEF_SOURCE_DIR . "/classes/Plugin/Mailform/FieldTag/{$file}") && FileManager::HasExtension($file, "php")) {
$name = pathinfo($file, PATHINFO_FILENAME);
$fieldTypes[] = array('name' => $name, 'label' => preg_replace('/([a-z])([A-Z])/', '$1 $2', $name));
}
}
return $fieldTypes;
}
示例2: mkdir
$base = TYPEF_DIR . '/files/public/userfiles/' . Typeframe::User()->get('userid');
if (!file_exists($base)) {
mkdir($base);
}
$folder = isset($_REQUEST['folder']) ? $_REQUEST['folder'] : '';
$currentFolder = "{$base}/{$folder}";
if ($_SERVER['REQUEST_METHOD'] == 'POST' && !empty($_POST['newfolder'])) {
if (!preg_match('/[^a-z0-9\\-_]/i', $_POST['newfolder'])) {
mkdir("{$currentFolder}/{$_POST['newfolder']}");
$folder = ($folder ? $folder . '/' : '') . $_POST['newfolder'];
$currentFolder = "{$currentFolder}/{$_POST['newfolder']}";
}
}
if ($dh = opendir("{$currentFolder}")) {
while (($file = readdir($dh)) !== false) {
if ($file != "." && $file != "..") {
if (is_dir("{$currentFolder}/{$file}")) {
$pm->addLoop('folders', array("name" => $file));
} else {
if (is_null($extensions) || FileManager::HasExtension("{$currentFolder}/{$file}", $extensions)) {
$pm->addLoop('files', array("name" => $file, "size" => number_format(filesize("{$currentFolder}/{$file}") / 1024, 2)));
}
}
}
}
}
closedir($dh);
$pm->setVariable('type', $type);
$pm->setVariable('folder', $folder);
$pm->sortLoop('folders', 'name');
$pm->sortLoop('files', 'name');