Permalink
Browse files

バージョン表記を簡素に。また、実行の度に環境チェックは行わない。

  • Loading branch information...
1 parent d405fb4 commit 465ad4ecf17e179db355cb930b3da23c30c45ed9 @rsky committed Sep 12, 2012
View
@@ -0,0 +1 @@
+*
View
@@ -6,13 +6,11 @@
// バージョン情報
$_conf = array(
- 'p2version' => '1.7.99', // rep2のバージョン
- 'p2expack' => '120300.9999', // 拡張パックのバージョン
- 'p2name' => 'expack', // rep2の名前
- 'p2custom' => '0', // カスタムバージョン
+ 'p2name' => 'rep2-expack', // rep2の名前
+ 'p2version' => '120912.2345', // rep2のバージョン
);
-$_conf['p2ua'] = "{$_conf['p2name']}/{$_conf['p2version']}+{$_conf['p2expack']}";
+$_conf['p2ua'] = "{$_conf['p2name']}/{$_conf['p2version']}";
define('P2_VERSION_ID', sprintf('%u', crc32($_conf['p2ua'])));
@@ -178,14 +176,11 @@ function p2_init()
include P2_LIB_DIR . '/startup.funcs.php';
spl_autoload_register('p2_load_class');
- require_once P2_LIB_DIR . '/wiki/P2UtilWiki.php';
-
- // 動作環境を確認 (要件を満たしているならコメントアウト可)
- p2_check_environment();
+ include P2_LIB_DIR . '/wiki/P2UtilWiki.php';
if ($debug) {
if (!class_exists('Benchmark_Profiler', false)) {
- require 'Benchmark/Profiler.php';
+ include 'Benchmark/Profiler.php';
}
$profiler = new Benchmark_Profiler(true);
// p2_print_memory_usage();
View
@@ -40,12 +40,7 @@
$config_version = '000000.0000';
}
- if ($config_version !== $_conf['p2expack'] && !defined('P2_CLI_RUN')) {
- // 設定の更新
- if ($migrators = p2_check_migration($config_version)) {
- $conf_user = p2_invoke_migrators($migrators, $conf_user);
- }
-
+ if ($config_version !== $_conf['p2version'] && !defined('P2_CLI_RUN')) {
// デフォルト設定を読み込み、ユーザー設定とともにマージ
include P2_CONFIG_DIR . '/conf_user_def.inc.php';
$_conf = array_merge($_conf, $conf_user_def, $conf_user);
@@ -69,7 +64,7 @@
// 新しいユーザー設定をシリアライズして保存
if ($save_conf_user) {
- $conf_save = array('.' => $_conf['p2expack']);
+ $conf_save = array('.' => $_conf['p2version']);
foreach ($conf_user_def as $k => $v) {
$conf_save[$k] = $_conf[$k];
}
@@ -6,6 +6,7 @@
use expack\Console\Command;
require_once __DIR__ . '/Command/Archive.php';
+require_once __DIR__ . '/Command/Check.php';
require_once __DIR__ . '/Command/Update.php';
class Application extends sfConsoleApplication
@@ -19,6 +20,7 @@ public function __construct()
parent::__construct('rep2-expack console script', '1.0');
$this->addCommands(array(
new Command\Archive(),
+ new Command\Check(),
new Command\Update(),
));
}
@@ -0,0 +1,91 @@
+<?php
+
+namespace expack\Console\Command;
+
+use Symfony\Component\Console\Command\Command as sfConsoleCommand;
+use Symfony\Component\Console\Input\InputInterface,
+ Symfony\Component\Console\Output\OutputInterface;
+
+class Check extends sfConsoleCommand
+{
+ /**
+ * (non-PHPdoc)
+ * @see Symfony\Component\Console\Command\Command::configure()
+ */
+ protected function configure()
+ {
+ $this
+ ->setName('check')
+ ->setDescription('Checks the environment');
+ }
+
+ /**
+ * (non-PHPdoc)
+ * @see Symfony\Component\Console\Command\Command::execute()
+ */
+ protected function execute(InputInterface $input, OutputInterface $output)
+ {
+ include \P2_CONFIG_DIR . '/setup_info.php';
+
+ $status = 0;
+
+ $php_version = phpversion();
+
+ if (version_compare($php_version, '5.4.0-dev', '>=')) {
+ $required_version = $p2_required_version_5_4;
+ } else {
+ $required_version = $p2_required_version_5_3;
+ }
+
+ // PHPのバージョン
+ $output->writeln('PHP Version:');
+ $message = " <info>{$php_version}</info>: ";
+ if (version_compare($php_version, $required_version, '>=')) {
+ $message .= '<comment>OK</comment>';
+ } else {
+ $message .= "<error>Requires PHP {$required_version} or later</error>";
+ $status = 1;
+ }
+ $output->writeln($message);
+
+ // 必須拡張モジュール
+ $output->writeln('PHP Extensions:');
+ foreach ($p2_required_extensions as $ext) {
+ $message = " <info>{$ext}</info>: ";
+ if (extension_loaded($ext)) {
+ $message .= '<comment>OK</comment>';
+ } else {
+ $message .= '<error>Not loaded</error>';
+ $status = 1;
+ }
+ $output->writeln($message);
+ }
+
+ // 有効だと動作しないphp.iniディレクティブ
+ $output->writeln('php.ini directives:');
+ foreach ($p2_incompatible_ini_directives as $directive) {
+ $value = ini_get($directive);
+ $message = " <info>{$directive} = {$value}</info>: ";
+ if ($value) {
+ $message .= '<error>Please turn off</error>';
+ $status = 1;
+ } else {
+ $message .= '<comment>OK</comment>';
+ }
+ $output->writeln($message);
+ }
+
+ return $status;
+ }
+}
+
+/*
+ * Local Variables:
+ * mode: php
+ * coding: cp932
+ * tab-width: 4
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
+// vim: set syn=php fenc=cp932 ai et ts=4 sw=4 sts=4 fdm=marker:
View
@@ -3,104 +3,6 @@
* rep2expack - セットアップ用関数群
*/
-// {{{ p2_check_environment()
-
-/**
- * 動作環境を確認する
- *
- * @return bool
- */
-function p2_check_environment()
-{
- include P2_CONFIG_DIR . '/setup_info.php';
-
- $php_version = phpversion();
-
- if (version_compare($php_version, '5.4.0-dev', '>=')) {
- $required_version = $p2_required_version_5_4;
- } else {
- $required_version = $p2_required_version_5_3;
- }
-
- // PHPのバージョン
- if (version_compare($php_version, $required_version, '<')) {
- p2die("PHP {$required_version} 未満では使えません。");
- }
-
- // 必須拡張モジュール
- foreach ($p2_required_extensions as $ext) {
- if (!extension_loaded($ext)) {
- p2die("{$ext} 拡張モジュールがロードされていません。");
- }
- }
-
- // 有効だと動作しないphp.iniディレクティブ
- foreach ($p2_incompatible_ini_directives as $directive) {
- if (ini_get($directive)) {
- p2die("{$directive} が On です。",
- "php.ini で {$directive} を Off にしてください。");
- }
- }
-
- return true;
-}
-
-// }}}
-// {{{ p2_check_migration()
-
-/**
- * マイグレーションの必要があるかどうかをチェック
- *
- * @param string $config_version
- * @return array
- */
-function p2_check_migration($config_version)
-{
- include P2_CONFIG_DIR . '/setup_info.php';
-
- $migrators = array();
- $found = false;
-
- foreach ($p2_changed_versions as $version) {
- if ($found || version_compare($config_version, $version, '<')) {
- $found = true;
- $migrator_name = str_replace('.', '_', $version);
- $migrator_func = 'p2_migrate_' . $migrator_name;
- $migrator_file = '/migrators/' . $migrator_name . '.php';
- $migrators[$migrator_func] = $migrator_file;
- }
- }
-
- if ($found) {
- return $migrators;
- } else {
- return null;
- }
-}
-
-// }}}
-// {{{ p2_invoke_migrators()
-
-/**
- * マイグレーションを実行
- *
- * @param array $migrators マイグレーション関数のリスト
- * @param array $user_config 古いユーザー設定
- * @return array 新しいユーザー設定
- */
-function p2_invoke_migrators(array $migrators, array $user_config)
-{
- global $_conf;
-
- foreach ($migrators as $migrator_func => $migrator_file) {
- include P2_LIB_DIR . $migrator_file;
- $user_config = $migrator_func($_conf, $user_config);
- }
-
- return $user_config;
-}
-
-// }}}
// {{{ p2_load_class()
/**
View
@@ -46,8 +46,7 @@
applyRules();
// ポストされた値 > 現在の値 > デフォルト値 の順で新しい設定を作成する
- $conf_save = array('.' => $_conf['p2expack']);
- $conf_save['p2custom-ver'] = $_conf['p2custom'];
+ $conf_save = array('.' => $_conf['p2version']);
foreach ($conf_user_def as $k => $v) {
if (array_key_exists($k, $_POST['conf_edit'])) {
$conf_save[$k] = $_POST['conf_edit'][$k];
View
@@ -64,7 +64,7 @@
if (!$_conf['ktai']) {
echo <<<EOP
- <script type="text/javascript" src="js/basic.js?{$_conf['p2expack']}"></script>
+ <script type="text/javascript" src="js/basic.js?{$_conf['p2_version_id']}"></script>
<link rel="stylesheet" href="css.php?css=style&amp;skin={$skin_en}" type="text/css">
<link rel="stylesheet" href="css.php?css=edit_conf_user&amp;skin={$skin_en}" type="text/css">
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon">\n
@@ -65,7 +65,7 @@
if (!$_conf['ktai']) {
echo <<<EOP
- <script type="text/javascript" src="js/basic.js?{$_conf['p2expack']}"></script>
+ <script type="text/javascript" src="js/basic.js?{$_conf['p2_version_id']}"></script>
<link rel="stylesheet" href="css.php?css=style&amp;skin={$skin_en}" type="text/css">
<link rel="stylesheet" href="css.php?css=edit_conf_user&amp;skin={$skin_en}" type="text/css">
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon">\n
View
@@ -74,7 +74,7 @@
if (!$_conf['ktai']) {
echo <<<EOP
- <script type="text/javascript" src="js/basic.js?{$_conf['p2expack']}"></script>
+ <script type="text/javascript" src="js/basic.js?{$_conf['p2_version_id']}"></script>
<link rel="stylesheet" href="css.php?css=style&amp;skin={$skin_en}" type="text/css">
<link rel="stylesheet" href="css.php?css=edit_conf_user&amp;skin={$skin_en}" type="text/css">
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon">\n
@@ -66,7 +66,7 @@
if (!$_conf['ktai']) {
echo <<<EOP
- <script type="text/javascript" src="js/basic.js?{$_conf['p2expack']}"></script>
+ <script type="text/javascript" src="js/basic.js?{$_conf['p2_version_id']}"></script>
<link rel="stylesheet" href="css.php?css=style&amp;skin={$skin_en}" type="text/css">
<link rel="stylesheet" href="css.php?css=edit_conf_user&amp;skin={$skin_en}" type="text/css">
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon">\n
View
@@ -168,7 +168,7 @@
<br>
<div class="container">
{$newversion_found}
- <p>rep2-expack rev.{$_conf['p2expack']}; extends rep2-{$_conf['p2version']}<br>
+ <p>{$_conf['p2name']} ver.{$_conf['p2version']}<br>
<a href="{$expack_url_r}"{$_conf['ext_win_target_at']}>{$_conf['expack.web_url']}</a><br>
<a href="{$p2web_url_r}"{$_conf['ext_win_target_at']}>{$_conf['p2web_url']}</a></p>
<ul>
@@ -223,7 +223,7 @@ function checkUpdatan()
//$kita = 'キタ*・゚゚・*:.。..。.:*・゚(゚∀゚)゚・*:.。. .。.:*・゚゚・*!!!!!';
$newversion_found_html = '';
- if ($update_ver && version_compare($update_ver, $_conf['p2expack'], '>')) {
+ if ($update_ver && version_compare($update_ver, $_conf['p2version'], '>')) {
$newversion_found_html = <<<EOP
<div class="kakomi">
{$kita}<br>

0 comments on commit 465ad4e

Please sign in to comment.