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