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


PHP ElggFile::getFilenameOnFilestore方法代码示例

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


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

示例1: getURL

 /**
  * Returns publically accessible URL
  * @return string|false
  */
 public function getURL()
 {
     if (!$this->file instanceof \ElggFile || !$this->file->exists()) {
         elgg_log("Unable to resolve resource URL for a file that does not exist on filestore");
         return false;
     }
     $relative_path = '';
     $root_prefix = _elgg_services()->config->get('dataroot');
     $path = $this->file->getFilenameOnFilestore();
     if (substr($path, 0, strlen($root_prefix)) == $root_prefix) {
         $relative_path = substr($path, strlen($root_prefix));
     }
     if (!$relative_path) {
         elgg_log("Unable to resolve relative path of the file on the filestore");
         return false;
     }
     $data = array('expires' => isset($this->expires) ? $this->expires : 0, 'last_updated' => filemtime($this->file->getFilenameOnFilestore()), 'disposition' => $this->disposition == self::DISPOSITION_INLINE ? 'i' : 'a', 'path' => $relative_path);
     if ($this->use_cookie) {
         $data['cookie'] = _elgg_services()->session->getId();
         if (empty($data['cookie'])) {
             return false;
         }
         $data['use_cookie'] = 1;
     } else {
         $data['use_cookie'] = 0;
     }
     ksort($data);
     $mac = elgg_build_hmac($data)->getToken();
     return elgg_normalize_url("mod/proxy/e{$data['expires']}/l{$data['last_updated']}/d{$data['disposition']}/c{$data['use_cookie']}/{$mac}/{$relative_path}");
 }
开发者ID:hypeJunction,项目名称:Elgg-proxy,代码行数:34,代码来源:File.php

示例2: handle

 /**
  * {@inheritdoc}
  */
 public function handle(ElggEntity $entity)
 {
     $value = get_input($this->getShortname());
     if (!$entity->guid) {
         return $entity;
     }
     $old_owner_guid = $entity->owner_guid;
     $new_owner_guid = $value === null ? $old_owner_guid : (int) $value;
     $owner_has_changed = false;
     $old_icontime = null;
     if (!$new_owner_guid || $new_owner_guid == $old_owner_guid) {
         return $entity;
     }
     $user = elgg_get_logged_in_user_entity();
     // verify new owner is member and old owner/admin is logged in
     if ($entity->isMember(get_user($new_owner_guid)) && ($old_owner_guid == $user->guid || $user->isAdmin())) {
         $entity->owner_guid = $new_owner_guid;
         if ($entity->container_guid == $old_owner_guid) {
             // Even though this action defaults container_guid to the logged in user guid,
             // the group may have initially been created with a custom script that assigned
             // a different container entity. We want to make sure we preserve the original
             // container if it the group is not contained by the original owner.
             $entity->container_guid = $new_owner_guid;
         }
         $metadata = elgg_get_metadata(['guid' => $entity->guid, 'limit' => false]);
         if ($metadata) {
             foreach ($metadata as $md) {
                 if ($md->owner_guid == $old_owner_guid) {
                     $md->owner_guid = $new_owner_guid;
                     $md->save();
                 }
             }
         }
         // @todo Remove this when #4683 fixed
         $owner_has_changed = true;
         $old_icontime = $entity->icontime;
     }
     $must_move_icons = $owner_has_changed && $old_icontime;
     if ($must_move_icons) {
         $filehandler = new ElggFile();
         $filehandler->setFilename('groups');
         $filehandler->owner_guid = $old_owner_guid;
         $old_path = $filehandler->getFilenameOnFilestore();
         $icon_sizes = hypeApps()->iconFactory->getSizes($entity);
         $sizes = array_keys($icon_sizes);
         array_unshift($sizes, '');
         // move existing to new owner
         $filehandler->owner_guid = $entity->owner_guid;
         $new_path = $filehandler->getFilenameOnFilestore();
         foreach ($sizes as $size) {
             rename("{$old_path}/{$entity->guid}{$size}.jpg", "{$new_path}/{$entity->guid}{$size}.jpg");
         }
     }
     return $entity;
 }
开发者ID:hypeJunction,项目名称:Elgg-prototyper_group,代码行数:58,代码来源:OwnerField.php

示例3: generateMultiSizesForFile

function generateMultiSizesForFile($type, $iconName)
{
    $filehandler = new ElggFile();
    // 1. must run this code as admin
    // 2. and put some original icon files in the file dir of the admin
    // example dir: data/2014/01/18/33/myicon/user, and
    // data/2014/01/18/33/myicon/group
    // 3. the files must have the right permission set:
    //		user:group should be like www-data:www-data on linux
    $filehandler->owner_guid = elgg_get_logged_in_user_guid();
    $filehandler->setFilename("myicon/" . $type . "/" . $iconName . ".png");
    $fileName = $filehandler->getFilenameOnFilestore();
    //fordebug register_error($fileName);
    $prefix = "myicon/" . $type . "/" . $iconName;
    $icon_sizes = elgg_get_config('icon_sizes');
    $sizes = array('large', 'medium', 'small', 'tiny', 'master', 'topbar');
    $thumbs = array();
    foreach ($sizes as $size) {
        //fordebug register_error("{$size}");
        $thumbs[$size] = get_resized_image_from_existing_file($fileName, $icon_sizes[$size]['w'], $icon_sizes[$size]['h'], $icon_sizes[$size]['square']);
    }
    if ($thumbs['tiny']) {
        // just checking if resize successful
        $thumb = new ElggFile();
        $thumb->owner_guid = elgg_get_logged_in_user_guid();
        $thumb->setMimeType('image/jpeg');
        foreach ($sizes as $size) {
            $thumb->setFilename("{$prefix}{$size}.jpg");
            //fordebug register_error("{$prefix}{$size}.jpg");
            $thumb->open("write");
            $thumb->write($thumbs[$size]);
            $thumb->close();
        }
    }
}
开发者ID:pingwangcs,项目名称:51zhaohu,代码行数:35,代码来源:start.php

示例4: getURL

 /**
  * Returns publicly accessible URL
  * @return string|false
  */
 public function getURL()
 {
     if (!$this->file instanceof \ElggFile || !$this->file->exists()) {
         elgg_log("Unable to resolve resource URL for a file that does not exist on filestore");
         return false;
     }
     $relative_path = '';
     $root_prefix = _elgg_services()->config->getDataPath();
     $path = $this->file->getFilenameOnFilestore();
     if (substr($path, 0, strlen($root_prefix)) == $root_prefix) {
         $relative_path = substr($path, strlen($root_prefix));
     }
     if (!$relative_path) {
         elgg_log("Unable to resolve relative path of the file on the filestore");
         return false;
     }
     $data = array('expires' => isset($this->expires) ? $this->expires : 0, 'last_updated' => filemtime($this->file->getFilenameOnFilestore()), 'disposition' => $this->disposition == self::INLINE ? 'i' : 'a', 'path' => $relative_path);
     if ($this->use_cookie) {
         $data['cookie'] = _elgg_services()->session->getId();
         if (empty($data['cookie'])) {
             return false;
         }
         $data['use_cookie'] = 1;
     } else {
         $data['use_cookie'] = 0;
     }
     ksort($data);
     $mac = _elgg_services()->crypto->getHmac($data)->getToken();
     $url_segments = array('serve-file', "e{$data['expires']}", "l{$data['last_updated']}", "d{$data['disposition']}", "c{$data['use_cookie']}", $mac, $relative_path);
     return elgg_normalize_url(implode('/', $url_segments));
 }
开发者ID:elgg,项目名称:elgg,代码行数:35,代码来源:File.php

示例5: zhsocial_apply_icon

function zhsocial_apply_icon($zh_user, $icon_url)
{
    // 	if($zh_user->icontime)
    // 		return;
    $icon_sizes = elgg_get_config('icon_sizes');
    $prefix = "profile/{$zh_user->guid}";
    $filehandler = new ElggFile();
    $filehandler->owner_guid = $zh_user->guid;
    $filehandler->setFilename($prefix . ".jpg");
    $filehandler->open("write");
    $filehandler->write(file_get_contents($icon_url));
    $filehandler->close();
    $filename = $filehandler->getFilenameOnFilestore();
    $sizes = array('topbar', 'tiny', 'small', 'medium', 'large', 'master');
    $thumbs = array();
    foreach ($sizes as $size) {
        $thumbs[$size] = get_resized_image_from_existing_file($filename, $icon_sizes[$size]['w'], $icon_sizes[$size]['h'], $icon_sizes[$size]['square']);
    }
    if ($thumbs['tiny']) {
        // just checking if resize successful
        $thumb = new ElggFile();
        $thumb->owner_guid = $zh_user->guid;
        $thumb->setMimeType('image/jpeg');
        foreach ($sizes as $size) {
            $thumb->setFilename("{$prefix}{$size}.jpg");
            $thumb->open("write");
            $thumb->write($thumbs[$size]);
            $thumb->close();
        }
        $zh_user->icontime = time();
    }
}
开发者ID:pingwangcs,项目名称:51zhaohu,代码行数:32,代码来源:start.php

示例6: del_photo

 /**
  * Delete item photo from diskspace
  * 
  * @return boolean
  */
 public function del_photo()
 {
     $photo_sizes = elgg_get_config('amapnews_photo_sizes');
     foreach ($photo_sizes as $name => $photo_info) {
         $file = new ElggFile();
         $file->owner_guid = $this->owner_guid;
         $file->setFilename("amapnews/{$this->getGUID()}{$name}.jpg");
         $filepath = $file->getFilenameOnFilestore();
         if (!$file->delete()) {
             // do nothing
         }
     }
     return true;
 }
开发者ID:nlybe,项目名称:elgg-news,代码行数:19,代码来源:Amapnews.php

示例7: testResponseHeadersMatchFileAttributesForAttachmentUrls

 /**
  * @group FileService
  */
 public function testResponseHeadersMatchFileAttributesForAttachmentUrls()
 {
     $file = new \Elgg\FileService\File();
     $file->setFile($this->file);
     $file->setDisposition('attachment');
     $file->bindSession(true);
     $request = $this->createRequest($file);
     $response = $this->handler->getResponse($request);
     $this->assertEquals('text/plain', $response->headers->get('Content-Type'));
     $filesize = filesize($this->file->getFilenameOnFilestore());
     $this->assertEquals($filesize, $response->headers->get('Content-Length'));
     $this->assertContains('attachment', $response->headers->get('Content-Disposition'));
     $this->assertEquals('"' . $this->file->getModifiedTime() . '"', $response->headers->get('Etag'));
 }
开发者ID:elgg,项目名称:elgg,代码行数:17,代码来源:ServeFileHandlerTest.php

示例8: testElggFileDelete

 function testElggFileDelete()
 {
     global $CONFIG;
     $user = $this->createTestUser();
     $filestore = $this->filestore;
     $dir = new \Elgg\EntityDirLocator($user->guid);
     $file = new \ElggFile();
     $file->owner_guid = $user->guid;
     $file->setFilename('testing/ElggFileDelete');
     $this->assertTrue($file->open('write'));
     $this->assertTrue($file->write('Test'));
     $this->assertTrue($file->close());
     $file->save();
     $filename = $file->getFilenameOnFilestore($file);
     $filepath = $CONFIG->dataroot . $dir . "testing/ElggFileDelete";
     $this->assertIdentical($filename, $filepath);
     $this->assertTrue(file_exists($filepath));
     $this->assertTrue($file->delete());
     $this->assertFalse(file_exists($filepath));
     $user->delete();
 }
开发者ID:sephiroth88,项目名称:Elgg,代码行数:21,代码来源:ElggCoreFilestoreTest.php

示例9: viewCK

function viewCK($page, $identifier, $obj)
{
    include_once dirname(dirname(dirname(__FILE__))) . "/engine/start.php";
    $file_guid = (int) get_input('file_guid');
    $file = get_entity($file_guid);
    $readfile = new ElggFile();
    $readfile->owner_guid = $file->owner_guid;
    $readfile->setFilename($file->originalfilename);
    $filename = $readfile->getFilenameOnFilestore();
    $handle = fopen($filename, "r");
    $contents = fread($handle, filesize($filename));
    fclose($handle);
    $mime = $file->getMimeType();
    $expires = 14 * 60 * 60 * 24;
    header("Content-Type: {$mime}");
    header("Content-Length: " . strlen($contents));
    header("Cache-Control: public", true);
    header("Pragma: public", true);
    header('Expires: ' . gmdate('D, d M Y H:i:s', time() + $expires) . ' GMT', true);
    echo $contents;
    return true;
}
开发者ID:socialweb,项目名称:PiGo,代码行数:22,代码来源:start.php

示例10: testFilenameOnFilestore

 public function testFilenameOnFilestore()
 {
     global $CONFIG;
     // create a user to own the file
     $user = $this->createTestUser();
     $created = date('Y/m/d', $user->time_created);
     // setup a test file
     $file = new ElggFile();
     $file->owner_guid = $user->guid;
     $file->setFilename('testing/filestore.txt');
     $file->open('write');
     $file->write('Testing!');
     $this->assertTrue($file->close());
     // ensure filename and path is expected
     $filename = $file->getFilenameOnFilestore($file);
     $filepath = "{$CONFIG->dataroot}{$created}/{$user->guid}/testing/filestore.txt";
     $this->assertIdentical($filename, $filepath);
     $this->assertTrue(file_exists($filepath));
     // ensure file removed on user delete
     $user->delete();
     $this->assertFalse(file_exists($filepath));
 }
开发者ID:ashwiniravi,项目名称:Elgg-Social-Network-Single-Sign-on-and-Web-Statistics,代码行数:22,代码来源:filestore.php

示例11: forward

 *
 */
$guid = get_input('guid');
$owner = get_entity($guid);
if (!$owner || !$owner instanceof ElggUser || !$owner->canEdit()) {
    register_error(elgg_echo('avatar:crop:fail'));
    forward(REFERER);
}
$x1 = (int) get_input('x1', 0);
$y1 = (int) get_input('y1', 0);
$x2 = (int) get_input('x2', 0);
$y2 = (int) get_input('y2', 0);
$filehandler = new ElggFile();
$filehandler->owner_guid = $owner->getGUID();
$filehandler->setFilename("profile/" . $owner->guid . "master" . ".jpg");
$filename = $filehandler->getFilenameOnFilestore();
$icon_sizes = elgg_get_config('icon_sizes');
unset($icon_sizes['master']);
// get the images and save their file handlers into an array
// so we can do clean up if one fails.
$files = array();
foreach ($icon_sizes as $name => $size_info) {
    $resized = get_resized_image_from_existing_file($filename, $size_info['w'], $size_info['h'], $size_info['square'], $x1, $y1, $x2, $y2, $size_info['upscale']);
    if ($resized) {
        //@todo Make these actual entities.  See exts #348.
        $file = new ElggFile();
        $file->owner_guid = $guid;
        $file->setFilename("profile/{$guid}{$name}.jpg");
        $file->open('write');
        $file->write($resized);
        $file->close();
开发者ID:portokallidis,项目名称:Metamorphosis-Meducator,代码行数:31,代码来源:crop.php

示例12: ElggFile

}
$dgroup->save();
if (!$dgroup->isMember($user)) {
    $dgroup->join($user);
}
// Creator always a member
// Now see if we have a file icon
if (isset($_FILES['icon']) && substr_count($_FILES['icon']['type'], 'image/')) {
    $prefix = "dgroups/" . $dgroup->guid;
    $filehandler = new ElggFile();
    $filehandler->owner_guid = $dgroup->owner_guid;
    $filehandler->setFilename($prefix . ".jpg");
    $filehandler->open("write");
    $filehandler->write(get_uploaded_file('icon'));
    $filehandler->close();
    $thumbtiny = get_resized_image_from_existing_file($filehandler->getFilenameOnFilestore(), 25, 25, true);
    $thumbsmall = get_resized_image_from_existing_file($filehandler->getFilenameOnFilestore(), 40, 40, true);
    $thumbmedium = get_resized_image_from_existing_file($filehandler->getFilenameOnFilestore(), 100, 100, true);
    $thumblarge = get_resized_image_from_existing_file($filehandler->getFilenameOnFilestore(), 200, 200, false);
    if ($thumbtiny) {
        $thumb = new ElggFile();
        $thumb->owner_guid = $dgroup->owner_guid;
        $thumb->setMimeType('image/jpeg');
        $thumb->setFilename($prefix . "tiny.jpg");
        $thumb->open("write");
        $thumb->write($thumbtiny);
        $thumb->close();
        $thumb->setFilename($prefix . "small.jpg");
        $thumb->open("write");
        $thumb->write($thumbsmall);
        $thumb->close();
开发者ID:eokyere,项目名称:elgg,代码行数:31,代码来源:edit.php

示例13: testDetectMimeType

 function testDetectMimeType()
 {
     $user = $this->createTestUser();
     $file = new \ElggFile();
     $file->owner_guid = $user->guid;
     $file->setFilename('testing/filestore.txt');
     $file->open('write');
     $file->write('Testing!');
     $file->close();
     $mime = $file->detectMimeType(null, 'text/plain');
     // mime should not be null if default is set
     $this->assertTrue(isset($mime));
     // mime of a file object should match mime of a file path that represents this file on filestore
     $resource_mime = $file->detectMimeType($file->getFilenameOnFilestore(), 'text/plain');
     $this->assertIdentical($mime, $resource_mime);
     // calling detectMimeType statically raises strict policy warning
     // @todo: remove this once a new static method has been implemented
     error_reporting(E_ALL & ~E_STRICT & ~E_DEPRECATED);
     // method output should not differ between a static and a concrete call if the file path is set
     $resource_mime_static = \ElggFile::detectMimeType($file->getFilenameOnFilestore(), 'text/plain');
     $this->assertIdentical($resource_mime, $resource_mime_static);
     error_reporting(E_ALL);
     $user->delete();
 }
开发者ID:epsylon,项目名称:Hydra-dev,代码行数:24,代码来源:ElggCoreFilestoreTest.php

示例14: foreach

<?php

/**
 * Avatar remove action
 */
$guid = get_input('guid');
$user = get_entity($guid);
if ($user) {
    // Delete all icons from diskspace
    $icon_sizes = elgg_get_config('icon_sizes');
    foreach ($icon_sizes as $name => $size_info) {
        $file = new ElggFile();
        $file->owner_guid = $guid;
        $file->setFilename("profile/{$guid}{$name}.jpg");
        $filepath = $file->getFilenameOnFilestore();
        if (!$file->delete()) {
            elgg_log("Avatar file remove failed. Remove {$filepath} manually, please.", 'WARNING');
        }
    }
    // Remove crop coords
    unset($user->x1);
    unset($user->x2);
    unset($user->y1);
    unset($user->y2);
    // Remove icon
    unset($user->icontime);
    system_message(elgg_echo('avatar:remove:success'));
} else {
    register_error(elgg_echo('avatar:remove:fail'));
}
forward(REFERER);
开发者ID:duanhv,项目名称:mdg-social,代码行数:31,代码来源:remove.php

示例15: tp_get_img_dir

/**
 * Get image directory path
 *
 * Each album gets a subdirectory based on its container id
 *
 * @return string	path to image directory
 */
function tp_get_img_dir($album_guid)
{
    $file = new ElggFile();
    $file->setFilename("image/{$album_guid}");
    return $file->getFilenameOnFilestore($file);
}
开发者ID:iionly,项目名称:tidypics,代码行数:13,代码来源:tidypics.php


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