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


PHP ElggFile::exists方法代码示例

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


在下文中一共展示了ElggFile::exists方法的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: 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: 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

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

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

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

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

示例8: seo_get_data

/**
 * Get URL data
 *
 * @param string $url URL
 * @return array|false
 */
function seo_get_data($url)
{
    $path = seo_get_path($url);
    if (!$path) {
        return false;
    }
    $hash = sha1($path);
    $site = elgg_get_site_entity();
    $file = new ElggFile();
    $file->owner_guid = $site->guid;
    $file->setFilename("seo/{$hash}.json");
    $data = false;
    if ($file->exists()) {
        $file->open('read');
        $json = $file->grabFile();
        $file->close();
        $data = json_decode($json, true);
    }
    return $data;
}
开发者ID:hypeJunction,项目名称:Elgg-seo,代码行数:26,代码来源:functions.php

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

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

示例12: ElggFile

<?php

$icon = (int) get_input("icon");
$plugin = elgg_get_plugin_from_id("theme_eersel");
$fh = new ElggFile();
$fh->owner_guid = $plugin->getGUID();
$fh->setFilename("slider_images/" . $icon . ".jpg");
if ($fh->exists()) {
    $contents = $fh->grabFile();
    header("Content-type: image/jpeg", true);
    header("Expires: " . gmdate("D, d M Y H:i:s \\G\\M\\T", strtotime("+6 months")), true);
    header("Pragma: public", true);
    header("Cache-Control: public", true);
    header("Content-Length: " . strlen($contents));
    echo $contents;
} else {
    header("HTTP/1.1 404 Not Found");
}
开发者ID:pleio,项目名称:theme_eersel,代码行数:18,代码来源:slider_image.php

示例13: getMenuItemsCache

 /**
  * Reads cached menu items from file for give root entity
  *
  * @param \ElggEntity $root_entity root entity to fetch the cache from
  *
  * @return array
  */
 public static function getMenuItemsCache(\ElggEntity $root_entity)
 {
     $static_items = [];
     $file = new \ElggFile();
     $file->owner_guid = $root_entity->getGUID();
     $file->setFilename('static_menu_item_cache');
     if ($file->exists()) {
         $static_items = unserialize($file->grabFile());
     }
     return $static_items;
 }
开发者ID:coldtrick,项目名称:static,代码行数:18,代码来源:Cache.php

示例14: elgg_get_media_file

/**
 * Returns media file
 *
 * @param \ElggEntity $entity  Entity
 * @param string      $type    Media type
 * @return \ElggFile
 */
function elgg_get_media_file(\ElggEntity $entity, $type = 'icon', $size = 'small', $ext = 'jpg')
{
    $file = new \ElggFile();
    $file->owner_guid = $entity->guid;
    $file->setFilename("media/{$type}/{$size}.{$ext}");
    return $file->exists() ? $file : false;
}
开发者ID:hypeJunction,项目名称:elgg_media,代码行数:14,代码来源:functions.php

示例15: theme_eersel_get_slider_images

function theme_eersel_get_slider_images()
{
    static $result;
    if (!isset($result)) {
        $result = false;
        $plugin = elgg_get_plugin_from_id("theme_eersel");
        $fh = new ElggFile();
        $fh->owner_guid = $plugin->getGUID();
        $prefix = "slider_images/";
        for ($i = 1; $i <= 5; $i++) {
            $fh->setFilename($prefix . $i . ".jpg");
            if ($fh->exists()) {
                $mod_time = filemtime($fh->getFilenameOnFilestore());
                if (!$result) {
                    $result = array();
                }
                $result[$i] = "theme_eersel/slider/" . $i . "/" . $mod_time . ".jpg";
            }
        }
    }
    return $result;
}
开发者ID:pleio,项目名称:theme_eersel,代码行数:22,代码来源:functions.php


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