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


PHP ElggFile::getFilename方法代码示例

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


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

示例1: file_tools_get_file_extension

/**
 * Get the extension of an ElggFile
 *
 * @param ElggFile $file the file to check
 *
 * @return string
 */
function file_tools_get_file_extension($file)
{
    $result = '';
    if ($file->getSubtype() == 'file') {
        if ($filename = $file->getFilename()) {
            $exploded_filename = explode('.', $filename);
            $result = end($exploded_filename);
        }
    }
    return strtolower($result);
}
开发者ID:lorea,项目名称:Hydra-dev,代码行数:18,代码来源:functions.php

示例2: exists

 /**
  * Tests if an \ElggFile file exists.
  *
  * @param \ElggFile $file File object
  *
  * @return bool
  */
 public function exists(\ElggFile $file)
 {
     if (!$file->getFilename()) {
         return false;
     }
     return file_exists($this->getFilenameOnFilestore($file));
 }
开发者ID:nirajkaushal,项目名称:Elgg,代码行数:14,代码来源:ElggDiskFilestore.php

示例3: elgg_file_viewer_convert_file

/**
 * Convert a video/audio file to a web compatible format
 * 
 * @param ElggFile $file   File entity
 * @param string   $format Format to convert to (extension)
 * @return ElggFile|false
 */
function elgg_file_viewer_convert_file($file, $format)
{
    if (!$file instanceof ElggFile || !$format) {
        return false;
    }
    $ffmpeg_path = elgg_get_plugin_setting('ffmpeg_path', 'elgg_file_viewer');
    if (!$ffmpeg_path) {
        return false;
    }
    $info = pathinfo($file->getFilenameOnFilestore());
    $filename = $info['filename'];
    $output = new ElggFile();
    $output->owner_guid = $file->owner_guid;
    $output->setFilename("projekktor/{$file->guid}/{$filename}.{$format}");
    $output->open('write');
    $output->close();
    try {
        $FFmpeg = new FFmpeg($ffmpeg_path);
        if (!$file->icontime) {
            $icon = new ElggFile();
            $icon->owner_guid = $file->owner_guid;
            $icon->setFilename("projekktor/{$file->guid}/{$filename}.jpg");
            $FFmpeg->input($file->getFilenameOnFilestore())->thumb(0, 1)->output($icon->getFilenameOnFilestore())->ready();
            if ($icon->exists()) {
                $file->icontime = time();
                $file->ffmpeg_thumb = $icon->getFilename();
                $prefix = 'file/';
                $filestorename = $file->icontime . $filename . '.jpg';
                $thumbnail = get_resized_image_from_existing_file($icon->getFilenameOnFilestore(), 60, 60, true);
                if ($thumbnail) {
                    $thumb = new ElggFile();
                    $thumb->setMimeType($_FILES['upload']['type']);
                    $thumb->setFilename($prefix . "thumb" . $filestorename);
                    $thumb->open("write");
                    $thumb->write($thumbnail);
                    $thumb->close();
                    $file->thumbnail = $prefix . "thumb" . $filestorename;
                    unset($thumbnail);
                }
                $thumbsmall = get_resized_image_from_existing_file($icon->getFilenameOnFilestore(), 153, 153, true);
                if ($thumbsmall) {
                    $thumb->setFilename($prefix . "smallthumb" . $filestorename);
                    $thumb->open("write");
                    $thumb->write($thumbsmall);
                    $thumb->close();
                    $file->smallthumb = $prefix . "smallthumb" . $filestorename;
                    unset($thumbsmall);
                }
                $thumblarge = get_resized_image_from_existing_file($icon->getFilenameOnFilestore(), 600, 600, false);
                if ($thumblarge) {
                    $thumb->setFilename($prefix . "largethumb" . $filestorename);
                    $thumb->open("write");
                    $thumb->write($thumblarge);
                    $thumb->close();
                    $file->largethumb = $prefix . "largethumb" . $filestorename;
                    unset($thumblarge);
                }
            }
        }
        $FFmpeg->input($file->getFilenameOnFilestore())->output($output->getFilenameOnFilestore())->ready();
        elgg_log("Converting file {$file->guid} to {$format}: {$FFmpeg->command}", 'NOTICE');
    } catch (Exception $ex) {
        elgg_log($ex->getMessage(), 'ERROR');
        return false;
    }
    return $output;
}
开发者ID:hypejunction,项目名称:elgg_file_viewer,代码行数:74,代码来源:start.php

示例4: testCanTransferFile

 /**
  * @group FileService
  */
 public function testCanTransferFile()
 {
     $dataroot = elgg_get_config('dataroot');
     $file = new \ElggFile();
     $file->owner_guid = 3;
     $file->setFilename("file-to-transfer.txt");
     $file->setFilename("file-to-transfer.txt");
     // Fail with non-existent file
     $this->assertFalse($file->transfer(4));
     $file->open('write');
     $file->write('Transfer');
     $file->close();
     $this->assertTrue($file->transfer(4));
     $this->assertEquals(4, $file->owner_guid);
     $this->assertEquals("file-to-transfer.txt", $file->getFilename());
     $this->assertEquals("{$dataroot}1/4/file-to-transfer.txt", $file->getFilenameOnFilestore());
     $this->assertTrue($file->exists());
     $this->assertFalse(file_exists("{$dataroot}1/3/file-to-transfer.txt"));
     $this->assertTrue($file->transfer(3, 'tmp/transferred-file.txt'));
     $this->assertEquals(3, $file->owner_guid);
     $this->assertEquals("tmp/transferred-file.txt", $file->getFilename());
     $this->assertEquals("{$dataroot}1/3/tmp/transferred-file.txt", $file->getFilenameOnFilestore());
     $this->assertTrue($file->exists());
     $this->assertFalse(file_exists("{$dataroot}1/4/file-to-transfer.txt"));
     // cleanup
     _elgg_rmdir("{$dataroot}1/3/");
     _elgg_rmdir("{$dataroot}1/4/");
 }
开发者ID:elgg,项目名称:elgg,代码行数:31,代码来源:ElggFileTest.php

示例5: hj_framework_handle_multifile_upload

function hj_framework_handle_multifile_upload($user_guid)
{
    if (!empty($_FILES)) {
        $access = elgg_get_ignore_access();
        elgg_set_ignore_access(true);
        $file = $_FILES['Filedata'];
        $filehandler = new hjFile();
        $filehandler->owner_guid = (int) $user_guid;
        $filehandler->container_guid = (int) $user_guid;
        $filehandler->access_id = ACCESS_DEFAULT;
        $filehandler->data_pattern = hj_framework_get_data_pattern('object', 'hjfile');
        $filehandler->title = $file['name'];
        $filehandler->description = '';
        $prefix = "hjfile/";
        $filestorename = elgg_strtolower($file['name']);
        $mime = hj_framework_get_mime_type($file['name']);
        $filehandler->setFilename($prefix . $filestorename);
        $filehandler->setMimeType($mime);
        $filehandler->originalfilename = $file['name'];
        $filehandler->simpletype = hj_framework_get_simple_type($mime);
        $filehandler->filesize = round($file['size'] / (1024 * 1024), 2) . "Mb";
        $filehandler->open("write");
        $filehandler->close();
        move_uploaded_file($file['tmp_name'], $filehandler->getFilenameOnFilestore());
        $file_guid = $filehandler->save();
        hj_framework_set_entity_priority($filehandler);
        elgg_trigger_plugin_hook('hj:framework:file:process', 'object', array('entity' => $filehandler));
        if ($file_guid) {
            $meta_value = $filehandler->getGUID();
        } else {
            $meta_value = $filehandler->getFilenameOnFilestore();
        }
        if ($file_guid && $filehandler->simpletype == "image") {
            $thumb_sizes = hj_framework_get_thumb_sizes();
            foreach ($thumb_sizes as $thumb_type => $thumb_size) {
                $thumbnail = get_resized_image_from_existing_file($filehandler->getFilenameOnFilestore(), $thumb_size['w'], $thumb_size['h'], $thumb_size['square'], 0, 0, 0, 0, true);
                if ($thumbnail) {
                    $thumb = new ElggFile();
                    $thumb->setMimeType($file['type']);
                    $thumb->owner_guid = $user_guid;
                    $thumb->setFilename("{$prefix}{$filehandler->getGUID()}{$thumb_type}.jpg");
                    $thumb->open("write");
                    $thumb->write($thumbnail);
                    $thumb->close();
                    $thumb_meta = "{$thumb_type}thumb";
                    $filehandler->{$thumb_meta} = $thumb->getFilename();
                    unset($thumbnail);
                }
            }
        }
        $response = array('status' => 'OK', 'value' => $meta_value);
    } else {
        $response = array('status' => 'FAIL');
    }
    echo json_encode($response);
    elgg_set_ignore_access($access);
    return;
}
开发者ID:amcfarlane1251,项目名称:ongarde,代码行数:58,代码来源:deprecated.php

示例6: getFilenameOnFilestore

 /**
  * Returns the filename as saved on disk for an ElggFile object
  *
  * @param ElggFile $file File object
  *
  * @return string The full path of where the file is stored
  */
 public function getFilenameOnFilestore(ElggFile $file)
 {
     $owner = $file->getOwnerEntity();
     if (!$owner) {
         $owner = elgg_get_logged_in_user_entity();
     }
     if (!$owner) {
         $msg = elgg_echo('InvalidParameterException:MissingOwner', array($file->getFilename(), $file->guid));
         throw new InvalidParameterException($msg);
     }
     return $this->dir_root . $this->makefileMatrix($owner->guid) . $file->getFilename();
 }
开发者ID:portokallidis,项目名称:Metamorphosis-Meducator,代码行数:19,代码来源:ElggDiskFilestore.php

示例7: getFilenameOnFilestore

 public function getFilenameOnFilestore(ElggFile $file)
 {
     $owner = $file->getOwnerEntity();
     if (!$owner) {
         $owner = get_loggedin_user();
     }
     if (!$owner || !$owner->username) {
         throw new InvalidParameterException(elgg_echo('InvalidParameterException:MissingOwner'));
     }
     return $this->dir_root . $this->make_file_matrix($owner->username) . $file->getFilename();
 }
开发者ID:eokyere,项目名称:elgg,代码行数:11,代码来源:filestore.php


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