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


PHP Safe::mkdir方法代码示例

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


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

示例1: make_path

 /**
  * create a complete path to a file
  *
  * The target path can be relative to YACS, or an absolute path pointing
  * almost anywhere.
  *
  * @param the target path
  * @return TRUE on success, or FALSE on failure
  */
 public static function make_path($path)
 {
     global $context;
     // sanity check
     if (!$path) {
         return TRUE;
     }
     // translate path
     $translated = Safe::realpath($path);
     // the path exists
     if (is_dir($translated)) {
         return TRUE;
     }
     // create upper level first
     $dir_name = dirname($path);
     if ($dir_name != $path && preg_match('|/|', $dir_name)) {
         // it is mandatory to have upper level
         if (!Safe::make_path($dir_name)) {
             return FALSE;
         }
     }
     // create last level directory
     return Safe::mkdir($translated);
 }
开发者ID:rair,项目名称:yacs,代码行数:33,代码来源:safe.php

示例2:

        $from = $context['path_to_root'] . Files::get_path($last_parent->get_reference()) . '/' . $file->item['file_name'];
        $dir = $context['path_to_root'] . Files::get_path($target->get_reference());
        $to = $dir . '/' . $file->item['file_name'];
        // check that dir exists
        if (!is_dir($dir)) {
            Safe::make_path($dir);
        }
        Safe::rename($from, $to);
        // move thumb if any
        if ($file->item['thumbnail_url']) {
            $from = Files::get_path($last_parent->get_reference()) . '/thumbs/' . $file->item['file_name'];
            // make directory thumbs
            $to = $dir . '/thumbs/' . $file->item['file_name'];
            // check that dir exist
            if (!is_dir($dir . '/thumbs')) {
                Safe::mkdir($dir . '/thumbs');
            }
            Safe::rename($from, $to);
        }
    }
}
// we return some JSON
$output = json_encode($output);
// allow for data compression
render_raw('application/json; charset=' . $context['charset']);
// actual transmission except on a HEAD request
if (!isset($_SERVER['REQUEST_METHOD']) || $_SERVER['REQUEST_METHOD'] != 'HEAD') {
    echo $output;
}
// the post-processing hook, then exit
finalize_page(TRUE);
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:move.php

示例3: derive_thumbnail

 /**
  * compute a thumbnail image for a file
  *
  * This function builds a preview image where possible, and returns its URL to caller, or NULL.
  * That result can be saved directly as attribute ##thumbnail_url## or associated file record.
  *
  * @param string path to the file, including trailing slash (e.g., 'files/article/123/')
  * @param string file name (e.g., 'document.pdf')
  * @return string web address of the thumbnail that has been built, or NULL
  *
  * @see files/edit.php
  */
 public static function derive_thumbnail($file_path, $file_name)
 {
     global $context;
     // if the file is an image, create a thumbnail for it
     if (($image_information = Safe::GetImageSize($file_path . $file_name)) && $image_information[2] >= 1 && $image_information[2] <= 3) {
         // derive a thumbnail image
         $thumbnail_name = 'thumbs/' . $file_name;
         include_once $context['path_to_root'] . 'images/image.php';
         Image::shrink($context['path_to_root'] . $file_path . $file_name, $context['path_to_root'] . $file_path . $thumbnail_name, FALSE, TRUE);
         // remember the address of the thumbnail
         return $context['url_to_root'] . $file_path . $thumbnail_name;
         // if this is a PDF that can be converted by Image Magick, then compute a thumbnail for the file
     } else {
         if (preg_match('/\\.pdf$/i', $file_name) && class_exists('Imagick') && ($handle = new Imagick($context['path_to_root'] . $file_path . $file_name))) {
             // derive a thumbnail image
             $thumbnail_name = 'thumbs/' . $file_name . '.png';
             Safe::mkdir($context['path_to_root'] . $file_path . 'thumbs');
             // consider only the first page
             $handle->setIteratorIndex(0);
             $handle->setImageCompression(Imagick::COMPRESSION_LZW);
             $handle->setImageCompressionQuality(90);
             $handle->stripImage(90);
             $handle->thumbnailImage(100, NULL);
             $handle->writeImage($context['path_to_root'] . $file_path . $thumbnail_name);
             // remember the address of the thumbnail
             return $context['url_to_root'] . $file_path . $thumbnail_name;
         }
     }
     // no thumbnail
     return NULL;
 }
开发者ID:rair,项目名称:yacs,代码行数:43,代码来源:files.php


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