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


PHP ElggFile::read方法代码示例

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


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

示例1: testCanTellPosition

 /**
  * @group FileService
  */
 public function testCanTellPosition()
 {
     $size = $this->file->getSize();
     $this->assertNotEmpty($size);
     $this->assertNotEmpty($this->file->open('read'));
     $this->assertEquals(0, $this->file->seek(2));
     $this->assertEquals(2, $this->file->tell());
     $this->assertFalse($this->file->eof());
     $this->assertEquals(0, $this->file->seek($size));
     $this->assertFalse($this->file->eof());
     $this->file->read(1);
     $this->assertTrue($this->file->eof());
     $this->assertTrue($this->file->close());
 }
开发者ID:elgg,项目名称:elgg,代码行数:17,代码来源:ElggFileTest.php

示例2: forward

}
// If user doesn't exist, return default icon
if (!$user) {
    $url = "_graphics/icons/default/{$size}.png";
    $url = elgg_normalize_url($url);
    forward($url);
}
$user_guid = $user->getGUID();
// Try and get the icon
$filehandler = new ElggFile();
$filehandler->owner_guid = $user_guid;
$filehandler->setFilename("profile/{$user_guid}{$size}.jpg");
$success = false;
try {
    if ($filehandler->open("read")) {
        if ($contents = $filehandler->read($filehandler->getSize())) {
            $success = true;
        }
    }
} catch (InvalidParameterException $e) {
    elgg_log("Unable to get avatar for user with GUID {$user_guid}", 'ERROR');
}
if (!$success) {
    $url = "_graphics/icons/default/{$size}.png";
    $url = elgg_normalize_url($url);
    forward($url);
}
header("Content-type: image/jpeg", true);
header('Expires: ' . gmdate('D, d M Y H:i:s \\G\\M\\T', strtotime("+6 months")), true);
header("Pragma: public", true);
header("Cache-Control: public", true);
开发者ID:ibou77,项目名称:elgg,代码行数:31,代码来源:view.php

示例3: group_get_icon

/**
 * @param $guid
 * @param $size
 * @throws IOException
 * @throws InvalidParameterException
 */
function group_get_icon($guid, $size)
{
    /* @var ElggGroup $group */
    $group = get_entity($guid);
    if (!$group instanceof ElggGroup) {
        header("HTTP/1.1 404 Not Found");
        exit;
    }
    // If is the same ETag, content didn't changed.
    $etag = $group->icontime . $guid;
    if (isset($_SERVER['HTTP_IF_NONE_MATCH']) && trim($_SERVER['HTTP_IF_NONE_MATCH']) == "\"{$etag}\"") {
        header("HTTP/1.1 304 Not Modified");
        exit;
    }
    if (!in_array($size, array('large', 'medium', 'small', 'tiny', 'master', 'topbar'))) {
        $size = "medium";
    }
    $success = false;
    $filehandler = new ElggFile();
    $filehandler->owner_guid = $group->owner_guid;
    $filehandler->setFilename("groups/" . $group->guid . $size . ".jpg");
    $success = false;
    if ($filehandler->open("read")) {
        if ($contents = $filehandler->read($filehandler->getSize())) {
            $success = true;
        }
    }
    header("Content-type: image/jpeg");
    header('Expires: ' . gmdate('D, d M Y H:i:s \\G\\M\\T', strtotime("+10 days")), true);
    header("Pragma: public", true);
    header("Cache-Control: public", true);
    header("Content-Length: " . strlen($contents));
    header("ETag: \"{$etag}\"");
    echo $contents;
    exit;
}
开发者ID:manlui,项目名称:elgg_with_rest_api,代码行数:42,代码来源:group.php


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