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


PHP BigTree::pathInfo方法代码示例

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


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

示例1: processImageUpload


//.........这里部分代码省略.........
                     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"])) {
                                 $prefixes[] = $center_crop["prefix"];
                             }
                         }
                     }
                 }
             }
         }
         // Upload the original to the proper place.
         $field["output"] = $storage->store($first_copy, $name, $field["options"]["directory"], true, $prefixes);
         // If the upload service didn't return a value, we failed to upload it for one reason or another.
         if (!$field["output"]) {
             if ($storage->DisabledFileError) {
                 $bigtree["errors"][] = array("field" => $field["title"], "error" => "Could not upload file. The file extension is not allowed.");
             } else {
                 $bigtree["errors"][] = array("field" => $field["title"], "error" => "Could not upload file. The destination is not writable.");
             }
             unlink($temp_copy);
             unlink($first_copy);
             // Failed, we keep the current value
             return false;
             // If we did upload it successfully, check on thumbs and crops.
         } else {
             // Get path info on the file.
             $pinfo = BigTree::pathInfo($field["output"]);
             // Handle Crops
             if (is_array($field["options"]["crops"])) {
                 foreach ($field["options"]["crops"] as $crop) {
                     if (is_array($crop)) {
                         // Make sure the crops have a width/height and it's numeric
                         if ($crop["width"] && $crop["height"] && is_numeric($crop["width"]) && is_numeric($crop["height"])) {
                             $cwidth = $crop["width"];
                             $cheight = $crop["height"];
                             // Check to make sure each dimension is greater then or equal to, but not both equal to the crop.
                             if ($iheight >= $cheight && $iwidth > $cwidth || $iwidth >= $cwidth && $iheight > $cheight) {
                                 // Make a square if for some reason someone only entered one dimension for a crop.
                                 if (!$cwidth) {
                                     $cwidth = $cheight;
                                 } elseif (!$cheight) {
                                     $cheight = $cwidth;
                                 }
                                 $bigtree["crops"][] = array("image" => $temp_copy, "directory" => $field["options"]["directory"], "retina" => $field["options"]["retina"], "name" => $pinfo["basename"], "width" => $cwidth, "height" => $cheight, "prefix" => $crop["prefix"], "thumbs" => $crop["thumbs"], "center_crops" => $crop["center_crops"], "grayscale" => $crop["grayscale"]);
                                 // If it's the same dimensions, let's see if they're looking for a prefix for whatever reason...
                             } elseif ($iheight == $cheight && $iwidth == $cwidth) {
                                 // See if we want thumbnails
                                 if (is_array($crop["thumbs"])) {
                                     foreach ($crop["thumbs"] as $thumb) {
                                         // Make sure the thumbnail has a width or height and it's numeric
                                         if ($thumb["width"] && is_numeric($thumb["width"]) || $thumb["height"] && is_numeric($thumb["height"])) {
                                             // Create a temporary thumbnail of the image on the server before moving it to it's destination.
                                             $temp_thumb = SITE_ROOT . "files/" . uniqid("temp-") . $itype_exts[$itype];
                                             BigTree::createThumbnail($temp_copy, $temp_thumb, $thumb["width"], $thumb["height"], $field["options"]["retina"], $thumb["grayscale"]);
                                             // We use replace here instead of upload because we want to be 100% sure that this file name doesn't change.
                                             $storage->replace($temp_thumb, $thumb["prefix"] . $pinfo["basename"], $field["options"]["directory"]);
                                         }
                                     }
                                 }
开发者ID:kurt-planet,项目名称:BigTree-CMS,代码行数:67,代码来源:admin.php

示例2: list

 $first_copy = $temp_name;
 list($iwidth, $iheight, $itype, $iattr) = getimagesize($first_copy);
 foreach ($thumbnails_to_create as $thumb) {
     // We don't want to add multiple errors and we also don't want to waste effort getting thumbnail sizes if we already failed.
     if (!$error) {
         $sizes = BigTree::getThumbnailSizes($first_copy, $thumb["width"], $thumb["height"]);
         if (!BigTree::imageManipulationMemoryAvailable($first_copy, $sizes[3], $sizes[4], $iwidth, $iheight)) {
             $error = "Image uploaded is too large for the server to manipulate. Please upload a smaller version of this image.";
             unlink($first_copy);
         }
     }
 }
 if (!$error) {
     // Now let's make the thumbnails we need for the image manager
     $thumbs = array();
     $pinfo = BigTree::pathInfo($file_name);
     // Create a bunch of thumbnails
     foreach ($thumbnails_to_create as $key => $thumb) {
         if ($iwidth > $thumb["width"] || $iheight > $thumb["height"]) {
             $temp_thumb = SITE_ROOT . "files/" . uniqid("temp-") . $itype_exts[$itype];
             BigTree::createThumbnail($first_copy, $temp_thumb, $thumb["width"], $thumb["height"]);
             if ($key == "bigtree_internal_list") {
                 list($twidth, $theight) = getimagesize($temp_thumb);
                 $margin = floor((100 - $theight) / 2);
             }
             if ($replacing) {
                 $file = $storage->replace($temp_thumb, $thumb["prefix"] . $pinfo["basename"], "files/resources/");
             } else {
                 $file = $storage->store($temp_thumb, $thumb["prefix"] . $pinfo["basename"], "files/resources/");
             }
             $thumbs[$key] = $file;
开发者ID:matthisamoto,项目名称:Graphfan,代码行数:31,代码来源:upload.php

示例3: uniqid

<?php

$file = $admin->getResourceByFile($_POST["file"]);
$pinfo = BigTree::pathInfo($file["file"]);
// We throw on ?uniqid so that we don't cache the thumbnail in the event that we just replaced it
if ($file["is_image"]) {
    ?>
<div class="file_browser_detail_thumb">
	<img src="<?php 
    echo $file["thumbs"]["bigtree_internal_detail"] . ($_COOKIE["bigtree_admin"]["recently_replaced_file"] ? "?" . uniqid() : "");
    ?>
" alt="" />
</div>
<?php 
}
?>
<div class="file_browser_detail_title">
	<label>Title</label>
	<input type="text" name="<?php 
echo $file["id"];
?>
" id="file_browser_detail_title_input" value="<?php 
echo $file["name"];
?>
" />
</div>
<div class="file_browser_detail_list">
	<?php 
if (!$file["is_image"]) {
    ?>
	<p><span>File Name</span><strong><?php 
开发者ID:kurt-planet,项目名称:BigTree-CMS,代码行数:31,代码来源:file-info.php

示例4: foreach

    echo $container["name"];
    ?>
"><span class="icon_small icon_small_export"></span><?php 
    echo $container["name"];
    ?>
</a></li>
		<?php 
}
?>
	</ul>
</div>
<div class="browser_pane">
	<ul>
		<?php 
foreach ($files as $file) {
    $parts = BigTree::pathInfo($file);
    $ext = strtolower($parts["extension"]);
    ?>
		<li class="file<?php 
    if ($file == $_POST["file"]) {
        ?>
 selected<?php 
    }
    ?>
"><span class="icon_small icon_small_file_default icon_small_file_<?php 
    echo $ext;
    ?>
"></span><p><?php 
    echo $file;
    ?>
</p></li>
开发者ID:jzxyouok,项目名称:BigTree-CMS,代码行数:31,代码来源:file-browser.php

示例5: uploadFile

 function uploadFile($file, $container, $pointer = false, $public = false)
 {
     // MIME Types
     $exts = array("jpg" => "image/jpeg", "jpeg" => "image/jpeg", "gif" => "image/gif", "png" => "image/png", "ico" => "image/x-icon", "pdf" => "application/pdf", "tif" => "image/tiff", "tiff" => "image/tiff", "svg" => "image/svg+xml", "svgz" => "image/svg+xml", "swf" => "application/x-shockwave-flash", "zip" => "application/zip", "gz" => "application/x-gzip", "tar" => "application/x-tar", "bz" => "application/x-bzip", "bz2" => "application/x-bzip2", "rar" => "application/x-rar-compressed", "exe" => "application/x-msdownload", "msi" => "application/x-msdownload", "cab" => "application/vnd.ms-cab-compressed", "txt" => "text/plain", "asc" => "text/plain", "htm" => "text/html", "html" => "text/html", "css" => "text/css", "js" => "text/javascript", "xml" => "text/xml", "xsl" => "application/xsl+xml", "ogg" => "application/ogg", "mp3" => "audio/mpeg", "wav" => "audio/x-wav", "avi" => "video/x-msvideo", "mpg" => "video/mpeg", "mpeg" => "video/mpeg", "mov" => "video/quicktime", "flv" => "video/x-flv", "php" => "text/x-php");
     // Default the pointer to the name of the file if not provided.
     if (!$pointer) {
         $path_info = BigTree::pathInfo($file);
         $pointer = $path_info["basename"];
     } else {
         $path_info = BigTree::pathInfo($pointer);
     }
     // Get destination mime type
     $content_type = isset($exts[strtolower($path_info["extension"])]) ? $exts[strtolower($path_info["extension"])] : "application/octet-stream";
     // Amazon S3
     if ($this->Service == "amazon") {
         $response = $this->callAmazonS3("PUT", $container, $pointer, array(), array("Content-Type" => $content_type, "Content-Length" => filesize($file)), array("x-amz-acl" => $public ? "public-read" : "private"), false, $file);
         if (!$response) {
             return "//s3.amazonaws.com/{$container}/{$pointer}";
         }
         $this->_setAmazonError($response);
         return false;
         // Rackspace Cloud Files
     } elseif ($this->Service == "rackspace") {
         global $bigtree;
         $file_pointer = fopen($file, "r");
         BigTree::cURL($this->RackspaceAPIEndpoint . "/{$container}/{$pointer}", false, array(CURLOPT_PUT => true, CURLOPT_INFILE => $file_pointer, CURLOPT_HTTPHEADER => array("Content-Length" => filesize($file), "X-Auth-Token: " . $this->Settings["rackspace"]["token"])));
         fclose($file_pointer);
         if ($bigtree["last_curl_response_code"] == "201") {
             return $this->_getRackspaceURL($container, $pointer);
         }
         return false;
         // Google Cloud Storage
     } elseif ($this->Service == "google") {
         $file_pointer = fopen($file, "r");
         $response = json_decode(BigTree::cURL("https://www.googleapis.com/upload/storage/v1/b/{$container}/o?name={$pointer}&uploadType=media", false, array(CURLOPT_INFILE => $file_pointer, CURLOPT_POST => true, CURLOPT_HTTPHEADER => array("Content-Type: {$content_type}", "Content-Length: " . filesize($file), "Authorization: Bearer " . $this->Settings["token"]))));
         fclose($file_pointer);
         if (isset($response->id)) {
             // Set the access control level if it's publicly accessible
             if ($public) {
                 $this->call("b/{$container}/o/" . rawurlencode($pointer) . "/acl", json_encode(array("entity" => "allUsers", "role" => "READER")), "POST");
             }
             return "//storage.googleapis.com/{$container}/{$pointer}";
         } else {
             foreach ($response->error->errors as $error) {
                 $this->Errors[] = $error;
             }
             return false;
         }
     } else {
         return false;
     }
 }
开发者ID:kurt-planet,项目名称:BigTree-CMS,代码行数:52,代码来源:cloud-storage.php

示例6:

echo $field["tabindex"];
?>
" name="<?php 
echo $field["key"];
?>
" data-min-width="<?php 
echo $min_width;
?>
" data-min-height="<?php 
echo $min_height;
?>
" />
	<?php 
if (!isset($field["options"]["image"]) || !$field["options"]["image"]) {
    if ($field["value"]) {
        $pathinfo = BigTree::pathInfo($field["value"]);
        ?>
	<div class="currently_file">
		<input type="hidden" name="<?php 
        echo $field["key"];
        ?>
" value="<?php 
        echo $field["value"];
        ?>
" />
		<strong>Currently:</strong> <?php 
        echo $pathinfo["basename"];
        ?>
 <a href="#" class="remove_resource">Remove</a>
	</div>
	<?php 
开发者ID:kurt-planet,项目名称:BigTree-CMS,代码行数:31,代码来源:upload.php

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

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

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