本文整理汇总了PHP中FileUtils类的典型用法代码示例。如果您正苦于以下问题:PHP FileUtils类的具体用法?PHP FileUtils怎么用?PHP FileUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FileUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testRandomFromFolderWithFoldersNoMtime
function testRandomFromFolderWithFoldersNoMtime()
{
$count = 0;
$another_count = 0;
$css_count = 0;
$ext_count = 0;
$test_count = 0;
for ($i = 0; $i < 30; $i++) {
$result = FileUtils::randomFromFolder("/" . FRAMEWORK_CORE_PATH . "tests/io/test_dir/content_dir/", false, true);
$this->assertNotNull($result);
if ($result == "/" . FRAMEWORK_CORE_PATH . "tests/io/test_dir/content_dir/another_dir/") {
$another_count += 1;
}
if ($result == "/" . FRAMEWORK_CORE_PATH . "tests/io/test_dir/content_dir/css_test.css") {
$css_count += 1;
}
if ($result == "/" . FRAMEWORK_CORE_PATH . "tests/io/test_dir/content_dir/ext_test.plug.txt") {
$ext_count += 1;
}
if ($result == "/" . FRAMEWORK_CORE_PATH . "tests/io/test_dir/content_dir/test_file.txt") {
$test_count += 1;
}
$sum = $another_count + $css_count + $ext_count + $test_count;
$this->assertTrue($count == $sum - 1);
$count += 1;
}
}
示例2: after_create
public function after_create()
{
UserMailer::deliver_new_user($this->email, $this);
$path = FileUtils::join(NIMBLE_ROOT, 'get', $this->username);
FileUtils::mkdir_p($path);
chmod($path, 0755);
}
示例3: clearCacheDir
protected static function clearCacheDir($path)
{
if (is_dir($path)) {
return FileUtils::rrmdir($path);
}
return true;
}
示例4: loadDir
public static function loadDir($path)
{
$files = FileUtils::getFilesForDirectory($path);
foreach ($files as $file) {
self::loadFile($path . DIRECTORY_SEPARATOR . $file);
}
}
示例5: __construct
protected function __construct()
{
$this->array = ArrayUtils::instance();
$this->file = FileUtils::instance();
$this->object = ObjectUtils::instance();
$this->string = StringUtils::instance();
}
示例6: uploadWare
function uploadWare($file, $fields)
{
$rs = FileUtils::UpWare($file, true);
if ($rs != false) {
$fields['title'] = $rs;
}
$this->_dbmaterials->create($fields);
}
示例7: _deleteTempAvatarFiles
private function _deleteTempAvatarFiles($uid)
{
$files = $this->_getTempAvatarFiles($uid);
$path = UploadUtils::getTempAvatarPath();
foreach ($files as $fileName) {
FileUtils::safeDeleteFile($path . '/' . $fileName);
}
}
示例8: __destruct
public function __destruct()
{
try {
FileUtils::removeDirectory($this->path, true);
} catch (BaseException $e) {
// boo! deal with garbage yourself.
}
}
示例9: getItemsTable
public function getItemsTable($pageNumber, $num, $response, $key, $valueToSearch)
{
$mainTag = new Div();
$tdNum = 3;
$tdNumTotal = $tdNum * 2 - 1;
$indOnPage = 0;
$items = 0;
$td = 0;
$item = new Item();
$rowIndex = 1;
$tdHeight = Utils::isSquareViewMode() ? 300 : 30;
$highLightId = Utils::getFromGET(UrlParameters::HIGH_LIGHT_ELEMENT);
$isMetro = array_key_exists(UrlParameters::VIEW_MODE, $_GET) && Utils::getFromGET(UrlParameters::VIEW_MODE) == "metro" || !array_key_exists(UrlParameters::VIEW_MODE, $_GET);
$isCompact = array_key_exists(UrlParameters::VIEW_MODE, $_GET) && Utils::getFromGET(UrlParameters::VIEW_MODE) == "compact";
$isExtend = array_key_exists(UrlParameters::VIEW_MODE, $_GET) && Utils::getFromGET(UrlParameters::VIEW_MODE) == "extend";
$isList = array_key_exists(UrlParameters::VIEW_MODE, $_GET) && Utils::getFromGET(UrlParameters::VIEW_MODE) == "list";
$rowViewClass = $isCompact ? 'compact' : ($isMetro ? "metro" : ($isExtend ? "extend" : ($isList ? "list" : "list")));
if ($response != 0) {
$mainTag->addStyleClass("items_table");
$rowView = new Div();
$mainTag->addChild($rowView);
while ($row = mysql_fetch_array($response)) {
$items++;
$indOnPage++;
$td++;
if (ceil(fmod($indOnPage, $tdNum)) == 1) {
$rowIndex++;
$indOnPage = 1;
$td = 1;
} elseif (Utils::isEven($td)) {
$td++;
}
$rowView->addStyleClass($rowViewClass);
$cellView = new Div();
$rowView->addChild($cellView);
$keyItem = $row["key_item"];
$images = FileUtils::getFilesByPrefixByDescription(Constants::DEFAULT_ROOT_CATALOG_PATH . DIRECTORY_SEPARATOR . $keyItem . DIRECTORY_SEPARATOR, Constants::MEDIUM_IMAGE, 'jpg');
if (count($images) == 0) {
$capImage = FileUtils::getCapImage(Labels::CAP_IMAGE_FOR_CLOTHING);
$images = [$capImage];
}
$item = null;
if ($isMetro) {
$item = Item::getMetroItemView($row["name"], $images, $row["key_item"], $pageNumber, $num, $key, $valueToSearch, $row['god_type'], Utils::formatClotheTitle($row["name"]), $highLightId == $row["key_item"]);
} elseif ($isCompact) {
//$name, $images, $itemId, $pageNumber, $num, $key, $valueToSearch, $type, $trimName, $isHighLightElement
$item = Item::getCompactItemView($row["name"], $images, $row["key_item"], $pageNumber, $num, $key, $valueToSearch, $row['god_type'], Utils::formatClotheTitle($row["name"]), $highLightId == $row["key_item"]);
} elseif ($isExtend) {
$item = Item::getSquareItemView($row["name"], $images, $row["key_item"], $pageNumber, $num, $key, $valueToSearch, $row['god_type'], Utils::formatClotheTitle($row["name"]));
} elseif ($isList) {
$item = Item::getLineItemView($row["name"], $images, $row["key_item"], $pageNumber, $num, $key, $valueToSearch, $row['god_type'], Utils::trimFormatClotheTitle($row["name"]), $highLightId == $row["key_item"]);
}
$cellView->addChild($item);
$cellView->addStyleClass("catalog_good_item");
}
}
return $mainTag;
}
示例10: clearOldFiles
function clearOldFiles()
{
$files = FileUtils::getFiles("../tmpworksheets");
foreach ($files as $fName) {
if (filectime($fName) < time() - 1 * 60 * 60) {
unlink($fName);
}
}
}
示例11: setUp
public function setUp()
{
$dir = dirname(__FILE__);
$this->nimble = Nimble::getINstance();
Nimble::set_config('stylesheet_folder', FileUtils::join($dir, 'assets', 'stylesheets'));
Nimble::set_config('stylesheet_folder_url', '/stylesheet');
Nimble::set_config('javascript_folder', FileUtils::join($dir, 'assets', 'javascript'));
Nimble::set_config('javascript_folder_url', '/javascript');
}
示例12: about
public function about()
{
$this->set_default_side_bar();
require_once FileUtils::join(NIMBLE_ROOT, 'lib', 'markdown.php');
$template = FileUtils::join(NIMBLE_ROOT, 'app', 'view', 'help', 'about.markdown');
$this->about = file_get_contents($template);
$this->title = 'About Pearfarm';
Nimble::set_title($this->title);
}
示例13: saveBookletImage
private static function saveBookletImage($bookletCode, $imageName, $base64Image)
{
$bookletImagesRoot = DBPreferencesType::getPreferenceS(Constants::BOOKLET_IMAGE_PATH);
$bookletImageDirectory = FileUtils::buildPath($bookletImagesRoot, $bookletCode);
FileUtils::createDir($bookletImageDirectory);
$imageEditor = ImageEditor::newImageBase64($base64Image);
$bookletImagePath = FileUtils::buildPath($bookletImagesRoot, $bookletCode, $imageName);
$imageEditor->saveImage($bookletImagePath);
return FileUtils::buildPath($bookletCode, $imageName);
}
示例14: parse
public static function parse(DOMNode $node)
{
if ($node->nodeName == self::getNodeName()) {
if (($code = HTTPCode::getByCode(XMLUtils::getChildByName($node, "code")->nodeValue)) != null) {
return new Error(FileUtils::getAbsolutePath(XMLUtils::getChildByName($node, "file")->nodeValue, VIEWS_FOLDER), $code);
}
throw new Exception("Unknown HTTP Code '" . XMLUtils::getChildByName($node, "code")->nodeValue . "'");
}
throw new Exception("Unexpected node '" . $node->nodeName . "', expected '" . self::getNodeName() . "'");
}
示例15: testUniqueNames
public function testUniqueNames()
{
$uniqueName = FileUtils::makeUniqueName('Chasey Lain.jpeg');
$this->assertEquals(substr($uniqueName, strpos($uniqueName, '.')), '.jpeg');
$uniqueName = FileUtils::makeUniqueName('Елена Беркова.jpeg');
$this->assertEquals(substr($uniqueName, strpos($uniqueName, '.')), '.jpeg');
$uniqueName = FileUtils::makeUniqueLatinName('Елена Беркова.gif');
//animated gif ;)
$this->assertEquals(substr($uniqueName, strpos($uniqueName, '.')), '.gif');
}