• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP ElggFile类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: blog_tools_remove_blog_icon

/**
 * Remove the icon of a blog
 *
 * @param ElggBlog $blog The blog to remove the icon from
 *
 * @return bool
 */
function blog_tools_remove_blog_icon(ElggBlog $blog)
{
    $result = false;
    if (!empty($blog) && elgg_instanceof($blog, "object", "blog", "ElggBlog")) {
        if (!empty($blog->icontime)) {
            $icon_sizes = elgg_get_config("icon_sizes");
            if (!empty($icon_sizes)) {
                $fh = new ElggFile();
                $fh->owner_guid = $blog->getOwnerGUID();
                $prefix = "blogs/" . $blog->getGUID();
                foreach ($icon_sizes as $name => $info) {
                    $fh->setFilename($prefix . $name . ".jpg");
                    if ($fh->exists()) {
                        $fh->delete();
                    }
                }
            }
            unset($blog->icontime);
            $result = true;
        } else {
            $result = true;
        }
    }
    return $result;
}
开发者ID:lorea,项目名称:Hydra-dev,代码行数:32,代码来源:functions.php


示例2: 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


示例3: 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


示例4: delete

 public function delete()
 {
     $thumbnails = array($this->thumbnail, $this->smallthumb, $this->largethumb);
     foreach ($thumbnails as $thumbnail) {
         if ($thumbnail) {
             $delfile = new ElggFile();
             $delfile->owner_guid = $this->owner_guid;
             $delfile->setFilename($thumbnail);
             $delfile->delete();
         }
     }
     return parent::delete();
 }
开发者ID:ibou77,项目名称:elgg,代码行数:13,代码来源:FilePluginFile.php


示例5: 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


示例6: 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


示例7: group_icon_url_override

function group_icon_url_override($hook, $type, $returnvalue, $params)
{
    $group = $params['entity'];
    $size = $params['size'];
    $icontime = $group->icontime;
    if (null === $icontime) {
        $file = new ElggFile();
        $file->owner_guid = $group->owner_guid;
        $file->setFilename("groups/" . $group->guid . "large.jpg");
        $icontime = $file->exists() ? time() : 0;
        create_metadata($group->guid, 'icontime', $icontime, 'integer', $group->owner_guid, ACCESS_PUBLIC);
    }
    if ($icontime) {
        // return thumbnail
        return "groupicon/{$group->guid}/{$size}/{$group->name}.jpg";
    }
    return "mod/groups/graphics/default{$size}.gif";
}
开发者ID:centillien,项目名称:metatags,代码行数:18,代码来源:start.php


示例8: blog_tools_icon_hook

function blog_tools_icon_hook($hook, $entity_type, $returnvalue, $params)
{
    if (!empty($params) && is_array($params)) {
        $entity = $params["entity"];
        if (elgg_instanceof($entity, "object", "blog")) {
            $size = $params["size"];
            if ($icontime = $entity->icontime) {
                $icontime = "{$icontime}";
                $filehandler = new ElggFile();
                $filehandler->owner_guid = $entity->getOwnerGUID();
                $filehandler->setFilename("blogs/" . $entity->getGUID() . $size . ".jpg");
                if ($filehandler->exists()) {
                    $url = elgg_get_site_url() . "blogicon/{$entity->getGUID()}/{$size}/{$icontime}.jpg";
                    return $url;
                }
            }
        }
    }
}
开发者ID:amcfarlane1251,项目名称:ongarde,代码行数:19,代码来源:hooks.php


示例9: migrateJsonSteps

 public function migrateJsonSteps()
 {
     $fh = new \ElggFile();
     $fh->owner_guid = $this->getGUID();
     $fh->setFilename('steps.json');
     if (!$fh->exists()) {
         return false;
     }
     $steps = $fh->grabFile();
     $steps = @json_decode($steps, true);
     foreach ($steps as $step) {
         $new_step = new WizardStep();
         $new_step->container_guid = $this->getGUID();
         $new_step->description = $step;
         $new_step->save();
     }
     $fh->delete();
     return true;
 }
开发者ID:coldtrick,项目名称:wizard,代码行数:19,代码来源:Wizard.php


示例10: getSteps

 /**
  * Get the steps from disk
  *
  * @param bool $count get the count of the steps
  *
  * @return false|string[]|int
  */
 public function getSteps($count = false)
 {
     $count = (bool) $count;
     $fh = new ElggFile();
     $fh->owner_guid = $this->getGUID();
     $fh->setFilename('steps.json');
     if (!$fh->exists()) {
         return false;
     }
     $steps = $fh->grabFile();
     unset($fh);
     $steps = @json_decode($steps, true);
     if ($count) {
         return count($steps);
     }
     // reset indexing on steps
     $steps = array_values($steps);
     return $steps;
 }
开发者ID:lorea,项目名称:Hydra-dev,代码行数:26,代码来源:Wizard.php


示例11: removeThumbnail

 /**
  * Removes the thumbnail
  *
  * @return void
  */
 public function removeThumbnail()
 {
     if (empty($this->icontime)) {
         return;
     }
     $fh = new \ElggFile();
     $fh->owner_guid = $this->getGUID();
     $prefix = 'thumb';
     $icon_sizes = elgg_get_config('icon_sizes');
     if (empty($icon_sizes)) {
         return;
     }
     foreach ($icon_sizes as $size => $info) {
         $fh->setFilename($prefix . $size . '.jpg');
         if ($fh->exists()) {
             $fh->delete();
         }
     }
     unset($this->icontime);
 }
开发者ID:coldtrick,项目名称:static,代码行数:25,代码来源:StaticPage.php


示例12: videolist_2012022501

/**
 * Downloads the thumbnail and saves into data folder
 *
 * @param ElggObject $item
 * @return bool
 */
function videolist_2012022501($item)
{
    // do not upgrade videos that have already been upgraded
    if ($item->thumbnail === true) {
        return true;
    }
    $thumbnail = file_get_contents($item->thumbnail);
    if (!$thumbnail) {
        return false;
    }
    $prefix = "videolist/" . $item->guid;
    $filehandler = new ElggFile();
    $filehandler->owner_guid = $item->owner_guid;
    $filehandler->setFilename($prefix . ".jpg");
    $filehandler->open("write");
    $filehandler->write($thumbnail);
    $filehandler->close();
    $item->thumbnail = true;
    return true;
}
开发者ID:pleio,项目名称:subsite_manager,代码行数:26,代码来源:2012022501.php


示例13: setFolderGUID

 /**
  * Set the folder for the file
  *
  * @param \ElggFile $entity the file to edit
  *
  * @return void
  */
 protected static function setFolderGUID(\ElggFile $entity)
 {
     $folder_guid = get_input('folder_guid', false);
     if ($folder_guid === false) {
         // folder_input was not present in form/action
         // maybe someone else did something with a file
         return;
     }
     $folder_guid = (int) $folder_guid;
     if (!empty($folder_guid)) {
         $folder = get_entity($folder_guid);
         if (!elgg_instanceof($folder, 'object', FILE_TOOLS_SUBTYPE)) {
             unset($folder_guid);
         }
     }
     // remove old relationships
     remove_entity_relationships($entity->getGUID(), FILE_TOOLS_RELATIONSHIP, true);
     if (!empty($folder_guid)) {
         add_entity_relationship($folder_guid, FILE_TOOLS_RELATIONSHIP, $entity->getGUID());
     }
 }
开发者ID:coldtrick,项目名称:file_tools,代码行数:28,代码来源:ElggFile.php


示例14: pleiofile_generate_file_thumbs

function pleiofile_generate_file_thumbs(ElggObject $file)
{
    if ($file->simpletype != "image") {
        return null;
    }
    $file->icontime = time();
    $sizes = array(60 => "thumb", 153 => "tinythumb", 153 => "smallthumb", 600 => "largethumb");
    $filename = str_replace("file/", "", $file->getFilename());
    foreach ($sizes as $size => $description) {
        if ($size < 600) {
            $upscale = true;
        } else {
            $upscale = false;
        }
        $thumbnail = get_resized_image_from_existing_file($file->getFilenameOnFilestore(), $size, $size, $upscale);
        if ($thumbnail) {
            $path = "file/" . $description . "_" . $filename;
            $thumb = new ElggFile();
            $thumb->setMimeType($_FILES['upload']['type']);
            $thumb->setFilename($path);
            $thumb->open("write");
            $thumb->write($thumbnail);
            $thumb->close();
            if ($description == "thumb") {
                $file->thumbnail = $path;
            } else {
                $file->{$description} = $path;
            }
            unset($thumbnail);
        }
    }
}
开发者ID:pleio,项目名称:pleiofile,代码行数:32,代码来源:functions.php


示例15: 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


示例16: videolist_2012022501

/**
 * Downloads the thumbnail and saves into data folder
 *
 * @param ElggObject $item
 * @return bool
 */
function videolist_2012022501($item)
{
    require_once elgg_get_plugins_path() . 'upgrade-tools/lib/upgrade_tools.php';
    // get thumbnail image
    $thumbnail = file_get_contents($item->thumbnail);
    if (!$thumbnail) {
        return false;
    }
    $prefix = "videolist/" . $item->guid;
    $filehandler = new ElggFile();
    $filehandler->owner_guid = $item->owner_guid;
    $filehandler->setFilename($prefix . ".jpg");
    $filehandler->open("write");
    $filehandler->write($thumbnail);
    $filehandler->close();
    // update properties
    if ($item->url) {
        $item->video_url = $item->url;
        $item->deleteMetadata('url');
    }
    if ($item->desc) {
        $item->description = $item->desc;
        $item->deleteMetadata('desc');
        $item->save();
    }
    if ($item->embedurl) {
        $item->deleteMetadata('embedurl');
    }
    upgrade_change_subtype($item, 'videolist_item');
    // update river
    $options = array('object_guid' => $item->guid);
    $river_items = elgg_get_river($options);
    foreach ($river_items as $river_item) {
        if ($river_item->action_type == 'create') {
            upgrade_update_river($river_item->id, 'river/object/videolist_item/create', $item->guid, 0);
        }
    }
    return true;
}
开发者ID:epsylon,项目名称:Hydra-dev,代码行数:45,代码来源:2012022501.php


示例17: delete

 public function delete()
 {
     $icon_sizes = hj_framework_get_thumb_sizes($this->getSubtype());
     $prefix_old = "hjfile/{$this->container_guid}/{$this->guid}";
     $prefix_old_alt = "hjfile/{$this->guid}";
     $prefix = "icons/{$this->guid}";
     foreach ($icon_sizes as $size => $values) {
         $thumb = new ElggFile();
         $thumb->owner_guid = elgg_get_logged_in_user_guid();
         $thumb->setFilename("{$prefix}{$size}.jpg");
         $thumb->delete();
         $thumb = new ElggFile();
         $thumb->owner_guid = elgg_get_logged_in_user_guid();
         $thumb->setFilename("{$prefix_old}{$size}.jpg");
         $thumb->delete();
         $thumb = new ElggFile();
         $thumb->owner_guid = elgg_get_logged_in_user_guid();
         $thumb->setFilename("{$prefix_old_alt}{$size}.jpg");
         $thumb->delete();
     }
     return parent::delete();
 }
开发者ID:amcfarlane1251,项目名称:ongarde,代码行数:22,代码来源:hjFile.php


示例18: 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


示例19: migrateSteps

 /**
  * Listen to upgrade event
  *
  * @param string $event  the name of the event
  * @param string $type   the type of the event
  * @param mixed  $object supplied params
  *
  * @return void
  */
 public static function migrateSteps($event, $type, $object)
 {
     $path = 'admin/upgrades/migrate_wizard_steps';
     $upgrade = new \ElggUpgrade();
     // ignore acces while checking for existence
     $ia = elgg_set_ignore_access(true);
     // already registered?
     if ($upgrade->getUpgradeFromPath($path)) {
         // restore access
         elgg_set_ignore_access($ia);
         return;
     }
     // find if upgrade is needed
     $upgrade_needed = false;
     $batch = new \ElggBatch('elgg_get_entities', ['type' => 'object', 'subtype' => \Wizard::SUBTYPE, 'limit' => false]);
     foreach ($batch as $entity) {
         $fa = new \ElggFile();
         $fa->owner_guid = $entity->getGUID();
         $fa->setFilename('steps.json');
         if (!$fa->exists()) {
             continue;
         }
         $upgrade_needed = true;
         break;
     }
     if (!$upgrade_needed) {
         // restore access
         elgg_set_ignore_access($ia);
         return;
     }
     $upgrade->title = elgg_echo('admin:upgrades:migrate_wizard_steps');
     $upgrade->description = elgg_echo('admin:upgrades:migrate_wizard_steps:description');
     $upgrade->setPath($path);
     $upgrade->save();
     // restore access
     elgg_set_ignore_access($ia);
 }
开发者ID:coldtrick,项目名称:wizard,代码行数:46,代码来源:Upgrade.php


示例20: blog_tools_remove_blog_icon

/**
 * Remove the icon of a blog
 *
 * @param ElggBlog $blog The blog to remove the icon from
 *
 * @return bool
 */
function blog_tools_remove_blog_icon(ElggBlog $blog)
{
    if (!$blog instanceof ElggBlog) {
        return false;
    }
    if (empty($blog->icontime)) {
        // no icon
        return true;
    }
    $icon_sizes = elgg_get_icon_sizes('object', 'blog');
    if (!empty($icon_sizes)) {
        $fh = new ElggFile();
        $fh->owner_guid = $blog->getOwnerGUID();
        $prefix = "blogs/{$blog->getGUID()}";
        foreach ($icon_sizes as $name => $info) {
            $fh->setFilename("{$prefix}{$name}.jpg");
            if ($fh->exists()) {
                $fh->delete();
            }
        }
    }
    unset($blog->icontime);
    return true;
}
开发者ID:coldtrick,项目名称:blog_tools,代码行数:31,代码来源:functions.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP ElggGroup类代码示例发布时间:2022-05-23
下一篇:
PHP ElggEntity类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap