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


PHP BigTree::copyFile方法代码示例

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


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

示例1: foreach

// Import Field Types
foreach ($json["components"]["field_types"] as $type) {
    if ($type) {
        sqlquery("DELETE FROM bigtree_field_types WHERE id = '" . sqlescape($type["id"]) . "'");
        // Backwards compatibility with field types packaged for 4.1
        if (!isset($type["use_cases"])) {
            $type["use_cases"] = array("templates" => $type["pages"], "modules" => $type["modules"], "callouts" => $type["callouts"], "settings" => $type["settings"]);
        }
        $use_cases = is_array($type["use_cases"]) ? sqlescape(json_encode($type["use_cases"])) : sqlescape($type["use_cases"]);
        $self_draw = $type["self_draw"] ? "'on'" : "NULL";
        sqlquery("INSERT INTO bigtree_field_types (`id`,`name`,`use_cases`,`self_draw`) VALUES ('" . sqlescape($type["id"]) . "','" . sqlescape($type["name"]) . "','{$use_cases}',{$self_draw})");
    }
}
// Import files
foreach ($json["files"] as $file) {
    BigTree::copyFile(SERVER_ROOT . "cache/package/{$file}", SERVER_ROOT . $file);
}
// Run SQL
foreach ($json["sql"] as $sql) {
    sqlquery($sql);
}
// Empty view cache
sqlquery("DELETE FROM bigtree_module_view_cache");
// Remove the package directory, we do it backwards because the "deepest" files are last
$contents = @array_reverse(BigTree::directoryContents(SERVER_ROOT . "cache/package/"));
foreach ($contents as $file) {
    @unlink($file);
    @rmdir($file);
}
@rmdir(SERVER_ROOT . "cache/package/");
// Clear module class cache and field type cache.
开发者ID:matthisamoto,项目名称:Graphfan,代码行数:31,代码来源:process.php

示例2: processImageUpload


//.........这里部分代码省略.........
     if (!$failed) {
         // Make a temporary copy to be used for thumbnails and crops.
         $itype_exts = array(IMAGETYPE_PNG => ".png", IMAGETYPE_JPEG => ".jpg", IMAGETYPE_GIF => ".gif");
         // Make a first copy
         $first_copy = SITE_ROOT . "files/" . uniqid("temp-") . $itype_exts[$itype];
         BigTree::moveFile($temp_name, $first_copy);
         // Do EXIF Image Rotation
         if ($itype == IMAGETYPE_JPEG && function_exists("exif_read_data")) {
             $exif = @exif_read_data($first_copy);
             $o = $exif['Orientation'];
             if ($o == 3 || $o == 6 || $o == 8) {
                 $source = imagecreatefromjpeg($first_copy);
                 if ($o == 3) {
                     $source = imagerotate($source, 180, 0);
                 } elseif ($o == 6) {
                     $source = imagerotate($source, 270, 0);
                 } else {
                     $source = imagerotate($source, 90, 0);
                 }
                 // We're going to create a PNG so that we don't lose quality when we resave
                 imagepng($source, $first_copy);
                 rename($first_copy, substr($first_copy, 0, -3) . "png");
                 $first_copy = substr($first_copy, 0, -3) . "png";
                 // Force JPEG since we made the first copy a PNG
                 $storage->AutoJPEG = true;
                 // Clean up memory
                 imagedestroy($source);
                 // Get new width/height/type
                 list($iwidth, $iheight, $itype, $iattr) = getimagesize($first_copy);
             }
         }
         // Create a temporary copy that we will use later for crops and thumbnails
         $temp_copy = SITE_ROOT . "files/" . uniqid("temp-") . $itype_exts[$itype];
         BigTree::copyFile($first_copy, $temp_copy);
         // Gather up an array of file prefixes
         $prefixes = array();
         if (is_array($field["options"]["thumbs"])) {
             foreach ($field["options"]["thumbs"] as $thumb) {
                 if (!empty($thumb["prefix"])) {
                     $prefixes[] = $thumb["prefix"];
                 }
             }
         }
         if (is_array($field["options"]["center_crops"])) {
             foreach ($field["options"]["center_crops"] as $crop) {
                 if (!empty($crop["prefix"])) {
                     $prefixes[] = $crop["prefix"];
                 }
             }
         }
         if (is_array($field["options"]["crops"])) {
             foreach ($field["options"]["crops"] as $crop) {
                 if (is_array($crop)) {
                     if (!empty($crop["prefix"])) {
                         $prefixes[] = $crop["prefix"];
                     }
                     if (is_array($crop["thumbs"])) {
                         foreach ($crop["thumbs"] as $thumb) {
                             if (!empty($thumb["prefix"])) {
                                 $prefixes[] = $thumb["prefix"];
                             }
                         }
                     }
                     if (is_array($crop["center_crops"])) {
                         foreach ($crop["center_crops"] as $center_crop) {
                             if (!empty($center_crop["prefix"])) {
开发者ID:kurt-planet,项目名称:BigTree-CMS,代码行数:67,代码来源:admin.php

示例3: elseif

        } elseif (substr($file, 0, 20) == "custom/admin/images/") {
            $d = "images/" . substr($file, 20);
        } elseif (substr($file, 0, 21) == "custom/admin/modules/") {
            $d = "modules/" . substr($file, 21);
        } elseif (substr($file, 0, 19) == "custom/inc/modules/") {
            $d = "classes/" . substr($file, 19);
        } elseif (substr($file, 0, 10) == "templates/") {
            $d = $file;
        } elseif (substr($file, 0, 5) == "site/") {
            // Already in the proper directory, should be copied to public, not moved
            if (strpos($file, "site/extensions/{$id}/") === 0) {
                BigTree::copyFile(SERVER_ROOT . $file, SERVER_ROOT . "extensions/{$id}/public/" . str_replace("site/extensions/{$id}/", "", $file));
                // Move into the site/extensions/ folder and then copy into /public/
            } else {
                BigTree::moveFile(SERVER_ROOT . $file, SITE_ROOT . "extensions/{$id}/" . substr($file, 5));
                BigTree::copyFile(SITE_ROOT . "extensions/{$id}/" . substr($file, 5), SERVER_ROOT . "extensions/{$id}/public/" . substr($file, 5));
            }
        }
        // If we have a place to move it to, move it.
        if ($d) {
            BigTree::moveFile(SERVER_ROOT . $file, SERVER_ROOT . "extensions/{$id}/" . $d);
        }
    }
}
// If this package already exists, we need to do a diff of the tables, increment revision numbers, and add SQL statements.
$existing = sqlfetch(sqlquery("SELECT * FROM bigtree_extensions WHERE id = '" . sqlescape($id) . "' AND type = 'extension'"));
if ($existing) {
    $existing_json = json_decode($existing["manifest"], true);
    // Increment revision numbers
    $revision = $package["revision"] = intval($existing_json["revision"]) + 1;
    $package["sql_revisions"] = (array) $existing_json["sql_revisions"];
开发者ID:kurt-planet,项目名称:BigTree-CMS,代码行数:31,代码来源:create.php

示例4: store

 function store($local_file, $file_name, $relative_path, $remove_original = true, $prefixes = array())
 {
     // If the file name ends in a disabled extension, fail.
     if (preg_match($this->DisabledExtensionRegEx, $file_name)) {
         $this->DisabledFileError = true;
         return false;
     }
     // If we're auto converting images to JPG from PNG
     $file_name = $this->convertJPEG($local_file, $file_name);
     // Enforce trailing slashe on relative_path
     $relative_path = $relative_path ? rtrim($relative_path, "/") . "/" : "files/";
     if ($this->Cloud) {
         // Clean up the file name
         global $cms;
         $parts = BigTree::pathInfo($file_name);
         $clean_name = $cms->urlify($parts["filename"]);
         if (strlen($clean_name) > 50) {
             $clean_name = substr($clean_name, 0, 50);
         }
         // Best case name
         $file_name = $clean_name . "." . strtolower($parts["extension"]);
         $x = 2;
         // Make sure we have a unique name
         while (!$file_name || sqlrows(sqlquery("SELECT `timestamp` FROM bigtree_caches WHERE `identifier` = 'org.bigtreecms.cloudfiles' AND `key` = '" . sqlescape($relative_path . $file_name) . "'"))) {
             $file_name = $clean_name . "-{$x}." . strtolower($parts["extension"]);
             $x++;
             // Check all the prefixes, make sure they don't exist either
             if (is_array($prefixes) && count($prefixes)) {
                 $prefix_query = array();
                 foreach ($prefixes as $prefix) {
                     $prefix_query[] = "`key` = '" . sqlescape($relative_path . $prefix . $file_name) . "'";
                 }
                 if (sqlrows(sqlquery("SELECT `timestamp` FROM bigtree_caches WHERE identifier = 'org.bigtreecms.cloudfiles' AND (" . implode(" OR ", $prefix_query) . ")"))) {
                     $file_name = false;
                 }
             }
         }
         // Upload it
         $success = $this->Cloud->uploadFile($local_file, $this->Settings->Container, $relative_path . $file_name, true);
         if ($success) {
             sqlquery("INSERT INTO bigtree_caches (`identifier`,`key`,`value`) VALUES ('org.bigtreecms.cloudfiles','" . sqlescape($relative_path . $file_name) . "','" . sqlescape(json_encode(array("name" => $file_name, "path" => $relative_path . $file_name, "size" => filesize($local_file)))) . "')");
         }
         if ($remove_original) {
             unlink($local_file);
         }
         return $success;
     } else {
         $safe_name = BigTree::getAvailableFileName(SITE_ROOT . $relative_path, $file_name, $prefixes);
         if ($remove_original) {
             $success = BigTree::moveFile($local_file, SITE_ROOT . $relative_path . $safe_name);
         } else {
             $success = BigTree::copyFile($local_file, SITE_ROOT . $relative_path . $safe_name);
         }
         if ($success) {
             return "{staticroot}" . $relative_path . $safe_name;
         } else {
             return false;
         }
     }
 }
开发者ID:matthisamoto,项目名称:Graphfan,代码行数:60,代码来源:storage.php

示例5: array

$photo_gallery = array();
if (is_array($field["input"])) {
    foreach ($field["input"] as $photo_count => $data) {
        // Existing Data
        if ($data["image"]) {
            $data["caption"] = BigTree::safeEncode($data["caption"]);
            $photo_gallery[] = $data;
            // Uploaded File
        } elseif ($field["file_input"][$photo_count]["image"]["name"]) {
            $field_copy = $field;
            $field_copy["file_input"] = $field["file_input"][$photo_count]["image"];
            $file = $admin->processImageUpload($field_copy);
            if ($file) {
                $photo_gallery[] = array("caption" => BigTree::safeEncode($data["caption"]), "image" => $file);
            }
            // File From Image Manager
        } elseif ($data["existing"]) {
            $data["existing"] = str_replace(WWW_ROOT, SITE_ROOT, $data["existing"]);
            $pinfo = BigTree::pathInfo($data["existing"]);
            $field_copy = $field;
            $field_copy["file_input"] = array("name" => $pinfo["basename"], "tmp_name" => SITE_ROOT . "files/" . uniqid("temp-") . ".img", "error" => false);
            BigTree::copyFile($data["existing"], $field_copy["file_input"]["tmp_name"]);
            $file = $admin->processImageUpload($field_copy);
            if ($file) {
                $photo_gallery[] = array("caption" => BigTree::safeEncode($data["caption"]), "image" => $file);
            }
        }
    }
}
$field["output"] = $photo_gallery;
开发者ID:kurt-planet,项目名称:BigTree-CMS,代码行数:30,代码来源:photo-gallery.php

示例6: array

                } else {
                    $bigtree["errors"][] = array("field" => $field["options"]["title"], "error" => "Could not upload file. The destination is not writable.");
                }
            }
        } else {
            $field["output"] = $field["input"];
        }
        // We're processing an image.
    } else {
        // We uploaded a new image.
        if (is_uploaded_file($field["file_input"]["tmp_name"])) {
            $file = $admin->processImageUpload($field);
            $field["output"] = $file ? $file : $field["input"];
            // Using an existing image or one from the Image Browser
        } else {
            $field["output"] = $field["input"];
            // We're trying to use an image from the Image Browser.
            if (substr($field["output"], 0, 11) == "resource://") {
                // It's technically a new file now, but we pulled it from resources so we might need to crop it.
                $resource = $admin->getResourceByFile(str_replace(array(STATIC_ROOT, WWW_ROOT), array("{staticroot}", "{wwwroot}"), substr($field["output"], 11)));
                $resource_location = str_replace(array("{wwwroot}", WWW_ROOT, "{staticroot}", STATIC_ROOT), SITE_ROOT, $resource["file"]);
                $pinfo = BigTree::pathInfo($resource_location);
                // Emulate a newly uploaded file
                $field["file_input"] = array("name" => $pinfo["basename"], "tmp_name" => SITE_ROOT . "files/" . uniqid("temp-") . ".img", "error" => false);
                BigTree::copyFile($resource_location, $field["file_input"]["tmp_name"]);
                $file = $admin->processImageUpload($field);
                $field["output"] = $file ? $file : $field["input"];
            }
        }
    }
}
开发者ID:matthisamoto,项目名称:Graphfan,代码行数:31,代码来源:upload.php


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