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


PHP ElggFile::delete方法代码示例

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


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

示例1: form_delete_file

function form_delete_file($file_id)
{
    $file = get_entity($file_id);
    if ($file->canEdit()) {
        $thumbnail = $file->thumbnail;
        $smallthumb = $file->smallthumb;
        $largethumb = $file->largethumb;
        if ($thumbnail) {
            $delfile = new ElggFile();
            $delfile->owner_guid = $file->owner_guid;
            $delfile->setFilename($thumbnail);
            $delfile->delete();
        }
        if ($smallthumb) {
            $delfile = new ElggFile();
            $delfile->owner_guid = $file->owner_guid;
            $delfile->setFilename($smallthumb);
            $delfile->delete();
        }
        if ($largethumb) {
            $delfile = new ElggFile();
            $delfile->owner_guid = $file->owner_guid;
            $delfile->setFilename($largethumb);
            $delfile->delete();
        }
        return $file->delete();
    }
}
开发者ID:portokallidis,项目名称:Metamorphosis-Meducator,代码行数:28,代码来源:model.php

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

示例3: delete

 /**
  * Delete image
  *
  * @return bool
  */
 public function delete()
 {
     $thumb_image = get_entity($this->thumb_file_guid);
     if ($thumb_image) {
         $thumb_image->delete();
     }
     return parent::delete();
 }
开发者ID:epsylon,项目名称:Hydra-dev,代码行数:13,代码来源:GalleryFieldImage.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: resetAllCache

 /**
  * Resets all cache on the static pages
  *
  * @param string $event  'cache:flush'
  * @param string $type   'system'
  * @param mixed  $entity the entity about to be removed
  *
  * @return void
  */
 public static function resetAllCache($event, $type, $entity)
 {
     // fetch all top pages
     $options = ['type' => 'object', 'subtype' => \StaticPage::SUBTYPE, 'limit' => false, 'relationship' => 'subpage_of'];
     // ignore access
     $ia = elgg_set_ignore_access(true);
     $batch = new \ElggBatch('elgg_get_entities_from_relationship', $options);
     foreach ($batch as $entity) {
         // reset cache for the pages
         $file = new \ElggFile();
         $file->owner_guid = $entity->guid;
         $file->setFilename('static_menu_item_cache');
         if ($file->exists()) {
             $file->delete();
         }
     }
     elgg_set_ignore_access($ia);
 }
开发者ID:coldtrick,项目名称:static,代码行数:27,代码来源:Cache.php

示例7: delete

 /**
  * Override ElggFile::delete()
  *
  * After deleting the file delete also the directory.
  *
  * @return bool
  */
 public function delete()
 {
     $fs = $this->getFilestore();
     $dir = $this->getFileDirectory();
     // Delete the file on disc
     if ($fs->delete($this)) {
         // Delete the ElggFile entity
         if (parent::delete()) {
             // Delete the directory
             if (is_dir($dir)) {
                 if (rmdir($dir)) {
                     return true;
                 } else {
                     elgg_add_admin_notice('video_dir_delete_failed', elgg_echo('video:dir_delete_failed', $dir));
                 }
             }
         }
     }
     return false;
 }
开发者ID:juho-jaakkola,项目名称:elgg-videos,代码行数:27,代码来源:Video.php

示例8: saveThumbnail

 protected function saveThumbnail($image, $name)
 {
     try {
         $thumbnail = get_resized_image_from_existing_file($image->getFilenameOnFilestore(), 60, 60, true);
     } catch (Exception $e) {
         return FALSE;
     }
     $thumb = new ElggFile();
     $thumb->setMimeType('image/jpeg');
     $thumb->access_id = $this->access_id;
     $thumb->setFilename($name);
     $thumb->open("write");
     $thumb->write($thumbnail);
     $thumb->save();
     $image->thumbnail_guid = $thumb->getGUID();
     if (!$thumb->getGUID()) {
         $thumb->delete();
         return FALSE;
     }
     return TRUE;
 }
开发者ID:nohup,项目名称:community_plugins,代码行数:21,代码来源:PluginProject.php

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

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

示例11: foreach

<?php

$group_guid = get_input('group_guid');
if (!empty($group_guid) && ($group = get_entity($group_guid))) {
    if (elgg_instanceof($group, "group") && $group->canEdit()) {
        if ($layouts = $group->getEntitiesFromRelationship(GROUP_CUSTOM_LAYOUT_RELATION, false, false)) {
            foreach ($layouts as $layout) {
                if (!empty($layout->background)) {
                    $bgf = new ElggFile();
                    $bgf->owner_guid = $group->getGUID();
                    $bgf->setFilename(GROUP_CUSTOM_LAYOUT_BACKGROUND);
                    $bgf->delete();
                }
                if ($layout->delete()) {
                    system_message(elgg_echo('group_custom_layout:action:reset:success'));
                } else {
                    register_error(elgg_echo('group_custom_layout:action:reset:error:remove'));
                }
            }
        } else {
            register_error(elgg_echo('group_custom_layout:action:reset:error:no_custom'));
        }
    } else {
        register_error(elgg_echo('group_custom_layout:action:reset:error:no_group'));
    }
} else {
    register_error(elgg_echo('group_custom_layout:action:reset:error:input'));
}
forward(REFERER);
开发者ID:beck24,项目名称:group_custom_layout,代码行数:29,代码来源:reset.php

示例12: forward

$videolist_item = get_entity($guid);
if (!$videolist_item->guid) {
    register_error(elgg_echo("videolist:deletefailed"));
    forward('videolist/all');
}
if (!$videolist_item->canEdit()) {
    register_error(elgg_echo("videolist:deletefailed"));
    forward($videolist_item->getURL());
}
$container = $videolist_item->getContainerEntity();
$owner_guid = $videolist_item->getOwnerGUID();
$url = $videolist_item->getURL();
if (!$videolist_item->delete()) {
    register_error(elgg_echo("videolist:deletefailed"));
} else {
    // Remove the video thumbnail
    $file = new ElggFile();
    $file->owner_guid = $owner_guid;
    $file->setFilename("videolist/{$guid}.jpg");
    $file->delete();
    system_message(elgg_echo("videolist:deleted"));
}
// we can't come back to video url because it's deleted
if ($url != $_SERVER['HTTP_REFERER']) {
    forward(REFERER);
}
if (elgg_instanceof($container, 'group')) {
    forward("videolist/group/{$container->guid}/all");
} else {
    forward("videolist/owner/{$container->username}");
}
开发者ID:elgg,项目名称:videolist,代码行数:31,代码来源:delete.php

示例13: theme_haarlem_intranet_profile_sync_profile_icon

/**
 * Update the user profile icon based on profile_sync data
 *
 * @param string $event  the name of the event
 * @param string $type   the type of the event
 * @param mixed  $object supplied object
 *
 * @return void
 */
function theme_haarlem_intranet_profile_sync_profile_icon($event, $type, $object)
{
    if (empty($object) || !is_array($object)) {
        return;
    }
    $user = elgg_extract('entity', $object);
    if (empty($user) || !elgg_instanceof($user, 'user')) {
        return;
    }
    // handle icons
    $datasource = elgg_extract('datasource', $object);
    $source_row = elgg_extract('source_row', $object);
    if (empty($datasource) || empty($source_row)) {
        return;
    }
    // handle custom icon
    $fh = new ElggFile();
    $fh->owner_guid = $user->getGUID();
    $icon_sizes = elgg_get_config('icon_sizes');
    $icon_path = elgg_extract('profielfoto', $source_row);
    $icon_path = profile_sync_filter_var($icon_path);
    if (empty($icon_path)) {
        // remove icon
        foreach ($icon_sizes as $size => $info) {
            $fh->setFilename("haarlem_icon/{$size}.jpg");
            if ($fh->exists()) {
                $fh->delete();
            }
        }
        unset($user->haarlem_icontime);
        return;
    }
    $csv_location = $datasource->csv_location;
    if (empty($csv_location)) {
        return;
    }
    $csv_filename = basename($csv_location);
    $base_location = rtrim(str_ireplace($csv_filename, "", $csv_location), DIRECTORY_SEPARATOR);
    $icon_path = sanitise_filepath($icon_path, false);
    // prevent abuse (like ../../......)
    $icon_path = ltrim($icon_path, DIRECTORY_SEPARATOR);
    // remove beginning /
    $icon_path = $base_location . DIRECTORY_SEPARATOR . $icon_path;
    // concat base location and rel path
    // icon exists
    if (!file_exists($icon_path)) {
        return;
    }
    // was csv image updated
    $csv_iconsize = @filesize($icon_path);
    if ($csv_iconsize !== false) {
        $csv_iconsize = md5($csv_iconsize);
        $icontime = $user->haarlem_icontime;
        if ($csv_iconsize === $icontime) {
            // icons are the same
            return;
        }
    }
    // try to get the user icon
    $icon_contents = file_get_contents($icon_path);
    if (empty($icon_contents)) {
        return;
    }
    // make sure we have a hash to save
    if ($csv_iconsize === false) {
        $csv_iconsize = strlen($icon_contents);
        $csv_iconsize = md5($csv_iconsize);
    }
    // write icon to a temp location for further handling
    $tmp_icon = tempnam(sys_get_temp_dir(), $user->getGUID());
    file_put_contents($tmp_icon, $icon_contents);
    // resize icon
    $icon_updated = false;
    foreach ($icon_sizes as $size => $icon_info) {
        $icon_contents = get_resized_image_from_existing_file($tmp_icon, $icon_info["w"], $icon_info["h"], $icon_info["square"], 0, 0, 0, 0, $icon_info["upscale"]);
        if (empty($icon_contents)) {
            continue;
        }
        $fh->setFilename("haarlem_icon/{$size}.jpg");
        $fh->open("write");
        $fh->write($icon_contents);
        $fh->close();
        $icon_updated = true;
    }
    // did we have a successfull icon upload?
    if ($icon_updated) {
        $user->haarlem_icontime = $csv_iconsize;
    }
    // cleanup
    unlink($tmp_icon);
}
开发者ID:Twizanex,项目名称:theme_haarlem_intranet,代码行数:100,代码来源:events.php

示例14: delete

 /**
  * Deletes a video, override for the parent delete
  *
  * @return boolean
  */
 public function delete()
 {
     // in case of an uploaded video make sure it's also deleted from queue and trash
     // with related media if it still remained there
     if ($this->videotype == 'uploaded') {
         $queue_object = new izapQueue();
         $queue_object->delete_from_trash($this->guid, true);
         $queue_object->delete($this->guid, true);
     }
     $imagesrc = $this->imagesrc;
     $filesrc = $this->videofile;
     $ofilesrc = $this->orignalfile;
     //delete entity from elgg db and corresponding files if exist
     $this->setFilename($imagesrc);
     $image_file = $this->getFilenameOnFilestore();
     file_exists($image_file) && @unlink($image_file);
     $this->setFilename($filesrc);
     $video_file = $this->getFilenameOnFilestore();
     file_exists($video_file) && @unlink($video_file);
     $this->setFilename($ofilesrc);
     $orignal_file = $this->getFilenameOnFilestore();
     file_exists($orignal_file) && @unlink($orignal_file);
     return parent::delete();
 }
开发者ID:iionly,项目名称:izap_videos,代码行数:29,代码来源:izap_videos.php

示例15: file_delete

/**
 * Delete an ElggFile file
 *
 * @param int $guid ElggFile GUID
 *
 * @return bool
 */
function file_delete($guid)
{
    if ($file = get_entity($guid)) {
        if ($file->canEdit()) {
            $container = get_entity($file->container_guid);
            $thumbnail = $file->thumbnail;
            $smallthumb = $file->smallthumb;
            $largethumb = $file->largethumb;
            if ($thumbnail) {
                $delfile = new ElggFile();
                $delfile->owner_guid = $file->owner_guid;
                $delfile->setFilename($thumbnail);
                $delfile->delete();
            }
            if ($smallthumb) {
                $delfile = new ElggFile();
                $delfile->owner_guid = $file->owner_guid;
                $delfile->setFilename($smallthumb);
                $delfile->delete();
            }
            if ($largethumb) {
                $delfile = new ElggFile();
                $delfile->owner_guid = $file->owner_guid;
                $delfile->setFilename($largethumb);
                $delfile->delete();
            }
            return $file->delete();
        }
    }
    return false;
}
开发者ID:rcolomoc,项目名称:Master-Red-Social,代码行数:38,代码来源:filestore.php


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