示例#1
0
文件: publish.php 项目: nagumo/Phest
function plugin_button_publish(array $params, Phest $phest)
{
    $phest->registerSection('publish', 'Publish');
    $phest->registerSection('publisherror', 'Publishエラー', array('type' => 'danger'));
    $dir_docs = DIR_PHEST . '/../docs';
    if (!is_dir($dir_docs)) {
        $phest->add('publisherror', 'docs ディレクトリが見つかりません');
        return false;
    }
    File::removeDir($dir_docs);
    mkdir($dir_docs, 0777);
    $phest->add('publish', 'docs/フォルダをクリアしました');
    $dir_production = $phest->getOutputPath('', 'production');
    if (!is_dir($dir_production)) {
        $phest->add('publisherror', 'output/production ディレクトリが見つかりません');
        return false;
    }
    File::copyDir($dir_production, $dir_docs);
    $phest->add('publish', 'docs/フォルダへoutput/productionの内容をコピーしました');
    $path_readme = $dir_docs . '/README.md';
    if (!file_exists($path_readme)) {
        $phest->add('publisherror', 'README.mdが見つかりません');
        echo $path_readme;
        return false;
    }
    rename($dir_docs . '/README.md', DIR_PHEST . '/../README.md');
    $phest->add('publish', 'docs/README.mdをトップへ移動しました');
    rename($dir_docs . '/CHANGELOGS.md', DIR_PHEST . '/../CHANGELOGS.md');
    $phest->add('publish', 'docs/CHANGELOGS.mdをトップへ移動しました');
}
示例#2
0
文件: copydir.php 项目: nagumo/Phest
function plugin_build_copydir(array $params, Phest $phest)
{
    $dir_source = $phest->getSourcePath();
    $from_dpath = $dir_source . '/' . $params['from'];
    $to_dpath = $dir_source . '/' . $params['to'];
    $phest->add('build', '[copydir] <b>' . $from_dpath . '</b> から <b>' . $to_dpath . '</b> へコピー');
    File::copyDir($from_dpath, $to_dpath, true);
    return true;
}
示例#3
0
文件: File.php 项目: nagumo/Phest
 /**
  * ディレクトリごとコピー
  *
  * サブディレクトリ、含まれるファイルも全てコピーする
  *
  * <code>
  * #./test以下を./backup/testにコピー
  * File::copyDir('./test','./backup/test');
  * </code>
  *
  * @param string $source コピー元 (ディレクトリ名)
  * @param string $dest コピー先 (ディレクトリ名)
  * @param bool $overwrite 上書きするか
  * @param mixed $ignore 無視するファイル名のリスト (.svnを指定するとSubVersionを無視)
  * @param mixed $hook_func ファイル、ディレクトリを作成した時にhookする関数名 (call_user_func 形式の引数)
  */
 public static function copyDir($source, $dest, $overwrite = false, $ignore = array(), $hook_func = '')
 {
     $source = rtrim($source, '\\/');
     $dest = rtrim($dest, '\\/');
     if (!is_array($ignore)) {
         $ignore = array($ignore);
     }
     if (!is_dir($dest)) {
         File::buildMakeDir($dest, $hook_func);
     }
     chmod($dest, 0755);
     if ($handle = opendir($source)) {
         while (false !== ($file = readdir($handle))) {
             if ($file != '.' && $file != '..' && !in_array($file, $ignore)) {
                 $path = $source . '/' . $file;
                 if (is_file($path)) {
                     if (!($ovr = is_file($dest . '/' . $file)) || $overwrite) {
                         if (!@copy($path, $dest . '/' . $file)) {
                             ECF::error($path . 'はコピーできません。パーミッションが適切に設定されていない可能性があります');
                         }
                     }
                     if ($hook_func) {
                         call_user_func($hook_func, 'make_file', $dest . '/' . $file, $ovr);
                     }
                 } elseif (is_dir($path)) {
                     if (!is_dir($dest . '/' . $file)) {
                         File::buildMakeDir($dest . '/' . $file, $hook_func);
                         //サブディレクトリを作成
                     }
                     chmod($dest . '/' . $file, 0755);
                     File::copyDir($path, $dest . '/' . $file, $overwrite, $ignore, $hook_func);
                     //再帰呼び出し
                 }
             }
         }
         closedir($handle);
     }
 }
示例#4
0
文件: index.php 项目: nagumo/Phest
if (isset($_GET['site']) and in_array($_GET['site'], $site_list)) {
    $site = $_GET['site'];
} else {
    $site = current($site_list);
}
$buildtype = '';
if (!empty($_GET['build'])) {
    $buildtype = $_GET['build'];
}
//site作成
if (!empty($_GET['create_site'])) {
    $create_site = trim($_GET['create_site']);
    $path_create_site = DIR_SITES . '/' . $create_site;
    if (!file_exists($path_create_site)) {
        File::buildMakeDir(DIR_SITES);
        File::copyDir('./sitetemplates/default', DIR_SITES . '/' . $create_site);
        $path_config_yml = DIR_SITES . '/' . $create_site . '/source/config.yml';
        file_put_contents($path_config_yml, strtr(file_get_contents($path_config_yml), array('{{site}}' => $create_site)));
        header('Location: ?site=' . $create_site);
        exit;
    } else {
        die('すでに ' . $create_site . ' というサイトが存在します');
    }
}
//watch mode
$watch = 0;
if (!empty($_GET['watch'])) {
    header('Content-type:application/json;charset=UTF-8');
    $watch = 1;
} else {
    header('Content-type:text/html;charset=UTF-8');