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


PHP tools::createDirectory方法代码示例

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


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

示例1: validate

 public function validate($value)
 {
     if (is_array($value) && isset($value['path']) && isset($value['dataURL'])) {
         $fileName = str_replace('..', '', $value['path']);
         /* secure relative path */
         /* find an unused name */
         $fileInfo = pathinfo($fileName);
         $base = $fileInfo['filename'];
         $ext = $fileInfo['extension'];
         $dir = empty($fileInfo['dirname']) ? '' : $fileInfo['dirname'] . '/';
         /*  $fileInfo['dirname'] in case that filename contains a part of dirname */
         $path = PROFILE_PATH . $this->entity->getModule() . '/' . $this->path . '/';
         $nbn = 0;
         while (is_file($path . $fileName)) {
             $fileName = $dir . $base . '_' . $nbn . '.' . $ext;
             $nbn++;
         }
         if (!is_dir($path . $dir)) {
             \tools::createDirectory($path . $fileInfo['dirname'] . '/');
         }
         /* decode dataURL */
         $cut = explode(',', $value['dataURL']);
         $dataURL = $cut[1];
         $dataURL = base64_decode(str_replace(' ', '+', $dataURL));
         /* save and check image */
         if (file_put_contents($path . $fileName, $dataURL)) {
             return $fileName;
         } else {
             return FALSE;
             /* can't write image */
         }
     } else {
         return parent::validate($value);
     }
 }
开发者ID:saitinet,项目名称:parsimony,代码行数:35,代码来源:file.php

示例2: createDirAction

 /**
  * Create directory 
  * @param string $directory
  * @param string $mask
  * @return string 
  */
 protected function createDirAction($directory, $mask = 0755)
 {
     return \tools::createDirectory($directory, $mask = 0755);
 }
开发者ID:saitinet,项目名称:parsimony,代码行数:10,代码来源:module.php

示例3: build

    /**
     * Generates the code to build a module
     * @static function
     * @param string $name module name
     * @param string $title module title
     */
    public static function build($name, $title)
    {
        $reservedKeywords = array('__halt_compiler', 'abstract', 'and', 'array', 'as', 'break', 'callable', 'case', 'catch', 'class', 'clone', 'const', 'continue', 'declare', 'default', 'die', 'do', 'echo', 'else', 'elseif', 'empty', 'enddeclare', 'endfor', 'endforeach', 'endif', 'endswitch', 'endwhile', 'eval', 'exit', 'extends', 'final', 'for', 'foreach', 'function', 'global', 'goto', 'if', 'implements', 'include', 'include_once', 'instanceof', 'insteadof', 'interface', 'isset', 'list', 'namespace', 'new', 'or', 'print', 'private', 'protected', 'public', 'require', 'require_once', 'return', 'static', 'switch', 'throw', 'trait', 'try', 'unset', 'use', 'var', 'while', 'xor');
        if (!is_dir('modules/' . $name) && !is_numeric($name) && !in_array($name, $reservedKeywords)) {
            $name = preg_replace('@[^a-zA-Z0-9]@', '', $name);
            $licence = str_replace('{{module}}', $name, file_get_contents("modules/admin/licence.txt"));
            tools::createDirectory('modules/' . $name);
            $template = '<?php
' . $licence . '

namespace ' . $name . ';

/**
 * @title ' . str_replace('\'', '\\\'', $title) . '
 * @description ' . str_replace('\'', '\\\'', $title) . '
 * @copyright 1
 * @browsers all
 * @php_version_min 5.3
 */

class module extends \\module {
	protected $name = \'' . str_replace('\'', '\\\'', $name) . '\';
}
?>';
            file_put_contents('modules/' . $name . '/module.php', $template);
            include 'modules/' . $name . '/module.php';
            $name2 = $name . '\\module';
            $mod = new $name2($name);
            $page = new \page(1, $name);
            $page->setModule($name);
            $page->setTitle('Index ' . $name);
            $page->setRegex('@^index$@');
            /* Set rights forbidden for non admins, admins are allowed by default */
            foreach (\app::getModule('core')->getEntity('role') as $role) {
                if ($role->permissions == 0) {
                    $mod->setRights($role->id_role, 0);
                    $page->setRights($role->id_role, 0);
                }
            }
            $mod->addPage($page);
            $mod->save();
            $config = new \config('profiles/' . PROFILE . '/config.php', TRUE);
            $config->add('$config[\'modules\'][\'' . $name . '\']', '7');
            return $config->save();
        } else {
            return FALSE;
        }
    }
开发者ID:saitinet,项目名称:parsimony,代码行数:54,代码来源:module.php

示例4: copy

 * @authors Julien Gras et Benoît Lorillot
 * @copyright Julien Gras et Benoît Lorillot
 * 
 * @category Parsimony
 * @package core/blocks
 * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
 */
/* In case the file isn't in PROFILES/ */
$viewPath = $this->getConfig('viewPath');
if (!is_file(PROFILE_PATH . $viewPath) && is_file('modules/' . $viewPath)) {
    \tools::createDirectory(dirname(PROFILE_PATH . $viewPath));
    copy('modules/' . $viewPath, PROFILE_PATH . $viewPath);
}
$this->viewPath = PROFILE_PATH . $this->getConfig('viewPath');
if (!file_exists($this->viewPath)) {
    tools::createDirectory(dirname($this->viewPath));
}
if (!file_exists($this->viewPath)) {
    $this->generateViewAction(array());
}
$view = $this->getConfig('view');
?>
<script src="<?php 
echo BASE_PATH;
?>
lib/jquery-ui/jquery-ui-1.10.3.min.js"></script>
<script type="text/javascript" src="<?php 
echo BASE_PATH;
?>
lib/jsPlumb/jquery.jsPlumb-1.3.16-all-min.js"></script>
<style>
开发者ID:saitinet,项目名称:parsimony,代码行数:31,代码来源:adminView.php

示例5: upload

 /**
  * Upload a file
  * @param string $file
  * @return string|false
  */
 public function upload($file)
 {
     if ($file["error"] == 0) {
         if (!empty($this->target)) {
             if ($file['size'] <= $this->maxSize) {
                 if (empty($this->fileName)) {
                     $this->fileName = strtolower($file['name']);
                 }
                 $fichier_info = pathinfo($this->target . $this->fileName);
                 $extension = strtolower($fichier_info['extension']);
                 $upload_ok = '';
                 foreach ($this->type as $type) {
                     if ($extension == $type || $type == 'all') {
                         $upload_ok = 'ok';
                     }
                 }
                 if (!empty($this->fileName)) {
                     $root = $fichier_info['filename'];
                     $nbn = 0;
                     while (file_exists($this->target . $this->fileName)) {
                         $this->fileName = $root . '_' . $nbn . '.' . $extension;
                         $nbn++;
                     }
                     if ($upload_ok == 'ok') {
                         if (!is_dir($this->target)) {
                             \tools::createDirectory($this->target);
                         }
                         if (!move_uploaded_file($file['tmp_name'], $this->target . $this->fileName)) {
                             throw new \Exception(t('Error : No file Uploaded', FALSE));
                         } else {
                             return $this->fileName;
                         }
                     } else {
                         throw new \Exception(t('Error : The file format is invalid', FALSE));
                     }
                 } else {
                     throw new \Exception(t('Error : the filename can\'t be empty', FALSE));
                 }
             } else {
                 throw new \Exception(t('The uploaded file exceeds the MAX_FILE_SIZE :', FALSE) . ' ' . ceil($this->maxSize / 1024) . ' ko');
             }
         } else {
             throw new \Exception(t('The target folder doesn\'t exist :', FALSE) . $this->target);
         }
     } else {
         throw new \Exception(t('The uploaded file exceeds the MAX_FILE_SIZE :', FALSE) . ' ' . ceil($this->maxSize / 1024) . ' ko');
     }
 }
开发者ID:saitinet,项目名称:parsimony,代码行数:53,代码来源:upload.php

示例6: build

    /**
     * Generates the code to build a block
     * @static 
     * @param string $moduleName Module name where the block is created
     * @param string $blockName Block name to create
     * @param string $extends
     * @param string $configs
     */
    public static function build($moduleName, $blockName, $extends, $configs, $viewPath)
    {
        $moduleName = tools::sanitizeString($moduleName);
        $blockName = tools::sanitizeString($blockName);
        $licence = str_replace('{{module}}', $blockName, file_get_contents("modules/admin/licence.txt"));
        $dir = 'modules/' . $moduleName . '/blocks/' . $blockName;
        tools::createDirectory('modules/' . $moduleName . '/blocks/' . $blockName);
        list($moduleFrom, $b, $nameFrom) = explode('\\', $extends);
        $template = '<?php
' . $licence . '
	
namespace ' . $moduleName . '\\blocks;

/**
 * @title ' . $blockName . '
 * @description ' . $blockName . '
 * @copyright 1
 * @browsers all
 * @php_version_min 5.3
 * @block_category ' . $moduleName . '
 * @modules_dependencies ' . $moduleFrom . ':1
 */

class ' . $blockName . ' extends \\' . $extends . ' {

	public function __construct($id) {
		parent::__construct($id);
		$configs = \'' . $configs . '\';
		$this->configs = unserialize(base64_decode($configs));
	}

	public function getAdminView() {
		ob_start();
		include(\'modules/' . $moduleFrom . '/blocks/' . $nameFrom . '/adminView.php\');
		return ob_get_clean();
	}

}
?>';
        if (is_dir($dir)) {
            file_put_contents('modules/' . $moduleName . '/blocks/' . $blockName . '/block.php', $template);
            file_put_contents('modules/' . $moduleName . '/blocks/' . $blockName . '/icon.png', file_get_contents('modules/' . $moduleFrom . '/blocks/' . $nameFrom . '/icon.png'));
            file_put_contents('modules/' . $moduleName . '/blocks/' . $blockName . '/view.php', file_get_contents($viewPath, FILE_USE_INCLUDE_PATH));
            $return = array('eval' => '', 'notification' => t('Block has been created'), 'notificationType' => 'positive');
        } else {
            $return = array('eval' => '', 'notification' => t('Block has\'nt been created', FALSE), 'notificationType' => 'negative');
        }
        \app::$response->setHeader('X-XSS-Protection', '0');
        \app::$response->setHeader('Content-type', 'application/json');
        return json_encode($return);
    }
开发者ID:saitinet,项目名称:parsimony,代码行数:59,代码来源:block.php

示例7: concatFiles

 /**
  * Concat JS or CSS Files
  * @param array $module
  */
 public function concatFiles(array $files, $format)
 {
     $hash = $format . 'concat_' . md5(implode('', $files));
     $pathCache = 'profiles/' . PROFILE . '/modules/' . app::$config['defaultModule'] . '/' . $hash . '.' . $format;
     $dltCache = '';
     if (!is_file($pathCache) || app::$config['dev']['status'] !== 'prod') {
         ob_start();
         foreach ($files as $file) {
             $pathParts = pathinfo($file, PATHINFO_EXTENSION);
             if ($pathParts === 'js' || $pathParts === 'css') {
                 $path = stream_resolve_include_path($file);
                 if ($path) {
                     if ($_SESSION['permissions'] & 16 && $pathParts === 'css') {
                         echo '.parsimonyMarker{background-image: url(' . $file . ') }' . PHP_EOL;
                     }
                     include $path;
                 }
                 echo PHP_EOL;
                 //in order to split JS script and avoid "}function"
             } else {
                 return FALSE;
             }
         }
         $content = ob_get_clean();
         \tools::createDirectory(dirname($pathCache));
         file_put_contents($pathCache, $content);
         $dltCache = '?' . time();
     }
     return $hash . '.' . $format . $dltCache;
 }
开发者ID:saitinet,项目名称:parsimony,代码行数:34,代码来源:response.php


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