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


PHP ElggFile::setFilename方法代码示例

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


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

示例1: form_generate_thumbnail

function form_generate_thumbnail($file, $fieldname)
{
    // Generate thumbnail (if image)
    $prefix = "file/";
    $filestorename = strtolower(time() . $_FILES[$fieldname]['name']);
    if (substr_count($file->getMimeType(), 'image/')) {
        $thumbnail = get_resized_image_from_existing_file($file->getFilenameOnFilestore(), 60, 60, true);
        $thumbsmall = get_resized_image_from_existing_file($file->getFilenameOnFilestore(), 153, 153, true);
        $thumblarge = get_resized_image_from_existing_file($file->getFilenameOnFilestore(), 600, 600, false);
        if ($thumbnail) {
            $thumb = new ElggFile();
            $thumb->setMimeType($_FILES[$fieldname]['type']);
            $thumb->setFilename($prefix . "thumb" . $filestorename);
            $thumb->open("write");
            $thumb->write($thumbnail);
            $thumb->close();
            $file->thumbnail = $prefix . "thumb" . $filestorename;
            $thumb->setFilename($prefix . "smallthumb" . $filestorename);
            $thumb->open("write");
            $thumb->write($thumbsmall);
            $thumb->close();
            $file->smallthumb = $prefix . "smallthumb" . $filestorename;
            $thumb->setFilename($prefix . "largethumb" . $filestorename);
            $thumb->open("write");
            $thumb->write($thumblarge);
            $thumb->close();
            $file->largethumb = $prefix . "largethumb" . $filestorename;
        }
    }
}
开发者ID:portokallidis,项目名称:Metamorphosis-Meducator,代码行数:30,代码来源:model.php

示例2: CreateLTIGroup

function CreateLTIGroup($user, $name, $context_id, $consumer_key)
{
    $group_guid = 0;
    $group = new ElggGroup($group_guid);
    // Set the group properties that we can!
    $group->name = $name;
    $group->context_id = $context_id;
    // This is a unique identifier from the consumer for this context
    $group->consumer_key = $consumer_key;
    // Which consumer is creating this group
    $group->membership = ACCESS_PRIVATE;
    $group->access_id = ACCESS_PUBLIC;
    $group->briefdescription = elgg_echo('LTI:provision:group');
    $consumer_instance = new LTI_Tool_Consumer_Instance($group->consumer_key, elgg_get_config('dbprefix'));
    $context = new LTI_Context($consumer_instance, $group->context_id);
    $group->description = $context->title;
    $group->save();
    $group->join($user);
    // Add images
    $prefix = 'groups/' . $group->guid;
    $filename = GetImage($consumer_key, '.jpg');
    $thumbtiny = get_resized_image_from_existing_file($filename, 25, 25, true);
    $thumbsmall = get_resized_image_from_existing_file($filename, 40, 40, true);
    $thumbmedium = get_resized_image_from_existing_file($filename, 100, 100, true);
    $thumblarge = get_resized_image_from_existing_file($filename, 200, 200, false);
    if ($thumbtiny) {
        $thumb = new ElggFile();
        $thumb->owner_guid = $group->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();
        $thumb->setFilename($prefix . "medium.jpg");
        $thumb->open("write");
        $thumb->write($thumbmedium);
        $thumb->close();
        $thumb->setFilename($prefix . "large.jpg");
        $thumb->open("write");
        $thumb->write($thumblarge);
        $thumb->close();
        $group->icontime = time();
    }
    // return the URL
    return $group;
}
开发者ID:vsheokeen,项目名称:Elgg-Plugins,代码行数:50,代码来源:LTIGroup.php

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

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

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

示例7: setUp

 public function setUp()
 {
     $session = \ElggSession::getMock();
     _elgg_services()->setValue('session', $session);
     _elgg_services()->session->start();
     $this->handler = _elgg_services()->serveFileHandler;
     $file = new \ElggFile();
     $file->owner_guid = 1;
     $file->setFilename("foobar.txt");
     $this->file = $file;
 }
开发者ID:elgg,项目名称:elgg,代码行数:11,代码来源:ServeFileHandlerTest.php

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

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

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

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

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

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

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

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


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