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


PHP ElggFile::getSize方法代码示例

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


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

示例4: ckeditor_addons_page_handler

/**
 * Handles browser pages
 *
 * @param array $segments An array of URL segments
 * @return boolean
 */
function ckeditor_addons_page_handler($segments)
{
    if (!elgg_get_plugin_setting('allow_uploads', 'ckeditor_addons')) {
        return false;
    }
    switch ($segments[0]) {
        case 'browse':
            echo elgg_view_resource('ckeditor/browse');
            return true;
        case 'image':
            $user_guid = $segments[1];
            $hash = $segments[2];
            $ext = $segments[3];
            if (!$user_guid || !$hash) {
                header("HTTP/1.1 400 Bad Request");
                exit;
            }
            if (!in_array($ext, array('jpg', 'gif'))) {
                $ext = 'jpg';
            }
            if (isset($_SERVER['HTTP_IF_NONE_MATCH']) && trim($_SERVER['HTTP_IF_NONE_MATCH']) == "\"{$hash}\"") {
                header("HTTP/1.1 304 Not Modified");
                exit;
            }
            $file = new ElggFile();
            $file->owner_guid = $user_guid;
            $file->setFilename("ckeditor/{$hash}.{$ext}");
            if (!$file->exists()) {
                header("HTTP/1.1 404 Not Found");
                exit;
            }
            $file->open('read');
            $contents = $file->grabFile();
            $file->close();
            if (md5($contents) != $hash) {
                header("HTTP/1.1 403 Forbidden");
                exit;
            }
            header("Content-type: image/jpeg");
            header("Etag: {$hash}");
            header('Expires: ' . date('r', time() + 864000));
            header("Pragma: public");
            header("Cache-Control: public");
            header("Content-Length: " . $file->getSize());
            ob_get_clean();
            echo $contents;
            exit;
        case 'assets':
            array_unshift($segments, 'ckeditor');
            $view = implode('/', $segments);
            forward(elgg_get_simplecache_url($view));
            break;
    }
    return false;
}
开发者ID:hypejunction,项目名称:ckeditor_addons,代码行数:61,代码来源:start.php


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