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


PHP ElggFile类代码示例

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


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


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