當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。