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


PHP ElggFile::grabFile方法代码示例

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


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

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

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

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

示例4: array

 if (!empty($group->icontime)) {
     $prefix = "groups/" . $group->getGUID();
     $sizes = array("tiny", "small", "medium", "large");
     $ofh = new ElggFile();
     $ofh->owner_guid = $old_owner->getGUID();
     $nfh = new ElggFile();
     $nfh->owner_guid = $group->getOwnerGUID();
     foreach ($sizes as $size) {
         // set correct file to handle
         $ofh->setFilename($prefix . $size . ".jpg");
         $nfh->setFilename($prefix . $size . ".jpg");
         // open files
         $ofh->open("read");
         $nfh->open("write");
         // copy file
         $nfh->write($ofh->grabFile());
         // close file
         $ofh->close();
         $nfh->close();
         // cleanup old file
         $ofh->delete();
     }
     $group->icontime = time();
 }
 // move metadata of the group to the new owner
 $options = array("guid" => $group->getGUID(), "limit" => false);
 if ($metadata = elgg_get_metadata($options)) {
     foreach ($metadata as $md) {
         if ($md->owner_guid == $old_owner->getGUID()) {
             $md->owner_guid = $new_owner->getGUID();
             $md->save();
开发者ID:socialweb,项目名称:PiGo,代码行数:31,代码来源:admin_transfer.php

示例5: switch

            switch ($size) {
                case "small":
                    $thumbfile = $file->thumbnail;
                    break;
                case "medium":
                    $thumbfile = $file->smallthumb;
                    break;
                case "large":
                default:
                    $thumbfile = $file->largethumb;
                    break;
            }
            // Grab the file
            if ($thumbfile && !empty($thumbfile)) {
                $readfile = new ElggFile();
                $readfile->owner_guid = $file->owner_guid;
                $readfile->setFilename($thumbfile);
                $mime = $file->getMimeType();
                $contents = $readfile->grabFile();
                // caching images for 10 days
                header("Content-type: {$mime}");
                header('Expires: ' . date('r', time() + 864000));
                header("Pragma: public", true);
                header("Cache-Control: public", true);
                header("Content-Length: " . strlen($contents));
                echo $contents;
                exit;
            }
        }
    }
}
开发者ID:ashwiniravi,项目名称:Elgg-Social-Network-Single-Sign-on-and-Web-Statistics,代码行数:31,代码来源:thumbnail.php

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

示例7: elseif

$what = elgg_extract('what', $vars);
$izap_videos = izapVideoCheck_izap_videos($guid);
if ($izap_videos) {
    // check what is needed
    if ($what == 'image') {
        $filename = $izap_videos->imagesrc;
    } elseif (!isset($what) || empty($what) || $what == 'file') {
        $filename = $izap_videos->videofile;
    }
    // only works if there is some file name
    if ($filename != '') {
        $fileHandler = new ElggFile();
        $fileHandler->owner_guid = $izap_videos->owner_guid;
        $fileHandler->setFilename($filename);
        if (file_exists($fileHandler->getFilenameOnFilestore())) {
            $contents = $fileHandler->grabFile();
        }
    }
    if ($contents == '') {
        $contents = elgg_view("izap_videos/izapdesign_logo.gif");
        $type = 'image/gif';
    } elseif ($what == 'image') {
        $type = 'image/jpeg';
    } elseif (!isset($what) || empty($what) || $what == 'file') {
        $type = 'application/x-flv';
    }
    header('Expires: ' . gmdate('D, d M Y H:i:s \\G\\M\\T', strtotime("+10 days")), true);
    header("Pragma: public");
    header("Cache-Control: public");
    header("Content-Length: " . strlen($contents));
    header("Content-Type: {$type}");
开发者ID:iionly,项目名称:izap_videos,代码行数:31,代码来源:thumbs.php

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

示例9: ElggFile

<?php

/**
 * Elgg video thumbnail
 *
 * @package Video
 */
// Get video GUID
$video_guid = (int) get_input('video_guid', 0);
// Get video thumbnail size
$size = get_input('size', 'small');
$video = get_entity($video_guid);
if (!elgg_instanceof($video, 'object', 'video')) {
    exit;
}
$filename = "video/{$video_guid}/icon-{$size}.jpg";
// Grab the file
$thumb = new ElggFile();
$thumb->owner_guid = $video->owner_guid;
$thumb->setFilename($filename);
$storename = $thumb->getFilenameOnFilestore();
$contents = $thumb->grabFile();
// caching images for 10 days
header("Content-type: image/jpg");
header('Expires: ' . gmdate('D, d M Y H:i:s \\G\\M\\T', strtotime("+10 days")), true);
header("Pragma: public", true);
header("Cache-Control: public", true);
header("Content-Length: " . strlen($contents));
echo $contents;
exit;
开发者ID:juho-jaakkola,项目名称:elgg-videos,代码行数:30,代码来源:videothumb.php

示例10: testCanCreateAndReadSymlinks

 /**
  * @group FileService
  */
 public function testCanCreateAndReadSymlinks()
 {
     $symlink_name = "symlink.txt";
     $dataroot = _elgg_services()->config->get('dataroot');
     $dir = new \Elgg\EntityDirLocator(2);
     // Remove symlink in case it exists
     if (file_exists("{$dataroot}{$dir}{$symlink_name}")) {
         unlink("{$dataroot}{$dir}{$symlink_name}");
     }
     $target = new ElggFile();
     $target->owner_guid = 2;
     $target->setFilename('symlink-target.txt');
     $target->open('write');
     $target->write('Testing!');
     $target->close();
     $symlink = new ElggFile();
     $symlink->owner_guid = 2;
     $symlink->setFilename($symlink_name);
     $to = $target->getFilenameOnFilestore();
     $from = $symlink->getFilenameOnFilestore();
     $this->assertTrue(symlink($to, $from));
     $this->assertEquals("{$dataroot}{$dir}{$symlink_name}", $from);
     $this->assertTrue($symlink->exists());
     $target->open('read');
     $file_contents = $target->grabFile();
     $target->close();
     $symlink->open('read');
     $symlink_contents = $symlink->grabFile();
     $symlink->close();
     $this->assertEquals($file_contents, $symlink_contents);
     $this->assertTrue(unlink("{$dataroot}{$dir}{$symlink_name}"));
     $this->assertFalse($symlink->exists());
 }
开发者ID:elgg,项目名称:elgg,代码行数:36,代码来源:ElggFileTest.php

示例11: getAttachment

 /**
  * Get the contents of one attchements
  *
  * @param string $filename the filename of the attachment
  *
  * @return false|string
  */
 public function getAttachment($filename)
 {
     if (!$this->getGUID()) {
         return false;
     }
     $fh = new ElggFile();
     $fh->owner_guid = $this->getGUID();
     $fh->setFilename("attachments/{$filename}");
     if (!$fh->exists()) {
         return false;
     }
     return $fh->grabFile();
 }
开发者ID:coldtrick,项目名称:todos,代码行数:20,代码来源:TodoItem.php

示例12: getRecipients

 /**
  * Get the recipients
  *
  * @return bool|array
  */
 public function getRecipients()
 {
     $result = false;
     // check for previous DB recipients
     if ($this->recipients) {
         $recipients = json_decode($this->recipients, true);
         $this->setRecipients($recipients);
     }
     $fh = new ElggFile();
     $fh->owner_guid = $this->getGUID();
     $fh->setFilename('recipients.json');
     if ($fh->exists()) {
         $raw = $fh->grabFile();
         $result = json_decode($raw, true);
     }
     return $result;
 }
开发者ID:coldtrick,项目名称:newsletter,代码行数:22,代码来源:Newsletter.php

示例13: elasticsearch_reschedule_document_for_deletion

/**
 * Reschedule a document for deletion, because something failed
 *
 * @param int $guid the document to be rescheduled
 *
 * @return void
 */
function elasticsearch_reschedule_document_for_deletion($guid)
{
    $plugin = elgg_get_plugin_from_id('elasticsearch');
    $fh = new ElggFile();
    $fh->owner_guid = $plugin->getGUID();
    $fh->setFilename("documents_for_deletion/{$guid}");
    if (!$fh->exists()) {
        // shouldn't happen
        return;
    }
    $contents = $fh->grabFile();
    if (empty($contents)) {
        return;
    }
    $contents = unserialize($contents);
    if (!is_array($contents)) {
        return;
    }
    // try agin in an hour
    $contents['time'] = time() + 60 * 60;
    $fh->open('write');
    $fh->write(serialize($contents));
    $fh->close();
}
开发者ID:ColdTrick,项目名称:elasticsearch,代码行数:31,代码来源:functions.php

示例14: group_tools_transfer_group_ownership

/**
 * Helper function to transfer the ownership of a group to a new user
 *
 * @param ElggGroup $group     the group to transfer
 * @param ElggUser  $new_owner the new owner
 *
 * @return bool
 */
function group_tools_transfer_group_ownership(ElggGroup $group, ElggUser $new_owner)
{
    if (!$group instanceof ElggGroup || !$group->canEdit()) {
        return false;
    }
    if (!$new_owner instanceof ElggUser) {
        return false;
    }
    $loggedin_user = elgg_get_logged_in_user_entity();
    // register plugin hook to make sure transfer can complete
    elgg_register_plugin_hook_handler('permissions_check', 'group', '\\ColdTrick\\GroupTools\\Access::allowGroupOwnerTransfer');
    $old_owner = $group->getOwnerEntity();
    // transfer ownership
    $group->owner_guid = $new_owner->getGUID();
    $group->container_guid = $new_owner->getGUID();
    if (!$group->save()) {
        return false;
    }
    // make sure user is added to the group
    $group->join($new_owner);
    // remove existing group administrator role for new owner
    remove_entity_relationship($new_owner->getGUID(), 'group_admin', $group->getGUID());
    // check for group icon
    if (!empty($group->icontime)) {
        $prefix = "groups/{$group->getGUID()}";
        $sizes = elgg_get_icon_sizes($group->getType());
        $ofh = new ElggFile();
        $ofh->owner_guid = $old_owner->getGUID();
        $nfh = new ElggFile();
        $nfh->owner_guid = $group->getOwnerGUID();
        foreach ($sizes as $size => $info) {
            // set correct file to handle
            $ofh->setFilename("{$prefix}{$size}.jpg");
            if (!$ofh->exists()) {
                // file doesn't exist
                continue;
            }
            $nfh->setFilename("{$prefix}{$size}.jpg");
            // open files
            $ofh->open('read');
            $nfh->open('write');
            // copy file
            $nfh->write($ofh->grabFile());
            // close file
            $ofh->close();
            $nfh->close();
            // cleanup old file
            $ofh->delete();
        }
        $group->icontime = time();
    }
    // move metadata of the group to the new owner
    $options = ['guid' => $group->getGUID(), 'limit' => false];
    $metadata = elgg_get_metadata($options);
    if (!empty($metadata)) {
        foreach ($metadata as $md) {
            if ($md->owner_guid == $old_owner->getGUID()) {
                $md->owner_guid = $new_owner->getGUID();
                $md->save();
            }
        }
    }
    // notify new owner
    if ($new_owner->getGUID() !== $loggedin_user->getGUID()) {
        $subject = elgg_echo('group_tools:notify:transfer:subject', [$group->name]);
        $message = elgg_echo('group_tools:notify:transfer:message', [$new_owner->name, $loggedin_user->name, $group->name, $group->getURL()]);
        notify_user($new_owner->getGUID(), $group->getGUID(), $subject, $message);
    }
    // unregister plugin hook to make sure transfer can complete
    elgg_unregister_plugin_hook_handler('permissions_check', 'group', '\\ColdTrick\\GroupTools\\Access::allowGroupOwnerTransfer');
    return true;
}
开发者ID:coldtrick,项目名称:group_tools,代码行数:80,代码来源:functions.php

示例15: get_resized_image_from_existing_file

/**
 * Gets the jpeg contents of the resized version of an already uploaded image
 * (Returns false if the file was not an image)
 *
 * @param string $input_name The name of the file on the disk
 * @param int    $maxwidth   The desired width of the resized image
 * @param int    $maxheight  The desired height of the resized image
 * @param bool   $square     If set to true, takes the smallest of maxwidth and
 * 			                 maxheight and use it to set the dimensions on the new image.
 *                           If no crop parameters are set, the largest square that fits
 *                           in the image centered will be used for the resize. If square,
 *                           the crop must be a square region.
 * @param int    $x1         x coordinate for top, left corner
 * @param int    $y1         y coordinate for top, left corner
 * @param int    $x2         x coordinate for bottom, right corner
 * @param int    $y2         y coordinate for bottom, right corner
 * @param bool   $upscale    Resize images smaller than $maxwidth x $maxheight?
 *
 * @return false|mixed The contents of the resized image, or false on failure
 * @deprecated 2.3
 */
function get_resized_image_from_existing_file($input_name, $maxwidth, $maxheight, $square = false, $x1 = 0, $y1 = 0, $x2 = 0, $y2 = 0, $upscale = false)
{
    elgg_deprecated_notice(__FUNCTION__ . ' has been deprecated. Use elgg_save_resized_image()', '2.3');
    if (!is_readable($input_name)) {
        return false;
    }
    // we will write resized image to a temporary file and then delete it
    $tmp_filename = time() . pathinfo($input_name, PATHINFO_BASENAME);
    $tmp = new ElggFile();
    $tmp->setFilename("tmp/{$tmp_filename}");
    $tmp->open('write');
    $tmp->close();
    $params = ['w' => $maxwidth, 'h' => $maxheight, 'x1' => $x1, 'y1' => $y1, 'x2' => $x2, 'y2' => $y2, 'square' => $square, 'upscale' => $upscale];
    $destination = $tmp->getFilenameOnFilestore();
    $image_bytes = false;
    if (elgg_save_resized_image($input_name, $destination, $params)) {
        $tmp->open('read');
        $image_bytes = $tmp->grabFile();
        $tmp->close();
    }
    $tmp->delete();
    return $image_bytes;
}
开发者ID:elgg,项目名称:elgg,代码行数:44,代码来源:filestore.php


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